Skip to content

Commit 51c41c8

Browse files
authored
Merge pull request #58 from Andreas-W/buff_system
Buff system
2 parents 3aa4f3a + a123527 commit 51c41c8

File tree

25 files changed

+2145
-95
lines changed

25 files changed

+2145
-95
lines changed

Core/GameEngine/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ set(GAMEENGINE_SRC
460460
# Include/GameLogic/Module/SupplyWarehouseDockUpdate.h
461461
# Include/GameLogic/Module/TechBuildingBehavior.h
462462
# Include/GameLogic/Module/TempWeaponBonusHelper.h
463+
# Include/GameLogic/Module/BuffEffectHelper.h
463464
# Include/GameLogic/Module/TensileFormationUpdate.h
464465
# Include/GameLogic/Module/ToppleUpdate.h
465466
# Include/GameLogic/Module/TransitionDamageFX.h
@@ -477,11 +478,13 @@ set(GAMEENGINE_SRC
477478
# Include/GameLogic/Module/WanderAIUpdate.h
478479
# Include/GameLogic/Module/WaveGuideUpdate.h
479480
# Include/GameLogic/Module/WeaponBonusUpdate.h
481+
# Include/GameLogic/Module/BuffUpdate.h
480482
# Include/GameLogic/Module/WeaponBonusUpgrade.h
481483
# Include/GameLogic/Module/WeaponSetUpgrade.h
482484
# Include/GameLogic/Module/WorkerAIUpdate.h
483485
# Include/GameLogic/Object.h
484486
# Include/GameLogic/ObjectCreationList.h
487+
# Include/GameLogic/BuffSystem.h
485488
# Include/GameLogic/ObjectIter.h
486489
# Include/GameLogic/ObjectScriptStatusBits.h
487490
# Include/GameLogic/ObjectTypes.h
@@ -959,9 +962,11 @@ set(GAMEENGINE_SRC
959962
# Source/GameLogic/Object/Helper/StatusDamageHelper.cpp
960963
# Source/GameLogic/Object/Helper/SubdualDamageHelper.cpp
961964
# Source/GameLogic/Object/Helper/TempWeaponBonusHelper.cpp
965+
# Source/GameLogic/Object/Helper/BuffEffectHelper.cpp
962966
# Source/GameLogic/Object/Locomotor.cpp
963967
# Source/GameLogic/Object/Object.cpp
964968
# Source/GameLogic/Object/ObjectCreationList.cpp
969+
# Source/GameLogic/Object/BuffSystem.cpp
965970
# Source/GameLogic/Object/ObjectTypes.cpp
966971
# Source/GameLogic/Object/PartitionManager.cpp
967972
# Source/GameLogic/Object/SimpleObjectIterator.cpp
@@ -1062,6 +1067,7 @@ set(GAMEENGINE_SRC
10621067
# Source/GameLogic/Object/Update/UpdateModule.cpp
10631068
# Source/GameLogic/Object/Update/WaveGuideUpdate.cpp
10641069
# Source/GameLogic/Object/Update/WeaponBonusUpdate.cpp
1070+
# Source/GameLogic/Object/Update/BuffUpdate.cpp
10651071
# Source/GameLogic/Object/Upgrade/ActiveShroudUpgrade.cpp
10661072
# Source/GameLogic/Object/Upgrade/ArmorUpgrade.cpp
10671073
# Source/GameLogic/Object/Upgrade/CommandSetUpgrade.cpp

Core/GameEngine/Source/Common/System/GameMemoryInitPools_GeneralsMD.inl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ static PoolSizeRec PoolSizes[] =
8888
{ "SubdualDamageHelper", 1500, 256 },
8989
{ "ChronoDamageHelper", 1500, 256 },
9090
{ "TempWeaponBonusHelper", 4096, 256 },
91+
{ "BuffEffectHelper", 4096, 256 },
9192
{ "Locomotor", 2048, 32 },
9293
{ "LocomotorTemplate", 192, 32 },
9394
{ "ObjectPool", 1500, 256 },
@@ -105,6 +106,7 @@ static PoolSizeRec PoolSizes[] =
105106
{ "AudioRequest", 256, 8 },
106107
{ "AutoHealBehavior", 1024, 256 },
107108
{ "WeaponBonusUpdate", 16, 16 },
109+
{ "BuffUpdate", 32, 32 },
108110
{ "GrantStealthBehavior", 4096, 32 },
109111
{ "NeutronBlastBehavior", 4096, 32 },
110112
{ "CountermeasuresBehavior", 256, 32 },
@@ -548,6 +550,11 @@ static PoolSizeRec PoolSizes[] =
548550
{ "MetaMapRec", 256, 32 },
549551
{ "TransportStatus", 32, 32 },
550552
{ "Anim2DTemplate", 32, 32 },
553+
{ "BuffTemplate", 32, 32 },
554+
{ "ValueModifierBuffEffectNugget", 64, 32 },
555+
{ "FlagModifierBuffEffectNugget", 64, 32 },
556+
{ "ColorTintBuffEffectNugget", 32, 32 },
557+
{ "ParticleSystemBuffEffectNugget", 32, 32 },
551558
{ "ObjectTypes", 32, 32 },
552559
{ "NetCommandList", 512, 32 },
553560
{ "TurretAIData", 256, 32 },

GeneralsMD/Code/GameEngine/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ set(GAMEENGINE_SRC
474474
Include/GameLogic/Module/SupplyWarehouseDockUpdate.h
475475
Include/GameLogic/Module/TechBuildingBehavior.h
476476
Include/GameLogic/Module/TempWeaponBonusHelper.h
477+
Include/GameLogic/Module/BuffEffectHelper.h
477478
Include/GameLogic/Module/TensileFormationUpdate.h
478479
Include/GameLogic/Module/ToppleUpdate.h
479480
Include/GameLogic/Module/TransitionDamageFX.h
@@ -492,6 +493,7 @@ set(GAMEENGINE_SRC
492493
Include/GameLogic/Module/TeleporterAIUpdate.h
493494
Include/GameLogic/Module/WaveGuideUpdate.h
494495
Include/GameLogic/Module/WeaponBonusUpdate.h
496+
Include/GameLogic/Module/BuffUpdate.h
495497
Include/GameLogic/Module/ArmorDamageScalarUpdate.h
496498
Include/GameLogic/Module/WeaponBonusUpgrade.h
497499
Include/GameLogic/Module/WeaponSetUpgrade.h
@@ -503,6 +505,7 @@ set(GAMEENGINE_SRC
503505
Include/GameLogic/Module/CarrierDroneAIUpdate.h
504506
Include/GameLogic/Object.h
505507
Include/GameLogic/ObjectCreationList.h
508+
Include/GameLogic/BuffSystem.h
506509
Include/GameLogic/ObjectIter.h
507510
Include/GameLogic/ObjectScriptStatusBits.h
508511
Include/GameLogic/ObjectTypes.h
@@ -987,9 +990,11 @@ set(GAMEENGINE_SRC
987990
Source/GameLogic/Object/Helper/SubdualDamageHelper.cpp
988991
Source/GameLogic/Object/Helper/ChronoDamageHelper.cpp
989992
Source/GameLogic/Object/Helper/TempWeaponBonusHelper.cpp
993+
Source/GameLogic/Object/Helper/BuffEffectHelper.cpp
990994
Source/GameLogic/Object/Locomotor.cpp
991995
Source/GameLogic/Object/Object.cpp
992996
Source/GameLogic/Object/ObjectCreationList.cpp
997+
Source/GameLogic/Object/BuffSystem.cpp
993998
Source/GameLogic/Object/ObjectTypes.cpp
994999
Source/GameLogic/Object/PartitionManager.cpp
9951000
Source/GameLogic/Object/SimpleObjectIterator.cpp
@@ -1098,6 +1103,7 @@ set(GAMEENGINE_SRC
10981103
Source/GameLogic/Object/Update/UpdateModule.cpp
10991104
Source/GameLogic/Object/Update/WaveGuideUpdate.cpp
11001105
Source/GameLogic/Object/Update/WeaponBonusUpdate.cpp
1106+
Source/GameLogic/Object/Update/BuffUpdate.cpp
11011107
Source/GameLogic/Object/Update/ArmorDamageScalarUpdate.cpp
11021108
Source/GameLogic/Object/Update/KodiakDeploymentUpdate.cpp
11031109
Source/GameLogic/Object/Update/KodiakUpdate.cpp

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class INI
176176
~INI();
177177

178178
void loadDirectory( AsciiString dirName, Bool subdirs, INILoadType loadType, Xfer *pXfer ); ///< load directory of INI files
179-
void load( AsciiString filename, INILoadType loadType, Xfer *pXfer ); ///< load INI file
179+
void load( AsciiString filename, INILoadType loadType, Xfer *pXfer, Bool optional=FALSE); ///< load INI file
180180

181181
static Bool isDeclarationOfType( AsciiString blockType, AsciiString blockName, char *bufferToCheck );
182182
static Bool isEndOfBlock( char *bufferToCheck );
@@ -214,6 +214,7 @@ class INI
214214
static void parseTerrainBridgeDefinition( INI *ini );
215215
static void parseMetaMapDefinition( INI *ini );
216216
static void parseFXListDefinition( INI *ini );
217+
static void parseBuffTemplateDefinition( INI* ini );
217218
static void parseObjectCreationListDefinition( INI* ini );
218219
static void parseMultiplayerSettingsDefinition( INI* ini );
219220
static void parseMultiplayerColorDefinition( INI* ini );
@@ -395,7 +396,7 @@ class INI
395396

396397
static Bool isValidINIFilename( const char *filename ); ///< is this a valid .ini filename
397398

398-
void prepFile( AsciiString filename, INILoadType loadType );
399+
void prepFile( AsciiString filename, INILoadType loadType, Bool optional=FALSE );
399400
void unPrepFile();
400401

401402
void readLine( void );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class SubsystemInterfaceList
150150
SubsystemInterfaceList();
151151
~SubsystemInterfaceList();
152152

153-
void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, const char* dirpath, Xfer *pXfer, AsciiString name="");
153+
void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, const char* dirpath, Xfer *pXfer, AsciiString name="", Bool optional=FALSE);
154154
void addSubsystem(SubsystemInterface* sys);
155155
void removeSubsystem(SubsystemInterface* sys);
156156
void postProcessLoadAll();
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
////////////////////////////////////////////////////////////////////////////////
20+
// //
21+
// (c) 2001-2003 Electronic Arts Inc. //
22+
// //
23+
////////////////////////////////////////////////////////////////////////////////
24+
25+
// FILE: BuffSystem.h /////////////////////////////////////////////////////////////////////////////
26+
// Author: Andi W, October 25
27+
// Desc: Buff/Debuff effects
28+
///////////////////////////////////////////////////////////////////////////////////////////////////
29+
30+
#pragma once
31+
32+
#ifndef _BuffSystem_H_
33+
#define _BuffSystem_H_
34+
35+
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
36+
#include "Common/GameMemory.h"
37+
#include "GameLogic/Object.h"
38+
39+
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
40+
class BuffEffectNugget;
41+
class BuffTemplate;
42+
class BuffTemplateStore;
43+
44+
struct BuffEffectTracker;
45+
46+
//class Object;
47+
48+
49+
class BuffEffectNugget : public MemoryPoolObject
50+
{
51+
MEMORY_POOL_GLUE_ABC(BuffEffectNugget)
52+
53+
public:
54+
55+
BuffEffectNugget() { }
56+
//virtual ~BuffEffectNugget() { }
57+
58+
virtual void apply(Object* targetObj, const Object* sourceObj, BuffEffectTracker* buffTracker) const = 0;
59+
60+
virtual void remove(Object* targetObj, BuffEffectTracker* buffTracker) const = 0;
61+
62+
63+
};
64+
EMPTY_DTOR(BuffEffectNugget)
65+
66+
// -----------------------------------------------
67+
// -----------------------------------------------
68+
69+
class BuffTemplate : public MemoryPoolObject
70+
{
71+
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(BuffTemplate, "BuffTemplate")
72+
73+
public:
74+
// for lookup
75+
AsciiString getName(void) const { return m_name; }
76+
void friend_setName(const AsciiString& n) { m_name = n; }
77+
78+
inline UnsignedInt getMaxStackSize() const { return m_maxStackSize; }
79+
inline Bool isStackPerSource() const { return m_stackPerSource; }
80+
inline const std::vector<AsciiString>& getPriorityTemplates() const { return m_priorityTemplates; }
81+
82+
//inline WeaponBonusConditionType getWeaponBonusType() const { return m_bonusType; }
83+
//inline WeaponBonusConditionType getWeaponBonusTypeAgainst() const { return m_bonusTypeAgainst; }
84+
//inline WeaponSetType getWeaponSetFlag() const { return m_weaponSetFlag; }
85+
//inline ArmorSetType getArmorSetFlag() const { return m_armorSetFlag; }
86+
//inline ObjectStatusMaskType getStatusToSet() const { return m_statusToSet; }
87+
88+
BuffTemplate();
89+
90+
/**
91+
Toss the contents.
92+
*/
93+
void clear();
94+
95+
void addBuffEffectNugget(BuffEffectNugget* nugget);
96+
97+
UnsignedInt getNextTickFrame(UnsignedInt startFrame, UnsignedInt endFrame) const;
98+
99+
void applyEffects(Object* targetObj, Object* sourceObj, BuffEffectTracker* buffTracker) const;
100+
void removeEffects(Object* targetObj, BuffEffectTracker* buffTracker, Bool ignoreFlags = FALSE) const;
101+
102+
Bool hasPriorityOver(AsciiString templateName) const;
103+
104+
void reApplyFlags(Object* targetObj, const BuffTemplate* other) const;
105+
106+
const FieldParse* getFieldParse(void) const { return TheBuffTemplateFieldParse; }
107+
108+
109+
protected:
110+
AsciiString m_name;
111+
UnsignedInt m_maxStackSize;
112+
Bool m_stackPerSource; ///< Each sourceObj has its own stack of buffs on the target.
113+
114+
std::vector<AsciiString> m_priorityTemplates; ///< list of buffTemplates this template has priority over.
115+
116+
// Flags are stored directly in BuffTemplate
117+
WeaponBonusConditionType m_bonusType; ///< weapon bonus granted to the object
118+
WeaponBonusConditionType m_bonusTypeAgainst; ///< weapon bonus granted when attacking the object
119+
WeaponSetType m_weaponSetFlag; ///< the weaponset flag to set
120+
ArmorSetType m_armorSetFlag; ///< the armorset flag to set
121+
ObjectStatusMaskType m_statusToSet; ///< the status to set (allows multiple)
122+
123+
// --
124+
static const FieldParse TheBuffTemplateFieldParse[];
125+
//static const FieldParse flagModifierFieldParse[];
126+
127+
static void parseFlagModifier(INI* ini, void* instance, void* store, const void* userData);
128+
129+
private:
130+
131+
// note, this list doesn't own the nuggets; all nuggets are owned by the Store.
132+
typedef std::vector<BuffEffectNugget*> BuffEffectNuggetVector;
133+
BuffEffectNuggetVector m_nuggets;
134+
135+
};
136+
EMPTY_DTOR(BuffTemplate)
137+
138+
//-------------------------------------------------------------------------------------------------
139+
/**
140+
The "store" used to hold all the Buffs in existence.
141+
*/
142+
class BuffTemplateStore : public SubsystemInterface
143+
{
144+
145+
public:
146+
147+
BuffTemplateStore();
148+
~BuffTemplateStore();
149+
150+
void init() {}
151+
void reset() {}
152+
void update() {}
153+
154+
/**
155+
return the BuffTemplate with the given namekey.
156+
return NULL if no such BuffTemplate exists.
157+
*/
158+
const BuffTemplate* findBuffTemplate(const char* name) const;
159+
const BuffTemplate* findBuffTemplate(const AsciiString& name) const { return findBuffTemplate(name.str()); }
160+
161+
BuffTemplate* findBuffTemplate(const char* name);
162+
BuffTemplate* findBuffTemplate(AsciiString& name) { return findBuffTemplate(name.str()); }
163+
164+
//BuffTemplate* newBuffTemplate(AsciiString& name);
165+
166+
static void parseBuffTemplateDefinition(INI* ini);
167+
168+
void addBuffEffectNugget(BuffEffectNugget* nugget);
169+
170+
private:
171+
172+
typedef std::map< NameKeyType, BuffTemplate*, std::less<NameKeyType> > BuffTemplateMap;
173+
BuffTemplateMap m_buffTemplates;
174+
175+
// note, this list doesn't own the nuggets; all nuggets are owned by the Store.
176+
typedef std::vector<BuffEffectNugget*> BuffEffectNuggetVector;
177+
BuffEffectNuggetVector m_nuggets;
178+
179+
};
180+
181+
// EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
182+
extern BuffTemplateStore* TheBuffTemplateStore;
183+
184+
#endif // _Buff_H_
185+

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "Common/GameMemory.h"
3737
#include "Common/AudioEventRTS.h"
3838
#include "GameLogic/Module/UpdateModule.h"
39+
#include "GameLogic/WeaponBonusConditionFlags.h"
3940

4041
class Object;
4142
class Weapon;
@@ -90,6 +91,8 @@ class FiringTracker : public UpdateModule
9091

9192
UnsignedInt m_frameToStopLoopingSound; ///< if sound is looping, frame to stop looping it (or zero if not looping)
9293
AudioHandle m_audioHandle;
94+
95+
WeaponBonusConditionFlags m_prevTargetWeaponBonus; ///< weaponBonus against previous target
9396
};
9497

9598
#endif

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface
603603

604604
Bool canAutoAcquireWhileStealthed() const;
605605

606+
void applySpeedMultiplier(Real scalar);
607+
inline Real getSpeedMultiplier(void) const { return m_speedMultiplier; }
606608

607609
protected:
608610

@@ -812,6 +814,8 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface
812814
Bool m_allowedToChase; ///< Allowed to pursue targets.
813815
Bool m_isInUpdate; ///< If true, we are inside our update method.
814816
Bool m_fixLocoInPostProcess;
817+
818+
Real m_speedMultiplier; ///< global multiplier to move speed (kept in AIUpdate rather than Locomotor because it's persistent)
815819
};
816820

817821
//------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)