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
feat(ai): turtle choke lines and favoured armies on every rung
Olcay Seygan217abdf6c979
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5e26b5e75..32a7003f3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,14 +13,14 @@ found and fixed — EA's own, not port damage.**- Every computer seat in the skirmish, LAN and online lobbies has a new Personality box beside its team. It says how that player plays, and the difficulty still says how well, so a Hard Turtle and an Easy Turtle play the same way at different strengths.- Normal is the computer player you know, unchanged. The others:- **Attacker** goes out early and often with smaller waves and spends everything it earns.- - **Turtle** builds defences first, holds its army back for a few big late waves and pulls out of fights it is losing.+ - **Turtle** finds the narrow stretch of each road into its base and packs its defences there so they cover each other, rather than ringing its command centre. China mines the guns on that line, GLA lays demo traps in front of it and America leans on Fire Bases. It holds its army back for a few big late waves and pulls out of fights it is losing.- **Economist** puts income and upgrades first and keeps a fatter bank before it spends on the army.- - **Air Force** leans on aircraft, and builds fewer of them when it runs into heavy anti-air.+ - **Air Force** puts up several airfields early and fights mostly from the air, switching aircraft rather than giving up when it meets heavy anti-air. GLA has no airfield, so a GLA Air Force fields rockets instead: Quad Cannons, Rocket Buggies, Scud Launchers and an early Scud Storm.- **Rusher** throws everything into one attack in the first four minutes, then keeps pressing.- **Raider** sends its fastest vehicles after supply trucks, workers and depots the enemy has left unguarded.- **Tech** goes for its tech, general powers and superweapon, and defends until they stand.- - **Infantry** fields cheap infantry in numbers and fills buildings with it.- - **Armor** builds tanks and comes at you in big slow waves.+ - **Infantry** fields a crowd of foot soldiers from two to four barracks, cheap ones mixed with whatever beats the army it has seen, and fills buildings with them.+ - **Armor** builds tanks from several war factories and comes at you in big slow waves.- **Sneaky** prefers stealth units and comes in by the back door or the flank.- **Opportunist** goes for the weakest enemy, and for whoever is already busy fighting someone else.- **Supporter** attacks what its ally attacks and sends its army home to its ally when the ally's base is hit.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ProductionPrerequisite.h b/GeneralsMD/Code/GameEngine/Include/Common/ProductionPrerequisite.hindex e63c9cb49..d0b74c8f6 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/ProductionPrerequisite.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/ProductionPrerequisite.h@@ -70,6 +70,7 @@ public:void resetSciences( void ) { m_prereqSciences.clear(); }void addSciencePrereq( ScienceType science ) { m_prereqSciences.push_back(science); }+ const ScienceVec &getSciencePrereqs( void ) const { return m_prereqSciences; }void resetUnits( void ) { m_prereqUnits.clear(); }void addUnitPrereq( AsciiString units, Bool orUnitWithPrevious );diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ScoreKeeper.h b/GeneralsMD/Code/GameEngine/Include/Common/ScoreKeeper.hindex d4d006348..d2c0a70ff 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/ScoreKeeper.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/ScoreKeeper.h@@ -102,6 +102,7 @@ public:// for battle honor calculation. done once at the end of each online gameInt getTotalUnitsBuilt( KindOfMaskType validMask, KindOfMaskType invalidMask );+ Int getTotalUnitsBuilt( KindOfMaskType validMask, KindOfMaskType invalidMask, Bool (*accept)( const ThingTemplate * ) ) const; ///< ... of templates accept says yes to, for the AI's summary lineInt getTotalObjectsDestroyed( KindOfMaskType validMask, KindOfMaskType invalidMask ) const; ///< of every other player's, for the AI's summary lineprotected:diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.hindex fb917097e..b33b3bf1a 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h@@ -262,6 +262,7 @@ public:* from the logic random stream here, and only then. */void setAIPersonality(AIPersonality persona);AIPersonality getAIPersonality(void) const {return m_persona;}+ Bool superweaponIsPlan(void) const; ///< a Tech AI, or a GLA Air AI whose SCUD Storm stands in for the air force: its first superweapon is rushed/// HEADLESS PERSONA: one line of what this seat's personality did over the match, for ai-batchvoid logPersonaSummary(void);@@ -406,6 +407,7 @@ protected:const std::vector<Coord3D> &turtleChokes(void); ///< the narrowest place on the road in from each start an enemy may be at, nearest first, cached until the base or the starts changeInt guardedChokes(void); ///< how many of turtleChokes this rung fortifiesReal nearestChokeDistance(const Coord3D *pos); ///< straight-line distance to the nearest guarded choke, negative when there is none+ void queueTurtleLine(void); ///< the Turtle's defence pass, on every rung, before the hoard and not while the base is hitvoid queueBaseDefenses(Object *dozer); ///< the next defences the allowance has room for, off this dozer's buttons, each on its best spotvoid fortifyChokes(Object *dozer); ///< a Turtle's mines on the guns at its chokes and demo traps in front of themconst std::vector<UnsignedShort> &groundFromBase(void); ///< AIGroundFlood distance of every pathfind cell from the base center, cached until the center moves@@ -543,7 +545,11 @@ protected:// the personality (AIPersonality) and what it keeps; nothing here is read on a Normal seatconst AIPersonaWeights &personaWeights(void) const; ///< its row, the Attacker's for a Rusher whose rush is out- AIPersonaWeights personaTaste(void) const; ///< ... with an Air one's taste cut by the enemy's known anti-air+ AIPersonaWeights personaTaste(void) const; ///< ... with an Air one's taste cut by the enemy's known anti-air, or turned to vehicles on a side with no airfield+ Int personaShareKind(void) const; ///< the kind (SHARE_* in AIPlayer.cpp) whose share of what it builds this personality is about, -1 for none+ AIPersonaWeights personaKindTaste(void) const; ///< the row, turned to vehicles for an Air AI on a side with no airfield+ Bool sideFlies(void) const; ///< this side's dozers can put up an airfield at all+ Int favouredFactoryScore(const ThingTemplate *tmpl) const; ///< what a personality adds to the purchase score of a factory of its favoured kind, 0 for any other buildingReal wavePower(void) const; ///< what a parked wave waits forUnsignedInt waveMaxHoldFrames(void) const; ///< ... and for how long at mostBool rushPending(void) const; ///< a Rusher whose one big attack has not gone yet@@ -552,6 +558,7 @@ protected:void notePersonaProgress(void); ///< the summary's superweapon frame and the chat's beaten enemiesvoid doPersonaRaids(void); ///< Raider: fast units at the enemy's gatherers, workers and depotsvoid huntGatherers(void); ///< raiders out of the base turn on the nearest known gatherer near them+ void personaSortie(void); ///< Attacker and Rusher on a rung that does not mass: the rush and the regular sorties of what idles at homevoid defendAlly(void); ///< Supporter: idle units at home go to an ally's base when it is hitvoid shareSurplusWithAllies(Int bank, Int target); ///< Economist: who gets what out of the bank (the hook only)AsciiString sneakyLane(const Coord3D *from, const AsciiString &requested, Int pathSuffix); ///< Sneaky: the back door or the flankdiff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cppindex c36d71e45..86c6c46fc 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp@@ -3540,9 +3540,10 @@ Bool Player::canBuildMoreOfType( const ThingTemplate *whatToBuild, Int unitsPerO{SuperweaponDefenseCount count = { 0, 0 };iterateObjects( countSuperweaponDefenses, &count );- // a Tech computer's first superweapon is its plan, and waits for a few guns rather than twelve, Easy the most+ // a Tech computer's first superweapon is its plan, and a GLA Air one's SCUD Storm, and waits for a few+ // guns rather than twelve, Easy the moststatic const Int TECH_FIRST_DEFENSES[ AISKILL_COUNT ] = { 8, 6, 4 };- const Bool techFirst = count.superweapons == 0 && getAIPersonality() == AIPERSONA_TECH &&+ const Bool techFirst = count.superweapons == 0 && m_ai && m_ai->superweaponIsPlan() &&count.defenses >= TECH_FIRST_DEFENSES[ getAISkillLevel() ];if ( !techFirst && SuperweaponDefenseCapRefuses( count.defenses, count.superweapons ) )return false;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cppindex 5b06c1fa1..25e0d84f9 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ScoreKeeper.cpp@@ -170,6 +170,15 @@ Int ScoreKeeper::getTotalUnitsBuilt( KindOfMaskType validMask, KindOfMaskType inreturn count;}+Int ScoreKeeper::getTotalUnitsBuilt( KindOfMaskType validMask, KindOfMaskType invalidMask, Bool (*accept)( const ThingTemplate * ) ) const+{+ Int count = 0;+ for (ObjectCountMap::const_iterator it = m_objectsBuilt.begin(); it != m_objectsBuilt.end(); ++it)+ if (it->first && it->first->isKindOfMulti(validMask, invalidMask) && accept(it->first))+ count += it->second;+ return count;+}+Int ScoreKeeper::getTotalObjectsDestroyed( KindOfMaskType validMask, KindOfMaskType invalidMask ) const{Int count = 0;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex 5bc00c234..af56041dc 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -78,6 +78,7 @@#include "Common/ActionManager.h" // canCaptureBuilding, for the tech buildings#include "GameLogic/Module/SpecialPowerModule.h" // ... and the module that does it#include "GameLogic/Module/SpecialAbilityUpdate.h" // ending a raider's bomb run+#include "GameLogic/Module/StealthUpdate.h" // a unit that goes invisible from the factory#include "GameLogic/Module/CollideModule.h" // ... and the collide that takes a vehicle by touching it#include "GameLogic/Module/ContainModule.h"#include "GameLogic/Module/OpenContain.h" // a seat's own shoot-out flag, asked before a rider exists@@ -1246,7 +1247,7 @@ Object *AIPlayer::buildStructureWithDozer(const ThingTemplate *bldgPlan, BuildLi// Check available funds, and with a Hard AI whether the money is saved for something better.Money *money = m_player->getMoney();const Int cost = bldgPlan->calcCostToBuild(m_player);- if (!purchaseAllowed(bldgPlan->getTemplateID(), cost, purchaseKindOf(bldgPlan), TRUE, bldgPlan->getName())) {+ if (!purchaseAllowed(bldgPlan->getTemplateID(), cost, purchaseKindOf(bldgPlan), TRUE, bldgPlan->getName(), favouredFactoryScore(bldgPlan))) {return NULL;}if ((Int)money->countMoney()<cost) {@@ -3117,25 +3118,53 @@ static AITeamCapability teamCapability( const TeamPrototype *proto, const Playerreturn cap;}-/** A template that can go invisible: it carries a StealthUpdate. */+/** A template that goes invisible from the factory: an innate StealthUpdate. Most of a side carries one+ * that only an upgrade or a scrambler switches on, and those are not a stealthy army. */static Bool templateCanStealth( const ThingTemplate *tmpl ){const ModuleInfo &modules = tmpl->getBehaviorModuleInfo();for( Int m = 0; m < modules.getCount(); ++m )if( modules.getNthName( m ).compareNoCase( "StealthUpdate" ) == 0 )- return TRUE;+ return ( (const StealthUpdateModuleData *)modules.getNthData( m ) )->m_innateStealth;+ return FALSE;+}++/** Some unit that goes invisible from the factory waits on this science: the USA's Pathfinder. */+static Bool unlocksStealthUnit( ScienceType science )+{+ for( const ThingTemplate *tmpl = TheThingFactory->firstTemplate(); tmpl; tmpl = tmpl->friend_getNextTemplate() )+ {+ if( !templateCanStealth( tmpl ) )+ continue;+ for( Int p = 0; p < tmpl->getPrereqCount(); ++p )+ {+ const ScienceVec &sciences = tmpl->getNthPrereq( p )->getSciencePrereqs();+ for( ScienceVec::const_iterator s = sciences.begin(); s != sciences.end(); ++s )+ if( *s == science )+ return TRUE;+ }+ }return FALSE;}static Int personaFavouredKind( const AIPersonaWeights &taste );-/** The share of aircraft an Air AI wants among the units it has built, by rung, before the scripts'- * teams without any are built again. */-static const Real AIR_SHARE_TARGET[ AISKILL_COUNT ] = { 0.25f, 0.35f, 0.45f };+/** The kinds a personality's share is counted in: personaFavouredKind's three, then units that can go+ * invisible (a Sneaky AI's) and a GLA Air AI's rockets and anti-air (isAirAnalogue). */+enum { SHARE_VEHICLE, SHARE_INFANTRY, SHARE_AIR, SHARE_STEALTH, SHARE_AIR_ANALOGUE, SHARE_KINDS };++/** The share of its kind among the units it has built that an Air, Infantry, Armor or Sneaky AI wants,+ * by rung, before the scripts' teams short of that kind are built again. A team under half its cost+ * of the kind is short of it: an infantry team riding a Humvee is still infantry. */+static const Real PERSONA_SHARE_TARGET[ SHARE_KINDS ][ AISKILL_COUNT ] = {+ { 0.50f, 0.65f, 0.75f }, { 0.65f, 0.75f, 0.85f }, { 0.35f, 0.50f, 0.60f }, { 0.30f, 0.40f, 0.50f }, { 0.35f, 0.50f, 0.60f } };+static const Real PERSONA_TEAM_KIND_SHARE = 0.5f;-/** Of the units this player built that fly, walk or drive, the share that flies, by count as the- * HEADLESS PERSONA summary counts it. */-static Real builtAircraftShare( Player *player )+static Bool isAirAnalogue( const ThingTemplate *tmpl );++/** Of the units this player built that fly, walk or drive, the share of one kind (SHARE_*), by count as+ * the HEADLESS PERSONA summary counts it. */+static Real builtKindShare( Player *player, Int kind ){ScoreKeeper *score = player->getScoreKeeper();const KindOfMaskType none = KINDOFMASK_NONE;@@ -3148,9 +3177,17 @@ static Real builtAircraftShare( Player *player )KindOfMaskType notVehicle = air;notVehicle.set( KINDOF_HARVESTER );notVehicle.set( KINDOF_DOZER );- const Int aircraft = score->getTotalUnitsBuilt( air, none );- const Int total = aircraft + score->getTotalUnitsBuilt( ground, air ) + score->getTotalUnitsBuilt( vehicle, notVehicle );- return total > 0 ? INT_TO_REAL( aircraft ) / INT_TO_REAL( total ) : 0.0f;+ Int built[ SHARE_KINDS ];+ built[ SHARE_VEHICLE ] = score->getTotalUnitsBuilt( vehicle, notVehicle );+ built[ SHARE_INFANTRY ] = score->getTotalUnitsBuilt( ground, air );+ built[ SHARE_AIR ] = score->getTotalUnitsBuilt( air, none );+ const Int total = built[ SHARE_VEHICLE ] + built[ SHARE_INFANTRY ] + built[ SHARE_AIR ];+ if( kind == SHARE_STEALTH )+ built[ kind ] = score->getTotalUnitsBuilt( ground, air, templateCanStealth ) + score->getTotalUnitsBuilt( vehicle, notVehicle, templateCanStealth ) ++ score->getTotalUnitsBuilt( air, none, templateCanStealth );+ else if( kind == SHARE_AIR_ANALOGUE )+ built[ kind ] = score->getTotalUnitsBuilt( vehicle, notVehicle, isAirAnalogue );+ return total > 0 ? INT_TO_REAL( built[ kind ] ) / INT_TO_REAL( total ) : 0.0f;}/** What a team prototype is made of, by cost: the shares that fly, walk, drive and can go invisible,@@ -3395,11 +3432,15 @@ Bool AIPlayer::selectTeamToBuild( void )// share of the enemy's known guns that can shoot upconst Bool persona = skirmish && m_persona != AIPERSONA_NORMAL;const AIPersonaWeights taste = persona ? personaTaste() : aiPersonaWeights( AIPERSONA_NORMAL );- // an Air AI under its rung's share of aircraft built skips the scripts' teams with no aircraft in- // them: the taste on the score moved nothing, and every soldier they trained thinned the share- Real aircraftShare = 0.0f;- const Bool skipGround = persona && m_persona == AIPERSONA_AIR && personaFavouredKind( taste ) == 2 &&- ( aircraftShare = builtAircraftShare( m_player ) ) < AIR_SHARE_TARGET[ m_skillLevel ];+ // an Air, Infantry or Armor AI under its rung's share of its kind built skips the scripts' teams+ // short of that kind (not a Sneaky one: a side has one to three units that go invisible, two of them+ // heroes, and skipping for them left it no army at all): the taste on the score moved nothing, and every soldier they trained+ // thinned an Air AI's share, every tank an Infantry AI's+ const Bool kindPersona = persona && ( m_persona == AIPERSONA_AIR || m_persona == AIPERSONA_INFANTRY || m_persona == AIPERSONA_ARMOR );+ const Int favoured = kindPersona ? personaShareKind() : -1;+ Real favouredShare = 0.0f;+ const Bool skipOthers = favoured >= 0 &&+ ( favouredShare = builtKindShare( m_player, favoured ) ) < PERSONA_SHARE_TARGET[ favoured ][ m_skillLevel ];Int skipped = 0;Player::PlayerTeamList candidateList;@@ -3423,7 +3464,11 @@ Bool AIPlayer::selectTeamToBuild( void ){Real air, infantry, vehicle, stealth;teamKindShares( *t, m_player, &air, &infantry, &vehicle, &stealth );- if( skipGround && !isDefenceTeam && air <= 0.0f )+ // a GLA Air AI's rockets and anti-air are vehicles to a team's cost+ const Real teamShare = favoured == SHARE_AIR ? air : favoured == SHARE_INFANTRY ? infantry : favoured == SHARE_STEALTH ? stealth : vehicle;+ // the base guards too: a China Air AI's were half its infantry, and the emergency trainer+ // (defendHome) still answers anything that walks in+ if( skipOthers && teamShare < PERSONA_TEAM_KIND_SHARE ){++skipped;continue;@@ -3448,9 +3493,9 @@ Bool AIPlayer::selectTeamToBuild( void )}if( skipped > 0 )- DEBUG_LOG(("AI PERSONA frame %d player %d skips %d teams with no aircraft, %.2f of what it built flies, %d teams left\n",- TheGameLogic->getFrame(), m_player->getPlayerIndex(), skipped, aircraftShare, count));- if( skipGround && count == 0 )+ DEBUG_LOG(("AI PERSONA frame %d player %d skips %d teams short of its kind, %.2f of what it built is, %d teams left\n",+ TheGameLogic->getFrame(), m_player->getPlayerIndex(), skipped, favouredShare, count));+ if( skipOthers && count == 0 )return false;// pick a random team from the hi-priority set@@ -5036,6 +5081,14 @@ void AIPlayer::doUpgradesAndSkills( void )case 4: skillset = &sideInfo->m_skillSet5; break;}const Bool saves = isSkirmishAI() && getSkillProfile()->m_savesSciencePoints;+ // a Sneaky AI's points go first on whatever unlocks a unit that goes invisible+ if (m_persona == AIPERSONA_SNEAKY) {+ for (Int s = 0; s < skillset->m_numSkills; ++s) {+ const ScienceType science = skillset->m_skills[s];+ if (unlocksStealthUnit(science) && m_player->isCapableOfPurchasingScience(science))+ m_player->attemptToPurchaseScience(science);+ }+ }Int i;for (i=0; i<skillset->m_numSkills; i++) {ScienceType science = skillset->m_skills[i];@@ -5670,7 +5723,7 @@ static const Real TURTLE_CHOKE_GUARD = 500.0f;/** Chokes fortified, the share of Turtle's own defence allowance it stands, the guns at a choke that* buy the mine upgrade and the demo traps laid in front of the line, by rung. */static const Int TURTLE_CHOKES[ AISKILL_COUNT ] = { 1, 2, 3 };-static const Real TURTLE_DEFENSE_SCALE[ AISKILL_COUNT ] = { 0.6f, 0.8f, 1.0f };+static const Real TURTLE_DEFENSE_SCALE[ AISKILL_COUNT ] = { 0.4f, 0.7f, 1.0f };static const Int TURTLE_MINED_GUNS[ AISKILL_COUNT ] = { 2, 4, 8 };static const Int TURTLE_DEMO_TRAPS[ AISKILL_COUNT ] = { 2, 4, 6 };/** Where the chokes are looked for, in base radii from the base by the ground, and never past this@@ -6308,6 +6361,17 @@ static Real unitTaste( const AIPersonaWeights &taste, const ThingTemplate *tmpl* disliked one waits behind the base defences and an upgrade. */static const Int PERSONA_LIKED_SCORE = 10;static const Int PERSONA_DISLIKED_SCORE = -25;+/** A favoured factory goes ahead of the power, dozers and gatherers: an Air AI's second airfield sat on+ * the list from 3.3 minutes to 15, held behind whatever the queue was saving for. */+static const Int PERSONA_FAVOURED_FACTORY_SCORE = 25;++Int AIPlayer::favouredFactoryScore( const ThingTemplate *tmpl ) const+{+ if( m_persona == AIPERSONA_NORMAL )+ return 0;+ const Int favoured = personaFavouredKind( personaKindTaste() );+ return favoured >= 0 && tmpl->isKindOf( PRODUCTION_KIND[ favoured ] ) ? PERSONA_FAVOURED_FACTORY_SCORE : 0;+}static void countFactoryLoad( Object *obj, void *userData ){@@ -6335,13 +6399,14 @@ static FactoryLoad readFactoryLoad( Player *player, KindOfType kind )return load;}-/** Factories of this kind the build list has yet to put up, which go up before any extra one. */-static Int plannedOfKind( Player *player, KindOfType kind )+/** Factories of this kind the build list has yet to put up, which go up before any extra one; with+ * askedOnly, only the ones the AI asked for itself (a priority entry). */+static Int plannedOfKind( Player *player, KindOfType kind, Bool askedOnly = FALSE ){Int planned = 0;for( BuildListInfo *info = player->getBuildList(); info; info = info->getNext() ){- if( info->getObjectID() != INVALID_ID || !info->isBuildable() )+ if( info->getObjectID() != INVALID_ID || !info->isBuildable() || ( askedOnly && !info->isPriorityBuild() ) )continue;const ThingTemplate *tmpl = TheThingFactory->findTemplate( info->getTemplateName(), FALSE );if( tmpl && tmpl->isKindOf( kind ) )@@ -6763,6 +6828,9 @@ void AIPlayer::doEconomy( void ){if( m_player->getEnergy()->hasSufficientPower() )buyEarlyIncome();+ // the Turtle's line is its point on every rung, and the rungs below Hard buy no defences here otherwise+ if( m_persona == AIPERSONA_TURTLE )+ queueTurtleLine();return;}@@ -6799,14 +6867,8 @@ void AIPlayer::doEconomy( void )buyEarlyIncome();- // the Turtle's line goes up before the hoard, unless the base is already being hit- if( m_persona == AIPERSONA_TURTLE && m_player->getCanBuildBase() && m_baseCenterSet && !isBaseUnderAttack() )- {- Object *dozer = NULL;- m_player->iterateObjects( findAnyDozer, &dozer );- if( dozer )- queueBaseDefenses( dozer );- }+ if( m_persona == AIPERSONA_TURTLE )+ queueTurtleLine();// hackers and the buildings that pay out on a timer earn their price back, so they only wait for// the hoard threshold, and each of them is bought on every pass the bank allows one ...@@ -6880,6 +6942,17 @@ void AIPlayer::doEconomy( void )* The Turtle's do not wait for the hoard: its line is what it spends on first, and the purchase* queue saves for each gun. *///----------------------------------------------------------------------------------------------------------+void AIPlayer::queueTurtleLine( void )+{+ // before the hoard, unless the base is already being hit+ if( !m_player->getCanBuildBase() || !m_baseCenterSet || isBaseUnderAttack() )+ return;+ Object *dozer = NULL;+ m_player->iterateObjects( findAnyDozer, &dozer );+ if( dozer )+ queueBaseDefenses( dozer );+}+void AIPlayer::queueBaseDefenses( Object *dozer ){const BaseTally tally = tallyBase( m_player );@@ -7367,7 +7440,7 @@ Bool AIPlayer::buyUnit( ProductionUpdateInterface *pu, const ThingTemplate *unitInt offset = 0;if( m_persona != AIPERSONA_NORMAL && kind == AIBUY_ARMY ){- const Real taste = unitTaste( personaWeights(), unit );+ const Real taste = unitTaste( personaKindTaste(), unit );offset = taste > 0.0f ? PERSONA_LIKED_SCORE : taste < 0.0f ? PERSONA_DISLIKED_SCORE : 0;}if( !purchaseAllowed( unit->getTemplateID(), cost, kind, pu->getProductionCount() == 0, unit->getName(), offset ) )@@ -7447,9 +7520,10 @@ void AIPlayer::buyMoneyUnits( void )Bool AIPlayer::queueExtraFactory( Object *dozer, KindOfType kind ){const ThingTemplate *tmpl = buildableOfKind( dozer, GUI_COMMAND_DOZER_CONSTRUCT, kind );- if( tmpl == NULL || plannedOfKind( m_player, kind ) > 0 )+ if( tmpl == NULL )return FALSE;- // a personality's favoured factory goes up to the rung's count without waiting for a backlog, one at a time+ // a personality's favoured factory goes up to the rung's count without waiting for a backlog, one at a+ // time, and without waiting for the build list's own, which the scripts reach at eight minutesBool favoured = FALSE;if( m_persona != AIPERSONA_NORMAL ){@@ -7460,7 +7534,7 @@ Bool AIPlayer::queueExtraFactory( Object *dozer, KindOfType kind )favoured = load.constructing == 0 && load.finished < PERSONA_FAVOURED_FACTORIES[ m_skillLevel ];}}- if( !favoured && holdsExtraFactory( tmpl ) )+ if( favoured ? plannedOfKind( m_player, kind, TRUE ) > 0 : plannedOfKind( m_player, kind ) > 0 || holdsExtraFactory( tmpl ) )return FALSE;const Object *warehouse = TheGameLogic->findObjectByID( m_curWarehouseID );@@ -7485,6 +7559,10 @@ Bool AIPlayer::holdsExtraFactory( const ThingTemplate *tmpl )if( !tmpl->isKindOf( PRODUCTION_KIND[ k ] ) )continue;const FactoryLoad load = readFactoryLoad( m_player, PRODUCTION_KIND[ k ] );+ // a personality's favoured kind goes up to the rung's count one at a time, backlog or not: an Air+ // AI's plan airfield waited here from 3.3 minutes to 15+ if( favouredFactoryScore( tmpl ) > 0 )+ return load.constructing > 0 || load.finished >= PERSONA_FAVOURED_FACTORIES[ m_skillLevel ];const UnsignedInt since = m_factoryBackedUpSince[ k ];return !aiWantsAnotherFactory( load.finished, load.constructing, load.shallowest,since == 0 ? 0 : TheGameLogic->getFrame() - since );@@ -8299,11 +8377,29 @@ static Real armyMatchup( const ThingTemplate *tmpl, const Player *owner, const s** With a personality's taste, a unit of a kind it likes comes before every other, and an Air one* takes jets as well. */+/** How far the enemy's anti-air may cut an Air AI's taste for aircraft, as a share of it: below this it+ * stopped building air at all, and the owner wants an air force against anti-air too, of the aircraft+ * that trade best with it (the counter pick does that) and with more escorts. */+static const Real AIR_TASTE_FLOOR = 0.5f;+/** The personality's row, an Air one's taste for aircraft cut by the share of the enemy's known guns- * that shoot up (aiPersonaAirBias). */-AIPersonaWeights AIPlayer::personaTaste( void ) const+ * that shoot up (aiPersonaAirBias), never below AIR_TASTE_FLOOR of it. An Air AI whose side has no+ * airfield, the GLA, likes vehicles instead, and its favoured units are its rockets and its anti-air+ * (trainFavoured, isAirAnalogue). */+AIPersonaWeights AIPlayer::personaKindTaste( void ) const{AIPersonaWeights taste = personaWeights();+ if( taste.m_air > 0.0f && !sideFlies() )+ {+ taste.m_vehicle = taste.m_air;+ taste.m_air = 0.0f;+ }+ return taste;+}++AIPersonaWeights AIPlayer::personaTaste( void ) const+{+ AIPersonaWeights taste = personaKindTaste();if( taste.m_air > 0.0f ){std::vector<AIKnownGun> guns;@@ -8312,11 +8408,71 @@ AIPersonaWeights AIPlayer::personaTaste( void ) constfor( size_t g = 0; g < guns.size(); ++g )if( guns[ g ].m_airReach > 0.0f )++antiAir;- taste.m_air = aiPersonaAirBias( taste.m_air, guns.empty() ? 0.0f : INT_TO_REAL( antiAir ) / INT_TO_REAL( (Int)guns.size() ) );+ const Real cut = aiPersonaAirBias( taste.m_air, guns.empty() ? 0.0f : INT_TO_REAL( antiAir ) / INT_TO_REAL( (Int)guns.size() ) );+ taste.m_air = max( cut, AIR_TASTE_FLOOR * taste.m_air );}return taste;}+Int AIPlayer::personaShareKind( void ) const+{+ if( m_persona == AIPERSONA_NORMAL )+ return -1;+ if( m_persona == AIPERSONA_SNEAKY )+ return SHARE_STEALTH;+ if( m_persona == AIPERSONA_AIR && !sideFlies() )+ return SHARE_AIR_ANALOGUE;+ return personaFavouredKind( personaKindTaste() );+}++Bool AIPlayer::superweaponIsPlan( void ) const+{+ return m_persona == AIPERSONA_TECH || ( m_persona == AIPERSONA_AIR && !sideFlies() );+}++static Bool airfieldOnButtons( const Object *builder )+{+ const CommandSet *commandSet = TheCommandStore->findCommandSet( builder->getCommandSetString() );+ for( Int i = 0; commandSet && i < MAX_COMMANDS_PER_SET; ++i )+ {+ const CommandButton *button = commandSet->getCommandButton( i );+ if( button && button->getCommandType() == GUI_COMMAND_DOZER_CONSTRUCT && button->getThingTemplate() &&+ button->getThingTemplate()->isKindOf( KINDOF_FS_AIRFIELD ) )+ return TRUE;+ }+ return FALSE;+}++//----------------------------------------------------------------------------------------------------------+/** Whether this side builds airfields at all, off a dozer's buttons, whatever their prerequisites; TRUE+ * with no dozer to ask, which keeps what the side was doing. */+//----------------------------------------------------------------------------------------------------------+Bool AIPlayer::sideFlies( void ) const+{+ Object *dozer = NULL;+ m_player->iterateObjects( findAnyDozer, &dozer );+ return dozer == NULL || airfieldOnButtons( dozer );+}++/** What stands in for an aircraft in a GLA Air AI's army: a vehicle with a gun that shoots up (a Quad+ * Cannon) or one that reaches like artillery (a Rocket Buggy, a SCUD Launcher), off its own weapons, so+ * every general's variant counts. */+static const Real AIR_ANALOGUE_REACH = 300.0f;++static Bool isAirAnalogue( const ThingTemplate *tmpl )+{+ if( !tmpl->isKindOf( KINDOF_VEHICLE ) || tmpl->isKindOf( KINDOF_AIRCRAFT ) )+ return FALSE;+ const WeaponTemplateSet *set = tmpl->getWeaponTemplateSets().empty() ? NULL : tmpl->findWeaponTemplateSet( WeaponSetFlags() );+ for( Int slot = 0; set && slot < WEAPONSLOT_COUNT; ++slot )+ {+ const WeaponTemplate *weapon = set->getNth( (WeaponSlotType)slot );+ if( weapon && ( ( weapon->getAntiMask() & WEAPON_ANTI_AIRBORNE_VEHICLE ) != 0 || weapon->getUnmodifiedAttackRange() >= AIR_ANALOGUE_REACH ) )+ return TRUE;+ }+ return FALSE;+}+static const ThingTemplate *surplusUnit( Object *factory, const Player *owner, const std::vector<AIVisibleEnemy> &army, Real weight,const AIPersonaWeights *taste = NULL ){@@ -8444,6 +8600,9 @@ void AIPlayer::doSpending( void )* at the building with the shortest queue that offers it, through the purchase queue like everything* else. *///----------------------------------------------------------------------------------------------------------+static const Real PERSONA_UPGRADE_LIKED = 2.0f;+static const Real PERSONA_UPGRADE_DISLIKED = 0.5f;+void AIPlayer::buyUpgradesForArmy( Bool overTarget ){const AIDifficultyProfile *profile = getSkillProfile();@@ -8498,6 +8657,8 @@ void AIPlayer::buyUpgradesForArmy( Bool overTarget )std::vector<Object *> owned;m_player->iterateObjects( collectOwned, &owned );std::vector<Real> covered( upgrades.size(), 0.0f );+ const Bool tasted = m_persona != AIPERSONA_NORMAL;+ const AIPersonaWeights taste = tasted ? personaKindTaste() : aiPersonaWeights( AIPERSONA_NORMAL );std::vector<const ThingTemplate *> fitTemplate; // the fit by template, worked out once a passstd::vector<Real> fitValue;for( std::vector<Object *>::const_iterator o = owned.begin(); o != owned.end(); ++o )@@ -8520,7 +8681,14 @@ void AIPlayer::buyUpgradesForArmy( Bool overTarget )}fit = fitValue[ t ];}- const Real value = aiUpgradeWeight( fights, fit, profile->m_upgradeNonCombatWeight ) * INT_TO_REAL( tmpl->calcCostToBuild( m_player ) );+ Real value = aiUpgradeWeight( fights, fit, profile->m_upgradeNonCombatWeight ) * INT_TO_REAL( tmpl->calcCostToBuild( m_player ) );+ // a personality's upgrades are its kind's: what improves the units it likes counts double, the+ // ones it does not half, so its infantry, armour or air upgrades come first+ if( tasted && fights )+ {+ const Real liking = unitTaste( taste, tmpl );+ value *= liking > 0.0f ? PERSONA_UPGRADE_LIKED : liking < 0.0f ? PERSONA_UPGRADE_DISLIKED : 1.0f;+ }for( size_t u = 0; u < upgrades.size(); ++u )if( obj->affectedByUpgrade( upgrades[ u ] ) )covered[ u ] += value;@@ -8656,12 +8824,16 @@ void AIPlayer::trainSurplus( Int budget )/** How deep a personality with a unit taste keeps its favoured factories' queues, below the bank target, by rung. */static const Int PERSONA_FAVOURED_DEPTH[ AISKILL_COUNT ] = { 1, 2, 2 };-/** The same for the Air AI's airfields: an aircraft costs three to six soldiers, so by count its share- * only climbs with more of them on order. */-static const Int AIR_FAVOURED_DEPTH[ AISKILL_COUNT ] = { 1, 3, 3 };--/** The cheapest armed ground vehicle off this factory's buttons it can make now, the first of two- * alike: a Technical, a Humvee, a Scorpion, the quick ones a Raider sends. Not a worker or a gatherer. */+/** The same for the Air, Infantry and Armor AIs, whose kind is their whole army now that the scripts'+ * teams short of it are skipped (selectTeamToBuild): an aircraft costs three to six soldiers, so by+ * count its share only climbs with more of them on order, and a barracks that trained one soldier at+ * a time could not field a horde. */+static const Int KIND_FAVOURED_DEPTH[ AISKILL_COUNT ] = { 1, 3, 3 };+static const Int INFANTRY_FAVOURED_DEPTH[ AISKILL_COUNT ] = { 2, 3, 4 };++/** The cheapest armed ground unit of a kind off this factory's buttons it can make now, the first of+ * two alike: a Technical, a Humvee, a Scorpion, the quick ones a Raider sends; a Red Guard, a Rebel,+ * a Ranger, the horde an Infantry AI fills its ranks with. Not a worker or a gatherer. */static Bool hasPrimaryWeapon( const ThingTemplate *tmpl ){// a Demo radar van carries only its suicide charge, in the tertiary slot: "can have a weapon" let it@@ -8670,7 +8842,7 @@ static Bool hasPrimaryWeapon( const ThingTemplate *tmpl )return set && set->getNth( PRIMARY_WEAPON ) != NULL;}-static const ThingTemplate *cheapestVehicle( Object *factory, const Player *owner )+static const ThingTemplate *cheapestArmed( Object *factory, const Player *owner, KindOfType kind ){const CommandSet *commandSet = TheCommandStore->findCommandSet( factory->getCommandSetString() );const ThingTemplate *best = NULL;@@ -8681,7 +8853,7 @@ static const ThingTemplate *cheapestVehicle( Object *factory, const Player *owneif( button == NULL || button->getCommandType() != GUI_COMMAND_UNIT_BUILD )continue;const ThingTemplate *tmpl = button->getThingTemplate();- if( tmpl == NULL || !hasPrimaryWeapon( tmpl ) || !tmpl->isKindOf( KINDOF_VEHICLE ) || tmpl->isKindOf( KINDOF_AIRCRAFT ) ||+ if( tmpl == NULL || !hasPrimaryWeapon( tmpl ) || !tmpl->isKindOf( kind ) || tmpl->isKindOf( KINDOF_AIRCRAFT ) ||tmpl->isKindOf( KINDOF_DOZER ) || tmpl->isKindOf( KINDOF_HARVESTER ) || tmpl->isKindOf( KINDOF_MONEY_HACKER ) ||TheBuildAssistant->canMakeUnit( factory, tmpl ) != CANMAKE_OK )continue;@@ -8695,6 +8867,31 @@ static const ThingTemplate *cheapestVehicle( Object *factory, const Player *ownereturn best;}+/** An armed unit this factory can make now that accept takes (a GLA Air AI's isAirAnalogue, a Sneaky+ * AI's templateCanStealth), the cheapest or the dearest, the first of two alike; NULL when it makes none. */+static const ThingTemplate *favouredUnitOf( Object *factory, const Player *owner, Bool (*accept)( const ThingTemplate * ), Bool dearest )+{+ const CommandSet *commandSet = TheCommandStore->findCommandSet( factory->getCommandSetString() );+ const ThingTemplate *best = NULL;+ Int bestCost = 0;+ for( Int i = 0; commandSet && i < MAX_COMMANDS_PER_SET; ++i )+ {+ const CommandButton *button = commandSet->getCommandButton( i );+ if( button == NULL || button->getCommandType() != GUI_COMMAND_UNIT_BUILD )+ continue;+ const ThingTemplate *tmpl = button->getThingTemplate();+ if( tmpl == NULL || !hasPrimaryWeapon( tmpl ) || !accept( tmpl ) || TheBuildAssistant->canMakeUnit( factory, tmpl ) != CANMAKE_OK )+ continue;+ const Int cost = tmpl->calcCostToBuild( owner );+ if( best == NULL || ( dearest ? cost > bestCost : cost < bestCost ) )+ {+ best = tmpl;+ bestCost = cost;+ }+ }+ return best;+}+struct TemplateCount{const ThingTemplate *tmpl;@@ -8719,16 +8916,19 @@ static void countOfTemplate( Object *obj, void *userData )void AIPlayer::trainFavoured( void ){// the opening's economy first; a Raider's raiders a minute before its first sortie- // and an Air AI's from its first airfield: behind the drop-zone wait its first jet came at six minutes+ // and an Air, Infantry or Armor AI's from its first factory of the kind: behind the drop-zone wait its+ // first jet came at six minutes, and the scripts' teams it skips are the rest of its armyconst Bool raider = m_persona == AIPERSONA_RAIDER;- const Bool air = m_persona == AIPERSONA_AIR;+ const Bool sneaky = m_persona == AIPERSONA_SNEAKY;+ const Bool ofItsKind = m_persona == AIPERSONA_AIR || m_persona == AIPERSONA_INFANTRY || m_persona == AIPERSONA_ARMOR || sneaky;if( raider ? TheGameLogic->getFrame() < (UnsignedInt)( ( RAID_START_SECONDS[ m_skillLevel ] - 60 ) * LOGICFRAMES_PER_SECOND )- : !air && !readyToPush() )+ : !ofItsKind && !readyToPush() )return;const AIPersonaWeights taste = personaTaste();const Int favoured = personaFavouredKind( taste );if( favoured < 0 )- return; // an Air AI against heavy anti-air plays without its taste+ return;+ const Bool groundedAir = m_persona == AIPERSONA_AIR && favoured == 0;const KindOfType kind = PRODUCTION_KIND[ favoured ];std::vector<AIVisibleEnemy> army;rememberedArmy( &army );@@ -8741,10 +8941,20 @@ void AIPlayer::trainFavoured( void )continue;++ofKind;ProductionUpdateInterface *pu = (*f)->getProductionUpdateInterface();- if( (Int)pu->getProductionCount() >= ( air ? AIR_FAVOURED_DEPTH : PERSONA_FAVOURED_DEPTH )[ m_skillLevel ] )+ const Int *depth = m_persona == AIPERSONA_INFANTRY ? INFANTRY_FAVOURED_DEPTH : ofItsKind ? KIND_FAVOURED_DEPTH : PERSONA_FAVOURED_DEPTH;+ if( (Int)pu->getProductionCount() >= depth[ m_skillLevel ] )continue;- const ThingTemplate *unit = raider ? cheapestVehicle( *f, m_player )- : surplusUnit( *f, m_player, army, getSkillProfile()->m_counterCompositionWeight, &taste );+ // an Infantry AI's every other soldier is the cheapest one, the horde round the counter picks+ // and a GLA Air AI's its rockets and anti-air, the cheap and the dear ones by turns; a Sneaky AI's+ // whatever goes invisible there, and the counter's pick once that runs out (one Jarmen Kell)+ const Bool turn = ( TheGameLogic->getFrame() / ECONOMY_CHECK_RATE + ofKind ) % 2 == 0;+ const ThingTemplate *unit = raider ? cheapestArmed( *f, m_player, KINDOF_VEHICLE )+ : groundedAir ? favouredUnitOf( *f, m_player, isAirAnalogue, turn )+ : sneaky ? favouredUnitOf( *f, m_player, templateCanStealth, turn )+ : m_persona == AIPERSONA_INFANTRY && turn ? cheapestArmed( *f, m_player, KINDOF_INFANTRY )+ : NULL;+ if( unit == NULL && !raider && !groundedAir )+ unit = surplusUnit( *f, m_player, army, getSkillProfile()->m_counterCompositionWeight, &taste );if( unit == NULL || unitTaste( taste, unit ) <= 0.0f )continue;// a Raider keeps two sorties' worth of its raider, and the rest of the money for the army@@ -9511,6 +9721,8 @@ void AIPlayer::doWaves( void )defendAlly();if( m_persona == AIPERSONA_RAIDER )doPersonaRaids();+ if( ( m_persona == AIPERSONA_ATTACKER || m_persona == AIPERSONA_RUSHER ) && isSkirmishAI() && !getSkillProfile()->m_massBeforeAttacking )+ personaSortie();sendIdleAttackTeams();sendIdleUnitsHunting();keepSiegeBehind();@@ -10509,6 +10721,83 @@ void AIPlayer::sendIdleAttackTeams( void )}}+/** How often an Attacker on a rung that does not mass its waves sends what stands idle at home, by+ * rung; Hard masses, and its waves are the Attacker's knobs already. */+static const Int PERSONA_SORTIE_SECONDS[ AISKILL_COUNT ] = { 120, 75, 0 };++//----------------------------------------------------------------------------------------------------------+/** Easy and Medium do not mass their attack teams, so the Attacker's and the Rusher's wave knobs moved+ * nothing there: a Medium Attacker sent one wave a match to its Normal opponent's three, and a Medium+ * Rusher's rush went at seven and a half minutes with one team of a third of its army. So on those+ * rungs the Rusher sends every fighter at home at its rush time, as one wave, and the Attacker (and the+ * Rusher after its rush) sends what stands idle at home every PERSONA_SORTIE_SECONDS, once it is worth+ * the rung's smallest attack. The base guard teams stay, except for the rush. */+//----------------------------------------------------------------------------------------------------------+void AIPlayer::personaSortie( void )+{+ if( !m_baseCenterSet || isBaseUnderAttack() )+ return;+ Player *enemy = getAiEnemy();+ if( enemy == NULL )+ return;+ const UnsignedInt now = TheGameLogic->getFrame();+ const Bool rush = rushPending();+ if( rush )+ {+ if( now < rushFrame() )+ return;+ }+ else+ {+ const UnsignedInt every = (UnsignedInt)( PERSONA_SORTIE_SECONDS[ m_skillLevel ] * LOGICFRAMES_PER_SECOND );+ // once a period, without a member for it: doWaves runs every WAVE_CHECK_RATE frames+ if( every == 0 || now % every >= (UnsignedInt)WAVE_CHECK_RATE || !readyToPush() )+ return;+ }++ std::vector<Object *> owned;+ m_player->iterateObjects( collectOwned, &owned );+ AIGroup *group = TheAI->createGroup();+ Real power = 0.0f;+ for( std::vector<Object *>::const_iterator o = owned.begin(); o != owned.end(); ++o )+ {+ Object *obj = *o;+ if( obj->isEffectivelyDead() || obj->isKindOf( KINDOF_STRUCTURE ) || obj->isKindOf( KINDOF_IMMOBILE ) ||+ obj->isKindOf( KINDOF_AIRCRAFT ) || obj->getAI() == NULL || obj->isContained() || !obj->isAbleToAttack() ||+ !isAtHome( obj->getPosition() ) || !leavesToFinish( obj ) || isOutOnOrders( obj ) || isFallingBack( obj->getID() ) )+ continue;+ const StateID state = obj->getAI()->getCurrentStateID();+ if( state != AI_IDLE && state != AI_GUARD && state != AI_GUARD_RETALIATE )+ continue;+ // the guard teams stay, except for the rush and a Medium Attacker's sorties: Medium's scripts keep+ // most of its army in them, and a sortie without them was two units+ const TeamTemplateInfo *info = obj->getTeam() ? obj->getTeam()->getPrototype()->getTemplateInfo() : NULL;+ const Bool takesGuards = rush || ( m_persona == AIPERSONA_ATTACKER && m_skillLevel >= AISKILL_MEDIUM );+ if( !takesGuards && info && ( info->m_isBaseDefense || info->m_isPerimeterDefense ) )+ continue;+ group->add( obj );+ power += aiCombatPower( obj );+ }+ if( group->isEmpty() || ( !rush && power < getSkillProfile()->m_minAttackPower ) )+ {+ TheAI->destroyGroup( group );+ return;+ }++ const Int pathSuffix = enemy->getMpStartIndex() + 1;+ Coord3D from;+ group->getCenter( &from );+ const AsciiString approach = chooseApproachLabel( &from, AsciiString( SKIRMISH_CENTER ), pathSuffix );+ if( m_personaWaves == 0 )+ m_firstWaveFrame = now;+ ++m_personaWaves;+ if( rush )+ DEBUG_LOG(("AI PERSONA frame %d player %d rushes with %d units, %.0f power\n", now, m_player->getPlayerIndex(), group->getCount(), power));+ m_rushSent = TRUE;+ personaChat( "Wave" );+ sendWave( group, approach, pathSuffix, 0, power, 0, rush ? "rush" : "sortie" );+}+//----------------------------------------------------------------------------------------------------------/** The default team's fighters standing idle at home join the wave, and what they add to it. defendHome* trains its emergency defenders into that team, and no script ever gives it an order: once the fight@@ -15703,11 +15992,14 @@ void AIPlayer::logPersonaSummary( void )}std::vector<Coord3D> traps;m_player->iterateObjects( collectDemoTraps, &traps );- DEBUG_LOG(("HEADLESS PERSONA %d: %s waves %d defenses %d aircraftShare %.2f infantryShare %.2f vehicleShare %.2f gathererKills %d wouldShare %d superweapon %u firstWave %u chokeDefenses %d chokeDist %.0f chokeMined %d demoTraps %d\n",+ // the share of the kind the personality is about, -1 for one with none (and Normal)+ const Int shareKind = personaShareKind();+ DEBUG_LOG(("HEADLESS PERSONA %d: %s waves %d defenses %d aircraftShare %.2f infantryShare %.2f vehicleShare %.2f gathererKills %d wouldShare %d superweapon %u firstWave %u chokeDefenses %d chokeDist %.0f chokeMined %d demoTraps %d favouredShare %.2f stealthShare %.2f\n",m_player->getPlayerIndex(), aiPersonalityName( m_persona ), m_personaWaves, tallyBase( m_player ).defenses,INT_TO_REAL( aircraft ) * per, INT_TO_REAL( soldiers ) * per, INT_TO_REAL( vehicles ) * per, gathererKills,m_personaShared, m_superweaponFrame, m_firstWaveFrame, chokeDefenses,- measured > 0 ? chokeDistance / INT_TO_REAL( measured ) : 0.0f, chokeMined, (Int)traps.size()));+ measured > 0 ? chokeDistance / INT_TO_REAL( measured ) : 0.0f, chokeMined, (Int)traps.size(),+ shareKind >= 0 ? builtKindShare( m_player, shareKind ) : -1.0f, builtKindShare( m_player, SHARE_STEALTH )));}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cppindex 38f71a402..be7f5a59a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp@@ -129,9 +129,10 @@ void AISkirmishPlayer::processBaseBuilding( void )const ThingTemplate *bldgPlan=NULL;BuildListInfo *bldgInfo = NULL;Bool isPriority = false;- // and a Tech AI from Medium up, whose whole plan is the tree and the superweapon at its top+ // 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 buildconst Bool rushBigGuns = getSkillProfile()->m_economyBuildings ||- (m_persona == AIPERSONA_TECH && m_skillLevel >= AISKILL_MEDIUM);+ (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.@@ -258,7 +259,7 @@ void AISkirmishPlayer::processBaseBuilding( void )(powerThin && curPlan->isKindOf(KINDOF_FS_POWER) && !curPlan->isKindOf(KINDOF_CASH_GENERATOR)));const AIPurchaseKind planKind = purchaseKindOf(curPlan);const Int planScore = byScore ? aiPurchaseScore(planKind, earlyGame) +- (m_persona != AIPERSONA_NORMAL ? personaWeights().m_buy[planKind] : 0) : 0;+ (m_persona != AIPERSONA_NORMAL ? personaWeights().m_buy[planKind] + favouredFactoryScore(curPlan) : 0) : 0;const Bool couldBePriority = info->isPriorityBuild() &&(!isPriority || (rushThis && !rushTaken) || planScore > bldgScore) && m_player->canBuild(curPlan);const Bool couldBePower = powerPlan==NULL && curPlan->isKindOf(KINDOF_FS_POWER) &&