Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes vanilla bug/inconsistency in harvester replacement logic #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ShizCalev
Copy link

@ShizCalev ShizCalev commented Jun 7, 2024

Vanilla behavior is SUPPOSED to be that Easy AI are never supposed to replace their harvesters (it's explicitly stated in TD's code for the campaign AI here):

/*
** A computer controlled house will try to build a replacement
** harvester if possible. Never replace harvesters if the game
** is in easy mode.
*/
if (!(GameToPlay == GAME_NORMAL && PlayerPtr->Difficulty == DIFF_EASY) && !IsHuman && (ActiveBScan & STRUCTF_REFINERY) && !(UScan & UNITF_HARVESTER)) {

However, it appears this was accidentally inverted in RA's equivalent build logic - checking if the AI's difficulty is not set to hard, meaning that Hard AI will not replace their harvesters instead. This mistake then got backported to TD for the skirmish AI with the remaster.

This is an obvious inconsistency/mistake resulting in the Hard AI actually being easier to defeat by just targeting their harvesters, and the easy AI being harder than intended.

@ChthonVII
Copy link
Owner

ChthonVII commented Jun 13, 2024

I'm sorry, but I don't think this correct. Take a deeper look at how and when the Difficulty member is set for HouseClass objects.

But one thing first. It sounds like you think this member is the difficulty setting for the multiplayer AI. It's not. If you look in the dll API, you'll discover that the AI difficulty widgets in the multiplayer lobby DO NOTHING. They are never communicated to the dll in any way. In multiplayer, all houses have Difficulty initialized as DIFF_NORMAL which is never changed, and all AI houses have IQ set to max. So there's no bug here in multiplayer in either game, since DIFF_NORMAL is the only value those checks ever see.

In TD single-player, Difficulty is only set for the player. For the AI, it's initialized to DIFF_NORMAL and never changed. [Edit: I was mistaken. No bug here.]

In RA single player, the original code wasn't buggy, but Remastered may have made it so. In the original code, Select_Game() in INIT.CPP would set Scen.Difficulty to the selected value and Scen.CDifficulty to the opposite value. The HouseClass constructor would set all house's Difficulty = Scen.CDifficulty. Then the player's Difficulty would be set to Scen.Difficulty. So the harvester check code is correct. If the AI house is DIFF_HARD, then the player is playing on easy. However, Remastered uses a new function Set_Scenario_Difficulty() that only impacts the player. And I'm not sure if Select_Game() is ever called anymore, so Scen.CDifficulty is staying in its initial DIFF_NORMAL state. Moreover, I'm not sure we want to be setting Scen.CDifficulty anymore because it's going to cause handicap values to get applied, thus changing units stats and probably radically changing the actual experienced difficulty. The best fix is probably to alter Set_Scenario_Difficulty() to also set Difficulty for the AI without setting handicap.

@ChthonVII
Copy link
Owner

Actually, I was mistaken. Logic_Switch_Player_Context(this) doesn't change PlayerPtr in single player. So there's no bug in TD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants