*Fix a crash bug caused by motionmaster.
*Fix charge movement. --HG-- branch : trunk
This commit is contained in:
@@ -342,7 +342,7 @@ Unit* ScriptedAI::SelectUnit(SelectAggroTarget targetType, uint32 position, floa
|
||||
Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
|
||||
if(!target
|
||||
|| playerOnly && target->GetTypeId() != TYPEID_PLAYER
|
||||
|| dist && !m_creature->IsWithinDistInMap(target, dist))
|
||||
|| dist && !m_creature->IsWithinCombatRange(target, dist))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -388,7 +388,7 @@ Unit* ScriptedAI::SelectUnit(SelectAggroTarget targetType, uint32 position, floa
|
||||
target = Unit::GetUnit(*m_creature,(*i)->getUnitGuid());
|
||||
if(!target
|
||||
|| playerOnly && target->GetTypeId() != TYPEID_PLAYER
|
||||
|| dist && !m_creature->IsWithinDistInMap(target, dist))
|
||||
|| dist && !m_creature->IsWithinCombatRange(target, dist))
|
||||
{
|
||||
m_threatlist.erase(i);
|
||||
}
|
||||
@@ -414,7 +414,7 @@ void ScriptedAI::SelectUnitList(std::list<Unit*> &targetList, uint32 num, Select
|
||||
Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
|
||||
if(!target
|
||||
|| playerOnly && target->GetTypeId() != TYPEID_PLAYER
|
||||
|| dist && !m_creature->IsWithinDistInMap(target, dist))
|
||||
|| dist && !m_creature->IsWithinCombatRange(target, dist))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -448,7 +448,7 @@ void ScriptedAI::SelectUnitList(std::list<Unit*> &targetList, uint32 num, Select
|
||||
m_threatlist.erase(i);
|
||||
if(!target
|
||||
|| playerOnly && target->GetTypeId() != TYPEID_PLAYER
|
||||
|| dist && !m_creature->IsWithinDistInMap(target, dist))
|
||||
|| dist && !m_creature->IsWithinCombatRange(target, dist))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -575,6 +575,16 @@ bool ScriptedAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
float GetSpellMaxRange(uint32 id)
|
||||
{
|
||||
SpellEntry const *spellInfo = GetSpellStore()->LookupEntry(id);
|
||||
if(!spellInfo) return 0;
|
||||
SpellRangeEntry const *range = GetSpellRangeStore()->LookupEntry(spellInfo->rangeIndex);
|
||||
if(!range) return 0;
|
||||
return range->maxRange;
|
||||
}
|
||||
|
||||
void FillSpellSummary()
|
||||
{
|
||||
SpellSummary = new TSpellSummary[GetSpellStore()->GetNumRows()];
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "CreatureAI.h"
|
||||
#include "Creature.h"
|
||||
|
||||
float GetSpellMaxRange(uint32 id);
|
||||
|
||||
class SummonList : std::list<uint64>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -905,18 +905,11 @@ struct TRINITY_DLL_DECL flame_of_azzinothAI : public ScriptedAI
|
||||
void ChargeCheck()
|
||||
{
|
||||
Unit* target = SelectUnit(SELECT_TARGET_FARTHEST, 0, 200, false);
|
||||
if(target && (!m_creature->IsWithinDistInMap(target, FLAME_CHARGE_DISTANCE)))
|
||||
if(target && (!m_creature->IsWithinCombatRange(target, FLAME_CHARGE_DISTANCE)))
|
||||
{
|
||||
m_creature->AttackStop();
|
||||
m_creature->GetMotionMaster()->Clear(false);
|
||||
float x, y, z; // is it possible to fix charge?
|
||||
target->GetContactPoint(m_creature, x, y, z);
|
||||
m_creature->Relocate(x,y,z);
|
||||
m_creature->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_WALK_MODE, 1);
|
||||
//m_creature->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());
|
||||
m_creature->StopMoving();
|
||||
//DoCast(target, SPELL_CHARGE);
|
||||
m_creature->AddThreat(target, 5000000.0f);
|
||||
AttackStart(target);
|
||||
DoCast(target, SPELL_CHARGE);
|
||||
DoTextEmote("sets its gaze on $N!", target);
|
||||
}
|
||||
}
|
||||
@@ -964,7 +957,7 @@ struct TRINITY_DLL_DECL flame_of_azzinothAI : public ScriptedAI
|
||||
{
|
||||
ChargeCheck();
|
||||
EnrageCheck();
|
||||
CheckTimer = 5000;
|
||||
CheckTimer = 1000;
|
||||
}else CheckTimer -= diff;
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
|
||||
@@ -246,9 +246,6 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
|
||||
FlamePatch_Timer = 30000;
|
||||
Phase1 = false;
|
||||
break;
|
||||
case WE_CHARGE:
|
||||
m_creature->SetSpeed(MOVE_RUN, DefaultMoveSpeedRate);
|
||||
break;
|
||||
case WE_METEOR:
|
||||
m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false);
|
||||
m_creature->CastSpell(m_creature, SPELL_DIVE_BOMB_VISUAL, false);
|
||||
@@ -336,17 +333,8 @@ struct TRINITY_DLL_DECL boss_alarAI : public ScriptedAI
|
||||
|
||||
if(Charge_Timer < diff)
|
||||
{
|
||||
if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1))
|
||||
{
|
||||
m_creature->SetInFront(target);
|
||||
m_creature->GetMotionMaster()->Clear();
|
||||
m_creature->AttackStop();
|
||||
m_creature->SetSpeed(MOVE_RUN, 5.0f);
|
||||
DoCast(target, SPELL_CHARGE);
|
||||
WaitEvent = WE_CHARGE;
|
||||
WaitTimer = 1000;
|
||||
return;
|
||||
}
|
||||
Unit *target= SelectUnit(SELECT_TARGET_RANDOM, 1, GetSpellMaxRange(SPELL_CHARGE), true);
|
||||
DoCast(target, SPELL_CHARGE);
|
||||
Charge_Timer = 30000;
|
||||
}else Charge_Timer -= diff;
|
||||
|
||||
|
||||
@@ -112,9 +112,6 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
|
||||
uint32 ShapeShift_Timer;
|
||||
uint32 Berserk_Timer;
|
||||
|
||||
uint64 ChargeTargetGUID;
|
||||
uint64 TankGUID;
|
||||
|
||||
bool inBearForm;
|
||||
bool MoveEvent;
|
||||
bool inMove;
|
||||
@@ -145,9 +142,6 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
|
||||
ShapeShift_Timer = 45000 + rand()%5000;
|
||||
Berserk_Timer = 600000;
|
||||
|
||||
ChargeTargetGUID = 0;
|
||||
TankGUID = 0;
|
||||
|
||||
inBearForm = false;
|
||||
m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + 1, 5122);
|
||||
}
|
||||
@@ -301,15 +295,7 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
|
||||
|
||||
void MovementInform(uint32 type, uint32 id)
|
||||
{
|
||||
if(!MoveEvent)
|
||||
{
|
||||
if(ChargeTargetGUID)
|
||||
{
|
||||
if(Unit* target = Unit::GetUnit(*m_creature, ChargeTargetGUID))
|
||||
m_creature->CastSpell(target, SPELL_SURGE, true);
|
||||
ChargeTargetGUID = 0;
|
||||
}
|
||||
}else
|
||||
if(MoveEvent)
|
||||
{
|
||||
if(type != POINT_MOTION_TYPE)
|
||||
return;
|
||||
@@ -360,19 +346,6 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
|
||||
}else waitTimer -= diff;
|
||||
}
|
||||
|
||||
if(TankGUID)
|
||||
{
|
||||
if(!ChargeTargetGUID)
|
||||
{
|
||||
m_creature->SetSpeed(MOVE_RUN, 1.2f);
|
||||
m_creature->GetMotionMaster()->Clear();
|
||||
if(Unit* target = Unit::GetUnit(*m_creature, TankGUID))
|
||||
m_creature->GetMotionMaster()->MoveChase(target);
|
||||
TankGUID = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!m_creature->SelectHostilTarget() && !m_creature->getVictim())
|
||||
return;
|
||||
|
||||
@@ -434,37 +407,13 @@ struct TRINITY_DLL_DECL boss_nalorakkAI : public ScriptedAI
|
||||
{
|
||||
DoYell(YELL_SURGE, LANG_UNIVERSAL, NULL);
|
||||
DoPlaySoundToSet(m_creature, SOUND_YELL_SURGE);
|
||||
|
||||
Unit *target = NULL;
|
||||
std::list<HostilReference *> t_list = m_creature->getThreatManager().getThreatList();
|
||||
std::vector<Unit *> target_list;
|
||||
for(std::list<HostilReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
|
||||
{
|
||||
target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
|
||||
//50 yard radius maximum
|
||||
if(target && target->GetDistance2d(m_creature) < 50)
|
||||
target_list.push_back(target);
|
||||
target = NULL;
|
||||
}
|
||||
if(target_list.size())
|
||||
target = *(target_list.begin()+rand()%target_list.size());
|
||||
|
||||
if(!target)
|
||||
target = m_creature->getVictim();
|
||||
TankGUID = m_creature->getVictim()->GetGUID();
|
||||
ChargeTargetGUID = target->GetGUID();
|
||||
|
||||
float x, y, z;
|
||||
target->GetContactPoint(m_creature, x, y, z);
|
||||
m_creature->SetSpeed(MOVE_RUN, 5.0f);
|
||||
m_creature->GetMotionMaster()->Clear();
|
||||
m_creature->GetMotionMaster()->MovePoint(0, x, y, z);
|
||||
|
||||
Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1, GetSpellMaxRange(SPELL_SURGE), true);
|
||||
DoCast(target, SPELL_SURGE);
|
||||
Surge_Timer = 15000 + rand()%5000;
|
||||
return;
|
||||
}else Surge_Timer -= diff;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if(LaceratingSlash_Timer < diff)
|
||||
{
|
||||
DoCast(m_creature->getVictim(), SPELL_LACERATINGSLASH);
|
||||
|
||||
Reference in New Issue
Block a user