From 68848314e2ae8182fe7f31f4a11694d25a8d5b8c Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Thu, 18 Jun 2009 19:10:18 +0400 Subject: [PATCH] [8040] Implement Creature::ForcedDespawn and ACTION_T_FORCE_DESPAWN for EventAI. Signed-off-by: VladimirMangos --- doc/EventAI.txt | 7 +++++++ src/game/Creature.cpp | 7 +++++++ src/game/Creature.h | 2 ++ src/game/CreatureEventAI.cpp | 5 +++++ src/game/CreatureEventAI.h | 1 + src/game/CreatureEventAIMgr.cpp | 1 + src/game/SpellAuras.cpp | 8 ++------ src/game/SpellEffects.cpp | 23 +++++++---------------- src/shared/revision_nr.h | 2 +- 9 files changed, 33 insertions(+), 23 deletions(-) diff --git a/doc/EventAI.txt b/doc/EventAI.txt index 0f411b628..2557bada9 100644 --- a/doc/EventAI.txt +++ b/doc/EventAI.txt @@ -132,6 +132,7 @@ Params are always read from Param1, then Param2, then Param3. 38 ACTION_T_ZONE_COMBAT_PULSE No Params Places all players within the instance into combat with the creature. Only works in combat and only works inside of instances. 39 ACTION_T_CALL_FOR_HELP Radius Call any friendly creatures (if its not in combat/etc) in radius attack creature target. 40 ACTION_T_SET_SHEATH Sheath Let set sheath state for creature (0-no weapon show (not used mostly by creatures), 1-melee weapon show, 2-ranged weapon show) +41 ACTION_T_FORCE_DESPAWN No Params Despawns the creature * = Use -1 to specify that if this param is picked to do nothing. Random is constant between actions within an event. So if you have a random Yell and a random Sound they will match up (ex: param2 with param2) @@ -725,6 +726,12 @@ Let set sheath state for creature. Note: SHEATH_STATE_RANGED case work in combat state only if combat not start as melee commands. This possible setup by set ar event AI start (single used EVENT_T_TIMER_OOC set ACTION_T_COMBAT_MOVEMENT 0 for creature that prefered ranged attack) +------------------------- +41 ACTION_T_FORCE_DESPAWN +------------------------- +Despawns the creature (in or out of combat) +No parameters + ========================================= Target Types ========================================= diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 921d86444..3de02a988 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1580,6 +1580,13 @@ void Creature::Respawn() } } +void Creature::ForcedDespawn() +{ + setDeathState(JUST_DIED); + RemoveCorpse(); + SetHealth(0); // just for nice GM-mode view +} + bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo) { if (!spellInfo) diff --git a/src/game/Creature.h b/src/game/Creature.h index c23631a35..834dec44b 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -629,6 +629,8 @@ class MANGOS_DLL_SPEC Creature : public Unit void RemoveCorpse(); bool isDeadByDefault() const { return m_isDeadByDefault; }; + void ForcedDespawn(); + time_t const& GetRespawnTime() const { return m_respawnTime; } time_t GetRespawnTimeEx() const; void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; } diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index b25a44797..bf5337f78 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -780,6 +780,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_creature->SetSheath(SheathState(action.set_sheath.sheath)); break; } + case ACTION_T_FORCE_DESPAWN: + { + m_creature->ForcedDespawn(); + break; + } } } diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index f3e74730b..6895df666 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -105,6 +105,7 @@ enum EventAI_ActionType ACTION_T_ZONE_COMBAT_PULSE = 38, // No Params ACTION_T_CALL_FOR_HELP = 39, // Radius ACTION_T_SET_SHEATH = 40, // Sheath (0-passive,1-melee,2-ranged) + ACTION_T_FORCE_DESPAWN = 41, // No Params ACTION_T_END, }; diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index 573ed9879..79f059961 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -666,6 +666,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case ACTION_T_FLEE_FOR_ASSIST: //No Params case ACTION_T_DIE: //No Params case ACTION_T_ZONE_COMBAT_PULSE: //No Params + case ACTION_T_FORCE_DESPAWN: //No Params case ACTION_T_AUTO_ATTACK: //AllowAttackState (0 = stop attack, anything else means continue attacking) case ACTION_T_COMBAT_MOVEMENT: //AllowCombatMovement (0 = stop combat based movement, anything else continue attacking) case ACTION_T_RANGED_MOVEMENT: //Distance, Angle diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 3c01c22aa..d42e7ccc3 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -1563,9 +1563,7 @@ void Aura::TriggerSpell() player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId,LootTemplates_Skinning,true); - creature->setDeathState(JUST_DIED); - creature->RemoveCorpse(); - creature->SetHealth(0); // just for nice GM-mode view + creature->ForcedDespawn(); } return; } @@ -1714,9 +1712,7 @@ void Aura::TriggerSpell() Creature* creatureTarget = (Creature*)m_target; - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view + creatureTarget->ForcedDespawn(); return; } // // Magic Sucker Device timer diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 1d673bf83..fa7ffe9ce 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -735,9 +735,8 @@ void Spell::EffectDummy(uint32 i) return; Creature* creatureTarget = (Creature*)unitTarget; - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view + + creatureTarget->ForcedDespawn(); return; } case 16589: // Noggenfogger Elixir @@ -810,9 +809,7 @@ void Spell::EffectDummy(uint32 i) pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() ); pGameObj->SetSpellId(m_spellInfo->Id); - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view + creatureTarget->ForcedDespawn(); DEBUG_LOG("AddObject at SpellEfects.cpp EffectDummy"); map->Add(pGameObj); @@ -1026,9 +1023,7 @@ void Spell::EffectDummy(uint32 i) Creature* creatureTarget = (Creature*)unitTarget; - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view + creatureTarget->ForcedDespawn(); //cast spell Raptor Capture Credit m_caster->CastSpell(m_caster, 42337, true, NULL); @@ -1117,9 +1112,7 @@ void Spell::EffectDummy(uint32 i) Creature* creatureTarget = (Creature*)unitTarget; - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view + creatureTarget->ForcedDespawn(); return; } @@ -4040,10 +4033,8 @@ void Spell::EffectTameCreature(uint32 /*i*/) if(!pet) // in versy specific state like near world end/etc. return; - // kill original creature - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view + // "kill" original creature + creatureTarget->ForcedDespawn(); uint32 level = (creatureTarget->getLevel() < (m_caster->getLevel() - 5)) ? (m_caster->getLevel() - 5) : creatureTarget->getLevel(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 731249243..132cab5c8 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8039" + #define REVISION_NR "8040" #endif // __REVISION_NR_H__