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
7 changes: 6 additions & 1 deletion Generals/Code/GameEngine/Include/Common/DisabledTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "Lib/BaseType.h"
#include "Common/BitFlags.h"
#include "Common/BitFlagsIO.h"

//-------------------------------------------------------------------------------------------------
/** Kind of flags for determining groups of things that belong together
Expand All @@ -48,11 +49,16 @@ enum DisabledType CPP_11(: Int)
DISABLED_UNDERPOWERED,//Separate from ScriptUnderpowered, the owning player has insufficient power. Energy status controls this
DISABLED_FREEFALL, //This unit has been disabled via being in free fall

DISABLED_AWESTRUCK,
Comment thread
Skyaero42 marked this conversation as resolved.
DISABLED_BRAINWASHED,
DISABLED_SUBDUED, ///< Temporarily shut down by Subdual damage
//These ones are specifically for scripts to enable/reenable!
DISABLED_SCRIPT_DISABLED,
DISABLED_SCRIPT_UNDERPOWERED,

DISABLED_COUNT,

DISABLED_ANY = 65535 ///< Do not use this value for setting disabled types (read-only)
};

typedef BitFlags<DISABLED_COUNT> DisabledMaskType;
Expand Down Expand Up @@ -102,6 +108,5 @@ inline void FLIP_DISABLEDMASK(DisabledMaskType& m)


// defined in Common/System/DisabledTypes.cpp
extern const char *TheDisabledNames[];
extern DisabledMaskType DISABLEDMASK_NONE; // inits to all zeroes
extern DisabledMaskType DISABLEDMASK_ALL; // inits to all bits set.
16 changes: 16 additions & 0 deletions Generals/Code/GameEngine/Include/Common/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,22 @@ class Player : public Snapshot
if he has multiple, return one arbitrarily. */
Object* findNaturalCommandCenter();

Object* findAnyExistingObjectWithThingTemplate( const ThingTemplate *thing );

// Finds a short-cut firing special power of specified type returning the first ready power or
// the most ready if none ready.
Object* findMostReadyShortcutSpecialPowerOfType( SpecialPowerType spType );

//Find specified thing template's most ready weapon.
Object* findMostReadyShortcutWeaponForThing( const ThingTemplate *thing, UnsignedInt &mostReadyPercentage );
Object* findMostReadyShortcutSpecialPowerForThing( const ThingTemplate *thing, UnsignedInt &mostReadyPercentage );

// Finds a short-cut firing special power of any type arbitrarily.
Bool hasAnyShortcutSpecialPower();

// Counts available shortcut special power of specified type that can fire now.
Int countReadyShortcutSpecialPowersOfType( SpecialPowerType spType );

/// return t if the player has the given science, either intrinsically, via specialization, or via capture.
Bool hasScience(ScienceType t) const;
Bool isScienceDisabled( ScienceType t ) const; ///< Can't purchase this science because of script reasons.
Expand Down
47 changes: 37 additions & 10 deletions Generals/Code/GameEngine/Include/GameClient/ControlBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ControlBarSchemeManager;
class UpgradeTemplate;
class ControlBarResizer;
class GameWindowTransitionsHandler;
class DisplayString;

enum ProductionID CPP_11(: Int);

Expand Down Expand Up @@ -96,6 +97,8 @@ enum CommandOption CPP_11(: Int)
SCRIPT_ONLY = 0x00080000, // Only a script can use this command (not by users)
IGNORES_UNDERPOWERED = 0x00100000, // this button isn't disabled if its object is merely underpowered
USES_MINE_CLEARING_WEAPONSET= 0x00200000, // uses the special mine-clearing weaponset, even if not current
CAN_USE_WAYPOINTS = 0x00400000, // button has option to use a waypoint path
MUST_BE_STOPPED = 0x00800000, // Unit must be stopped in order to be able to use button.
};

#ifdef DEFINE_COMMAND_OPTION_NAMES
Expand Down Expand Up @@ -127,6 +130,8 @@ static const char *const TheCommandOptionNames[] =
"SCRIPT_ONLY",
"IGNORES_UNDERPOWERED",
"USES_MINE_CLEARING_WEAPONSET",
"CAN_USE_WAYPOINTS",
"MUST_BE_STOPPED",

nullptr
};
Expand Down Expand Up @@ -181,25 +186,33 @@ enum GUICommandType CPP_11(: Int)
GUI_COMMAND_FIRE_WEAPON, ///< fire a weapon
GUI_COMMAND_SPECIAL_POWER, ///< do a special power
GUI_COMMAND_PURCHASE_SCIENCE, ///< purchase science
GUI_COMMAND_HACK_INTERNET, ///< Hey author, write me!
GUI_COMMAND_HACK_INTERNET, ///< gain income from the ether (by hacking the internet)
GUI_COMMAND_TOGGLE_OVERCHARGE, ///< Overcharge command for power plants
#ifdef ALLOW_SURRENDER
GUI_COMMAND_POW_RETURN_TO_PRISON, ///< POW Truck, return to prison
#endif
GUI_COMMAND_COMBATDROP, ///< rappel contents to ground or bldg
GUI_COMMAND_SWITCH_WEAPON, ///< switch weapon use

//Context senstive command modes
//Context sensitive command modes
GUICOMMANDMODE_HIJACK_VEHICLE,
GUICOMMANDMODE_CONVERT_TO_CARBOMB,
GUICOMMANDMODE_SABOTAGE_BUILDING,
#ifdef ALLOW_SURRENDER
GUICOMMANDMODE_PICK_UP_PRISONER, ///< POW Truck assigned to pick up a specific prisoner
#endif

// context-insensitive command mode(s)
GUICOMMANDMODE_PLACE_BEACON,

GUI_COMMAND_SPECIAL_POWER_FROM_COMMAND_CENTER, ///< do a special power from localPlayer's command center, regardless of selection
GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT, ///< do a special power from localPlayer's command center, regardless of selection
#if RTS_GENERALS
GUI_COMMAND_SPECIAL_POWER_FROM_COMMAND_CENTER = GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT, ///< Legacy name
Comment thread
Skyaero42 marked this conversation as resolved.
#endif
GUI_COMMAND_SPECIAL_POWER_CONSTRUCT, ///< do a special power using the construct building interface
GUI_COMMAND_SPECIAL_POWER_CONSTRUCT_FROM_SHORTCUT, ///< do a shortcut special power using the construct building interface

GUI_COMMAND_SELECT_ALL_UNITS_OF_TYPE,

// add more commands here, don't forget to update the string command list below too ...

Expand Down Expand Up @@ -241,11 +254,19 @@ static const char *const TheGuiCommandNames[] =
"SWITCH_WEAPON",
"HIJACK_VEHICLE",
"CONVERT_TO_CARBOMB",
"SABOTAGE_BUILDING",
#ifdef ALLOW_SURRENDER
"PICK_UP_PRISONER",
#endif
"PLACE_BEACON",
"SPECIAL_POWER_FROM_COMMAND_CENTER",
#if RTS_GENERALS
"SPECIAL_POWER_FROM_COMMAND_CENTER", ///< Legacy name
Comment thread
Skyaero42 marked this conversation as resolved.
#else
"SPECIAL_POWER_FROM_SHORTCUT",
#endif
"SPECIAL_POWER_CONSTRUCT",
"SPECIAL_POWER_CONSTRUCT_FROM_SHORTCUT",
"SELECT_ALL_UNITS_OF_TYPE",

nullptr
};
Expand Down Expand Up @@ -386,16 +407,16 @@ class CommandButton : public Overridable
/** Command sets are collections of configurable command buttons. They are used in the
* command context sensitive window in the battle user interface */
//-------------------------------------------------------------------------------------------------
enum { MAX_COMMANDS_PER_SET = 12 }; // user interface max button limit for commands
enum { MAX_COMMANDS_PER_SET = 18 }; // user interface max is 14 (but internally it's 18 for script only buttons!)
enum { MAX_RIGHT_HUD_UPGRADE_CAMEOS = 5};
enum {
MAX_PURCHASE_SCIENCE_RANK_1 = 3,
MAX_PURCHASE_SCIENCE_RANK_3 = 12,
MAX_PURCHASE_SCIENCE_RANK_8 = 1,
MAX_PURCHASE_SCIENCE_RANK_1 = 4,
MAX_PURCHASE_SCIENCE_RANK_3 = 15,
MAX_PURCHASE_SCIENCE_RANK_8 = 4,
};
enum { MAX_STRUCTURE_INVENTORY_BUTTONS = 10 }; // there are this many physical buttons in "inventory" windows for structures
enum { MAX_BUILD_QUEUE_BUTTONS = 9 };// physical button count for the build queue
enum { MAX_SPECIAL_POWER_SHORTCUTS = 5};
enum { MAX_SPECIAL_POWER_SHORTCUTS = 11};
class CommandSet : public Overridable
{

Expand Down Expand Up @@ -760,6 +781,11 @@ class ControlBar : public SubsystemInterface
void initSpecialPowershortcutBar( Player *player);

void triggerRadarAttackGlow();

void drawSpecialPowerShortcutMultiplierText();

Bool hasAnyShortcutSelection() const;

protected:
void updateRadarAttackGlow ();

Expand Down Expand Up @@ -824,7 +850,7 @@ class ControlBar : public SubsystemInterface
static void populateInvDataCallback( Object *obj, void *userData );

// the following methods are for updating the currently showing context
CommandAvailability getCommandAvailability( const CommandButton *command, Object *obj, GameWindow *win, Bool forceDisabledEvaluation = FALSE ) const;
CommandAvailability getCommandAvailability( const CommandButton *command, Object *obj, GameWindow *win, GameWindow *applyToWin = nullptr, Bool forceDisabledEvaluation = FALSE ) const;
void updateContextMultiSelect();
void updateContextPurchaseScience();
void updateContextCommand();
Expand Down Expand Up @@ -893,6 +919,7 @@ class ControlBar : public SubsystemInterface
GameWindow *m_sciencePurchaseWindowsRank8[ MAX_PURCHASE_SCIENCE_RANK_8 ]; ///< command window controls for easy access
GameWindow *m_specialPowerShortcutButtons[ MAX_SPECIAL_POWER_SHORTCUTS ];
GameWindow *m_specialPowerShortcutButtonParents[ MAX_SPECIAL_POWER_SHORTCUTS ];
DisplayString *m_shortcutDisplayStrings[ MAX_SPECIAL_POWER_SHORTCUTS ];
Int m_currentlyUsedSpecialPowersButtons; ///< Value will be <= MAX_SPECIAL_POWER_SHORTCUTS;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ class ProductionUpdateInterface

virtual void setHoldDoorOpen(ExitDoorType exitDoor, Bool holdIt) = 0;

//These functions keep track of the special power construction of a new building via a special power instead of standard production interface.
//This was added for the sneak attack building functionality.
virtual const CommandButton* getSpecialPowerConstructionCommandButton() const = 0;
virtual void setSpecialPowerConstructionCommandButton( const CommandButton *commandButton ) = 0;

};

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -224,6 +229,11 @@ class ProductionUpdate : public UpdateModule, public ProductionUpdateInterface,

virtual UpdateSleepTime update() override; ///< the update

//These functions keep track of the special power construction of a new building via a special power instead of standard production interface.
//This was added for the sneak attack building functionality.
virtual const CommandButton* getSpecialPowerConstructionCommandButton() const override { return m_specialPowerConstructionCommandButton; }
virtual void setSpecialPowerConstructionCommandButton( const CommandButton *commandButton ) override { m_specialPowerConstructionCommandButton = commandButton; }

// DieModuleInterface
virtual void onDie( const DamageInfo *damageInfo ) override;

Expand All @@ -243,6 +253,7 @@ class ProductionUpdate : public UpdateModule, public ProductionUpdateInterface,
Bool m_holdOpen; ///< if T, don't allow door to close
};

const CommandButton *m_specialPowerConstructionCommandButton; ///< In a mode to construct a specific building via a special power. (NO NEED TO SAVE DATA ON THIS FIELD)
ProductionEntry* m_productionQueue; ///< queue of things we want to build
ProductionEntry* m_productionQueueTail; ///< tail pointer for m_productionQueue
ProductionID m_uniqueID; ///< unique ID counter for producing units
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class SpecialPowerModuleInterface
virtual void markSpecialPowerTriggered( const Coord3D *location ) = 0;
virtual void startPowerRecharge() = 0;
virtual const AudioEventRTS& getInitiateSound() const = 0;
virtual Bool isScriptOnly() const = 0;
};

//-------------------------------------------------------------------------------------------------
Expand All @@ -79,9 +80,10 @@ class SpecialPowerModuleData : public BehaviorModuleData
static void buildFieldParse(MultiIniFieldParse& p);

const SpecialPowerTemplate *m_specialPowerTemplate; ///< pointer to the special power template
Bool m_updateModuleStartsAttack; ///< update module determines when the special power actually starts! If true, update module is required.
Bool m_startsPaused; ///< Paused on creation, someone else will have to unpause (like upgrade module, or script)
AudioEventRTS m_initiateSound;
AudioEventRTS m_initiateSound;
Bool m_updateModuleStartsAttack; ///< update module determines when the special power actually starts! If true, update module is required.
Bool m_startsPaused; ///< Paused on creation, someone else will have to unpause (like upgrade module, or script)
Bool m_scriptedSpecialPowerOnly;
};

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -152,6 +154,8 @@ class SpecialPowerModule : public BehaviorModule,
virtual void startPowerRecharge() override;
virtual const AudioEventRTS& getInitiateSound() const override;

virtual Bool isScriptOnly() const override;

protected:

Bool initiateIntentToDoSpecialPower( const Object *targetObj, const Coord3D *targetPos, const Waypoint *way, UnsignedInt commandOptions );
Expand Down
2 changes: 2 additions & 0 deletions Generals/Code/GameEngine/Include/GameLogic/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ class Object : public Thing, public Snapshot
Bool hasAnyDamageWeapon() const; //Kris: a should be used for real weapons that directly inflict damage... not deploy, hack, etc.
Bool hasWeaponToDealDamageType(DamageType typeToDeal) const;
Real getLargestWeaponRange() const;
UnsignedInt getMostPercentReadyToFireAnyWeapon() const;

Weapon* getWeaponInWeaponSlot(WeaponSlotType wslot) const { return m_weaponSet.getWeaponInWeaponSlot(wslot); }

Expand Down Expand Up @@ -525,6 +526,7 @@ class Object : public Thing, public Snapshot
/// return true if the template has the specified special power flag set
// @todo: inline
Bool hasSpecialPower( SpecialPowerType type ) const;
Bool hasAnySpecialPower() const;

void setWeaponBonusCondition(WeaponBonusConditionType wst) { m_weaponBonusCondition |= (1 << wst); }
void clearWeaponBonusCondition(WeaponBonusConditionType wst) { m_weaponBonusCondition &= ~(1 << wst); }
Expand Down
1 change: 1 addition & 0 deletions Generals/Code/GameEngine/Include/GameLogic/WeaponSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class WeaponSet : public Snapshot
WeaponSlotType getCurWeaponSlot() const { return m_curWeapon; }
Weapon* findWaypointFollowingCapableWeapon();
const Weapon* findAmmoPipShowingWeapon() const;
UnsignedInt getMostPercentReadyToFireAnyWeapon() const;

Bool setWeaponLock( WeaponSlotType weaponSlot, WeaponLockType lockType );
void releaseWeaponLock(WeaponLockType lockType);
Expand Down
Loading
Loading