Handle despawning and respawning of nearby linked traps on gameobject despawn and respawn

This commit is contained in:
hondacrx
2017-11-13 13:17:21 -05:00
parent 7edcdb6ea2
commit 2db12344e6
2 changed files with 23 additions and 1 deletions
+19 -1
View File
@@ -468,6 +468,11 @@ namespace Game.Entities
m_SkillupList.Clear();
m_usetimes = 0;
// If nearby linked trap exists, respawn it
GameObject linkedTrap = GetLinkedTrap();
if (linkedTrap)
linkedTrap.SetLootState(LootState.Ready);
switch (GetGoType())
{
case GameObjectTypes.FishingNode: // can't fish now
@@ -547,7 +552,7 @@ namespace Game.Entities
if (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);
Cell.VisitGridObjects(this, searcher, radius);
target = searcher.GetTarget();
@@ -657,6 +662,11 @@ namespace Game.Entities
}
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 (GetGoType() == GameObjectTypes.Goober)
{
@@ -2338,6 +2348,12 @@ namespace Game.Entities
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)
{
if (!target)
@@ -2688,6 +2704,8 @@ namespace Game.Entities
public Loot loot = new Loot();
public GameObjectModel m_model;
ObjectGuid m_linkedTrap;
#endregion
}