diff options
Diffstat (limited to 'src')
81 files changed, 1259 insertions, 999 deletions
diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index d35710aa40f..67e75633b05 100755 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -22,7 +22,7 @@ #include "Vehicle.h" #include "ObjectAccessor.h" -int AggressorAI::Permissible(const Creature *creature) +int AggressorAI::Permissible(const Creature* creature) { // have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight if (!creature->isCivilian() && !creature->IsNeutralToAll()) @@ -81,7 +81,7 @@ void CombatAI::JustDied(Unit* killer) me->CastSpell(killer, *i, true); } -void CombatAI::EnterCombat(Unit *who) +void CombatAI::EnterCombat(Unit* who) { for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i) { @@ -127,7 +127,7 @@ void CasterAI::InitializeAI() m_attackDist = MELEE_RANGE; } -void CasterAI::EnterCombat(Unit *who) +void CasterAI::EnterCombat(Unit* who) { if (spells.empty()) return; @@ -173,7 +173,7 @@ void CasterAI::UpdateAI(const uint32 diff) //ArcherAI ////////////// -ArcherAI::ArcherAI(Creature *c) : CreatureAI(c) +ArcherAI::ArcherAI(Creature* c) : CreatureAI(c) { if (!me->m_spells[0]) sLog->outError("ArcherAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry()); @@ -187,7 +187,7 @@ ArcherAI::ArcherAI(Creature *c) : CreatureAI(c) me->m_SightDistance = me->m_CombatDistance; } -void ArcherAI::AttackStart(Unit *who) +void ArcherAI::AttackStart(Unit* who) { if (!who) return; @@ -222,7 +222,7 @@ void ArcherAI::UpdateAI(const uint32 /*diff*/) //TurretAI ////////////// -TurretAI::TurretAI(Creature *c) : CreatureAI(c) +TurretAI::TurretAI(Creature* c) : CreatureAI(c) { if (!me->m_spells[0]) sLog->outError("TurretAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry()); @@ -242,7 +242,7 @@ bool TurretAI::CanAIAttack(const Unit* /*who*/) const return true; } -void TurretAI::AttackStart(Unit *who) +void TurretAI::AttackStart(Unit* who) { if (who) me->Attack(who, false); @@ -260,7 +260,7 @@ void TurretAI::UpdateAI(const uint32 /*diff*/) //VehicleAI ////////////// -VehicleAI::VehicleAI(Creature *c) : CreatureAI(c), m_vehicle(c->GetVehicleKit()), m_IsVehicleInUse(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) +VehicleAI::VehicleAI(Creature* c) : CreatureAI(c), m_vehicle(c->GetVehicleKit()), m_IsVehicleInUse(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) { LoadConditions(); m_DoDismiss = false; @@ -318,11 +318,11 @@ void VehicleAI::CheckConditions(const uint32 diff) for (SeatMap::iterator itr = m_vehicle->Seats.begin(); itr != m_vehicle->Seats.end(); ++itr) if (Unit* passenger = ObjectAccessor::GetUnit(*m_vehicle->GetBase(), itr->second.Passenger)) { - if (Player* plr = passenger->ToPlayer()) + if (Player* player = passenger->ToPlayer()) { - if (!sConditionMgr->IsPlayerMeetToConditions(plr, conditions)) + if (!sConditionMgr->IsPlayerMeetToConditions(player, conditions)) { - plr->ExitVehicle(); + player->ExitVehicle(); return;//check other pessanger in next tick } } diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h index 94f11ba8431..fca964826d3 100755 --- a/src/server/game/AI/CoreAI/CombatAI.h +++ b/src/server/game/AI/CoreAI/CombatAI.h @@ -28,10 +28,10 @@ class Creature; class AggressorAI : public CreatureAI { public: - explicit AggressorAI(Creature *c) : CreatureAI(c) {} + explicit AggressorAI(Creature* c) : CreatureAI(c) {} void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); }; typedef std::vector<uint32> SpellVct; @@ -39,14 +39,14 @@ typedef std::vector<uint32> SpellVct; class CombatAI : public CreatureAI { public: - explicit CombatAI(Creature *c) : CreatureAI(c) {} + explicit CombatAI(Creature* c) : CreatureAI(c) {} void InitializeAI(); void Reset(); void EnterCombat(Unit* who); void JustDied(Unit* killer); void UpdateAI(const uint32 diff); - static int Permissible(const Creature *); + static int Permissible(const Creature*); protected: EventMap events; SpellVct spells; @@ -55,7 +55,7 @@ class CombatAI : public CreatureAI class CasterAI : public CombatAI { public: - explicit CasterAI(Creature *c) : CombatAI(c) { m_attackDist = MELEE_RANGE; } + explicit CasterAI(Creature* c) : CombatAI(c) { m_attackDist = MELEE_RANGE; } void InitializeAI(); void AttackStart(Unit* victim) { AttackStartCaster(victim, m_attackDist); } void UpdateAI(const uint32 diff); @@ -67,11 +67,11 @@ class CasterAI : public CombatAI struct ArcherAI : public CreatureAI { public: - explicit ArcherAI(Creature *c); - void AttackStart(Unit *who); + explicit ArcherAI(Creature* c); + void AttackStart(Unit* who); void UpdateAI(const uint32 diff); - static int Permissible(const Creature *); + static int Permissible(const Creature*); protected: float m_minRange; }; @@ -79,12 +79,12 @@ struct ArcherAI : public CreatureAI struct TurretAI : public CreatureAI { public: - explicit TurretAI(Creature *c); - bool CanAIAttack(const Unit *who) const; - void AttackStart(Unit *who); + explicit TurretAI(Creature* c); + bool CanAIAttack(const Unit* who) const; + void AttackStart(Unit* who); void UpdateAI(const uint32 diff); - static int Permissible(const Creature *); + static int Permissible(const Creature*); protected: float m_minRange; }; @@ -94,13 +94,13 @@ struct TurretAI : public CreatureAI struct VehicleAI : public CreatureAI { public: - explicit VehicleAI(Creature *c); + explicit VehicleAI(Creature* c); void UpdateAI(const uint32 diff); - static int Permissible(const Creature *); + static int Permissible(const Creature*); void Reset(); - void MoveInLineOfSight(Unit *) {} - void AttackStart(Unit *) {} + void MoveInLineOfSight(Unit*) {} + void AttackStart(Unit*) {} void OnCharmed(bool apply); private: diff --git a/src/server/game/AI/CoreAI/GameObjectAI.cpp b/src/server/game/AI/CoreAI/GameObjectAI.cpp index 7262530d7ac..28c42a8ccdb 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.cpp +++ b/src/server/game/AI/CoreAI/GameObjectAI.cpp @@ -26,4 +26,4 @@ int GameObjectAI::Permissible(const GameObject* go) return PERMIT_BASE_NO; } -NullGameObjectAI::NullGameObjectAI(GameObject *g) : GameObjectAI(g) {}
\ No newline at end of file +NullGameObjectAI::NullGameObjectAI(GameObject* g) : GameObjectAI(g) {}
\ No newline at end of file diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h index ed3a5b47e76..8d0e0508113 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.h +++ b/src/server/game/AI/CoreAI/GameObjectAI.h @@ -30,7 +30,7 @@ class GameObjectAI protected: GameObject* const go; public: - explicit GameObjectAI(GameObject *g) : go(g) {} + explicit GameObjectAI(GameObject* g) : go(g) {} virtual ~GameObjectAI() {} virtual void UpdateAI(const uint32 /*diff*/) {} @@ -54,7 +54,7 @@ class GameObjectAI class NullGameObjectAI : public GameObjectAI { public: - explicit NullGameObjectAI(GameObject *g); + explicit NullGameObjectAI(GameObject* g); void UpdateAI(const uint32 /*diff*/) {} diff --git a/src/server/game/AI/CoreAI/GuardAI.cpp b/src/server/game/AI/CoreAI/GuardAI.cpp index 1ebc9e69078..228996e5d2d 100755 --- a/src/server/game/AI/CoreAI/GuardAI.cpp +++ b/src/server/game/AI/CoreAI/GuardAI.cpp @@ -40,8 +40,8 @@ bool GuardAI::CanSeeAlways(WorldObject const* obj) if (!obj->isType(TYPEMASK_UNIT)) return false; - std::list<HostileReference *> t_list = me->getThreatManager().getThreatList(); - for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); + for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) if (unit == obj) diff --git a/src/server/game/AI/CoreAI/GuardAI.h b/src/server/game/AI/CoreAI/GuardAI.h index 7b9c8d6808c..c0b80ac5174 100755 --- a/src/server/game/AI/CoreAI/GuardAI.h +++ b/src/server/game/AI/CoreAI/GuardAI.h @@ -34,15 +34,15 @@ class GuardAI : public ScriptedAI public: - explicit GuardAI(Creature *c); + explicit GuardAI(Creature* c); - void MoveInLineOfSight(Unit *); + void MoveInLineOfSight(Unit*); void EnterEvadeMode(); - void JustDied(Unit *); + void JustDied(Unit*); bool CanSeeAlways(WorldObject const* obj); void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); private: uint64 i_victimGuid; diff --git a/src/server/game/AI/CoreAI/PassiveAI.cpp b/src/server/game/AI/CoreAI/PassiveAI.cpp index 1b449f44fbd..4107179f6f7 100755 --- a/src/server/game/AI/CoreAI/PassiveAI.cpp +++ b/src/server/game/AI/CoreAI/PassiveAI.cpp @@ -20,9 +20,9 @@ #include "Creature.h" #include "TemporarySummon.h" -PassiveAI::PassiveAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } -PossessedAI::PossessedAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } -NullCreatureAI::NullCreatureAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } +PassiveAI::PassiveAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } +PossessedAI::PossessedAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } +NullCreatureAI::NullCreatureAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } void PassiveAI::UpdateAI(const uint32) { @@ -59,7 +59,7 @@ void PossessedAI::KilledUnit(Unit* victim) victim->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); } -void CritterAI::DamageTaken(Unit* /*done_by*/, uint32 &) +void CritterAI::DamageTaken(Unit* /*done_by*/, uint32&) { if (!me->HasUnitState(UNIT_STAT_FLEEING)) me->SetControlled(true, UNIT_STAT_FLEEING); @@ -72,7 +72,7 @@ void CritterAI::EnterEvadeMode() CreatureAI::EnterEvadeMode(); } -void TriggerAI::IsSummonedBy(Unit *summoner) +void TriggerAI::IsSummonedBy(Unit* summoner) { if (me->m_spells[0]) me->CastSpell(me, me->m_spells[0], false, 0, 0, summoner->GetGUID()); diff --git a/src/server/game/AI/CoreAI/PassiveAI.h b/src/server/game/AI/CoreAI/PassiveAI.h index be78918c608..e23fb41d608 100755 --- a/src/server/game/AI/CoreAI/PassiveAI.h +++ b/src/server/game/AI/CoreAI/PassiveAI.h @@ -25,21 +25,21 @@ class PassiveAI : public CreatureAI { public: - explicit PassiveAI(Creature *c); + explicit PassiveAI(Creature* c); - void MoveInLineOfSight(Unit *) {} - void AttackStart(Unit *) {} + void MoveInLineOfSight(Unit*) {} + void AttackStart(Unit*) {} void UpdateAI(const uint32); - static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; } + static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; class PossessedAI : public CreatureAI { public: - explicit PossessedAI(Creature *c); + explicit PossessedAI(Creature* c); - void MoveInLineOfSight(Unit *) {} + void MoveInLineOfSight(Unit*) {} void AttackStart(Unit* target); void UpdateAI(const uint32); void EnterEvadeMode() {} @@ -47,37 +47,37 @@ class PossessedAI : public CreatureAI void JustDied(Unit*); void KilledUnit(Unit* victim); - static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; } + static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; class NullCreatureAI : public CreatureAI { public: - explicit NullCreatureAI(Creature *c); + explicit NullCreatureAI(Creature* c); - void MoveInLineOfSight(Unit *) {} - void AttackStart(Unit *) {} + void MoveInLineOfSight(Unit*) {} + void AttackStart(Unit*) {} void UpdateAI(const uint32) {} void EnterEvadeMode() {} void OnCharmed(bool /*apply*/) {} - static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; } + static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; class CritterAI : public PassiveAI { public: - explicit CritterAI(Creature *c) : PassiveAI(c) {} + explicit CritterAI(Creature* c) : PassiveAI(c) {} - void DamageTaken(Unit *done_by, uint32 & /*damage*/); + void DamageTaken(Unit* done_by, uint32& /*damage*/); void EnterEvadeMode(); }; class TriggerAI : public NullCreatureAI { public: - explicit TriggerAI(Creature *c) : NullCreatureAI(c) {} - void IsSummonedBy(Unit *summoner); + explicit TriggerAI(Creature* c) : NullCreatureAI(c) {} + void IsSummonedBy(Unit* summoner); }; #endif diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index ff67e3b344b..0d8841dafd3 100755 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -30,7 +30,7 @@ #include "Group.h" #include "SpellInfo.h" -int PetAI::Permissible(const Creature *creature) +int PetAI::Permissible(const Creature* creature) { if (creature->isPet()) return PERMIT_BASE_SPECIAL; @@ -38,7 +38,7 @@ int PetAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -PetAI::PetAI(Creature *c) : CreatureAI(c), i_tracker(TIME_INTERVAL_LOOK) +PetAI::PetAI(Creature* c) : CreatureAI(c), i_tracker(TIME_INTERVAL_LOOK) { m_AllySet.clear(); UpdateAllies(); @@ -107,7 +107,7 @@ void PetAI::UpdateAI(const uint32 diff) } else if (owner && me->GetCharmInfo()) //no victim { - Unit *nextTarget = SelectNextTarget(); + Unit* nextTarget = SelectNextTarget(); if (me->HasReactState(REACT_PASSIVE)) _stopAttack(); @@ -134,7 +134,7 @@ void PetAI::UpdateAI(const uint32 diff) if (!spellID) continue; - SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellID); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID); if (!spellInfo) continue; @@ -239,30 +239,30 @@ void PetAI::UpdateAI(const uint32 diff) void PetAI::UpdateAllies() { Unit* owner = me->GetCharmerOrOwner(); - Group *pGroup = NULL; + Group* group = NULL; m_updateAlliesTimer = 10*IN_MILLISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance if (!owner) return; else if (owner->GetTypeId() == TYPEID_PLAYER) - pGroup = owner->ToPlayer()->GetGroup(); + group = owner->ToPlayer()->GetGroup(); //only pet and owner/not in group->ok - if (m_AllySet.size() == 2 && !pGroup) + if (m_AllySet.size() == 2 && !group) return; //owner is in group; group members filled in already (no raid -> subgroupcount = whole count) - if (pGroup && !pGroup->isRaidGroup() && m_AllySet.size() == (pGroup->GetMembersCount() + 2)) + if (group && !group->isRaidGroup() && m_AllySet.size() == (group->GetMembersCount() + 2)) return; m_AllySet.clear(); m_AllySet.insert(me->GetGUID()); - if (pGroup) //add group + if (group) //add group { - for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* Target = itr->getSource(); - if (!Target || !pGroup->SameSubGroup((Player*)owner, Target)) + if (!Target || !group->SameSubGroup((Player*)owner, Target)) continue; if (Target->GetGUID() == owner->GetGUID()) @@ -289,7 +289,7 @@ void PetAI::KilledUnit(Unit* victim) me->AttackStop(); me->GetCharmInfo()->SetIsCommandAttack(false); - Unit *nextTarget = SelectNextTarget(); + Unit* nextTarget = SelectNextTarget(); if (nextTarget) AttackStart(nextTarget); @@ -307,10 +307,13 @@ void PetAI::AttackStart(Unit* target) targetHasCC = _CheckTargetCC(target); + if (Unit* owner = me->GetOwner()) + owner->SetInCombatWith(target); + DoAttack(target, true); } -Unit *PetAI::SelectNextTarget() +Unit* PetAI::SelectNextTarget() { // Provides next target selection after current target death diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h index 2e0e451ef28..9f0472cfe4d 100755 --- a/src/server/game/AI/CoreAI/PetAI.h +++ b/src/server/game/AI/CoreAI/PetAI.h @@ -29,20 +29,20 @@ class PetAI : public CreatureAI { public: - explicit PetAI(Creature *c); + explicit PetAI(Creature* c); void EnterEvadeMode(); void JustDied(Unit* /*who*/) { _stopAttack(); } void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); void KilledUnit(Unit* /*victim*/); void AttackStart(Unit* target); void MovementInform(uint32 moveType, uint32 data); private: - bool _isVisible(Unit *) const; + bool _isVisible(Unit*) const; bool _needToStop(void); void _stopAttack(void); @@ -54,7 +54,7 @@ class PetAI : public CreatureAI std::set<uint64> m_AllySet; uint32 m_updateAlliesTimer; - Unit *SelectNextTarget(); + Unit* SelectNextTarget(); void HandleReturnMovement(); void DoAttack(Unit* target, bool chase); bool _CanAttack(Unit* target); diff --git a/src/server/game/AI/CoreAI/ReactorAI.cpp b/src/server/game/AI/CoreAI/ReactorAI.cpp index e2d1c8f601c..df914fbf500 100755 --- a/src/server/game/AI/CoreAI/ReactorAI.cpp +++ b/src/server/game/AI/CoreAI/ReactorAI.cpp @@ -26,7 +26,7 @@ #define REACTOR_VISIBLE_RANGE (26.46f) int -ReactorAI::Permissible(const Creature *creature) +ReactorAI::Permissible(const Creature* creature) { if (creature->isCivilian() || creature->IsNeutralToAll()) return PERMIT_BASE_REACTIVE; @@ -35,7 +35,7 @@ ReactorAI::Permissible(const Creature *creature) } void -ReactorAI::MoveInLineOfSight(Unit *) +ReactorAI::MoveInLineOfSight(Unit*) { } diff --git a/src/server/game/AI/CoreAI/ReactorAI.h b/src/server/game/AI/CoreAI/ReactorAI.h index 5328634c231..e66b382ef68 100755 --- a/src/server/game/AI/CoreAI/ReactorAI.h +++ b/src/server/game/AI/CoreAI/ReactorAI.h @@ -27,12 +27,12 @@ class ReactorAI : public CreatureAI { public: - explicit ReactorAI(Creature *c) : CreatureAI(c) {} + explicit ReactorAI(Creature* c) : CreatureAI(c) {} - void MoveInLineOfSight(Unit *); + void MoveInLineOfSight(Unit*); void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); }; #endif diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp index f1106f2dc28..96da4c4f4e2 100755 --- a/src/server/game/AI/CoreAI/TotemAI.cpp +++ b/src/server/game/AI/CoreAI/TotemAI.cpp @@ -28,7 +28,7 @@ #include "CellImpl.h" int -TotemAI::Permissible(const Creature *creature) +TotemAI::Permissible(const Creature* creature) { if (creature->isTotem()) return PERMIT_BASE_PROACTIVE; @@ -36,13 +36,13 @@ TotemAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -TotemAI::TotemAI(Creature *c) : CreatureAI(c), i_victimGuid(0) +TotemAI::TotemAI(Creature* c) : CreatureAI(c), i_victimGuid(0) { ASSERT(c->isTotem()); } void -TotemAI::MoveInLineOfSight(Unit *) +TotemAI::MoveInLineOfSight(Unit*) { } @@ -61,7 +61,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/) return; // Search spell - SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(me->ToTotem()->GetSpell()); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(me->ToTotem()->GetSpell()); if (!spellInfo) return; @@ -99,7 +99,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/) } void -TotemAI::AttackStart(Unit *) +TotemAI::AttackStart(Unit*) { // Sentry totem sends ping on attack if (me->GetEntry() == SENTRY_TOTEM_ENTRY && me->GetOwner()->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/game/AI/CoreAI/TotemAI.h b/src/server/game/AI/CoreAI/TotemAI.h index f99e345450d..4791c3af92a 100755 --- a/src/server/game/AI/CoreAI/TotemAI.h +++ b/src/server/game/AI/CoreAI/TotemAI.h @@ -29,14 +29,14 @@ class TotemAI : public CreatureAI { public: - explicit TotemAI(Creature *c); + explicit TotemAI(Creature* c); - void MoveInLineOfSight(Unit *); - void AttackStart(Unit *); + void MoveInLineOfSight(Unit*); + void AttackStart(Unit*); void EnterEvadeMode(); void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); private: uint64 i_victimGuid; diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 92b81e7967b..91de52db9f8 100755 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -91,7 +91,7 @@ Unit* UnitAI::SelectTarget(SelectAggroTarget targetType, uint32 position, float return SelectTarget(targetType, position, DefaultTargetSelector(me, dist, playerOnly, aura)); } -void UnitAI::SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAggroTarget targetType, float dist, bool playerOnly, int32 aura) +void UnitAI::SelectTargetList(std::list<Unit*>& targetList, uint32 num, SelectAggroTarget targetType, float dist, bool playerOnly, int32 aura) { SelectTargetList(targetList, DefaultTargetSelector(me, dist, playerOnly, aura), num, targetType); } @@ -109,9 +109,9 @@ void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid) std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { - if (Unit *pTemp = Unit::GetUnit(*me, (*itr)->getUnitGuid())) - if (pTemp->GetTypeId() == TYPEID_PLAYER) - me->AddAura(spellid, pTemp); + if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) + if (unit->GetTypeId() == TYPEID_PLAYER) + me->AddAura(spellid, unit); } }else return; @@ -124,9 +124,9 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { - if (Unit *pTemp = Unit::GetUnit(*me, (*itr)->getUnitGuid())) - if (pTemp->GetTypeId() == TYPEID_PLAYER) - me->CastSpell(pTemp, spellid, triggered); + if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) + if (unit->GetTypeId() == TYPEID_PLAYER) + me->CastSpell(unit, spellid, triggered); } }else return; @@ -143,7 +143,7 @@ void UnitAI::DoCast(uint32 spellId) case AITARGET_VICTIM: target = me->getVictim(); break; case AITARGET_ENEMY: { - const SpellInfo * spellInfo = sSpellMgr->GetSpellInfo(spellId); + const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; //float range = GetSpellMaxRange(spellInfo, false); target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly); @@ -153,7 +153,7 @@ void UnitAI::DoCast(uint32 spellId) case AITARGET_BUFF: target = me; break; case AITARGET_DEBUFF: { - const SpellInfo * spellInfo = sSpellMgr->GetSpellInfo(spellId); + const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; float range = spellInfo->GetMaxRange(false); @@ -178,8 +178,8 @@ void UnitAI::FillAISpellInfo() { AISpellInfo = new AISpellInfoType[sSpellMgr->GetSpellInfoStoreSize()]; - AISpellInfoType *AIInfo = AISpellInfo; - const SpellInfo * spellInfo; + AISpellInfoType* AIInfo = AISpellInfo; + const SpellInfo* spellInfo; for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i, ++AIInfo) { @@ -230,7 +230,7 @@ void PlayerAI::OnCharmed(bool apply) { me->IsAIEnabled = apply; } void SimpleCharmedAI::UpdateAI(const uint32 /*diff*/) { - Creature *charmer = me->GetCharmer()->ToCreature(); + Creature* charmer = me->GetCharmer()->ToCreature(); //kill self if charm aura has infinite duration if (charmer->IsInEvadeMode()) diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index f17c74fe7cf..ec00b53b5ca 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -60,7 +60,7 @@ struct DefaultTargetSelector : public std::unary_function<Unit* , bool> // dist: if 0: ignored, if > 0: maximum distance to the reference unit, if < 0: minimum distance to the reference unit // playerOnly: self explaining // aura: if 0: ignored, if > 0: the target shall have the aura, if < 0, the target shall NOT have the aura - DefaultTargetSelector(Unit const* pUnit, float dist, bool playerOnly, int32 aura) : me(pUnit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) {} + DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, int32 aura) : me(unit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) {} bool operator()(Unit const* target) const { @@ -128,7 +128,7 @@ class UnitAI // predicate shall extend std::unary_function<Unit* , bool> template <class PREDICATE> Unit* SelectTarget(SelectAggroTarget targetType, uint32 position, PREDICATE const& predicate) { - const std::list<HostileReference* > &threatlist = me->getThreatManager().getThreatList(); + const std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); if (position >= threatlist.size()) return NULL; @@ -172,11 +172,11 @@ class UnitAI return NULL; } - void SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAggroTarget targetType, float dist = 0.0f, bool playerOnly = false, int32 aura = 0); + void SelectTargetList(std::list<Unit*>& targetList, uint32 num, SelectAggroTarget targetType, float dist = 0.0f, bool playerOnly = false, int32 aura = 0); // Select the targets satifying the predicate. // predicate shall extend std::unary_function<Unit* , bool> - template <class PREDICATE> void SelectTargetList(std::list<Unit*> &targetList, PREDICATE const& predicate, uint32 maxTargets, SelectAggroTarget targetType) + template <class PREDICATE> void SelectTargetList(std::list<Unit*>& targetList, PREDICATE const& predicate, uint32 maxTargets, SelectAggroTarget targetType) { std::list<HostileReference*> const& threatlist = me->getThreatManager().getThreatList(); if (threatlist.empty()) @@ -247,7 +247,7 @@ class PlayerAI : public UnitAI protected: Player* const me; public: - explicit PlayerAI(Player* p) : UnitAI((Unit*)p), me(p) {} + explicit PlayerAI(Player* player) : UnitAI((Unit*)player), me(player) {} void OnCharmed(bool apply); }; diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index ee822d9df40..b72556dbab1 100755 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -34,8 +34,8 @@ void CreatureAI::OnCharmed(bool /*apply*/) me->IsAIEnabled = false; } -AISpellInfoType * UnitAI::AISpellInfo; - AISpellInfoType * GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; } +AISpellInfoType* UnitAI::AISpellInfo; +AISpellInfoType* GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; } void CreatureAI::Talk(uint8 id, uint64 WhisperGuid) { @@ -50,7 +50,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/) if (!creature->CanHaveThreatList()) return; - Map *map = creature->GetMap(); + Map* map = creature->GetMap(); if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated { sLog->outError("DoZoneInCombat call for map that isn't an instance (creature entry = %d)", creature->GetTypeId() == TYPEID_UNIT ? creature->ToCreature()->GetEntry() : 0); @@ -63,7 +63,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/) creature->AI()->AttackStart(target); else if (creature->isSummon()) { - if (Unit *summoner = creature->ToTempSummon()->GetSummoner()) + if (Unit* summoner = creature->ToTempSummon()->GetSummoner()) { Unit* target = summoner->getAttackerForHelper(); if (!target && summoner->CanHaveThreatList() && !summoner->getThreatManager().isThreatListEmpty()) @@ -80,23 +80,23 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/) return; } - Map::PlayerList const &PlList = map->GetPlayers(); + Map::PlayerList const& playerList = map->GetPlayers(); - if (PlList.isEmpty()) + if (playerList.isEmpty()) return; - for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i) + for (Map::PlayerList::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr) { - if (Player* pPlayer = i->getSource()) + if (Player* player = itr->getSource()) { - if (pPlayer->isGameMaster()) + if (player->isGameMaster()) continue; - if (pPlayer->isAlive()) + if (player->isAlive()) { - creature->SetInCombatWith(pPlayer); - pPlayer->SetInCombatWith(creature); - creature->AddThreat(pPlayer, 0.0f); + creature->SetInCombatWith(player); + player->SetInCombatWith(creature); + creature->AddThreat(player, 0.0f); } /* Causes certain things to never leave the threat list (Priest Lightwell, etc): @@ -112,7 +112,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/) // scripts does not take care about MoveInLineOfSight loops // MoveInLineOfSight can be called inside another MoveInLineOfSight and cause stack overflow -void CreatureAI::MoveInLineOfSight_Safe(Unit *who) +void CreatureAI::MoveInLineOfSight_Safe(Unit* who) { if (m_MoveInLineOfSight_locked == true) return; @@ -121,7 +121,7 @@ void CreatureAI::MoveInLineOfSight_Safe(Unit *who) m_MoveInLineOfSight_locked = false; } -void CreatureAI::MoveInLineOfSight(Unit *who) +void CreatureAI::MoveInLineOfSight(Unit* who) { if (me->getVictim()) return; @@ -146,7 +146,7 @@ void CreatureAI::EnterEvadeMode() if (!me->GetVehicle()) // otherwise me will be in evade mode forever { - if (Unit *owner = me->GetCharmerOrOwner()) + if (Unit* owner = me->GetCharmerOrOwner()) { me->GetMotionMaster()->Clear(false); me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE); diff --git a/src/server/game/AI/CreatureAIFactory.h b/src/server/game/AI/CreatureAIFactory.h index ba0de3a4ddd..4cedb3d9545 100755 --- a/src/server/game/AI/CreatureAIFactory.h +++ b/src/server/game/AI/CreatureAIFactory.h @@ -25,24 +25,24 @@ struct SelectableAI : public FactoryHolder<CreatureAI>, public Permissible<Creature> { - SelectableAI(const char *id) : FactoryHolder<CreatureAI>(id) {} + SelectableAI(const char* id) : FactoryHolder<CreatureAI>(id) {} }; template<class REAL_AI> struct CreatureAIFactory : public SelectableAI { - CreatureAIFactory(const char *name) : SelectableAI(name) {} + CreatureAIFactory(const char* name) : SelectableAI(name) {} - CreatureAI* Create(void *) const; + CreatureAI* Create(void*) const; - int Permit(const Creature *c) const { return REAL_AI::Permissible(c); } + int Permit(const Creature* c) const { return REAL_AI::Permissible(c); } }; template<class REAL_AI> inline CreatureAI* -CreatureAIFactory<REAL_AI>::Create(void *data) const +CreatureAIFactory<REAL_AI>::Create(void* data) const { - Creature* creature = reinterpret_cast<Creature *>(data); + Creature* creature = reinterpret_cast<Creature*>(data); return (new REAL_AI(creature)); } @@ -53,24 +53,24 @@ typedef FactoryHolder<CreatureAI>::FactoryHolderRepository CreatureAIRepository; //GO struct SelectableGameObjectAI : public FactoryHolder<GameObjectAI>, public Permissible<GameObject> { - SelectableGameObjectAI(const char *id) : FactoryHolder<GameObjectAI>(id) {} + SelectableGameObjectAI(const char* id) : FactoryHolder<GameObjectAI>(id) {} }; template<class REAL_GO_AI> struct GameObjectAIFactory : public SelectableGameObjectAI { - GameObjectAIFactory(const char *name) : SelectableGameObjectAI(name) {} + GameObjectAIFactory(const char* name) : SelectableGameObjectAI(name) {} - GameObjectAI* Create(void *) const; + GameObjectAI* Create(void*) const; - int Permit(const GameObject *g) const { return REAL_GO_AI::Permissible(g); } + int Permit(const GameObject* g) const { return REAL_GO_AI::Permissible(g); } }; template<class REAL_GO_AI> inline GameObjectAI* -GameObjectAIFactory<REAL_GO_AI>::Create(void *data) const +GameObjectAIFactory<REAL_GO_AI>::Create(void* data) const { - GameObject* go = reinterpret_cast<GameObject *>(data); + GameObject* go = reinterpret_cast<GameObject*>(data); return (new REAL_GO_AI(go)); } diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h index 5bb0580ae7c..7e57082827c 100755 --- a/src/server/game/AI/CreatureAIImpl.h +++ b/src/server/game/AI/CreatureAIImpl.h @@ -524,7 +524,7 @@ struct AISpellInfoType float maxRange; }; - AISpellInfoType * GetAISpellInfo(uint32 i); +AISpellInfoType* GetAISpellInfo(uint32 i); inline void CreatureAI::SetGazeOn(Unit* target) { @@ -615,7 +615,7 @@ inline void UnitAI::DoCastAOE(uint32 spellId, bool triggered) me->CastSpell((Unit*)NULL, spellId, triggered); } -inline Creature* CreatureAI::DoSummon(uint32 entry, const Position &pos, uint32 despawnTime, TempSummonType summonType) +inline Creature* CreatureAI::DoSummon(uint32 entry, const Position& pos, uint32 despawnTime, TempSummonType summonType) { return me->SummonCreature(entry, pos, summonType, despawnTime); } diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp index f7e760c7b79..5b7ee7750bc 100755 --- a/src/server/game/AI/CreatureAISelector.cpp +++ b/src/server/game/AI/CreatureAISelector.cpp @@ -28,9 +28,9 @@ namespace FactorySelector { - CreatureAI* selectAI(Creature *creature) + CreatureAI* selectAI(Creature* creature) { - const CreatureAICreator *ai_factory = NULL; + const CreatureAICreator* ai_factory = NULL; CreatureAIRegistry& ai_registry(*CreatureAIRepository::instance()); if (creature->isPet()) @@ -77,11 +77,11 @@ namespace FactorySelector { int best_val = -1; typedef CreatureAIRegistry::RegistryMapType RMT; - RMT const &l = ai_registry.GetRegisteredItems(); + RMT const& l = ai_registry.GetRegisteredItems(); for (RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter) { - const CreatureAICreator *factory = iter->second; - const SelectableAI *p = dynamic_cast<const SelectableAI *>(factory); + const CreatureAICreator* factory = iter->second; + const SelectableAI* p = dynamic_cast<const SelectableAI*>(factory); ASSERT(p != NULL); int val = p->Permit(creature); if (val > best_val) @@ -99,11 +99,11 @@ namespace FactorySelector return (ai_factory == NULL ? new NullCreatureAI(creature) : ai_factory->Create(creature)); } - MovementGenerator* selectMovementGenerator(Creature *creature) + MovementGenerator* selectMovementGenerator(Creature* creature) { MovementGeneratorRegistry& mv_registry(*MovementGeneratorRepository::instance()); ASSERT(creature->GetCreatureInfo() != NULL); - const MovementGeneratorCreator *mv_factory = mv_registry.GetRegistryItem(creature->GetDefaultMovementType()); + const MovementGeneratorCreator* mv_factory = mv_registry.GetRegistryItem(creature->GetDefaultMovementType()); /* if (mv_factory == NULL) { @@ -128,9 +128,9 @@ namespace FactorySelector } - GameObjectAI* SelectGameObjectAI(GameObject *go) + GameObjectAI* SelectGameObjectAI(GameObject* go) { - const GameObjectAICreator *ai_factory = NULL; + const GameObjectAICreator* ai_factory = NULL; GameObjectAIRegistry& ai_registry(*GameObjectAIRepository::instance()); ai_factory = ai_registry.GetRegistryItem(go->GetAIName()); diff --git a/src/server/game/AI/CreatureAISelector.h b/src/server/game/AI/CreatureAISelector.h index 4b45a73c64d..64bf96c01af 100755 --- a/src/server/game/AI/CreatureAISelector.h +++ b/src/server/game/AI/CreatureAISelector.h @@ -27,9 +27,9 @@ class GameObject; namespace FactorySelector { - CreatureAI* selectAI(Creature *); - MovementGenerator* selectMovementGenerator(Creature *); - GameObjectAI* SelectGameObjectAI(GameObject *); + CreatureAI* selectAI(Creature*); + MovementGenerator* selectMovementGenerator(Creature*); + GameObjectAI* SelectGameObjectAI(GameObject*); } #endif diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index a1a3cc6c48a..d09939c3243 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -48,14 +48,14 @@ bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatM return true; } -int CreatureEventAI::Permissible(const Creature *creature) +int CreatureEventAI::Permissible(const Creature* creature) { if (creature->GetAIName() == "EventAI") return PERMIT_BASE_SPECIAL; return PERMIT_BASE_NO; } -CreatureEventAI::CreatureEventAI(Creature *c) : CreatureAI(c) +CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c) { // Need make copy for filter unneeded steps and safe in case table reload CreatureEventAI_Event_Map::const_iterator CreatureEvents = sEventAIMgr->GetCreatureEventAIMap().find(me->GetEntry()); @@ -106,16 +106,16 @@ CreatureEventAI::CreatureEventAI(Creature *c) : CreatureAI(c) } } -bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker /*=NULL*/) +bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& holder, Unit* actionInvoker /*=NULL*/) { - if (!pHolder.Enabled || pHolder.Time) + if (!holder.Enabled || holder.Time) return false; //Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask) - if (pHolder.Event.event_inverse_phase_mask & (1 << m_Phase)) + if (holder.Event.event_inverse_phase_mask & (1 << m_Phase)) return false; - CreatureEventAI_Event const& event = pHolder.Event; + CreatureEventAI_Event const& event = holder.Event; //Check event conditions based on the event type, also reset events switch (event.event_type) @@ -125,14 +125,14 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); + holder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); break; case EVENT_T_TIMER_OOC: if (me->isInCombat()) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); + holder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); break; case EVENT_T_HP: { @@ -145,7 +145,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); + holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_MANA: @@ -159,14 +159,14 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); + holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_AGGRO: break; case EVENT_T_KILL: //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.kill.repeatMin, event.kill.repeatMax); + holder.UpdateRepeatTimer(me, event.kill.repeatMin, event.kill.repeatMax); break; case EVENT_T_DEATH: case EVENT_T_EVADE: @@ -175,15 +175,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction //Spell hit is special case, param1 and param2 handled within CreatureEventAI::SpellHit //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.spell_hit.repeatMin, event.spell_hit.repeatMax); + holder.UpdateRepeatTimer(me, event.spell_hit.repeatMin, event.spell_hit.repeatMax); break; case EVENT_T_RANGE: //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.range.repeatMin, event.range.repeatMax); + holder.UpdateRepeatTimer(me, event.range.repeatMin, event.range.repeatMax); break; case EVENT_T_OOC_LOS: //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.ooc_los.repeatMin, event.ooc_los.repeatMax); + holder.UpdateRepeatTimer(me, event.ooc_los.repeatMin, event.ooc_los.repeatMax); break; case EVENT_T_RESET: case EVENT_T_SPAWNED: @@ -199,7 +199,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); + holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_TARGET_CASTING: @@ -207,21 +207,21 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.target_casting.repeatMin, event.target_casting.repeatMax); + holder.UpdateRepeatTimer(me, event.target_casting.repeatMin, event.target_casting.repeatMax); break; case EVENT_T_FRIENDLY_HP: { if (!me->isInCombat()) return false; - Unit* pUnit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit); - if (!pUnit) + Unit* unit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit); + if (!unit) return false; - pActionInvoker = pUnit; + actionInvoker = unit; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.friendly_hp.repeatMin, event.friendly_hp.repeatMax); + holder.UpdateRepeatTimer(me, event.friendly_hp.repeatMin, event.friendly_hp.repeatMax); break; } case EVENT_T_FRIENDLY_IS_CC: @@ -237,10 +237,10 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //We don't really care about the whole list, just return first available - pActionInvoker = *(pList.begin()); + actionInvoker = *(pList.begin()); //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax); + holder.UpdateRepeatTimer(me, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax); break; } case EVENT_T_FRIENDLY_MISSING_BUFF: @@ -253,24 +253,24 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //We don't really care about the whole list, just return first available - pActionInvoker = *(pList.begin()); + actionInvoker = *(pList.begin()); //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.friendly_buff.repeatMin, event.friendly_buff.repeatMax); + holder.UpdateRepeatTimer(me, event.friendly_buff.repeatMin, event.friendly_buff.repeatMax); break; } case EVENT_T_SUMMONED_UNIT: { //Prevent event from occuring on no unit or non creatures - if (!pActionInvoker || pActionInvoker->GetTypeId() != TYPEID_UNIT) + if (!actionInvoker || actionInvoker->GetTypeId() != TYPEID_UNIT) return false; //Creature id doesn't match up - if (pActionInvoker->ToCreature()->GetEntry() != event.summon_unit.creatureId) + if (actionInvoker->ToCreature()->GetEntry() != event.summon_unit.creatureId) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.summon_unit.repeatMin, event.summon_unit.repeatMax); + holder.UpdateRepeatTimer(me, event.summon_unit.repeatMin, event.summon_unit.repeatMax); break; } case EVENT_T_TARGET_MANA: @@ -284,7 +284,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); + holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_REACHED_HOME: @@ -299,49 +299,49 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); + holder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); break; } case EVENT_T_TARGET_BUFFED: { //Prevent event from occuring on no unit - if (!pActionInvoker) + if (!actionInvoker) return false; //Note: checked only aura for effect 0, if need check aura for effect 1/2 then // possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx) - Aura const* aura = pActionInvoker->GetAura(event.buffed.spellId); + Aura const* aura = actionInvoker->GetAura(event.buffed.spellId); if (!aura || aura->GetStackAmount() < event.buffed.amount) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); + holder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); break; } default: - sLog->outErrorDb("CreatureEventAI: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", me->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + sLog->outErrorDb("CreatureEventAI: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", me->GetEntry(), holder.Event.event_id, holder.Event.event_type); break; } //Disable non-repeatable events - if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE)) - pHolder.Enabled = false; + if (!(holder.Event.event_flags & EFLAG_REPEATABLE)) + holder.Enabled = false; //Store random here so that all random actions match up uint32 rnd = rand(); //Return if chance for event is not met - if (pHolder.Event.event_chance <= rnd % 100) + if (holder.Event.event_chance <= rnd % 100) return false; //Process actions for (uint8 j = 0; j < MAX_ACTIONS; ++j) - ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker); + ProcessAction(holder.Event.action[j], rnd, holder.Event.event_id, actionInvoker); return true; } -void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker) +void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 eventId, Unit* actionInvoker) { switch (action.type) { @@ -361,11 +361,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 { Unit* target = NULL; - if (pActionInvoker) + if (actionInvoker) { - if (pActionInvoker->GetTypeId() == TYPEID_PLAYER) - target = pActionInvoker; - else if (Unit* owner = pActionInvoker->GetOwner()) + if (actionInvoker->GetTypeId() == TYPEID_PLAYER) + target = actionInvoker; + else if (Unit* owner = actionInvoker->GetOwner()) { if (owner->GetTypeId() == TYPEID_PLAYER) target = owner; @@ -442,7 +442,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } case ACTION_T_CAST: { - Unit* target = GetTargetByType(action.cast.target, pActionInvoker); + Unit* target = GetTargetByType(action.cast.target, actionInvoker); Unit* caster = me; if (!target) @@ -496,29 +496,29 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } else - sLog->outErrorDb("CreatureEventAI: event %d creature %d attempt to cast spell that doesn't exist %d", EventId, me->GetEntry(), action.cast.spellId); + sLog->outErrorDb("CreatureEventAI: event %d creature %d attempt to cast spell that doesn't exist %d", eventId, me->GetEntry(), action.cast.spellId); } break; } case ACTION_T_SUMMON: { - Unit* target = GetTargetByType(action.summon.target, pActionInvoker); + Unit* target = GetTargetByType(action.summon.target, actionInvoker); - Creature* pCreature = NULL; + Creature* creature = NULL; if (action.summon.duration) - pCreature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration); + creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration); else - pCreature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); + creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); - if (!pCreature) - sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, me->GetEntry()); + if (!creature) + sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, eventId, me->GetEntry()); else if (action.summon.target != TARGET_T_SELF && target) - pCreature->AI()->AttackStart(target); + creature->AI()->AttackStart(target); break; } case ACTION_T_THREAT_SINGLE_PCT: - if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.threat_single_pct.target, actionInvoker)) me->getThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); break; case ACTION_T_THREAT_ALL_PCT: @@ -530,18 +530,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; } case ACTION_T_QUEST_EVENT: - if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.quest_event.target, actionInvoker)) if (target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->AreaExploredOrEventHappens(action.quest_event.questId); break; case ACTION_T_CAST_EVENT: - if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.cast_event.target, actionInvoker)) if (target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->CastedCreatureOrGO(action.cast_event.creatureId, me->GetGUID(), action.cast_event.spellId); break; case ACTION_T_SET_UNIT_FIELD: { - Unit* target = GetTargetByType(action.set_unit_field.target, pActionInvoker); + Unit* target = GetTargetByType(action.set_unit_field.target, actionInvoker); // not allow modify important for integrity object fields if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END) @@ -553,11 +553,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; } case ACTION_T_SET_UNIT_FLAG: - if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.unit_flag.target, actionInvoker)) target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); break; case ACTION_T_REMOVE_UNIT_FLAG: - if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.unit_flag.target, actionInvoker)) target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); break; case ACTION_T_AUTO_ATTACK: @@ -608,12 +608,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 int32 new_phase = int32(m_Phase)+action.set_inc_phase.step; if (new_phase < 0) { - sLog->outErrorDb("CreatureEventAI: Event %d decrease m_Phase under 0. CreatureEntry = %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d decrease m_Phase under 0. CreatureEntry = %d", eventId, me->GetEntry()); m_Phase = 0; } else if (new_phase >= MAX_PHASE) { - sLog->outErrorDb("CreatureEventAI: Event %d incremented m_Phase above %u. m_Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE-1, MAX_PHASE-1, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d incremented m_Phase above %u. m_Phase mask cannot be used with phases past %u. CreatureEntry = %d", eventId, MAX_PHASE-1, MAX_PHASE-1, me->GetEntry()); m_Phase = MAX_PHASE-1; } else @@ -628,9 +628,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 me->DoFleeToGetAssistance(); break; case ACTION_T_QUEST_EVENT_ALL: - if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER) + if (actionInvoker && actionInvoker->GetTypeId() == TYPEID_PLAYER) { - if (Unit* Temp = Unit::GetUnit(*me, pActionInvoker->GetGUID())) + if (Unit* Temp = Unit::GetUnit(*me, actionInvoker->GetGUID())) if (Temp->GetTypeId() == TYPEID_PLAYER) Temp->ToPlayer()->GroupEventHappens(action.quest_event_all.questId, me); } @@ -645,7 +645,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; } case ACTION_T_REMOVEAURASFROMSPELL: - if (Unit* target = GetTargetByType(action.remove_aura.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.remove_aura.target, actionInvoker)) target->RemoveAurasDueToSpell(action.remove_aura.spellId); break; case ACTION_T_RANGED_MOVEMENT: @@ -664,80 +664,80 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (action.random_phase_range.phaseMin <= action.random_phase_range.phaseMax) m_Phase = urand(action.random_phase_range.phaseMin, action.random_phase_range.phaseMax); else - sLog->outErrorDb("CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 < Param1. Event = %d. CreatureEntry = %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 < Param1. Event = %d. CreatureEntry = %d", eventId, me->GetEntry()); break; case ACTION_T_SUMMON_ID: { - Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker); + Unit* target = GetTargetByType(action.summon_id.target, actionInvoker); CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr->GetCreatureEventAISummonMap().find(action.summon_id.spawnId); if (i == sEventAIMgr->GetCreatureEventAISummonMap().end()) { - sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, eventId, me->GetEntry()); return; } - Creature* pCreature = NULL; + Creature* creature = NULL; if ((*i).second.SpawnTimeSecs) - pCreature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, (*i).second.SpawnTimeSecs); + creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, (*i).second.SpawnTimeSecs); else - pCreature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); + creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); - if (!pCreature) - sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, me->GetEntry()); + if (!creature) + sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, eventId, me->GetEntry()); else if (action.summon_id.target != TARGET_T_SELF && target) - pCreature->AI()->AttackStart(target); + creature->AI()->AttackStart(target); break; } case ACTION_T_KILLED_MONSTER: //first attempt player who tapped creature - if (Player* pPlayer = me->GetLootRecipient()) - pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, pPlayer); // pPlayer as param is a hacky solution not to use GUID + if (Player* player = me->GetLootRecipient()) + player->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, player); // player as param is a hacky solution not to use GUID else { - //if not available, use pActionInvoker - if (Unit* pTarget = GetTargetByType(action.killed_monster.target, pActionInvoker)) - if (Player* pPlayer2 = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself()) - pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, pPlayer2); + //if not available, use actionInvoker + if (Unit* target = GetTargetByType(action.killed_monster.target, actionInvoker)) + if (Player* player2 = target->GetCharmerOrOwnerPlayerOrPlayerItself()) + player2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, player2); } break; case ACTION_T_SET_INST_DATA: { - InstanceScript* pInst = (InstanceScript*)me->GetInstanceScript(); - if (!pInst) + InstanceScript* instance = (InstanceScript*)me->GetInstanceScript(); + if (!instance) { - sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", eventId, me->GetEntry()); return; } - pInst->SetData(action.set_inst_data.field, action.set_inst_data.value); + instance->SetData(action.set_inst_data.field, action.set_inst_data.value); break; } case ACTION_T_SET_INST_DATA64: { - Unit* target = GetTargetByType(action.set_inst_data64.target, pActionInvoker); + Unit* target = GetTargetByType(action.set_inst_data64.target, actionInvoker); if (!target) { - sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", eventId, me->GetEntry()); return; } - InstanceScript* pInst = (InstanceScript*)me->GetInstanceScript(); - if (!pInst) + InstanceScript* instance = (InstanceScript*)me->GetInstanceScript(); + if (!instance) { - sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", eventId, me->GetEntry()); return; } - pInst->SetData64(action.set_inst_data64.field, target->GetGUID()); + instance->SetData64(action.set_inst_data64.field, target->GetGUID()); break; } case ACTION_T_UPDATE_TEMPLATE: if (me->GetEntry() == action.update_template.creatureId) { - sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", eventId, me->GetEntry()); return; } @@ -747,7 +747,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (me->isDead()) { - sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", eventId, me->GetEntry()); return; } me->Kill(me); @@ -792,14 +792,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_SUMMON_GO: { - GameObject* pObject = NULL; + GameObject* object = NULL; float x, y, z; me->GetPosition(x, y, z); - pObject = me->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2); - if (!pObject) + object = me->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2); + if (!object) { - sLog->outErrorDb("TSCR: EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.raw.param1, EventId, me->GetEntry()); + sLog->outErrorDb("TSCR: EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.raw.param1, eventId, me->GetEntry()); } break; } @@ -955,19 +955,19 @@ void CreatureEventAI::KilledUnit(Unit* victim) } } -void CreatureEventAI::JustSummoned(Creature* pUnit) +void CreatureEventAI::JustSummoned(Creature* unit) { - if (m_bEmptyList || !pUnit) + if (m_bEmptyList || !unit) return; for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) { if ((*i).Event.event_type == EVENT_T_SUMMONED_UNIT) - ProcessEvent(*i, pUnit); + ProcessEvent(*i, unit); } } -void CreatureEventAI::EnterCombat(Unit *enemy) +void CreatureEventAI::EnterCombat(Unit* enemy) { //Check for on combat start events if (!m_bEmptyList) @@ -999,7 +999,7 @@ void CreatureEventAI::EnterCombat(Unit *enemy) m_EventDiff = 0; } -void CreatureEventAI::AttackStart(Unit *who) +void CreatureEventAI::AttackStart(Unit* who) { if (!who) return; @@ -1047,7 +1047,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who) CreatureAI::MoveInLineOfSight(who); } -void CreatureEventAI::SpellHit(Unit* pUnit, const SpellInfo* pSpell) +void CreatureEventAI::SpellHit(Unit* unit, const SpellInfo* spell) { if (m_bEmptyList) @@ -1056,9 +1056,9 @@ void CreatureEventAI::SpellHit(Unit* pUnit, const SpellInfo* pSpell) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) if ((*i).Event.event_type == EVENT_T_SPELLHIT) //If spell id matches (or no spell id) & if spell school matches (or no spell school) - if (!(*i).Event.spell_hit.spellId || pSpell->Id == (*i).Event.spell_hit.spellId) - if (pSpell->SchoolMask & (*i).Event.spell_hit.schoolMask) - ProcessEvent(*i, pUnit); + if (!(*i).Event.spell_hit.spellId || spell->Id == (*i).Event.spell_hit.spellId) + if (spell->SchoolMask & (*i).Event.spell_hit.schoolMask) + ProcessEvent(*i, unit); } void CreatureEventAI::UpdateAI(const uint32 diff) @@ -1152,9 +1152,9 @@ inline int32 CreatureEventAI::GetRandActionParam(uint32 rnd, int32 param1, int32 return 0; } -inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoker) +inline Unit* CreatureEventAI::GetTargetByType(uint32 target, Unit* actionInvoker) { - switch (Target) + switch (target) { case TARGET_T_SELF: return me; @@ -1169,23 +1169,23 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoke case TARGET_T_HOSTILE_RANDOM_NOT_TOP: return SelectTarget(SELECT_TARGET_RANDOM, 1); case TARGET_T_ACTION_INVOKER: - return pActionInvoker; + return actionInvoker; default: return NULL; }; } -Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) +Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff) { CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Unit* pUnit = NULL; + Unit* unit = NULL; - Trinity::MostHPMissingInRange u_check(me, range, MinHPDiff); - Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, pUnit, u_check); + Trinity::MostHPMissingInRange u_check(me, range, minHPDiff); + Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check); /* typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; @@ -1194,7 +1194,7 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher); cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, range); - return pUnit; + return unit; } void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range) @@ -1230,9 +1230,9 @@ void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, flo // ********************************* // *** Functions used globally *** -void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target) +void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* source, Unit* target) { - if (!pSource) + if (!source) { sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i, invalid Source pointer.", textEntry); return; @@ -1240,7 +1240,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* if (textEntry >= 0) { - sLog->outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), textEntry); + sLog->outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", source->GetEntry(), source->GetTypeId(), source->GetGUIDLow(), textEntry); return; } @@ -1248,7 +1248,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* if (i == sEventAIMgr->GetCreatureEventAITextMap().end()) { - sLog->outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), textEntry); + sLog->outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", source->GetEntry(), source->GetTypeId(), source->GetGUIDLow(), textEntry); return; } @@ -1257,75 +1257,75 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* if ((*i).second.SoundId) { if (GetSoundEntriesStore()->LookupEntry((*i).second.SoundId)) - pSource->PlayDirectSound((*i).second.SoundId); + source->PlayDirectSound((*i).second.SoundId); else sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process invalid sound id %u.", textEntry, (*i).second.SoundId); } if ((*i).second.Emote) { - if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER) + if (source->GetTypeId() == TYPEID_UNIT || source->GetTypeId() == TYPEID_PLAYER) { - ((Unit*)pSource)->HandleEmoteCommand((*i).second.Emote); + ((Unit*)source)->HandleEmoteCommand((*i).second.Emote); } else - sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", textEntry, pSource->GetTypeId()); + sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", textEntry, source->GetTypeId()); } switch((*i).second.Type) { case CHAT_TYPE_SAY: - pSource->MonsterSay(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); + source->MonsterSay(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); break; case CHAT_TYPE_YELL: - pSource->MonsterYell(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); + source->MonsterYell(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); break; case CHAT_TYPE_TEXT_EMOTE: - pSource->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0); + source->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0); break; case CHAT_TYPE_BOSS_EMOTE: - pSource->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0, true); + source->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0, true); break; case CHAT_TYPE_WHISPER: { if (target && target->GetTypeId() == TYPEID_PLAYER) - pSource->MonsterWhisper(textEntry, target->GetGUID()); + source->MonsterWhisper(textEntry, target->GetGUID()); else sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); }break; case CHAT_TYPE_BOSS_WHISPER: { if (target && target->GetTypeId() == TYPEID_PLAYER) - pSource->MonsterWhisper(textEntry, target->GetGUID(), true); + source->MonsterWhisper(textEntry, target->GetGUID(), true); else sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); }break; case CHAT_TYPE_ZONE_YELL: - pSource->MonsterYellToZone(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); + source->MonsterYellToZone(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); break; } } -bool CreatureEventAI::CanCast(Unit* Target, SpellInfo const *Spell, bool Triggered) +bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool triggered) { //No target so we can't cast - if (!Target || !Spell) + if (!target || !spell) return false; //Silenced so we can't cast - if (!Triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) + if (!triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) return false; //Check for power - if (!Triggered && me->GetPower((Powers)Spell->PowerType) < Spell->CalcPowerCost(me, Spell->GetSchoolMask())) + if (!triggered && me->GetPower((Powers)spell->PowerType) < spell->CalcPowerCost(me, spell->GetSchoolMask())) return false; //Unit is out of range of this spell - if (!me->IsInRange(Target, Spell->GetMinRange(false), Spell->GetMaxRange(false))) + if (!me->IsInRange(target, spell->GetMinRange(false), spell->GetMaxRange(false))) return false; return true; } -void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) +void CreatureEventAI::ReceiveEmote(Player* player, uint32 textEmote) { if (m_bEmptyList) return; @@ -1334,7 +1334,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) { if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE) { - if ((*itr).Event.receive_emote.emoteId != text_emote) + if ((*itr).Event.receive_emote.emoteId != textEmote) return; Condition cond; @@ -1342,10 +1342,10 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) cond.mConditionValue1 = (*itr).Event.receive_emote.conditionValue1; cond.mConditionValue2 = (*itr).Event.receive_emote.conditionValue2; - if (cond.Meets(pPlayer)) + if (cond.Meets(player)) { sLog->outDebug(LOG_FILTER_DATABASE_AI, "CreatureEventAI: ReceiveEmote CreatureEventAI: Condition ok, processing"); - ProcessEvent(*itr, pPlayer); + ProcessEvent(*itr, player); } } } diff --git a/src/server/game/AI/EventAI/CreatureEventAI.h b/src/server/game/AI/EventAI/CreatureEventAI.h index 7df0dc2d30d..2fc26bcbd3e 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.h +++ b/src/server/game/AI/EventAI/CreatureEventAI.h @@ -591,7 +591,7 @@ class CreatureEventAI : public CreatureAI { public: - explicit CreatureEventAI(Creature *c); + explicit CreatureEventAI(Creature* c); ~CreatureEventAI() { m_CreatureEventAIList.clear(); @@ -599,32 +599,32 @@ class CreatureEventAI : public CreatureAI void JustRespawned(); void Reset(); void JustReachedHome(); - void EnterCombat(Unit *enemy); + void EnterCombat(Unit* enemy); void EnterEvadeMode(); void JustDied(Unit* /*killer*/); void KilledUnit(Unit* victim); - void JustSummoned(Creature* pUnit); - void AttackStart(Unit *who); - void MoveInLineOfSight(Unit *who); - void SpellHit(Unit* pUnit, const SpellInfo* pSpell); + void JustSummoned(Creature* unit); + void AttackStart(Unit* who); + void MoveInLineOfSight(Unit* who); + void SpellHit(Unit* unit, const SpellInfo* spell); void DamageTaken(Unit* done_by, uint32& damage); void HealReceived(Unit* /*done_by*/, uint32& /*addhealth*/) {} void UpdateAI(const uint32 diff); - void ReceiveEmote(Player* pPlayer, uint32 text_emote); - static int Permissible(const Creature *); + void ReceiveEmote(Player* player, uint32 textEmote); + static int Permissible(const Creature*); - bool ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker = NULL); - void ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker); + bool ProcessEvent(CreatureEventAIHolder& holder, Unit* actionInvoker = NULL); + void ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 eventId, Unit* actionInvoker); inline uint32 GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3); inline int32 GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3); - inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker); + inline Unit* GetTargetByType(uint32 target, Unit* actionInvoker); - void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target); - bool CanCast(Unit* Target, SpellInfo const *Spell, bool Triggered); + void DoScriptText(int32 textEntry, WorldObject* source, Unit* target); + bool CanCast(Unit* target, SpellInfo const* spell, bool triggered); bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event); - Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff); + Unit* DoSelectLowestHpFriendly(float range, uint32 minHPDiff); void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid); void DoFindFriendlyCC(std::list<Creature*>& _list, float range); diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp index 6c3765252f0..72828ad01d6 100755 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp @@ -124,7 +124,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); CreatureEventAI_Summon temp; @@ -178,7 +178,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); CreatureEventAI_Event temp; temp.event_id = EventAI_Type(fields[0].GetUInt32()); @@ -250,14 +250,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case EVENT_T_SPELLHIT: if (temp.spell_hit.spellId) { - SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); - if (!pSpell) + SpellInfo const* spell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); + if (!spell) { sLog->outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); continue; } - if ((temp.spell_hit.schoolMask & pSpell->SchoolMask) != pSpell->SchoolMask) + if ((temp.spell_hit.schoolMask & spell->SchoolMask) != spell->SchoolMask) sLog->outErrorDb("CreatureEventAI: Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i); } @@ -304,8 +304,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case EVENT_T_FRIENDLY_MISSING_BUFF: { - SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); - if (!pSpell) + SpellInfo const* spell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); + if (!spell) { sLog->outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); continue; @@ -381,8 +381,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case EVENT_T_BUFFED: case EVENT_T_TARGET_BUFFED: { - SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(temp.buffed.spellId); - if (!pSpell) + SpellInfo const* spell = sSpellMgr->GetSpellInfo(temp.buffed.spellId); + if (!spell) { sLog->outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); continue; @@ -501,7 +501,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case ACTION_T_CAST: { - const SpellInfo *spell = sSpellMgr->GetSpellInfo(action.cast.spellId); + const SpellInfo* spell = sSpellMgr->GetSpellInfo(action.cast.spellId); if (!spell) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.cast.spellId); /* FIXME: temp.raw.param3 not have event tipes with recovery time in it.... diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 001296e5c45..ebca71df079 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -16,13 +16,13 @@ struct TSpellSummary { uint8 Targets; // set of enum SelectTarget uint8 Effects; // set of enum SelectEffect -} extern *SpellSummary; +} extern* SpellSummary; void SummonList::DoZoneInCombat(uint32 entry) { for (iterator i = begin(); i != end();) { - Creature *summon = Unit::GetCreature(*me, *i); + Creature* summon = Unit::GetCreature(*me, *i); ++i; if (summon && summon->IsAIEnabled && (!entry || summon->GetEntry() == entry)) @@ -34,7 +34,7 @@ void SummonList::DoAction(uint32 entry, int32 info) { for (iterator i = begin(); i != end();) { - Creature *summon = Unit::GetCreature(*me, *i); + Creature* summon = Unit::GetCreature(*me, *i); ++i; if (summon && summon->IsAIEnabled && (!entry || summon->GetEntry() == entry)) @@ -46,7 +46,7 @@ void SummonList::DespawnEntry(uint32 entry) { for (iterator i = begin(); i != end();) { - Creature *summon = Unit::GetCreature(*me, *i); + Creature* summon = Unit::GetCreature(*me, *i); if (!summon) erase(i++); else if (summon->GetEntry() == entry) @@ -64,7 +64,7 @@ void SummonList::DespawnAll() { while (!empty()) { - Creature *summon = Unit::GetCreature(*me, *begin()); + Creature* summon = Unit::GetCreature(*me, *begin()); if (!summon) erase(begin()); else @@ -108,8 +108,8 @@ bool SummonList::HasEntry(uint32 entry) return false; } -ScriptedAI::ScriptedAI(Creature* pCreature) : CreatureAI(pCreature), - me(pCreature), +ScriptedAI::ScriptedAI(Creature* creature) : CreatureAI(creature), + me(creature), IsFleeing(false), _evadeCheckCooldown(2500), _isCombatMovementAllowed(true) @@ -118,13 +118,13 @@ ScriptedAI::ScriptedAI(Creature* pCreature) : CreatureAI(pCreature), _difficulty = Difficulty(me->GetMap()->GetSpawnMode()); } -void ScriptedAI::AttackStartNoMove(Unit* pWho) +void ScriptedAI::AttackStartNoMove(Unit* who) { - if (!pWho) + if (!who) return; - if (me->Attack(pWho, false)) - DoStartNoMovement(pWho); + if (me->Attack(who, false)) + DoStartNoMovement(who); } void ScriptedAI::UpdateAI(uint32 const /*diff*/) @@ -144,15 +144,15 @@ void ScriptedAI::UpdateAI(uint32 const /*diff*/) } } -void ScriptedAI::DoStartMovement(Unit* pVictim, float fDistance, float fAngle) +void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle) { - if (pVictim) - me->GetMotionMaster()->MoveChase(pVictim, fDistance, fAngle); + if (victim) + me->GetMotionMaster()->MoveChase(victim, distance, angle); } -void ScriptedAI::DoStartNoMovement(Unit* pVictim) +void ScriptedAI::DoStartNoMovement(Unit* victim) { - if (!pVictim) + if (!victim) return; me->GetMotionMaster()->MoveIdle(); @@ -164,27 +164,27 @@ void ScriptedAI::DoStopAttack() me->AttackStop(); } -void ScriptedAI::DoCastSpell(Unit* pTarget, SpellInfo const* pSpellInfo, bool bTriggered) +void ScriptedAI::DoCastSpell(Unit* target, SpellInfo const* spellInfo, bool triggered) { - if (!pTarget || me->IsNonMeleeSpellCasted(false)) + if (!target || me->IsNonMeleeSpellCasted(false)) return; me->StopMoving(); - me->CastSpell(pTarget, pSpellInfo, bTriggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE); + me->CastSpell(target, spellInfo, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE); } -void ScriptedAI::DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId) +void ScriptedAI::DoPlaySoundToSet(WorldObject* source, uint32 soundId) { - if (!pSource) + if (!source) return; - if (!GetSoundEntriesStore()->LookupEntry(uiSoundId)) + if (!GetSoundEntriesStore()->LookupEntry(soundId)) { - sLog->outError("TSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", uiSoundId, pSource->GetTypeId(), pSource->GetGUIDLow()); + sLog->outError("TSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", soundId, source->GetTypeId(), source->GetGUIDLow()); return; } - pSource->PlayDirectSound(uiSoundId); + source->PlayDirectSound(soundId); } Creature* ScriptedAI::DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime) @@ -302,105 +302,107 @@ void ScriptedAI::DoResetThreat() for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { - Unit* pUnit = Unit::GetUnit((*me), (*itr)->getUnitGuid()); + Unit* unit = Unit::GetUnit((*me), (*itr)->getUnitGuid()); - if (pUnit && DoGetThreat(pUnit)) - DoModifyThreatPercent(pUnit, -100); + if (unit && DoGetThreat(unit)) + DoModifyThreatPercent(unit, -100); } } -float ScriptedAI::DoGetThreat(Unit* pUnit) +float ScriptedAI::DoGetThreat(Unit* unit) { - if (!pUnit) return 0.0f; - return me->getThreatManager().getThreat(pUnit); + if (!unit) + return 0.0f; + return me->getThreatManager().getThreat(unit); } -void ScriptedAI::DoModifyThreatPercent(Unit* pUnit, int32 pct) +void ScriptedAI::DoModifyThreatPercent(Unit* unit, int32 pct) { - if (!pUnit) return; - me->getThreatManager().modifyThreatPercent(pUnit, pct); + if (!unit) + return; + me->getThreatManager().modifyThreatPercent(unit, pct); } -void ScriptedAI::DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime) +void ScriptedAI::DoTeleportTo(float x, float y, float z, uint32 time) { - me->Relocate(fX, fY, fZ); - me->SendMonsterMove(fX, fY, fZ, uiTime); + me->Relocate(x, y, z); + me->SendMonsterMove(x, y, z, time); } -void ScriptedAI::DoTeleportTo(const float fPos[4]) +void ScriptedAI::DoTeleportTo(const float position[4]) { - me->NearTeleportTo(fPos[0], fPos[1], fPos[2], fPos[3]); + me->NearTeleportTo(position[0], position[1], position[2], position[3]); } -void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, float fO) +void ScriptedAI::DoTeleportPlayer(Unit* unit, float x, float y, float z, float o) { - if (!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER) + if (!unit || unit->GetTypeId() != TYPEID_PLAYER) { - if (pUnit) - sLog->outError("TSCR: Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), fX, fY, fZ, fO); + if (unit) + sLog->outError("TSCR: Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o); return; } - CAST_PLR(pUnit)->TeleportTo(pUnit->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT); + CAST_PLR(unit)->TeleportTo(unit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); } -void ScriptedAI::DoTeleportAll(float fX, float fY, float fZ, float fO) +void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) { - Map *map = me->GetMap(); + Map* map = me->GetMap(); if (!map->IsDungeon()) return; - Map::PlayerList const &PlayerList = map->GetPlayers(); - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (Player* i_pl = i->getSource()) - if (i_pl->isAlive()) - i_pl->TeleportTo(me->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT); + Map::PlayerList const& PlayerList = map->GetPlayers(); + for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) + if (Player* player = itr->getSource()) + if (player->isAlive()) + player->TeleportTo(me->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); } -Unit* ScriptedAI::DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff) +Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff) { - Unit* pUnit = NULL; - Trinity::MostHPMissingInRange u_check(me, fRange, uiMinHPDiff); - Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, pUnit, u_check); - me->VisitNearbyObject(fRange, searcher); + Unit* unit = NULL; + Trinity::MostHPMissingInRange u_check(me, range, minHPDiff); + Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check); + me->VisitNearbyObject(range, searcher); - return pUnit; + return unit; } -std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float fRange) +std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float range) { - std::list<Creature*> pList; - Trinity::FriendlyCCedInRange u_check(me, fRange); - Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, pList, u_check); - me->VisitNearbyObject(fRange, searcher); - return pList; + std::list<Creature*> list; + Trinity::FriendlyCCedInRange u_check(me, range); + Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, list, u_check); + me->VisitNearbyObject(range, searcher); + return list; } -std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellid) +std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 uiSpellid) { - std::list<Creature*> pList; - Trinity::FriendlyMissingBuffInRange u_check(me, fRange, uiSpellid); - Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, pList, u_check); - me->VisitNearbyObject(fRange, searcher); - return pList; + std::list<Creature*> list; + Trinity::FriendlyMissingBuffInRange u_check(me, range, uiSpellid); + Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, list, u_check); + me->VisitNearbyObject(range, searcher); + return list; } -Player* ScriptedAI::GetPlayerAtMinimumRange(float fMinimumRange) +Player* ScriptedAI::GetPlayerAtMinimumRange(float minimumRange) { - Player* pPlayer = NULL; + Player* player = NULL; CellPair pair(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); Cell cell(pair); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Trinity::PlayerAtMinimumRangeAway check(me, fMinimumRange); - Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(me, pPlayer, check); + Trinity::PlayerAtMinimumRangeAway check(me, minimumRange); + Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(me, player, check); TypeContainerVisitor<Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway>, GridTypeMapContainer> visitor(searcher); cell.Visit(pair, visitor, *(me->GetMap())); - return pPlayer; + return player; } void ScriptedAI::SetEquipmentSlots(bool loadDefault, int32 mainHand /*= EQUIP_NO_CHANGE*/, int32 offHand /*= EQUIP_NO_CHANGE*/, int32 ranged /*= EQUIP_NO_CHANGE*/) @@ -451,14 +453,14 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff) if (me->IsInEvadeMode() || !me->getVictim()) return false; - float fX = me->GetPositionX(); - float fY = me->GetPositionY(); - float fZ = me->GetPositionZ(); + float x = me->GetPositionX(); + float y = me->GetPositionY(); + float z = me->GetPositionZ(); switch(me->GetEntry()) { case NPC_BROODLORD: // broodlord (not move down stairs) - if (fZ > 448.60f) + if (z > 448.60f) return false; break; case NPC_VOID_REAVER: // void reaver (calculate from center of room) @@ -466,11 +468,11 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff) return false; break; case NPC_JAN_ALAI: // jan'alai (calculate by Z) - if (fZ > 12.0f) + if (z > 12.0f) return false; break; case NPC_SARTHARION: // sartharion (calculate box) - if (fX > 3218.86f && fX < 3275.69f && fY < 572.40f && fY > 484.68f) + if (x > 3218.86f && x < 3275.69f && y < 572.40f && y > 484.68f) return false; break; default: diff --git a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp index a3bbd65aff0..c4142ba2b1b 100755 --- a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp @@ -26,7 +26,7 @@ EndScriptData */ #include "ScriptPCH.h" #include "ScriptedSimpleAI.h" -SimpleAI::SimpleAI(Creature *c) : ScriptedAI(c) +SimpleAI::SimpleAI(Creature* c) : ScriptedAI(c) { //Clear all data Aggro_TextId[0] = 0; @@ -63,7 +63,7 @@ void SimpleAI::Reset() { } -void SimpleAI::EnterCombat(Unit *who) +void SimpleAI::EnterCombat(Unit* who) { //Reset cast timers if (Spell[0].First_Cast >= 0) @@ -123,36 +123,36 @@ void SimpleAI::KilledUnit(Unit* victim) if (!Kill_Spell) return; - Unit *pTarget = NULL; + Unit* target = NULL; switch (Kill_Target_Type) { case CAST_SELF: - pTarget = me; + target = me; break; case CAST_HOSTILE_TARGET: - pTarget = me->getVictim(); + target = me->getVictim(); break; case CAST_HOSTILE_SECOND_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); + target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); break; case CAST_HOSTILE_LAST_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); + target = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); break; case CAST_HOSTILE_RANDOM: - pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0); + target = SelectTarget(SELECT_TARGET_RANDOM, 0); break; case CAST_KILLEDUNIT_VICTIM: - pTarget = victim; + target = victim; break; } //Target is ok, cast a spell on it - if (pTarget) - DoCast(pTarget, Kill_Spell); + if (target) + DoCast(target, Kill_Spell); } -void SimpleAI::DamageTaken(Unit* killer, uint32 &damage) +void SimpleAI::DamageTaken(Unit* killer, uint32& damage) { //Return if damage taken won't kill us if (me->GetHealth() > damage) @@ -171,33 +171,33 @@ void SimpleAI::DamageTaken(Unit* killer, uint32 &damage) if (!Death_Spell) return; - Unit *pTarget = NULL; + Unit* target = NULL; switch (Death_Target_Type) { case CAST_SELF: - pTarget = me; + target = me; break; case CAST_HOSTILE_TARGET: - pTarget = me->getVictim(); + target = me->getVictim(); break; case CAST_HOSTILE_SECOND_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); + target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); break; case CAST_HOSTILE_LAST_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); + target = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); break; case CAST_HOSTILE_RANDOM: - pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0); + target = SelectTarget(SELECT_TARGET_RANDOM, 0); break; case CAST_JUSTDIED_KILLER: - pTarget = killer; + target = killer; break; } //Target is ok, cast a spell on it - if (pTarget) - DoCast(pTarget, Death_Spell); + if (target) + DoCast(target, Death_Spell); } void SimpleAI::UpdateAI(const uint32 diff) @@ -222,34 +222,34 @@ void SimpleAI::UpdateAI(const uint32 diff) //Check Current spell if (!(Spell[i].InterruptPreviousCast && me->IsNonMeleeSpellCasted(false))) { - Unit *pTarget = NULL; + Unit* target = NULL; switch (Spell[i].Cast_Target_Type) { case CAST_SELF: - pTarget = me; + target = me; break; case CAST_HOSTILE_TARGET: - pTarget = me->getVictim(); + target = me->getVictim(); break; case CAST_HOSTILE_SECOND_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); + target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); break; case CAST_HOSTILE_LAST_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); + target = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); break; case CAST_HOSTILE_RANDOM: - pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0); + target = SelectTarget(SELECT_TARGET_RANDOM, 0); break; } //Target is ok, cast a spell on it and then do our random yell - if (pTarget) + if (target) { if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); - DoCast(pTarget, Spell[i].Spell_Id); + DoCast(target, Spell[i].Spell_Id); //Yell and sound use the same number so that you can make //the Creature yell with the correct sound effect attached @@ -257,7 +257,7 @@ void SimpleAI::UpdateAI(const uint32 diff) //Random yell if (Spell[i].TextId[random_text]) - DoScriptText(Spell[i].TextId[random_text], me, pTarget); + DoScriptText(Spell[i].TextId[random_text], me, target); //Random sound if (Spell[i].Text_Sound[random_text]) diff --git a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h index 246f1b9df3e..a38bdf85e14 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h @@ -23,7 +23,7 @@ enum CastTarget struct SimpleAI : public ScriptedAI { - SimpleAI(Creature *c);// : ScriptedAI(c); + SimpleAI(Creature* c);// : ScriptedAI(c); void Reset(); @@ -31,7 +31,7 @@ struct SimpleAI : public ScriptedAI void KilledUnit(Unit* /*victim*/); - void DamageTaken(Unit* killer, uint32 &damage); + void DamageTaken(Unit* killer, uint32& damage); void UpdateAI(const uint32 diff); diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index db8d2ffc2cb..7817465c55e 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -787,7 +787,7 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui mFollowCreditType = creditType; } -void SmartAI::SetScript9(SmartScriptHolder &e, uint32 entry, Unit* invoker) +void SmartAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker) { if (invoker) GetScript()->mLastInvoker = invoker->GetGUID(); @@ -888,7 +888,7 @@ void SmartGameObjectAI::SetData(uint32 id, uint32 value) GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, NULL, id, value); } -void SmartGameObjectAI::SetScript9(SmartScriptHolder &e, uint32 entry, Unit* invoker) +void SmartGameObjectAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker) { if (invoker) GetScript()->mLastInvoker = invoker->GetGUID(); diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index e26d125b442..834a34bf17b 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -48,7 +48,7 @@ class SmartAI : public CreatureAI { public: ~SmartAI(){}; - explicit SmartAI(Creature *c); + explicit SmartAI(Creature* c); // Start moving to the desired MovePoint void StartPath(bool run = false, uint32 path = 0, bool repeat = false, Unit* invoker = NULL); @@ -65,7 +65,7 @@ class SmartAI : public CreatureAI void SetCombatMove(bool on); void SetFollow(Unit* target, float dist = 0.0f, float angle = 0.0f, uint32 credit = 0, uint32 end = 0, uint32 creditType = 0); - void SetScript9(SmartScriptHolder &e, uint32 entry, Unit* invoker); + void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker); SmartScript* GetScript() { return &mScript; } bool IsEscortInvokerInRange(); @@ -79,7 +79,7 @@ class SmartAI : public CreatureAI void JustReachedHome(); // Called for reaction at enter to combat if not in combat yet (enemy can be NULL) - void EnterCombat(Unit *enemy); + void EnterCombat(Unit* enemy); // Called for reaction at stopping attack at no attackers or targets void EnterEvadeMode(); @@ -97,7 +97,7 @@ class SmartAI : public CreatureAI void AttackStart(Unit* who); // Called if IsVisible(Unit *who) is true at each *who move, reaction at visibility zone enter - void MoveInLineOfSight(Unit *who); + void MoveInLineOfSight(Unit* who); // Called when hit by a spell void SpellHit(Unit* pUnit, const SpellInfo* pSpell); @@ -124,13 +124,13 @@ class SmartAI : public CreatureAI void IsSummonedBy(Unit* summoner); // Called at any Damage to any victim (before damage apply) - void DamageDealt(Unit* done_to, uint32 & damage, DamageEffectType /*damagetype*/); + void DamageDealt(Unit* done_to, uint32& damage, DamageEffectType /*damagetype*/); // Called when a summoned creature dissapears (UnSommoned) void SummonedCreatureDespawn(Creature* unit); // called when the corpse of this creature gets removed - void CorpseRemoved(uint32 & respawnDelay); + void CorpseRemoved(uint32& respawnDelay); // Called at World update tick if creature is charmed void UpdateAIWhileCharmed(const uint32 diff); @@ -163,7 +163,7 @@ class SmartAI : public CreatureAI uint64 GetGUID(int32 id = 0); //core related - static int Permissible(const Creature *); + static int Permissible(const Creature*); // Called at movepoint reached void MovepointReached(uint32 id); @@ -231,7 +231,7 @@ class SmartAI : public CreatureAI class SmartGameObjectAI : public GameObjectAI { public: - SmartGameObjectAI(GameObject *g) : GameObjectAI(g), go(g) {} + SmartGameObjectAI(GameObject* g) : GameObjectAI(g), go(g) {} ~SmartGameObjectAI() {} void UpdateAI(const uint32 diff); @@ -248,7 +248,7 @@ public: uint32 GetDialogStatus(Player* /*player*/); void Destroyed(Player* player, uint32 eventId); void SetData(uint32 id, uint32 value); - void SetScript9(SmartScriptHolder &e, uint32 entry, Unit* invoker); + void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker); protected: GameObject* const go; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 99c804d3d2c..cc244f77dc2 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -282,7 +282,7 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e) return true; } -bool SmartAIMgr::IsEventValid(SmartScriptHolder &e) +bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) { if (e.event.type >= SMART_EVENT_END) { diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 4ab9a738707..2292a343c21 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1236,7 +1236,7 @@ class SmartAIMgr //event stores SmartAIEventMap mEventMap[SMART_SCRIPT_TYPE_MAX]; - bool IsEventValid(SmartScriptHolder &e); + bool IsEventValid(SmartScriptHolder& e); bool IsTargetValid(SmartScriptHolder const& e); /*inline bool IsTargetValid(SmartScriptHolder e, int32 target) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 0896a6d603a..b099fb5faa7 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -996,12 +996,12 @@ void Creature::SetLootRecipient(Unit *unit) } // return true if this creature is tapped by the player or by a member of his group. -bool Creature::isTappedBy(Player* player) const +bool Creature::isTappedBy(Player const* player) const { if (player->GetGUID() == m_lootRecipient) return true; - Group* playerGroup = player->GetGroup(); + Group const* playerGroup = player->GetGroup(); if (!playerGroup || playerGroup != GetLootRecipientGroup()) // if we dont have a group we arent the recipient return false; // if creature doesnt have group bound it means it was solo killed by someone else @@ -1947,7 +1947,7 @@ bool Creature::_IsTargetAcceptable(const Unit* target) const // if the target cannot be attacked, the target is not acceptable if (IsFriendlyTo(target) - || !target->isAttackableByAOE() + || !target->isTargetableForAttack(false) || (m_vehicle && (IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target)))) return false; diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index b1d805a3a6e..bf61e98bb41 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -555,10 +555,10 @@ class Creature : public Unit, public GridObject<Creature> Loot loot; bool lootForPickPocketed; bool lootForBody; - Player *GetLootRecipient() const; - Group *GetLootRecipientGroup() const; + Player* GetLootRecipient() const; + Group* GetLootRecipientGroup() const; bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; } - bool isTappedBy(Player* player) const; // return true if the creature is tapped by the player or a member of his party. + bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party. void SetLootRecipient (Unit* unit); void AllLootRemovedFromCorpse(); diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index b325a7fb407..5308c30a196 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -147,7 +147,7 @@ void GameObject::RemoveFromWorld() if (Unit* owner = GetOwner()) owner->RemoveGameObject(this, false); else - sLog->outError("Delete GameObject (GUID: %u Entry: %u) that have references in not found creature %u GO list. Crash possible later.", GetGUIDLow(), GetGOInfo()->entry, GUID_LOPART(owner_guid)); + sLog->outError("Delete GameObject (GUID: %u Entry: %u, Name: %s) that have references in not found creature %u GO list. Crash possible later.", GetGUIDLow(), GetGOInfo()->entry, GetGOInfo()->name.c_str(), GUID_LOPART(owner_guid)); } WorldObject::RemoveFromWorld(); sObjectAccessor->RemoveObject(this); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 8067341b43b..ec493c4b23f 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -5677,8 +5677,6 @@ void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, floa m_auraBaseMod[modGroup][modType] += apply ? amount : -amount; break; case PCT_MOD: - if (amount <= -100.0f) - amount = -200.0f; ApplyPercentModFloatVar(m_auraBaseMod[modGroup][modType], amount, apply); break; } @@ -8094,7 +8092,7 @@ void Player::_ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType att if (unitModType == TOTAL_VALUE) ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, aura->GetAmount(), apply); else - ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, aura->GetAmount() / 100.0f, apply); + ApplyPercentModFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, aura->GetAmount(), apply); } } @@ -14213,7 +14211,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men break; case GOSSIP_OPTION_SPIRITHEALER: if (isDead()) - source->ToCreature()->CastSpell((source->ToCreature()), 17251, true, NULL, NULL, GetGUID()); + source->ToCreature()->CastSpell(source->ToCreature(), 17251, true, NULL, NULL, GetGUID()); break; case GOSSIP_OPTION_QUESTGIVER: PrepareQuestMenu(guid); @@ -14250,7 +14248,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men ResetPetTalents(); break; case GOSSIP_OPTION_TAXIVENDOR: - GetSession()->SendTaxiMenu((source->ToCreature())); + GetSession()->SendTaxiMenu(source->ToCreature()); break; case GOSSIP_OPTION_INNKEEPER: PlayerTalkClass->SendCloseGossip(); @@ -14268,7 +14266,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men GetSession()->SendTabardVendorActivate(guid); break; case GOSSIP_OPTION_AUCTIONEER: - GetSession()->SendAuctionHello(guid, (source->ToCreature())); + GetSession()->SendAuctionHello(guid, source->ToCreature()); break; case GOSSIP_OPTION_SPIRITGUIDE: PrepareGossipMenu(source); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 1b6c5baa8f0..8ed36224a34 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -7207,6 +7207,8 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere if (!triggeredSpell) return false; basepoints0 = CalculatePctN(int32(damage), triggerAmount) / (triggeredSpell->GetMaxDuration() / triggeredSpell->Effects[0].Amplitude); + // Add remaining ticks to healing done + basepoints0 += GetRemainingPeriodicAmount(GetGUID(), triggered_spell_id, SPELL_AURA_PERIODIC_HEAL); } break; } @@ -10853,16 +10855,16 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellInfo const* spellProto, uint32 coeff = DotFactor; } - float coeff2 = CalculateLevelPenalty(spellProto) * stack; - if (spellProto->SpellFamilyName) // TODO: fix this - TakenTotal+= int32(TakenAdvertisedBenefit * coeff * coeff2); + float factorMod = CalculateLevelPenalty(spellProto) * stack; + // level penalty still applied on Taken bonus - is it blizzlike? + TakenTotal+= int32(TakenAdvertisedBenefit * factorMod); if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff); coeff /= 100.0f; } - DoneTotal += int32(DoneAdvertisedBenefit * coeff * coeff2); + DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod); } // Some spells don't benefit from done mods @@ -11412,7 +11414,8 @@ uint32 Unit::SpellHealingBonus(Unit* victim, SpellInfo const* spellProto, uint32 } factorMod *= CalculateLevelPenalty(spellProto) * stack; - TakenTotal += int32(TakenAdvertisedBenefit * coeff * factorMod); + // level penalty still applied on Taken bonus - is it blizzlike? + TakenTotal += int32(TakenAdvertisedBenefit * factorMod); if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; @@ -12253,10 +12256,16 @@ void Unit::ClearInCombat() RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); } -// TODO: remove this function -bool Unit::isTargetableForAttack() const +bool Unit::isTargetableForAttack(bool checkFakeDeath) const { - return isAttackableByAOE() && !HasUnitState(UNIT_STAT_DIED); + if (HasFlag(UNIT_FIELD_FLAGS, + UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_OOC_NOT_ATTACKABLE)) + return false; + + if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->isGameMaster()) + return false; + + return !HasUnitState(UNIT_STAT_UNATTACKABLE) && (!checkFakeDeath || !HasUnitState(UNIT_STAT_DIED)); } bool Unit::canAttack(Unit const* target, bool force) const @@ -12283,7 +12292,7 @@ bool Unit::canAttack(Unit const* target, bool force) const else if (!IsHostileTo(target)) return false; - if (!target->isAttackableByAOE()) + if (!target->isTargetableForAttack(false)) return false; if (target->HasUnitState(UNIT_STAT_DIED)) @@ -12306,27 +12315,6 @@ bool Unit::canAttack(Unit const* target, bool force) const return true; } -bool Unit::isAttackableByAOE(SpellInfo const* spellProto) const -{ - bool targetMustBeDead = spellProto ? bool(spellProto->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_GHOSTS) : false; - bool targetCanBeDead = spellProto ? bool(spellProto->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_DEAD) : false; - - if (targetMustBeDead && isAlive()) - return false; - - if (!targetMustBeDead && !targetCanBeDead && !isAlive()) - return false; - - if (HasFlag(UNIT_FIELD_FLAGS, - UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_OOC_NOT_ATTACKABLE)) - return false; - - if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->isGameMaster()) - return false; - - return !HasUnitState(UNIT_STAT_UNATTACKABLE); -} - int32 Unit::ModifyHealth(int32 dVal) { int32 gain = 0; @@ -13360,7 +13348,7 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f break; case BASE_PCT: case TOTAL_PCT: - m_auraModifiersGroup[unitMod][modifierType] += (apply ? amount : -amount) / 100.0f; + ApplyPercentModFloatVar(m_auraModifiersGroup[unitMod][modifierType], amount, apply); break; default: break; @@ -16192,6 +16180,26 @@ bool Unit::IsInRaidWith(Unit const* unit) const return false; } +bool Unit::IsTargetMatchingCheck(Unit const* target, SpellTargetSelectionCheckTypes check) const +{ + switch (check) + { + case TARGET_SELECT_CHECK_ENEMY: + if (IsControlledByPlayer()) + return !IsFriendlyTo(target); + else + return IsHostileTo(target); + case TARGET_SELECT_CHECK_ALLY: + return IsFriendlyTo(target); + case TARGET_SELECT_CHECK_PARTY: + return IsInPartyWith(target); + case TARGET_SELECT_CHECK_RAID: + return IsInRaidWith(target); + default: + return true; + } +} + void Unit::GetRaidMember(std::list<Unit*> &nearMembers, float radius) { Player* owner = GetCharmerOrOwnerPlayerOrPlayerItself(); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 8b7d3606b44..caf1f4e46ad 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -32,6 +32,7 @@ #include "EventProcessor.h" #include "MotionMaster.h" #include "DBCStructure.h" +#include "SpellInfo.h" #include "Path.h" #include "WorldPacket.h" #include "Timer.h" @@ -395,10 +396,7 @@ enum TriggerCastFlags TRIGGERED_IGNORE_SET_FACING = 0x00000200, //! Will not adjust facing to target (if any) TRIGGERED_IGNORE_SHAPESHIFT = 0x00000400, //! Will ignore shapeshift checks TRIGGERED_IGNORE_CASTER_AURASTATE = 0x00000800, //! Will ignore caster aura states including combat requirements and death state - TRIGGERED_IGNORE_TARGET_AURASTATE = 0x00001000, //! Will ignore target aura states TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE = 0x00002000, //! Will ignore mounted/on vehicle restrictions - TRIGGERED_IGNORE_TARGET_DETECTABILITY = 0x00004000, //! Will ignore canSeeOrDetect - TRIGGERED_IGNORE_LOS = 0x00008000, //! Will ignore LOS to target TRIGGERED_IGNORE_CASTER_AURAS = 0x00010000, //! Will ignore caster aura restrictions or requirements TRIGGERED_DISALLOW_PROC_EVENTS = 0x00020000, //! Disallows proc events from triggered spell (default) TRIGGERED_DONT_REPORT_CAST_ERROR = 0x00040000, //! Will return SPELL_FAILED_DONT_REPORT in CheckCast functions @@ -471,7 +469,7 @@ enum DeathState enum UnitState { - UNIT_STAT_DIED = 0x00000001, + UNIT_STAT_DIED = 0x00000001, // player has fake death aura UNIT_STAT_MELEE_ATTACKING = 0x00000002, // player is melee attacking someone //UNIT_STAT_MELEE_ATTACK_BY = 0x00000004, // player is melee attack by someone UNIT_STAT_STUNNED = 0x00000008, @@ -1394,6 +1392,7 @@ class Unit : public WorldObject bool IsNeutralToAll() const; bool IsInPartyWith(Unit const* unit) const; bool IsInRaidWith(Unit const* unit) const; + bool IsTargetMatchingCheck(Unit const* target, SpellTargetSelectionCheckTypes check) const; void GetPartyMemberInDist(std::list<Unit*> &units, float dist); void GetPartyMembers(std::list<Unit*> &units); void GetRaidMember(std::list<Unit*> &units, float dist); @@ -1547,8 +1546,7 @@ class Unit : public WorldObject bool isFrozen() const; - bool isTargetableForAttack() const; - bool isAttackableByAOE(SpellInfo const* spellProto = NULL) const; + bool isTargetableForAttack(bool checkFakeDeath = true) const; bool canAttack(Unit const* target, bool force = true) const; virtual bool IsInWater() const; virtual bool IsUnderWater() const; diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index 13a88a26b89..9914426215c 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -26,6 +26,7 @@ #include "Transport.h" #include "ObjectAccessor.h" #include "CellImpl.h" +#include "SpellInfo.h" using namespace Trinity; @@ -330,38 +331,41 @@ ObjectUpdater::Visit(GridRefManager<T> &m) } } -bool CannibalizeObjectCheck::operator()(Corpse* u) +bool AnyDeadUnitObjectInRangeCheck::operator()(Player* u) { - // ignore bones - if (u->GetType() == CORPSE_BONES) - return false; - - Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGUID()); - - if (!owner || i_funit->IsFriendlyTo(owner)) - return false; + return !u->isAlive() && !u->HasAuraType(SPELL_AURA_GHOST) && i_searchObj->IsWithinDistInMap(u, i_range); +} - if (i_funit->IsWithinDistInMap(u, i_range)) - return true; +bool AnyDeadUnitObjectInRangeCheck::operator()(Corpse* u) +{ + return u->GetType() != CORPSE_BONES && i_searchObj->IsWithinDistInMap(u, i_range); +} - return false; +bool AnyDeadUnitObjectInRangeCheck::operator()(Creature* u) +{ + return !u->isAlive() && i_searchObj->IsWithinDistInMap(u, i_range); } -bool CarrionFeederObjectCheck::operator()(Corpse* u) +bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Player* u) { - // ignore bones - if (u->GetType() == CORPSE_BONES) - return false; + return AnyDeadUnitObjectInRangeCheck::operator()(u) + && i_spellInfo->CheckTarget(i_searchObj, u, true) + && i_searchObj->IsTargetMatchingCheck(u, i_check); +} +bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Corpse* u) +{ Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGUID()); + return owner && AnyDeadUnitObjectInRangeCheck::operator()(u) + && i_spellInfo->CheckTarget(i_searchObj, owner, true) + && i_searchObj->IsTargetMatchingCheck(owner, i_check); +} - if (!owner || i_funit->IsFriendlyTo(owner)) - return false; - - if (i_funit->IsWithinDistInMap(u, i_range)) - return true; - - return false; +bool AnyDeadUnitSpellTargetInRangeCheck::operator()(Creature* u) +{ + return AnyDeadUnitObjectInRangeCheck::operator()(u) + && i_spellInfo->CheckTarget(i_searchObj, u, true) + && i_searchObj->IsTargetMatchingCheck(u, i_check); } template void ObjectUpdater::Visit<GameObject>(GameObjectMapType &); diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index b4d20f25740..4d4f0bfe05e 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -554,56 +554,31 @@ namespace Trinity float i_range; }; - class CannibalizeObjectCheck + class AnyDeadUnitObjectInRangeCheck { public: - CannibalizeObjectCheck(Unit* funit, float range) : i_funit(funit), i_range(range) {} - bool operator()(Player* u) - { - if (i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight()) - return false; - - return i_funit->IsWithinDistInMap(u, i_range); - } + AnyDeadUnitObjectInRangeCheck(Unit const* searchObj, float range) : i_searchObj(searchObj), i_range(range) {} + bool operator()(Player* u); bool operator()(Corpse* u); - bool operator()(Creature* u) - { - if (i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight() || - (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) == 0) - return false; - - return i_funit->IsWithinDistInMap(u, i_range); - } + bool operator()(Creature* u); template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; } - private: - Unit* const i_funit; + protected: + Unit const* const i_searchObj; float i_range; }; - class CarrionFeederObjectCheck + class AnyDeadUnitSpellTargetInRangeCheck : public AnyDeadUnitObjectInRangeCheck { public: - CarrionFeederObjectCheck(Unit* funit, float range) : i_funit(funit), i_range(range) {} - bool operator()(Player* u) - { - if (i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight()) - return false; - - return i_funit->IsWithinDistInMap(u, i_range); - } + AnyDeadUnitSpellTargetInRangeCheck(Unit const* searchObj, float range, SpellInfo const* spellInfo, SpellTargetSelectionCheckTypes check) + : AnyDeadUnitObjectInRangeCheck(searchObj, range), i_spellInfo(spellInfo), i_check(check) {} + bool operator()(Player* u); bool operator()(Corpse* u); - bool operator()(Creature* u) - { - if (i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight() || - (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL) != 0) - return false; - - return i_funit->IsWithinDistInMap(u, i_range); - } + bool operator()(Creature* u); template<class NOT_INTERESTED> bool operator()(NOT_INTERESTED*) { return false; } - private: - Unit* const i_funit; - float i_range; + protected: + SpellInfo const* i_spellInfo; + SpellTargetSelectionCheckTypes i_check; }; // WorldObject do classes diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index 2fe38b0a953..101f0e4ce4d 100755 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -355,12 +355,19 @@ void InstanceScript::DoStopTimedAchievement(AchievementCriteriaTimedTypes type, // Remove Auras due to Spell on all players in instance void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell) { - Map::PlayerList const &PlayerList = instance->GetPlayers(); - + Map::PlayerList const& PlayerList = instance->GetPlayers(); if (!PlayerList.isEmpty()) - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (Player* pPlayer = i->getSource()) - pPlayer->RemoveAurasDueToSpell(spell); + { + for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) + { + if (Player* player = itr->getSource()) + { + player->RemoveAurasDueToSpell(spell); + if (Pet* pet = player->GetPet()) + pet->RemoveAurasDueToSpell(spell); + } + } + } } // Cast spell on all players in instance diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index aaceb1d7645..001f22815b5 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2541,8 +2541,8 @@ void InstanceMap::SetResetSchedule(bool on) if (InstanceSave *save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId())) sInstanceSaveMgr->ScheduleReset(on, save->GetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), Difficulty(GetSpawnMode()), GetInstanceId())); else - sLog->outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, there is no save information for instance (map [id: %u, name: %s], instance id: %u)", - on ? "on" : "off", GetId(), GetMapName(), GetInstanceId()); + sLog->outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, there is no save information for instance (map [id: %u, name: %s], instance id: %u, difficulty: %u)", + on ? "on" : "off", GetId(), GetMapName(), GetInstanceId(), Difficulty(GetSpawnMode())); } } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 6ff4bf05d42..f430002fca6 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -416,6 +416,7 @@ class Map : public GridRefManager<NGridType> template<class T> void SwitchGridContainers(T* obj, bool active); template<class NOTIFIER> void VisitAll(const float &x, const float &y, float radius, NOTIFIER ¬ifier); + template<class NOTIFIER> void VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER ¬ifier); template<class NOTIFIER> void VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier); template<class NOTIFIER> void VisitGrid(const float &x, const float &y, float radius, NOTIFIER ¬ifier); CreatureGroupHolderType CreatureGroupHolder; @@ -650,6 +651,25 @@ Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER ¬ifier) cell.Visit(p, grid_object_notifier, *this, radius, x, y); } +// should be used with Searcher notifiers, tries to search world if nothing found in grid +template<class NOTIFIER> +inline void +Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER ¬ifier) +{ + CellPair p(Trinity::ComputeCellPair(x, y)); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier); + cell.Visit(p, world_object_notifier, *this, radius, x, y); + if (!notifier.i_object) + { + TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier); + cell.Visit(p, grid_object_notifier, *this, radius, x, y); + } +} + template<class NOTIFIER> inline void Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier) diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 752776fcf06..b9c9c39028d 100755 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -337,7 +337,7 @@ enum SpellAttr2 { SPELL_ATTR2_CAN_TARGET_DEAD = 0x00000001, // 0 can target dead unit or corpse SPELL_ATTR2_UNK1 = 0x00000002, // 1 ? many triggered spells have this flag - SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS = 0x00000004, // 2 26368 4.0.1 dbc change (NYI) + SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS = 0x00000004, // 2 26368 4.0.1 dbc change SPELL_ATTR2_UNK3 = 0x00000008, // 3 SPELL_ATTR2_DISPLAY_IN_STANCE_BAR = 0x00000010, // 4 client displays icon in stance bar when learned, even if not shapeshift SPELL_ATTR2_AUTOREPEAT_FLAG = 0x00000020, // 5 @@ -383,7 +383,7 @@ enum SpellAttr3 SPELL_ATTR3_TRIGGERED_CAN_TRIGGER_PROC_2 = 0x00000200, // 9 triggered from effect? SPELL_ATTR3_MAIN_HAND = 0x00000400, // 10 Main hand weapon required SPELL_ATTR3_BATTLEGROUND = 0x00000800, // 11 Can casted only on battleground - SPELL_ATTR3_ONLY_TARGET_GHOSTS = 0x00001000, // 12 + SPELL_ATTR3_ONLY_TARGET_GHOSTS = 0x00001000, // 12 SPELL_ATTR3_UNK13 = 0x00002000, // 13 SPELL_ATTR3_UNK14 = 0x00004000, // 14 "Honorless Target" only this spells have this flag SPELL_ATTR3_UNK15 = 0x00008000, // 15 Auto Shoot, Shoot, Throw, - this is autoshot flag @@ -482,7 +482,7 @@ enum SpellAttr6 SPELL_ATTR6_DONT_DISPLAY_COOLDOWN = 0x00000001, // 0 client doesn't display cooldown in tooltip for these spells SPELL_ATTR6_ONLY_IN_ARENA = 0x00000002, // 1 only usable in arena SPELL_ATTR6_IGNORE_CASTER_AURAS = 0x00000004, // 2 - SPELL_ATTR6_CAN_TARGET_INVISIBLE = 0x00000008, // 3 (NYI) ignore visibility requirement for spell target (phases, invisibility, etc.) + SPELL_ATTR6_UNK3 = 0x00000008, // 3 SPELL_ATTR6_UNK4 = 0x00000010, // 4 SPELL_ATTR6_UNK5 = 0x00000020, // 5 SPELL_ATTR6_UNK6 = 0x00000040, // 6 @@ -492,18 +492,18 @@ enum SpellAttr6 SPELL_ATTR6_CAN_TARGET_POSSESSED_FRIENDS = 0x00000400, // 10 NYI! SPELL_ATTR6_NOT_IN_RAID_INSTANCE = 0x00000800, // 11 not usable in raid instance SPELL_ATTR6_CASTABLE_WHILE_ON_VEHICLE = 0x00001000, // 12 castable while caster is on vehicle - SPELL_ATTR6_UNK13 = 0x00002000, // 13 + SPELL_ATTR6_CAN_TARGET_INVISIBLE = 0x00002000, // 13 ignore visibility requirement for spell target (phases, invisibility, etc.) SPELL_ATTR6_UNK14 = 0x00004000, // 14 SPELL_ATTR6_UNK15 = 0x00008000, // 15 not set in 3.0.3 SPELL_ATTR6_UNK16 = 0x00010000, // 16 SPELL_ATTR6_UNK17 = 0x00020000, // 17 - SPELL_ATTR6_ONLY_CAST_WHILE_POSSESSED = 0x00040000, // 18 (NYI) client won't allow to cast these spells when unit does not have possessor + SPELL_ATTR6_CAST_BY_CHARMER = 0x00040000, // 18 client won't allow to cast these spells when unit is not possessed && charmer of caster will be original caster SPELL_ATTR6_UNK19 = 0x00080000, // 19 SPELL_ATTR6_UNK20 = 0x00100000, // 20 SPELL_ATTR6_CLIENT_UI_TARGET_EFFECTS = 0x00200000, // 21 it's only client-side attribute SPELL_ATTR6_UNK22 = 0x00400000, // 22 SPELL_ATTR6_UNK23 = 0x00800000, // 23 - SPELL_ATTR6_CAN_TARGET_UNTARGETABLE = 0x01000000, // 24 NYI! + SPELL_ATTR6_CAN_TARGET_UNTARGETABLE = 0x01000000, // 24 SPELL_ATTR6_UNK25 = 0x02000000, // 25 SPELL_ATTR6_UNK26 = 0x04000000, // 26 SPELL_ATTR6_UNK27 = 0x08000000, // 27 @@ -1474,13 +1474,13 @@ enum GameobjectTypes enum GameObjectFlags { - GO_FLAG_IN_USE = 0x00000001, //disables interaction while animated - GO_FLAG_LOCKED = 0x00000002, //require key, spell, event, etc to be opened. Makes "Locked" appear in tooltip - GO_FLAG_INTERACT_COND = 0x00000004, //cannot interact (condition to interact) - GO_FLAG_TRANSPORT = 0x00000008, //any kind of transport? Object can transport (elevator, boat, car) - GO_FLAG_UNK1 = 0x00000010, // - GO_FLAG_NODESPAWN = 0x00000020, //never despawn, typically for doors, they just change state - GO_FLAG_TRIGGERED = 0x00000040, //typically, summoned objects. Triggered by spell or other events + GO_FLAG_IN_USE = 0x00000001, // disables interaction while animated + GO_FLAG_LOCKED = 0x00000002, // require key, spell, event, etc to be opened. Makes "Locked" appear in tooltip + GO_FLAG_INTERACT_COND = 0x00000004, // cannot interact (condition to interact) + GO_FLAG_TRANSPORT = 0x00000008, // any kind of transport? Object can transport (elevator, boat, car) + GO_FLAG_NOT_SELECTABLE = 0x00000010, // not selectable even in GM mode + GO_FLAG_NODESPAWN = 0x00000020, // never despawn, typically for doors, they just change state + GO_FLAG_TRIGGERED = 0x00000040, // typically, summoned objects. Triggered by spell or other events GO_FLAG_DAMAGED = 0x00000200, GO_FLAG_DESTROYED = 0x00000400, }; diff --git a/src/server/game/Server/Protocol/Handlers/BattleGroundHandler.cpp b/src/server/game/Server/Protocol/Handlers/BattleGroundHandler.cpp index 63012a11707..5bccf511da3 100755 --- a/src/server/game/Server/Protocol/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/BattleGroundHandler.cpp @@ -370,7 +370,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data) if (!sBattlemasterListStore.LookupEntry(bgTypeId_)) { - sLog->outError("BattlegroundHandler: invalid bgtype (%u) received.", bgTypeId_); + sLog->outError("BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId_, _player->GetName(), _player->GetGUIDLow()); return; } if (!_player->InBattlegroundQueue()) diff --git a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp index 09897dcde19..3d8bb9e15c4 100755 --- a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp @@ -1502,7 +1502,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data) Map *map = _player->GetMap(); if (map && map->IsDungeon()) { - sLog->outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); + sLog->outError("WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!", _player->GetName(), _player->GetGUIDLow()); return; } @@ -1523,7 +1523,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data) map = pGroupGuy->GetMap(); if (map && map->IsNonRaidDungeon()) { - sLog->outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); + sLog->outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!", _player->GetGUIDLow(), pGroupGuy->GetName(), pGroupGuy->GetGUIDLow()); return; } } diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index d6a3ef5ff50..a5b6fa64795 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -4518,7 +4518,7 @@ void AuraEffect::HandleModDamagePercentDone(AuraApplication const* aurApp, uint8 target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float (GetAmount()), apply); if (target->GetTypeId() == TYPEID_PLAYER) - target->ToPlayer()->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, GetAmount() / 100.0f, apply); + target->ToPlayer()->ApplyPercentModFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, GetAmount(), apply); } else { @@ -4924,6 +4924,18 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool caster->CastSpell(target, GetAmount(), true); } break; + case SPELLFAMILY_PRIEST: + // Vampiric Touch + if (m_spellInfo->SpellFamilyFlags[1] & 0x0400 && aurApp->GetRemoveMode() == AURA_REMOVE_BY_ENEMY_SPELL && GetEffIndex() == 0) + { + if (AuraEffect const* aurEff = GetBase()->GetEffect(1)) + { + int32 damage = aurEff->GetAmount() * 8; + // backfire damage + target->CastCustomSpell(target, 64085, &damage, NULL, NULL, true, NULL, NULL, GetCasterGUID()); + } + } + break; case SPELLFAMILY_WARLOCK: // Haunt if (m_spellInfo->SpellFamilyFlags[1] & 0x40000) @@ -4952,18 +4964,6 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool } } break; - case SPELLFAMILY_PRIEST: - // Vampiric Touch - if (m_spellInfo->SpellFamilyFlags[1] & 0x0400 && aurApp->GetRemoveMode() == AURA_REMOVE_BY_ENEMY_SPELL && GetEffIndex() == 0) - { - if (AuraEffect const* aurEff = GetBase()->GetEffect(1)) - { - int32 damage = aurEff->GetAmount() * 8; - // backfire damage - target->CastCustomSpell(target, 64085, &damage, NULL, NULL, true, NULL, NULL, GetCasterGUID()); - } - } - break; case SPELLFAMILY_HUNTER: // Misdirection if (GetId() == 34477) @@ -5609,20 +5609,17 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const { case 54798: // FLAMING Arrow Triggered Effect { - if (!caster || !target || !target->ToCreature() || !caster->IsVehicle() || target->HasAura(54683)) + if (!caster || !target || !target->ToCreature() || !caster->GetVehicle() || target->HasAura(54683)) break; - if (Unit* rider = caster->GetVehicleKit()->GetPassenger(0)) - { - target->CastSpell(target, 54683, true); - - // Credit Frostworgs - if (target->GetEntry() == 29358) - rider->CastSpell(rider, 54896, true); - // Credit Frost Giants - else if (target->GetEntry() == 29351) - rider->CastSpell(rider, 54893, true); - } + target->CastSpell(target, 54683, true); + + // Credit Frostworgs + if (target->GetEntry() == 29358) + caster->CastSpell(caster, 54896, true); + // Credit Frost Giants + else if (target->GetEntry() == 29351) + caster->CastSpell(caster, 54893, true); break; } case 62292: // Blaze (Pool of Tar) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4b3f0ed73df..8da042f241d 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -451,7 +451,8 @@ SpellValue::SpellValue(SpellInfo const* proto) Spell::Spell(Unit* caster, SpellInfo const *info, TriggerCastFlags triggerFlags, uint64 originalCasterGUID, bool skipCheck) : m_spellInfo(sSpellMgr->GetSpellForDifficultyFromSpell(info, caster)), -m_caster(caster), m_spellValue(new SpellValue(m_spellInfo)) +m_caster((info->AttributesEx6 & SPELL_ATTR6_CAST_BY_CHARMER && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster) +, m_spellValue(new SpellValue(m_spellInfo)) { m_customError = SPELL_CUSTOM_ERROR_NONE; m_skipCheck = skipCheck; @@ -506,7 +507,8 @@ m_caster(caster), m_spellValue(new SpellValue(m_spellInfo)) else { m_originalCaster = ObjectAccessor::GetUnit(*m_caster, m_originalCasterGUID); - if (m_originalCaster && !m_originalCaster->IsInWorld()) m_originalCaster = NULL; + if (m_originalCaster && !m_originalCaster->IsInWorld()) + m_originalCaster = NULL; } m_spellState = SPELL_STATE_NULL; @@ -627,7 +629,7 @@ void Spell::SelectSpellTargets() if (effectTargetType != SPELL_REQUIRE_UNIT) { if (effectTargetType == SPELL_REQUIRE_CASTER) - AddUnitTarget(m_caster, i); + AddUnitTarget(m_caster, i, false); else if (effectTargetType == SPELL_REQUIRE_ITEM) if (m_targets.GetItemTarget()) AddItemTarget(m_targets.GetItemTarget(), i); @@ -638,7 +640,7 @@ void Spell::SelectSpellTargets() { if (!m_spellInfo->GetMaxRange(true)) { - AddUnitTarget(m_caster, i); + AddUnitTarget(m_caster, i, false); continue; } @@ -648,51 +650,10 @@ void Spell::SelectSpellTargets() { case SPELL_EFFECT_DUMMY: { - switch(m_spellInfo->Id) - { - case 20577: // Cannibalize - case 54044: // Carrion Feeder - { - WorldObject* result = NULL; - if (m_spellInfo->Id == 20577) - result = FindCorpseUsing<Trinity::CannibalizeObjectCheck>(); - else - result = FindCorpseUsing<Trinity::CarrionFeederObjectCheck>(); - - if (result) - { - switch(result->GetTypeId()) - { - case TYPEID_UNIT: - case TYPEID_PLAYER: - AddUnitTarget((Unit*)result, i); - break; - case TYPEID_CORPSE: - m_targets.SetCorpseTarget((Corpse*)result); - if (Player* owner = ObjectAccessor::FindPlayer(((Corpse*)result)->GetOwnerGUID())) - AddUnitTarget(owner, i); - break; - default: - break; - } - } - else - { - // clear cooldown at fail - if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true); - SendCastResult(SPELL_FAILED_NO_EDIBLE_CORPSES); - finish(false); - } - break; - } - default: - if (m_targets.GetUnitTarget()) - AddUnitTarget(m_targets.GetUnitTarget(), i); - else - AddUnitTarget(m_caster, i); - break; - } + if (m_targets.GetUnitTarget()) + AddUnitTarget(m_targets.GetUnitTarget(), i, false); + else + AddUnitTarget(m_caster, i, false); break; } case SPELL_EFFECT_BIND: @@ -707,10 +668,10 @@ void Spell::SelectSpellTargets() case SPELL_EFFECT_LEARN_SPELL: case SPELL_EFFECT_SEND_TAXI: if (m_targets.GetUnitTarget()) - AddUnitTarget(m_targets.GetUnitTarget(), i); + AddUnitTarget(m_targets.GetUnitTarget(), i, false); // Triggered spells have additional spell targets - cast them even if no explicit unit target is given (required for spell 50516 for example) else if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_TRIGGER_SPELL) - AddUnitTarget(m_caster, i); + AddUnitTarget(m_caster, i, false); break; case SPELL_EFFECT_SUMMON_RAF_FRIEND: case SPELL_EFFECT_SUMMON_PLAYER: @@ -718,12 +679,12 @@ void Spell::SelectSpellTargets() { Player* target = ObjectAccessor::FindPlayer(m_caster->ToPlayer()->GetSelection()); if (target) - AddUnitTarget(target, i); + AddUnitTarget(target, i, false); } break; case SPELL_EFFECT_RESURRECT_NEW: if (m_targets.GetUnitTarget()) - AddUnitTarget(m_targets.GetUnitTarget(), i); + AddUnitTarget(m_targets.GetUnitTarget(), i, false); if (m_targets.GetCorpseTargetGUID()) { Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster, m_targets.GetCorpseTargetGUID()); @@ -731,7 +692,7 @@ void Spell::SelectSpellTargets() { Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); if (owner) - AddUnitTarget(owner, i); + AddUnitTarget(owner, i, false); } } break; @@ -742,7 +703,7 @@ void Spell::SelectSpellTargets() case SPELL_EFFECT_FEED_PET: case SPELL_EFFECT_DESTROY_ALL_TOTEMS: case SPELL_EFFECT_KILL_CREDIT2: // only one spell: 42793 - AddUnitTarget(m_caster, i); + AddUnitTarget(m_caster, i, false); break; case SPELL_EFFECT_LEARN_PET_SPELL: if (Guardian* pet = m_caster->GetGuardianPet()) @@ -753,17 +714,17 @@ void Spell::SelectSpellTargets() { case SPELL_AURA_ADD_FLAT_MODIFIER: // some spell mods auras have 0 target modes instead expected TARGET_UNIT_CASTER(1) (and present for other ranks for same spell for example) case SPELL_AURA_ADD_PCT_MODIFIER: - AddUnitTarget(m_caster, i); + AddUnitTarget(m_caster, i, false); break; default: // apply to target in other case if (m_targets.GetUnitTarget()) - AddUnitTarget(m_targets.GetUnitTarget(), i); + AddUnitTarget(m_targets.GetUnitTarget(), i, false); break; } break; case SPELL_EFFECT_SKIN_PLAYER_CORPSE: if (m_targets.GetUnitTarget()) - AddUnitTarget(m_targets.GetUnitTarget(), i); + AddUnitTarget(m_targets.GetUnitTarget(), i, false); else if (m_targets.GetCorpseTargetGUID()) { Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster, m_targets.GetCorpseTargetGUID()); @@ -771,12 +732,12 @@ void Spell::SelectSpellTargets() { Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); if (owner) - AddUnitTarget(owner, i); + AddUnitTarget(owner, i, false); } } break; default: - AddUnitTarget(m_caster, i); + AddUnitTarget(m_caster, i, false); break; } } @@ -922,12 +883,15 @@ void Spell::CleanupTargetList() m_delayMoment = 0; } -void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) +void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex, bool checkIfValid /*=true*/) { if (!m_spellInfo->Effects[effIndex].IsEffect()) return; - if (!CheckTarget(pVictim, effIndex)) + if (checkIfValid) + if (m_spellInfo->CheckTarget(m_caster, pVictim, true) != SPELL_CAST_OK) + return; + if (!CheckEffectTarget(pVictim, effIndex)) return; // Check for effect immune skip if immuned @@ -1018,12 +982,6 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) m_UniqueTargetInfo.push_back(target); } -void Spell::AddUnitTarget(uint64 unitGUID, uint32 effIndex) -{ - if (Unit* unit = m_caster->GetGUID() == unitGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGUID)) - AddUnitTarget(unit, effIndex); -} - void Spell::AddGOTarget(GameObject* go, uint32 effIndex) { if (!m_spellInfo->Effects[effIndex].IsEffect()) @@ -1229,7 +1187,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) break; } } - switch(m_spellInfo->DmgClass) + switch (m_spellInfo->DmgClass) { case SPELL_DAMAGE_CLASS_MAGIC: if (positive) @@ -1279,6 +1237,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) int32 gain = caster->HealBySpell(unitTarget, m_spellInfo, addhealth, crit); unitTarget->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, m_spellInfo); + m_healing = gain; } // Do damage and triggers else if (m_damage > 0) @@ -1310,9 +1269,10 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) // Haunt if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->SpellFamilyFlags[1] & 0x40000 && m_spellAura && m_spellAura->GetEffect(1)) { - AuraEffect * aurEff = m_spellAura->GetEffect(1); + AuraEffect* aurEff = m_spellAura->GetEffect(1); aurEff->SetAmount(CalculatePctU(aurEff->GetAmount(), damageInfo.damage)); } + m_damage = damageInfo.damage; } // Passive spell hits/misses or active spells only misses (only triggers) else @@ -1357,18 +1317,15 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) p->CastedCreatureOrGO(spellHitTarget->GetEntry(), spellHitTarget->GetGUID(), m_spellInfo->Id); } - if (m_caster && m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsAIEnabled) + if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsAIEnabled) m_caster->ToCreature()->AI()->SpellHitTarget(spellHitTarget, m_spellInfo); // Needs to be called after dealing damage/healing to not remove breaking on damage auras DoTriggersOnSpellHit(spellHitTarget, mask); // if target is fallged for pvp also flag caster if a player - if (unit->IsPvP()) - { - if (m_caster->GetTypeId() == TYPEID_PLAYER) + if (unit->IsPvP() && m_caster->GetTypeId() == TYPEID_PLAYER) m_caster->ToPlayer()->UpdatePvP(true); - } CallScriptAfterHitHandlers(); } @@ -1449,7 +1406,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool uint8 aura_effmask = 0; for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (effectMask & (1 << i ) && m_spellInfo->Effects[i].IsUnitOwnedAuraEffect()) + if (effectMask & (1 << i) && m_spellInfo->Effects[i].IsUnitOwnedAuraEffect()) aura_effmask |= 1 << i; if (aura_effmask) @@ -1847,15 +1804,9 @@ void Spell::SearchAreaTarget(std::list<Unit*> &TagUnitMap, float radius, SpellNo Trinity::SpellNotifierCreatureAndPlayer notifier(m_caster, TagUnitMap, radius, type, TargetType, pos, entry, m_spellInfo); if ((m_spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS) || (TargetType == SPELL_TARGETS_ENTRY && !entry)) - { m_caster->GetMap()->VisitWorld(pos->m_positionX, pos->m_positionY, radius, notifier); - TagUnitMap.remove_if(Trinity::ObjectTypeIdCheck(TYPEID_PLAYER, false)); // above line will select also pets and totems, remove them - } else m_caster->GetMap()->VisitAll(pos->m_positionX, pos->m_positionY, radius, notifier); - - if (m_spellInfo->AttributesCu & SPELL_ATTR0_CU_EXCLUDE_SELF) - TagUnitMap.remove(m_caster); } void Spell::SearchGOAreaTarget(std::list<GameObject*> &TagGOMap, float radius, SpellNotifyPushType type, SpellTargets TargetType, uint32 entry) @@ -1996,7 +1947,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur) switch(cur.GetTarget()) { case TARGET_UNIT_CASTER: - AddUnitTarget(m_caster, i); + AddUnitTarget(m_caster, i, false); break; case TARGET_DEST_CASTER_FISHING: { @@ -2075,17 +2026,17 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur) pushType = PUSH_CHAIN; break; case TARGET_UNIT_TARGET_ALLY: - AddUnitTarget(target, i); + AddUnitTarget(target, i, false); break; case TARGET_UNIT_TARGET_RAID: case TARGET_UNIT_TARGET_PARTY: case TARGET_UNIT_TARGET_MINIPET: if (IsValidSingleTargetSpell(target)) - AddUnitTarget(target, i); + AddUnitTarget(target, i, false); break; case TARGET_UNIT_TARGET_PASSENGER: if (target->IsOnVehicle(m_caster)) - AddUnitTarget(target, i); + AddUnitTarget(target, i, false); break; case TARGET_UNIT_LASTTARGET_AREA_PARTY: case TARGET_UNIT_TARGET_AREA_RAID_CLASS: @@ -2439,10 +2390,10 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur) CallScriptAfterUnitTargetSelectHandlers(unitList, SpellEffIndex(i)); for (std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr) - AddUnitTarget(*itr, i); + AddUnitTarget(*itr, i, false); } else - AddUnitTarget(target, i); + AddUnitTarget(target, i, false); } else if (pushType) { @@ -2799,7 +2750,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur) CallScriptAfterUnitTargetSelectHandlers(unitList, SpellEffIndex(i)); for (std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr) - AddUnitTarget(*itr, i); + AddUnitTarget(*itr, i, false); } if (!gobjectList.empty()) @@ -4601,7 +4552,7 @@ void Spell::HandleEffects(Unit *pUnitTarget, Item *pItemTarget, GameObject *pGOT SpellCastResult Spell::CheckCast(bool strict) { // check death state - if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURASTATE) && !m_caster->isAlive() && !(m_spellInfo->Attributes & SPELL_ATTR0_PASSIVE) && !(m_spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD)) + if (!m_caster->isAlive() && !(m_spellInfo->Attributes & SPELL_ATTR0_PASSIVE) && !(m_spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD)) return SPELL_FAILED_CASTER_DEAD; // check cooldowns to prevent cheating @@ -4750,69 +4701,27 @@ SpellCastResult Spell::CheckCast(bool strict) if (target) { - // target state requirements (not allowed state), apply to self also - if (!(_triggeredCastFlags & TRIGGERED_IGNORE_TARGET_AURASTATE) && m_spellInfo->TargetAuraStateNot && target->HasAuraState(AuraStateType(m_spellInfo->TargetAuraStateNot), m_spellInfo, m_caster)) - return SPELL_FAILED_TARGET_AURASTATE; - - if (m_spellInfo->TargetAuraSpell && !target->HasAura(sSpellMgr->GetSpellIdForDifficulty(m_spellInfo->TargetAuraSpell, m_caster))) - return SPELL_FAILED_TARGET_AURASTATE; - - if (m_spellInfo->ExcludeTargetAuraSpell && target->HasAura(sSpellMgr->GetSpellIdForDifficulty(m_spellInfo->ExcludeTargetAuraSpell, m_caster))) - return SPELL_FAILED_TARGET_AURASTATE; - - if (!IsTriggered() && target == m_caster && m_spellInfo->AttributesEx & SPELL_ATTR1_CANT_TARGET_SELF) - return SPELL_FAILED_BAD_TARGETS; - - bool non_caster_target = target != m_caster && m_spellInfo->IsRequiringSelectedTarget(); - - if (non_caster_target) + if (target != m_caster && m_spellInfo->IsRequiringSelectedTarget()) { - // target state requirements (apply to non-self only), to allow cast affects to self like Dirty Deeds - if (!(_triggeredCastFlags & TRIGGERED_IGNORE_TARGET_AURASTATE) && m_spellInfo->TargetAuraState && !target->HasAuraState(AuraStateType(m_spellInfo->TargetAuraState), m_spellInfo, m_caster)) - return SPELL_FAILED_TARGET_AURASTATE; - - // Not allow casting on flying player or on vehicle player (if caster isnt vehicle) - if (target->HasUnitState(UNIT_STAT_IN_FLIGHT) /*|| (target->HasUnitState(UNIT_STAT_ONVEHICLE) && target->GetVehicleBase() != m_caster)*/) - return SPELL_FAILED_BAD_TARGETS; - - if (!(_triggeredCastFlags & TRIGGERED_IGNORE_TARGET_DETECTABILITY) && !m_caster->canSeeOrDetect(target)) - return SPELL_FAILED_BAD_TARGETS; - - if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - // Do not allow these spells to target creatures not tapped by us (Banish, Polymorph, many quest spells) - if (m_spellInfo->AttributesEx2 & SPELL_ATTR2_CANT_TARGET_TAPPED) - if (Creature *targetCreature = target->ToCreature()) - if (targetCreature->hasLootRecipient() && !targetCreature->isTappedBy(m_caster->ToPlayer())) - return SPELL_FAILED_CANT_CAST_ON_TAPPED; + SpellCastResult castResult = m_spellInfo->CheckTarget(m_caster, target, false); + if (castResult != SPELL_CAST_OK) + return castResult; + } - if (m_spellInfo->AttributesCu & SPELL_ATTR0_CU_PICKPOCKET) - { - if (target->GetTypeId() == TYPEID_PLAYER) - return SPELL_FAILED_BAD_TARGETS; - else if ((target->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) == 0) - return SPELL_FAILED_TARGET_NO_POCKETS; - } + if (target != m_caster) + { + // Must be behind the target + if ((m_spellInfo->AttributesCu & SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET) && target->HasInArc(static_cast<float>(M_PI), m_caster)) + return SPELL_FAILED_NOT_BEHIND; - // Not allow disarm unarmed player - if (m_spellInfo->Mechanic == MECHANIC_DISARM) - { - if (target->GetTypeId() == TYPEID_PLAYER) - { - Player* player = target->ToPlayer(); - if (!player->GetWeaponForAttack(BASE_ATTACK) || !player->IsUseEquipedWeapon(true)) - return SPELL_FAILED_TARGET_NO_WEAPONS; - } - else if (!target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)) - return SPELL_FAILED_TARGET_NO_WEAPONS; - } - } + // Target must be facing you + if ((m_spellInfo->AttributesCu & SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER) && !target->HasInArc(static_cast<float>(M_PI), m_caster)) + return SPELL_FAILED_NOT_INFRONT; - if (!(_triggeredCastFlags & TRIGGERED_IGNORE_LOS) && VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOSInMap(target)) + if (!(m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOSInMap(target)) return SPELL_FAILED_LINE_OF_SIGHT; - } - else if (m_caster == target) + else { if (m_caster->GetTypeId() == TYPEID_PLAYER) // Target - is player caster { @@ -4835,7 +4744,7 @@ SpellCastResult Spell::CheckCast(bool strict) } } - // check pet presents + // check pet presence for (int j = 0; j < MAX_SPELL_EFFECTS; ++j) { if (m_spellInfo->Effects[j].TargetA.GetTarget() == TARGET_UNIT_PET) @@ -4851,36 +4760,6 @@ SpellCastResult Spell::CheckCast(bool strict) break; } } - - // check creature type - // ignore self casts (including area casts when caster selected as target) - if (non_caster_target) - { - if (!CheckTargetCreatureType(target)) - { - if (target->GetTypeId() == TYPEID_PLAYER) - return SPELL_FAILED_TARGET_IS_PLAYER; - else - return SPELL_FAILED_BAD_TARGETS; - } - - // Must be behind the target - if ((m_spellInfo->AttributesCu & SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET) && target->HasInArc(static_cast<float>(M_PI), m_caster)) - return SPELL_FAILED_NOT_BEHIND; - - // Target must be facing you - if ((m_spellInfo->AttributesCu & SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER) && !target->HasInArc(static_cast<float>(M_PI), m_caster)) - return SPELL_FAILED_NOT_INFRONT; - - // Target must not be in combat - if (m_spellInfo->AttributesEx & SPELL_ATTR1_CANT_TARGET_IN_COMBAT && target->isInCombat()) - return SPELL_FAILED_TARGET_AFFECTING_COMBAT; - } - - if (target) - if (m_spellInfo->IsPositive()) - if (target->IsImmunedToSpell(m_spellInfo)) - return SPELL_FAILED_TARGET_AURASTATE; } // Spell casted only on battleground @@ -5551,46 +5430,41 @@ SpellCastResult Spell::CheckCast(bool strict) SpellCastResult Spell::CheckPetCast(Unit* target) { - if (!m_caster->isAlive() && !(m_spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD)) - return SPELL_FAILED_CASTER_DEAD; - if (m_caster->HasUnitState(UNIT_STAT_CASTING) && !(_triggeredCastFlags & TRIGGERED_IGNORE_CAST_IN_PROGRESS)) //prevent spellcast interruption by another spellcast return SPELL_FAILED_SPELL_IN_PROGRESS; - if (m_caster->isInCombat() && !m_spellInfo->CanBeUsedInCombat()) - return SPELL_FAILED_AFFECTING_COMBAT; - //dead owner (pets still alive when owners ressed?) - if (Unit *owner = m_caster->GetCharmerOrOwner()) - if (!owner->isAlive()) - return SPELL_FAILED_CASTER_DEAD; + // dead owner (pets still alive when owners ressed?) + if (Unit *owner = m_caster->GetCharmerOrOwner()) + if (!owner->isAlive()) + return SPELL_FAILED_CASTER_DEAD; - if (!target && m_targets.GetUnitTarget()) - target = m_targets.GetUnitTarget(); + if (!target && m_targets.GetUnitTarget()) + target = m_targets.GetUnitTarget(); - for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + if (m_spellInfo->Effects[i].TargetA.GetType() == TARGET_TYPE_UNIT_TARGET + || m_spellInfo->Effects[i].TargetA.GetType() == TARGET_TYPE_DEST_TARGET) { - if (m_spellInfo->Effects[i].TargetA.GetType() == TARGET_TYPE_UNIT_TARGET - || m_spellInfo->Effects[i].TargetA.GetType() == TARGET_TYPE_DEST_TARGET) - { - if (!target) - return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - m_targets.SetUnitTarget(target); - break; - } + if (!target) + return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + m_targets.SetUnitTarget(target); + break; } + } - Unit* _target = m_targets.GetUnitTarget(); + Unit* _target = m_targets.GetUnitTarget(); - if (_target) //for target dead/target not valid - { - if (!_target->isAlive()) - return SPELL_FAILED_BAD_TARGETS; + // for target dead/target not valid + if (_target) + { + if (!IsValidSingleTargetSpell(_target)) + return SPELL_FAILED_BAD_TARGETS; + } - if (!IsValidSingleTargetSpell(_target)) - return SPELL_FAILED_BAD_TARGETS; - } - //cooldown - if (m_caster->ToCreature()->HasSpellCooldown(m_spellInfo->Id)) + // cooldown + if (Creature const* creatureCaster = m_caster->ToCreature()) + if (creatureCaster->HasSpellCooldown(m_spellInfo->Id)) return SPELL_FAILED_NOT_READY; return CheckCast(true); @@ -6466,37 +6340,6 @@ void Spell::UpdatePointers() m_targets.Update(m_caster); } -bool Spell::CheckTargetCreatureType(Unit* target) const -{ - uint32 spellCreatureTargetMask = m_spellInfo->TargetCreatureType; - - // Curse of Doom & Exorcism: not find another way to fix spell target check :/ - if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->Category == 1179) - { - // not allow cast at player - if (target->GetTypeId() == TYPEID_PLAYER) - return false; - - spellCreatureTargetMask = 0x7FF; - } - - // Dismiss Pet and Taming Lesson skipped - if (m_spellInfo->Id == 2641 || m_spellInfo->Id == 23356) - spellCreatureTargetMask = 0; - - // Polymorph and Grounding Totem - if (target->GetEntry() == 5925 && m_spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (m_spellInfo->SpellFamilyFlags[0] & 0x1000000) && m_spellInfo->Effects[0].ApplyAuraName == SPELL_AURA_MOD_CONFUSE) - return true; - - if (spellCreatureTargetMask) - { - uint32 TargetCreatureType = target->GetCreatureTypeMask(); - - return !TargetCreatureType || (spellCreatureTargetMask & TargetCreatureType); - } - return true; -} - CurrentSpellTypes Spell::GetCurrentContainer() { if (IsNextMeleeSwingSpell()) @@ -6509,52 +6352,10 @@ CurrentSpellTypes Spell::GetCurrentContainer() return(CURRENT_GENERIC_SPELL); } -bool Spell::CheckTarget(Unit* target, uint32 eff) +bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const { - // Check targets for creature type mask and remove not appropriate (skip explicit self target case, maybe need other explicit targets) - if (m_spellInfo->Effects[eff].TargetA.GetTarget() != TARGET_UNIT_CASTER) - { - if (!CheckTargetCreatureType(target)) - return false; - } - - // Check Aura spell req (need for AoE spells) - if (m_spellInfo->TargetAuraSpell && !target->HasAura(sSpellMgr->GetSpellIdForDifficulty(m_spellInfo->TargetAuraSpell, m_caster))) - return false; - if (m_spellInfo->ExcludeTargetAuraSpell && target->HasAura(sSpellMgr->GetSpellIdForDifficulty(m_spellInfo->ExcludeTargetAuraSpell, m_caster))) - return false; - - // Check targets for not_selectable unit flag and remove - // A player can cast spells on his pet (or other controlled unit) though in any state - if (target != m_caster && target->GetCharmerOrOwnerGUID() != m_caster->GetGUID()) - { - // any unattackable target skipped - if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return false; - - // unselectable targets skipped in all cases except TARGET_UNIT_NEARBY_ENTRY targeting - // in case TARGET_UNIT_NEARBY_ENTRY target selected by server always and can't be cheated - /*if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) && - m_spellInfo->EffectImplicitTargetA[eff] != TARGET_UNIT_NEARBY_ENTRY && - m_spellInfo->EffectImplicitTargetB[eff] != TARGET_UNIT_NEARBY_ENTRY) - return false;*/ - } - - //Check player targets and remove if in GM mode or GM invisibility (for not self casting case) - if (target != m_caster && target->GetTypeId() == TYPEID_PLAYER) - { - if (!target->ToPlayer()->IsVisible()) - return false; - - if (target->ToPlayer()->isGameMaster() && !m_spellInfo->IsPositive()) - return false; - } - switch(m_spellInfo->Effects[eff].ApplyAuraName) { - case SPELL_AURA_NONE: - default: - break; case SPELL_AURA_MOD_POSSESS: case SPELL_AURA_MOD_CHARM: case SPELL_AURA_MOD_POSSESS_PET: @@ -6565,26 +6366,21 @@ bool Spell::CheckTarget(Unit* target, uint32 eff) return false; if (target->GetCharmerGUID()) return false; - if (int32 damage = CalculateDamage(eff, target)) + if (int32 damage = m_spellInfo->Effects[eff].CalcValue()) if ((int32)target->getLevel() > damage) return false; break; + default: + break; } - //Do not do further checks for triggered spells - if (IsTriggered()) + if (m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) return true; + // todo: shit below shouldn't be here, but it's temporary //Check targets for LOS visibility (except spells without range limitations) switch(m_spellInfo->Effects[eff].Effect) { - case SPELL_EFFECT_SUMMON_RAF_FRIEND: - case SPELL_EFFECT_SUMMON_PLAYER: // from anywhere - break; - case SPELL_EFFECT_DUMMY: - if (m_spellInfo->Id != 20577) // Cannibalize - break; - //fall through case SPELL_EFFECT_RESURRECT_NEW: // player far away, maybe his corpse near? if (target != m_caster && !target->IsWithinLOSInMap(m_caster)) @@ -6612,8 +6408,6 @@ bool Spell::CheckTarget(Unit* target, uint32 eff) caster = m_caster->GetMap()->GetGameObject(m_originalCasterGUID); if (!caster) caster = m_caster; - if (target->GetEntry() == 5925) - return true; if (target != m_caster && !target->IsWithinLOSInMap(caster)) return false; break; diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 47d22463119..ee3e7eab1bf 100755 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -429,7 +429,7 @@ class Spell template<typename T> WorldObject* FindCorpseUsing(); - bool CheckTarget(Unit* target, uint32 eff); + bool CheckEffectTarget(Unit const* target, uint32 eff) const; bool CanAutoCast(Unit* target); void CheckSrc() { if (!m_targets.HasSrc()) m_targets.SetSrc(*m_caster); } void CheckDst() { if (!m_targets.HasDst()) m_targets.SetDst(*m_caster); } @@ -498,8 +498,6 @@ class Spell void UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc) - bool CheckTargetCreatureType(Unit* target) const; - void CleanupTargetList(); void SetSpellValue(SpellValueMod mod, int32 value); @@ -614,8 +612,7 @@ class Spell }; std::list<ItemTargetInfo> m_UniqueItemInfo; - void AddUnitTarget(Unit* target, uint32 effIndex); - void AddUnitTarget(uint64 unitGUID, uint32 effIndex); + void AddUnitTarget(Unit* target, uint32 effIndex, bool checkIfValid = true); void AddGOTarget(GameObject* target, uint32 effIndex); void AddGOTarget(uint64 goGUID, uint32 effIndex); void AddItemTarget(Item* target, uint32 effIndex); @@ -706,7 +703,6 @@ namespace Trinity const Unit* const i_source; uint32 i_entry; const Position * const i_pos; - bool i_requireDeadTarget; SpellInfo const* i_spellProto; SpellNotifierCreatureAndPlayer(Unit *source, std::list<Unit*> &data, float radius, SpellNotifyPushType type, @@ -719,13 +715,11 @@ namespace Trinity template<class T> inline void Visit(GridRefManager<T>& m) { - i_requireDeadTarget = i_spellProto ? bool(i_spellProto->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_GHOSTS) : false; - for (typename GridRefManager<T>::iterator itr = m.begin(); itr != m.end(); ++itr) { Unit* target = (Unit*)itr->getSource(); - if (!i_source->canSeeOrDetect(target, true)) + if (i_spellProto->CheckTarget(i_source, target, true) != SPELL_CAST_OK) continue; switch (i_TargetType) @@ -733,7 +727,8 @@ namespace Trinity case SPELL_TARGETS_ENEMY: if (target->isTotem()) continue; - if (!target->isAttackableByAOE(i_spellProto)) + // can't be checked in SpellInfo::CheckTarget - needs more research + if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE)) continue; if (i_source->IsControlledByPlayer()) { @@ -751,12 +746,6 @@ namespace Trinity continue; if (!i_source->IsFriendlyTo(target)) continue; - if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) - continue; - if (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->isGameMaster()) - continue; - if (target->isAlive() == i_requireDeadTarget) - continue; break; case SPELL_TARGETS_ENTRY: if (target->GetEntry()!= i_entry) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 36244257d28..825c8c4fb14 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -816,10 +816,6 @@ void Spell::EffectDummy(SpellEffIndex effIndex) } return; } - case 20577: // Cannibalize - if (unitTarget) - m_caster->CastSpell(m_caster, 20578, false, NULL); - return; case 23019: // Crystal Prison Dummy DND { if (!unitTarget || !unitTarget->isAlive() || unitTarget->GetTypeId() != TYPEID_UNIT || unitTarget->ToCreature()->isPet()) @@ -3139,7 +3135,7 @@ void Spell::EffectDispel(SpellEffIndex effIndex) if (aura->IsPassive()) continue; - if ((aura->GetSpellInfo()->GetDispelMask()) & dispelMask) + if (aura->GetSpellInfo()->GetDispelMask() & dispelMask) { if (aura->GetSpellInfo()->Dispel == DISPEL_MAGIC) { @@ -5062,27 +5058,18 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) m_caster->ToPlayer()->learnSpell(discoveredSpell, false); return; } - case 62428: // Load into Catapult - { - if (Vehicle* seat = m_caster->GetVehicleKit()) - if (Unit* passenger = seat->GetPassenger(0)) - if (Unit* demolisher = m_caster->GetVehicleBase()) - passenger->CastSpell(demolisher, damage, true); - return; - } case 62482: // Grab Crate { if (unitTarget) { - if (Vehicle* seat = m_caster->GetVehicleKit()) + if (Unit* seat = m_caster->GetVehicleBase()) { - if (Unit* passenger = seat->GetPassenger(1)) - if (Creature* oldContainer = passenger->ToCreature()) - oldContainer->DisappearAndDie(); - - // TODO: a hack, range = 11, should after some time cast, otherwise too far - m_caster->CastSpell(seat->GetBase(), 62496, true); - unitTarget->EnterVehicle(m_caster, 1); + if (Unit* parent = seat->GetVehicleBase()) + { + // TODO: a hack, range = 11, should after some time cast, otherwise too far + m_caster->CastSpell(parent, 62496, true); + unitTarget->CastSpell(parent, m_spellInfo->Effects[EFFECT_0].CalcValue()); + } } } return; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 069864dfd74..2a05907996d 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -17,6 +17,7 @@ #include "SpellInfo.h" #include "SpellMgr.h" +#include "Spell.h" #include "DBCStores.h" SpellImplicitTargetInfo::SpellImplicitTargetInfo(uint32 target) @@ -423,17 +424,17 @@ bool SpellEffectInfo::IsAreaAuraEffect() const bool SpellEffectInfo::IsFarUnitTargetEffect() const { - return (Effect == SPELL_EFFECT_SUMMON_PLAYER); + return Effect == SPELL_EFFECT_SUMMON_PLAYER; } bool SpellEffectInfo::IsFarDestTargetEffect() const { - return (Effect == SPELL_EFFECT_TELEPORT_UNITS); + return Effect == SPELL_EFFECT_TELEPORT_UNITS; } bool SpellEffectInfo::IsUnitOwnedAuraEffect() const { - return (IsAreaAuraEffect() || Effect == SPELL_EFFECT_APPLY_AURA); + return IsAreaAuraEffect() || Effect == SPELL_EFFECT_APPLY_AURA; } int32 SpellEffectInfo::CalcValue(Unit const* caster, int32 const* bp, Unit const* /*target*/) const @@ -1101,7 +1102,7 @@ bool SpellInfo::IsRequiringDeadTarget() const bool SpellInfo::IsAllowingDeadTarget() const { - return AttributesEx2 & SPELL_ATTR2_CAN_TARGET_DEAD; + return AttributesEx2 & SPELL_ATTR2_CAN_TARGET_DEAD || Targets & (TARGET_FLAG_CORPSE_ALLY | TARGET_FLAG_CORPSE_ENEMY | TARGET_FLAG_UNIT_DEAD); } bool SpellInfo::CanBeUsedInCombat() const @@ -1162,7 +1163,7 @@ bool SpellInfo::IsAffectedBySpellMod(SpellModifier* mod) const return false; // true - if (mod->mask & SpellFamilyFlags) + if (mod->mask & SpellFamilyFlags) return true; return false; @@ -1486,6 +1487,128 @@ SpellCastResult SpellInfo::CheckLocation(uint32 map_id, uint32 zone_id, uint32 a return SPELL_CAST_OK; } +SpellCastResult SpellInfo::CheckTarget(Unit const* caster, Unit const* target, bool implicit) const +{ + if (AttributesEx & SPELL_ATTR1_CANT_TARGET_SELF && caster == target) + return SPELL_FAILED_BAD_TARGETS; + + if (AttributesEx & SPELL_ATTR1_CANT_TARGET_IN_COMBAT && target->isInCombat()) + return SPELL_FAILED_TARGET_AFFECTING_COMBAT; + + if (AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS && !target->ToPlayer()) + return SPELL_FAILED_TARGET_NOT_PLAYER; + + if (!IsAllowingDeadTarget() && !target->isAlive()) + return SPELL_FAILED_TARGETS_DEAD; + + if (AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_GHOSTS && !(!target->isAlive() && target->HasAuraType(SPELL_AURA_GHOST))) + return SPELL_FAILED_TARGET_NOT_GHOST; + + // check this flag only for implicit targets (chain and area), allow to explicitly target units for spells like Shield of Righteousness + if (implicit && AttributesEx6 & SPELL_ATTR6_CANT_TARGET_CROWD_CONTROLLED && !target->CanFreeMove()) + return SPELL_FAILED_BAD_TARGETS; + + // check visibility - ignore stealth for implicit (area) targets + if (!(AttributesEx6 & SPELL_ATTR6_CAN_TARGET_INVISIBLE) && !caster->canSeeOrDetect(target, implicit)) + return SPELL_FAILED_BAD_TARGETS; + + if (!(AttributesEx6 & SPELL_ATTR6_CAN_TARGET_UNTARGETABLE) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) + return SPELL_FAILED_BAD_TARGETS; + + //if (!(AttributesEx6 & SPELL_ATTR6_CAN_TARGET_POSSESSED_FRIENDS) + + if (!CheckTargetCreatureType(target)) + { + if (target->GetTypeId() == TYPEID_PLAYER) + return SPELL_FAILED_TARGET_IS_PLAYER; + else + return SPELL_FAILED_BAD_TARGETS; + } + + // check UNIT_FLAG_NON_ATTACKABLE flag - a player can cast spells on his pet (or other controlled unit) though in any state + if (target != caster && target->GetCharmerOrOwnerGUID() != caster->GetGUID()) + { + // any unattackable target skipped + if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return SPELL_FAILED_BAD_TARGETS; + } + + // check GM mode and GM invisibility - only for player casts (npc casts are controlled by AI) + if (target != caster && caster->IsControlledByPlayer() && target->GetTypeId() == TYPEID_PLAYER) + { + if (!target->ToPlayer()->IsVisible()) + return SPELL_FAILED_BAD_TARGETS; + + if (target->ToPlayer()->isGameMaster()) + return SPELL_FAILED_BAD_TARGETS; + } + + // not allow casting on flying player + if (target->HasUnitState(UNIT_STAT_IN_FLIGHT)) + return SPELL_FAILED_BAD_TARGETS; + + if (TargetAuraState && !target->HasAuraState(AuraStateType(TargetAuraState), this, caster)) + return SPELL_FAILED_TARGET_AURASTATE; + + if (TargetAuraStateNot && target->HasAuraState(AuraStateType(TargetAuraStateNot), this, caster)) + return SPELL_FAILED_TARGET_AURASTATE; + + if (TargetAuraSpell && !target->HasAura(sSpellMgr->GetSpellIdForDifficulty(TargetAuraSpell, caster))) + return SPELL_FAILED_TARGET_AURASTATE; + + if (ExcludeTargetAuraSpell && target->HasAura(sSpellMgr->GetSpellIdForDifficulty(ExcludeTargetAuraSpell, caster))) + return SPELL_FAILED_TARGET_AURASTATE; + + if (caster != target) + { + if (caster->GetTypeId() == TYPEID_PLAYER) + { + // Do not allow these spells to target creatures not tapped by us (Banish, Polymorph, many quest spells) + if (AttributesEx2 & SPELL_ATTR2_CANT_TARGET_TAPPED) + if (Creature const* targetCreature = target->ToCreature()) + if (targetCreature->hasLootRecipient() && !targetCreature->isTappedBy(caster->ToPlayer())) + return SPELL_FAILED_CANT_CAST_ON_TAPPED; + + if (AttributesCu & SPELL_ATTR0_CU_PICKPOCKET) + { + if (target->GetTypeId() == TYPEID_PLAYER) + return SPELL_FAILED_BAD_TARGETS; + else if ((target->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) == 0) + return SPELL_FAILED_TARGET_NO_POCKETS; + } + + // Not allow disarm unarmed player + if (Mechanic == MECHANIC_DISARM) + { + if (target->GetTypeId() == TYPEID_PLAYER) + { + Player const* player = target->ToPlayer(); + if (!player->GetWeaponForAttack(BASE_ATTACK) || !player->IsUseEquipedWeapon(true)) + return SPELL_FAILED_TARGET_NO_WEAPONS; + } + else if (!target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)) + return SPELL_FAILED_TARGET_NO_WEAPONS; + } + } + } + return SPELL_CAST_OK; +} + +bool SpellInfo::CheckTargetCreatureType(Unit const* target) const +{ + // Curse of Doom & Exorcism: not find another way to fix spell target check :/ + if (SpellFamilyName == SPELLFAMILY_WARLOCK && Category == 1179) + { + // not allow cast at player + if (target->GetTypeId() == TYPEID_PLAYER) + return false; + else + return true; + } + uint32 creatureType = target->GetCreatureTypeMask(); + return !TargetCreatureType || !creatureType || (creatureType & TargetCreatureType); +} + SpellSchoolMask SpellInfo::GetSchoolMask() const { return SpellSchoolMask(SchoolMask); @@ -1495,10 +1618,10 @@ uint32 SpellInfo::GetAllEffectsMechanicMask() const { uint32 mask = 0; if (Mechanic) - mask |= 1<< Mechanic; + mask |= 1 << Mechanic; for (int i = 0; i < MAX_SPELL_EFFECTS; ++i) if (Effects[i].Mechanic) - mask |= 1<< Effects[i].Mechanic; + mask |= 1 << Effects[i].Mechanic; return mask; } @@ -1523,7 +1646,7 @@ Mechanics SpellInfo::GetEffectMechanic(uint8 effIndex) const uint32 SpellInfo::GetDispelMask() const { - return SpellInfo::GetDispelMask(DispelType(Dispel)); + return GetDispelMask(DispelType(Dispel)); } uint32 SpellInfo::GetDispelMask(DispelType type) diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 5abf3851279..9efc4701f19 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -159,7 +159,6 @@ enum SpellCustomAttributes SPELL_ATTR0_CU_DIRECT_DAMAGE = 0x00000100, SPELL_ATTR0_CU_CHARGE = 0x00000200, SPELL_ATTR0_CU_PICKPOCKET = 0x00000400, - SPELL_ATTR0_CU_EXCLUDE_SELF = 0x00000800, SPELL_ATTR0_CU_NEGATIVE_EFF0 = 0x00001000, SPELL_ATTR0_CU_NEGATIVE_EFF1 = 0x00002000, SPELL_ATTR0_CU_NEGATIVE_EFF2 = 0x00004000, @@ -403,6 +402,8 @@ public: SpellCastResult CheckShapeshift(uint32 form) const; SpellCastResult CheckLocation(uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL) const; + SpellCastResult CheckTarget(Unit const* caster, Unit const* target, bool implicit = true) const; + bool CheckTargetCreatureType(Unit const* target) const; SpellSchoolMask GetSchoolMask() const; uint32 GetAllEffectsMechanicMask() const; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 8b86f002fa2..94c066c8c39 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -430,7 +430,7 @@ void SpellMgr::SetSpellDifficultyId(uint32 spellId, uint32 id) mSpellDifficultySearcherMap[spellId] = id; } -uint32 SpellMgr::GetSpellIdForDifficulty(uint32 spellId, Unit* caster) const +uint32 SpellMgr::GetSpellIdForDifficulty(uint32 spellId, Unit const* caster) const { if (!GetSpellInfo(spellId)) return spellId; @@ -472,7 +472,7 @@ uint32 SpellMgr::GetSpellIdForDifficulty(uint32 spellId, Unit* caster) const return uint32(difficultyEntry->SpellID[mode]); } -SpellInfo const* SpellMgr::GetSpellForDifficultyFromSpell(SpellInfo const* spell, Unit* caster) const +SpellInfo const* SpellMgr::GetSpellForDifficultyFromSpell(SpellInfo const* spell, Unit const* caster) const { uint32 newSpellId = GetSpellIdForDifficulty(spell->Id, caster); SpellInfo const* newSpell = GetSpellInfo(newSpellId); @@ -2774,21 +2774,6 @@ void SpellMgr::LoadSpellCustomAttr() // ONLY SPELLS WITH SPELLFAMILY_GENERIC and EFFECT_SCHOOL_DAMAGE spellInfo->AttributesCu |= SPELL_ATTR0_CU_SHARE_DAMAGE; break; - case 27820: // Mana Detonation - case 69782: // Ooze Flood - case 69796: // Ooze Flood - case 69798: // Ooze Flood - case 69801: // Ooze Flood - case 69538: // Ooze Combine - case 69553: // Ooze Combine - case 69610: // Ooze Combine - case 71447: // Bloodbolt Splash - case 71481: // Bloodbolt Splash - case 71482: // Bloodbolt Splash - case 71483: // Bloodbolt Splash - case 71390: // Pact of the Darkfallen - spellInfo->AttributesCu |= SPELL_ATTR0_CU_EXCLUDE_SELF; - break; case 18500: // Wing Buffet case 33086: // Wild Bite case 49749: // Piercing Blow @@ -3105,9 +3090,6 @@ void SpellMgr::LoadDbcDataCorrections() case 27937: // Anchor to Skulls spellInfo->rangeIndex = 13; break; - case 48743: // Death Pact - spellInfo->AttributesEx &= ~SPELL_ATTR1_CANT_TARGET_SELF; - break; // target allys instead of enemies, target A is src_caster, spells with effect like that have ally target // this is the only known exception, probably just wrong data case 29214: // Wrath of the Plaguebringer diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index f6f8fb4d080..78a8b02c044 100755 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -550,8 +550,8 @@ class SpellMgr // Spell difficulty uint32 GetSpellDifficultyId(uint32 spellId) const; void SetSpellDifficultyId(uint32 spellId, uint32 id); - uint32 GetSpellIdForDifficulty(uint32 spellId, Unit* caster) const; - SpellInfo const* GetSpellForDifficultyFromSpell(SpellInfo const* spell, Unit* caster) const; + uint32 GetSpellIdForDifficulty(uint32 spellId, Unit const* caster) const; + SpellInfo const* GetSpellForDifficultyFromSpell(SpellInfo const* spell, Unit const* caster) const; // Spell Ranks table SpellChainNode const* GetSpellChainNode(uint32 spell_id) const; diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index bb7b242a561..5c9a6a23304 100755 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -477,6 +477,11 @@ void SpellScript::SetCustomCastResultMessage(SpellCustomErrors result) m_spell->m_customError = result; } +SpellValue const* SpellScript::GetSpellValue() +{ + return m_spell->m_spellValue; +} + bool AuraScript::_Validate(SpellInfo const* entry) { for (std::list<CheckAreaTargetHandler>::iterator itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr) diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index e28030d7605..c9f88092028 100755 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -256,6 +256,7 @@ class SpellScript : public _SpellScript Unit* GetCaster(); Unit* GetOriginalCaster(); SpellInfo const* GetSpellInfo(); + SpellValue const* GetSpellValue(); // methods useable after spell targets are set // accessors to the "focus" targets of the spell @@ -287,10 +288,12 @@ class SpellScript : public _SpellScript // returns: target of current effect if it was GameObject otherwise NULL GameObject* GetHitGObj(); // setter/getter for for damage done by spell to target of spell hit + // returns damage calculated before hit, and real dmg done after hit int32 GetHitDamage(); void SetHitDamage(int32 damage); void PreventHitDamage() { SetHitDamage(0); } // setter/getter for for heal done by spell to target of spell hit + // returns healing calculated before hit, and real dmg done after hit int32 GetHitHeal(); void SetHitHeal(int32 heal); void PreventHitHeal() { SetHitHeal(0); } diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.h b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.h index 926acc8c965..2282acaa233 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.h +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.h @@ -54,6 +54,7 @@ enum eTypes DATA_THRONE_DOOR = 24, DATA_SF_BRAZIER_N = 25, - DATA_SF_BRAZIER_S = 26 + DATA_SF_BRAZIER_S = 26, + DATA_MOIRA = 27, }; #endif diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp index 3ff21b428d6..1d9878a331a 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp @@ -24,6 +24,7 @@ SDCategory: Blackrock Depths EndScriptData */ #include "ScriptPCH.h" +#include "blackrock_depths.h" enum Yells { @@ -49,8 +50,12 @@ public: struct boss_draganthaurissanAI : public ScriptedAI { - boss_draganthaurissanAI(Creature* c) : ScriptedAI(c) {} + boss_draganthaurissanAI(Creature* c) : ScriptedAI(c) + { + instance = me->GetInstanceScript(); + } + InstanceScript* instance; uint32 HandOfThaurissan_Timer; uint32 AvatarOfFlame_Timer; //uint32 Counter; @@ -73,6 +78,15 @@ public: DoScriptText(SAY_SLAY, me); } + void JustDied(Unit* /*who*/) + { + if (Creature* Moira = ObjectAccessor::GetCreature(*me, instance ? instance->GetData64(DATA_MOIRA) : 0)) + { + Moira->AI()->EnterEvadeMode(); + Moira->setFaction(35); + } + } + void UpdateAI(const uint32 diff) { //Return since we have no target diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp index 95d15ceb4bd..f6fa3ca18d9 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/instance_blackrock_depths.cpp @@ -42,6 +42,7 @@ enum eEnums NPC_GLOOMREL = 9037, NPC_DOOMREL = 9039, NPC_MAGMUS = 9938, + NPC_MOIRA = 8929, GO_ARENA1 = 161525, GO_ARENA2 = 161522, @@ -87,6 +88,7 @@ public: uint64 EmperorGUID; uint64 PhalanxGUID; uint64 MagmusGUID; + uint64 MoiraGUID; uint64 GoArena1GUID; uint64 GoArena2GUID; @@ -124,6 +126,7 @@ public: EmperorGUID = 0; PhalanxGUID = 0; MagmusGUID = 0; + MoiraGUID = 0; GoArena1GUID = 0; GoArena2GUID = 0; @@ -163,6 +166,7 @@ public: { case NPC_EMPEROR: EmperorGUID = creature->GetGUID(); break; case NPC_PHALANX: PhalanxGUID = creature->GetGUID(); break; + case NPC_MOIRA: MoiraGUID = creature->GetGUID(); break; case NPC_DOOMREL: TombBossGUIDs[0] = creature->GetGUID(); break; case NPC_DOPEREL: TombBossGUIDs[1] = creature->GetGUID(); break; case NPC_HATEREL: TombBossGUIDs[2] = creature->GetGUID(); break; @@ -308,6 +312,8 @@ public: return EmperorGUID; case DATA_PHALANX: return PhalanxGUID; + case DATA_MOIRA: + return MoiraGUID; case DATA_ARENA1: return GoArena1GUID; case DATA_ARENA2: diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp index ffea5fc8dc5..f18fc5ee243 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp @@ -357,7 +357,7 @@ public: if (GameObject* pGo = me->SummonGameObject(183410, -533.140f, -105.322f, -156.016f, 0, 0, 0, 0, 0, 1000)) { GoSummonList.push_back(pGo->GetGUID()); - pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); //We can't use it! + pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); //We can't use it! } Summon(3); break; @@ -372,7 +372,7 @@ public: if (GameObject* pGo = me->SummonGameObject(183410, -542.199f, -96.854f, -155.790f, 0, 0, 0, 0, 0, 1000)) { GoSummonList.push_back(pGo->GetGUID()); - pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } break; case 5: @@ -392,7 +392,7 @@ public: if (GameObject* pGo = me->SummonGameObject(183410, -507.820f, -103.333f, -151.353f, 0, 0, 0, 0, 0, 1000)) { GoSummonList.push_back(pGo->GetGUID()); - pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); //We can't use it! + pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); //We can't use it! Summon(6); } break; @@ -400,7 +400,7 @@ public: if (GameObject* pGo = me->SummonGameObject(183410, -511.829f, -86.249f, -151.431f, 0, 0, 0, 0, 0, 1000)) { GoSummonList.push_back(pGo->GetGUID()); - pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); //We can't use it! + pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); //We can't use it! } break; case 9: diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp index afd39b9b8d0..303a307d2b9 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp @@ -58,7 +58,7 @@ public: if (pInstance) { pGo->SetGoState(GO_STATE_ACTIVE); - pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); pInstance->SetData(DATA_FIRE, pInstance->GetData(DATA_FIRE) + 1); return true; } diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp index 0b0e9076fc1..07c7fcf6f27 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/instance_blackfathom_deeps.cpp @@ -126,12 +126,12 @@ public: case GO_SHRINE_OF_GELIHAST: m_uiShrineOfGelihastGUID = go->GetGUID(); if (m_auiEncounter[0] != DONE) - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; case GO_ALTAR_OF_THE_DEEPS: m_uiAltarOfTheDeepsGUID = go->GetGUID(); if (m_auiEncounter[3] != DONE) - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; case GO_AKU_MAI_DOOR: if (m_auiEncounter[2] == DONE) @@ -149,14 +149,14 @@ public: m_auiEncounter[0] = uiData; if (uiData == DONE) if (GameObject* go = instance->GetGameObject(m_uiShrineOfGelihastGUID)) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; case TYPE_AKU_MAI: m_auiEncounter[3] = uiData; if (uiData == DONE) if (GameObject* go = instance->GetGameObject(m_uiAltarOfTheDeepsGUID)) { - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); go->SummonCreature(NPC_MORRIDUNE, SpawnsLocation[4], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 300000); } break; diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp index 60cd1b5f82a..19287d656a8 100644 --- a/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp +++ b/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp @@ -105,7 +105,7 @@ public: case GO_GONG: uiGongGUID = go->GetGUID(); if (m_auiEncounter[0] == DONE) - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; default: break; @@ -123,7 +123,7 @@ public: case 9: case 14: if (GameObject* go = instance->GetGameObject(uiGongGUID)) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; case 1: case 10: @@ -134,7 +134,7 @@ public: if (!go) return; - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); uint32 uiCreature = 0; uint8 uiSummonTimes = 0; diff --git a/src/server/scripts/Kalimdor/ashenvale.cpp b/src/server/scripts/Kalimdor/ashenvale.cpp index da38e26fd22..527d6b3d3e4 100644 --- a/src/server/scripts/Kalimdor/ashenvale.cpp +++ b/src/server/scripts/Kalimdor/ashenvale.cpp @@ -331,7 +331,7 @@ class npc_muglash : public CreatureScript if (GameObject* pGo = GetClosestGameObjectWithEntry(me, GO_NAGA_BRAZIER, INTERACTION_DISTANCE*2)) { - pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); SetEscortPaused(true); } break; diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp index ba34591b84c..a4ded3f65b0 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp @@ -394,7 +394,7 @@ public: if (pPrinceTaldaram && pPrinceTaldaram->isAlive()) { // maybe these are hacks :( - pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); pGO->SetGoState(GO_STATE_ACTIVE); switch(pGO->GetEntry()) diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp index f9922009b1f..7472efcdc42 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp @@ -115,17 +115,17 @@ public: if (spheres[0] == IN_PROGRESS) { go->SetGoState(GO_STATE_ACTIVE); - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } - else go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + else go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; case 193094: Prince_TaldaramSpheres[1] = go->GetGUID(); if (spheres[1] == IN_PROGRESS) { go->SetGoState(GO_STATE_ACTIVE); - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } - else go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + else go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; case 192236: Prince_TaldaramGate = go->GetGUID(); // Web gate past Prince Taldaram if (m_auiEncounter[1] == DONE)HandleGameObject(0, true, go);break; diff --git a/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp b/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp index 8eca03a2075..f9ba820d54d 100644 --- a/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp +++ b/src/server/scripts/Northrend/Gundrak/instance_gundrak.cpp @@ -159,11 +159,11 @@ public: case 192518: uiSladRanAltar = go->GetGUID(); // Make sure that they start out as unusuable - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); if (m_auiEncounter[0] == DONE) { if (uiSladRanStatueState == GO_STATE_ACTIVE) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); else { ++phase; @@ -174,11 +174,11 @@ public: case 192519: uiMoorabiAltar = go->GetGUID(); // Make sure that they start out as unusuable - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); if (m_auiEncounter[0] == DONE) { if (uiMoorabiStatueState == GO_STATE_ACTIVE) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); else { ++phase; @@ -189,11 +189,11 @@ public: case 192520: uiDrakkariColossusAltar = go->GetGUID(); // Make sure that they start out as unusuable - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); if (m_auiEncounter[0] == DONE) { if (uiDrakkariColossusStatueState == GO_STATE_ACTIVE) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); else { ++phase; @@ -261,7 +261,7 @@ public: { GameObject* go = instance->GetGameObject(uiSladRanAltar); if (go) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } break; case DATA_MOORABI_EVENT: @@ -270,7 +270,7 @@ public: { GameObject* go = instance->GetGameObject(uiMoorabiAltar); if (go) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); if (bHeroicMode) HandleGameObject(uiEckTheFerociousDoor, true); } @@ -281,7 +281,7 @@ public: { GameObject* go = instance->GetGameObject(uiDrakkariColossusAltar); if (go) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } break; case DATA_GAL_DARAH_EVENT: @@ -524,7 +524,7 @@ public: InstanceScript *pInstance = pGO->GetInstanceScript(); uint64 uiStatue = 0; - pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); pGO->SetGoState(GO_STATE_ACTIVE); if (pInstance) @@ -545,7 +545,7 @@ public: if (!pInstance->GetData64(DATA_STATUE_ACTIVATE)) { pInstance->SetData64(DATA_STATUE_ACTIVATE, uiStatue); - pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); pGO->SetGoState(GO_STATE_ACTIVE); } return true; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index 62b00a90dc6..09f3bd49279 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -74,6 +74,7 @@ enum Event EVENT_TRIGGER, EVENT_PHASE, + EVENT_MORTAL_WOUND, }; enum Spells @@ -121,6 +122,10 @@ enum Spells //death knight SPELL_PLAGUE_STRIKE = 49921, SPELL_HOWLING_BLAST = 51411, + + // Abomination spells + SPELL_FRENZY = 28468, + SPELL_MORTAL_WOUND = 28467, }; enum Creatures @@ -302,6 +307,9 @@ public: FindGameObjects(); + if (instance) + instance->SetData(DATA_ABOMINATION_KILLED, 0); + if (GameObject* pKTTrigger = me->GetMap()->GetGameObject(KTTriggerGUID)) { pKTTrigger->ResetDoorOrButton(); @@ -709,8 +717,86 @@ public: }; +class npc_kelthuzad_abomination : public CreatureScript +{ + public: + npc_kelthuzad_abomination() : CreatureScript("npc_kelthuzad_abomination") { } + + struct npc_kelthuzad_abominationAI : public ScriptedAI + { + npc_kelthuzad_abominationAI(Creature* creature) : ScriptedAI(creature) + { + instance = me->GetInstanceScript(); + } + + InstanceScript* instance; + EventMap events; + + void Reset() + { + events.Reset(); + events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(2000, 5000)); + DoCast(me, SPELL_FRENZY, true); + } + + void UpdateAI(uint32 const diff) + { + if (!UpdateVictim()) + return; + + events.Update(diff); + + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_MORTAL_WOUND: + DoCastVictim(SPELL_MORTAL_WOUND, true); + events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(10000, 15000)); + break; + default: + break; + } + } + } + + void JustDied(Unit* /*who*/) + { + if (instance) + instance->SetData(DATA_ABOMINATION_KILLED, instance->GetData(DATA_ABOMINATION_KILLED) + 1); + } + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_kelthuzad_abominationAI(creature); + } +}; + +class achievement_just_cant_get_enough : public AchievementCriteriaScript +{ + public: + achievement_just_cant_get_enough() : AchievementCriteriaScript("achievement_just_cant_get_enough") + { + } + + bool OnCheck(Player* /*player*/, Unit* target) + { + if (!target) + return false; + + if (InstanceScript* instance = target->GetInstanceScript()) + if (instance->GetData(DATA_ABOMINATION_KILLED) >= 18) + return true; + + return false; + } +}; + void AddSC_boss_kelthuzad() { new boss_kelthuzad(); new at_kelthuzad_center(); + new npc_kelthuzad_abomination(); + new achievement_just_cant_get_enough(); } diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp index f57a81f4296..f08e0ccb5cf 100644 --- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp +++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp @@ -140,11 +140,33 @@ public: uint64 uiKelthuzadTrigger; uint64 uiPortals[4]; + uint32 AbominationCount; + GOState gothikDoorState; time_t minHorsemenDiedTime; time_t maxHorsemenDiedTime; + void Initialize() + { + GothikGateGUID = 0; + HorsemenChestGUID = 0; + SapphironGUID = 0; + uiFaerlina = 0; + uiThane = 0; + uiLady = 0; + uiBaron = 0; + uiSir = 0; + uiThaddius = 0; + uiHeigan = 0; + uiFeugen = 0; + uiStalagg = 0; + uiKelthuzad = 0; + uiKelthuzadTrigger = 0; + + memset(uiPortals, 0, sizeof(uiPortals)); + } + void OnCreatureCreate(Creature* creature) { switch(creature->GetEntry()) @@ -273,7 +295,23 @@ public: maxHorsemenDiedTime = now; } break; + case DATA_ABOMINATION_KILLED: + AbominationCount = value; + break; + } + } + + uint32 GetData(uint32 id) + { + switch (id) + { + case DATA_ABOMINATION_KILLED: + return AbominationCount; + default: + break; } + + return 0; } uint64 GetData64(uint32 id) diff --git a/src/server/scripts/Northrend/Naxxramas/naxxramas.h b/src/server/scripts/Northrend/Naxxramas/naxxramas.h index 86a7f67c11d..bb25ad691e0 100644 --- a/src/server/scripts/Northrend/Naxxramas/naxxramas.h +++ b/src/server/scripts/Northrend/Naxxramas/naxxramas.h @@ -48,6 +48,7 @@ enum Data DATA_HORSEMEN1, DATA_HORSEMEN2, DATA_HORSEMEN3, + DATA_ABOMINATION_KILLED, }; enum Data64 diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp index 6d3f32a0cae..cd742b11d58 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp @@ -216,7 +216,7 @@ public: if (pKeristrasza && pKeristrasza->isAlive()) { // maybe these are hacks :( - pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); pGO->SetGoState(GO_STATE_ACTIVE); CAST_AI(boss_keristrasza::boss_keristraszaAI, pKeristrasza->AI())->CheckContainmentSpheres(true); diff --git a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp index 5ab6a96dff3..a4676dee852 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/instance_nexus.cpp @@ -129,21 +129,21 @@ public: { AnomalusContainmentSphere = go->GetGUID(); if (m_auiEncounter[1] == DONE) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; } case 188528: { OrmoroksContainmentSphere = go->GetGUID(); if (m_auiEncounter[2] == DONE) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; } case 188526: { TelestrasContainmentSphere = go->GetGUID(); if (m_auiEncounter[0] == DONE) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; } } @@ -171,7 +171,7 @@ public: { GameObject* Sphere = instance->GetGameObject(TelestrasContainmentSphere); if (Sphere) - Sphere->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + Sphere->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } m_auiEncounter[0] = data; break; @@ -181,7 +181,7 @@ public: if (data == DONE) { if (GameObject* Sphere = instance->GetGameObject(AnomalusContainmentSphere)) - Sphere->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + Sphere->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } m_auiEncounter[1] = data; break; @@ -191,7 +191,7 @@ public: if (data == DONE) { if (GameObject* Sphere = instance->GetGameObject(OrmoroksContainmentSphere)) - Sphere->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + Sphere->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } m_auiEncounter[2] = data; break; diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp index 4b2776b688f..a7abfcf42be 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp +++ b/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp @@ -95,6 +95,7 @@ enum AssemblyActions ACTION_STEELBREAKER = 0, ACTION_MOLGEIM = 1, ACTION_BRUNDIR = 2, + ACTION_ADD_CHARGE = 3, }; enum AssemblyYells @@ -243,7 +244,10 @@ class boss_steelbreaker : public CreatureScript events.RescheduleEvent(EVENT_STATIC_DISRUPTION, 30000); if (phase >= 3) events.RescheduleEvent(EVENT_OVERWHELMING_POWER, urand(2000, 5000)); - break; + break; + case ACTION_ADD_CHARGE: + DoCast(me, SPELL_ELECTRICAL_CHARGE, true); + break; } } @@ -413,7 +417,7 @@ class boss_runemaster_molgeim : public CreatureScript DoCast(SPELL_BERSERK); events.CancelEvent(EVENT_BERSERK); break; - case EVENT_RUNE_OF_POWER: // Improve target selection; random alive friendly + case EVENT_RUNE_OF_POWER: { Unit* target = NULL; switch (urand(0, 2)) @@ -628,7 +632,7 @@ class boss_stormcaller_brundir : public CreatureScript Steelbreaker->AI()->DoAction(ACTION_STEELBREAKER); // Prevent to have Brundir somewhere in the air when he die in Air phase - if (me->GetPositionZ() > FLOOR_Z/* + 5.0f*/) + if (me->GetPositionZ() > FLOOR_Z) me->GetMotionMaster()->MoveFall(FLOOR_Z); } @@ -765,6 +769,34 @@ class spell_shield_of_runes : public SpellScriptLoader } }; +class spell_assembly_meltdown : public SpellScriptLoader +{ + public: + spell_assembly_meltdown() : SpellScriptLoader("spell_assembly_meltdown") { } + + class spell_assembly_meltdown_SpellScript : public SpellScript + { + PrepareSpellScript(spell_assembly_meltdown_SpellScript); + + void HandleInstaKill(SpellEffIndex /*effIndex*/) + { + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* Steelbreaker = ObjectAccessor::GetCreature(*GetCaster(), instance->GetData64(BOSS_STEELBREAKER))) + Steelbreaker->AI()->DoAction(ACTION_ADD_CHARGE); + } + + void Register() + { + OnEffect += SpellEffectFn(spell_assembly_meltdown_SpellScript::HandleInstaKill, EFFECT_1, SPELL_EFFECT_INSTAKILL); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_assembly_meltdown_SpellScript(); + } +}; + void AddSC_boss_assembly_of_iron() { new boss_steelbreaker(); @@ -774,4 +806,5 @@ void AddSC_boss_assembly_of_iron() new mob_rune_of_summoning(); new mob_rune_of_power(); new spell_shield_of_runes(); + new spell_assembly_meltdown(); } diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp index 779abd6ddf8..776b69d599b 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp @@ -49,6 +49,7 @@ enum Spells SPELL_SMOKE_TRAIL = 63575, SPELL_ELECTROSHOCK = 62522, SPELL_NAPALM = 63666, + SPELL_INVIS_AND_STEALTH_DETECT = 18950, // Passive //TOWER Additional SPELLS SPELL_THORIM_S_HAMMER = 62911, // Tower of Storms SPELL_MIMIRON_S_INFERNO = 62909, // Tower of Flames @@ -243,6 +244,8 @@ class boss_flame_leviathan : public CreatureScript Shutout = true; Unbroken = true; + DoCast(SPELL_INVIS_AND_STEALTH_DETECT); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_STUNNED); me->SetReactState(REACT_PASSIVE); } @@ -327,6 +330,9 @@ class boss_flame_leviathan : public CreatureScript void JustDied(Unit* /*victim*/) { _JustDied(); + // Set Field Flags 67108928 = 64 | 67108864 = UNIT_FLAG_UNK_6 | UNIT_FLAG_SKINNABLE + // Set DynFlags 12 + // Set NPCFlags 0 DoScriptText(SAY_DEATH, me); } @@ -1466,6 +1472,51 @@ class achievement_orbit_uary : public AchievementCriteriaScript } }; +class spell_load_into_catapult : public SpellScriptLoader +{ + enum Spells + { + SPELL_PASSENGER_LOADED = 62340, + }; + + public: + spell_load_into_catapult() : SpellScriptLoader("spell_load_into_catapult") { } + + class spell_load_into_catapult_AuraScript : public AuraScript + { + PrepareAuraScript(spell_load_into_catapult_AuraScript); + + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* owner = GetOwner()->ToUnit(); + if (!owner) + return; + + owner->CastSpell(owner, SPELL_PASSENGER_LOADED, true); + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* owner = GetOwner()->ToUnit(); + if (!owner) + return; + + owner->RemoveAurasDueToSpell(SPELL_PASSENGER_LOADED); + } + + void Register() + { + OnEffectApply += AuraEffectApplyFn(spell_load_into_catapult_AuraScript::OnApply, EFFECT_0, SPELL_AURA_CONTROL_VEHICLE, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_load_into_catapult_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_CONTROL_VEHICLE, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_load_into_catapult_AuraScript(); + } +}; + void AddSC_boss_flame_leviathan() { new boss_flame_leviathan(); @@ -1495,4 +1546,6 @@ void AddSC_boss_flame_leviathan() new achievement_orbital_devastation(); new achievement_nuked_from_orbit(); new achievement_orbit_uary(); + + new spell_load_into_catapult(); } diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp index 5ba0d1da53c..b3f77e893c3 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp +++ b/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp @@ -301,7 +301,7 @@ class go_razorscale_harpoon : public GameObjectScript { InstanceScript* instance = go->GetInstanceScript(); if (ObjectAccessor::GetCreature(*go, instance ? instance->GetData64(BOSS_RAZORSCALE) : 0)) - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); return false; } }; diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp index cb250adc01a..e7dffae5c9d 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp @@ -446,7 +446,7 @@ class instance_ulduar : public InstanceMapScript { if (GameObject* HodirRareCache = instance->GetGameObject(HodirRareCacheGUID)) if (GetData(DATA_HODIR_RARE_CACHE)) - HodirRareCache->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + HodirRareCache->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); if (GameObject* HodirChest = instance->GetGameObject(HodirChestGUID)) HodirChest->SetRespawnTime(HodirChest->GetRespawnDelay()); HandleGameObject(HodirDoorGUID, true); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp index 137492c16ca..9727ce3cbec 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp @@ -147,7 +147,7 @@ public: if (pGo) { pGo->SetGoState(GO_STATE_READY); - pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } } } @@ -841,7 +841,7 @@ public: Creature* pPalehoof = Unit::GetCreature(*pGO, pInstance ? pInstance->GetData64(DATA_GORTOK_PALEHOOF) : 0); if (pPalehoof && pPalehoof->isAlive()) { - pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); pGO->SetGoState(GO_STATE_ACTIVE); CAST_AI(boss_palehoof::boss_palehoofAI, pPalehoof->AI())->NextPhase(); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp index e2c5dc5d341..2eff50c1f8e 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/instance_pinnacle.cpp @@ -136,7 +136,7 @@ public: if (m_auiEncounter[1] == DONE) { HandleGameObject(0, true, go); - go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); } break; } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 48deb028625..3d6b4fba8bc 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -25,6 +25,7 @@ #include "ScriptPCH.h" #include "SpellAuraEffects.h" #include "SkillDiscovery.h" +#include "GridNotifiers.h" class spell_gen_absorb0_hitlimit1 : public SpellScriptLoader { @@ -161,6 +162,60 @@ class spell_gen_burn_brutallus : public SpellScriptLoader } }; +enum eCannibalizeSpells +{ + SPELL_CANNIBALIZE_TRIGGERED = 20578, +}; + +class spell_gen_cannibalize : public SpellScriptLoader +{ + public: + spell_gen_cannibalize() : SpellScriptLoader("spell_gen_cannibalize") { } + + class spell_gen_cannibalize_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gen_cannibalize_SpellScript); + + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_CANNIBALIZE_TRIGGERED)) + return false; + return true; + } + + SpellCastResult CheckIfCorpseNear() + { + Unit* caster = GetCaster(); + float max_range = GetSpellInfo()->GetMaxRange(false); + WorldObject* result = NULL; + // search for nearby enemy corpse in range + Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_SELECT_CHECK_ENEMY); + Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check); + caster->GetMap()->VisitFirstFound(caster->m_positionX, caster->m_positionY, max_range, searcher); + if (!result) + return SPELL_FAILED_NO_EDIBLE_CORPSES; + return SPELL_CAST_OK; + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + caster->CastSpell(caster, SPELL_CANNIBALIZE_TRIGGERED, false); + } + + void Register() + { + OnEffect += SpellEffectFn(spell_gen_cannibalize_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + OnCheckCast += SpellCheckCastFn(spell_gen_cannibalize_SpellScript::CheckIfCorpseNear); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_gen_cannibalize_SpellScript(); + } +}; + // 45472 Parachute enum eParachuteSpells { @@ -1264,6 +1319,7 @@ void AddSC_generic_spell_scripts() new spell_gen_aura_of_anger(); new spell_gen_av_drekthar_presence(); new spell_gen_burn_brutallus(); + new spell_gen_cannibalize(); new spell_gen_leeching_swarm(); new spell_gen_parachute(); new spell_gen_pet_summoned(); diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 79f92368ff9..0a81b13ed64 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -23,6 +23,7 @@ #include "ScriptPCH.h" #include "SpellAuraEffects.h" +#include "GridNotifiers.h" enum HunterSpells { @@ -468,10 +469,22 @@ public: return true; } + SpellCastResult CheckIfCorpseNear() + { + Unit* caster = GetCaster(); + float max_range = GetSpellInfo()->GetMaxRange(false); + WorldObject* result = NULL; + // search for nearby enemy corpse in range + Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_SELECT_CHECK_ENEMY); + Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check); + caster->GetMap()->VisitFirstFound(caster->m_positionX, caster->m_positionY, max_range, searcher); + if (!result) + return SPELL_FAILED_NO_EDIBLE_CORPSES; + return SPELL_CAST_OK; + } + void HandleDummy(SpellEffIndex /*effIndex*/) { - if (!GetHitUnit()) - return; Unit* caster = GetCaster(); caster->CastSpell(caster, HUNTER_PET_SPELL_CARRION_FEEDER_TRIGGERED, false); } @@ -480,6 +493,7 @@ public: { // add dummy effect spell handler to pet's Last Stand OnEffect += SpellEffectFn(spell_hun_pet_carrion_feeder_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + OnCheckCast += SpellCheckCastFn(spell_hun_pet_carrion_feeder_SpellScript::CheckIfCorpseNear); } bool Load() diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 4d2cd15199b..e2f37912931 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -1067,6 +1067,67 @@ class spell_item_ashbringer : public SpellScriptLoader } }; +enum MagicEater +{ + SPELL_WILD_MAGIC = 58891, + SPELL_WELL_FED_1 = 57288, + SPELL_WELL_FED_2 = 57139, + SPELL_WELL_FED_3 = 57111, + SPELL_WELL_FED_4 = 57286, + SPELL_WELL_FED_5 = 57291, +}; + +class spell_magic_eater_food : public SpellScriptLoader +{ + public: + spell_magic_eater_food() : SpellScriptLoader("spell_magic_eater_food") + { + } + + class spell_magic_eater_food_AuraScript : public AuraScript + { + PrepareAuraScript(spell_magic_eater_food_AuraScript); + + void HandleTriggerSpell(AuraEffect const* aurEff) + { + PreventDefaultAction(); + Unit* target = GetTarget(); + + switch (urand(0, 5)) + { + case 0: + target->CastSpell(target, SPELL_WILD_MAGIC, true); + break; + case 1: + target->CastSpell(target, SPELL_WELL_FED_1, true); + break; + case 2: + target->CastSpell(target, SPELL_WELL_FED_2, true); + break; + case 3: + target->CastSpell(target, SPELL_WELL_FED_3, true); + break; + case 4: + target->CastSpell(target, SPELL_WELL_FED_4, true); + break; + case 5: + target->CastSpell(target, SPELL_WELL_FED_5, true); + break; + } + } + + void Register() + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_magic_eater_food_AuraScript::HandleTriggerSpell, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_magic_eater_food_AuraScript(); + } +}; + void AddSC_item_spell_scripts() { // 23074 Arcanite Dragonling @@ -1098,4 +1159,5 @@ void AddSC_item_spell_scripts() new spell_item_vanquished_clutches(); new spell_item_ashbringer(); + new spell_magic_eater_food(); } diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index 1915697e018..f1add24fc73 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -351,7 +351,7 @@ class spell_rog_deadly_poison : public SpellScriptLoader SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(enchant->spellid[s]); if (!spellInfo) { - sLog->outError("Player::CastItemCombatSpell Enchant %i, cast unknown spell %i", enchant->ID, enchant->spellid[s]); + sLog->outError("Player::CastItemCombatSpell Enchant %i, player (Name: %s, GUID: %u) cast unknown spell %i", enchant->ID, player->GetName(), player->GetGUIDLow(), enchant->spellid[s]); continue; } |