Implement option to use delay in ForcedDespawn for creature, allow use delayed forced despawn also in EAI, by NoFantasy.

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2010-01-16 19:51:59 +03:00
parent a29727e423
commit 720318e856
4 changed files with 37 additions and 5 deletions
+17 -1
View File
@@ -137,6 +137,12 @@ CreatureBaseStats const* CreatureBaseStats::GetBaseStats(uint32 level, uint8 uni
return objmgr.GetCreatureBaseStats(level, unitClass);
}
bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
m_owner.ForcedDespawn();
return true;
}
Creature::Creature() :
Unit(),
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
@@ -1586,9 +1592,19 @@ void Creature::Respawn(bool force)
SetToNotify();
}
void Creature::ForcedDespawn()
void Creature::ForcedDespawn(uint32 timeMSToDespawn)
{
if (timeMSToDespawn)
{
ForcedDespawnDelayEvent *pEvent = new ForcedDespawnDelayEvent(*this);
m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn));
return;
}
if (isAlive())
setDeathState(JUST_DIED);
RemoveCorpse();
SetHealth(0); // just for nice GM-mode view
}
+12 -1
View File
@@ -589,7 +589,7 @@ class TRINITY_DLL_SPEC Creature : public Unit, public GridObject<Creature>
void RemoveCorpse();
bool isDeadByDefault() const { return m_isDeadByDefault; };
void ForcedDespawn();
void ForcedDespawn(uint32 timeMSToDespawn = 0);
time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const;
@@ -710,6 +710,7 @@ class TRINITY_DLL_SPEC Creature : public Unit, public GridObject<Creature>
CreatureData const* m_creatureData;
uint16 m_LootMode; // bitmask, default DEFAULT_LOOT_MODE, determines what loot will be lootable
private:
//WaypointMovementGenerator vars
uint32 m_waypointID;
@@ -734,4 +735,14 @@ class AssistDelayEvent : public BasicEvent
Unit& m_owner;
};
class ForcedDespawnDelayEvent : public BasicEvent
{
public:
ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
bool Execute(uint64 e_time, uint32 p_time);
private:
Creature& m_owner;
};
#endif
+1 -1
View File
@@ -801,7 +801,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
case ACTION_T_FORCE_DESPAWN:
{
m_creature->ForcedDespawn();
m_creature->ForcedDespawn(action.forced_despawn.msDelay);
break;
}
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL:
+5
View File
@@ -387,6 +387,11 @@ struct CreatureEventAI_Action
{
uint32 sheath;
} set_sheath;
// ACTION_T_FORCE_DESPAWN = 41
struct
{
uint32 msDelay;
} forced_despawn;
// ACTION_T_SET_INVINCIBILITY_HP_LEVEL = 42
struct
{