Skip to content

Commit e5540aa

Browse files
committed
New colors for the ingame AI player text; Lobby now correctly restores the decision of new AI difficulty levels instead of resetting anything above back to hard; New script additions; correct updating of KD ratios by buildTemplateCosts
1 parent 706a283 commit e5540aa

14 files changed

Lines changed: 947 additions & 65 deletions

File tree

Core/GameEngine/Source/GameNetwork/GameInfo.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,14 @@ AsciiString GameInfoToAsciiString( const GameInfo *game )
971971
c = 'E';
972972
else if (slot->getState() == SLOT_MED_AI)
973973
c = 'M';
974-
else
974+
else if (slot->getState() == SLOT_BRUTAL_AI)
975975
c = 'H';
976+
else if (slot->getState() == SLOT_MOD_BRUTAL_AI)
977+
c = 'B';
978+
else if (slot->getState() == SLOT_MOD_ABSURD_AI)
979+
c = 'A';
980+
else if (slot->getState() == SLOT_MOD_INHUMANE_AI)
981+
c = 'I';
976982
str.format("C%c,%d,%d,%d,%d:", c,
977983
slot->getColor(), slot->getPlayerTemplate(),
978984
slot->getStartPos(), slot->getTeamNumber());
@@ -1358,7 +1364,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options)
13581364
//DEBUG_LOG(("ParseAsciiStringToGameInfo - Brutal AI"));
13591365
}
13601366
break;
1361-
case 'C':
1367+
case 'B':
13621368
{
13631369
newSlot[i].setState(SLOT_MOD_BRUTAL_AI);
13641370
//DEBUG_LOG(("ParseAsciiStringToGameInfo - ACTUAL Brutal AI"));

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DifficultySelect.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ static NameKeyType radioButtonHardAIID = NAMEKEY_INVALID;
7777
static GameWindow * radioButtonEasyAI = nullptr;
7878
static GameWindow * radioButtonMediumAI = nullptr;
7979
static GameWindow * radioButtonHardAI = nullptr;
80+
static GameWindow * radioButtonBrutalAI = nullptr;
81+
static GameWindow * radioButtonAbsurdAI = nullptr;
82+
static GameWindow * radioButtonInhumaneAI = nullptr;
8083

8184
void setupGameStart(AsciiString mapName, GameDifficulty diff);
8285
//-----------------------------------------------------------------------------

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ class Player : public Snapshot
448448
//-------------------------------------------------------------------------------------------------
449449
//----------------------------------- @CLP_AI PLAYER ADDITIONS ------------------------------------
450450
//-------------------------------------------------------------------------------------------------
451-
451+
std::vector<const ThingTemplate*> m_lastFrameKills;
452+
std::vector<const ThingTemplate*> m_lastFrameDeaths;
453+
Bool m_lostUnitThisFrame;
452454
virtual Bool computeSuperweaponTargetEconomy(const SpecialPowerTemplate* power, Coord3D* retPos, Int playerNdx, Real weaponRadius);
453455
void buildBySuppliesAngle(Int minimumCash, const AsciiString& thingName, Real angle);
454456
void buildSpecificBuildingNearestTeamAngle(const AsciiString& thingName, const Team* team, Real angle);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,16 @@ class ScriptActions : public ScriptActionsInterface
402402
void doTeamMoveNearestBelongingToPlayer(const AsciiString& teamName, const AsciiString& objectType, const AsciiString& playerName);
403403
void doUnitMoveNearestBelongingToPlayer(const AsciiString& unitName, const AsciiString& objectType, const AsciiString& playerName);
404404
void doTeamMoveAwayFromRelationType(const AsciiString& teamName, Real feet, Int relationType, const AsciiString& objectType);
405+
void doTeamMoveTowardsRelationType(const AsciiString& teamName, Real feet, Int relationType, const AsciiString& objectType);
405406
void doUnitMoveAwayFromRelationType(const AsciiString& unitName, Real feet, Int relationType, const AsciiString& objectType);
407+
void doUnitMoveTowardsRelationType(const AsciiString& unitName, Real feet, Int relationType, const AsciiString& objectType);
406408
void doTeamMeet(const AsciiString& teamName);
407409
void doTeamMeetKindOf(const AsciiString& teamName, Int kindOf);
408410
void doTeamMeetType(const AsciiString& teamName, const AsciiString& objectType);
409411
void doTeamMoveAwayFromRelation(const AsciiString& teamName, Real feet, Int relationType);
412+
void doTeamMoveTowardsRelation(const AsciiString& teamName, Real feet, Int relationType);
410413
void doUnitMoveAwayFromRelation(const AsciiString& unitName, Real feet, Int relationType);
414+
void doUnitMoveTowardsRelation(const AsciiString& unitName, Real feet, Int relationType);
411415

412416
void doTeamUseCommandButtonAbilityOnType(const AsciiString& teamName, const AsciiString& ability, const AsciiString& objectType);
413417
void doTeamUseCommandButtonAbilityOnTeam(const AsciiString& teamName, const AsciiString& ability, const AsciiString& targetTeam);

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,19 @@ class ScriptConditions : public ScriptConditionsInterface
189189
Bool evaluateEmptySpot(Parameter* pStartNdx);
190190
Bool evaluateNeighbouringSpot(Parameter* pPlayerParm, Parameter* pStartNdx);
191191
Bool evaluateNeighbouringSpotsEmpty(Parameter* pPlayerParm, Parameter* pComparisonParm, Int pCount);
192+
Bool evaluateNeighbouringSpotsRelation(Parameter* pPlayerParm, Parameter* pComparisonParm, Int pCount, Int relationType);
192193
Bool evaluateStartingCash(Parameter* pComparisonParm, Int pAmount);
193194
Bool evaluateClosestRelationUnitToMySpawn(Int relationType, Parameter* pPlayerParm, Parameter* pComparisonParm, Int pDist);
194-
Bool evaluateNotHunted(Parameter* pPlayerParm);
195+
Bool evaluateHunted(Parameter* pPlayerParm);
195196
Bool evaluatePlayerLostTypeInArea(Parameter* pPlayerParm, Parameter* pObjectType, Parameter* pArea);
197+
Bool evaluatePlayerLostUnit(Parameter* pPlayerParm);
196198
Bool evaluateTeamSightedRelationType(Parameter* pTeam, Int relationType, Parameter* pObjectType);
197199
Bool evaluateSkirmishAnyRelationFaction(Parameter* pPlayerParm, Int relationType, Parameter* pFactionParm);
198200
Bool evaluateMapSize(Parameter* pComparisonParm, Int pMapSize);
201+
Bool evaluateActivePlayerCount(Parameter* pComparisonParm, Int pPlayerCount);
202+
Bool evaluateEmptySpotCount(Parameter* pComparisonParm, Int pEmptySpotCount);
203+
Bool evaluatePlayerDestroyedEnemyType(Parameter* pPlayerParm, Parameter* pObjectType);
204+
Bool evaluatePlayerDestroyedEnemyUnit(Parameter* pPlayerParm);
199205

200206
//-------------------------------------------------------------------------------------------------
201207
//---------------------------- @CLP_AI SCRIPT CONDITION ADDITIONS END -----------------------------

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ class ScriptEngine : public SubsystemInterface,
432432
//-------------------------------------------------------------------------------------------------
433433

434434
void setCounterRandom(ScriptAction* pAction, Bool random);
435+
Bool evaluateTwoCounters(Condition* pCondition);
436+
void copyCounter(ScriptAction* pAction);
437+
438+
435439
void setKDRatio(ScriptAction* pAction);
436440
Real allocateKDRatio(const AsciiString& name);
437441
const TKDRatio* getKDRatio(const AsciiString& counterName);
@@ -440,6 +444,10 @@ class ScriptEngine : public SubsystemInterface,
440444
void addKDRatioDeaths(ScriptAction* pAction);
441445
void subKDRatioKills(ScriptAction* pAction);
442446
void subKDRatioDeaths(ScriptAction* pAction);
447+
void updateKDRatioKills(ScriptAction* pAction);
448+
void updateKDRatioDeaths(ScriptAction* pAction);
449+
void copyKDRatioOntoCounters(ScriptAction* pAction);
450+
443451

444452
//-------------------------------------------------------------------------------------------------
445453
//------------------------------- @CLP_AI SCRIPT UI ADDITIONS END ---------------------------------

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,15 @@ class ScriptAction : public MemoryPoolObject // This is the action class.
561561
//------------------------------- @CLP_AI SCRIPT ACTIONS ADDITIONS --------------------------------
562562
//-------------------------------------------------------------------------------------------------
563563
SET_COUNTER_RANDOM, ///< Set a counter to a random value between x and y.
564+
COPY_COUNTER, ///< Copy counter A onto B. If B doesn't yet exist, create a counter.
564565
SET_KD_RATIO, ///< Set a real number variable as a KD ratio to x kills and y deaths.
565566
INCREMENT_KD_RATIO_KILLS, ///< Adds the kills of a KD ratio by <Real> credits.
566567
INCREMENT_KD_RATIO_DEATHS, ///< Adds the deaths of a KD ration by <Real> credits.
567568
DECREMENT_KD_RATIO_KILLS, ///< Subtracts the kills of a KD ratio by <Real> credits.
568569
DECREMENT_KD_RATIO_DEATHS, ///< Subtracts the deaths of a KD ratio by <Real> credits.
570+
UPDATE_KD_RATIO_KILLS_BUILDCOST, ///< Updates the kills of a KD ratio by the build cost of whatever is in m_lastFrameKills.
571+
UPDATE_KD_RATIO_DEATHS_BUILDCOST, ///< Updates the deaths of a KD ratio by the build cost of whatever is in m_lastFrameKills.
572+
COPY_KD_RATIO_ONTO_COUNTERS, ///< Copies a KD-Ratio's kills to counter A and deaths to Counter B.
569573

570574
AI_PLAYER_BUILDS_UNNAMED, ///< Tell the ai to produce a new unnamed unit.
571575
AI_PLAYER_BUILD_TYPE_NEAREST_TYPE_ROTATED, ///< AI player builds a structure near an object type rotated <Real> degrees.
@@ -591,6 +595,8 @@ class ScriptAction : public MemoryPoolObject // This is the action class.
591595
TEAM_MOVE_NEAREST_BELONGING_TO_PLAYER, ///< Set a team to move towards the nearest object type belonging to a player.
592596
TEAM_MOVE_AWAY_FROM_RELATION, ///< A team moves <Real> feet into the opposite direction of a <relation> unit.
593597
TEAM_MOVE_AWAY_FROM_RELATION_TYPE, ///< A team moves <Real> feet into the opposite direction of a <relation> <objectType>.
598+
TEAM_MOVE_TOWARDS_RELATION, ///< A team moves <Real> feet towards a <relation> unit.
599+
TEAM_MOVE_TOWARDS_RELATION_TYPE, ///< A team moves <Real> feet towards a <relation> <objectType>.
594600
TEAM_MEET, ///< Set a team to meet at their center point.
595601
TEAM_MEET_AT_KINDOF, ///< Set a team to meet at the center point of all units with <kindOf>.
596602
TEAM_MEET_AT_TYPE, ///< Set a team to meet at the center point of all units with <objectType>.
@@ -609,6 +615,8 @@ class ScriptAction : public MemoryPoolObject // This is the action class.
609615
UNIT_MOVE_NEAREST_BELONGING_TO_PLAYER, ///< Set a unit to move towards the nearest object type belonging to a player.
610616
UNIT_MOVE_AWAY_FROM_RELATION, ///< A unit moves <Real> feet into the opposite direction of a <relation> unit.
611617
UNIT_MOVE_AWAY_FROM_RELATION_TYPE, ///< A unit moves <Real> feet into the opposite direction of a <relation> <objectType>.
618+
UNIT_MOVE_TOWARDS_RELATION, ///< A unit moves <Real> feet towards a <relation> unit.
619+
UNIT_MOVE_TOWARDS_RELATION_TYPE, ///< A unit moves <Real> feet towards a <relation> <objectType>.
612620
/*TODO*/UNIT_USE_PRIMARY_WEAPON, ///< A unit starts using their primary weapon.
613621
/*TODO*/UNIT_USE_SECONDARY_WEAPON, ///< A unit starts using their secondary weapon.
614622

@@ -1078,19 +1086,28 @@ class Condition : public MemoryPoolObject // This is the conditional class.
10781086
//------------------------------ @CLP_AI SCRIPT CONDITION ADDITIONS -------------------------------
10791087
//-------------------------------------------------------------------------------------------------
10801088
KD_RATIO, // True if the KD Ratio is <comparison> a value
1089+
COMPARE_COUNTERS, // True if Counter A is <comparison> Counter B.
10811090

10821091
PLAYER_RELATION_FACTION, // True if one or more of the player's <relation> co-players are a faction.
10831092
RELATION_IS, // True if the relation between two players is as specified.
10841093
SPOT_EMPTY, // True if a specified spot is empty.
10851094
SPOT_NEIGHBOURING, // True if the index of a specified spot is neighbouring the player.
10861095
NEIGHBOURING_SPOTS_EMPTY, // True if <comparison> amount of neighbouring spots are empty.
1096+
NEIGHBOURING_SPOTS_RELATION, // True if <comparison> amount of neighbouring spots have a relation of <relation>.
10871097
MAP_COMPARE_SIZE, // True if there are <comparison> starting points in the map.
1098+
MAP_ACTIVE_PLAYERS, // True if there are <comparison> active layers in the map.
1099+
MAP_EMPTY_SPOTS, // True if there are <comparison> empty starting points in the map.
10881100

10891101
STARTING_CASH_COMPARE, // True if the player's starting cash is <comparison> <Int>.
10901102
CLOSEST_ENEMY_DISTANCE, // True if the enemy's closest unit is <comparison> feet away.
1091-
PLAYER_NOT_HUNTED, // True if the player has construction units || command center || supply stash.
1103+
PLAYER_HUNTED, // True if the player has construction units || command center || supply stash.
10921104
PLAYER_LOST_TYPE_AREA, // True if the player has lost an object of <type> in <area>
1105+
PLAYER_LOST_UNIT, // True if the player has lost a unit.
10931106
TEAM_SIGHTED_RELATION_TYPE, // True if a team has sighted a <relation> unit of <type>
1107+
1108+
PLAYER_DESTROYED_ENEMY_TYPE, // True if a player has destroyed an enemy unit of <type>
1109+
PLAYER_DESTROYED_ENEMY_UNIT, // True if a player has destroyed an enemy unit.
1110+
10941111
/*TODO*/RELATION_UNDER_ATTACK, // True if a(n) <relation> player is under attack.
10951112

10961113
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ extern Bool LANbuttonPushed;
6767
extern void MapSelectorTooltip(GameWindow *window, WinInstanceData *instData, UnsignedInt mouse);
6868
extern void gameAcceptTooltip(GameWindow *window, WinInstanceData *instData, UnsignedInt mouse);
6969
Color white = GameMakeColor( 255, 255, 255, 255 );
70+
Color easy = GameMakeColor(255, 210, 210, 255);
71+
Color medium = GameMakeColor(255, 170, 170, 255);
72+
Color hard = GameMakeColor(255, 130, 130, 255);
73+
Color brutal = GameMakeColor(255, 90, 90, 255);
74+
Color absurd = GameMakeColor(255, 50, 50, 255);
75+
Color inhumane = GameMakeColor(255, 10, 10, 255);
7076
static bool s_isIniting = FALSE;
7177
// window ids ------------------------------------------------------------------------------
7278
static NameKeyType parentLanGameOptionsID = NAMEKEY_INVALID;
@@ -728,12 +734,12 @@ void InitLanGameGadgets( void )
728734
{
729735
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:Open"),white);
730736
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:Closed"),white);
731-
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:EasyAI"),white);
732-
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:MediumAI"),white);
733-
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:HardAI"),white);
734-
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:BrutalAI"), white);
735-
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:AbsurdAI"), white);
736-
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:InhumaneAI"), white);
737+
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:EasyAI"),easy);
738+
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:MediumAI"),medium);
739+
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:HardAI"),hard);
740+
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:BrutalAI"), brutal);
741+
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:AbsurdAI"), absurd);
742+
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:InhumaneAI"), inhumane);
737743
GadgetComboBoxSetSelectedPos(comboBoxPlayer[i],0);
738744
}
739745
/*

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,13 @@ void InitSkirmishGameGadgets( void )
11181118
GadgetComboBoxReset(comboBoxPlayer[i]);
11191119
//GadgetComboBoxGetEditBox(comboBoxPlayer[i])->winSetTooltipFunc(playerTooltip);
11201120
}
1121-
Color white = GameMakeColor( 255, 255, 255, 255 );
1121+
Color white = GameMakeColor( 255, 255, 255, 255 );
1122+
Color easy = GameMakeColor(255, 210, 210, 255);
1123+
Color medium = GameMakeColor(255, 170, 170, 255);
1124+
Color hard = GameMakeColor(255, 130, 130, 255);
1125+
Color brutal = GameMakeColor(255, 90, 90, 255);
1126+
Color absurd = GameMakeColor(255, 50, 50, 255);
1127+
Color inhumane = GameMakeColor(255, 10, 10, 255);
11221128

11231129
if( i == 0 )
11241130
{
@@ -1132,18 +1138,18 @@ void InitSkirmishGameGadgets( void )
11321138
GadgetComboBoxSetItemData(comboBoxPlayer[i], 0, (void *)SLOT_OPEN);
11331139
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:Closed"),white); // leave this first
11341140
GadgetComboBoxSetItemData(comboBoxPlayer[i], 1, (void *)SLOT_CLOSED);
1135-
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:EasyAI"),white);
1141+
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:EasyAI"),easy);
11361142
GadgetComboBoxSetItemData(comboBoxPlayer[i], 2, (void *)SLOT_EASY_AI);
1137-
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:MediumAI"),white);
1143+
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:MediumAI"),medium);
11381144
GadgetComboBoxSetItemData(comboBoxPlayer[i], 3, (void *)SLOT_MED_AI);
1139-
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:HardAI"),white);
1145+
GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:HardAI"),hard);
11401146
GadgetComboBoxSetItemData(comboBoxPlayer[i], 4, (void *)SLOT_BRUTAL_AI);
11411147

1142-
GadgetComboBoxAddEntry(comboBoxPlayer[i], TheGameText->fetch("GUI:BrutalAI"), white);
1148+
GadgetComboBoxAddEntry(comboBoxPlayer[i], TheGameText->fetch("GUI:BrutalAI"), brutal);
11431149
GadgetComboBoxSetItemData(comboBoxPlayer[i], 5, (void*)SLOT_MOD_BRUTAL_AI);
1144-
GadgetComboBoxAddEntry(comboBoxPlayer[i], TheGameText->fetch("GUI:AbsurdAI"), white);
1150+
GadgetComboBoxAddEntry(comboBoxPlayer[i], TheGameText->fetch("GUI:AbsurdAI"), absurd);
11451151
GadgetComboBoxSetItemData(comboBoxPlayer[i], 6, (void*)SLOT_MOD_ABSURD_AI);
1146-
GadgetComboBoxAddEntry(comboBoxPlayer[i], TheGameText->fetch("GUI:InhumaneAI"), white);
1152+
GadgetComboBoxAddEntry(comboBoxPlayer[i], TheGameText->fetch("GUI:InhumaneAI"), inhumane);
11471153
GadgetComboBoxSetItemData(comboBoxPlayer[i], 7, (void*)SLOT_MOD_INHUMANE_AI);
11481154

11491155
GadgetComboBoxSetSelectedPos(comboBoxPlayer[i],0);

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,6 +2977,7 @@ void Object::scoreTheKill( const Object *victim )
29772977
if (victimController)
29782978
{
29792979
victimController->getScoreKeeper()->addObjectLost(victim);
2980+
victimController->m_lostUnitThisFrame = TRUE;
29802981
}
29812982

29822983
Relationship r = getRelationship(victim);
@@ -3006,6 +3007,14 @@ void Object::scoreTheKill( const Object *victim )
30063007
getExperienceTracker()->addExperiencePoints( experienceValue );
30073008
}
30083009
}
3010+
3011+
const ThingTemplate* tt = victim->getTemplate();
3012+
if (!tt) return;
3013+
3014+
// @-TanSo-: Add the kills and deaths to our vectors so we can check on them in scripts
3015+
controller->m_lastFrameKills.push_back(tt);
3016+
victimController->m_lastFrameDeaths.push_back(tt);
3017+
30093018
}
30103019

30113020
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)