Scripts/Pit of Saron: Changed Overlord's Brand script to be safer

Closes #9125
This commit is contained in:
Shauren
2013-04-12 17:54:40 +02:00
parent e3feabefec
commit 24a7a6f965
3 changed files with 31 additions and 16 deletions
-2
View File
@@ -2392,8 +2392,6 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
case SUMMON_CATEGORY_VEHICLE:
// Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker
// to cast a ride vehicle spell on the summoned unit.
float x, y, z;
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
summon = m_originalCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_caster, m_spellInfo->Id);
if (!summon || !summon->IsVehicle())
return;
@@ -136,9 +136,7 @@ class boss_tyrannus : public CreatureScript
void InitializeAI()
{
if (!instance || static_cast<InstanceMap*>(me->GetMap())->GetScriptId() != sObjectMgr->GetScriptId(PoSScriptName))
me->IsAIEnabled = false;
else if (instance->GetBossState(DATA_TYRANNUS) != DONE)
if (instance->GetBossState(DATA_TYRANNUS) != DONE)
Reset();
else
me->DespawnOrUnsummon();
@@ -281,7 +279,7 @@ class boss_tyrannus : public CreatureScript
CreatureAI* GetAI(Creature* creature) const
{
return new boss_tyrannusAI(creature);
return GetPitOfSaronAI<boss_tyrannusAI>(creature);
}
};
@@ -387,32 +385,32 @@ class boss_rimefang : public CreatureScript
class player_overlord_brandAI : public PlayerAI
{
public:
player_overlord_brandAI(Player* player) : PlayerAI(player)
player_overlord_brandAI(Player* player) : PlayerAI(player), _tyrannus(0)
{
tyrannus = NULL;
}
void SetGUID(uint64 guid, int32 /*type*/)
{
tyrannus = ObjectAccessor::GetCreature(*me, guid);
me->IsAIEnabled = tyrannus != NULL;
_tyrannus = guid;
}
void DamageDealt(Unit* /*victim*/, uint32& damage, DamageEffectType /*damageType*/)
{
if (tyrannus->getVictim())
me->CastCustomSpell(SPELL_OVERLORD_BRAND_DAMAGE, SPELLVALUE_BASE_POINT0, damage, tyrannus->getVictim(), true, NULL, NULL, tyrannus->GetGUID());
if (Creature* tyrannus = ObjectAccessor::GetCreature(*me, _tyrannus))
if (tyrannus->getVictim())
me->CastCustomSpell(SPELL_OVERLORD_BRAND_DAMAGE, SPELLVALUE_BASE_POINT0, damage, tyrannus->getVictim(), true, NULL, NULL, tyrannus->GetGUID());
}
void HealDone(Unit* /*target*/, uint32& addHealth)
{
me->CastCustomSpell(SPELL_OVERLORD_BRAND_HEAL, SPELLVALUE_BASE_POINT0, int32(addHealth*5.5f), tyrannus, true, NULL, NULL, tyrannus->GetGUID());
if (Creature* tyrannus = ObjectAccessor::GetCreature(*me, _tyrannus))
me->CastCustomSpell(SPELL_OVERLORD_BRAND_HEAL, SPELLVALUE_BASE_POINT0, int32(addHealth*5.5f), tyrannus, true, NULL, NULL, tyrannus->GetGUID());
}
void UpdateAI(uint32 /*diff*/) { }
private:
Creature* tyrannus;
uint64 _tyrannus;
};
class spell_tyrannus_overlord_brand : public SpellScriptLoader
@@ -424,6 +422,11 @@ class spell_tyrannus_overlord_brand : public SpellScriptLoader
{
PrepareAuraScript(spell_tyrannus_overlord_brand_AuraScript);
bool Load()
{
return GetCaster() && GetCaster()->GetEntry() == NPC_TYRANNUS;
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTarget()->GetTypeId() != TYPEID_PLAYER)
@@ -440,9 +443,10 @@ class spell_tyrannus_overlord_brand : public SpellScriptLoader
if (GetTarget()->GetTypeId() != TYPEID_PLAYER)
return;
delete GetTarget()->GetAI();
GetTarget()->SetAI(oldAI);
GetTarget()->IsAIEnabled = oldAIState;
UnitAI* thisAI = GetTarget()->GetAI();
GetTarget()->SetAI(oldAI);
delete thisAI;
}
void Register()
@@ -18,6 +18,9 @@
#ifndef DEF_PIT_OF_SARON_H
#define DEF_PIT_OF_SARON_H
#include "Map.h"
#include "Creature.h"
#define PoSScriptName "instance_pit_of_saron"
#define MAX_ENCOUNTER 3
@@ -94,4 +97,14 @@ enum GameObjectIds
GO_HALLS_OF_REFLECTION_PORTCULLIS = 201848,
};
template<class AI>
AI* GetPitOfSaronAI(Creature* creature)
{
if (InstanceMap* instance = creature->GetMap()->ToInstanceMap())
if (instance->GetInstanceScript())
if (instance->GetScriptId() == sObjectMgr->GetScriptId(PoSScriptName))
return new AI(creature);
return NULL;
}
#endif