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
4 changes: 2 additions & 2 deletions Generals/Code/GameEngine/Include/Common/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ class Player : public Snapshot
/// return t iff the player has all sciences that are prereqs for knowing the given science
Bool hasPrereqsForScience(ScienceType t) const;

Bool hasUpgradeComplete( const UpgradeTemplate *upgradeTemplate ); ///< does player have totally done and produced upgrade
Bool hasUpgradeComplete( UpgradeMaskType testMask ); ///< does player have totally done and produced upgrade
Bool hasUpgradeComplete( const UpgradeTemplate *upgradeTemplate ) const; ///< does player have totally done and produced upgrade
Bool hasUpgradeComplete( UpgradeMaskType testMask ) const; ///< does player have totally done and produced upgrade
UpgradeMaskType getCompletedUpgradeMask() const { return m_upgradesCompleted; } ///< get list of upgrades that are completed
Bool hasUpgradeInProduction( const UpgradeTemplate *upgradeTemplate ); ///< does player have this upgrade in progress right now
Upgrade *addUpgrade( const UpgradeTemplate *upgradeTemplate,
Expand Down
7 changes: 6 additions & 1 deletion Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class HackInternetAIInterface;
class AssaultTransportAIInterface;

enum AIStateType CPP_11(: Int);
enum HordeActionType CPP_11(: Int);
enum ObjectID CPP_11(: Int);


Expand Down Expand Up @@ -547,7 +548,11 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface
void setAttitude( AttitudeType tude ); ///< set the behavior modifier for this agent

// Common AI "status" effects -------------------------------------------------------------------
void evaluateMoraleBonus( void );
Bool hasNationalism() const;
Bool hasFanaticism() const;
void evaluateMoraleBonus( Bool inHorde, Bool allowNationalism, HordeActionType type );
void evaluateNationalismBonusClassic( Bool inHorde, Bool allowNationalism );
void evaluateNationalismBonus( Bool inHorde, Bool allowNationalism );

#ifdef ALLOW_DEMORALIZE
// demoralization ... what a nifty word to write.
Expand Down
47 changes: 35 additions & 12 deletions Generals/Code/GameEngine/Include/GameLogic/Module/HordeUpdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,38 @@ class UpgradeTemplate;
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------

// TheSuperHackers @bugfix xezon 15/09/2025 Adds a new horde action to select a fixed implementation.
//
// TheSuperHackers @todo If we want more control over the horde setup, then we need to implement
// filters for separate weapon bonuses and required upgrades. But adding more behavior modules will
// be a performance concern. Example INI setup:
//
// Behavior = HordeUpdate ModuleTag
// Action = NATIONALISM
// ;ApplyWeaponBonus = NATIONALISM
// UpgradeRequired = Upgrade_Nationalism
// End
//
enum HordeActionType CPP_11(: Int)
{
HORDEACTION_HORDE = 0,
HORDEACTION_HORDE, ///< Classic action, applies the Horde bonus correctly, but Nationalism and Fanaticism bonuses are not removed after leaving horde.
HORDEACTION_HORDE_FIXED, ///< Applies the Horde, Nationalism and Fanaticism bonuses correctly.

HORDEACTION_COUNT
HORDEACTION_COUNT,

#if RETAIL_COMPATIBLE_CRC
HORDEACTION_DEFAULT = HORDEACTION_HORDE,
#else
HORDEACTION_DEFAULT = HORDEACTION_HORDE_FIXED, ///< Does not change unmodified retail game behavior, because all its horde update modules explicitly set Action = HORDE.
#endif
};

#ifdef DEFINE_HORDEACTION_NAMES
static const char *const TheHordeActionTypeNames[] =
{
"HORDE",
"HORDE_FIXED",

NULL
};
static_assert(ARRAY_SIZE(TheHordeActionTypeNames) == HORDEACTION_COUNT + 1, "Incorrect array size");
Expand All @@ -62,15 +83,15 @@ class HordeUpdateModuleData : public ModuleData
{
public:
UnsignedInt m_updateRate; ///< how often to recheck our horde status
KindOfMaskType m_kindof; ///< the kind(s) of units that count towards horde-ness
KindOfMaskType m_kindof; ///< the kind(s) of units that count towards hordeness
Int m_minCount; ///< min count to get "horde" status
Real m_minDist; ///< min dist to contribute to horde-ness
Real m_minDist; ///< min dist to contribute to hordeness
Bool m_alliesOnly; ///< if true, only allied units count towards hordeness
Bool m_exactMatch; ///< if true, only exact same type of units count towards hordeness
Real m_rubOffRadius;///< If I am this close to another guy who is a true hordesman, it'll rub off on me
HordeActionType m_action; ///< what to do if we get horde-ness
Bool m_allowedNationalism; ///< Nationalism is hard ocded. Yeah! Add to the goodness with this flag instead of rewriting after Alpha.
std::vector<AsciiString> m_flagSubObjNames; ///< name(s) of the flag subobj
HordeActionType m_action; ///< what to do if we get hordeness
Bool m_allowedNationalism; ///< Nationalism is hard coded. Yeah! Add to the goodness with this flag instead of rewriting after Alpha.
std::vector<AsciiString> m_flagSubObjNames; ///< name(s) of the flag sub obj

HordeUpdateModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
Expand All @@ -87,7 +108,7 @@ class HordeUpdateInterface
virtual Bool hasFlag() const = 0;
virtual Bool isTrueHordeMember() const = 0;
virtual Bool isAllowedNationalism() const = 0;

virtual HordeActionType getHordeActionType() const = 0;
};

//-------------------------------------------------------------------------------------------------
Expand All @@ -104,11 +125,13 @@ class HordeUpdate : public UpdateModule, public HordeUpdateInterface
HordeUpdateInterface *getHordeUpdateInterface() { return this; }

virtual void onDrawableBoundToObject();
virtual UpdateSleepTime update(); ///< update this object's AI

virtual Bool isInHorde() const { return m_inHorde; }
virtual Bool hasFlag() const { return m_hasFlag; }
virtual Bool isTrueHordeMember() const { return m_trueHordeMember && m_inHorde; }
virtual Bool isAllowedNationalism() const;
virtual Bool hasFlag() const { return m_hasFlag; }
virtual UpdateSleepTime update(); ///< update this object's AI
virtual HordeActionType getHordeActionType() const { return getHordeUpdateModuleData()->m_action; };

protected:

Expand All @@ -117,8 +140,8 @@ class HordeUpdate : public UpdateModule, public HordeUpdateInterface

private:
UnsignedInt m_lastHordeRefreshFrame; //Just like it sounds
Bool m_inHorde; //I amy be a trueMember, or I may merely inherit hordehood from a neighbor who is
Bool m_trueHordeMember; //meaning, I have enough hordesman near me to qualify
Bool m_inHorde; //I may be a true member, or I may merely inherit hordehood from a neighbor who is
Bool m_trueHordeMember; //meaning, I have enough hordesmen near me to qualify
Bool m_hasFlag;

};
4 changes: 2 additions & 2 deletions Generals/Code/GameEngine/Source/Common/RTS/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2511,7 +2511,7 @@ Upgrade *Player::findUpgrade( const UpgradeTemplate *upgradeTemplate )
//=================================================================================================
/** Does the player have this completed upgrade */
//=================================================================================================
Bool Player::hasUpgradeComplete( const UpgradeTemplate *upgradeTemplate )
Bool Player::hasUpgradeComplete( const UpgradeTemplate *upgradeTemplate ) const
{
UpgradeMaskType testMask = upgradeTemplate->getUpgradeMask();
return hasUpgradeComplete( testMask );
Expand All @@ -2522,7 +2522,7 @@ Bool Player::hasUpgradeComplete( const UpgradeTemplate *upgradeTemplate )
Does the player have this completed upgrade. This form is exposed so Objects can do quick lookups.
*/
//=================================================================================================
Bool Player::hasUpgradeComplete( UpgradeMaskType testMask )
Bool Player::hasUpgradeComplete( UpgradeMaskType testMask ) const
{
return m_upgradesCompleted.testForAll( testMask );
}
Expand Down
Loading
Loading