diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-03-28 16:52:07 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-03-28 20:22:05 +0200 |
commit | 33b3ebcae67870f704d86d30aa357781b33bb411 (patch) | |
tree | 43b40a2767346addb3ca16778ec800bbab768826 /src | |
parent | f21270b987211041b95d6befa7192d313692920d (diff) |
Core/Objects: Pass privateObjectOwner guid directly to SummonCreature functions
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 8 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 13 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.h | 6 | ||||
-rw-r--r-- | src/server/game/Maps/Map.h | 2 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 12 | ||||
-rw-r--r-- | src/server/scripts/BrokenIsles/zone_orderhall_warrior.cpp | 2 |
6 files changed, 23 insertions, 20 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 05066012466..4192a243367 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1189,7 +1189,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!summoner) break; - bool personalSpawn = flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn); + ObjectGuid privateObjectOwner; + if (flags.HasFlag(SmartActionSummonCreatureFlags::PersonalSpawn)) + privateObjectOwner = summoner->IsPrivateObject() ? summoner->GetPrivateObjectOwner() : summoner->GetGUID(); float x, y, z, o; for (WorldObject* target : targets) @@ -1199,7 +1201,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u y += e.target.y; z += e.target.z; o += e.target.o; - if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, personalSpawn)) + if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, x, y, z, o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, privateObjectOwner)) if (e.action.summonCreature.attackInvoker) summon->AI()->AttackStart(target->ToUnit()); } @@ -1207,7 +1209,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (e.GetTargetType() != SMART_TARGET_POSITION) break; - if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, e.target.x, e.target.y, e.target.z, e.target.o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, personalSpawn)) + if (Creature* summon = summoner->SummonCreature(e.action.summonCreature.creature, e.target.x, e.target.y, e.target.z, e.target.o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration, privateObjectOwner)) if (unit && e.action.summonCreature.attackInvoker) summon->AI()->AttackStart(unit); break; diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 55d670b27f2..9ddf63b99f9 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1696,7 +1696,7 @@ void WorldObject::AddObjectToRemoveList() map->AddObjectToRemoveList(this); } -TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, Unit* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool personalSpawn /*= false*/) +TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, Unit* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, ObjectGuid privateObjectOwner /*= ObjectGuid::Empty*/) { uint32 mask = UNIT_MASK_SUMMON; if (properties) @@ -1782,8 +1782,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert summon->InitStats(duration); - if (personalSpawn && summoner) - summon->SetPrivateObjectOwner(summoner->IsPrivateObject() ? summoner->GetPrivateObjectOwner() : summoner->GetGUID()); + summon->SetPrivateObjectOwner(privateObjectOwner); AddToMap(summon->ToCreature()); summon->InitSummon(); @@ -1839,11 +1838,11 @@ Scenario* WorldObject::GetScenario() const return nullptr; } -TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despawnTime /*= 0*/, uint32 vehId /*= 0*/, bool personalSpawn /* = false */) +TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despawnTime /*= 0*/, uint32 vehId /*= 0*/, ObjectGuid privateObjectOwner /* = ObjectGuid::Empty */) { if (Map* map = FindMap()) { - if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime, ToUnit(), 0, vehId, personalSpawn)) + if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime, ToUnit(), 0, vehId, privateObjectOwner)) { summon->SetTempSummonType(despawnType); return summon; @@ -1853,13 +1852,13 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempS return nullptr; } -TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despawnTime /*= 0*/, bool personalSpawn /* = false */) +TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despawnTime /*= 0*/, ObjectGuid privateObjectOwner /* = ObjectGuid::Empty */) { if (!x && !y && !z) GetClosePoint(x, y, z, GetCombatReach()); if (!o) o = GetOrientation(); - return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime, 0, personalSpawn); + return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime, 0, privateObjectOwner); } GameObject* WorldObject::SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, uint32 respawnTime) diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index f2402bfa6f3..b877d8c6670 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -518,9 +518,9 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation Scenario* GetScenario() const; - TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, uint32 vehId = 0, bool personalSpawn = false); - TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType, Milliseconds const& despawnTime, uint32 vehId = 0, bool personalSpawn = false) { return SummonCreature(entry, pos, despawnType, uint32(despawnTime.count()), vehId, personalSpawn); } - TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, bool personalSpawn = false); + TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, uint32 vehId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty); + TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType, Milliseconds const& despawnTime, uint32 vehId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty) { return SummonCreature(entry, pos, despawnType, uint32(despawnTime.count()), vehId, privateObjectOwner); } + TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty); GameObject* SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, uint32 respawnTime /* s */); GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, QuaternionData const& rot, uint32 respawnTime /* s */); Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = nullptr); diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 0c07e8a5969..9721ff6dc2a 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -512,7 +512,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType> void UpdateIteratorBack(Player* player); - TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, Unit* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0, bool personalSpawn = false); + TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, Unit* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty); void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr); AreaTrigger* GetAreaTrigger(ObjectGuid const& guid); Conversation* GetConversation(ObjectGuid const& guid); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 61966343b37..30c64f3f77e 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -1892,7 +1892,9 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) if (!m_originalCaster) return; - bool personalSpawn = (properties->Flags & SUMMON_PROP_FLAG_PERSONAL_SPAWN) != 0; + ObjectGuid privateObjectOwner; + if (properties->Flags & SUMMON_PROP_FLAG_PERSONAL_SPAWN) + privateObjectOwner = m_originalCaster->IsPrivateObject() ? m_originalCaster->GetPrivateObjectOwner() : m_originalCaster->GetGUID(); int32 duration = m_spellInfo->CalcDuration(m_originalCaster); @@ -1955,7 +1957,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) case SummonTitle::Lightwell: case SummonTitle::Totem: { - summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn); + summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, privateObjectOwner); if (!summon || !summon->IsTotem()) return; @@ -1968,7 +1970,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) } case SummonTitle::Companion: { - summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn); + summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, privateObjectOwner); if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION)) return; @@ -1995,7 +1997,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) // randomize position for multiple summons pos = m_caster->GetRandomPoint(*destTarget, radius); - summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration, 0, personalSpawn); + summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration, 0, privateObjectOwner); if (!summon) continue; @@ -2016,7 +2018,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) SummonGuardian(effIndex, entry, properties, numSummons); break; case SUMMON_CATEGORY_PUPPET: - summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn); + summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, privateObjectOwner); break; case SUMMON_CATEGORY_VEHICLE: // Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker diff --git a/src/server/scripts/BrokenIsles/zone_orderhall_warrior.cpp b/src/server/scripts/BrokenIsles/zone_orderhall_warrior.cpp index 25bc457644e..86a8c8cf67c 100644 --- a/src/server/scripts/BrokenIsles/zone_orderhall_warrior.cpp +++ b/src/server/scripts/BrokenIsles/zone_orderhall_warrior.cpp @@ -166,7 +166,7 @@ struct npc_danica_the_reclaimer : public ScriptedAI // Should be some other way to do this... void QuestAccept(Player* player, Quest const* /*quest*/) override { - TempSummon* summon = player->SummonCreature(NPC_DANICA_THE_RECLAIMER, 1059.613f, 7224.605f, 100.4608f, 0.03462749f, TEMPSUMMON_MANUAL_DESPAWN, 0, true); + TempSummon* summon = player->SummonCreature(NPC_DANICA_THE_RECLAIMER, 1059.613f, 7224.605f, 100.4608f, 0.03462749f, TEMPSUMMON_MANUAL_DESPAWN, 0, player->GetGUID()); if (!summon) return; |