fix(Core/GameObject): Spawn linked traps when gameobjects are created (#8572)

This commit is contained in:
Skjalf
2021-10-26 22:15:30 -03:00
committed by GitHub
parent a5e4e9d92c
commit 041b327c80
4 changed files with 40 additions and 41 deletions

View File

@@ -384,6 +384,20 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
LastUsedScriptID = GetGOInfo()->ScriptId;
AIM_Initialize();
if (uint32 linkedEntry = GetGOInfo()->GetLinkedGameObjectEntry())
{
GameObject* linkedGO = new GameObject();
if (linkedGO->Create(map->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, map, phaseMask, x, y, z, ang, rotation, 255, GO_STATE_READY))
{
SetLinkedTrap(linkedGO);
map->AddToMap(linkedGO);
}
else
{
delete linkedGO;
}
}
// Check if GameObject is Large
if (goinfo->IsLargeGameObject())
SetVisibilityDistanceOverride(true);
@@ -735,7 +749,7 @@ void GameObject::Update(uint32 diff)
// If nearby linked trap exists, despawn it
if (GameObject* linkedTrap = GetLinkedTrap())
{
linkedTrap->Delete();
linkedTrap->DespawnOrUnsummon();
}
//if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
@@ -853,6 +867,11 @@ void GameObject::DespawnOrUnsummon(Milliseconds delay, Seconds forceRespawnTime)
SendObjectDeSpawnAnim(GetGUID());
SetGoState(GO_STATE_READY);
if (GameObject* trap = GetLinkedTrap())
{
trap->DespawnOrUnsummon();
}
if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
{
SetUInt32Value(GAMEOBJECT_FLAGS, addon->flags);