Core/Entities:

- Rename creature_linked_respawn to linked_respawn
- Update functionality: add field ´linkType´.
** 0 = creature respawn dependant on creature (default)
** 1 = creature respawn dependant on gameobject
** 2 = gameobject respawn dependant on gameobject
** 3 = gameobject respawn dependant on creature

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-12-24 18:55:50 +01:00
parent e57866ac9a
commit c05ed659cb
8 changed files with 271 additions and 135 deletions
+7 -44
View File
@@ -464,20 +464,17 @@ void Creature::Update(uint32 diff)
if (!allowed) // Will be rechecked on next Update call
break;
if (!GetLinkedCreatureRespawnTime()) // Can respawn
time_t linkedRespawntime = sObjectMgr->GetLinkedRespawnTime(GetGUID(), GetMap()->GetInstanceId());
if (!linkedRespawntime) // Can respawn
Respawn();
else // the master is dead
{
if (uint32 targetGuid = sObjectMgr->GetLinkedRespawnGuid(m_DBTableGuid))
{
if (targetGuid == m_DBTableGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
m_respawnTime = (now > GetLinkedCreatureRespawnTime() ? now : GetLinkedCreatureRespawnTime())+urand(5,MINUTE); // else copy time from master and add a little
SaveRespawnTime(); // also save to DB immediately
}
uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(GetGUID());
if (targetGuid == GetGUID()) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
Respawn();
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime)+urand(5,MINUTE); // else copy time from master and add a little
SaveRespawnTime(); // also save to DB immediately
}
}
break;
@@ -2383,40 +2380,6 @@ const char* Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const
return GetName();
}
const CreatureData* Creature::GetLinkedRespawnCreatureData() const
{
if (!m_DBTableGuid) // only hard-spawned creatures from DB can have a linked master
return NULL;
if (uint32 targetGuid = sObjectMgr->GetLinkedRespawnGuid(m_DBTableGuid))
return sObjectMgr->GetCreatureData(targetGuid);
return NULL;
}
// returns master's remaining respawn time if any
time_t Creature::GetLinkedCreatureRespawnTime() const
{
if (!m_DBTableGuid) // only hard-spawned creatures from DB can have a linked master
return 0;
if (uint32 targetGuid = sObjectMgr->GetLinkedRespawnGuid(m_DBTableGuid))
{
Map* targetMap = NULL;
if (const CreatureData* data = sObjectMgr->GetCreatureData(targetGuid))
{
if (data->mapid == GetMapId()) // look up on the same map
targetMap = GetMap();
else // it shouldn't be instanceable map here
targetMap = sMapMgr->FindMap(data->mapid);
}
if (targetMap)
return sObjectMgr->GetCreatureRespawnTime(targetGuid,targetMap->GetInstanceId());
}
return 0;
}
void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O)
{
InterruptNonMeleeSpells(true);
@@ -609,10 +609,6 @@ class Creature : public Unit, public GridObject<Creature>
float GetRespawnRadius() const { return m_respawnradius; }
void SetRespawnRadius(float dist) { m_respawnradius = dist; }
// Linked Creature Respawning System
time_t GetLinkedCreatureRespawnTime() const;
const CreatureData* GetLinkedRespawnCreatureData() const;
uint32 m_groupLootTimer; // (msecs)timer used for group loot
uint32 lootingGroupLowGUID; // used to find group which is looting corpse