mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-17 09:14:34 +00:00
feat(Core/Unit): New helper IsClass and script hook OnPlayerIsClass (#18243)
* Class Comparison Logic Encapsulation - Parity * Add Context to IsClass * Add Unit IsClass script hook * Replace additional getClass with IsClass * Update CanUseItem to replace getClass with IsClass * Add separate context for pet vs ability * Change Create to Init since not all referenced contexts are creation * Align spacing in ClassContext * Drop context on LFGManager max power * Update IsClass context that wraps around Missle Barrage * Rename context for swapping weapons * Be more specific than CLASS_CONTEXT_TALENT * Remove duplicate context * Moved IsClass Hook to Player * Removed unused parameter in virtual base function * Added maybe_unused to IsClass virtual in order to compile To match the override signature, the virtual base needs to include the parameter in question, so using [maybe_unused] to signal to the compiler to allow it * Remove extra blank line * Add ABILITY_REACTIVE context * Add context for PET_CHARM * Remove explicit nullopt check per review * Code Readability - Change if to if else in pet Due to the return pattern, this doesn't change functionality in any way * Add OnPlayer to disambiguate --------- Co-authored-by: NathanHandley <nathanhandley@protonmail.com>
This commit is contained in:
@@ -440,6 +440,29 @@ enum DamageEffectType : uint8
|
||||
SELF_DAMAGE = 5
|
||||
};
|
||||
|
||||
// Used for IsClass hook
|
||||
enum ClassContext : uint8
|
||||
{
|
||||
CLASS_CONTEXT_NONE = 0, // Default
|
||||
CLASS_CONTEXT_INIT = 1,
|
||||
CLASS_CONTEXT_TELEPORT = 2,
|
||||
CLASS_CONTEXT_QUEST = 3,
|
||||
CLASS_CONTEXT_STATS = 4,
|
||||
CLASS_CONTEXT_TAXI = 5,
|
||||
CLASS_CONTEXT_SKILL = 6,
|
||||
CLASS_CONTEXT_TALENT_POINT_CALC = 7,
|
||||
CLASS_CONTEXT_ABILITY = 8,
|
||||
CLASS_CONTEXT_ABILITY_REACTIVE = 9,
|
||||
CLASS_CONTEXT_PET = 10,
|
||||
CLASS_CONTEXT_PET_CHARM = 11,
|
||||
CLASS_CONTEXT_EQUIP_RELIC = 12,
|
||||
CLASS_CONTEXT_EQUIP_SHIELDS = 13,
|
||||
CLASS_CONTEXT_EQUIP_ARMOR_CLASS = 14,
|
||||
CLASS_CONTEXT_WEAPON_SWAP = 15,
|
||||
CLASS_CONTEXT_GRAVEYARD = 16,
|
||||
CLASS_CONTEXT_CLASS_TRAINER = 17
|
||||
};
|
||||
|
||||
// Value masks for UNIT_FIELD_FLAGS
|
||||
// EnumUtils: DESCRIBE THIS
|
||||
enum UnitFlags : uint32
|
||||
@@ -1436,6 +1459,7 @@ public:
|
||||
void setRace(uint8 race);
|
||||
[[nodiscard]] uint32 getRaceMask() const { return 1 << (getRace(true) - 1); }
|
||||
[[nodiscard]] uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); }
|
||||
[[nodiscard]] virtual bool IsClass(Classes unitClass, [[maybe_unused]] ClassContext context = CLASS_CONTEXT_NONE) const { return (getClass() == unitClass); }
|
||||
[[nodiscard]] uint32 getClassMask() const { return 1 << (getClass() - 1); }
|
||||
[[nodiscard]] uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); }
|
||||
[[nodiscard]] DisplayRace GetDisplayRaceFromModelId(uint32 modelId) const;
|
||||
|
||||
Reference in New Issue
Block a user