Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameengine): every ai rung calls up idle attack teams
Olcay Seygan5ea7bdba99ce
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 49d7deff2..796c0426b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -399,6 +399,7 @@ found and fixed — EA's own, not port damage.**- Hard sends its attack groups out together. A group too small to be a wave on its own waits on the near side of its base until about seven tanks' worth has gathered, or a minute and a half has passed, and then everything waiting leaves on one road at the pace of its slowest unit. A lone artillery piece or a single bomb truck used to drive across the map by itself, and nearly a third of Hard's units died with barely anyone of their own nearby.- It reads the odds before it attacks. Every attack was sized the same way whoever it was aimed at, so a computer with an army at home went on waiting for a full wave while the enemy across the map had nothing left to fight with. It now weighs its own army against what it has seen of yours, and an army it cannot see it assumes is growing back towards the size of its own. It has to be looking at your buildings before it believes it is ahead. Ahead by about two to one with your base in view, Hard stops waiting and sends each group as it forms. Ahead by about six to one, the computer on any difficulty sends the guards it used to keep at home for the whole match hunting as well, half a minute apart. Outnumbered two to one, Hard and Medium keep their groups at home until twice the usual wave has gathered, and a handful is never sent into an army that size. Two leaks went with it. Units that reached the end of their road into your base used to stop there and wait for something to shoot at them; they now go looking. A group that got reinforcements at home was ordered out again as a whole, which marched the half already fighting in your base back to the middle of the map to start the walk over. Only the ones at home leave now. Over sixteen Hard against Hard matches on Twilight Flame stopped at seventeen minutes, the five that finished took 12 minutes 26 seconds on average where they had taken 13 minutes 55. The other eleven still ran to the stop: the side that is ahead kills units faster than buildings, and a defender with 120,000 in the bank replaces them at its own door. Replays recorded before this change play out differently.- Hard stops piling its army up at home. Its plan only sends an attack group while the signal for the next wave is up, and only a group standing in the base at that moment. A group finished a minute later guarded the base until the signal came round again, and one that fell back from a lost fight guarded it for good: one GLA stood 38 of its Angry Mob by its own buildings with 70,000 in the bank. China's Dragon Tank group never left at all, because the attack order its plan names for it is missing from EA's file. Now any attack group standing idle at home joins the next wave. Rich computers also stopped building extra copies of the groups that only ever guard, four sets of tunnel guards where the plan asked for one. Over eight Hard matches on Twilight Flame, the units standing idle at home late in the match went from 43 to 17, the waves sent went from 134 to 319, and kills went up by a tenth. Replays recorded before this change play out differently.+- Medium and Easy stop piling their army up at home too. A player watched them gather at the edge of their plateau on Twilight Flame and stay there all match, and the fix above had only been made for Hard: one Medium China stood 57 units there with 109,000 in the bank and never attacked once. Now every difficulty calls up the attack groups standing idle at home, Medium every twenty seconds and Easy every minute, and the loose units standing beside them go along. Over two eight-player matches on each, Medium's idle units per player fell from 3.5 to 0.6 and its biggest pile from 57 to 7, while its attacks went from 17 to 80; Easy's attacks went from 2 to 38. Hard came out where it was, 75 attacks against 78. Replays recorded before this change play out differently.- The defenders it trains in a hurry go on to fight. Units a Hard computer bought while its base was being hit belonged to no attack group, so once that fight was over they stood wherever it had left them for the rest of the match. They now leave with the next attack, and any of them stuck out on the map goes hunting. An infantryman sent to take an oil derrick or a tech building could also stop halfway and stand frozen at the door for minutes on end; he finishes the job now. Over sixteen Hard matches on Twilight Flame, the computer's fighting units that had not moved or fired for half a minute went from 5.9 a side to 3.6, and it sent 1,155 attack waves where it had sent 1,079. Replays recorded before this change play out differently.- It puts more harvesters on a supply centre with more piles around it, instead of the same three numbers everywhere.- USA's Chinooks stop collecting over the command center. When the pile beside a supply centre ran out, its Chinooks flew home and hovered, and the computer went on buying new ones for its other centres while those sat idle. It only looked for an idle gatherer when a pile stood right next to the centre, a fraction of how far a Chinook looks. An idle gatherer is now sent to any of its supply centres with a pile inside that gatherer's own range, and nothing new is bought while one stands idle beside a pile that has no room for it.diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex 5e1361575..996747610 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -11036,12 +11036,29 @@ void AIPlayer::sendWave( AIGroup *wave, const AsciiString &approach, Int pathSuf* teams, and sent 319 waves instead of 134.** Against an enemy with next to no army left (AIPRESSURE_FINISH) every rung calls its attack teams up- * this way, and sendIdleUnitsHunting takes the guards. */+ * this way, and sendIdleUnitsHunting takes the guards.+ *+ * Issue #99: it was Hard's alone, and Medium and Easy kept the pile. A Medium China on Twilight Flame+ * stood 57 units at the lip of its plateau at minute fifteen, 109,000 in the bank and not one attack+ * made: its wave teams had come out after the launch window and its strays were in no team at all.+ * So every rung calls its idle attack teams up, the rungs that do not mass on a slower round+ * (IDLE_CALLUP_SECONDS), and the strays standing idle at home go out with a team that leaves. *///----------------------------------------------------------------------------------------------------------+/** How often a rung that does not mass its waves calls up what stands idle at home; 0 is every wave+ * tick, Hard's. */+static const Int IDLE_CALLUP_SECONDS[ AISKILL_COUNT ] = { 60, 20, 0 };+void AIPlayer::sendIdleAttackTeams( void ){- if( !isSkirmishAI() || (m_pressure != AIPRESSURE_FINISH && !getSkillProfile()->m_massBeforeAttacking) || !m_baseCenterSet )+ if( !isSkirmishAI() || !m_baseCenterSet )return;+ if( m_pressure != AIPRESSURE_FINISH && !getSkillProfile()->m_massBeforeAttacking )+ {+ // once a period, without a member for it: doWaves runs every WAVE_CHECK_RATE frames+ const UnsignedInt every = (UnsignedInt)( IDLE_CALLUP_SECONDS[ m_skillLevel ] * LOGICFRAMES_PER_SECOND );+ if( every != 0 && TheGameLogic->getFrame() % every >= (UnsignedInt)WAVE_CHECK_RATE )+ return;+ }// a team standing at home while the base is hit is its garrison: guarding, or idle beside a fight it// will pick up, it is not called awayif( isBaseUnderAttack() )@@ -11095,7 +11112,9 @@ void AIPlayer::sendIdleAttackTeams( void )if( holdTeamForWave( team, center, pathSuffix, FALSE ) )continue;AIGroup *group = TheAI->createGroup();- const Real power = waitingPower( team, group );+ // two statements: both fill the group, and the order of +'s operands is the compiler's+ Real power = waitingPower( team, group );+ power += addHomeStrays( group );Coord3D from;group->getCenter( &from );sendWave( group, chooseApproachLabel( &from, center, pathSuffix ), pathSuffix, 1, power, 0, "calledup" );