Scripts/Serpentshrine Cavern: Fixed crash in boss_leotheras_the_blind caused by uninitialized variable; also replaced unsafe AI typecasting with Get/SetGUID

This commit is contained in:
Shauren
2012-03-19 17:03:39 +01:00
parent 847b4366f3
commit f0ac821e0b
@@ -53,6 +53,7 @@ EndScriptData */
#define MODEL_NIGHTELF 20514 #define MODEL_NIGHTELF 20514
#define DEMON_FORM 21875 #define DEMON_FORM 21875
#define MOB_SPELLBINDER 21806 #define MOB_SPELLBINDER 21806
#define INNER_DEMON_VICTIM 1
#define SAY_AGGRO -1548009 #define SAY_AGGRO -1548009
#define SAY_SWITCH_TO_DEMON -1548010 #define SAY_SWITCH_TO_DEMON -1548010
@@ -94,6 +95,20 @@ public:
ShadowBolt_Timer = 10000; ShadowBolt_Timer = 10000;
Link_Timer = 1000; Link_Timer = 1000;
} }
void SetGUID(uint64 guid, int32 id/* = 0 */)
{
if (id == INNER_DEMON_VICTIM)
victimGUID = guid;
}
uint64 GetGUID(int32 id/* = 0 */)
{
if (id == INNER_DEMON_VICTIM)
return victimGUID;
return 0;
}
void JustDied(Unit* /*victim*/) void JustDied(Unit* /*victim*/)
{ {
Unit* unit = Unit::GetUnit((*me), victimGUID); Unit* unit = Unit::GetUnit((*me), victimGUID);
@@ -219,6 +234,7 @@ public:
IsFinalForm = false; IsFinalForm = false;
NeedThreatReset = false; NeedThreatReset = false;
EnrageUsed = false; EnrageUsed = false;
memset(InnderDemon, 0, sizeof(InnderDemon));
InnerDemon_Count = 0; InnerDemon_Count = 0;
me->SetSpeed(MOVE_RUN, 2.0f, true); me->SetSpeed(MOVE_RUN, 2.0f, true);
me->SetDisplayId(MODEL_NIGHTELF); me->SetDisplayId(MODEL_NIGHTELF);
@@ -357,7 +373,7 @@ public:
Creature* unit = Unit::GetCreature((*me), InnderDemon[i]); Creature* unit = Unit::GetCreature((*me), InnderDemon[i]);
if (unit && unit->isAlive()) if (unit && unit->isAlive())
{ {
Unit* unit_target = Unit::GetUnit(*unit, CAST_AI(mob_inner_demon::mob_inner_demonAI, unit->AI())->victimGUID); Unit* unit_target = Unit::GetUnit(*unit, unit->AI()->GetGUID(INNER_DEMON_VICTIM));
if (unit_target && unit_target->isAlive()) if (unit_target && unit_target->isAlive())
{ {
unit->CastSpell(unit_target, SPELL_CONSUMING_MADNESS, true); unit->CastSpell(unit_target, SPELL_CONSUMING_MADNESS, true);
@@ -525,7 +541,7 @@ public:
if (demon) if (demon)
{ {
demon->AI()->AttackStart((*itr)); demon->AI()->AttackStart((*itr));
CAST_AI(mob_inner_demon::mob_inner_demonAI, demon->AI())->victimGUID = (*itr)->GetGUID(); demon->AI()->SetGUID((*itr)->GetGUID(), INNER_DEMON_VICTIM);
(*itr)->AddAura(SPELL_INSIDIOUS_WHISPER, *itr); (*itr)->AddAura(SPELL_INSIDIOUS_WHISPER, *itr);