Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Core/GameEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ set(GAMEENGINE_SRC
# Include/GameLogic/Module/SupplyWarehouseDockUpdate.h
# Include/GameLogic/Module/TechBuildingBehavior.h
# Include/GameLogic/Module/TempWeaponBonusHelper.h
# Include/GameLogic/Module/BuffEffectHelper.h
# Include/GameLogic/Module/TensileFormationUpdate.h
# Include/GameLogic/Module/ToppleUpdate.h
# Include/GameLogic/Module/TransitionDamageFX.h
Expand All @@ -477,11 +478,13 @@ set(GAMEENGINE_SRC
# Include/GameLogic/Module/WanderAIUpdate.h
# Include/GameLogic/Module/WaveGuideUpdate.h
# Include/GameLogic/Module/WeaponBonusUpdate.h
# Include/GameLogic/Module/BuffUpdate.h
# Include/GameLogic/Module/WeaponBonusUpgrade.h
# Include/GameLogic/Module/WeaponSetUpgrade.h
# Include/GameLogic/Module/WorkerAIUpdate.h
# Include/GameLogic/Object.h
# Include/GameLogic/ObjectCreationList.h
# Include/GameLogic/BuffSystem.h
# Include/GameLogic/ObjectIter.h
# Include/GameLogic/ObjectScriptStatusBits.h
# Include/GameLogic/ObjectTypes.h
Expand Down Expand Up @@ -959,9 +962,11 @@ set(GAMEENGINE_SRC
# Source/GameLogic/Object/Helper/StatusDamageHelper.cpp
# Source/GameLogic/Object/Helper/SubdualDamageHelper.cpp
# Source/GameLogic/Object/Helper/TempWeaponBonusHelper.cpp
# Source/GameLogic/Object/Helper/BuffEffectHelper.cpp
# Source/GameLogic/Object/Locomotor.cpp
# Source/GameLogic/Object/Object.cpp
# Source/GameLogic/Object/ObjectCreationList.cpp
# Source/GameLogic/Object/BuffSystem.cpp
# Source/GameLogic/Object/ObjectTypes.cpp
# Source/GameLogic/Object/PartitionManager.cpp
# Source/GameLogic/Object/SimpleObjectIterator.cpp
Expand Down Expand Up @@ -1062,6 +1067,7 @@ set(GAMEENGINE_SRC
# Source/GameLogic/Object/Update/UpdateModule.cpp
# Source/GameLogic/Object/Update/WaveGuideUpdate.cpp
# Source/GameLogic/Object/Update/WeaponBonusUpdate.cpp
# Source/GameLogic/Object/Update/BuffUpdate.cpp
# Source/GameLogic/Object/Upgrade/ActiveShroudUpgrade.cpp
# Source/GameLogic/Object/Upgrade/ArmorUpgrade.cpp
# Source/GameLogic/Object/Upgrade/CommandSetUpgrade.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ static PoolSizeRec PoolSizes[] =
{ "SubdualDamageHelper", 1500, 256 },
{ "ChronoDamageHelper", 1500, 256 },
{ "TempWeaponBonusHelper", 4096, 256 },
{ "BuffEffectHelper", 4096, 256 },
{ "Locomotor", 2048, 32 },
{ "LocomotorTemplate", 192, 32 },
{ "ObjectPool", 1500, 256 },
Expand All @@ -105,6 +106,7 @@ static PoolSizeRec PoolSizes[] =
{ "AudioRequest", 256, 8 },
{ "AutoHealBehavior", 1024, 256 },
{ "WeaponBonusUpdate", 16, 16 },
{ "BuffUpdate", 32, 32 },
{ "GrantStealthBehavior", 4096, 32 },
{ "NeutronBlastBehavior", 4096, 32 },
{ "CountermeasuresBehavior", 256, 32 },
Expand Down Expand Up @@ -548,6 +550,11 @@ static PoolSizeRec PoolSizes[] =
{ "MetaMapRec", 256, 32 },
{ "TransportStatus", 32, 32 },
{ "Anim2DTemplate", 32, 32 },
{ "BuffTemplate", 32, 32 },
{ "ValueModifierBuffEffectNugget", 64, 32 },
{ "FlagModifierBuffEffectNugget", 64, 32 },
{ "ColorTintBuffEffectNugget", 32, 32 },
{ "ParticleSystemBuffEffectNugget", 32, 32 },
{ "ObjectTypes", 32, 32 },
{ "NetCommandList", 512, 32 },
{ "TurretAIData", 256, 32 },
Expand Down
6 changes: 6 additions & 0 deletions GeneralsMD/Code/GameEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ set(GAMEENGINE_SRC
Include/GameLogic/Module/SupplyWarehouseDockUpdate.h
Include/GameLogic/Module/TechBuildingBehavior.h
Include/GameLogic/Module/TempWeaponBonusHelper.h
Include/GameLogic/Module/BuffEffectHelper.h
Include/GameLogic/Module/TensileFormationUpdate.h
Include/GameLogic/Module/ToppleUpdate.h
Include/GameLogic/Module/TransitionDamageFX.h
Expand All @@ -492,6 +493,7 @@ set(GAMEENGINE_SRC
Include/GameLogic/Module/TeleporterAIUpdate.h
Include/GameLogic/Module/WaveGuideUpdate.h
Include/GameLogic/Module/WeaponBonusUpdate.h
Include/GameLogic/Module/BuffUpdate.h
Include/GameLogic/Module/ArmorDamageScalarUpdate.h
Include/GameLogic/Module/WeaponBonusUpgrade.h
Include/GameLogic/Module/WeaponSetUpgrade.h
Expand All @@ -503,6 +505,7 @@ set(GAMEENGINE_SRC
Include/GameLogic/Module/CarrierDroneAIUpdate.h
Include/GameLogic/Object.h
Include/GameLogic/ObjectCreationList.h
Include/GameLogic/BuffSystem.h
Include/GameLogic/ObjectIter.h
Include/GameLogic/ObjectScriptStatusBits.h
Include/GameLogic/ObjectTypes.h
Expand Down Expand Up @@ -987,9 +990,11 @@ set(GAMEENGINE_SRC
Source/GameLogic/Object/Helper/SubdualDamageHelper.cpp
Source/GameLogic/Object/Helper/ChronoDamageHelper.cpp
Source/GameLogic/Object/Helper/TempWeaponBonusHelper.cpp
Source/GameLogic/Object/Helper/BuffEffectHelper.cpp
Source/GameLogic/Object/Locomotor.cpp
Source/GameLogic/Object/Object.cpp
Source/GameLogic/Object/ObjectCreationList.cpp
Source/GameLogic/Object/BuffSystem.cpp
Source/GameLogic/Object/ObjectTypes.cpp
Source/GameLogic/Object/PartitionManager.cpp
Source/GameLogic/Object/SimpleObjectIterator.cpp
Expand Down Expand Up @@ -1098,6 +1103,7 @@ set(GAMEENGINE_SRC
Source/GameLogic/Object/Update/UpdateModule.cpp
Source/GameLogic/Object/Update/WaveGuideUpdate.cpp
Source/GameLogic/Object/Update/WeaponBonusUpdate.cpp
Source/GameLogic/Object/Update/BuffUpdate.cpp
Source/GameLogic/Object/Update/ArmorDamageScalarUpdate.cpp
Source/GameLogic/Object/Update/KodiakDeploymentUpdate.cpp
Source/GameLogic/Object/Update/KodiakUpdate.cpp
Expand Down
5 changes: 3 additions & 2 deletions GeneralsMD/Code/GameEngine/Include/Common/INI.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class INI
~INI();

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

static Bool isDeclarationOfType( AsciiString blockType, AsciiString blockName, char *bufferToCheck );
static Bool isEndOfBlock( char *bufferToCheck );
Expand Down Expand Up @@ -214,6 +214,7 @@ class INI
static void parseTerrainBridgeDefinition( INI *ini );
static void parseMetaMapDefinition( INI *ini );
static void parseFXListDefinition( INI *ini );
static void parseBuffTemplateDefinition( INI* ini );
static void parseObjectCreationListDefinition( INI* ini );
static void parseMultiplayerSettingsDefinition( INI* ini );
static void parseMultiplayerColorDefinition( INI* ini );
Expand Down Expand Up @@ -395,7 +396,7 @@ class INI

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

void prepFile( AsciiString filename, INILoadType loadType );
void prepFile( AsciiString filename, INILoadType loadType, Bool optional=FALSE );
void unPrepFile();

void readLine( void );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class SubsystemInterfaceList
SubsystemInterfaceList();
~SubsystemInterfaceList();

void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, const char* dirpath, Xfer *pXfer, AsciiString name="");
void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, const char* dirpath, Xfer *pXfer, AsciiString name="", Bool optional=FALSE);
void addSubsystem(SubsystemInterface* sys);
void removeSubsystem(SubsystemInterface* sys);
void postProcessLoadAll();
Expand Down
185 changes: 185 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/BuffSystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////

// FILE: BuffSystem.h /////////////////////////////////////////////////////////////////////////////
// Author: Andi W, October 25
// Desc: Buff/Debuff effects
///////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#ifndef _BuffSystem_H_
#define _BuffSystem_H_

// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Common/GameMemory.h"
#include "GameLogic/Object.h"

// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
class BuffEffectNugget;
class BuffTemplate;
class BuffTemplateStore;

struct BuffEffectTracker;

//class Object;


class BuffEffectNugget : public MemoryPoolObject
{
MEMORY_POOL_GLUE_ABC(BuffEffectNugget)

public:

BuffEffectNugget() { }
//virtual ~BuffEffectNugget() { }

virtual void apply(Object* targetObj, const Object* sourceObj, BuffEffectTracker* buffTracker) const = 0;

virtual void remove(Object* targetObj, BuffEffectTracker* buffTracker) const = 0;


};
EMPTY_DTOR(BuffEffectNugget)

// -----------------------------------------------
// -----------------------------------------------

class BuffTemplate : public MemoryPoolObject
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(BuffTemplate, "BuffTemplate")

public:
// for lookup
AsciiString getName(void) const { return m_name; }
void friend_setName(const AsciiString& n) { m_name = n; }

inline UnsignedInt getMaxStackSize() const { return m_maxStackSize; }
inline Bool isStackPerSource() const { return m_stackPerSource; }
inline const std::vector<AsciiString>& getPriorityTemplates() const { return m_priorityTemplates; }

//inline WeaponBonusConditionType getWeaponBonusType() const { return m_bonusType; }
//inline WeaponBonusConditionType getWeaponBonusTypeAgainst() const { return m_bonusTypeAgainst; }
//inline WeaponSetType getWeaponSetFlag() const { return m_weaponSetFlag; }
//inline ArmorSetType getArmorSetFlag() const { return m_armorSetFlag; }
//inline ObjectStatusMaskType getStatusToSet() const { return m_statusToSet; }

BuffTemplate();

/**
Toss the contents.
*/
void clear();

void addBuffEffectNugget(BuffEffectNugget* nugget);

UnsignedInt getNextTickFrame(UnsignedInt startFrame, UnsignedInt endFrame) const;

void applyEffects(Object* targetObj, Object* sourceObj, BuffEffectTracker* buffTracker) const;
void removeEffects(Object* targetObj, BuffEffectTracker* buffTracker, Bool ignoreFlags = FALSE) const;

Bool hasPriorityOver(AsciiString templateName) const;

void reApplyFlags(Object* targetObj, const BuffTemplate* other) const;

const FieldParse* getFieldParse(void) const { return TheBuffTemplateFieldParse; }


protected:
AsciiString m_name;
UnsignedInt m_maxStackSize;
Bool m_stackPerSource; ///< Each sourceObj has its own stack of buffs on the target.

std::vector<AsciiString> m_priorityTemplates; ///< list of buffTemplates this template has priority over.

// Flags are stored directly in BuffTemplate
WeaponBonusConditionType m_bonusType; ///< weapon bonus granted to the object
WeaponBonusConditionType m_bonusTypeAgainst; ///< weapon bonus granted when attacking the object
WeaponSetType m_weaponSetFlag; ///< the weaponset flag to set
ArmorSetType m_armorSetFlag; ///< the armorset flag to set
ObjectStatusMaskType m_statusToSet; ///< the status to set (allows multiple)

// --
static const FieldParse TheBuffTemplateFieldParse[];
//static const FieldParse flagModifierFieldParse[];

static void parseFlagModifier(INI* ini, void* instance, void* store, const void* userData);

private:

// note, this list doesn't own the nuggets; all nuggets are owned by the Store.
typedef std::vector<BuffEffectNugget*> BuffEffectNuggetVector;
BuffEffectNuggetVector m_nuggets;

};
EMPTY_DTOR(BuffTemplate)

//-------------------------------------------------------------------------------------------------
/**
The "store" used to hold all the Buffs in existence.
*/
class BuffTemplateStore : public SubsystemInterface
{

public:

BuffTemplateStore();
~BuffTemplateStore();

void init() {}
void reset() {}
void update() {}

/**
return the BuffTemplate with the given namekey.
return NULL if no such BuffTemplate exists.
*/
const BuffTemplate* findBuffTemplate(const char* name) const;
const BuffTemplate* findBuffTemplate(const AsciiString& name) const { return findBuffTemplate(name.str()); }

BuffTemplate* findBuffTemplate(const char* name);
BuffTemplate* findBuffTemplate(AsciiString& name) { return findBuffTemplate(name.str()); }

//BuffTemplate* newBuffTemplate(AsciiString& name);

static void parseBuffTemplateDefinition(INI* ini);

void addBuffEffectNugget(BuffEffectNugget* nugget);

private:

typedef std::map< NameKeyType, BuffTemplate*, std::less<NameKeyType> > BuffTemplateMap;
BuffTemplateMap m_buffTemplates;

// note, this list doesn't own the nuggets; all nuggets are owned by the Store.
typedef std::vector<BuffEffectNugget*> BuffEffectNuggetVector;
BuffEffectNuggetVector m_nuggets;

};

// EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
extern BuffTemplateStore* TheBuffTemplateStore;

#endif // _Buff_H_

3 changes: 3 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/FiringTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "Common/GameMemory.h"
#include "Common/AudioEventRTS.h"
#include "GameLogic/Module/UpdateModule.h"
#include "GameLogic/WeaponBonusConditionFlags.h"

class Object;
class Weapon;
Expand Down Expand Up @@ -90,6 +91,8 @@ class FiringTracker : public UpdateModule

UnsignedInt m_frameToStopLoopingSound; ///< if sound is looping, frame to stop looping it (or zero if not looping)
AudioHandle m_audioHandle;

WeaponBonusConditionFlags m_prevTargetWeaponBonus; ///< weaponBonus against previous target
};

#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface

Bool canAutoAcquireWhileStealthed() const;

void applySpeedMultiplier(Real scalar);
inline Real getSpeedMultiplier(void) const { return m_speedMultiplier; }

protected:

Expand Down Expand Up @@ -812,6 +814,8 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface
Bool m_allowedToChase; ///< Allowed to pursue targets.
Bool m_isInUpdate; ///< If true, we are inside our update method.
Bool m_fixLocoInPostProcess;

Real m_speedMultiplier; ///< global multiplier to move speed (kept in AIUpdate rather than Locomotor because it's persistent)
};

//------------------------------------------------------------------------------------------------------------
Expand Down
Loading