diff options
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 15f1276ac41..a3f7c616154 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -241,7 +241,7 @@ void Unit::Update(uint32 p_time) SendThreatListUpdate(); // update combat timer only for players and pets (only pets with PetAI) - if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || (((Creature *)this)->isPet() && IsControlledByPlayer()))) + if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || (ToCreature()->isPet() && IsControlledByPlayer()))) { // Check UNIT_STAT_MELEE_ATTACKING or UNIT_STAT_CHASE (without UNIT_STAT_FOLLOW in this case) so pets can reach far away // targets without stopping half way there and running off. @@ -578,13 +578,6 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb) uint32 originalDamage = damage; - //Script Event damage Deal - //if (GetTypeId() == TYPEID_UNIT && ((Creature *)this)->AI()) - // ((Creature *)this)->AI()->DamageDeal(pVictim, damage); - //Script Event damage taken - //if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature *)pVictim)->IsAIEnabled) - // ((Creature *)pVictim)->AI()->DamageTaken(this, damage); - if (absorb && originalDamage > damage) absorb += (originalDamage - damage); } @@ -1553,7 +1546,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) } if (GetTypeId() == TYPEID_PLAYER) - ((Player *)this)->CastItemCombatSpell(pVictim, damageInfo->attackType, damageInfo->procVictim, damageInfo->procEx); + ToPlayer()->CastItemCombatSpell(pVictim, damageInfo->attackType, damageInfo->procVictim, damageInfo->procEx); // Do effect if any damage done to target if (damageInfo->damage) @@ -1649,7 +1642,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt // item dependent spell - check curent weapons for (int i = 0; i < MAX_ATTACK; ++i) { - Item *weapon = ((Player *)this)->GetWeaponForAttack(WeaponAttackType(i)); + Item *weapon = ToPlayer()->GetWeaponForAttack(WeaponAttackType(i)); if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto())) { @@ -5518,14 +5511,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger return false; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45479; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(934) == REP_EXALTED) { // triggered at positive/self casts also, current attack target used then if(IsFriendlyTo(target)) @@ -5533,7 +5526,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger target = getVictim(); if(!target) { - uint64 selected_guid = ((Player *)this)->GetSelection(); + uint64 selected_guid = ToPlayer()->GetSelection(); target = ObjectAccessor::GetUnit(*this,selected_guid); if(!target) return false; @@ -5556,14 +5549,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger return false; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45480; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(934) == REP_EXALTED) { triggered_spell_id = 45428; break; @@ -5579,14 +5572,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger return false; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45432; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(934) == REP_EXALTED) { target = this; triggered_spell_id = 45431; @@ -5603,14 +5596,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger return false; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45478; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(934) == REP_EXALTED) { triggered_spell_id = 45430; break; @@ -6288,7 +6281,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger int32 basepoints1 = triggerAmount * 2; // Improved Leader of the Pack // Check cooldown of heal spell cooldown - if (GetTypeId() == TYPEID_PLAYER && !((Player *)this)->HasSpellCooldown(34299)) + if (GetTypeId() == TYPEID_PLAYER && !ToPlayer()->HasSpellCooldown(34299)) CastCustomSpell(this,60889,&basepoints1,0,0,true,0,triggeredByAura); break; } @@ -11301,7 +11294,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId) Pet* pet = this->ToPlayer()->GetPet(); if (pet) { - BattleGround *bg = ((Player *)this)->GetBattleGround(); + BattleGround *bg = ToPlayer()->GetBattleGround(); // don't unsummon pet in arena but SetFlag UNIT_FLAG_STUNNED to disable pet's interface if (bg && bg->isArena()) pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); @@ -11541,7 +11534,7 @@ bool Unit::isAttackableByAOE() const UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_OOC_NOT_ATTACKABLE)) return false; - if (GetTypeId() == TYPEID_PLAYER && ((Player *)this)->isGameMaster()) + if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->isGameMaster()) return false; return !hasUnitState(UNIT_STAT_UNATTACKABLE); @@ -14828,7 +14821,7 @@ void Unit::SetStunned(bool apply) // don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface) Unit *pOwner = GetOwner(); - if (!pOwner || (pOwner->GetTypeId() == TYPEID_PLAYER && !((Player *)pOwner)->IsMounted())) + if (!pOwner || (pOwner->GetTypeId() == TYPEID_PLAYER && !pOwner->ToPlayer()->IsMounted())) RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); if (!hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect @@ -14855,7 +14848,7 @@ void Unit::SetRooted(bool apply) SendMessageToSet(&data,true); if (GetTypeId() != TYPEID_PLAYER) - ((Creature *)this)->StopMoving(); + ToCreature()->StopMoving(); } else { |