mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-31 09:33:47 +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:
@@ -853,12 +853,12 @@ public:
|
||||
{
|
||||
if (p->getPowerType() != POWER_MANA)
|
||||
return true;
|
||||
if (p->getClass() == CLASS_HUNTER)
|
||||
if (p->IsClass(CLASS_HUNTER))
|
||||
return true;
|
||||
uint8 maxIndex = p->GetMostPointsTalentTree();
|
||||
if ((p->getClass() == CLASS_PALADIN && maxIndex >= 1) || (p->getClass() == CLASS_SHAMAN && maxIndex == 1) || (p->getClass() == CLASS_DRUID && maxIndex == 1))
|
||||
if ((p->IsClass(CLASS_PALADIN) && maxIndex >= 1) || (p->IsClass(CLASS_SHAMAN) && maxIndex == 1) || (p->IsClass(CLASS_DRUID) && maxIndex == 1))
|
||||
return true;
|
||||
if (_removeHealers == ((p->getClass() == CLASS_DRUID && maxIndex == 2) || (p->getClass() == CLASS_PALADIN && maxIndex == 0) || (p->getClass() == CLASS_PRIEST && maxIndex <= 1) || (p->getClass() == CLASS_SHAMAN && maxIndex == 2)))
|
||||
if (_removeHealers == ((p->IsClass(CLASS_DRUID) && maxIndex == 2) || (p->IsClass(CLASS_PALADIN) && maxIndex == 0) || (p->IsClass(CLASS_PRIEST) && maxIndex <= 1) || (p->IsClass(CLASS_SHAMAN) && maxIndex == 2)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -2856,8 +2856,7 @@ public:
|
||||
{
|
||||
c->AI()->AttackStart(target);
|
||||
DoZoneInCombat(c);
|
||||
uint8 Class = target->getClass();
|
||||
if (Class != CLASS_DRUID)
|
||||
if (!target->IsClass(CLASS_DRUID))
|
||||
if (Player* p = target->ToPlayer())
|
||||
{
|
||||
if (Item* i = p->GetWeaponForAttack(BASE_ATTACK))
|
||||
@@ -2869,7 +2868,7 @@ public:
|
||||
|
||||
target->CastSpell(c, 60352, true); // Mirror Image, clone visual appearance
|
||||
}
|
||||
c->AI()->DoAction(Class);
|
||||
c->AI()->DoAction(target->getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user