mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 01:59:09 +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:
@@ -8834,7 +8834,7 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp
|
||||
// Convert recently used Blood Rune to Death Rune
|
||||
if (Player* player = ToPlayer())
|
||||
{
|
||||
if (player->getClass() != CLASS_DEATH_KNIGHT)
|
||||
if (!player->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY))
|
||||
return false;
|
||||
|
||||
// xinef: not true
|
||||
@@ -9565,7 +9565,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
|
||||
// Item - Death Knight T10 Melee 4P Bonus
|
||||
if (auraSpellInfo->Id == 70656)
|
||||
{
|
||||
if (GetTypeId() != TYPEID_PLAYER || getClass() != CLASS_DEATH_KNIGHT)
|
||||
if (GetTypeId() != TYPEID_PLAYER || !IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY))
|
||||
return false;
|
||||
|
||||
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
||||
@@ -9576,7 +9576,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
|
||||
else if (auraSpellInfo->SpellIconID == 85)
|
||||
{
|
||||
Player* plr = ToPlayer();
|
||||
if (!plr || plr->getClass() != CLASS_DEATH_KNIGHT || !procSpell)
|
||||
if (!plr || !plr->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY) || !procSpell)
|
||||
return false;
|
||||
|
||||
if (!plr->IsBaseRuneSlotsOnCooldown(RUNE_BLOOD))
|
||||
@@ -13823,7 +13823,7 @@ void Unit::ClearInCombat()
|
||||
else if (Player* player = ToPlayer())
|
||||
{
|
||||
player->UpdatePotionCooldown();
|
||||
if (player->getClass() == CLASS_DEATH_KNIGHT)
|
||||
if (player->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY))
|
||||
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
||||
player->SetGracePeriod(i, 0);
|
||||
}
|
||||
@@ -16361,7 +16361,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
if (procExtra & PROC_EX_DODGE)
|
||||
{
|
||||
// Update AURA_STATE on dodge
|
||||
if (getClass() != CLASS_ROGUE) // skip Rogue Riposte
|
||||
if (!IsClass(CLASS_ROGUE, CLASS_CONTEXT_ABILITY_REACTIVE)) // skip Rogue Riposte
|
||||
{
|
||||
ModifyAuraState(AURA_STATE_DEFENSE, true);
|
||||
StartReactiveTimer(REACTIVE_DEFENSE);
|
||||
@@ -16371,7 +16371,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
if (procExtra & PROC_EX_PARRY)
|
||||
{
|
||||
// For Hunters only Counterattack (skip Mongoose bite)
|
||||
if (getClass() == CLASS_HUNTER)
|
||||
if (IsClass(CLASS_HUNTER, CLASS_CONTEXT_ABILITY_REACTIVE))
|
||||
{
|
||||
ModifyAuraState(AURA_STATE_HUNTER_PARRY, true);
|
||||
StartReactiveTimer(REACTIVE_HUNTER_PARRY);
|
||||
@@ -16394,7 +16394,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
|
||||
// Overpower on victim dodge
|
||||
if (procExtra & PROC_EX_DODGE)
|
||||
{
|
||||
if (getClass() == CLASS_WARRIOR)
|
||||
if (IsClass(CLASS_WARRIOR, CLASS_CONTEXT_ABILITY_REACTIVE))
|
||||
{
|
||||
AddComboPoints(target, 1);
|
||||
StartReactiveTimer(REACTIVE_OVERPOWER);
|
||||
@@ -17201,9 +17201,9 @@ void Unit::ClearAllReactives()
|
||||
|
||||
if (HasAuraState(AURA_STATE_DEFENSE))
|
||||
ModifyAuraState(AURA_STATE_DEFENSE, false);
|
||||
if (getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY))
|
||||
if (IsClass(CLASS_HUNTER, CLASS_CONTEXT_ABILITY_REACTIVE) && HasAuraState(AURA_STATE_HUNTER_PARRY))
|
||||
ModifyAuraState(AURA_STATE_HUNTER_PARRY, false);
|
||||
if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER)
|
||||
if (IsClass(CLASS_WARRIOR, CLASS_CONTEXT_ABILITY_REACTIVE) && GetTypeId() == TYPEID_PLAYER)
|
||||
ClearComboPoints();
|
||||
}
|
||||
|
||||
@@ -17227,11 +17227,11 @@ void Unit::UpdateReactives(uint32 p_time)
|
||||
ModifyAuraState(AURA_STATE_DEFENSE, false);
|
||||
break;
|
||||
case REACTIVE_HUNTER_PARRY:
|
||||
if (getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY))
|
||||
if (IsClass(CLASS_HUNTER, CLASS_CONTEXT_ABILITY_REACTIVE) && HasAuraState(AURA_STATE_HUNTER_PARRY))
|
||||
ModifyAuraState(AURA_STATE_HUNTER_PARRY, false);
|
||||
break;
|
||||
case REACTIVE_OVERPOWER:
|
||||
if (getClass() == CLASS_WARRIOR)
|
||||
if (IsClass(CLASS_WARRIOR, CLASS_CONTEXT_ABILITY_REACTIVE))
|
||||
{
|
||||
ClearComboPoints();
|
||||
}
|
||||
@@ -18096,7 +18096,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
|
||||
// Spirit of Redemption
|
||||
// if talent known but not triggered (check priest class for speedup check)
|
||||
bool spiritOfRedemption = false;
|
||||
if (victim->GetTypeId() == TYPEID_PLAYER && victim->getClass() == CLASS_PRIEST && !victim->ToPlayer()->HasPlayerFlag(PLAYER_FLAGS_IS_OUT_OF_BOUNDS))
|
||||
if (victim->GetTypeId() == TYPEID_PLAYER && victim->IsClass(CLASS_PRIEST, CLASS_CONTEXT_ABILITY) && !victim->ToPlayer()->HasPlayerFlag(PLAYER_FLAGS_IS_OUT_OF_BOUNDS))
|
||||
{
|
||||
if (AuraEffect* aurEff = victim->GetAuraEffectDummy(20711))
|
||||
{
|
||||
@@ -18704,7 +18704,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
GetMotionMaster()->MoveIdle();
|
||||
StopMoving();
|
||||
|
||||
if (charmer->GetTypeId() == TYPEID_PLAYER && charmer->getClass() == CLASS_WARLOCK && ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_DEMON)
|
||||
if (charmer->GetTypeId() == TYPEID_PLAYER && charmer->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET_CHARM) && ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_DEMON)
|
||||
{
|
||||
// Disable CreatureAI/SmartAI and switch to CharmAI when charmed by warlock
|
||||
Creature* charmed = ToCreature();
|
||||
@@ -18770,7 +18770,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
playerCharmer->PossessSpellInitialize();
|
||||
break;
|
||||
case CHARM_TYPE_CHARM:
|
||||
if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
|
||||
if (GetTypeId() == TYPEID_UNIT && charmer->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET_CHARM))
|
||||
{
|
||||
CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate();
|
||||
if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
|
||||
@@ -18892,7 +18892,7 @@ void Unit::RemoveCharmedBy(Unit* charmer)
|
||||
ClearUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
|
||||
break;
|
||||
case CHARM_TYPE_CHARM:
|
||||
if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
|
||||
if (GetTypeId() == TYPEID_UNIT && charmer->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET_CHARM))
|
||||
{
|
||||
CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate();
|
||||
if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
|
||||
|
||||
Reference in New Issue
Block a user