Handle despawning and respawning of nearby linked traps on gameobject despawn and respawn
This commit is contained in:
@@ -468,6 +468,11 @@ namespace Game.Entities
|
|||||||
m_SkillupList.Clear();
|
m_SkillupList.Clear();
|
||||||
m_usetimes = 0;
|
m_usetimes = 0;
|
||||||
|
|
||||||
|
// If nearby linked trap exists, respawn it
|
||||||
|
GameObject linkedTrap = GetLinkedTrap();
|
||||||
|
if (linkedTrap)
|
||||||
|
linkedTrap.SetLootState(LootState.Ready);
|
||||||
|
|
||||||
switch (GetGoType())
|
switch (GetGoType())
|
||||||
{
|
{
|
||||||
case GameObjectTypes.FishingNode: // can't fish now
|
case GameObjectTypes.FishingNode: // can't fish now
|
||||||
@@ -547,7 +552,7 @@ namespace Game.Entities
|
|||||||
if (owner)
|
if (owner)
|
||||||
{
|
{
|
||||||
// Hunter trap: Search units which are unfriendly to the trap's owner
|
// Hunter trap: Search units which are unfriendly to the trap's owner
|
||||||
var checker = new AnyUnfriendlyNoTotemUnitInObjectRangeCheck(this, owner, radius);
|
var checker = new NearestUnfriendlyNoTotemUnitInObjectRangeCheck(this, owner, radius);
|
||||||
var searcher = new UnitSearcher(this, checker);
|
var searcher = new UnitSearcher(this, checker);
|
||||||
Cell.VisitGridObjects(this, searcher, radius);
|
Cell.VisitGridObjects(this, searcher, radius);
|
||||||
target = searcher.GetTarget();
|
target = searcher.GetTarget();
|
||||||
@@ -657,6 +662,11 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
case LootState.JustDeactivated:
|
case LootState.JustDeactivated:
|
||||||
{
|
{
|
||||||
|
// If nearby linked trap exists, despawn it
|
||||||
|
GameObject linkedTrap = GetLinkedTrap();
|
||||||
|
if (linkedTrap)
|
||||||
|
linkedTrap.SetLootState(LootState.JustDeactivated);
|
||||||
|
|
||||||
//if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
|
//if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
|
||||||
if (GetGoType() == GameObjectTypes.Goober)
|
if (GetGoType() == GameObjectTypes.Goober)
|
||||||
{
|
{
|
||||||
@@ -2338,6 +2348,12 @@ namespace Game.Entities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetLinkedTrap(GameObject linkedTrap) { m_linkedTrap = linkedTrap.GetGUID(); }
|
||||||
|
GameObject GetLinkedTrap()
|
||||||
|
{
|
||||||
|
return ObjectAccessor.GetGameObject(this, m_linkedTrap);
|
||||||
|
}
|
||||||
|
|
||||||
public override void BuildValuesUpdate(UpdateType updateType, ByteBuffer data, Player target)
|
public override void BuildValuesUpdate(UpdateType updateType, ByteBuffer data, Player target)
|
||||||
{
|
{
|
||||||
if (!target)
|
if (!target)
|
||||||
@@ -2688,6 +2704,8 @@ namespace Game.Entities
|
|||||||
public Loot loot = new Loot();
|
public Loot loot = new Loot();
|
||||||
|
|
||||||
public GameObjectModel m_model;
|
public GameObjectModel m_model;
|
||||||
|
|
||||||
|
ObjectGuid m_linkedTrap;
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2914,6 +2914,8 @@ namespace Game.Spells
|
|||||||
GameObject linkedGO = new GameObject();
|
GameObject linkedGO = new GameObject();
|
||||||
if (linkedGO.Create(linkedEntry, map, m_caster.GetPhaseMask(), new Position(x, y, z, target.GetOrientation()), rotation, 255, GameObjectState.Ready))
|
if (linkedGO.Create(linkedEntry, map, m_caster.GetPhaseMask(), new Position(x, y, z, target.GetOrientation()), rotation, 255, GameObjectState.Ready))
|
||||||
{
|
{
|
||||||
|
pGameObj.SetLinkedTrap(linkedGO);
|
||||||
|
|
||||||
linkedGO.CopyPhaseFrom(m_caster);
|
linkedGO.CopyPhaseFrom(m_caster);
|
||||||
|
|
||||||
linkedGO.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
linkedGO.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
||||||
@@ -4656,6 +4658,8 @@ namespace Game.Spells
|
|||||||
GameObject linkedGO = new GameObject();
|
GameObject linkedGO = new GameObject();
|
||||||
if (linkedGO.Create(linkedEntry, cMap, m_caster.GetPhaseMask(), pos, rotation, 255, GameObjectState.Ready))
|
if (linkedGO.Create(linkedEntry, cMap, m_caster.GetPhaseMask(), pos, rotation, 255, GameObjectState.Ready))
|
||||||
{
|
{
|
||||||
|
pGameObj.SetLinkedTrap(linkedGO);
|
||||||
|
|
||||||
linkedGO.CopyPhaseFrom(m_caster);
|
linkedGO.CopyPhaseFrom(m_caster);
|
||||||
|
|
||||||
linkedGO.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
linkedGO.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user