mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[10390] Add several new script calls for InstanceData
OnCreature Evade/Death/EnterCombat and in addition OnPlayerLeave The functions are intended to help doing instance related tasks (in other words, not for the general AI of creatures). Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
1fd4ff3155
commit
9c02f476ec
4 changed files with 33 additions and 1 deletions
|
|
@ -57,12 +57,24 @@ 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 leaves the instance (before really removed from map (or possibly world))
|
||||||
|
virtual void OnPlayerLeave(Player *) {}
|
||||||
|
|
||||||
//Called when a gameobject is created
|
//Called when a gameobject is created
|
||||||
virtual void OnObjectCreate(GameObject *) {}
|
virtual void OnObjectCreate(GameObject *) {}
|
||||||
|
|
||||||
//called on creature creation
|
//called on creature creation
|
||||||
virtual void OnCreatureCreate(Creature * /*creature*/) {}
|
virtual void OnCreatureCreate(Creature * /*creature*/) {}
|
||||||
|
|
||||||
|
//called on creature enter combat
|
||||||
|
virtual void OnCreatureEnterCombat(Creature * /*creature*/) {}
|
||||||
|
|
||||||
|
//called on creature evade
|
||||||
|
virtual void OnCreatureEvade(Creature * /*creature*/) {}
|
||||||
|
|
||||||
|
//called on creature death
|
||||||
|
virtual void OnCreatureDeath(Creature * /*creature*/) {}
|
||||||
|
|
||||||
//All-purpose data storage 64 bit
|
//All-purpose data storage 64 bit
|
||||||
virtual uint64 GetData64(uint32 /*Data*/) { return 0; }
|
virtual uint64 GetData64(uint32 /*Data*/) { return 0; }
|
||||||
virtual void SetData64(uint32 /*Data*/, uint64 /*Value*/) { }
|
virtual void SetData64(uint32 /*Data*/, uint64 /*Value*/) { }
|
||||||
|
|
|
||||||
|
|
@ -1824,10 +1824,16 @@ void BattleGroundMap::Update(const uint32& diff)
|
||||||
void InstanceMap::Remove(Player *player, bool remove)
|
void InstanceMap::Remove(Player *player, bool remove)
|
||||||
{
|
{
|
||||||
DETAIL_LOG("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName());
|
DETAIL_LOG("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName());
|
||||||
|
|
||||||
//if last player set unload timer
|
//if last player set unload timer
|
||||||
if(!m_unloadTimer && m_mapRefManager.getSize() == 1)
|
if(!m_unloadTimer && m_mapRefManager.getSize() == 1)
|
||||||
m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_UINT32_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY);
|
m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_UINT32_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY);
|
||||||
|
|
||||||
|
if (i_data)
|
||||||
|
i_data->OnPlayerLeave(player);
|
||||||
|
|
||||||
Map::Remove(player, remove);
|
Map::Remove(player, remove);
|
||||||
|
|
||||||
// for normal instances schedule the reset after all players have left
|
// for normal instances schedule the reset after all players have left
|
||||||
SetResetSchedule(true);
|
SetResetSchedule(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "Totem.h"
|
#include "Totem.h"
|
||||||
#include "BattleGround.h"
|
#include "BattleGround.h"
|
||||||
|
#include "InstanceData.h"
|
||||||
#include "InstanceSaveMgr.h"
|
#include "InstanceSaveMgr.h"
|
||||||
#include "GridNotifiersImpl.h"
|
#include "GridNotifiersImpl.h"
|
||||||
#include "CellImpl.h"
|
#include "CellImpl.h"
|
||||||
|
|
@ -814,6 +815,9 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
||||||
((Creature*)pOwner)->AI()->SummonedCreatureJustDied(cVictim);
|
((Creature*)pOwner)->AI()->SummonedCreatureJustDied(cVictim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (InstanceData* mapInstance = cVictim->GetInstanceData())
|
||||||
|
mapInstance->OnCreatureDeath(cVictim);
|
||||||
|
|
||||||
// Dungeon specific stuff, only applies to players killing creatures
|
// Dungeon specific stuff, only applies to players killing creatures
|
||||||
if(cVictim->GetInstanceId())
|
if(cVictim->GetInstanceId())
|
||||||
{
|
{
|
||||||
|
|
@ -7470,6 +7474,9 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
|
||||||
|
|
||||||
if (((Creature*)this)->AI())
|
if (((Creature*)this)->AI())
|
||||||
((Creature*)this)->AI()->EnterCombat(enemy);
|
((Creature*)this)->AI()->EnterCombat(enemy);
|
||||||
|
|
||||||
|
if (InstanceData* mapInstance = this->GetInstanceData())
|
||||||
|
mapInstance->OnCreatureEnterCombat((Creature*)this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8329,6 +8336,10 @@ void Unit::TauntFadeOut(Unit *taunter)
|
||||||
{
|
{
|
||||||
if(((Creature*)this)->AI())
|
if(((Creature*)this)->AI())
|
||||||
((Creature*)this)->AI()->EnterEvadeMode();
|
((Creature*)this)->AI()->EnterEvadeMode();
|
||||||
|
|
||||||
|
if (InstanceData* mapInstance = this->GetInstanceData())
|
||||||
|
mapInstance->OnCreatureEvade((Creature*)this);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8424,6 +8435,9 @@ bool Unit::SelectHostileTarget()
|
||||||
// enter in evade mode in other case
|
// enter in evade mode in other case
|
||||||
((Creature*)this)->AI()->EnterEvadeMode();
|
((Creature*)this)->AI()->EnterEvadeMode();
|
||||||
|
|
||||||
|
if (InstanceData* mapInstance = this->GetInstanceData())
|
||||||
|
mapInstance->OnCreatureEvade((Creature*)this);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10389"
|
#define REVISION_NR "10390"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue