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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1635297022271998800');
DELETE FROM `gameobject_template` WHERE `entry` = 195641;
INSERT INTO `gameobject_template` (`entry`, `type`, `displayId`, `name`, `IconName`, `castBarCaption`, `unk1`, `size`, `Data0`, `Data1`, `Data2`, `Data3`, `Data4`, `Data5`, `Data6`, `Data7`, `Data8`, `Data9`, `Data10`, `Data11`, `Data12`, `Data13`, `Data14`, `Data15`, `Data16`, `Data17`, `Data18`, `Data19`, `Data20`, `Data21`, `Data22`, `Data23`, `AIName`, `ScriptName`, `VerifiedBuild`) VALUES
(195641, 6, 0, 'Brazier', '', '', '', 1, 0, 1, 1, 7897, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', '', -18019);

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);

View File

@@ -3787,28 +3787,11 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
if (Battleground* bg = player->GetBattleground())
bg->SetDroppedFlagGUID(pGameObj->GetGUID(), player->GetTeamId() == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE);
if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry())
if (GameObject* linkedTrap = pGameObj->GetLinkedTrap())
{
GameObject* linkedGO = sObjectMgr->IsGameObjectStaticTransport(linkedEntry) ? new StaticTransport() : new GameObject();
if (linkedGO->Create(map->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, map, m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY))
{
linkedGO->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0);
linkedGO->SetSpellId(m_spellInfo->Id);
// xinef: this is wrong
//ExecuteLogEffectSummonObject(effIndex, linkedGO);
pGameObj->SetLinkedTrap(linkedGO);
// Wild object not have owner and check clickable by players
map->AddToMap(linkedGO, true);
}
else
{
delete linkedGO;
linkedGO = nullptr;
return;
}
linkedTrap->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS :0);
linkedTrap->SetSpellId(m_spellInfo->Id);
ExecuteLogEffectSummonObject(effIndex, linkedTrap);
}
}
@@ -5685,27 +5668,13 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
cMap->AddToMap(pGameObj, true);
if (uint32 linkedEntry = pGameObj->GetGOInfo()->GetLinkedGameObjectEntry())
if (GameObject* linkedTrap = pGameObj->GetLinkedTrap())
{
GameObject* linkedGO = sObjectMgr->IsGameObjectStaticTransport(linkedEntry) ? new StaticTransport() : new GameObject();
if (linkedGO->Create(cMap->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, cMap, m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), G3D::Quat(), 100, GO_STATE_READY))
{
linkedGO->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0);
linkedGO->SetSpellId(m_spellInfo->Id);
linkedTrap->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0);
linkedTrap->SetSpellId(m_spellInfo->Id);
linkedTrap->SetOwnerGUID(m_caster->GetGUID());
// xinef: this is wrong
//linkedGO->SetOwnerGUID(m_caster->GetGUID());
//ExecuteLogEffectSummonObject(effIndex, linkedGO);
pGameObj->SetLinkedTrap(linkedGO);
cMap->AddToMap(linkedGO, true);
}
else
{
delete linkedGO;
linkedGO = nullptr;
return;
}
ExecuteLogEffectSummonObject(effIndex, linkedTrap);
}
}