Skip to content

Commit 16d9b35

Browse files
committed
map control scripts added
1 parent e5540aa commit 16d9b35

5 files changed

Lines changed: 237 additions & 46 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class ScriptConditions : public ScriptConditionsInterface
191191
Bool evaluateNeighbouringSpotsEmpty(Parameter* pPlayerParm, Parameter* pComparisonParm, Int pCount);
192192
Bool evaluateNeighbouringSpotsRelation(Parameter* pPlayerParm, Parameter* pComparisonParm, Int pCount, Int relationType);
193193
Bool evaluateStartingCash(Parameter* pComparisonParm, Int pAmount);
194-
Bool evaluateClosestRelationUnitToMySpawn(Int relationType, Parameter* pPlayerParm, Parameter* pComparisonParm, Int pDist);
194+
Bool evaluateClosestRelationUnitToMySpawn(Int relationType, Parameter* pPlayerParm, Parameter* pComparisonParm, Real pDist);
195195
Bool evaluateHunted(Parameter* pPlayerParm);
196196
Bool evaluatePlayerLostTypeInArea(Parameter* pPlayerParm, Parameter* pObjectType, Parameter* pArea);
197197
Bool evaluatePlayerLostUnit(Parameter* pPlayerParm);
@@ -202,6 +202,9 @@ class ScriptConditions : public ScriptConditionsInterface
202202
Bool evaluateEmptySpotCount(Parameter* pComparisonParm, Int pEmptySpotCount);
203203
Bool evaluatePlayerDestroyedEnemyType(Parameter* pPlayerParm, Parameter* pObjectType);
204204
Bool evaluatePlayerDestroyedEnemyUnit(Parameter* pPlayerParm);
205+
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);
205208

206209
//-------------------------------------------------------------------------------------------------
207210
//---------------------------- @CLP_AI SCRIPT CONDITION ADDITIONS END -----------------------------

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,8 @@ class Condition : public MemoryPoolObject // This is the conditional class.
11101110

11111111
/*TODO*/RELATION_UNDER_ATTACK, // True if a(n) <relation> player is under attack.
11121112

1113+
PLAYER_MAPCONTROL, // True if a player's map control is <comparison> <Real>.
1114+
PLAYER_RELATION_MAPCONTROL, // True if all <relation> player's map control is <comparison> <Real>.
11131115
//-------------------------------------------------------------------------------------------------
11141116
//---------------------------- @CLP_AI SCRIPT CONDITION ADDITIONS END -----------------------------
11151117
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6905,7 +6905,7 @@ void ScriptActions::doTeamMoveAwayFromRelationType(const AsciiString& teamName,
69056905
}
69066906
}
69076907
if (!bestObj) return;
6908-
//Calculate the flee vector
6908+
//@-TanSo-: Calculate the flee vector
69096909
Coord3D threatPos = *bestObj->getPosition();
69106910
Coord3D fleeVec;
69116911
fleeVec.x = teamPos.x - threatPos.x;
@@ -7015,7 +7015,7 @@ void ScriptActions::doTeamMoveTowardsRelationType(const AsciiString& teamName, R
70157015
}
70167016
}
70177017
if (!bestObj) return;
7018-
//Calculate the flee vector
7018+
//@-TanSo-: Calculate the flee vector
70197019
Coord3D threatPos = *bestObj->getPosition();
70207020
Coord3D fleeVec;
70217021
fleeVec.x = threatPos.x - teamPos.x;
@@ -7103,7 +7103,7 @@ void ScriptActions::doUnitMoveAwayFromRelationType(const AsciiString& unitName,
71037103

71047104
if (!bestObj) return;
71057105

7106-
//Calculate the flee vector.
7106+
//@-TanSo-: Calculate the flee vector.
71077107
Coord3D threatPos = *bestObj->getPosition();
71087108
Coord3D fleeVec;
71097109
fleeVec.x = objPos.x - threatPos.x;
@@ -7182,7 +7182,7 @@ void ScriptActions::doUnitMoveTowardsRelationType(const AsciiString& unitName, R
71827182

71837183
if (!bestObj) return;
71847184

7185-
//Calculate the flee vector.
7185+
//@-TanSo-: Calculate the flee vector.
71867186
Coord3D threatPos = *bestObj->getPosition();
71877187
Coord3D fleeVec;
71887188
fleeVec.x = threatPos.x - objPos.x;
@@ -7226,7 +7226,7 @@ void ScriptActions::doTeamMeet(const AsciiString& teamName)
72267226
Coord3D pos;
72277227
pos.x = pos.y = pos.z = 0;
72287228

7229-
// Get the center point for the team
7229+
//@-TanSo-: Get the center point for the team
72307230
for (DLINK_ITERATOR<Object> iter = pTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
72317231
{
72327232
Object* obj = iter.cur();
@@ -7268,7 +7268,7 @@ void ScriptActions::doTeamMeetKindOf(const AsciiString& teamName, Int kindOf)
72687268
Coord3D pos;
72697269
pos.x = pos.y = pos.z = 0;
72707270

7271-
// Get the center point for the kindOfs
7271+
//@-TanSo-: Get the center point for the kindOfs
72727272
for (DLINK_ITERATOR<Object> iter = pTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
72737273
{
72747274
Object* obj = iter.cur();
@@ -7318,7 +7318,7 @@ void ScriptActions::doTeamMeetType(const AsciiString& teamName, const AsciiStrin
73187318
Coord3D pos;
73197319
pos.x = pos.y = pos.z = 0;
73207320

7321-
// Get the center point for the objectType
7321+
//@-TanSo-: Get the center point for the objectType
73227322
for (DLINK_ITERATOR<Object> iter = pTeam->iterate_TeamMemberList(); !iter.done(); iter.advance())
73237323
{
73247324
Object* obj = iter.cur();
@@ -7483,7 +7483,7 @@ void ScriptActions::doPlayerMergeKindOf(const AsciiString& playerName, Int kindO
74837483
if (!obj) {
74847484
break;
74857485
}
7486-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7486+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
74877487
// Iterator MUST be advanced before calling setTeam().
74887488
// This mirrors original EA engine behavior. It's dirty I know.
74897489
nextObj = iter2.cur();
@@ -7526,7 +7526,7 @@ void ScriptActions::doTeamMergeKindOf(const AsciiString& srcName, Int kindOf, co
75267526
if (!obj) {
75277527
break;
75287528
}
7529-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7529+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
75307530
// Iterator MUST be advanced before calling setTeam().
75317531
// This mirrors original EA engine behavior. It's dirty I know.
75327532
nextObj = iter.cur();
@@ -7582,7 +7582,7 @@ void ScriptActions::doPlayerMergeType(const AsciiString& playerName, const Ascii
75827582
if (!obj) {
75837583
break;
75847584
}
7585-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7585+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
75867586
// Iterator MUST be advanced before calling setTeam().
75877587
// This mirrors original EA engine behavior. It's dirty I know.
75887588
nextObj = iter2.cur();
@@ -7655,7 +7655,7 @@ void ScriptActions::doTeamMergeType(const AsciiString& srcName, const AsciiStrin
76557655
if (!obj) {
76567656
break;
76577657
}
7658-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7658+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
76597659
// Iterator MUST be advanced before calling setTeam().
76607660
// This mirrors original EA engine behavior. It's dirty I know.
76617661
nextObj = iter.cur();
@@ -7722,7 +7722,7 @@ void ScriptActions::doPlayerDisbandKindOf(const AsciiString& playerName, Int kin
77227722
if (!obj) {
77237723
break;
77247724
}
7725-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7725+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
77267726
// Iterator MUST be advanced before calling setTeam().
77277727
// This mirrors original EA engine behavior. It's dirty I know.
77287728
nextObj = iter2.cur();
@@ -7762,7 +7762,7 @@ void ScriptActions::doTeamDisbandKindOf(const AsciiString& teamName, Int kindOf)
77627762
if (!obj) {
77637763
break;
77647764
}
7765-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7765+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
77667766
// Iterator MUST be advanced before calling setTeam().
77677767
// This mirrors original EA engine behavior. It's dirty I know.
77687768
nextObj = iter.cur();
@@ -7810,7 +7810,7 @@ void ScriptActions::doPlayerDisbandType(const AsciiString& playerName, const Asc
78107810
if (!obj) {
78117811
break;
78127812
}
7813-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7813+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
78147814
// Iterator MUST be advanced before calling setTeam().
78157815
// This mirrors original EA engine behavior. It's dirty I know.
78167816
nextObj = iter2.cur();
@@ -7880,7 +7880,7 @@ void ScriptActions::doTeamDisbandType(const AsciiString& teamName, const AsciiSt
78807880
if (!obj) {
78817881
break;
78827882
}
7883-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7883+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
78847884
// Iterator MUST be advanced before calling setTeam().
78857885
// This mirrors original EA engine behavior. It's dirty I know.
78867886
nextObj = iter.cur();
@@ -7941,7 +7941,7 @@ void ScriptActions::doPlayerTeamlessMerge(const AsciiString& playerName, const A
79417941
if (!obj) {
79427942
break;
79437943
}
7944-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7944+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
79457945
// Iterator MUST be advanced before calling setTeam().
79467946
// This mirrors original EA engine behavior. It's dirty I know.
79477947
nextObj = iter2.cur();
@@ -7982,7 +7982,7 @@ void ScriptActions::doPlayerTeamlessMergeKindOf(const AsciiString& playerName, I
79827982
if (!obj) {
79837983
break;
79847984
}
7985-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
7985+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
79867986
// Iterator MUST be advanced before calling setTeam().
79877987
// This mirrors original EA engine behavior. It's dirty I know.
79887988
nextObj = iter.cur();
@@ -8031,7 +8031,7 @@ void ScriptActions::doPlayerTeamlessMergeType(const AsciiString& playerName, con
80318031
if (!obj) {
80328032
break;
80338033
}
8034-
// IMPORTANT: setTeam() removes an object from TeamMemberList.
8034+
// @-TanSo-: IMPORTANT: setTeam() removes an object from TeamMemberList.
80358035
// Iterator MUST be advanced before calling setTeam().
80368036
// This mirrors original EA engine behavior. It's dirty I know.
80378037
nextObj = iter.cur();
@@ -8131,7 +8131,7 @@ void ScriptActions::doPlayerGarrisonMaxEach(const AsciiString& playerName, Int m
81318131
continue;
81328132
}
81338133

8134-
//Set a new maximum amount of available slots.
8134+
//@-TanSo-: Set a new maximum amount of available slots.
81358135
//If the max amount is bigger or equal to the slots available, just continue to fill normally
81368136
Int slotsAvailable;
81378137
if (cmi->getContainMax() - cmi->getContainCount() <= maxAmount)
@@ -8210,7 +8210,7 @@ void ScriptActions::doTeamGarrisonMaxEach(const AsciiString& teamName, Int maxAm
82108210
continue;
82118211
}
82128212

8213-
//Set a new maximum amount of available slots.
8213+
//@-TanSo-: Set a new maximum amount of available slots.
82148214
//If the max amount is bigger or equal to the slots available, just continue to fill normally
82158215
Int slotsAvailable;
82168216
if (cmi->getContainMax() - cmi->getContainCount() <= maxAmount)
@@ -8309,14 +8309,14 @@ void ScriptActions::doPlayerGarrisonEqually(const AsciiString& playerName, Int a
83098309

83108310
int slotsFree = cmi->getContainMax() - cmi->getContainCount();
83118311
if (slotsFree <= 0) {
8312-
// building cannot take any more units, add to the rest
8312+
// @-TanSo-: building cannot take any more units, add to the rest
83138313
rest += target;
83148314
continue;
83158315
}
83168316

83178317
int slotsAvailable = std::min(slotsFree, target);
83188318

8319-
// in case less people are garrisoning than expected
8319+
// @-TanSo-: in case less people are garrisoning than expected
83208320
if (slotsAvailable < target) {
83218321
rest += (target - slotsAvailable);
83228322
}
@@ -8406,14 +8406,14 @@ void ScriptActions::doTeamGarrisonEqually(const AsciiString& teamName, Int amoun
84068406

84078407
int slotsFree = cmi->getContainMax() - cmi->getContainCount();
84088408
if (slotsFree <= 0) {
8409-
// building cannot take any more units, add to the rest
8409+
// @-TanSo-: building cannot take any more units, add to the rest
84108410
rest += target;
84118411
continue;
84128412
}
84138413

84148414
int slotsAvailable = std::min(slotsFree, target);
84158415

8416-
// in case less people are garrisoning than expected
8416+
// @-TanSo-: in case less people are garrisoning than expected
84178417
if (slotsAvailable < target) {
84188418
rest += (target - slotsAvailable);
84198419
}
@@ -8691,7 +8691,7 @@ void ScriptActions::doTeamMoveAwayFromRelation(const AsciiString& teamName, Real
86918691
}
86928692

86938693
if (!bestObj) return;
8694-
//Calculate the flee vector
8694+
//@-TanSo-: Calculate the flee vector
86958695
Coord3D threatPos = *bestObj->getPosition();
86968696
Coord3D fleeVec;
86978697
fleeVec.x = teamPos.x - threatPos.x;
@@ -8766,7 +8766,7 @@ void ScriptActions::doTeamMoveTowardsRelation(const AsciiString& teamName, Real
87668766
}
87678767

87688768
if (!bestObj) return;
8769-
//Calculate the flee vector
8769+
//@-TanSo-: Calculate the flee vector
87708770
Coord3D threatPos = *bestObj->getPosition();
87718771
Coord3D fleeVec;
87728772
fleeVec.x = threatPos.x - teamPos.x;
@@ -8818,7 +8818,7 @@ void ScriptActions::doUnitMoveAwayFromRelation(const AsciiString& unitName, Real
88188818
bestObj = ThePartitionManager->getClosestObject(&objPos, REALLY_FAR, FROM_CENTER_2D, filters);
88198819
if (!bestObj) return;
88208820

8821-
//Calculate the flee vector.
8821+
//@-TanSo-: Calculate the flee vector.
88228822
Coord3D threatPos = *bestObj->getPosition();
88238823
Coord3D fleeVec;
88248824
fleeVec.x = objPos.x - threatPos.x;
@@ -8861,7 +8861,7 @@ void ScriptActions::doUnitMoveTowardsRelation(const AsciiString& unitName, Real
88618861
bestObj = ThePartitionManager->getClosestObject(&objPos, REALLY_FAR, FROM_CENTER_2D, filters);
88628862
if (!bestObj) return;
88638863

8864-
//Calculate the flee vector.
8864+
//@-TanSo-: Calculate the flee vector.
88658865
Coord3D threatPos = *bestObj->getPosition();
88668866
Coord3D fleeVec;
88678867
fleeVec.x = threatPos.x - objPos.x;

0 commit comments

Comments
 (0)