[10393] Add script call for InstanceData, OnPlayerDeath

Called when a player really dies and also unrelated to the source of the death (for example a player can die indirectly from some mob ability, but must be registered. Achievements, other special events)

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-08-21 13:19:24 +02:00
parent 6756fff93a
commit 3332ed72a6
3 changed files with 10 additions and 1 deletions

View file

@ -57,6 +57,9 @@ class MANGOS_DLL_SPEC InstanceData
//Called when a player successfully enters the instance (after really added to map) //Called when a player successfully enters the instance (after really added to map)
virtual void OnPlayerEnter(Player *) {} virtual void OnPlayerEnter(Player *) {}
//Called when a player dies inside instance
virtual void OnPlayerDeath(Player *) {}
//Called when a player leaves the instance (before really removed from map (or possibly world)) //Called when a player leaves the instance (before really removed from map (or possibly world))
virtual void OnPlayerLeave(Player *) {} virtual void OnPlayerLeave(Player *) {}

View file

@ -37,6 +37,7 @@
#include "MapManager.h" #include "MapManager.h"
#include "MapInstanced.h" #include "MapInstanced.h"
#include "InstanceSaveMgr.h" #include "InstanceSaveMgr.h"
#include "InstanceData.h"
#include "GridNotifiers.h" #include "GridNotifiers.h"
#include "GridNotifiersImpl.h" #include "GridNotifiersImpl.h"
#include "CellImpl.h" #include "CellImpl.h"
@ -1508,10 +1509,15 @@ void Player::setDeathState(DeathState s)
// passive spell // passive spell
if(!ressSpellId) if(!ressSpellId)
ressSpellId = GetResurrectionSpellId(); ressSpellId = GetResurrectionSpellId();
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP, 1); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP, 1);
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATH, 1); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATH, 1);
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON, 1); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON, 1);
if (InstanceData* mapInstance = this->GetInstanceData())
mapInstance->OnPlayerDeath(this);
} }
Unit::setDeathState(s); Unit::setDeathState(s);
// restore resurrection spell id for player after aura remove // restore resurrection spell id for player after aura remove

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 "10392" #define REVISION_NR "10393"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__