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): leave map-scripted skirmish ai to its scripts
Olcay Seygan67817700dcdd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4aed74fd8..ea2d87563 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -487,6 +487,7 @@ found and fixed, EA's own, not port damage.**- It steals your tanks. A hijacker costs a few hundred and walks off with whatever it touches, and no computer opponent had ever bought one: not one shipped skirmish plan asks for it. A GLA computer now keeps a thief on call as soon as one of your vehicles comes within walking distance, and sends it at the nearest one rather than the richest, because the Humvee it reaches is worth more than the Overlord it dies halfway to. Black Lotus works the same ground on the same terms: she hacks a vehicle that is already in front of her, and does not cross the map to shut one down for a few seconds.- Nor does it know which start position you took. It used to read that straight off the lobby, for every player, from the first second. Now it works it out: each position it has not looked at is a suspect, and the odds are simply how many opponents are still unaccounted for over how many places they could be - three of you on an eight-position map is 3 in 7 for each. Every empty position its scout crosses off makes the rest likelier, 3 in 6, then 3 in 5. When the numbers meet, it stops looking: three opponents with three places left to be is not a guess, and walking over to confirm it would waste the trip. On a two-player map that is true from the start, so nothing changed there - it never wastes a second hunting for an address it can work out by subtraction. Where it has not worked you out yet, it attacks the position you are most likely to be on, and finds out on arrival.- Nor does it read your base off the map. Where your base is, what it is worth, which supply dock to expand to and where to aim a superweapon all came off a walk of your object list, in the shroud, from the first second of the match. The computer now only counts what it can see, plus the buildings it has already found - buildings do not walk away. Before it has scouted you, all it knows is where you started, which is on the map preview anyway.+- A map that scripts its own computer player, the way Art of Defense maps script their GLA waves, gets that player back. All of the above ran on top of the map's script and pulled the waves off their routes: on AOD Super V the GLA sent 13 bunches of wave units off hunting on their own in one Easy match of 30,000 frames, and it could start a base of its own beside them. Now it plays the map's script and nothing else, as it did in the original game, on every difficulty. Official and random maps leave their computer players to the game's own scripts and play exactly as before.## Superweapons that go where the damage isdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.hindex 243a4fdb7..b000a4b6f 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h@@ -228,6 +228,10 @@ public: // AIPlayer interface, may be overridden by AISkirmishPlayer. jba.virtual void recruitSpecificAITeam(TeamPrototype *teamProto, Real recruitRadius); ///< Builds this team immediately.virtual Bool isSkirmishAI(void) {return false;}+ /** A skirmish AI that plays the fork's own game beside its scripts: economy, base, army, waves and+ * tactics. Not one whose map wrote those scripts itself (an Art of Defense map's waves), which is+ * left to them the way a Challenge or mission opponent is. */+ Bool runsOwnAI(void);virtual Player *getAiEnemy(void) {return NULL;} ///< Solo AI attacks based on scripting. Only skirmish auto-acquires an enemy at this point. jba.virtual Bool checkBridges(Object *unit, Waypoint *way) {return false;}/** Center, Flank or Backdoor: the approach with the least enemy firepower this AI knows about.diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.hindex 54c506b47..8d3bb1c5a 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.h@@ -162,6 +162,9 @@ public:SidesInfo *findSkirmishSideInfo(AsciiString name, Int* index = NULL);void prepareForMP_or_Skirmish(void); // After a map is loaded, save & clear any players.+ /// the map wrote its own scripts for its skirmish players (an Art of Defense map's waves), so+ /// prepareForMP_or_Skirmish left SkirmishScripts.scb unread+ Bool skirmishScriptsFromMap() const { return m_skirmishScriptsFromMap; }/** The skirmish side a computer player on pt copies its scripts from, and in *teams (when asked) the* record its teams are in. Under -modfactions a mod faction takes its own mod's side of the same@@ -214,6 +217,7 @@ protected:TeamsInfoRec m_teamrec;TeamsInfoRec m_skirmishTeamrec;+ Bool m_skirmishScriptsFromMap;/// -modfactions: each mod's SkirmishScripts.scb players and teams; and the standard file's players for/// sides the map has none for. Kept out of m_skirmishSides, which a map's own sides nearly filldiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex fd4123a5e..28899bc3d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -637,7 +637,7 @@ void AIPlayer::checkForSupplyCenter( BuildListInfo *info, Object *bldg )// safe radius, capped at two extra - a centre with three piles beside it can keep more// trucks busy, and one with a single pile cannot.//- if( isSkirmishAI() && getSkillProfile()->m_adaptiveHarvesters )+ if( runsOwnAI() && getSkillProfile()->m_adaptiveHarvesters ){Int warehouses = 0;PartitionFilterAcceptByKindOf supplyOnly( MAKE_KINDOF_MASK( KINDOF_SUPPLY_SOURCE ), KINDOFMASK_NONE );@@ -1339,7 +1339,7 @@ Bool AIPlayer::spotCooling( const Coord3D *pos )// ------------------------------------------------------------------------------------------------void AIPlayer::stageDozer( Object *dozer, const Coord3D *site ){- if( !isSkirmishAI() || !getSkillProfile()->m_stageDozers || dozer->getID() == m_repairDozer )+ if( !runsOwnAI() || !getSkillProfile()->m_stageDozers || dozer->getID() == m_repairDozer )return;AIUpdateInterface *ai = dozer->getAI();if( ai->getDozerAIInterface()->isAnyTaskPending() || !ai->isIdle() )@@ -1368,13 +1368,13 @@ void AIPlayer::stageDozer( Object *dozer, const Coord3D *site )Object *AIPlayer::buildStructureWithDozer(const ThingTemplate *bldgPlan, BuildListInfo *info){// A site given up here lately is left alone until its wait runs out.- if (isSkirmishAI() && spotCooling(info->getLocation())) {+ if (runsOwnAI() && spotCooling(info->getLocation())) {giveUpOnSpot(info);return NULL;}// Find a dozer.Object *dozer = findDozer(info->getLocation());- if (dozer==NULL && isSkirmishAI() && getSkillProfile()->m_economyBuildings && isPowerThin() &&+ if (dozer==NULL && runsOwnAI() && getSkillProfile()->m_economyBuildings && isPowerThin() &&bldgPlan->isKindOf(KINDOF_FS_POWER) && !bldgPlan->isKindOf(KINDOF_CASH_GENERATOR)) {// every dozer busy and the power running out: a Hard AI takes one off whatever it is doing. A China// asked for a plant with 26,000 in the bank and waited 95 seconds, going dark half way, because@@ -1458,12 +1458,12 @@ Object *AIPlayer::buildStructureWithDozer(const ThingTemplate *bldgPlan, BuildLibuildings. No spot now means no building from this entry: giveUpOnSpot drops it orsets it aside, so the rest of the list is not held behind it. */static const Int NEIGHBOURS[8][2] = { {1,0}, {-1,0}, {0,1}, {0,-1}, {1,1}, {-1,1}, {1,-1}, {-1,-1} };- const Int searchRadius = isSkirmishAI() ? SKIRMISH_BUILD_SEARCH_CELLS : BUILD_SEARCH_CELLS;+ const Int searchRadius = runsOwnAI() ? SKIRMISH_BUILD_SEARCH_CELLS : BUILD_SEARCH_CELLS;const Int searchWidth = 2*searchRadius + 1;- const Int probeStride = isSkirmishAI() ? 2 : 1; // the rings tried every other cell for a skirmish AI too+ const Int probeStride = runsOwnAI() ? 2 : 1; // the rings tried every other cell for a skirmish AI too// A home building the skirmish AI asked for stays within the base's edge and away from an// enemy. The flood only tested that the building fits.- const Bool home = isSkirmishAI() && info->isPriorityBuild() && m_baseCenterSet && staysHome(bldgPlan);+ const Bool home = runsOwnAI() && info->isPriorityBuild() && m_baseCenterSet && staysHome(bldgPlan);ICoord2D origin;TheAI->pathfinder()->worldToCell(&pos, &origin);if (m_buildSearchCells.empty() || m_buildSearchPlan != bldgPlan ||@@ -1510,7 +1510,7 @@ Object *AIPlayer::buildStructureWithDozer(const ThingTemplate *bldgPlan, BuildLinewPos.y = pos.y + dy*PATHFIND_CELL_SIZE_F;if (home && sqr(newPos.x - m_baseCenter.x) + sqr(newPos.y - m_baseCenter.y) > sqr(BASE_EDGE_REACH*m_baseRadius)) continue;// a flood from a spot that is itself cut off from the base stays on that ground- if (isSkirmishAI() && !reachableFromBase(&newPos)) continue;+ if (runsOwnAI() && !reachableFromBase(&newPos)) continue;++probes;valid = TheBuildAssistant->isLocationLegalToBuild( &newPos, bldgPlan, angle,BuildAssistant::CLEAR_PATH |@@ -2205,7 +2205,7 @@ Int AIPlayer::superweaponScore( Coord3D *center, Int playerNdx, Real radius, Boo{const Int value = getPlayerSuperweaponValue( center, playerNdx, radius, targetMilitaryUnits, m_player->getPlayerIndex(),strikeEconomyWeight(), strikeThreatWeight() );- if( value <= 0 || !isSkirmishAI() )+ if( value <= 0 || !runsOwnAI() )return value;const UnsignedInt now = TheGameLogic->getFrame();@@ -2231,12 +2231,12 @@ Int AIPlayer::superweaponScore( Coord3D *center, Int playerNdx, Real radius, Boo//----------------------------------------------------------------------------------------------------------Real AIPlayer::strikeEconomyWeight( void ){- return isSkirmishAI() ? getSkillProfile()->m_strikeEconomyWeight : 0.0f;+ return runsOwnAI() ? getSkillProfile()->m_strikeEconomyWeight : 0.0f;}Real AIPlayer::strikeThreatWeight( void ){- return isSkirmishAI() ? getSkillProfile()->m_strikeThreatWeight : 0.0f;+ return runsOwnAI() ? getSkillProfile()->m_strikeThreatWeight : 0.0f;}//----------------------------------------------------------------------------------------------------------@@ -2377,7 +2377,7 @@ Bool AIPlayer::computeSuperweaponTarget(const SpecialPowerTemplate *power, Coord// ponytail: a value pass per armed unit, which is only paid on a frame a superweapon is ready.//Player *enemy = ThePlayerList->getNthPlayer( playerNdx );- if( targetMilitaryUnits && enemy != NULL && isSkirmishAI() && ( strikeThreatWeight() > 0.0f || cash <= 0 ) )+ if( targetMilitaryUnits && enemy != NULL && runsOwnAI() && ( strikeThreatWeight() > 0.0f || cash <= 0 ) ){const Int observerNdx = m_player->getPlayerIndex();Player::PlayerTeamList::const_iterator teamIt;@@ -2736,7 +2736,7 @@ static const ThingTemplate *missingSpotterFor( const Player *player, const TeamPvoid AIPlayer::sendForSpotters( TeamInQueue *team, const Object *gun ){const Int spotters = getSkillProfile()->m_artillerySpotters;- if( !isSkirmishAI() || spotters <= 0 || !gun->getTemplate()->acquiresBeyondVision() )+ if( !runsOwnAI() || spotters <= 0 || !gun->getTemplate()->acquiresBeyondVision() )return;const ThingTemplate *spotter = missingSpotterFor( m_player, team->m_team->getPrototype() );const char *why = spotter == NULL ? "a team kept at home or with its own spotter" : "sends for its spotters";@@ -2933,7 +2933,7 @@ Bool AIPlayer::isAGoodIdeaToBuildTeam( TeamPrototype *proto )* a time, and not for a team still being built, whose spotters sendForSpotters has in hand. */Bool AIPlayer::replaceSpotter( void ){- if( !isSkirmishAI() || getSkillProfile()->m_artillerySpotters <= 0 )+ if( !runsOwnAI() || getSkillProfile()->m_artillerySpotters <= 0 )return false;for( Player::PlayerTeamList::const_iterator t = m_player->getPlayerTeams()->begin(); t != m_player->getPlayerTeams()->end(); ++t ){@@ -3355,7 +3355,7 @@ void AIPlayer::rememberEnemies( void ){const Int me = m_player->getPlayerIndex();const UnsignedInt now = TheGameLogic->getFrame();- if( !isSkirmishAI() || (now + computeUpdatePhase( me, LEDGER_RATE )) % LEDGER_RATE != 0 )+ if( !runsOwnAI() || (now + computeUpdatePhase( me, LEDGER_RATE )) % LEDGER_RATE != 0 )return;for( Int i = 0; i < ThePlayerList->getPlayerCount(); ++i )@@ -3457,7 +3457,7 @@ void AIPlayer::onUnitLost( const Object *obj )const Object *killer = last ? TheGameLogic->findObjectByID( last->in.m_sourceID ) : NULL;if( killer && killer->getContainedBy() )killer = killer->getContainedBy();- if( isSkirmishAI() && !obj->isKindOf( KINDOF_STRUCTURE ) && killer && killer->isKindOf( KINDOF_STRUCTURE ) &&+ if( runsOwnAI() && !obj->isKindOf( KINDOF_STRUCTURE ) && killer && killer->isKindOf( KINDOF_STRUCTURE ) &&m_player->getRelationship( killer->getTeam() ) == ENEMIES )DEBUG_LOG(("AI DEFLOSS frame %d player %d '%s' worth %.0f to '%s'; team '%s' state %d source %d, %.0f from home\n", TheGameLogic->getFrame(),m_player->getPlayerIndex(), obj->getTemplate()->getName().str(), aiCombatPower( obj ), killer->getTemplate()->getName().str(),@@ -3465,16 +3465,16 @@ void AIPlayer::onUnitLost( const Object *obj )obj->getAI() ? (Int)obj->getAI()->getLastCommandSource() : -1,(Real)sqrt( sqr( obj->getPosition()->x - m_baseCenter.x ) + sqr( obj->getPosition()->y - m_baseCenter.y ) )));// what killed a duty Ambulance, from how far, and whether this AI knew of it- if( isSkirmishAI() && isDutyAmbulance( obj ) )+ if( runsOwnAI() && isDutyAmbulance( obj ) )DEBUG_LOG(("AI AMBULANCE frame %d player %d %d killed by '%s' %.0f away, %s, %s\n", TheGameLogic->getFrame(), m_player->getPlayerIndex(),obj->getID(), killer ? killer->getTemplate()->getName().str() : "nothing known",killer ? (Real)sqrt( sqr( killer->getPosition()->x - obj->getPosition()->x ) + sqr( killer->getPosition()->y - obj->getPosition()->y ) ) : -1.0f,killer && observerKnowsAbout( killer, m_player->getPlayerIndex() ) ? "known" : "unseen",killer && killer->isKindOf( KINDOF_AIRCRAFT ) ? "aircraft" : killer && killer->isKindOf( KINDOF_STRUCTURE ) ? "building" : "ground"));- if( isSkirmishAI() && obj->isKindOf( KINDOF_STRUCTURE ) && aiCombatPower( obj ) > 0.0f )+ if( runsOwnAI() && obj->isKindOf( KINDOF_STRUCTURE ) && aiCombatPower( obj ) > 0.0f )DEBUG_LOG(("AI DEFDEAD frame %d player %d '%s' worth %.0f\n", TheGameLogic->getFrame(), m_player->getPlayerIndex(),obj->getTemplate()->getName().str(), aiCombatPower( obj )));- if( !isSkirmishAI() || obj->isKindOf( KINDOF_STRUCTURE ) || team == NULL || team == m_player->getDefaultTeam() )+ if( !runsOwnAI() || obj->isKindOf( KINDOF_STRUCTURE ) || team == NULL || team == m_player->getDefaultTeam() )return;const Real NEAR_SQR = 300.0f * 300.0f;Int alive = 0;@@ -3823,7 +3823,7 @@ Bool AIPlayer::selectTeamToBuild( void )const AIDifficultyProfile *profile = getSkillProfile();AIEnemyComposition enemy;std::vector<AIVisibleEnemy> army;- const Bool skirmish = isSkirmishAI(); // a Challenge or mission opponent picks by priority alone, as EA's did+ const Bool skirmish = runsOwnAI(); // a Challenge or mission opponent picks by priority alone, as EA's didif (skirmish && profile->m_counterCompositionWeight > 0.0f)computeEnemyComposition( &enemy, &army );@@ -4571,7 +4571,7 @@ Object *AIPlayer::findSupplyCenter(Int minimumCash, Bool holdableOnly)// Hard AI's expansion for ten minutes with a free pile one valley over. A safe dock// is preferred, the nearest of them, and the unsafe nearest only when none is safe.// A mission's script picked its piles by hand and keeps EA's nearest.- if (!holdableOnly && isSkirmishAI() && (bestSafeWarehouse==NULL || bestSafeDistSqr>distSqr) &&+ if (!holdableOnly && runsOwnAI() && (bestSafeWarehouse==NULL || bestSafeDistSqr>distSqr) &&isLocationSafe(obj->getPosition(), obj->getTemplate())) {bestSafeWarehouse = obj;bestSafeDistSqr = distSqr;@@ -4829,7 +4829,7 @@ void AIPlayer::buildSpecificAITeam( TeamPrototype *teamProto, Bool priorityBuild}// a share of the attack teams of a side whose guns fire past their own sight takes one of them// (AISideInfo Artillery), when a factory is up to make it: the scripts it runs may name none- const AISideInfo *sideInfo = isSkirmishAI() ? TheAI->getAiData()->findSideInfo( m_player ) : NULL;+ const AISideInfo *sideInfo = runsOwnAI() ? TheAI->getAiData()->findSideInfo( m_player ) : NULL;const ThingTemplate *gun = NULL;if (orders && sideInfo && !sideInfo->m_artillery.empty() && takesArtillery( m_player, teamProto ) &&GameLogicRandomValueReal( 0.0f, 1.0f ) < getSkillProfile()->m_artilleryShare)@@ -4911,7 +4911,7 @@ void AIPlayer::recruitSpecificAITeam(TeamPrototype *teamProto, Real recruitRadiureturn;}}- if (!teamProto->getTemplateInfo()->m_hasHomeLocation && !isSkirmishAI())+ if (!teamProto->getTemplateInfo()->m_hasHomeLocation && !isSkirmishAI()){AsciiString teamStr = "Error : team '";teamStr.concat(teamProto->getName());@@ -5093,6 +5093,12 @@ Int AIPlayer::computeStructureDelay( void )hoardThreshold() );}+//----------------------------------------------------------------------------------------------------------+Bool AIPlayer::runsOwnAI( void )+{+ return isSkirmishAI() && !TheSidesList->skirmishScriptsFromMap();+}+//----------------------------------------------------------------------------------------------------------/*** The bank at which a skirmish AI starts building faster. A Challenge or mission opponent is handed@@ -5100,7 +5106,7 @@ Int AIPlayer::computeStructureDelay( void )*/Int AIPlayer::hoardThreshold( void ){- return isSkirmishAI() ? getSkillProfile()->m_cashHoardThreshold : 0;+ return runsOwnAI() ? getSkillProfile()->m_cashHoardThreshold : 0;}//----------------------------------------------------------------------------------------------------------@@ -5248,7 +5254,7 @@ Bool AIPlayer::shouldHoldForMassing( TeamInQueue *team )Bool AIPlayer::holdReinforcement( Object *obj ){Team *team = obj->getTeam();- if( !isSkirmishAI() || team == NULL || team == m_player->getDefaultTeam() )+ if( !runsOwnAI() || team == NULL || team == m_player->getDefaultTeam() )return FALSE;const TeamTemplateInfo *info = team->getPrototype()->getTemplateInfo();if( info->m_isBaseDefense || info->m_isPerimeterDefense )@@ -5528,7 +5534,7 @@ void AIPlayer::doUpgradesAndSkills( void )case 3: skillset = &sideInfo->m_skillSet4; break;case 4: skillset = &sideInfo->m_skillSet5; break;}- const Bool saves = isSkirmishAI() && getSkillProfile()->m_savesSciencePoints;+ const Bool saves = runsOwnAI() && getSkillProfile()->m_savesSciencePoints;// a Sneaky AI's points go first on whatever unlocks a unit that goes invisibleif (m_persona == AIPERSONA_SNEAKY) {for (Int s = 0; s < skillset->m_numSkills; ++s) {@@ -5657,8 +5663,9 @@ void AIPlayer::update( void )AI_PHASE( AIP_BRIDGE, updateBridgeRepair() ); // Handle any bridge repairs.// Everything below is the skirmish AI's own. A Challenge or mission opponent is handed its money,// its base, its attacks and its superweapon by the map script, which is the whole of its difficulty:- // run on top of that, Kwai's $30000 stood three nuclear silos a minute into the match.- if( isSkirmishAI() )+ // run on top of that, Kwai's $30000 stood three nuclear silos a minute into the match. So is a+ // skirmish seat on a map that scripts it: an Art of Defense GLA left its wave paths for a base.+ if( runsOwnAI() ){AI_PHASE( AIP_SCOUT, doScouting() ); // Keep one unit looking at the map.AI_PHASE( AIP_RETREAT, doRetreats() ); // Break off the fights we are losing.@@ -7879,7 +7886,7 @@ Bool AIPlayer::richestGroundNear( const Coord3D *spot, Real radius, Coord3D *aim//----------------------------------------------------------------------------------------------------------Bool AIPlayer::purchaseQueueOn( void ){- return isSkirmishAI() && getSkillProfile()->m_bankTargetSeconds > 0.0f;+ return runsOwnAI() && getSkillProfile()->m_bankTargetSeconds > 0.0f;}Int AIPlayer::bankTarget( void )@@ -8260,7 +8267,7 @@ Bool AIPlayer::placeNear( const ThingTemplate *tmpl, const Coord3D *center, Real//----------------------------------------------------------------------------------------------------------AsciiString AIPlayer::chooseApproachLabel( const Coord3D *from, const AsciiString &requested, Int pathSuffix ){- if( !isSkirmishAI() || !getSkillProfile()->m_useInfluenceMapForAttackLane || from == NULL )+ if( !runsOwnAI() || !getSkillProfile()->m_useInfluenceMapForAttackLane || from == NULL )return requested;const Int LANE_COUNT = 3;@@ -8296,7 +8303,7 @@ AsciiString AIPlayer::chooseApproachLabel( const Coord3D *from, const AsciiStrin//----------------------------------------------------------------------------------------------------------AsciiString AIPlayer::secondApproachLabel( const Coord3D *from, const AsciiString &taken, Int pathSuffix ){- if( !isSkirmishAI() || !getSkillProfile()->m_useInfluenceMapForAttackLane )+ if( !runsOwnAI() || !getSkillProfile()->m_useInfluenceMapForAttackLane )return AsciiString::TheEmptyString;const Int LANE_COUNT = 3;@@ -8703,7 +8710,7 @@ static void creditAnswer( const ThingTemplate *tmpl, const Player *owner, const//----------------------------------------------------------------------------------------------------------void AIPlayer::defendHome( void ){- if( !isSkirmishAI() )+ if( !runsOwnAI() )return;Int intruders = 0;std::vector<AIVisibleEnemy> army;@@ -8880,7 +8887,7 @@ static void creditWhereNeeded( const ThingTemplate *tmpl, const Player *owner, c//----------------------------------------------------------------------------------------------------------void AIPlayer::answerArmy( void ){- if( !isSkirmishAI() || !m_baseCenterSet || !getSkillProfile()->m_answerArmy ||+ if( !runsOwnAI() || !m_baseCenterSet || !getSkillProfile()->m_answerArmy ||(TheGameLogic->getFrame() + computeUpdatePhase( m_player->getPlayerIndex(), ANSWER_RATE ) + ANSWER_RATE - ANSWER_SLOT_OFFSET) % ANSWER_RATE != 0 )return;if( isBaseUnderAttack() )@@ -9675,7 +9682,7 @@ Bool AIPlayer::isMassUnit( ObjectID id ) constvoid AIPlayer::doMass( void ){const UnsignedInt now = TheGameLogic->getFrame();- if( !isSkirmishAI() || !m_baseCenterSet || !getSkillProfile()->m_massUnit ||+ if( !runsOwnAI() || !m_baseCenterSet || !getSkillProfile()->m_massUnit ||(now + computeUpdatePhase( m_player->getPlayerIndex(), MASS_RATE )) % MASS_RATE != 0 )return;Player *enemy = getAiEnemy();@@ -9975,7 +9982,7 @@ Bool AIPlayer::refuseHold( Team *team, const char *why, Bool logIt )Bool AIPlayer::holdTeamForWave( Team *team, const AsciiString &approach, Int pathSuffix, Bool logRefusal ){// a base being hit keeps what its scripts would send out, on every rung, until the fight at home is over- if( team == NULL || !isSkirmishAI() )+ if( team == NULL || !runsOwnAI() )return FALSE;const TeamTemplateInfo *info = team->getPrototype()->getTemplateInfo();if( info->m_isBaseDefense || info->m_isPerimeterDefense )@@ -10063,7 +10070,7 @@ Bool AIPlayer::holdTeamForWave( Team *team, const AsciiString &approach, Int pat//----------------------------------------------------------------------------------------------------------Bool AIPlayer::gateTeamAttack( Team *team, const char *cause ){- if( team == NULL || !isSkirmishAI() )+ if( team == NULL || !runsOwnAI() )return FALSE;const TeamTemplateInfo *info = team->getPrototype()->getTemplateInfo();if( info->m_isBaseDefense || info->m_isPerimeterDefense )@@ -10313,7 +10320,7 @@ void AIPlayer::doWaves( void )doPersonaRaids();// and an Air, Infantry or Armor AI on every rung: what trainFavoured trains stands on no team, it skips// the scripts' teams short of its kind, and a Hard Infantry USA sent no wave the whole match- if( isSkirmishAI() && ( isKindPersona() ||+ if( runsOwnAI() && ( isKindPersona() ||( ( m_persona == AIPERSONA_ATTACKER || m_persona == AIPERSONA_RUSHER ) && !getSkillProfile()->m_massBeforeAttacking ) ) )personaSortie();sendIdleAttackTeams();@@ -10584,7 +10591,7 @@ struct GunshipRiderBool AIPlayer::loadGunships( void ){- if( !isSkirmishAI() || !m_baseCenterSet )+ if( !runsOwnAI() || !m_baseCenterSet )return FALSE;buyGunshipChinook();GunshipList list;@@ -10827,7 +10834,7 @@ static void collectOccupiedBuildings( Object *obj, void *userData )//----------------------------------------------------------------------------------------------------------void AIPlayer::evacuateBuildings( void ){- if( !isSkirmishAI() )+ if( !runsOwnAI() )return;std::vector<Object *> buildings;m_player->iterateObjects( collectOccupiedBuildings, &buildings );@@ -10879,7 +10886,7 @@ static void addMapSeats( Player *player, const Coord3D *pos, Real radius, std::v//----------------------------------------------------------------------------------------------------------void AIPlayer::garrisonBuildings( void ){- if( !isSkirmishAI() || !m_baseCenterSet )+ if( !runsOwnAI() || !m_baseCenterSet )return;std::vector<Object *> seats;m_player->iterateObjects( findFiringBuilding, &seats );@@ -11275,7 +11282,7 @@ static const Int IDLE_CALLUP_SECONDS[ AISKILL_COUNT ] = { 60, 20, 0 };void AIPlayer::sendIdleAttackTeams( void ){- if( !isSkirmishAI() || !m_baseCenterSet )+ if( !runsOwnAI() || !m_baseCenterSet )return;if( m_pressure != AIPRESSURE_FINISH && !getSkillProfile()->m_massBeforeAttacking ){@@ -11591,7 +11598,7 @@ Real AIPlayer::addHomeStrays( AIGroup *wave ) const//----------------------------------------------------------------------------------------------------------void AIPlayer::sendIdleUnitsHunting( void ){- if( !isSkirmishAI() || !m_baseCenterSet || m_pressure == AIPRESSURE_DEFEND || !readyToPush() )+ if( !runsOwnAI() || !m_baseCenterSet || m_pressure == AIPRESSURE_DEFEND || !readyToPush() )return;const Bool finish = m_pressure == AIPRESSURE_FINISH;const Bool guardsGo = finish &&@@ -12039,7 +12046,7 @@ void AIPlayer::lendDutyChinook( void )void AIPlayer::doShuttles( void ){- if( !isSkirmishAI() || !m_baseCenterSet || m_skillLevel == AISKILL_EASY || measuringWithoutTactics() )+ if( !runsOwnAI() || !m_baseCenterSet || m_skillLevel == AISKILL_EASY || measuringWithoutTactics() )return;if( (TheGameLogic->getFrame() + computeUpdatePhase( m_player->getPlayerIndex(), SHUTTLE_CHECK_RATE )) % SHUTTLE_CHECK_RATE != 0 )return;@@ -12963,7 +12970,7 @@ void AIPlayer::flyRaid( Int slot, const std::vector<AIKnownGun> &guns )void AIPlayer::doHelixes( void ){- if( !isSkirmishAI() || !m_baseCenterSet || m_skillLevel == AISKILL_EASY || measuringWithoutTactics() )+ if( !runsOwnAI() || !m_baseCenterSet || m_skillLevel == AISKILL_EASY || measuringWithoutTactics() )return;if( (TheGameLogic->getFrame() + computeUpdatePhase( m_player->getPlayerIndex(), HELIX_CHECK_RATE )) % HELIX_CHECK_RATE != 0 )return;@@ -13237,7 +13244,7 @@ void AIPlayer::followPatients( void )void AIPlayer::doAmbulances( void ){- if( !isSkirmishAI() || !m_baseCenterSet || m_skillLevel == AISKILL_EASY || measuringWithoutTactics() )+ if( !runsOwnAI() || !m_baseCenterSet || m_skillLevel == AISKILL_EASY || measuringWithoutTactics() )return;if( (TheGameLogic->getFrame() + computeUpdatePhase( m_player->getPlayerIndex(), AMBULANCE_CHECK_RATE )) % AMBULANCE_CHECK_RATE != 0 )return;@@ -14225,7 +14232,7 @@ static const Real SIEGE_SLACK = 60.0f;void AIPlayer::keepSiegeBehind( void ){const Real trail = getSkillProfile()->m_siegeTrail;- if( !isSkirmishAI() || !m_baseCenterSet || trail <= 0.0f )+ if( !runsOwnAI() || !m_baseCenterSet || trail <= 0.0f )return;const Coord3D &base = m_baseCenter;std::vector<Object *> owned;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cppindex deb33e5e8..b583e8d69 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp@@ -122,7 +122,7 @@ void AISkirmishPlayer::processBaseBuilding( void )// A Hard AI in the dark does not wait out the structure timer for its power plant: a USA whose plants a// superweapon took sat dark for two minutes of logic frames with a plant asked for and money coming in.// Once a second rather than every frame, because a pass walks the whole plan.- const Bool darkRush = getSkillProfile()->m_economyBuildings && !m_player->getEnergy()->hasSufficientPower() &&+ const Bool darkRush = runsOwnAI() && getSkillProfile()->m_economyBuildings && !m_player->getEnergy()->hasSufficientPower() &&TheGameLogic->getFrame() % LOGICFRAMES_PER_SECOND == 0;if (m_readyToBuildStructure || darkRush){@@ -131,8 +131,8 @@ void AISkirmishPlayer::processBaseBuilding( void )Bool isPriority = false;// and a Tech AI from Medium up, whose whole plan is the tree and the superweapon at its top, and a// GLA Air one, whose SCUD Storm stands in for the air force it cannot build- const Bool rushBigGuns = getSkillProfile()->m_economyBuildings ||- (m_persona != AIPERSONA_NORMAL && m_skillLevel >= AISKILL_MEDIUM && superweaponIsPlan());+ const Bool rushBigGuns = runsOwnAI() && (getSkillProfile()->m_economyBuildings ||+ (m_persona != AIPERSONA_NORMAL && m_skillLevel >= AISKILL_MEDIUM && superweaponIsPlan()));Bool rushTaken = false;// With the purchase queue the priority entries are taken by its score, the first of the best in// list order, so an early drop zone does not wait behind the scripts' bunkers.@@ -268,7 +268,9 @@ void AISkirmishPlayer::processBaseBuilding( void )(!isPriority || (rushThis && !rushTaken) || planScore > bldgScore) && m_player->canBuild(curPlan);const Bool couldBePower = powerPlan==NULL && curPlan->isKindOf(KINDOF_FS_POWER) &&!curPlan->isKindOf(KINDOF_CASH_GENERATOR) && (isUnderPowered || info->isAutomaticBuild());- const Bool couldBeBuilt = bldgPlan==NULL && info->isAutomaticBuild() && info->isBuildable();+ // The rest of the plan, unasked: a seat its map scripts builds what the scripts ask and the+ // power, as retail's did, or an Art of Defense GLA puts up a base and leaves its waves.+ const Bool couldBeBuilt = runsOwnAI() && bldgPlan==NULL && info->isAutomaticBuild() && info->isBuildable();if (!couldBePriority && !couldBePower && !couldBeBuilt) {continue;}@@ -1226,7 +1228,8 @@ void AISkirmishPlayer::doSurrender( void )const UnsignedInt CHECK_FRAMES = 5 * LOGICFRAMES_PER_SECOND;if( (now + 7 * (UnsignedInt)m_player->getPlayerIndex()) % CHECK_FRAMES != 0 )return;- if( !TheRecorder->isMultiplayer() || !m_player->isPlayableSide() )+ // a seat its map scripts may hold no base by design, an Art of Defense GLA's waves+ if( !TheRecorder->isMultiplayer() || !m_player->isPlayableSide() || !runsOwnAI() )return;// Easy, Medium, Hard.diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cppindex a80a2c8ab..0c54a90ca 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cpp@@ -207,7 +207,7 @@ Int SidesInfo::removeFromBuildList(BuildListInfo *pBuildList)/**SidesList - Constructor.*/-SidesList::SidesList(void) : m_numSides(0), m_numSkirmishSides(0)+SidesList::SidesList(void) : m_numSides(0), m_numSkirmishSides(0), m_skirmishScriptsFromMap(false){}@@ -233,6 +233,7 @@ void SidesList::clear(void){emptySides();emptyTeams();+ m_skirmishScriptsFromMap = false;}@@ -731,6 +732,7 @@ void SidesList::prepareForMP_or_Skirmish(void)gotScripts = true;}}+ m_skirmishScriptsFromMap = gotScripts;loadModSkirmishScripts();if (!gotScripts) {AsciiString path = "data\\Scripts\\SkirmishScripts.scb";