diff options
author | Rat <none@none> | 2010-04-14 23:07:41 +0200 |
---|---|---|
committer | Rat <none@none> | 2010-04-14 23:07:41 +0200 |
commit | 6bcb297de4d5231373a3e2bf2b40e527b91cdf46 (patch) | |
tree | a5379b14ceb2ac9e7273143b334bfc693e2ef042 /src/game | |
parent | cc262e1cde544eb7cf643df79fa00c9f34af4785 (diff) |
*code cleanup
*totally destroyed m_creature, use "me" for future coding
--HG--
branch : trunk
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/CreatureAI.cpp | 4 | ||||
-rw-r--r-- | src/game/CreatureAI.h | 5 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 282 | ||||
-rw-r--r-- | src/game/CreatureEventAI.h | 2 | ||||
-rw-r--r-- | src/game/GridNotifiers.h | 12 | ||||
-rw-r--r-- | src/game/GuardAI.cpp | 62 | ||||
-rw-r--r-- | src/game/PetAI.cpp | 60 | ||||
-rw-r--r-- | src/game/ReactorAI.cpp | 10 | ||||
-rw-r--r-- | src/game/ScriptedCreature.cpp | 140 | ||||
-rw-r--r-- | src/game/ScriptedCreature.h | 14 | ||||
-rw-r--r-- | src/game/ScriptedEscortAI.cpp | 116 | ||||
-rw-r--r-- | src/game/ScriptedEscortAI.h | 2 | ||||
-rw-r--r-- | src/game/ScriptedFollowerAI.cpp | 120 | ||||
-rw-r--r-- | src/game/ScriptedGuardAI.cpp | 68 | ||||
-rw-r--r-- | src/game/ScriptedSimpleAI.cpp | 38 | ||||
-rw-r--r-- | src/game/TotemAI.cpp | 34 |
16 files changed, 484 insertions, 485 deletions
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index bdd78f0fa63..628b156fcf1 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -152,7 +152,7 @@ void CreatureAI::EnterEvadeMode() if (Unit *owner = me->GetCharmerOrOwner()) { me->GetMotionMaster()->Clear(false); - me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, m_creature->GetFollowAngle(), MOTION_SLOT_ACTIVE); + me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE); } else me->GetMotionMaster()->MoveTargetedHome(); @@ -166,6 +166,6 @@ void CreatureAI::EnterEvadeMode() /*void CreatureAI::AttackedBy(Unit* attacker) { - if (!m_creature->getVictim()) + if (!me->getVictim()) AttackStart(attacker); }*/ diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index abbdc24036b..d06fe80d0fa 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -68,7 +68,6 @@ class CreatureAI : public UnitAI { protected: Creature * const me; - Creature * const m_creature; bool UpdateVictim(); bool UpdateVictimWithGaze(); @@ -83,7 +82,7 @@ class CreatureAI : public UnitAI Creature *DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float fZ, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); public: - explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_creature(c), m_MoveInLineOfSight_locked(false) {} + explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_MoveInLineOfSight_locked(false) {} virtual ~CreatureAI() {} @@ -169,7 +168,7 @@ class CreatureAI : public UnitAI /// == Fields ======================================= // Pointer to controlled by AI creature - //Creature* const m_creature; + //Creature* const me; virtual void PassengerBoarded(Unit *who, int8 seatId, bool apply) {} diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index ef6f556ca99..ce70e0961ef 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -59,7 +59,7 @@ int CreatureEventAI::Permissible(const Creature *creature) 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 = CreatureEAI_Mgr.GetCreatureEventAIMap().find(m_creature->GetEntry()); + CreatureEventAI_Event_Map::const_iterator CreatureEvents = CreatureEAI_Mgr.GetCreatureEventAIMap().find(me->GetEntry()); if (CreatureEvents != CreatureEAI_Mgr.GetCreatureEventAIMap().end()) { std::vector<CreatureEventAI_Event>::const_iterator i; @@ -71,9 +71,9 @@ CreatureEventAI::CreatureEventAI(Creature *c) : CreatureAI(c) if ((*i).event_flags & EFLAG_DEBUG_ONLY) continue; #endif - if (m_creature->GetMap()->IsDungeon()) + if (me->GetMap()->IsDungeon()) { - if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags) + if ((1 << (me->GetMap()->GetSpawnMode()+1)) & (*i).event_flags) { //event flagged for instance mode CreatureEventAIList.push_back(CreatureEventAIHolder(*i)); @@ -84,10 +84,10 @@ CreatureEventAI::CreatureEventAI(Creature *c) : CreatureAI(c) } //EventMap had events but they were not added because they must be for instance if (CreatureEventAIList.empty()) - sLog.outError("CreatureEventAI: Creature %u has events but no events added to list because of instance flags.", m_creature->GetEntry()); + sLog.outError("CreatureEventAI: Creature %u has events but no events added to list because of instance flags.", me->GetEntry()); } else - sLog.outError("CreatureEventAI: EventMap for Creature %u is empty but creature is using CreatureEventAI.", m_creature->GetEntry()); + sLog.outError("CreatureEventAI: EventMap for Creature %u is empty but creature is using CreatureEventAI.", me->GetEntry()); bEmptyList = CreatureEventAIList.empty(); Phase = 0; @@ -122,52 +122,52 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction switch (event.event_type) { case EVENT_T_TIMER: - if (!m_creature->isInCombat()) + if (!me->isInCombat()) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.timer.repeatMin,event.timer.repeatMax); + pHolder.UpdateRepeatTimer(me,event.timer.repeatMin,event.timer.repeatMax); break; case EVENT_T_TIMER_OOC: - if (m_creature->isInCombat()) + if (me->isInCombat()) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.timer.repeatMin,event.timer.repeatMax); + pHolder.UpdateRepeatTimer(me,event.timer.repeatMin,event.timer.repeatMax); break; case EVENT_T_HP: { - if (!m_creature->isInCombat() || !m_creature->GetMaxHealth()) + if (!me->isInCombat() || !me->GetMaxHealth()) return false; - uint32 perc = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth(); + uint32 perc = (me->GetHealth()*100) / me->GetMaxHealth(); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax); + pHolder.UpdateRepeatTimer(me,event.percent_range.repeatMin,event.percent_range.repeatMax); break; } case EVENT_T_MANA: { - if (!m_creature->isInCombat() || !m_creature->GetMaxPower(POWER_MANA)) + if (!me->isInCombat() || !me->GetMaxPower(POWER_MANA)) return false; - uint32 perc = (m_creature->GetPower(POWER_MANA)*100) / m_creature->GetMaxPower(POWER_MANA); + uint32 perc = (me->GetPower(POWER_MANA)*100) / me->GetMaxPower(POWER_MANA); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax); + pHolder.UpdateRepeatTimer(me,event.percent_range.repeatMin,event.percent_range.repeatMax); break; } case EVENT_T_AGGRO: break; case EVENT_T_KILL: //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.kill.repeatMin,event.kill.repeatMax); + pHolder.UpdateRepeatTimer(me,event.kill.repeatMin,event.kill.repeatMax); break; case EVENT_T_DEATH: case EVENT_T_EVADE: @@ -176,43 +176,43 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction //Spell hit is special case, param1 and param2 handled within CreatureEventAI::SpellHit //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.spell_hit.repeatMin,event.spell_hit.repeatMax); + pHolder.UpdateRepeatTimer(me,event.spell_hit.repeatMin,event.spell_hit.repeatMax); break; case EVENT_T_RANGE: //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.range.repeatMin,event.range.repeatMax); + pHolder.UpdateRepeatTimer(me,event.range.repeatMin,event.range.repeatMax); break; case EVENT_T_OOC_LOS: //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.ooc_los.repeatMin,event.ooc_los.repeatMax); + pHolder.UpdateRepeatTimer(me,event.ooc_los.repeatMin,event.ooc_los.repeatMax); break; case EVENT_T_RESET: case EVENT_T_SPAWNED: break; case EVENT_T_TARGET_HP: { - if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth()) + if (!me->isInCombat() || !me->getVictim() || !me->getVictim()->GetMaxHealth()) return false; - uint32 perc = (m_creature->getVictim()->GetHealth()*100) / m_creature->getVictim()->GetMaxHealth(); + uint32 perc = (me->getVictim()->GetHealth()*100) / me->getVictim()->GetMaxHealth(); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax); + pHolder.UpdateRepeatTimer(me,event.percent_range.repeatMin,event.percent_range.repeatMax); break; } case EVENT_T_TARGET_CASTING: - if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true)) + if (!me->isInCombat() || !me->getVictim() || !me->getVictim()->IsNonMeleeSpellCasted(false, false, true)) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.target_casting.repeatMin,event.target_casting.repeatMax); + pHolder.UpdateRepeatTimer(me,event.target_casting.repeatMin,event.target_casting.repeatMax); break; case EVENT_T_FRIENDLY_HP: { - if (!m_creature->isInCombat()) + if (!me->isInCombat()) return false; Unit* pUnit = DoSelectLowestHpFriendly(event.friendly_hp.radius, event.friendly_hp.hpDeficit); @@ -222,12 +222,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction pActionInvoker = pUnit; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.friendly_hp.repeatMin,event.friendly_hp.repeatMax); + pHolder.UpdateRepeatTimer(me,event.friendly_hp.repeatMin,event.friendly_hp.repeatMax); break; } case EVENT_T_FRIENDLY_IS_CC: { - if (!m_creature->isInCombat()) + if (!me->isInCombat()) return false; std::list<Creature*> pList; @@ -241,7 +241,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction pActionInvoker = *(pList.begin()); //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.friendly_is_cc.repeatMin,event.friendly_is_cc.repeatMax); + pHolder.UpdateRepeatTimer(me,event.friendly_is_cc.repeatMin,event.friendly_is_cc.repeatMax); break; } case EVENT_T_FRIENDLY_MISSING_BUFF: @@ -257,7 +257,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction pActionInvoker = *(pList.begin()); //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.friendly_buff.repeatMin,event.friendly_buff.repeatMax); + pHolder.UpdateRepeatTimer(me,event.friendly_buff.repeatMin,event.friendly_buff.repeatMax); break; } case EVENT_T_SUMMONED_UNIT: @@ -271,21 +271,21 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.summon_unit.repeatMin,event.summon_unit.repeatMax); + pHolder.UpdateRepeatTimer(me,event.summon_unit.repeatMin,event.summon_unit.repeatMax); break; } case EVENT_T_TARGET_MANA: { - if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxPower(POWER_MANA)) + if (!me->isInCombat() || !me->getVictim() || !me->getVictim()->GetMaxPower(POWER_MANA)) return false; - uint32 perc = (m_creature->getVictim()->GetPower(POWER_MANA)*100) / m_creature->getVictim()->GetMaxPower(POWER_MANA); + uint32 perc = (me->getVictim()->GetPower(POWER_MANA)*100) / me->getVictim()->GetMaxPower(POWER_MANA); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax); + pHolder.UpdateRepeatTimer(me,event.percent_range.repeatMin,event.percent_range.repeatMax); break; } case EVENT_T_REACHED_HOME: @@ -295,12 +295,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction { //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 = m_creature->GetAura(event.buffed.spellId); + Aura const * aura = me->GetAura(event.buffed.spellId); if (!aura || aura->GetStackAmount() < event.buffed.amount) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax); + pHolder.UpdateRepeatTimer(me,event.buffed.repeatMin,event.buffed.repeatMax); break; } case EVENT_T_TARGET_BUFFED: @@ -316,11 +316,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax); + pHolder.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.", m_creature->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(), pHolder.Event.event_id, pHolder.Event.event_type); break; } @@ -374,7 +374,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 target = owner; } } - else if ((target = m_creature->getVictim())) + else if ((target = me->getVictim())) { if (target->GetTypeId() != TYPEID_PLAYER) if (Unit* owner = target->GetOwner()) @@ -382,21 +382,21 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 target = owner; } - DoScriptText(temp, m_creature, target); + DoScriptText(temp, me, target); } break; } case ACTION_T_SET_FACTION: { if (action.set_faction.factionId) - m_creature->setFaction(action.set_faction.factionId); + me->setFaction(action.set_faction.factionId); else { - if (CreatureInfo const* ci = GetCreatureTemplateStore(m_creature->GetEntry())) + if (CreatureInfo const* ci = GetCreatureTemplateStore(me->GetEntry())) { //if no id provided, assume reset and then use default - if (m_creature->getFaction() != ci->faction_A) - m_creature->setFaction(ci->faction_A); + if (me->getFaction() != ci->faction_A) + me->setFaction(ci->faction_A); } } break; @@ -411,41 +411,41 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (CreatureInfo const* ci = GetCreatureTemplateStore(action.morph.creatureId)) { uint32 display_id = objmgr.ChooseDisplayId(0,ci); - m_creature->SetDisplayId(display_id); + me->SetDisplayId(display_id); } } //if no param1, then use value from param2 (modelId) else - m_creature->SetDisplayId(action.morph.modelId); + me->SetDisplayId(action.morph.modelId); } else - m_creature->DeMorph(); + me->DeMorph(); break; } case ACTION_T_SOUND: - m_creature->PlayDirectSound(action.sound.soundId); + me->PlayDirectSound(action.sound.soundId); break; case ACTION_T_EMOTE: - m_creature->HandleEmoteCommand(action.emote.emoteId); + me->HandleEmoteCommand(action.emote.emoteId); break; case ACTION_T_RANDOM_SOUND: { int32 temp = GetRandActionParam(rnd, action.random_sound.soundId1, action.random_sound.soundId2, action.random_sound.soundId3); if (temp >= 0) - m_creature->PlayDirectSound(temp); + me->PlayDirectSound(temp); break; } case ACTION_T_RANDOM_EMOTE: { int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3); if (temp >= 0) - m_creature->HandleEmoteCommand(temp); + me->HandleEmoteCommand(temp); break; } case ACTION_T_CAST: { Unit* target = GetTargetByType(action.cast.target, pActionInvoker); - Unit* caster = m_creature; + Unit* caster = me; if (!target) return; @@ -477,12 +477,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 //Melee current victim if flag not set if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM)) { - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) { AttackDistance = 0.0f; AttackAngle = 0.0f; - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); + me->GetMotionMaster()->MoveChase(me->getVictim(), AttackDistance, AttackAngle); } } @@ -498,7 +498,7 @@ 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, m_creature->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; } @@ -509,26 +509,26 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 Creature* pCreature = NULL; if (action.summon.duration) - pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 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); else - pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); + pCreature = 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, m_creature->GetEntry()); + 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); break; } case ACTION_T_THREAT_SINGLE_PCT: if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker)) - m_creature->getThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); + me->getThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); break; case ACTION_T_THREAT_ALL_PCT: { - std::list<HostileReference*>& threatList = m_creature->getThreatManager().getThreatList(); + std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::iterator i = threatList.begin(); i != threatList.end(); ++i) - if (Unit* Temp = Unit::GetUnit(*m_creature,(*i)->getUnitGuid())) - m_creature->getThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); + if (Unit* Temp = Unit::GetUnit(*me,(*i)->getUnitGuid())) + me->getThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); break; } case ACTION_T_QUEST_EVENT: @@ -539,7 +539,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_CAST_EVENT: if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker)) if (target->GetTypeId() == TYPEID_PLAYER) - target->ToPlayer()->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetGUID(), action.cast_event.spellId); + target->ToPlayer()->CastedCreatureOrGO(action.cast_event.creatureId, me->GetGUID(), action.cast_event.spellId); break; case ACTION_T_SET_UNIT_FIELD: { @@ -575,30 +575,30 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 //Allow movement (create new targeted movement gen only if idle) if (CombatMovementEnabled) { - Unit* victim = m_creature->getVictim(); - if (m_creature->isInCombat() && victim) + Unit* victim = me->getVictim(); + if (me->isInCombat() && victim) { if (action.combat_movement.melee) { - m_creature->addUnitState(UNIT_STAT_MELEE_ATTACKING); - m_creature->SendMeleeAttackStart(victim); + me->addUnitState(UNIT_STAT_MELEE_ATTACKING); + me->SendMeleeAttackStart(victim); } - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE) - m_creature->GetMotionMaster()->MoveChase(victim, AttackDistance, AttackAngle); // Targeted movement generator will start melee automatically, no need to send it explicitly + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE) + me->GetMotionMaster()->MoveChase(victim, AttackDistance, AttackAngle); // Targeted movement generator will start melee automatically, no need to send it explicitly } } else { - if (m_creature->isInCombat()) + if (me->isInCombat()) { - Unit* victim = m_creature->getVictim(); + Unit* victim = me->getVictim(); if (action.combat_movement.melee && victim) { - m_creature->clearUnitState(UNIT_STAT_MELEE_ATTACKING); - m_creature->SendMeleeAttackStop(victim); + me->clearUnitState(UNIT_STAT_MELEE_ATTACKING); + me->SendMeleeAttackStop(victim); } - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) - m_creature->GetMotionMaster()->MoveIdle(); + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + me->GetMotionMaster()->MoveIdle(); } } break; @@ -610,12 +610,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 int32 new_phase = int32(Phase)+action.set_inc_phase.step; if (new_phase < 0) { - sLog.outErrorDb("CreatureEventAI: Event %d decrease Phase under 0. CreatureEntry = %d", EventId, m_creature->GetEntry()); + sLog.outErrorDb("CreatureEventAI: Event %d decrease Phase under 0. CreatureEntry = %d", EventId, me->GetEntry()); Phase = 0; } else if (new_phase >= MAX_PHASE) { - sLog.outErrorDb("CreatureEventAI: Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE-1, MAX_PHASE-1, m_creature->GetEntry()); + sLog.outErrorDb("CreatureEventAI: Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE-1, MAX_PHASE-1, me->GetEntry()); Phase = MAX_PHASE-1; } else @@ -627,23 +627,23 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 EnterEvadeMode(); break; case ACTION_T_FLEE_FOR_ASSIST: - m_creature->DoFleeToGetAssistance(); + me->DoFleeToGetAssistance(); break; case ACTION_T_QUEST_EVENT_ALL: if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER) { - if (Unit* Temp = Unit::GetUnit(*m_creature,pActionInvoker->GetGUID())) + if (Unit* Temp = Unit::GetUnit(*me,pActionInvoker->GetGUID())) if (Temp->GetTypeId() == TYPEID_PLAYER) - Temp->ToPlayer()->GroupEventHappens(action.quest_event_all.questId,m_creature); + Temp->ToPlayer()->GroupEventHappens(action.quest_event_all.questId,me); } break; case ACTION_T_CAST_EVENT_ALL: { - std::list<HostileReference*>& threatList = m_creature->getThreatManager().getThreatList(); + std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::iterator i = threatList.begin(); i != threatList.end(); ++i) - if (Unit* Temp = Unit::GetUnit(*m_creature,(*i)->getUnitGuid())) + if (Unit* Temp = Unit::GetUnit(*me,(*i)->getUnitGuid())) if (Temp->GetTypeId() == TYPEID_PLAYER) - Temp->ToPlayer()->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetGUID(), action.cast_event_all.spellId); + Temp->ToPlayer()->CastedCreatureOrGO(action.cast_event_all.creatureId, me->GetGUID(), action.cast_event_all.spellId); break; } case ACTION_T_REMOVEAURASFROMSPELL: @@ -656,7 +656,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (CombatMovementEnabled) { - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); + me->GetMotionMaster()->MoveChase(me->getVictim(), AttackDistance, AttackAngle); } break; case ACTION_T_RANDOM_PHASE: @@ -666,7 +666,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (action.random_phase_range.phaseMin <= action.random_phase_range.phaseMax) 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, m_creature->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: { @@ -675,18 +675,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 CreatureEventAI_Summon_Map::const_iterator i = CreatureEAI_Mgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId); if (i == CreatureEAI_Mgr.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, m_creature->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; if ((*i).second.SpawnTimeSecs) - pCreature = m_creature->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); + 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); else - pCreature = m_creature->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); + 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); if (!pCreature) - sLog.outErrorDb("CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry()); + 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); @@ -694,22 +694,22 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } case ACTION_T_KILLED_MONSTER: //first attempt player who tapped creature - if (Player* pPlayer = m_creature->GetLootRecipient()) - pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); + if (Player* pPlayer = me->GetLootRecipient()) + pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, me); 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, m_creature); + pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, me); } break; case ACTION_T_SET_INST_DATA: { - InstanceData* pInst = (InstanceData*)m_creature->GetInstanceData(); + InstanceData* pInst = (InstanceData*)me->GetInstanceData(); if (!pInst) { - sLog.outErrorDb("CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", EventId, m_creature->GetEntry()); + sLog.outErrorDb("CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", EventId, me->GetEntry()); return; } @@ -721,14 +721,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 Unit* target = GetTargetByType(action.set_inst_data64.target, pActionInvoker); if (!target) { - sLog.outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry()); + sLog.outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, me->GetEntry()); return; } - InstanceData* pInst = (InstanceData*)m_creature->GetInstanceData(); + InstanceData* pInst = (InstanceData*)me->GetInstanceData(); if (!pInst) { - sLog.outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", EventId, m_creature->GetEntry()); + sLog.outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", EventId, me->GetEntry()); return; } @@ -736,32 +736,32 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; } case ACTION_T_UPDATE_TEMPLATE: - if (m_creature->GetEntry() == action.update_template.creatureId) + if (me->GetEntry() == action.update_template.creatureId) { - sLog.outErrorDb("CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, m_creature->GetEntry()); + sLog.outErrorDb("CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, me->GetEntry()); return; } - m_creature->UpdateEntry(action.update_template.creatureId, action.update_template.team ? HORDE : ALLIANCE); + me->UpdateEntry(action.update_template.creatureId, action.update_template.team ? HORDE : ALLIANCE); break; case ACTION_T_DIE: - if (m_creature->isDead()) + if (me->isDead()) { - sLog.outErrorDb("CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry()); + sLog.outErrorDb("CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, me->GetEntry()); return; } - m_creature->Kill(m_creature); + me->Kill(me); break; case ACTION_T_ZONE_COMBAT_PULSE: { - m_creature->SetInCombatWithZone(); + me->SetInCombatWithZone(); break; } case ACTION_T_CALL_FOR_HELP: { - m_creature->CallForHelp(action.call_for_help.radius); + me->CallForHelp(action.call_for_help.radius); break; } break; @@ -797,29 +797,29 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 GameObject* pObject = NULL; float x,y,z; - m_creature->GetPosition(x,y,z); - pObject = m_creature->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2); + me->GetPosition(x,y,z); + pObject = me->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2); if (!pObject) { - sLog.outErrorDb("TSCR: EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.raw.param1, EventId, m_creature->GetEntry()); + sLog.outErrorDb("TSCR: EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.raw.param1, EventId, me->GetEntry()); } break; } case ACTION_T_SET_SHEATH: { - m_creature->SetSheath(SheathState(action.set_sheath.sheath)); + me->SetSheath(SheathState(action.set_sheath.sheath)); break; } case ACTION_T_FORCE_DESPAWN: { - m_creature->ForcedDespawn(action.forced_despawn.msDelay); + me->ForcedDespawn(action.forced_despawn.msDelay); break; } case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: { if (action.invincibility_hp_level.is_percent) - InvinceabilityHpLevel = m_creature->GetMaxHealth()*action.invincibility_hp_level.hp_level/100; + InvinceabilityHpLevel = me->GetMaxHealth()*action.invincibility_hp_level.hp_level/100; else InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; break; @@ -865,7 +865,7 @@ void CreatureEventAI::Reset() //Reset all out of combat timers case EVENT_T_TIMER_OOC: { - if ((*i).UpdateRepeatTimer(m_creature,event.timer.initialMin,event.timer.initialMax)) + if ((*i).UpdateRepeatTimer(me,event.timer.initialMin,event.timer.initialMax)) (*i).Enabled = true; break; } @@ -880,7 +880,7 @@ void CreatureEventAI::Reset() void CreatureEventAI::JustReachedHome() { - m_creature->LoadCreaturesAddon(); + me->LoadCreaturesAddon(); if (!bEmptyList) { @@ -967,7 +967,7 @@ void CreatureEventAI::EnterCombat(Unit *enemy) break; //Reset all in combat timers case EVENT_T_TIMER: - if ((*i).UpdateRepeatTimer(m_creature,event.timer.initialMin,event.timer.initialMax)) + if ((*i).UpdateRepeatTimer(me,event.timer.initialMin,event.timer.initialMax)) (*i).Enabled = true; break; //All normal events need to be re-enabled and their time set to 0 @@ -988,15 +988,15 @@ void CreatureEventAI::AttackStart(Unit *who) if (!who) return; - if (m_creature->Attack(who, MeleeEnabled)) + if (me->Attack(who, MeleeEnabled)) { if (CombatMovementEnabled) { - m_creature->GetMotionMaster()->MoveChase(who, AttackDistance, AttackAngle); + me->GetMotionMaster()->MoveChase(who, AttackDistance, AttackAngle); } else { - m_creature->GetMotionMaster()->MoveIdle(); + me->GetMotionMaster()->MoveIdle(); } } } @@ -1017,11 +1017,11 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who) float fMaxAllowedRange = (*itr).Event.ooc_los.maxRange; //if range is ok and we are actually in LOS - if (m_creature->IsWithinDistInMap(who, fMaxAllowedRange) && m_creature->IsWithinLOSInMap(who)) + if (me->IsWithinDistInMap(who, fMaxAllowedRange) && me->IsWithinLOSInMap(who)) { //if friendly event&&who is not hostile OR hostile event&&who is hostile - if (((*itr).Event.ooc_los.noHostile && !m_creature->IsHostileTo(who)) || - ((!(*itr).Event.ooc_los.noHostile) && m_creature->IsHostileTo(who))) + if (((*itr).Event.ooc_los.noHostile && !me->IsHostileTo(who)) || + ((!(*itr).Event.ooc_los.noHostile) && me->IsHostileTo(who))) ProcessEvent(*itr, who); } } @@ -1092,8 +1092,8 @@ void CreatureEventAI::UpdateAI(const uint32 diff) break; case EVENT_T_RANGE: if (me->getVictim()) - if (m_creature->IsInMap(m_creature->getVictim())) - if (m_creature->IsInRange(m_creature->getVictim(),(float)(*i).Event.range.minDist,(float)(*i).Event.range.maxDist)) + if (me->IsInMap(me->getVictim())) + if (me->IsInRange(me->getVictim(),(float)(*i).Event.range.minDist,(float)(*i).Event.range.maxDist)) ProcessEvent(*i); break; } @@ -1141,9 +1141,9 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoke switch (Target) { case TARGET_T_SELF: - return m_creature; + return me; case TARGET_T_HOSTILE: - return m_creature->getVictim(); + return me->getVictim(); case TARGET_T_HOSTILE_SECOND_AGGRO: return SelectTarget(SELECT_TARGET_TOPAGGRO,1); case TARGET_T_HOSTILE_LAST_AGGRO: @@ -1161,15 +1161,15 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoke Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) { - CellPair p(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Unit* pUnit = NULL; - Trinity::MostHPMissingInRange u_check(m_creature, range, MinHPDiff); - Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(m_creature, pUnit, u_check); + Trinity::MostHPMissingInRange u_check(me, range, MinHPDiff); + Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, pUnit, u_check); /* typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; @@ -1177,38 +1177,38 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) */ TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher); - cell.Visit(p, grid_unit_searcher, *m_creature->GetMap(), *m_creature, range); + cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, range); return pUnit; } void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range) { - CellPair p(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Trinity::FriendlyCCedInRange u_check(m_creature, range); - Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(m_creature, _list, u_check); + Trinity::FriendlyCCedInRange u_check(me, range); + Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, _list, u_check); TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher); - cell.Visit(p, grid_creature_searcher, *m_creature->GetMap()); + cell.Visit(p, grid_creature_searcher, *me->GetMap()); } void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid) { - CellPair p(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Trinity::FriendlyMissingBuffInRange u_check(m_creature, range, spellid); - Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(m_creature, _list, u_check); + Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid); + Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, _list, u_check); TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher); - cell.Visit(p, grid_creature_searcher, *m_creature->GetMap()); + cell.Visit(p, grid_creature_searcher, *me->GetMap()); } //********************************* @@ -1311,7 +1311,7 @@ bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Trigge return false; //Unit is out of range of this spell - if (!m_creature->IsInRange(Target,TempRange->minRangeHostile,TempRange->maxRangeHostile)) + if (!me->IsInRange(Target,TempRange->minRangeHostile,TempRange->maxRangeHostile)) return false; return true; @@ -1341,12 +1341,12 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) void CreatureEventAI::DamageTaken(Unit* done_by, uint32& damage) { - if (InvinceabilityHpLevel > 0 && m_creature->GetHealth() < InvinceabilityHpLevel+damage) + if (InvinceabilityHpLevel > 0 && me->GetHealth() < InvinceabilityHpLevel+damage) { - if (m_creature->GetHealth() <= InvinceabilityHpLevel) + if (me->GetHealth() <= InvinceabilityHpLevel) damage = 0; else - damage = m_creature->GetHealth() - InvinceabilityHpLevel; + damage = me->GetHealth() - InvinceabilityHpLevel; } } @@ -1362,12 +1362,12 @@ bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& e return true; case SPAWNED_EVENT_MAP: // map ID check - return m_creature->GetMapId() == event.spawned.conditionValue1; + return me->GetMapId() == event.spawned.conditionValue1; case SPAWNED_EVENT_ZONE: { // zone ID check uint32 zone, area; - m_creature->GetZoneAndAreaId(zone,area); + me->GetZoneAndAreaId(zone,area); return zone == event.spawned.conditionValue1 || area == event.spawned.conditionValue1; } default: diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 96845524131..921d0facc12 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -123,7 +123,7 @@ enum EventAI_ActionType enum Target { - //Self (m_creature) + //Self (me) TARGET_T_SELF = 0, //Self cast //Hostile targets (if pet then returns pet owner) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 9143f14d0dd..7b860af1d1e 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -943,7 +943,7 @@ namespace Trinity class NearestHostileUnitInAttackDistanceCheck { public: - explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0) : m_creature(creature) + explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0) : me(creature) { m_range = (dist == 0 ? 9999 : dist); m_force = (dist == 0 ? false : true); @@ -951,26 +951,26 @@ namespace Trinity bool operator()(Unit* u) { // TODO: addthreat for every enemy in range? - if (!m_creature->IsWithinDistInMap(u, m_range)) + if (!me->IsWithinDistInMap(u, m_range)) return false; if (m_force) { - if (!m_creature->canAttack(u)) + if (!me->canAttack(u)) return false; } else { - if (!m_creature->canStartAttack(u, false)) + if (!me->canStartAttack(u, false)) return false; } - m_range = m_creature->GetDistance(u); + m_range = me->GetDistance(u); return true; } float GetLastRange() const { return m_range; } private: - Creature const *m_creature; + Creature const *me; float m_range; bool m_force; NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&); diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index dbabea7a6af..108e15b607a 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -40,15 +40,15 @@ GuardAI::GuardAI(Creature *c) : CreatureAI(c), i_victimGuid(0), i_state(STATE_NO void GuardAI::MoveInLineOfSight(Unit *u) { // Ignore Z for flying creatures - if (!m_creature->canFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE) + if (!me->canFly() && me->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE) return; - if (!m_creature->getVictim() && m_creature->canAttack(u) && - (u->IsHostileToPlayers() || m_creature->IsHostileTo(u) /*|| u->getVictim() && m_creature->IsFriendlyTo(u->getVictim())*/) && - u->isInAccessiblePlaceFor(m_creature)) + if (!me->getVictim() && me->canAttack(u) && + (u->IsHostileToPlayers() || me->IsHostileTo(u) /*|| u->getVictim() && me->IsFriendlyTo(u->getVictim())*/) && + u->isInAccessiblePlaceFor(me)) { - float attackRadius = m_creature->GetAttackDistance(u); - if (m_creature->IsWithinDistInMap(u,attackRadius)) + float attackRadius = me->GetAttackDistance(u); + if (me->IsWithinDistInMap(u,attackRadius)) { //Need add code to let guard support player AttackStart(u); @@ -59,80 +59,80 @@ void GuardAI::MoveInLineOfSight(Unit *u) void GuardAI::EnterEvadeMode() { - if (!m_creature->isAlive()) + if (!me->isAlive()) { - DEBUG_LOG("Creature stopped attacking because he's dead [guid=%u]", m_creature->GetGUIDLow()); - m_creature->GetMotionMaster()->MoveIdle(); + DEBUG_LOG("Creature stopped attacking because he's dead [guid=%u]", me->GetGUIDLow()); + me->GetMotionMaster()->MoveIdle(); i_state = STATE_NORMAL; i_victimGuid = 0; - m_creature->CombatStop(true); - m_creature->DeleteThreatList(); + me->CombatStop(true); + me->DeleteThreatList(); return; } - Unit* victim = ObjectAccessor::GetUnit(*m_creature, i_victimGuid); + Unit* victim = ObjectAccessor::GetUnit(*me, i_victimGuid); if (!victim) { - DEBUG_LOG("Creature stopped attacking because victim is non exist [guid=%u]", m_creature->GetGUIDLow()); + DEBUG_LOG("Creature stopped attacking because victim is non exist [guid=%u]", me->GetGUIDLow()); } else if (!victim ->isAlive()) { - DEBUG_LOG("Creature stopped attacking because victim is dead [guid=%u]", m_creature->GetGUIDLow()); + DEBUG_LOG("Creature stopped attacking because victim is dead [guid=%u]", me->GetGUIDLow()); } else if (victim ->HasStealthAura()) { - DEBUG_LOG("Creature stopped attacking because victim is using stealth [guid=%u]", m_creature->GetGUIDLow()); + DEBUG_LOG("Creature stopped attacking because victim is using stealth [guid=%u]", me->GetGUIDLow()); } else if (victim ->isInFlight()) { - DEBUG_LOG("Creature stopped attacking because victim is flying away [guid=%u]", m_creature->GetGUIDLow()); + DEBUG_LOG("Creature stopped attacking because victim is flying away [guid=%u]", me->GetGUIDLow()); } else { - DEBUG_LOG("Creature stopped attacking because victim outran him [guid=%u]", m_creature->GetGUIDLow()); + DEBUG_LOG("Creature stopped attacking because victim outran him [guid=%u]", me->GetGUIDLow()); } - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); + me->RemoveAllAuras(); + me->DeleteThreatList(); i_victimGuid = 0; - m_creature->CombatStop(true); + me->CombatStop(true); i_state = STATE_NORMAL; // Remove TargetedMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) - m_creature->GetMotionMaster()->MoveTargetedHome(); + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + me->GetMotionMaster()->MoveTargetedHome(); } void GuardAI::UpdateAI(const uint32 /*diff*/) { - // update i_victimGuid if m_creature->getVictim() !=0 and changed + // update i_victimGuid if me->getVictim() !=0 and changed if (!UpdateVictim()) return; - i_victimGuid = m_creature->getVictim()->GetGUID(); + i_victimGuid = me->getVictim()->GetGUID(); - if (m_creature->isAttackReady()) + if (me->isAttackReady()) { - if (m_creature->IsWithinMeleeRange(m_creature->getVictim())) + if (me->IsWithinMeleeRange(me->getVictim())) { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); + me->AttackerStateUpdate(me->getVictim()); + me->resetAttackTimer(); } } } bool GuardAI::IsVisible(Unit *pl) const { - return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_SIGHT_GUARDER)) - && pl->isVisibleForOrDetect(m_creature,true); + return me->IsWithinDist(pl,sWorld.getConfig(CONFIG_SIGHT_GUARDER)) + && pl->isVisibleForOrDetect(me,true); } void GuardAI::JustDied(Unit *killer) { if (Player* pkiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) - m_creature->SendZoneUnderAttackMessage(pkiller); + me->SendZoneUnderAttackMessage(pkiller); } diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index e8b21e807cf..09ec8fae53f 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -51,36 +51,36 @@ void PetAI::EnterEvadeMode() bool PetAI::_needToStop() const { // This is needed for charmed creatures, as once their target was reset other effects can trigger threat - if (m_creature->isCharmed() && m_creature->getVictim() == m_creature->GetCharmer()) + if (me->isCharmed() && me->getVictim() == me->GetCharmer()) return true; - return !m_creature->canAttack(m_creature->getVictim()); + return !me->canAttack(me->getVictim()); } void PetAI::_stopAttack() { - if (!m_creature->isAlive()) + if (!me->isAlive()) { - DEBUG_LOG("Creature stoped attacking cuz his dead [guid=%u]", m_creature->GetGUIDLow()); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->CombatStop(); - m_creature->getHostileRefManager().deleteReferences(); + DEBUG_LOG("Creature stoped attacking cuz his dead [guid=%u]", me->GetGUIDLow()); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveIdle(); + me->CombatStop(); + me->getHostileRefManager().deleteReferences(); return; } - m_creature->AttackStop(); + me->AttackStop(); me->GetCharmInfo()->SetIsCommandAttack(false); HandleReturnMovement(); } void PetAI::UpdateAI(const uint32 diff) { - if (!m_creature->isAlive()) + if (!me->isAlive()) return; - Unit* owner = m_creature->GetCharmerOrOwner(); + Unit* owner = me->GetCharmerOrOwner(); if (m_updateAlliesTimer <= diff) // UpdateAllies self set update timer @@ -88,19 +88,19 @@ void PetAI::UpdateAI(const uint32 diff) else m_updateAlliesTimer -= diff; - // m_creature->getVictim() can't be used for check in case stop fighting, m_creature->getVictim() clear at Unit death etc. - if (m_creature->getVictim()) + // me->getVictim() can't be used for check in case stop fighting, me->getVictim() clear at Unit death etc. + if (me->getVictim()) { if (_needToStop()) { - DEBUG_LOG("Pet AI stoped attacking [guid=%u]", m_creature->GetGUIDLow()); + DEBUG_LOG("Pet AI stoped attacking [guid=%u]", me->GetGUIDLow()); _stopAttack(); return; } DoMeleeAttackIfReady(); } - else if (owner && m_creature->GetCharmInfo()) //no victim + else if (owner && me->GetCharmInfo()) //no victim { Unit *nextTarget = SelectNextTarget(); @@ -109,21 +109,21 @@ void PetAI::UpdateAI(const uint32 diff) else HandleReturnMovement(); } - else if (owner && !m_creature->hasUnitState(UNIT_STAT_FOLLOW)) // no charm info and no victim - m_creature->GetMotionMaster()->MoveFollow(owner,PET_FOLLOW_DIST, m_creature->GetFollowAngle()); + else if (owner && !me->hasUnitState(UNIT_STAT_FOLLOW)) // no charm info and no victim + me->GetMotionMaster()->MoveFollow(owner,PET_FOLLOW_DIST, me->GetFollowAngle()); if (!me->GetCharmInfo()) return; // Autocast (casted only in combat or persistent spells in any state) - if (m_creature->GetGlobalCooldown() == 0 && !m_creature->hasUnitState(UNIT_STAT_CASTING)) + if (me->GetGlobalCooldown() == 0 && !me->hasUnitState(UNIT_STAT_CASTING)) { typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList; TargetSpellList targetSpellStore; - for (uint8 i = 0; i < m_creature->GetPetAutoSpellSize(); ++i) + for (uint8 i = 0; i < me->GetPetAutoSpellSize(); ++i) { - uint32 spellID = m_creature->GetPetAutoSpellOnPos(i); + uint32 spellID = me->GetPetAutoSpellOnPos(i); if (!spellID) continue; @@ -161,12 +161,12 @@ void PetAI::UpdateAI(const uint32 diff) continue; } - Spell *spell = new Spell(m_creature, spellInfo, false, 0); + Spell *spell = new Spell(me, spellInfo, false, 0); // Fix to allow pets on STAY to autocast if (me->getVictim() && _CanAttack(me->getVictim()) && spell->CanAutoCast(me->getVictim())) { - targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(m_creature->getVictim(), spell)); + targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(me->getVictim(), spell)); continue; } else @@ -174,7 +174,7 @@ void PetAI::UpdateAI(const uint32 diff) bool spellUsed = false; for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar) { - Unit* Target = ObjectAccessor::GetUnit(*m_creature,*tar); + Unit* Target = ObjectAccessor::GetUnit(*me,*tar); //only buff targets that are in combat, unless the spell can only be cast while out of combat if (!Target) @@ -205,17 +205,17 @@ void PetAI::UpdateAI(const uint32 diff) SpellCastTargets targets; targets.setUnitTarget(target); - if (!m_creature->HasInArc(M_PI, target)) + if (!me->HasInArc(M_PI, target)) { - m_creature->SetInFront(target); + me->SetInFront(target); if (target && target->GetTypeId() == TYPEID_PLAYER) - m_creature->SendUpdateToPlayer(target->ToPlayer()); + me->SendUpdateToPlayer(target->ToPlayer()); if (owner && owner->GetTypeId() == TYPEID_PLAYER) - m_creature->SendUpdateToPlayer(owner->ToPlayer()); + me->SendUpdateToPlayer(owner->ToPlayer()); } - m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id); + me->AddCreatureSpellCooldown(spell->m_spellInfo->Id); spell->prepare(&targets); } @@ -228,7 +228,7 @@ void PetAI::UpdateAI(const uint32 diff) void PetAI::UpdateAllies() { - Unit* owner = m_creature->GetCharmerOrOwner(); + Unit* owner = me->GetCharmerOrOwner(); Group *pGroup = NULL; m_updateAlliesTimer = 10*IN_MILISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance @@ -246,7 +246,7 @@ void PetAI::UpdateAllies() return; m_AllySet.clear(); - m_AllySet.insert(m_creature->GetGUID()); + m_AllySet.insert(me->GetGUID()); if (pGroup) //add group { for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp index 661d9ff3cb7..fdca6314747 100644 --- a/src/game/ReactorAI.cpp +++ b/src/game/ReactorAI.cpp @@ -44,16 +44,16 @@ ReactorAI::MoveInLineOfSight(Unit *) void ReactorAI::UpdateAI(const uint32 /*time_diff*/) { - // update i_victimGuid if m_creature->getVictim() !=0 and changed + // update i_victimGuid if me->getVictim() !=0 and changed if (!UpdateVictim()) return; - if (m_creature->isAttackReady()) + if (me->isAttackReady()) { - if (m_creature->IsWithinMeleeRange(m_creature->getVictim())) + if (me->IsWithinMeleeRange(me->getVictim())) { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); + me->AttackerStateUpdate(me->getVictim()); + me->resetAttackTimer(); } } } diff --git a/src/game/ScriptedCreature.cpp b/src/game/ScriptedCreature.cpp index 9e5bdb4c3f6..48f17463824 100644 --- a/src/game/ScriptedCreature.cpp +++ b/src/game/ScriptedCreature.cpp @@ -22,7 +22,7 @@ void SummonList::DoZoneInCombat(uint32 entry) { for (iterator i = begin(); i != end();) { - Creature *summon = Unit::GetCreature(*m_creature, *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, uint32 info) { for (iterator i = begin(); i != end();) { - Creature *summon = Unit::GetCreature(*m_creature, *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(*m_creature, *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(*m_creature, *begin()); + Creature *summon = Unit::GetCreature(*me, *begin()); if (!summon) erase(begin()); else @@ -82,13 +82,13 @@ void SummonList::DespawnAll() } ScriptedAI::ScriptedAI(Creature* pCreature) : CreatureAI(pCreature), - m_creature(pCreature), + me(pCreature), IsFleeing(false), m_bCombatMovement(true), m_uiEvadeCheckCooldown(2500) { - m_heroicMode = m_creature->GetMap()->IsHeroic(); - m_difficulty = Difficulty(m_creature->GetMap()->GetSpawnMode()); + m_heroicMode = me->GetMap()->IsHeroic(); + m_difficulty = Difficulty(me->GetMap()->GetSpawnMode()); } void ScriptedAI::AttackStartNoMove(Unit* pWho) @@ -96,7 +96,7 @@ void ScriptedAI::AttackStartNoMove(Unit* pWho) if (!pWho) return; - if (m_creature->Attack(pWho, false)) + if (me->Attack(pWho, false)) DoStartNoMovement(pWho); } @@ -106,13 +106,13 @@ void ScriptedAI::UpdateAI(const uint32 uiDiff) if (!UpdateVictim()) return; - if (m_creature->isAttackReady()) + if (me->isAttackReady()) { //If we are within range melee the target - if (m_creature->IsWithinMeleeRange(m_creature->getVictim())) + if (me->IsWithinMeleeRange(me->getVictim())) { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); + me->AttackerStateUpdate(me->getVictim()); + me->resetAttackTimer(); } } } @@ -120,7 +120,7 @@ void ScriptedAI::UpdateAI(const uint32 uiDiff) void ScriptedAI::DoStartMovement(Unit* pVictim, float fDistance, float fAngle) { if (pVictim) - m_creature->GetMotionMaster()->MoveChase(pVictim, fDistance, fAngle); + me->GetMotionMaster()->MoveChase(pVictim, fDistance, fAngle); } void ScriptedAI::DoStartNoMovement(Unit* pVictim) @@ -128,22 +128,22 @@ void ScriptedAI::DoStartNoMovement(Unit* pVictim) if (!pVictim) return; - m_creature->GetMotionMaster()->MoveIdle(); + me->GetMotionMaster()->MoveIdle(); } void ScriptedAI::DoStopAttack() { - if (m_creature->getVictim()) - m_creature->AttackStop(); + if (me->getVictim()) + me->AttackStop(); } void ScriptedAI::DoCastSpell(Unit* pTarget, SpellEntry const* pSpellInfo, bool bTriggered) { - if (!pTarget || m_creature->IsNonMeleeSpellCasted(false)) + if (!pTarget || me->IsNonMeleeSpellCasted(false)) return; - m_creature->StopMoving(); - m_creature->CastSpell(pTarget, pSpellInfo, bTriggered); + me->StopMoving(); + me->CastSpell(pTarget, pSpellInfo, bTriggered); } void ScriptedAI::DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId) @@ -162,13 +162,13 @@ void ScriptedAI::DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId) Creature* ScriptedAI::DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime) { - return m_creature->SummonCreature(uiId, m_creature->GetPositionX()+fX, m_creature->GetPositionY()+fY, m_creature->GetPositionZ()+fZ, fAngle, (TempSummonType)uiType, uiDespawntime); + return me->SummonCreature(uiId, me->GetPositionX()+fX, me->GetPositionY()+fY, me->GetPositionZ()+fZ, fAngle, (TempSummonType)uiType, uiDespawntime); } Unit* ScriptedAI::SelectUnit(SelectAggroTarget pTarget, uint32 uiPosition) { //ThreatList m_threatlist; - std::list<HostileReference*>& threatlist = m_creature->getThreatManager().getThreatList(); + std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); std::list<HostileReference*>::iterator itr = threatlist.begin(); std::list<HostileReference*>::reverse_iterator ritr = threatlist.rbegin(); @@ -179,17 +179,17 @@ Unit* ScriptedAI::SelectUnit(SelectAggroTarget pTarget, uint32 uiPosition) { case SELECT_TARGET_RANDOM: advance (itr , uiPosition + (rand() % (threatlist.size() - uiPosition))); - return Unit::GetUnit((*m_creature),(*itr)->getUnitGuid()); + return Unit::GetUnit((*me),(*itr)->getUnitGuid()); break; case SELECT_TARGET_TOPAGGRO: advance (itr , uiPosition); - return Unit::GetUnit((*m_creature),(*itr)->getUnitGuid()); + return Unit::GetUnit((*me),(*itr)->getUnitGuid()); break; case SELECT_TARGET_BOTTOMAGGRO: advance (ritr , uiPosition); - return Unit::GetUnit((*m_creature),(*ritr)->getUnitGuid()); + return Unit::GetUnit((*me),(*ritr)->getUnitGuid()); break; default: @@ -206,7 +206,7 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, int32 uiSchool, int32 u return false; //Silenced so we can't cast - if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) + if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) return false; //Using the extended script system we first create a list of viable spells @@ -221,7 +221,7 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, int32 uiSchool, int32 u //Check if each spell is viable(set it to null if not) for (uint32 i = 0; i < CREATURE_MAX_SPELLS; i++) { - pTempSpell = GetSpellStore()->LookupEntry(m_creature->m_spells[i]); + pTempSpell = GetSpellStore()->LookupEntry(me->m_spells[i]); //This spell doesn't exist if (!pTempSpell) @@ -229,11 +229,11 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, int32 uiSchool, int32 u // Targets and Effects checked first as most used restrictions //Check the spell targets if specified - if (selectTargets && !(SpellSummary[m_creature->m_spells[i]].Targets & (1 << (selectTargets-1)))) + if (selectTargets && !(SpellSummary[me->m_spells[i]].Targets & (1 << (selectTargets-1)))) continue; //Check the type of spell if we are looking for a specific spell type - if (selectEffects && !(SpellSummary[m_creature->m_spells[i]].Effects & (1 << (selectEffects-1)))) + if (selectEffects && !(SpellSummary[me->m_spells[i]].Effects & (1 << (selectEffects-1)))) continue; //Check for school if specified @@ -252,7 +252,7 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, int32 uiSchool, int32 u continue; //Continue if we don't have the mana to actually cast this spell - if (pTempSpell->manaCost > m_creature->GetPower((Powers)pTempSpell->powerType)) + if (pTempSpell->manaCost > me->GetPower((Powers)pTempSpell->powerType)) continue; //Get the Range @@ -263,13 +263,13 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, int32 uiSchool, int32 u continue; //Check if the spell meets our range requirements - if (fRangeMin && m_creature->GetSpellMinRangeForTarget(pTarget, pTempRange) < fRangeMin) + if (fRangeMin && me->GetSpellMinRangeForTarget(pTarget, pTempRange) < fRangeMin) continue; - if (fRangeMax && m_creature->GetSpellMaxRangeForTarget(pTarget, pTempRange) > fRangeMax) + if (fRangeMax && me->GetSpellMaxRangeForTarget(pTarget, pTempRange) > fRangeMax) continue; //Check if our target is in range - if (m_creature->IsWithinDistInMap(pTarget, m_creature->GetSpellMinRangeForTarget(pTarget, pTempRange)) || !m_creature->IsWithinDistInMap(pTarget, m_creature->GetSpellMaxRangeForTarget(pTarget, pTempRange))) + if (me->IsWithinDistInMap(pTarget, me->GetSpellMinRangeForTarget(pTarget, pTempRange)) || !me->IsWithinDistInMap(pTarget, me->GetSpellMaxRangeForTarget(pTarget, pTempRange))) continue; //All good so lets add it to the spell list @@ -305,7 +305,7 @@ bool ScriptedAI::CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggere return false; //Unit is out of range of this spell - if (me->IsInRange(pTarget, m_creature->GetSpellMinRangeForTarget(pTarget, pTempRange), m_creature->GetSpellMaxRangeForTarget(pTarget, pTempRange))) + if (me->IsInRange(pTarget, me->GetSpellMinRangeForTarget(pTarget, pTempRange), me->GetSpellMaxRangeForTarget(pTarget, pTempRange))) return false; return true; @@ -398,17 +398,17 @@ void FillSpellSummary() void ScriptedAI::DoResetThreat() { - if (!m_creature->CanHaveThreatList() || m_creature->getThreatManager().isThreatListEmpty()) + if (!me->CanHaveThreatList() || me->getThreatManager().isThreatListEmpty()) { - error_log("TSCR: DoResetThreat called for creature that either cannot have threat list or has empty threat list (m_creature entry = %d)", m_creature->GetEntry()); + error_log("TSCR: DoResetThreat called for creature that either cannot have threat list or has empty threat list (me entry = %d)", me->GetEntry()); return; } - std::list<HostileReference*>& threatlist = m_creature->getThreatManager().getThreatList(); + std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { - Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); + Unit* pUnit = Unit::GetUnit((*me), (*itr)->getUnitGuid()); if (pUnit && DoGetThreat(pUnit)) DoModifyThreatPercent(pUnit, -100); @@ -418,19 +418,19 @@ void ScriptedAI::DoResetThreat() float ScriptedAI::DoGetThreat(Unit* pUnit) { if (!pUnit) return 0.0f; - return m_creature->getThreatManager().getThreat(pUnit); + return me->getThreatManager().getThreat(pUnit); } void ScriptedAI::DoModifyThreatPercent(Unit* pUnit, int32 pct) { if (!pUnit) return; - m_creature->getThreatManager().modifyThreatPercent(pUnit, pct); + me->getThreatManager().modifyThreatPercent(pUnit, pct); } void ScriptedAI::DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime) { - m_creature->Relocate(fX, fY, fZ); - m_creature->SendMonsterMove(fX, fY, fZ, uiTime); + me->Relocate(fX, fY, fZ); + me->SendMonsterMove(fX, fY, fZ, uiTime); } void ScriptedAI::DoTeleportTo(const float fPos[4]) @@ -443,7 +443,7 @@ void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, flo if (!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER) { if (pUnit) - error_log("TSCR: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", m_creature->GetGUID(), m_creature->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), fX, fY, fZ, fO); + error_log("TSCR: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), fX, fY, fZ, fO); return; } @@ -452,7 +452,7 @@ void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, flo void ScriptedAI::DoTeleportAll(float fX, float fY, float fZ, float fO) { - Map *map = m_creature->GetMap(); + Map *map = me->GetMap(); if (!map->IsDungeon()) return; @@ -460,15 +460,15 @@ void ScriptedAI::DoTeleportAll(float fX, float fY, float fZ, float fO) 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(m_creature->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT); + i_pl->TeleportTo(me->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT); } Unit* ScriptedAI::DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff) { Unit* pUnit = NULL; - Trinity::MostHPMissingInRange u_check(m_creature, fRange, uiMinHPDiff); - Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(m_creature, pUnit, u_check); - m_creature->VisitNearbyObject(fRange, searcher); + Trinity::MostHPMissingInRange u_check(me, fRange, uiMinHPDiff); + Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, pUnit, u_check); + me->VisitNearbyObject(fRange, searcher); return pUnit; } @@ -476,18 +476,18 @@ Unit* ScriptedAI::DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff) std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float fRange) { std::list<Creature*> pList; - Trinity::FriendlyCCedInRange u_check(m_creature, fRange); - Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(m_creature, pList, u_check); - m_creature->VisitNearbyObject(fRange, searcher); + Trinity::FriendlyCCedInRange u_check(me, fRange); + Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, pList, u_check); + me->VisitNearbyObject(fRange, searcher); return pList; } std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellid) { std::list<Creature*> pList; - Trinity::FriendlyMissingBuffInRange u_check(m_creature, fRange, uiSpellid); - Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(m_creature, pList, u_check); - m_creature->VisitNearbyObject(fRange, searcher); + Trinity::FriendlyMissingBuffInRange u_check(me, fRange, uiSpellid); + Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, pList, u_check); + me->VisitNearbyObject(fRange, searcher); return pList; } @@ -495,16 +495,16 @@ Player* ScriptedAI::GetPlayerAtMinimumRange(float fMinimumRange) { Player* pPlayer = NULL; - CellPair pair(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + CellPair pair(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); Cell cell(pair); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Trinity::PlayerAtMinimumRangeAway check(m_creature, fMinimumRange); - Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(m_creature, pPlayer, check); + Trinity::PlayerAtMinimumRangeAway check(me, fMinimumRange); + Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(me, pPlayer, check); TypeContainerVisitor<Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway>, GridTypeMapContainer> visitor(searcher); - cell.Visit(pair, visitor, *(m_creature->GetMap())); + cell.Visit(pair, visitor, *(me->GetMap())); return pPlayer; } @@ -513,20 +513,20 @@ void ScriptedAI::SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand, int32 ui { if (bLoadDefault) { - if (CreatureInfo const* pInfo = GetCreatureTemplateStore(m_creature->GetEntry())) - m_creature->LoadEquipment(pInfo->equipmentId,true); + if (CreatureInfo const* pInfo = GetCreatureTemplateStore(me->GetEntry())) + me->LoadEquipment(pInfo->equipmentId,true); return; } if (uiMainHand >= 0) - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(uiMainHand)); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(uiMainHand)); if (uiOffHand >= 0) - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, uint32(uiOffHand)); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, uint32(uiOffHand)); if (uiRanged >= 0) - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, uint32(uiRanged)); + me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, uint32(uiRanged)); } void ScriptedAI::SetCombatMovement(bool bCombatMove) @@ -554,21 +554,21 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff) return false; } - if (m_creature->IsInEvadeMode() || !m_creature->getVictim()) + if (me->IsInEvadeMode() || !me->getVictim()) return false; - float fX = m_creature->GetPositionX(); - float fY = m_creature->GetPositionY(); - float fZ = m_creature->GetPositionZ(); + float fX = me->GetPositionX(); + float fY = me->GetPositionY(); + float fZ = me->GetPositionZ(); - switch(m_creature->GetEntry()) + switch(me->GetEntry()) { case NPC_BROODLORD: // broodlord (not move down stairs) if (fZ > 448.60f) return false; break; case NPC_VOID_REAVER: // void reaver (calculate from center of room) - if (m_creature->GetDistance2d(432.59f, 371.93f) < 105.0f) + if (me->GetDistance2d(432.59f, 371.93f) < 105.0f) return false; break; case NPC_JAN_ALAI: // jan'alai (calculate by Z) @@ -580,7 +580,7 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff) return false; break; default: - error_log("TSCR: EnterEvadeIfOutOfCombatArea used for creature entry %u, but does not have any definition.", m_creature->GetEntry()); + error_log("TSCR: EnterEvadeIfOutOfCombatArea used for creature entry %u, but does not have any definition.", me->GetEntry()); return false; } @@ -593,7 +593,7 @@ void Scripted_NoMovementAI::AttackStart(Unit* pWho) if (!pWho) return; - if (m_creature->Attack(pWho, true)) + if (me->Attack(pWho, true)) { DoStartNoMovement(pWho); } diff --git a/src/game/ScriptedCreature.h b/src/game/ScriptedCreature.h index 605bc7c3bc3..b416b9f3781 100644 --- a/src/game/ScriptedCreature.h +++ b/src/game/ScriptedCreature.h @@ -29,7 +29,7 @@ class ScriptedInstance; class SummonList : public std::list<uint64> { public: - explicit SummonList(Creature* creature) : m_creature(creature) {} + explicit SummonList(Creature* creature) : me(creature) {} void Summon(Creature *summon) { push_back(summon->GetGUID()); } void Despawn(Creature *summon) { remove(summon->GetGUID()); } void DespawnEntry(uint32 entry); @@ -37,7 +37,7 @@ class SummonList : public std::list<uint64> void DoAction(uint32 entry, uint32 info); void DoZoneInCombat(uint32 entry = 0); private: - Creature *m_creature; + Creature *me; }; struct ScriptedAI : public CreatureAI @@ -86,7 +86,7 @@ struct ScriptedAI : public CreatureAI //************* //Pointer to creature we are manipulating - Creature* m_creature; + Creature* me; //For fleeing bool IsFleeing; @@ -144,16 +144,16 @@ struct ScriptedAI : public CreatureAI //Returns a list of all friendly units missing a specific buff within range std::list<Creature*> DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellId); - //Return a player with at least minimumRange from m_creature + //Return a player with at least minimumRange from me Player* GetPlayerAtMinimumRange(float fMinimumRange); - //Spawns a creature relative to m_creature + //Spawns a creature relative to me Creature* DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime); //Selects a unit from the creature's current aggro list Unit* SelectUnit(SelectAggroTarget pTarget, uint32 uiPosition); - bool HealthBelowPct(uint32 pct) const { return me->GetHealth() * 100 < m_creature->GetMaxHealth() * pct; } + bool HealthBelowPct(uint32 pct) const { return me->GetHealth() * 100 < me->GetMaxHealth() * pct; } //Returns spells that meet the specified criteria from the creatures spell list SpellEntry const* SelectSpell(Unit* Target, int32 School, int32 Mechanic, SelectTargetType Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effect); @@ -238,7 +238,7 @@ struct Scripted_NoMovementAI : public ScriptedAI Scripted_NoMovementAI(Creature* creature) : ScriptedAI(creature) {} virtual ~Scripted_NoMovementAI() {} - //Called at each attack of m_creature by any victim + //Called at each attack of me by any victim void AttackStart(Unit* who); }; diff --git a/src/game/ScriptedEscortAI.cpp b/src/game/ScriptedEscortAI.cpp index 445974eedfd..1ad1cf18d74 100644 --- a/src/game/ScriptedEscortAI.cpp +++ b/src/game/ScriptedEscortAI.cpp @@ -39,13 +39,13 @@ void npc_escortAI::AttackStart(Unit* pWho) if (!pWho) return; - if (m_creature->Attack(pWho, true)) + if (me->Attack(pWho, true)) { - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) - m_creature->GetMotionMaster()->MovementExpired(); + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) + me->GetMotionMaster()->MovementExpired(); if (IsCombatMovement()) - m_creature->GetMotionMaster()->MoveChase(pWho); + me->GetMotionMaster()->MoveChase(pWho); } } @@ -56,7 +56,7 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* pWho) return false; //experimental (unknown) flag not present - if (!(m_creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13)) + if (!(me->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13)) return false; //not a player @@ -64,22 +64,22 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* pWho) return false; //never attack friendly - if (m_creature->IsFriendlyTo(pWho)) + if (me->IsFriendlyTo(pWho)) return false; //too far away and no free sight? - if (m_creature->IsWithinDistInMap(pWho, GetMaxPlayerDistance()) && m_creature->IsWithinLOSInMap(pWho)) + if (me->IsWithinDistInMap(pWho, GetMaxPlayerDistance()) && me->IsWithinLOSInMap(pWho)) { //already fighting someone? - if (!m_creature->getVictim()) + if (!me->getVictim()) { AttackStart(pWho); return true; } else { - pWho->SetInCombatWith(m_creature); - m_creature->AddThreat(pWho, 0.0f); + pWho->SetInCombatWith(me); + me->AddThreat(pWho, 0.0f); return true; } } @@ -89,28 +89,28 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* pWho) void npc_escortAI::MoveInLineOfSight(Unit* pWho) { - if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && pWho->isInAccessiblePlaceFor(m_creature)) + if (!me->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && pWho->isInAccessiblePlaceFor(me)) { if (HasEscortState(STATE_ESCORT_ESCORTING) && AssistPlayerInCombat(pWho)) return; - if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + if (!me->canFly() && me->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) return; - if (m_creature->IsHostileTo(pWho)) + if (me->IsHostileTo(pWho)) { - float fAttackRadius = m_creature->GetAttackDistance(pWho); - if (m_creature->IsWithinDistInMap(pWho, fAttackRadius) && m_creature->IsWithinLOSInMap(pWho)) + float fAttackRadius = me->GetAttackDistance(pWho); + if (me->IsWithinDistInMap(pWho, fAttackRadius) && me->IsWithinLOSInMap(pWho)) { - if (!m_creature->getVictim()) + if (!me->getVictim()) { pWho->RemoveAurasDueToSpell(SPELL_AURA_MOD_STEALTH); AttackStart(pWho); } - else if (m_creature->GetMap()->IsDungeon()) + else if (me->GetMap()->IsDungeon()) { - pWho->SetInCombatWith(m_creature); - m_creature->AddThreat(pWho, 0.0f); + pWho->SetInCombatWith(me); + me->AddThreat(pWho, 0.0f); } } } @@ -153,7 +153,7 @@ void npc_escortAI::JustRespawned() //add a small delay before going to first waypoint, normal in near all cases m_uiWPWaitTimer = 2500; - if (m_creature->getFaction() != m_creature->GetCreatureInfo()->faction_A) + if (me->getFaction() != me->GetCreatureInfo()->faction_A) me->RestoreFaction(); Reset(); @@ -162,16 +162,16 @@ void npc_escortAI::JustRespawned() void npc_escortAI::ReturnToLastPoint() { float x, y, z, o; - m_creature->GetHomePosition(x, y, z, o); - m_creature->GetMotionMaster()->MovePoint(POINT_LAST_POINT, x, y, z); + me->GetHomePosition(x, y, z, o); + me->GetMotionMaster()->MovePoint(POINT_LAST_POINT, x, y, z); } void npc_escortAI::EnterEvadeMode() { - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(true); - m_creature->SetLootRecipient(NULL); + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(true); + me->SetLootRecipient(NULL); if (HasEscortState(STATE_ESCORT_ESCORTING)) { @@ -181,7 +181,7 @@ void npc_escortAI::EnterEvadeMode() } else { - m_creature->GetMotionMaster()->MoveTargetedHome(); + me->GetMotionMaster()->MoveTargetedHome(); Reset(); } } @@ -196,7 +196,7 @@ bool npc_escortAI::IsPlayerOrGroupInRange() { Player* pMember = pRef->getSource(); - if (pMember && m_creature->IsWithinDistInMap(pMember, GetMaxPlayerDistance())) + if (pMember && me->IsWithinDistInMap(pMember, GetMaxPlayerDistance())) { return true; break; @@ -205,7 +205,7 @@ bool npc_escortAI::IsPlayerOrGroupInRange() } else { - if (m_creature->IsWithinDistInMap(pPlayer, GetMaxPlayerDistance())) + if (me->IsWithinDistInMap(pPlayer, GetMaxPlayerDistance())) return true; } } @@ -215,7 +215,7 @@ bool npc_escortAI::IsPlayerOrGroupInRange() void npc_escortAI::UpdateAI(const uint32 uiDiff) { //Waypoint Updating - if (HasEscortState(STATE_ESCORT_ESCORTING) && !m_creature->getVictim() && m_uiWPWaitTimer && !HasEscortState(STATE_ESCORT_RETURNING)) + if (HasEscortState(STATE_ESCORT_ESCORTING) && !me->getVictim() && m_uiWPWaitTimer && !HasEscortState(STATE_ESCORT_RETURNING)) { if (m_uiWPWaitTimer <= uiDiff) { @@ -229,9 +229,9 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) if (m_bCanReturnToStart) { float fRetX, fRetY, fRetZ; - m_creature->GetRespawnCoord(fRetX, fRetY, fRetZ); + me->GetRespawnCoord(fRetX, fRetY, fRetZ); - m_creature->GetMotionMaster()->MovePoint(POINT_HOME, fRetX, fRetY, fRetZ); + me->GetMotionMaster()->MovePoint(POINT_HOME, fRetX, fRetY, fRetZ); m_uiWPWaitTimer = 0; @@ -241,11 +241,11 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) if (m_bCanInstantRespawn) { - m_creature->setDeathState(JUST_DIED); - m_creature->Respawn(); + me->setDeathState(JUST_DIED); + me->Respawn(); } else - m_creature->ForcedDespawn(); + me->ForcedDespawn(); return; } @@ -259,7 +259,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) if (!HasEscortState(STATE_ESCORT_PAUSED)) { - m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); + me->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); debug_log("TSCR: EscortAI start waypoint %u (%f, %f, %f).", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); WaypointStart(CurrentWP->id); @@ -272,7 +272,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) } //Check if player or any member of his group is within range - if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPlayerGUID && !m_creature->getVictim() && !HasEscortState(STATE_ESCORT_RETURNING)) + if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPlayerGUID && !me->getVictim() && !HasEscortState(STATE_ESCORT_RETURNING)) { if (m_uiPlayerCheckTimer <= uiDiff) { @@ -282,11 +282,11 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff) if (m_bCanInstantRespawn) { - m_creature->setDeathState(JUST_DIED); - m_creature->Respawn(); + me->setDeathState(JUST_DIED); + me->Respawn(); } else - m_creature->ForcedDespawn(); + me->ForcedDespawn(); return; } @@ -318,10 +318,10 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) { debug_log("TSCR: EscortAI has returned to original position before combat"); - if (m_bIsRunning && m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - else if (!m_bIsRunning && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + if (m_bIsRunning && me->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) + me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + else if (!m_bIsRunning && !me->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) + me->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); RemoveEscortState(STATE_ESCORT_RETURNING); @@ -340,7 +340,7 @@ void npc_escortAI::MovementInform(uint32 uiMoveType, uint32 uiPointId) //Make sure that we are still on the right waypoint if (CurrentWP->id != uiPointId) { - error_log("TSCR ERROR: EscortAI reached waypoint out of order %u, expected %u, creature entry %u", uiPointId, CurrentWP->id, m_creature->GetEntry()); + error_log("TSCR ERROR: EscortAI reached waypoint out of order %u, expected %u, creature entry %u", uiPointId, CurrentWP->id, me->GetEntry()); return; } @@ -363,12 +363,12 @@ void npc_escortAI::OnPossess(bool apply) if (HasEscortState(STATE_ESCORT_ESCORTING)) { if (apply) - m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z); + me->GetPosition(LastPos.x, LastPos.y, LastPos.z); else { Returning = true; - m_creature->GetMotionMaster()->MovementExpired(); - m_creature->GetMotionMaster()->MovePoint(WP_LAST_POINT, LastPos.x, LastPos.y, LastPos.z); + me->GetMotionMaster()->MovementExpired(); + me->GetMotionMaster()->MovePoint(WP_LAST_POINT, LastPos.x, LastPos.y, LastPos.z); } } } @@ -394,7 +394,7 @@ void npc_escortAI::AddWaypoint(uint32 id, float x, float y, float z, uint32 Wait void npc_escortAI::FillPointMovementListForCreature() { - std::vector<ScriptPointMove> const &pPointsEntries = pSystemMgr.GetPointMoveList(m_creature->GetEntry()); + std::vector<ScriptPointMove> const &pPointsEntries = pSystemMgr.GetPointMoveList(me->GetEntry()); if (pPointsEntries.empty()) return; @@ -413,14 +413,14 @@ void npc_escortAI::SetRun(bool bRun) if (bRun) { if (!m_bIsRunning) - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); else debug_log("TSCR: EscortAI attempt to set run mode, but is already running."); } else { if (m_bIsRunning) - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + me->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); else debug_log("TSCR: EscortAI attempt to set walk mode, but is already walking."); } @@ -430,7 +430,7 @@ void npc_escortAI::SetRun(bool bRun) //TODO: get rid of this many variables passed in function. void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, const Quest* pQuest, bool bInstantRespawn, bool bCanLoopPath) { - if (m_creature->getVictim()) + if (me->getVictim()) { error_log("TSCR ERROR: EscortAI attempt to Start while in combat."); return; @@ -471,15 +471,15 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, if (m_bCanReturnToStart && m_bCanInstantRespawn) debug_log("TSCR: EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn."); - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) { - m_creature->GetMotionMaster()->MovementExpired(); - m_creature->GetMotionMaster()->MoveIdle(); + me->GetMotionMaster()->MovementExpired(); + me->GetMotionMaster()->MoveIdle(); debug_log("TSCR: EscortAI start with WAYPOINT_MOTION_TYPE, changed to MoveIdle."); } //disable npcflags - m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); + me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); debug_log("TSCR: EscortAI started with %u waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = %u", WaypointList.size(), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID); @@ -487,9 +487,9 @@ void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, //Set initial speed if (m_bIsRunning) - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); else - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + me->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); AddEscortState(STATE_ESCORT_ESCORTING); } diff --git a/src/game/ScriptedEscortAI.h b/src/game/ScriptedEscortAI.h index 8901d4da40c..8b8064007d4 100644 --- a/src/game/ScriptedEscortAI.h +++ b/src/game/ScriptedEscortAI.h @@ -83,7 +83,7 @@ struct npc_escortAI : public ScriptedAI uint64 GetEventStarterGUID() { return m_uiPlayerGUID; } protected: - Player* GetPlayerForEscort() { return (Player*)Unit::GetUnit(*m_creature, m_uiPlayerGUID); } + Player* GetPlayerForEscort() { return (Player*)Unit::GetUnit(*me, m_uiPlayerGUID); } private: bool AssistPlayerInCombat(Unit* pWho); diff --git a/src/game/ScriptedFollowerAI.cpp b/src/game/ScriptedFollowerAI.cpp index b47f534556f..657b344469c 100644 --- a/src/game/ScriptedFollowerAI.cpp +++ b/src/game/ScriptedFollowerAI.cpp @@ -31,22 +31,22 @@ void FollowerAI::AttackStart(Unit* pWho) if (!pWho) return; - if (m_creature->Attack(pWho, true)) + if (me->Attack(pWho, true)) { - m_creature->AddThreat(pWho, 0.0f); - m_creature->SetInCombatWith(pWho); - pWho->SetInCombatWith(m_creature); + me->AddThreat(pWho, 0.0f); + me->SetInCombatWith(pWho); + pWho->SetInCombatWith(me); - if (m_creature->hasUnitState(UNIT_STAT_FOLLOW)) - m_creature->clearUnitState(UNIT_STAT_FOLLOW); + if (me->hasUnitState(UNIT_STAT_FOLLOW)) + me->clearUnitState(UNIT_STAT_FOLLOW); if (IsCombatMovement()) - m_creature->GetMotionMaster()->MoveChase(pWho); + me->GetMotionMaster()->MoveChase(pWho); } } //This part provides assistance to a player that are attacked by pWho, even if out of normal aggro range -//It will cause m_creature to attack pWho that are attacking _any_ player (which has been confirmed may happen also on offi) +//It will cause me to attack pWho that are attacking _any_ player (which has been confirmed may happen also on offi) //The flag (type_flag) is unconfirmed, but used here for further research and is a good candidate. bool FollowerAI::AssistPlayerInCombat(Unit* pWho) { @@ -54,7 +54,7 @@ bool FollowerAI::AssistPlayerInCombat(Unit* pWho) return false; //experimental (unknown) flag not present - if (!(m_creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13)) + if (!(me->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK13)) return false; //not a player @@ -62,22 +62,22 @@ bool FollowerAI::AssistPlayerInCombat(Unit* pWho) return false; //never attack friendly - if (m_creature->IsFriendlyTo(pWho)) + if (me->IsFriendlyTo(pWho)) return false; //too far away and no free sight? - if (m_creature->IsWithinDistInMap(pWho, MAX_PLAYER_DISTANCE) && m_creature->IsWithinLOSInMap(pWho)) + if (me->IsWithinDistInMap(pWho, MAX_PLAYER_DISTANCE) && me->IsWithinLOSInMap(pWho)) { //already fighting someone? - if (!m_creature->getVictim()) + if (!me->getVictim()) { AttackStart(pWho); return true; } else { - pWho->SetInCombatWith(m_creature); - m_creature->AddThreat(pWho, 0.0f); + pWho->SetInCombatWith(me); + me->AddThreat(pWho, 0.0f); return true; } } @@ -87,28 +87,28 @@ bool FollowerAI::AssistPlayerInCombat(Unit* pWho) void FollowerAI::MoveInLineOfSight(Unit* pWho) { - if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && pWho->isInAccessiblePlaceFor(m_creature)) + if (!me->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && pWho->isInAccessiblePlaceFor(me)) { if (HasFollowState(STATE_FOLLOW_INPROGRESS) && AssistPlayerInCombat(pWho)) return; - if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + if (!me->canFly() && me->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) return; - if (m_creature->IsHostileTo(pWho)) + if (me->IsHostileTo(pWho)) { - float fAttackRadius = m_creature->GetAttackDistance(pWho); - if (m_creature->IsWithinDistInMap(pWho, fAttackRadius) && m_creature->IsWithinLOSInMap(pWho)) + float fAttackRadius = me->GetAttackDistance(pWho); + if (me->IsWithinDistInMap(pWho, fAttackRadius) && me->IsWithinLOSInMap(pWho)) { - if (!m_creature->getVictim()) + if (!me->getVictim()) { pWho->RemoveAurasDueToSpell(SPELL_AURA_MOD_STEALTH); AttackStart(pWho); } - else if (m_creature->GetMap()->IsDungeon()) + else if (me->GetMap()->IsDungeon()) { - pWho->SetInCombatWith(m_creature); - m_creature->AddThreat(pWho, 0.0f); + pWho->SetInCombatWith(me); + me->AddThreat(pWho, 0.0f); } } } @@ -149,34 +149,34 @@ void FollowerAI::JustRespawned() if (!IsCombatMovement()) SetCombatMovement(true); - if (m_creature->getFaction() != m_creature->GetCreatureInfo()->faction_A) - m_creature->setFaction(m_creature->GetCreatureInfo()->faction_A); + if (me->getFaction() != me->GetCreatureInfo()->faction_A) + me->setFaction(me->GetCreatureInfo()->faction_A); Reset(); } void FollowerAI::EnterEvadeMode() { - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(true); - m_creature->SetLootRecipient(NULL); + me->RemoveAllAuras(); + me->DeleteThreatList(); + me->CombatStop(true); + me->SetLootRecipient(NULL); if (HasFollowState(STATE_FOLLOW_INPROGRESS)) { debug_log("TSCR: FollowerAI left combat, returning to CombatStartPosition."); - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) { float fPosX, fPosY, fPosZ; - m_creature->GetPosition(fPosX, fPosY, fPosZ); - m_creature->GetMotionMaster()->MovePoint(POINT_COMBAT_START, fPosX, fPosY, fPosZ); + me->GetPosition(fPosX, fPosY, fPosZ); + me->GetMotionMaster()->MovePoint(POINT_COMBAT_START, fPosX, fPosY, fPosZ); } } else { - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) - m_creature->GetMotionMaster()->MoveTargetedHome(); + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + me->GetMotionMaster()->MoveTargetedHome(); } Reset(); @@ -184,14 +184,14 @@ void FollowerAI::EnterEvadeMode() void FollowerAI::UpdateAI(const uint32 uiDiff) { - if (HasFollowState(STATE_FOLLOW_INPROGRESS) && !m_creature->getVictim()) + if (HasFollowState(STATE_FOLLOW_INPROGRESS) && !me->getVictim()) { if (m_uiUpdateFollowTimer <= uiDiff) { if (HasFollowState(STATE_FOLLOW_COMPLETE) && !HasFollowState(STATE_FOLLOW_POSTEVENT)) { debug_log("TSCR: FollowerAI is set completed, despawns."); - m_creature->ForcedDespawn(); + me->ForcedDespawn(); return; } @@ -204,7 +204,7 @@ void FollowerAI::UpdateAI(const uint32 uiDiff) debug_log("TSCR: FollowerAI is returning to leader."); RemoveFollowState(STATE_FOLLOW_RETURNING); - m_creature->GetMotionMaster()->MoveFollow(pPlayer, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + me->GetMotionMaster()->MoveFollow(pPlayer, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); return; } @@ -214,7 +214,7 @@ void FollowerAI::UpdateAI(const uint32 uiDiff) { Player* pMember = pRef->getSource(); - if (pMember && m_creature->IsWithinDistInMap(pMember, MAX_PLAYER_DISTANCE)) + if (pMember && me->IsWithinDistInMap(pMember, MAX_PLAYER_DISTANCE)) { bIsMaxRangeExceeded = false; break; @@ -223,7 +223,7 @@ void FollowerAI::UpdateAI(const uint32 uiDiff) } else { - if (m_creature->IsWithinDistInMap(pPlayer, MAX_PLAYER_DISTANCE)) + if (me->IsWithinDistInMap(pPlayer, MAX_PLAYER_DISTANCE)) bIsMaxRangeExceeded = false; } } @@ -231,7 +231,7 @@ void FollowerAI::UpdateAI(const uint32 uiDiff) if (bIsMaxRangeExceeded) { debug_log("TSCR: FollowerAI failed because player/group was to far away or not found"); - m_creature->ForcedDespawn(); + me->ForcedDespawn(); return; } @@ -265,13 +265,13 @@ void FollowerAI::MovementInform(uint32 uiMotionType, uint32 uiPointId) AddFollowState(STATE_FOLLOW_RETURNING); } else - m_creature->ForcedDespawn(); + me->ForcedDespawn(); } } void FollowerAI::StartFollow(Player* pLeader, uint32 uiFactionForFollower, const Quest* pQuest) { - if (m_creature->getVictim()) + if (me->getVictim()) { debug_log("TSCR: FollowerAI attempt to StartFollow while in combat."); return; @@ -287,22 +287,22 @@ void FollowerAI::StartFollow(Player* pLeader, uint32 uiFactionForFollower, const m_uiLeaderGUID = pLeader->GetGUID(); if (uiFactionForFollower) - m_creature->setFaction(uiFactionForFollower); + me->setFaction(uiFactionForFollower); m_pQuestForFollow = pQuest; - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) + if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) { - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveIdle(); debug_log("TSCR: FollowerAI start with WAYPOINT_MOTION_TYPE, set to MoveIdle."); } - m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); + me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); AddFollowState(STATE_FOLLOW_INPROGRESS); - m_creature->GetMotionMaster()->MoveFollow(pLeader, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + me->GetMotionMaster()->MoveFollow(pLeader, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); debug_log("TSCR: FollowerAI start follow %s (GUID %u)", pLeader->GetName(), m_uiLeaderGUID); } @@ -321,7 +321,7 @@ Player* FollowerAI::GetLeaderForFollower() { Player* pMember = pRef->getSource(); - if (pMember && pMember->isAlive() && m_creature->IsWithinDistInMap(pMember, MAX_PLAYER_DISTANCE)) + if (pMember && pMember->isAlive() && me->IsWithinDistInMap(pMember, MAX_PLAYER_DISTANCE)) { debug_log("TSCR: FollowerAI GetLeader changed and returned new leader."); m_uiLeaderGUID = pMember->GetGUID(); @@ -339,13 +339,13 @@ Player* FollowerAI::GetLeaderForFollower() void FollowerAI::SetFollowComplete(bool bWithEndEvent) { - if (m_creature->hasUnitState(UNIT_STAT_FOLLOW)) + if (me->hasUnitState(UNIT_STAT_FOLLOW)) { - m_creature->clearUnitState(UNIT_STAT_FOLLOW); + me->clearUnitState(UNIT_STAT_FOLLOW); - m_creature->StopMoving(); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); + me->StopMoving(); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveIdle(); } if (bWithEndEvent) @@ -368,13 +368,13 @@ void FollowerAI::SetFollowPaused(bool bPaused) { AddFollowState(STATE_FOLLOW_PAUSED); - if (m_creature->hasUnitState(UNIT_STAT_FOLLOW)) + if (me->hasUnitState(UNIT_STAT_FOLLOW)) { - m_creature->clearUnitState(UNIT_STAT_FOLLOW); + me->clearUnitState(UNIT_STAT_FOLLOW); - m_creature->StopMoving(); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); + me->StopMoving(); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveIdle(); } } else @@ -382,6 +382,6 @@ void FollowerAI::SetFollowPaused(bool bPaused) RemoveFollowState(STATE_FOLLOW_PAUSED); if (Player* pLeader = GetLeaderForFollower()) - m_creature->GetMotionMaster()->MoveFollow(pLeader, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + me->GetMotionMaster()->MoveFollow(pLeader, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); } } diff --git a/src/game/ScriptedGuardAI.cpp b/src/game/ScriptedGuardAI.cpp index 83cc8c20479..2fbf8bff1cb 100644 --- a/src/game/ScriptedGuardAI.cpp +++ b/src/game/ScriptedGuardAI.cpp @@ -45,10 +45,10 @@ void guardAI::Reset() void guardAI::EnterCombat(Unit *who) { - if (m_creature->GetEntry() == 15184) - DoScriptText(RAND(SAY_GUARD_SIL_AGGRO1,SAY_GUARD_SIL_AGGRO2,SAY_GUARD_SIL_AGGRO3), m_creature, who); + if (me->GetEntry() == 15184) + DoScriptText(RAND(SAY_GUARD_SIL_AGGRO1,SAY_GUARD_SIL_AGGRO2,SAY_GUARD_SIL_AGGRO3), me, who); - if (SpellEntry const *spell = m_creature->reachWithSpellAttack(who)) + if (SpellEntry const *spell = me->reachWithSpellAttack(who)) DoCastSpell(who, spell); } @@ -56,7 +56,7 @@ void guardAI::JustDied(Unit *Killer) { //Send Zone Under Attack message to the LocalDefense and WorldDefense Channels if (Player* pKiller = Killer->GetCharmerOrOwnerPlayerOrPlayerItself()) - m_creature->SendZoneUnderAttackMessage(pKiller); + me->SendZoneUnderAttackMessage(pKiller); } void guardAI::UpdateAI(const uint32 diff) @@ -67,16 +67,16 @@ void guardAI::UpdateAI(const uint32 diff) else GlobalCooldown = 0; //Buff timer (only buff when we are alive and not in combat - if (m_creature->isAlive() && !m_creature->isInCombat()) + if (me->isAlive() && !me->isInCombat()) if (BuffTimer <= diff) { //Find a spell that targets friendly and applies an aura (these are generally buffs) - SpellEntry const *info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_AURA); + SpellEntry const *info = SelectSpell(me, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_AURA); if (info && !GlobalCooldown) { //Cast the buff spell - DoCastSpell(m_creature, info); + DoCastSpell(me, info); //Set our global cooldown GlobalCooldown = GENERIC_CREATURE_COOLDOWN; @@ -92,77 +92,77 @@ void guardAI::UpdateAI(const uint32 diff) return; // Make sure our attack is ready and we arn't currently casting - if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + if (me->isAttackReady() && !me->IsNonMeleeSpellCasted(false)) { //If we are within range melee the target - if (m_creature->IsWithinMeleeRange(m_creature->getVictim())) + if (me->IsWithinMeleeRange(me->getVictim())) { bool Healing = false; SpellEntry const *info = NULL; //Select a healing spell if less than 30% hp - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30) - info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); + if (me->GetHealth()*100 / me->GetMaxHealth() < 30) + info = SelectSpell(me, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); //No healing spell available, select a hostile spell if (info) Healing = true; - else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE); + else info = SelectSpell(me->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE); //20% chance to replace our white hit with a spell if (info && rand() % 5 == 0 && !GlobalCooldown) { //Cast the spell - if (Healing)DoCastSpell(m_creature, info); - else DoCastSpell(m_creature->getVictim(), info); + if (Healing)DoCastSpell(me, info); + else DoCastSpell(me->getVictim(), info); //Set our global cooldown GlobalCooldown = GENERIC_CREATURE_COOLDOWN; } - else m_creature->AttackerStateUpdate(m_creature->getVictim()); + else me->AttackerStateUpdate(me->getVictim()); - m_creature->resetAttackTimer(); + me->resetAttackTimer(); } } else { //Only run this code if we arn't already casting - if (!m_creature->IsNonMeleeSpellCasted(false)) + if (!me->IsNonMeleeSpellCasted(false)) { bool Healing = false; SpellEntry const *info = NULL; //Select a healing spell if less than 30% hp ONLY 33% of the time - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30 && rand() % 3 == 0) - info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); + if (me->GetHealth()*100 / me->GetMaxHealth() < 30 && rand() % 3 == 0) + info = SelectSpell(me, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) if (info) Healing = true; - else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE); + else info = SelectSpell(me->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE); //Found a spell, check if we arn't on cooldown if (info && !GlobalCooldown) { //If we are currently moving stop us and set the movement generator - if ((*m_creature).GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE) + if ((*me).GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE) { - (*m_creature).GetMotionMaster()->Clear(false); - (*m_creature).GetMotionMaster()->MoveIdle(); + (*me).GetMotionMaster()->Clear(false); + (*me).GetMotionMaster()->MoveIdle(); } //Cast spell - if (Healing) DoCastSpell(m_creature,info); - else DoCastSpell(m_creature->getVictim(),info); + if (Healing) DoCastSpell(me,info); + else DoCastSpell(me->getVictim(),info); //Set our global cooldown GlobalCooldown = GENERIC_CREATURE_COOLDOWN; } //If no spells available and we arn't moving run to target - else if ((*m_creature).GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) + else if ((*me).GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) { //Cancel our current spell and then mutate new movement generator - m_creature->InterruptNonMeleeSpells(false); - (*m_creature).GetMotionMaster()->Clear(false); - (*m_creature).GetMotionMaster()->MoveChase(m_creature->getVictim()); + me->InterruptNonMeleeSpells(false); + (*me).GetMotionMaster()->Clear(false); + (*me).GetMotionMaster()->MoveChase(me->getVictim()); } } } @@ -172,12 +172,12 @@ void guardAI::DoReplyToTextEmote(uint32 em) { switch(em) { - case TEXTEMOTE_KISS: m_creature->HandleEmoteCommand(EMOTE_ONESHOT_BOW); break; - case TEXTEMOTE_WAVE: m_creature->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); break; - case TEXTEMOTE_SALUTE: m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); break; - case TEXTEMOTE_SHY: m_creature->HandleEmoteCommand(EMOTE_ONESHOT_FLEX); break; + case TEXTEMOTE_KISS: me->HandleEmoteCommand(EMOTE_ONESHOT_BOW); break; + case TEXTEMOTE_WAVE: me->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); break; + case TEXTEMOTE_SALUTE: me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); break; + case TEXTEMOTE_SHY: me->HandleEmoteCommand(EMOTE_ONESHOT_FLEX); break; case TEXTEMOTE_RUDE: - case TEXTEMOTE_CHICKEN: m_creature->HandleEmoteCommand(EMOTE_ONESHOT_POINT); break; + case TEXTEMOTE_CHICKEN: me->HandleEmoteCommand(EMOTE_ONESHOT_POINT); break; } } diff --git a/src/game/ScriptedSimpleAI.cpp b/src/game/ScriptedSimpleAI.cpp index 805cd0e866b..08797515837 100644 --- a/src/game/ScriptedSimpleAI.cpp +++ b/src/game/ScriptedSimpleAI.cpp @@ -99,11 +99,11 @@ void SimpleAI::EnterCombat(Unit *who) //Random text if (Aggro_TextId[random_text]) - DoScriptText(Aggro_TextId[random_text], m_creature, who); + DoScriptText(Aggro_TextId[random_text], me, who); //Random sound if (Aggro_Sound[random_text]) - DoPlaySoundToSet(m_creature, Aggro_Sound[random_text]); + DoPlaySoundToSet(me, Aggro_Sound[random_text]); } void SimpleAI::KilledUnit(Unit *victim) @@ -112,11 +112,11 @@ void SimpleAI::KilledUnit(Unit *victim) //Random yell if (Kill_TextId[random_text]) - DoScriptText(Kill_TextId[random_text], m_creature, victim); + DoScriptText(Kill_TextId[random_text], me, victim); //Random sound if (Kill_Sound[random_text]) - DoPlaySoundToSet(m_creature, Kill_Sound[random_text]); + DoPlaySoundToSet(me, Kill_Sound[random_text]); if (!Kill_Spell) return; @@ -126,10 +126,10 @@ void SimpleAI::KilledUnit(Unit *victim) switch (Kill_Target_Type) { case CAST_SELF: - pTarget = m_creature; + pTarget = me; break; case CAST_HOSTILE_TARGET: - pTarget = m_creature->getVictim(); + pTarget = me->getVictim(); break; case CAST_HOSTILE_SECOND_AGGRO: pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO,1); @@ -153,18 +153,18 @@ void SimpleAI::KilledUnit(Unit *victim) void SimpleAI::DamageTaken(Unit *killer, uint32 &damage) { //Return if damage taken won't kill us - if (m_creature->GetHealth() > damage) + if (me->GetHealth() > damage) return; uint8 random_text = urand(0,2); //Random yell if (Death_TextId[random_text]) - DoScriptText(Death_TextId[random_text], m_creature, killer); + DoScriptText(Death_TextId[random_text], me, killer); //Random sound if (Death_Sound[random_text]) - DoPlaySoundToSet(m_creature, Death_Sound[random_text]); + DoPlaySoundToSet(me, Death_Sound[random_text]); if (!Death_Spell) return; @@ -174,10 +174,10 @@ void SimpleAI::DamageTaken(Unit *killer, uint32 &damage) switch (Death_Target_Type) { case CAST_SELF: - pTarget = m_creature; + pTarget = me; break; case CAST_HOSTILE_TARGET: - pTarget = m_creature->getVictim(); + pTarget = me->getVictim(); break; case CAST_HOSTILE_SECOND_AGGRO: pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO,1); @@ -214,21 +214,21 @@ void SimpleAI::UpdateAI(const uint32 diff) if (Spell_Timer[i] <= diff) { //Check if this is a percentage based - if (Spell[i].First_Cast < 0 && Spell[i].First_Cast > -100 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > -Spell[i].First_Cast) + if (Spell[i].First_Cast < 0 && Spell[i].First_Cast > -100 && me->GetHealth()*100 / me->GetMaxHealth() > -Spell[i].First_Cast) continue; //Check Current spell - if (!(Spell[i].InterruptPreviousCast && m_creature->IsNonMeleeSpellCasted(false))) + if (!(Spell[i].InterruptPreviousCast && me->IsNonMeleeSpellCasted(false))) { Unit *pTarget = NULL; switch (Spell[i].Cast_Target_Type) { case CAST_SELF: - pTarget = m_creature; + pTarget = me; break; case CAST_HOSTILE_TARGET: - pTarget = m_creature->getVictim(); + pTarget = me->getVictim(); break; case CAST_HOSTILE_SECOND_AGGRO: pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO,1); @@ -244,8 +244,8 @@ void SimpleAI::UpdateAI(const uint32 diff) //Target is ok, cast a spell on it and then do our random yell if (pTarget) { - if (m_creature->IsNonMeleeSpellCasted(false)) - m_creature->InterruptNonMeleeSpells(false); + if (me->IsNonMeleeSpellCasted(false)) + me->InterruptNonMeleeSpells(false); DoCast(pTarget, Spell[i].Spell_Id); @@ -255,11 +255,11 @@ void SimpleAI::UpdateAI(const uint32 diff) //Random yell if (Spell[i].TextId[random_text]) - DoScriptText(Spell[i].TextId[random_text], m_creature, pTarget); + DoScriptText(Spell[i].TextId[random_text], me, pTarget); //Random sound if (Spell[i].Text_Sound[random_text]) - DoPlaySoundToSet(m_creature, Spell[i].Text_Sound[random_text]); + DoPlaySoundToSet(me, Spell[i].Text_Sound[random_text]); } } diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index 6102d2ee4d2..a6464f189e8 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -50,20 +50,20 @@ TotemAI::MoveInLineOfSight(Unit *) void TotemAI::EnterEvadeMode() { - m_creature->CombatStop(true); + me->CombatStop(true); } void TotemAI::UpdateAI(const uint32 /*diff*/) { - if (m_creature->ToTotem()->GetTotemType() != TOTEM_ACTIVE) + if (me->ToTotem()->GetTotemType() != TOTEM_ACTIVE) return; - if (!m_creature->isAlive() || m_creature->IsNonMeleeSpellCasted(false)) + if (!me->isAlive() || me->IsNonMeleeSpellCasted(false)) return; // Search spell - SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_creature->ToTotem()->GetSpell()); + SpellEntry const *spellInfo = sSpellStore.LookupEntry(me->ToTotem()->GetSpell()); if (!spellInfo) return; @@ -74,17 +74,17 @@ TotemAI::UpdateAI(const uint32 /*diff*/) // SPELLMOD_RANGE not applied in this place just because not existence range mods for attacking totems // pointer to appropriate target if found any - Unit* victim = i_victimGuid ? ObjectAccessor::GetUnit(*m_creature, i_victimGuid) : NULL; + Unit* victim = i_victimGuid ? ObjectAccessor::GetUnit(*me, i_victimGuid) : NULL; // Search victim if no, not attackable, or out of range, or friendly (possible in case duel end) if (!victim || - !victim->isTargetableForAttack() || !m_creature->IsWithinDistInMap(victim, max_range) || - m_creature->IsFriendlyTo(victim) || !victim->isVisibleForOrDetect(m_creature,false)) + !victim->isTargetableForAttack() || !me->IsWithinDistInMap(victim, max_range) || + me->IsFriendlyTo(victim) || !victim->isVisibleForOrDetect(me,false)) { victim = NULL; - Trinity::NearestAttackableUnitInObjectRangeCheck u_check(m_creature, m_creature, max_range); - Trinity::UnitLastSearcher<Trinity::NearestAttackableUnitInObjectRangeCheck> checker(m_creature, victim, u_check); - m_creature->VisitNearbyObject(max_range, checker); + Trinity::NearestAttackableUnitInObjectRangeCheck u_check(me, me, max_range); + Trinity::UnitLastSearcher<Trinity::NearestAttackableUnitInObjectRangeCheck> checker(me, victim, u_check); + me->VisitNearbyObject(max_range, checker); } // If have target @@ -94,8 +94,8 @@ TotemAI::UpdateAI(const uint32 /*diff*/) i_victimGuid = victim->GetGUID(); // attack - m_creature->SetInFront(victim); // client change orientation by self - m_creature->CastSpell(victim, m_creature->ToTotem()->GetSpell(), false); + me->SetInFront(victim); // client change orientation by self + me->CastSpell(victim, me->ToTotem()->GetSpell(), false); } else i_victimGuid = 0; @@ -105,12 +105,12 @@ void TotemAI::AttackStart(Unit *) { // Sentry totem sends ping on attack - if (m_creature->GetEntry() == SENTRY_TOTEM_ENTRY && m_creature->GetOwner()->GetTypeId() == TYPEID_PLAYER) + if (me->GetEntry() == SENTRY_TOTEM_ENTRY && me->GetOwner()->GetTypeId() == TYPEID_PLAYER) { WorldPacket data(MSG_MINIMAP_PING, (8+4+4)); - data << m_creature->GetGUID(); - data << m_creature->GetPositionX(); - data << m_creature->GetPositionY(); - ((Player*)m_creature->GetOwner())->GetSession()->SendPacket(&data); + data << me->GetGUID(); + data << me->GetPositionX(); + data << me->GetPositionY(); + ((Player*)me->GetOwner())->GetSession()->SendPacket(&data); } } |