Scripts: Replaced calls to ForcedDespawn with DespawnOrUnsummon (calls appropriate AI hooks in case of temporary summons) and made ForcedDespawn private

This commit is contained in:
Shauren
2012-04-24 16:53:37 +02:00
parent 396b1ded1a
commit 1851a2e9e3
18 changed files with 32 additions and 31 deletions
@@ -135,7 +135,7 @@ CreatureBaseStats const* CreatureBaseStats::GetBaseStats(uint8 level, uint8 unit
bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{ {
m_owner.ForcedDespawn(); m_owner.DespawnOrUnsummon(); // since we are here, we are not TempSummon as object type cannot change during runtime
return true; return true;
} }
+2 -1
View File
@@ -635,7 +635,6 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
void RemoveCorpse(bool setSpawnTime = true); void RemoveCorpse(bool setSpawnTime = true);
void ForcedDespawn(uint32 timeMSToDespawn = 0);
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0); void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
time_t const& GetRespawnTime() const { return m_respawnTime; } time_t const& GetRespawnTime() const { return m_respawnTime; }
@@ -763,6 +762,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
bool IsInvisibleDueToDespawn() const; bool IsInvisibleDueToDespawn() const;
bool CanAlwaysSee(WorldObject const* obj) const; bool CanAlwaysSee(WorldObject const* obj) const;
private: private:
void ForcedDespawn(uint32 timeMSToDespawn = 0);
//WaypointMovementGenerator vars //WaypointMovementGenerator vars
uint32 m_waypointID; uint32 m_waypointID;
uint32 m_path_id; uint32 m_path_id;
@@ -664,7 +664,7 @@ public:
{ {
CAST_PLR(charmer)->GroupEventHappens(12687, me); CAST_PLR(charmer)->GroupEventHappens(12687, me);
charmer->RemoveAurasDueToSpell(SPELL_EFFECT_OVERTAKE); charmer->RemoveAurasDueToSpell(SPELL_EFFECT_OVERTAKE);
CAST_CRE(who)->ForcedDespawn(); CAST_CRE(who)->DespawnOrUnsummon();
//CAST_CRE(who)->Respawn(true); //CAST_CRE(who)->Respawn(true);
} }
@@ -767,7 +767,7 @@ public:
//Todo: Creatures must not be removed, but, must instead //Todo: Creatures must not be removed, but, must instead
// stand next to Gothik and be commanded into the pit // stand next to Gothik and be commanded into the pit
// and dig into the ground. // and dig into the ground.
CAST_CRE(who)->ForcedDespawn(); CAST_CRE(who)->DespawnOrUnsummon();
if (CAST_PLR(owner)->GetQuestStatus(12698) == QUEST_STATUS_COMPLETE) if (CAST_PLR(owner)->GetQuestStatus(12698) == QUEST_STATUS_COMPLETE)
owner->RemoveAllMinionsByEntry(GHOULS); owner->RemoveAllMinionsByEntry(GHOULS);
@@ -193,7 +193,7 @@ public:
if (type == POINT_MOTION_TYPE && id == 1) if (type == POINT_MOTION_TYPE && id == 1)
{ {
DoScriptText(SAY_DIRECTION, me); DoScriptText(SAY_DIRECTION, me);
me->ForcedDespawn(); me->DespawnOrUnsummon();
} }
} }
}; };
+2 -2
View File
@@ -264,7 +264,7 @@ class npc_tiger_matriarch : public CreatureScript
vehSummoner->RemoveAurasDueToSpell(SPELL_SPIRIT_OF_THE_TIGER_RIDER); vehSummoner->RemoveAurasDueToSpell(SPELL_SPIRIT_OF_THE_TIGER_RIDER);
vehSummoner->RemoveAurasDueToSpell(SPELL_SUMMON_ZENTABRA_TRIGGER); vehSummoner->RemoveAurasDueToSpell(SPELL_SUMMON_ZENTABRA_TRIGGER);
} }
me->ForcedDespawn(); me->DespawnOrUnsummon();
} }
void DamageTaken(Unit* attacker, uint32& damage) void DamageTaken(Unit* attacker, uint32& damage)
@@ -287,7 +287,7 @@ class npc_tiger_matriarch : public CreatureScript
vehSummoner->RemoveAurasDueToSpell(SPELL_SUMMON_ZENTABRA_TRIGGER); vehSummoner->RemoveAurasDueToSpell(SPELL_SUMMON_ZENTABRA_TRIGGER);
} }
me->ForcedDespawn(); me->DespawnOrUnsummon();
} }
} }
@@ -847,7 +847,7 @@ public:
player->KilledMonsterCredit(NPC_THERAMORE_PRISONER, 0); player->KilledMonsterCredit(NPC_THERAMORE_PRISONER, 0);
prisoner->AI()->Talk(SAY_FREE); // We also emote cry here (handled in creature_text.emote) prisoner->AI()->Talk(SAY_FREE); // We also emote cry here (handled in creature_text.emote)
prisoner->ForcedDespawn(6000); prisoner->DespawnOrUnsummon(6000);
} }
return true; return true;
} }
@@ -262,7 +262,7 @@ class ValithriaDespawner : public BasicEvent
if (CreatureData const* data = creature->GetCreatureData()) if (CreatureData const* data = creature->GetCreatureData())
creature->SetPosition(data->posX, data->posY, data->posZ, data->orientation); creature->SetPosition(data->posX, data->posY, data->posZ, data->orientation);
creature->ForcedDespawn(); creature->DespawnOrUnsummon();
creature->SetCorpseDelay(corpseDelay); creature->SetCorpseDelay(corpseDelay);
creature->SetRespawnDelay(respawnDelay); creature->SetRespawnDelay(respawnDelay);
@@ -1087,7 +1087,7 @@ class npc_dream_cloud : public CreatureScript
me->GetMotionMaster()->MoveIdle(); me->GetMotionMaster()->MoveIdle();
// must use originalCaster the same for all clouds to allow stacking // must use originalCaster the same for all clouds to allow stacking
me->CastSpell(me, EMERALD_VIGOR, false, NULL, NULL, _instance->GetData64(DATA_VALITHRIA_DREAMWALKER)); me->CastSpell(me, EMERALD_VIGOR, false, NULL, NULL, _instance->GetData64(DATA_VALITHRIA_DREAMWALKER));
me->ForcedDespawn(100); me->DespawnOrUnsummon(100);
break; break;
default: default:
break; break;
@@ -346,7 +346,7 @@ class FrostwingGauntletRespawner
if (CreatureData const* data = creature->GetCreatureData()) if (CreatureData const* data = creature->GetCreatureData())
creature->SetPosition(data->posX, data->posY, data->posZ, data->orientation); creature->SetPosition(data->posX, data->posY, data->posZ, data->orientation);
creature->ForcedDespawn(); creature->DespawnOrUnsummon();
creature->SetCorpseDelay(corpseDelay); creature->SetCorpseDelay(corpseDelay);
creature->SetRespawnDelay(respawnDelay); creature->SetRespawnDelay(respawnDelay);
@@ -298,14 +298,14 @@ class npc_auriaya_seeping_trigger : public CreatureScript
void Reset() void Reset()
{ {
me->ForcedDespawn(600000); me->DespawnOrUnsummon(600000);
DoCast(me, SPELL_SEEPING_ESSENCE); DoCast(me, SPELL_SEEPING_ESSENCE);
} }
void UpdateAI(uint32 const /*diff*/) void UpdateAI(uint32 const /*diff*/)
{ {
if (instance->GetBossState(BOSS_AURIAYA) != IN_PROGRESS) if (instance->GetBossState(BOSS_AURIAYA) != IN_PROGRESS)
me->ForcedDespawn(); me->DespawnOrUnsummon();
} }
private: private:
@@ -507,7 +507,7 @@ class boss_freya : public CreatureScript
for (uint8 n = 0; n < 3; ++n) for (uint8 n = 0; n < 3; ++n)
{ {
summons.remove(Elemental[n][i]->GetGUID()); summons.remove(Elemental[n][i]->GetGUID());
Elemental[n][i]->ForcedDespawn(5000); Elemental[n][i]->DespawnOrUnsummon(5000);
trioDefeated[i] = true; trioDefeated[i] = true;
Elemental[n][i]->CastSpell(me, SPELL_REMOVE_10STACK, true); Elemental[n][i]->CastSpell(me, SPELL_REMOVE_10STACK, true);
} }
@@ -664,12 +664,12 @@ class boss_freya : public CreatureScript
case NPC_DETONATING_LASHER: case NPC_DETONATING_LASHER:
summoned->CastSpell(me, SPELL_REMOVE_2STACK, true); summoned->CastSpell(me, SPELL_REMOVE_2STACK, true);
summoned->CastSpell(who, SPELL_DETONATE, true); summoned->CastSpell(who, SPELL_DETONATE, true);
summoned->ForcedDespawn(5000); summoned->DespawnOrUnsummon(5000);
summons.remove(summoned->GetGUID()); summons.remove(summoned->GetGUID());
break; break;
case NPC_ANCIENT_CONSERVATOR: case NPC_ANCIENT_CONSERVATOR:
summoned->CastSpell(me, SPELL_REMOVE_25STACK, true); summoned->CastSpell(me, SPELL_REMOVE_25STACK, true);
summoned->ForcedDespawn(5000); summoned->DespawnOrUnsummon(5000);
summons.remove(summoned->GetGUID()); summons.remove(summoned->GetGUID());
break; break;
} }
@@ -1385,7 +1385,7 @@ class npc_healthy_spore : public CreatureScript
if (lifeTimer <= diff) if (lifeTimer <= diff)
{ {
me->RemoveAurasDueToSpell(SPELL_GROW); me->RemoveAurasDueToSpell(SPELL_GROW);
me->ForcedDespawn(2200); me->DespawnOrUnsummon(2200);
lifeTimer = urand(22000, 30000); lifeTimer = urand(22000, 30000);
} }
else else
@@ -1423,7 +1423,7 @@ class npc_eonars_gift : public CreatureScript
{ {
me->RemoveAurasDueToSpell(SPELL_GROW); me->RemoveAurasDueToSpell(SPELL_GROW);
DoCast(SPELL_LIFEBINDERS_GIFT); DoCast(SPELL_LIFEBINDERS_GIFT);
me->ForcedDespawn(2500); me->DespawnOrUnsummon(2500);
lifeBindersGiftTimer = 12000; lifeBindersGiftTimer = 12000;
} }
else else
@@ -186,7 +186,7 @@ public:
if (owner->GetTypeId() == TYPEID_PLAYER) if (owner->GetTypeId() == TYPEID_PLAYER)
{ {
owner->CastSpell(owner, 46231, true); owner->CastSpell(owner, 46231, true);
CAST_CRE(who)->ForcedDespawn(); CAST_CRE(who)->DespawnOrUnsummon();
} }
} }
} }
+3 -3
View File
@@ -550,7 +550,7 @@ public:
// drake unsummoned, passengers dropped // drake unsummoned, passengers dropped
if (!me->IsOnVehicle(drake) && !hasEmptySeats) if (!me->IsOnVehicle(drake) && !hasEmptySeats)
me->ForcedDespawn(3000); me->DespawnOrUnsummon(3000);
if (enter_timer <= 0) if (enter_timer <= 0)
return; return;
@@ -605,7 +605,7 @@ public:
me->ExitVehicle(); me->ExitVehicle();
me->CastSpell(me, SPELL_SUMMON_LIBERATED, true); me->CastSpell(me, SPELL_SUMMON_LIBERATED, true);
me->ForcedDespawn(500); me->DespawnOrUnsummon(500);
// drake is empty now, deliver credit for drake and despawn him // drake is empty now, deliver credit for drake and despawn him
if (drake->GetVehicleKit()->HasEmptySeat(1) && if (drake->GetVehicleKit()->HasEmptySeat(1) &&
@@ -616,7 +616,7 @@ public:
if (rider->ToPlayer()) if (rider->ToPlayer())
rider->ToPlayer()->KilledMonsterCredit(29709, 0); rider->ToPlayer()->KilledMonsterCredit(29709, 0);
drake->ForcedDespawn(0); drake->DespawnOrUnsummon(0);
} }
} }
} }
@@ -855,7 +855,7 @@ class npc_simon_bunny : public CreatureScript
if (GameObject* relic = me->FindNearestGameObject(large ? GO_APEXIS_MONUMENT : GO_APEXIS_RELIC, searchDistance)) if (GameObject* relic = me->FindNearestGameObject(large ? GO_APEXIS_MONUMENT : GO_APEXIS_RELIC, searchDistance))
relic->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); relic->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
me->ForcedDespawn(1000); me->DespawnOrUnsummon(1000);
} }
/* /*
+2 -2
View File
@@ -450,7 +450,7 @@ public:
{ {
if (Say_Timer <= diff) if (Say_Timer <= diff)
{ {
me->ForcedDespawn(); me->DespawnOrUnsummon();
ReleasedFromCage = false; ReleasedFromCage = false;
} }
else else
@@ -689,7 +689,7 @@ class go_warmaul_prison : public GameObjectScript
player->KilledMonsterCredit(NPC_MAGHAR_PRISONER, 0); player->KilledMonsterCredit(NPC_MAGHAR_PRISONER, 0);
prisoner->AI()->Talk(SAY_FREE, player->GetGUID()); prisoner->AI()->Talk(SAY_FREE, player->GetGUID());
prisoner->ForcedDespawn(6000); prisoner->DespawnOrUnsummon(6000);
} }
return true; return true;
} }
+1 -1
View File
@@ -1057,7 +1057,7 @@ class go_captain_tyralius_prison : public GameObjectScript
player->KilledMonsterCredit(NPC_CAPTAIN_TYRALIUS, 0); player->KilledMonsterCredit(NPC_CAPTAIN_TYRALIUS, 0);
tyralius->AI()->Talk(SAY_FREE); tyralius->AI()->Talk(SAY_FREE);
tyralius->ForcedDespawn(8000); tyralius->DespawnOrUnsummon(8000);
} }
return true; return true;
} }
+1 -1
View File
@@ -2006,7 +2006,7 @@ class spell_item_muisek_vessel : public SpellScriptLoader
{ {
if (Creature* target = GetHitCreature()) if (Creature* target = GetHitCreature())
if (target->isDead()) if (target->isDead())
target->ForcedDespawn(); target->DespawnOrUnsummon();
} }
void Register() void Register()
+1 -1
View File
@@ -837,7 +837,7 @@ class spell_q12659_ahunaes_knife : public SpellScriptLoader
Player* caster = GetCaster()->ToPlayer(); Player* caster = GetCaster()->ToPlayer();
if (Creature* target = GetHitCreature()) if (Creature* target = GetHitCreature())
{ {
target->ForcedDespawn(); target->DespawnOrUnsummon();
caster->KilledMonsterCredit(NPC_SCALPS_KC_BUNNY, 0); caster->KilledMonsterCredit(NPC_SCALPS_KC_BUNNY, 0);
} }
} }
+3 -3
View File
@@ -1174,7 +1174,7 @@ class go_gjalerbron_cage : public GameObjectScript
player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, 0); player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, 0);
prisoner->AI()->Talk(SAY_FREE); prisoner->AI()->Talk(SAY_FREE);
prisoner->ForcedDespawn(6000); prisoner->DespawnOrUnsummon(6000);
} }
} }
return true; return true;
@@ -1201,7 +1201,7 @@ class go_large_gjalerbron_cage : public GameObjectScript
{ {
go->UseDoorOrButton(); go->UseDoorOrButton();
player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, (*itr)->GetGUID()); player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, (*itr)->GetGUID());
(*itr)->ForcedDespawn(6000); (*itr)->DespawnOrUnsummon(6000);
(*itr)->AI()->Talk(SAY_FREE); (*itr)->AI()->Talk(SAY_FREE);
} }
} }
@@ -1235,7 +1235,7 @@ class go_veil_skith_cage : public GameObjectScript
{ {
go->UseDoorOrButton(); go->UseDoorOrButton();
player->KilledMonsterCredit(NPC_CAPTIVE_CHILD, (*itr)->GetGUID()); player->KilledMonsterCredit(NPC_CAPTIVE_CHILD, (*itr)->GetGUID());
(*itr)->ForcedDespawn(5000); (*itr)->DespawnOrUnsummon(5000);
(*itr)->GetMotionMaster()->MovePoint(1, go->GetPositionX()+5, go->GetPositionY(), go->GetPositionZ()); (*itr)->GetMotionMaster()->MovePoint(1, go->GetPositionX()+5, go->GetPositionY(), go->GetPositionZ());
(*itr)->AI()->Talk(SAY_FREE_0); (*itr)->AI()->Talk(SAY_FREE_0);
(*itr)->GetMotionMaster()->Clear(); (*itr)->GetMotionMaster()->Clear();