mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 01:37:00 +00:00
[11827] Implement Creature Linking via database
Thanks to Silverice for feedback! This system interprets the content of the table `creature_linking_template`. To trigger different actions on different events of the npcs that are linked together. Possible event/ action combinations can be taken form the flags in CreatureLinkingMgr.h::CreatureLinkingFlags
This commit is contained in:
parent
6edfcea7f0
commit
fbdd79141c
16 changed files with 783 additions and 7 deletions
|
|
@ -46,6 +46,7 @@
|
|||
#include "GridNotifiersImpl.h"
|
||||
#include "CellImpl.h"
|
||||
#include "movement/MoveSplineInit.h"
|
||||
#include "CreatureLinkingMgr.h"
|
||||
|
||||
// apply implementation of the singletons
|
||||
#include "Policies/SingletonImp.h"
|
||||
|
|
@ -469,7 +470,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
|
|||
break;
|
||||
case DEAD:
|
||||
{
|
||||
if( m_respawnTime <= time(NULL) )
|
||||
if (m_respawnTime <= time(NULL) && (!m_isSpawningLinked || GetMap()->GetCreatureLinkingHolder()->CanSpawn(this)))
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Respawning...");
|
||||
m_respawnTime = 0;
|
||||
|
|
@ -506,6 +507,9 @@ void Creature::Update(uint32 update_diff, uint32 diff)
|
|||
if (AI())
|
||||
AI()->JustRespawned();
|
||||
|
||||
if (m_isCreatureLinkingTrigger)
|
||||
GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, this);
|
||||
|
||||
GetMap()->Add(this);
|
||||
}
|
||||
break;
|
||||
|
|
@ -771,6 +775,15 @@ bool Creature::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo cons
|
|||
break;
|
||||
}
|
||||
|
||||
// Add to CreatureLinkingHolder if needed
|
||||
if (sCreatureLinkingMgr.GetLinkedTriggerInformation(this))
|
||||
cPos.GetMap()->GetCreatureLinkingHolder()->AddSlaveToHolder(this);
|
||||
if (sCreatureLinkingMgr.IsLinkedEventTrigger(this))
|
||||
{
|
||||
m_isCreatureLinkingTrigger = true;
|
||||
cPos.GetMap()->GetCreatureLinkingHolder()->AddMasterToHolder(this);
|
||||
}
|
||||
|
||||
LoadCreatureAddon();
|
||||
|
||||
return true;
|
||||
|
|
@ -1315,6 +1328,23 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
|
|||
curhealth = 1;
|
||||
}
|
||||
|
||||
if (sCreatureLinkingMgr.IsSpawnedByLinkedMob(this))
|
||||
{
|
||||
m_isSpawningLinked = true;
|
||||
if (m_deathState == ALIVE && !GetMap()->GetCreatureLinkingHolder()->CanSpawn(this))
|
||||
{
|
||||
m_deathState = DEAD;
|
||||
|
||||
// Just set to dead, so need to relocate like above
|
||||
if (CanFly())
|
||||
{
|
||||
float tz = GetTerrain()->GetHeight(data->posX, data->posY, data->posZ, false);
|
||||
if (data->posZ - tz > 0.1)
|
||||
Relocate(data->posX, data->posY, tz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetHealth(m_deathState == ALIVE ? curhealth : 0);
|
||||
SetPower(POWER_MANA, data->curmana);
|
||||
|
||||
|
|
@ -1324,6 +1354,11 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
|
|||
m_defaultMovementType = MovementGeneratorType(data->movementType);
|
||||
|
||||
AIM_Initialize();
|
||||
|
||||
// Creature Linking, Initial load is handled like respawn
|
||||
if (m_isCreatureLinkingTrigger && isAlive())
|
||||
GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue