mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +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:
@@ -1014,7 +1014,7 @@ class spell_dk_blood_boil : public SpellScript
|
||||
bool Load() override
|
||||
{
|
||||
_executed = false;
|
||||
return GetCaster()->GetTypeId() == TYPEID_PLAYER && GetCaster()->getClass() == CLASS_DEATH_KNIGHT;
|
||||
return GetCaster()->GetTypeId() == TYPEID_PLAYER && GetCaster()->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY);
|
||||
}
|
||||
|
||||
void HandleAfterHit()
|
||||
@@ -1258,7 +1258,7 @@ class spell_dk_death_gate : public SpellScript
|
||||
|
||||
SpellCastResult CheckClass()
|
||||
{
|
||||
if (GetCaster()->getClass() != CLASS_DEATH_KNIGHT)
|
||||
if (!GetCaster()->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY))
|
||||
{
|
||||
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_MUST_BE_DEATH_KNIGHT);
|
||||
return SPELL_FAILED_CUSTOM_ERROR;
|
||||
|
||||
@@ -446,7 +446,7 @@ class spell_pet_hit_expertise_scalling : public AuraScript
|
||||
{
|
||||
if (Player* modOwner = GetUnitOwner()->GetSpellModOwner())
|
||||
{
|
||||
if (modOwner->getClass() == CLASS_HUNTER)
|
||||
if (modOwner->IsClass(CLASS_HUNTER, CLASS_CONTEXT_STATS))
|
||||
amount = CalculatePercent(modOwner->m_modRangedHitChance, 8.0f, 8.0f);
|
||||
else if (modOwner->getPowerType() == POWER_MANA)
|
||||
amount = CalculatePercent(modOwner->m_modSpellHitChance, 17.0f, 8.0f);
|
||||
@@ -459,7 +459,7 @@ class spell_pet_hit_expertise_scalling : public AuraScript
|
||||
{
|
||||
if (Player* modOwner = GetUnitOwner()->GetSpellModOwner())
|
||||
{
|
||||
if (modOwner->getClass() == CLASS_HUNTER)
|
||||
if (modOwner->IsClass(CLASS_HUNTER, CLASS_CONTEXT_STATS))
|
||||
amount = CalculatePercent(modOwner->m_modRangedHitChance, 8.0f, 17.0f);
|
||||
else if (modOwner->getPowerType() == POWER_MANA)
|
||||
amount = CalculatePercent(modOwner->m_modSpellHitChance, 17.0f, 17.0f);
|
||||
@@ -472,7 +472,7 @@ class spell_pet_hit_expertise_scalling : public AuraScript
|
||||
{
|
||||
if (Player* modOwner = GetUnitOwner()->GetSpellModOwner())
|
||||
{
|
||||
if (modOwner->getClass() == CLASS_HUNTER)
|
||||
if (modOwner->IsClass(CLASS_HUNTER, CLASS_CONTEXT_STATS))
|
||||
amount = CalculatePercent(modOwner->m_modRangedHitChance, 8.0f, 26.0f);
|
||||
else if (modOwner->getPowerType() == POWER_MANA)
|
||||
amount = CalculatePercent(modOwner->m_modSpellHitChance, 17.0f, 26.0f);
|
||||
@@ -1673,7 +1673,7 @@ class spell_gen_pet_summoned : public SpellScript
|
||||
Player* player = GetCaster()->ToPlayer();
|
||||
if (player->GetLastPetNumber() && player->CanResummonPet(player->GetLastPetSpell()))
|
||||
{
|
||||
PetType newPetType = (player->getClass() == CLASS_HUNTER) ? HUNTER_PET : SUMMON_PET;
|
||||
PetType newPetType = (player->IsClass(CLASS_HUNTER, CLASS_CONTEXT_PET)) ? HUNTER_PET : SUMMON_PET;
|
||||
Pet* newPet = new Pet(player, newPetType);
|
||||
if (newPet->LoadPetFromDB(player, 0, player->GetLastPetNumber(), true, 100))
|
||||
{
|
||||
@@ -3545,11 +3545,11 @@ class spell_gen_on_tournament_mount : public AuraScript
|
||||
case NPC_ARGENT_WARHORSE:
|
||||
{
|
||||
if (player->HasAchieved(ACHIEVEMENT_CHAMPION_ALLIANCE) || player->HasAchieved(ACHIEVEMENT_CHAMPION_HORDE))
|
||||
return player->getClass() == CLASS_DEATH_KNIGHT ? SPELL_PENNANT_EBON_BLADE_CHAMPION : SPELL_PENNANT_ARGENT_CRUSADE_CHAMPION;
|
||||
return player->IsClass(CLASS_DEATH_KNIGHT) ? SPELL_PENNANT_EBON_BLADE_CHAMPION : SPELL_PENNANT_ARGENT_CRUSADE_CHAMPION;
|
||||
else if (player->HasAchieved(ACHIEVEMENT_ARGENT_VALOR))
|
||||
return player->getClass() == CLASS_DEATH_KNIGHT ? SPELL_PENNANT_EBON_BLADE_VALIANT : SPELL_PENNANT_ARGENT_CRUSADE_VALIANT;
|
||||
return player->IsClass(CLASS_DEATH_KNIGHT) ? SPELL_PENNANT_EBON_BLADE_VALIANT : SPELL_PENNANT_ARGENT_CRUSADE_VALIANT;
|
||||
else
|
||||
return player->getClass() == CLASS_DEATH_KNIGHT ? SPELL_PENNANT_EBON_BLADE_ASPIRANT : SPELL_PENNANT_ARGENT_CRUSADE_ASPIRANT;
|
||||
return player->IsClass(CLASS_DEATH_KNIGHT) ? SPELL_PENNANT_EBON_BLADE_ASPIRANT : SPELL_PENNANT_ARGENT_CRUSADE_ASPIRANT;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
|
||||
@@ -3469,7 +3469,7 @@ class spell_item_refocus : public SpellScript
|
||||
{
|
||||
Player* caster = GetCaster()->ToPlayer();
|
||||
|
||||
if (!caster || caster->getClass() != CLASS_HUNTER)
|
||||
if (!caster || !caster->IsClass(CLASS_HUNTER, CLASS_CONTEXT_ABILITY))
|
||||
return;
|
||||
|
||||
caster->RemoveCategoryCooldown(SPELL_CATEGORY_AIMED_MULTI);
|
||||
|
||||
Reference in New Issue
Block a user