Skip to content

Commit 98514e7

Browse files
2 parents 7b2fd48 + 7667ee0 commit 98514e7

13 files changed

Lines changed: 911 additions & 20 deletions

File tree

GeneralsMD/Code/GameEngine/Include/Common/Player.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,12 @@ class Player : public Snapshot
605605
/// Build base defense on front or flank of base. Gets passed to aiPlayer.
606606
void buildBaseDefense(Bool flank);
607607

608+
/// @-TanSo-: Build base defense on front or flank of base based on our vector. Gets passed to aiPlayer.
609+
void buildBaseDefenseFromVector(Bool flank, Real rotation, Real percent);
610+
void buildBaseDefenseFromVectorAtPlayer(Bool flank, Real rotation, Real percent, const AsciiString& playerName);
611+
void addAIBaseDefenseToVector(const AsciiString& objectType);
612+
void removeAIBaseDefenseFromVector(const AsciiString& objectType);
613+
608614
/// Build structure type on front or flank of base. Gets passed to aiPlayer.
609615
void buildBaseDefenseStructure(const AsciiString &thingName, Bool flank);
610616

GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class AISideInfo : public MemoryPoolObject
104104
{
105105
m_side.clear();
106106
m_baseDefenseStructure1.clear();
107+
m_baseDefenseStructures.clear();
107108
}
108109

109110
AsciiString m_side; ///< Name of the side
@@ -118,7 +119,10 @@ class AISideInfo : public MemoryPoolObject
118119
TSkillSet m_skillSet3;
119120
TSkillSet m_skillSet4;
120121
TSkillSet m_skillSet5;
122+
TSkillSet m_skillSet6;
123+
TSkillSet m_skillSet7;
121124
AsciiString m_baseDefenseStructure1;
125+
std::vector<AsciiString> m_baseDefenseStructures; // @-TanSo-: why not be able to let the user of the World Builder specify more than one base defense structure?
122126
AISideInfo *m_next;
123127
};
124128
EMPTY_DTOR(AISideInfo)

GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ class AIPlayer : public MemoryPoolObject,
181181
virtual void buildSpecificAITeam(TeamPrototype *teamProto, Bool priorityBuild); ///< Builds this team immediately.
182182

183183
virtual void buildAIBaseDefense(Bool flank); ///< Builds base defense on front or flank of base.
184+
virtual void buildAIBaseDefenseFromVector(Bool flank, Real rotation, Real percent); // @-TanSo-: for whatever reason we need to put this into THIS public section...
185+
virtual void buildAIBaseDefenseFromVectorAtPlayer(Bool flank, Real rotation, Real percent, const AsciiString& playerName);
186+
virtual void addAIBaseDefenseToVector(const AsciiString& objectType);
187+
virtual void removeAIBaseDefenseFromVector(const AsciiString& objectType);
184188

185189
virtual void buildAIBaseDefenseStructure(const AsciiString &thingName, Bool flank); ///< Builds base defense on front or flank of base.
186190

@@ -227,11 +231,12 @@ class AIPlayer : public MemoryPoolObject,
227231
//---------------------------------- @CLP_AI AIPLAYER ADDITIONS -----------------------------------
228232
//-------------------------------------------------------------------------------------------------
229233
void buildSpecificBuildingNearestTeamAngle(const AsciiString& thingName, const Team* team, Real bAngle);
230-
231234
void buildBySuppliesAngle(Int minimumCash, const AsciiString& thingName, Real bAngle);
232-
233235
void buildSpecificBuildingNearestObjectAngle(const AsciiString& thingName, const Object* bestObj, Real bAngle);
234236

237+
Coord3D getSkirmishBuildListBaseCenter();
238+
Real getSkirmishBuildListBaseRadius();
239+
235240
//-------------------------------------------------------------------------------------------------
236241
//-------------------------------- @CLP_AI AIPLAYER ADDITIONS END ---------------------------------
237242
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Include/GameLogic/AISkirmishPlayer.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ class AISkirmishPlayer : public AIPlayer
7272

7373
virtual Player *getAiEnemy(); ///< Solo AI attacks based on scripting. Only skirmish auto-acquires an enemy at this point. jba.
7474

75+
virtual void buildAIBaseDefenseFromVector(Bool flank, Real rotation, Real percent); ///< Do the same as buildAIBaseDefense, but use the vector and randomize the outcome.
76+
virtual void buildAIBaseDefenseFromVectorAtPlayer(Bool flank, Real rotation, Real percent, const AsciiString& playerName);
77+
virtual void buildAIBaseDefenseStructureFromVector(const AsciiString& thingName, Bool flank, Real rotation, Real percent);
78+
virtual void buildAIBaseDefenseStructureFromVectorAtPlayer(const AsciiString& thingName, Bool flank, Real rotation, Real percent, const AsciiString& playerName);
79+
virtual void addAIBaseDefenseToVector(const AsciiString &thingName);
80+
virtual void removeAIBaseDefenseFromVector(const AsciiString& thingName);
81+
82+
Int getCurrentFrontBaseDefense();
83+
Int getCurrentFlankBaseDefense();
84+
Real getCurrentFrontLeftDefenseAngle();
85+
Real getCurrentFrontRightDefenseAngle();
86+
Real getCurrentLeftFlankLeftDefenseAngle();
87+
Real getCurrentLeftFlankRightDefenseAngle();
88+
Real getCurrentRightFlankLeftDefenseAngle();
89+
Real getCurrentRightFlankRightDefenseAngle();
90+
7591
protected:
7692

7793
// snapshot methods

GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,13 @@ class ScriptActions : public ScriptActionsInterface
450450
void doPlayerSellAllBuildingsArea(const AsciiString& playerName, const AsciiString& triggerArea);
451451
void doPlayerSellAllBuildingsTypeArea(const AsciiString& playerName, const AsciiString& objectType, const AsciiString& triggerArea);
452452

453-
// @-TanSo-: 53 additions
453+
void doAIPlayerBuildDefenseStructureFromVector(Bool flank, Real rotation, Real percent);
454+
void doAIPlayerBuildDefenseStructureFromVectorAtPlayer(Bool flank, Real rotation, Real percent, const AsciiString& playerName);
455+
void doAIPlayerAddBaseDefenseStructure(const AsciiString& objectType);
456+
void doAIPlayerRemoveBaseDefenseStructure(const AsciiString& objectType);
457+
458+
459+
// @-TanSo-: 56 additions
454460
//-------------------------------------------------------------------------------------------------
455461
//----------------------------- @CLP_AI SCRIPT ACTION ADDITIONS END -------------------------------
456462
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptConditions.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ class ScriptConditions : public ScriptConditionsInterface
203203
Bool evaluatePlayerDestroyedEnemyType(Parameter* pPlayerParm, Parameter* pObjectType);
204204
Bool evaluatePlayerDestroyedEnemyUnit(Parameter* pPlayerParm);
205205
Bool evaluatePointControlled(Player* player, const Coord3D& point, Real radius); //@-TanSo-: helper method for evaluate(Relation)MapControl.
206-
Bool evaluateMapControl(Parameter* pPlayerParm, Parameter* pComparisonParm, Real value);
207-
Bool evaluateRelationMapControl(Parameter* pPlayerParm, Int relationType, Parameter* pComparisonParm, Real value);
206+
Bool evaluateMapControl(Parameter* pPlayerParm, Parameter* pComparisonParm, Real pValue);
207+
Bool evaluateRelationMapControl(Parameter* pPlayerParm, Int relationType, Parameter* pComparisonParm, Real pValue);
208+
Bool evaluateMapControlArea(Parameter* pPlayerParm, Parameter* pComparisonParm, Real pValue, Parameter* pTriggerParm);
209+
Bool evaluateRelationMapControlArea(Parameter* pPlayerParm, Int relationType, Parameter* pComparisonParm, Real pValue, Parameter* pTriggerParm);
208210
Bool evaluateTeamLostType(Parameter* pTeamParm, Parameter* objectType);
209211
Bool evaluateTeamLostUnit(Parameter* pTeamParm);
210212
Bool evaluatePlayerSightedRelationType(Parameter* pPlayerParm, Int relationType, Parameter* pObjectType);
@@ -217,7 +219,7 @@ class ScriptConditions : public ScriptConditionsInterface
217219
Bool evaluatePlayerBuildingBeingCapturedArea(Parameter* pPlayerParm, Parameter* pTriggerParm);
218220
Bool evaluatePlayerBuildingBeingCapturedTypeArea(Parameter* pPlayerParm, Parameter* objectType, Parameter* pTriggerParm);
219221

220-
// @-TanSo-: 30 additions, 1 helper method
222+
// @-TanSo-: 32 additions, 1 helper method
221223
//-------------------------------------------------------------------------------------------------
222224
//---------------------------- @CLP_AI SCRIPT CONDITION ADDITIONS END -----------------------------
223225
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Include/GameLogic/Scripts.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,13 @@ class ScriptAction : public MemoryPoolObject // This is the action class.
568568
AI_PLAYER_BUILD_TYPE_NEAREST_KINDOF_ROTATED, ///< AI player builds a structure near a kindOf rotated <Real> degrees.
569569
AI_PLAYER_BUILD_TYPE_NEAREST_TEAM_ROTATED, ///< AI player builds a structure near a team rotated <Real> degrees.
570570
AI_PLAYER_BUILD_TYPE_NEAREST_SUPPLY_ROTATED, ///< AI player builds a structure near a supply source rotaded <Real> degrees.
571-
/*TODO*/AI_PLAYER_BUILD_TYPE_AT_BACKDOOR, ///< AI player builds a structure at the back door path.
572-
/*TODO*/AT_PLAYER_BUILD_TYPE_AT_SPECIAL, ///< AI player builds a structure at the special path.
573-
/*TODO*/AI_PLAYER_BUILD_TYPE_AT_PERCENT_FRONT, ///< AI player builds a structure at <Real> percent distance between spot and outskirts at the center path.
574-
/*TODO*/AI_PLAYER_BUILD_TYPE_AT_PERCENT_FLANK, ///< AI player builds a structure at <Real> percent distance between spot and outskirts at the flank path.
575-
/*TODO*/AI_PLAYER_BUILD_TYPE_AT_PERCENT_BACKDOOR, ///< AI player builds a structure at <Real> percent distance between spot and outskirts at the back door path.
576-
/*TODO*/AI_PLAYER_BUILD_TYPE_AT_PERCENT_SPECIAL, ///< AI player builds a structure at <Real> percent distance between spot and outskirts at the special path.
571+
AI_PLAYER_BUILD_DEFENSE_FRONT_FROM_VECTOR_ROTATED_PERCENT, ///< AI player builds a defensive structure on the front from our vector, rotated <Real> degrees, and at a distance of <Real> percent of our actual base boundaries.
572+
AI_PLAYER_BUILD_DEFENSE_FLANK_FROM_VECTOR_ROTATED_PERCENT, ///< AI player builds a defensive structure on the flank from our vector, rotated <Real> degrees, and at a distance of <Real> percent of our actual base boundaries.
573+
574+
AI_PLAYER_ADD_DEFENSE_TO_VECTOR, ///< add a defensive structure to m_baseDefenseStructures.
575+
AI_PLAYER_REMOVE_DEFENSE_FROM_VECTOR, ///< remove a defensive structure from m_baseDefenseStructures.
576+
AI_PLAYER_BUILD_DEFENSE_FRONT_FROM_VECTOR_ROTATED_PERCENT_AT_PLAYER,///< AI player builds a defensive structure on the front from our vector, rotated <Real> degrees, and at a distance of <Real> percent of a player's actual base boundaries.
577+
AI_PLAYER_BUILD_DEFENSE_FLANK_FROM_VECTOR_ROTATED_PERCENT_AT_PLAYER,///< AI player builds a defensive structure on the flank from our vector, rotated <Real> degrees, and at a distance of <Real> percent of a player's actual base boundaries.
577578

578579
PLAYER_SURRENDER, ///< The player surrenders, provided that other allied players are alive; otherwise quit.
579580
PLAYER_MERGE_KINDOF, ///< The player merges all units with <kindOf> into another team.
@@ -1121,6 +1122,8 @@ class Condition : public MemoryPoolObject // This is the conditional class.
11211122

11221123
PLAYER_MAPCONTROL, // True if a player's map control is <comparison> <Real>.
11231124
PLAYER_RELATION_MAPCONTROL, // True if all <relation> player's map control is <comparison> <Real>.
1125+
PLAYER_MAPCONTROL_AREA, // True if a player's map control in an area is <comparison> <Real>.
1126+
PLAYER_RELATION_MAPCONTROL_AREA, // True if all <relation> player's map control in an area is <comparison> <Real>.
11241127

11251128
PLAYER_SIGHTED_RELATION_TYPE, // True if a player has sighted a <relation> unit of <type>.
11261129
RELATION_PLAYER_SIGHTED_RELATION_TYPE, // True if a <relation> player has sighted a <relation> unit of <type>.

GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4614,6 +4614,43 @@ void Player::buildSpecificBuildingNearestObjectAngle(const AsciiString& thingNam
46144614
}
46154615
}
46164616

4617+
//-------------------------------------------------------------------------------------------------
4618+
void Player::buildBaseDefenseFromVector(Bool flank, Real rotation, Real percent)
4619+
{
4620+
if (m_ai)
4621+
{
4622+
// Do a priority build.
4623+
m_ai->buildAIBaseDefenseFromVector(flank, rotation, percent);
4624+
}
4625+
}
4626+
4627+
//-------------------------------------------------------------------------------------------------
4628+
void Player::buildBaseDefenseFromVectorAtPlayer(Bool flank, Real rotation, Real percent, const AsciiString& playerName)
4629+
{
4630+
if (m_ai)
4631+
{
4632+
// Do a priority build.
4633+
m_ai->buildAIBaseDefenseFromVectorAtPlayer(flank, rotation, percent, playerName);
4634+
}
4635+
}
4636+
4637+
//-------------------------------------------------------------------------------------------------
4638+
void Player::addAIBaseDefenseToVector(const AsciiString& objectType)
4639+
{
4640+
if (m_ai)
4641+
{
4642+
m_ai->addAIBaseDefenseToVector(objectType);
4643+
}
4644+
}
4645+
4646+
//-------------------------------------------------------------------------------------------------
4647+
void Player::removeAIBaseDefenseFromVector(const AsciiString& objectType)
4648+
{
4649+
if (m_ai)
4650+
{
4651+
m_ai->removeAIBaseDefenseFromVector(objectType);
4652+
}
4653+
}
46174654

46184655
//-------------------------------------------------------------------------------------------------
46194656
//--------------------------------- @CLP_AI PLAYER ADDITIONS END ----------------------------------

GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,6 +3062,12 @@ void AIPlayer::doUpgradesAndSkills()
30623062
limit = 3;
30633063
if (sideInfo->m_skillSet5.m_numSkills>0) {
30643064
limit = 4;
3065+
if (sideInfo->m_skillSet6.m_numSkills > 0) {
3066+
limit = 5;
3067+
if (sideInfo->m_skillSet7.m_numSkills > 0) {
3068+
limit = 6;
3069+
}
3070+
}
30653071
}
30663072
}
30673073
}
@@ -3083,6 +3089,8 @@ void AIPlayer::doUpgradesAndSkills()
30833089
case 2: skillset = &sideInfo->m_skillSet3; break;
30843090
case 3: skillset = &sideInfo->m_skillSet4; break;
30853091
case 4: skillset = &sideInfo->m_skillSet5; break;
3092+
case 5: skillset = &sideInfo->m_skillSet6; break;
3093+
case 6: skillset = &sideInfo->m_skillSet7; break;
30863094
}
30873095
Int i;
30883096
for (i=0; i<skillset->m_numSkills; i++) {
@@ -4527,6 +4535,40 @@ void AIPlayer::buildSpecificBuildingNearestObjectAngle(const AsciiString& thingN
45274535
TheTerrainVisual->removeAllBibs(); // isLocationLegalToBuild adds bib feedback, turn it off. jba.
45284536
}
45294537

4538+
//-------------------------------------------------------------------------------------------------
4539+
void AIPlayer::buildAIBaseDefenseFromVector(Bool flank, Real rotation, Real percent)
4540+
{
4541+
//
4542+
AsciiString teamStr = "Error : Solo ai doesn't support buildAIBaseDefense. '";
4543+
TheScriptEngine->AppendDebugMessage(teamStr, false);
4544+
}
4545+
4546+
//-------------------------------------------------------------------------------------------------
4547+
void AIPlayer::buildAIBaseDefenseFromVectorAtPlayer(Bool flank, Real rotation, Real percent, const AsciiString& playerName)
4548+
{
4549+
//
4550+
AsciiString teamStr = "Error : Solo ai doesn't support buildAIBaseDefense. '";
4551+
TheScriptEngine->AppendDebugMessage(teamStr, false);
4552+
}
4553+
4554+
//-------------------------------------------------------------------------------------------------
4555+
void AIPlayer::addAIBaseDefenseToVector(const AsciiString& objectType)
4556+
{
4557+
//
4558+
AsciiString teamStr = "Error : Solo ai doesn't support addBaseDefenseFromVector. '";
4559+
TheScriptEngine->AppendDebugMessage(teamStr, false);
4560+
}
4561+
4562+
//-------------------------------------------------------------------------------------------------
4563+
void AIPlayer::removeAIBaseDefenseFromVector(const AsciiString& objectType)
4564+
{
4565+
//
4566+
AsciiString teamStr = "Error : Solo ai doesn't support removeBaseDefenseFromVector. '";
4567+
TheScriptEngine->AppendDebugMessage(teamStr, false);
4568+
}
4569+
4570+
Coord3D AIPlayer::getSkirmishBuildListBaseCenter() { return m_baseCenter; }
4571+
Real AIPlayer::getSkirmishBuildListBaseRadius() { return m_baseRadius; }
45304572
//-------------------------------------------------------------------------------------------------
45314573
//-------------------------------- @CLP_AI AIPLAYER ADDITIONS END ---------------------------------
45324574
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)