[8040] Implement Creature::ForcedDespawn and ACTION_T_FORCE_DESPAWN for EventAI.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
NoFantasy 2009-06-18 19:10:18 +04:00 committed by VladimirMangos
parent 23c96493b1
commit 68848314e2
9 changed files with 33 additions and 23 deletions

View file

@ -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. 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. 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) 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) * = 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. 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) 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 Target Types
========================================= =========================================

View file

@ -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) bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo)
{ {
if (!spellInfo) if (!spellInfo)

View file

@ -629,6 +629,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
void RemoveCorpse(); void RemoveCorpse();
bool isDeadByDefault() const { return m_isDeadByDefault; }; bool isDeadByDefault() const { return m_isDeadByDefault; };
void ForcedDespawn();
time_t const& GetRespawnTime() const { return m_respawnTime; } time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const; time_t GetRespawnTimeEx() const;
void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; } void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }

View file

@ -780,6 +780,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
m_creature->SetSheath(SheathState(action.set_sheath.sheath)); m_creature->SetSheath(SheathState(action.set_sheath.sheath));
break; break;
} }
case ACTION_T_FORCE_DESPAWN:
{
m_creature->ForcedDespawn();
break;
}
} }
} }

View file

@ -105,6 +105,7 @@ enum EventAI_ActionType
ACTION_T_ZONE_COMBAT_PULSE = 38, // No Params ACTION_T_ZONE_COMBAT_PULSE = 38, // No Params
ACTION_T_CALL_FOR_HELP = 39, // Radius ACTION_T_CALL_FOR_HELP = 39, // Radius
ACTION_T_SET_SHEATH = 40, // Sheath (0-passive,1-melee,2-ranged) ACTION_T_SET_SHEATH = 40, // Sheath (0-passive,1-melee,2-ranged)
ACTION_T_FORCE_DESPAWN = 41, // No Params
ACTION_T_END, ACTION_T_END,
}; };

View file

@ -666,6 +666,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case ACTION_T_FLEE_FOR_ASSIST: //No Params case ACTION_T_FLEE_FOR_ASSIST: //No Params
case ACTION_T_DIE: //No Params case ACTION_T_DIE: //No Params
case ACTION_T_ZONE_COMBAT_PULSE: //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_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_COMBAT_MOVEMENT: //AllowCombatMovement (0 = stop combat based movement, anything else continue attacking)
case ACTION_T_RANGED_MOVEMENT: //Distance, Angle case ACTION_T_RANGED_MOVEMENT: //Distance, Angle

View file

@ -1563,9 +1563,7 @@ void Aura::TriggerSpell()
player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId,LootTemplates_Skinning,true); player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId,LootTemplates_Skinning,true);
creature->setDeathState(JUST_DIED); creature->ForcedDespawn();
creature->RemoveCorpse();
creature->SetHealth(0); // just for nice GM-mode view
} }
return; return;
} }
@ -1714,9 +1712,7 @@ void Aura::TriggerSpell()
Creature* creatureTarget = (Creature*)m_target; Creature* creatureTarget = (Creature*)m_target;
creatureTarget->setDeathState(JUST_DIED); creatureTarget->ForcedDespawn();
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
return; return;
} }
// // Magic Sucker Device timer // // Magic Sucker Device timer

View file

@ -735,9 +735,8 @@ void Spell::EffectDummy(uint32 i)
return; return;
Creature* creatureTarget = (Creature*)unitTarget; Creature* creatureTarget = (Creature*)unitTarget;
creatureTarget->setDeathState(JUST_DIED);
creatureTarget->RemoveCorpse(); creatureTarget->ForcedDespawn();
creatureTarget->SetHealth(0); // just for nice GM-mode view
return; return;
} }
case 16589: // Noggenfogger Elixir case 16589: // Noggenfogger Elixir
@ -810,9 +809,7 @@ void Spell::EffectDummy(uint32 i)
pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() ); pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() );
pGameObj->SetSpellId(m_spellInfo->Id); pGameObj->SetSpellId(m_spellInfo->Id);
creatureTarget->setDeathState(JUST_DIED); creatureTarget->ForcedDespawn();
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
DEBUG_LOG("AddObject at SpellEfects.cpp EffectDummy"); DEBUG_LOG("AddObject at SpellEfects.cpp EffectDummy");
map->Add(pGameObj); map->Add(pGameObj);
@ -1026,9 +1023,7 @@ void Spell::EffectDummy(uint32 i)
Creature* creatureTarget = (Creature*)unitTarget; Creature* creatureTarget = (Creature*)unitTarget;
creatureTarget->setDeathState(JUST_DIED); creatureTarget->ForcedDespawn();
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
//cast spell Raptor Capture Credit //cast spell Raptor Capture Credit
m_caster->CastSpell(m_caster, 42337, true, NULL); m_caster->CastSpell(m_caster, 42337, true, NULL);
@ -1117,9 +1112,7 @@ void Spell::EffectDummy(uint32 i)
Creature* creatureTarget = (Creature*)unitTarget; Creature* creatureTarget = (Creature*)unitTarget;
creatureTarget->setDeathState(JUST_DIED); creatureTarget->ForcedDespawn();
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
return; return;
} }
@ -4040,10 +4033,8 @@ void Spell::EffectTameCreature(uint32 /*i*/)
if(!pet) // in versy specific state like near world end/etc. if(!pet) // in versy specific state like near world end/etc.
return; return;
// kill original creature // "kill" original creature
creatureTarget->setDeathState(JUST_DIED); creatureTarget->ForcedDespawn();
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
uint32 level = (creatureTarget->getLevel() < (m_caster->getLevel() - 5)) ? (m_caster->getLevel() - 5) : creatureTarget->getLevel(); uint32 level = (creatureTarget->getLevel() < (m_caster->getLevel() - 5)) ? (m_caster->getLevel() - 5) : creatureTarget->getLevel();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8039" #define REVISION_NR "8040"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__