Skip to content

Commit f281bb8

Browse files
committed
Add shipyard ai features
1 parent ded8a7c commit f281bb8

21 files changed

Lines changed: 291 additions & 48 deletions

File tree

Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,7 @@ void W3DModelDrawModuleData::parseConditionState(INI* ini, void *instance, void
14421442
{ "AltTurretArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtAngle) },
14431443
{ "AltTurretPitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretPitchNameKey) },
14441444
{ "AltTurretArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtPitch) },
1445+
{ "Turret1", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretAngleNameKey) },
14451446
{ "Turret1ArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtAngle) },
14461447
{ "Turret1Pitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretPitchNameKey) },
14471448
{ "Turret1ArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtPitch) },

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
class BuildListInfo;
3535
class SpecialPowerTemplate;
3636

37+
typedef BitFlags<10> UsedShipyardLocationMask;
3738

3839
/**
3940
* The computer-controlled opponent.
@@ -110,6 +111,7 @@ class AISkirmishPlayer : public AIPlayer
110111
Real m_curLeftFlankRightDefenseAngle;
111112
Real m_curRightFlankLeftDefenseAngle;
112113
Real m_curRightFlankRightDefenseAngle;
114+
UsedShipyardLocationMask m_usedShipyards;
113115

114116
UnsignedInt m_frameToCheckEnemy;
115117
Player *m_currentEnemy;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,9 @@ class Player : public Snapshot
615615
/// Build structure type on front or flank of base. Gets passed to aiPlayer.
616616
void buildBaseDefenseStructure(const AsciiString &thingName, Bool flank);
617617

618+
/// Build shipyard. Gets passed to aiPlayer.
619+
void buildShipyard(const AsciiString& thingName);
620+
618621
/// Recruits an instance of a specific team. Gets passed to aiPlayer.
619622
void recruitSpecificTeam(TeamPrototype *teamProto, Real recruitRadius);
620623

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ class AIPlayer : public MemoryPoolObject,
175175

176176
virtual void buildSpecificAIBuilding(const AsciiString &thingName); ///< Builds this building as soon as possible.
177177

178+
virtual void buildAIShipyard(const AsciiString& thingName); ///< Build structure at shipyard location
178179

179180
virtual void recruitSpecificAITeam(TeamPrototype *teamProto, Real recruitRadius); ///< Builds this team immediately.
180181

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
class BuildListInfo;
3535
class SpecialPowerTemplate;
3636

37+
typedef BitFlags<10> UsedShipyardsMask;
3738

3839
/**
3940
* The computer-controlled opponent.
@@ -66,6 +67,8 @@ class AISkirmishPlayer : public AIPlayer
6667

6768
virtual void recruitSpecificAITeam(TeamPrototype *teamProto, Real recruitRadius); ///< Builds this team immediately.
6869

70+
virtual void buildAIShipyard(const AsciiString& thingName) override; ///< Build structure at shipyard location
71+
6972
virtual Bool isSkirmishAI(void) {return true;}
7073

7174
virtual Bool checkBridges(Object *unit, Waypoint *way);
@@ -110,6 +113,7 @@ class AISkirmishPlayer : public AIPlayer
110113
Real m_curLeftFlankRightDefenseAngle;
111114
Real m_curRightFlankLeftDefenseAngle;
112115
Real m_curRightFlankRightDefenseAngle;
116+
UsedShipyardsMask m_usedShipyards;
113117

114118
UnsignedInt m_frameToCheckEnemy;
115119
Player *m_currentEnemy;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class ScriptActions : public ScriptActionsInterface
138138
void doBuildUpgrade(const AsciiString& playerName, const AsciiString& upgrade);
139139
void doBuildBaseDefense(Bool flank);
140140
void doBuildBaseStructure(const AsciiString& buildingType, Bool flank);
141+
void doBuildShipyard(const AsciiString& buildingType);
141142
void createUnitOnTeamAt(const AsciiString& unitName, const AsciiString& objType, const AsciiString& teamName, const AsciiString& waypoint);
142143
void doNamedAttackArea(const AsciiString& unitName, const AsciiString& areaName);
143144
void doNamedAttackTeam(const AsciiString& unitName, const AsciiString& teamName);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class ScriptConditions : public ScriptConditionsInterface
178178
Bool evaluateSkirmishSupplySourceSafe(Condition *pCondition, Parameter *pSkirmishPlayerParm, Parameter *pMinAmountOfSupplies );
179179
Bool evaluateSkirmishSupplySourceAttacked(Parameter *pSkirmishPlayerParm );
180180
Bool evaluateSkirmishStartPosition(Parameter *pSkirmishPlayerParm, Parameter *startNdx );
181+
Bool evaluateSkirmishShipsEnabled(void);
181182

182183

183184
// Stubs

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#define SKIRMISH_FLANK "Flank"
5555
#define SKIRMISH_BACKDOOR "Backdoor"
5656
#define SKIRMISH_SPECIAL "Special"
57+
#define SKIRMISH_SHIPYARD "Shipyard"
5758

5859
// Skirmish Player Areas
5960
#define SKIRMISH_AREA_HOME_BASE "Home Base"
@@ -62,11 +63,14 @@
6263
// Skirmish trigger names.
6364
#define MY_INNER_PERIMETER "[Skirmish]MyInnerPerimeter"
6465
#define MY_OUTER_PERIMETER "[Skirmish]MyOuterPerimeter"
66+
#define MY_NAVAL_PERIMETER "[Skirmish]MyNavalPerimeter"
6567
#define ENEMY_OUTER_PERIMETER "[Skirmish]EnemyOuterPerimeter"
6668
#define ENEMY_INNER_PERIMETER "[Skirmish]EnemyInnerPerimeter"
69+
#define ENEMY_NAVAL_PERIMETER "[Skirmish]EnemyNavalPerimeter"
6770

6871
#define INNER_PERIMETER "InnerPerimeter"
6972
#define OUTER_PERIMETER "OuterPerimeter"
73+
#define NAVAL_PERIMETER "NavalPerimeter"
7074

7175
class Parameter;
7276
class Script;
@@ -543,6 +547,7 @@ class ScriptAction : public MemoryPoolObject // This is the action class.
543547
TEAM_SET_BOOBYTRAPPED, ///< Add boobytrap to all units on team.
544548
SHOW_WEATHER, ///< show map defined weather.
545549
AI_PLAYER_BUILD_TYPE_NEAREST_TEAM, ///< Tell the ai player to build an object nearest team.
550+
SKIRMISH_BUILD_SHIPYARD, ///< Tell the ai player to build a shipyard
546551
// add new items here, please
547552
NUM_ITEMS
548553
};
@@ -971,6 +976,8 @@ class Condition : public MemoryPoolObject // This is the conditional class.
971976
START_POSITION_IS, // True if our start position matches.
972977
NAMED_HAS_FREE_CONTAINER_SLOTS, ///< Kris -- Checks if any given container has any free slots.
973978

979+
SKIRMISH_SHIPS_ENABLED, // True if ships are enabled on the played map
980+
974981
NUM_ITEMS // Always the last condition.
975982
};
976983

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ class TerrainLogic : public Snapshot,
266266
/// Return the closest waypoint on the labeled path
267267
virtual Waypoint *getClosestWaypointOnPath( const Coord3D *pos, AsciiString label );
268268

269+
/// Return a vector of shipyard locations for this Label, expected to be ShipyardN where N is player index starting with 1
270+
virtual std::vector<Waypoint*> getShipyardBuildPositions(const Coord3D* pos, AsciiString label);
271+
269272
/// Return true if the waypoint path containing pWay is labeled with the label.
270273
virtual Bool isPurposeOfPath( Waypoint *pWay, AsciiString label );
271274

@@ -298,6 +301,9 @@ class TerrainLogic : public Snapshot,
298301

299302
virtual void updateBridgeDamageStates(void); ///< Updates bridge's damage info.
300303

304+
/// Check if a point is in a NO_SHIPYARD area
305+
virtual bool isInNoShipyardZone(const Coord3D * pos);
306+
301307
Bool anyBridgesDamageStatesChanged(void) {return m_bridgeDamageStatesChanged; } ///< Bridge damage states updated.
302308
Bool isBridgeRepaired(const Object *bridge); ///< Is bridge repaired?
303309
Bool isBridgeBroken(const Object *bridge); ///< Is bridge Broken?
@@ -318,6 +324,8 @@ class TerrainLogic : public Snapshot,
318324
void flattenTerrain(Object *obj); ///< Flatten the terrain under a building.
319325
void createCraterInTerrain(Object *obj); ///< Flatten the terrain under a building.
320326

327+
Real getShipyardPlacementAngle(const Coord3D& worldPos, const ThingTemplate* thing);
328+
321329
protected:
322330

323331
// snapshot methods

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,14 @@ void Player::buildBaseDefenseStructure(const AsciiString &thingName, Bool flank)
24952495
}
24962496
}
24972497

2498+
//=============================================================================
2499+
void Player::buildShipyard(const AsciiString &thingName) {
2500+
if (m_ai)
2501+
{
2502+
m_ai->buildAIShipyard(thingName);
2503+
}
2504+
}
2505+
24982506
//=============================================================================
24992507
void Player::buildSpecificBuilding(const AsciiString &thingName)
25002508
{

0 commit comments

Comments
 (0)