Skip to content

Commit

Permalink
[9120] Implement option to use delay in ForcedDespawn for creature
Browse files Browse the repository at this point in the history
Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed Jan 7, 2010
1 parent c0e3cc9 commit b5d446f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
20 changes: 18 additions & 2 deletions src/game/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
return true;
}

bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
m_owner.ForcedDespawn();
return true;
}

Creature::Creature() :
Unit(), i_AI(NULL),
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
Expand Down Expand Up @@ -1294,9 +1300,19 @@ void Creature::Respawn()
}
}

void Creature::ForcedDespawn()
void Creature::ForcedDespawn(uint32 timeMSToDespawn)
{
setDeathState(JUST_DIED);
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
}
Expand Down
12 changes: 11 additions & 1 deletion src/game/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
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;
Expand Down Expand Up @@ -660,4 +660,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
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9119"
#define REVISION_NR "9120"
#endif // __REVISION_NR_H__

0 comments on commit b5d446f

Please sign in to comment.