From c429e7d4899b51bba5df9bf0be0acee4ecc38cb7 Mon Sep 17 00:00:00 2001 From: ariel- Date: Sat, 30 Jul 2016 18:50:44 -0300 Subject: Core/Entities: debloat SummonGameObject parameter list using proper wrappers and enable GO rotation in scripts - There's still an overload allowing for x, y, z, o to be passed directly - Fixed default animstate for GameObject creation in many places, it should be 255, not 100 (checked in sniffs) (cherry picked from commit 62bfee37cb21584cef631dda428feaf5eb829cda) # Conflicts: # src/server/game/Battlefield/Battlefield.cpp # src/server/game/Battlegrounds/Battleground.cpp # src/server/game/Entities/GameObject/GameObject.cpp # src/server/game/Entities/GameObject/GameObject.h # src/server/game/Entities/Object/Object.cpp # src/server/game/Entities/Object/Object.h # src/server/game/Spells/SpellEffects.cpp # src/server/scripts/Commands/cs_gobject.cpp # src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp # src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp # src/server/scripts/Kalimdor/zone_feralas.cpp # src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp # src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp # src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp --- src/server/game/Entities/Object/Object.cpp | 27 ++++++++++++++++++++------- src/server/game/Entities/Object/Object.h | 5 +++-- 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'src/server/game/Entities/Object') diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 67cde258ed9..3d6f7498d9b 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2449,7 +2449,7 @@ Scenario* WorldObject::GetScenario() const return nullptr; } -TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/) const +TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType spwtype /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 duration /*= 0*/, uint32 /*vehId = 0*/) const { if (Map* map = FindMap()) { @@ -2460,7 +2460,7 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempS } } - return NULL; + return nullptr; } TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang /*= 0*/, TempSummonType spwtype /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despwtime /*= 0*/) const @@ -2470,29 +2470,30 @@ TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, fl GetClosePoint(x, y, z, GetObjectSize()); ang = GetOrientation(); } + Position pos; pos.Relocate(x, y, z, ang); return SummonCreature(id, pos, spwtype, despwtime, 0); } -GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime) +GameObject* WorldObject::SummonGameObject(uint32 entry, Position const& pos, G3D::Quat const& rot, uint32 respawnTime) { if (!IsInWorld()) - return NULL; + return nullptr; GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry); if (!goinfo) { TC_LOG_ERROR("sql.sql", "Gameobject template %u not found in database!", entry); - return NULL; + return nullptr; } Map* map = GetMap(); GameObject* go = new GameObject(); - if (!go->Create(entry, map, GetPhaseMask(), x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY)) + if (!go->Create(entry, map, GetPhaseMask(), pos, rot, 255, GO_STATE_READY)) { delete go; - return NULL; + return nullptr; } go->CopyPhaseFrom(this); @@ -2507,6 +2508,18 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float return go; } +GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, G3D::Quat const& rot, uint32 respawnTime) +{ + if (!x && !y && !z) + { + GetClosePoint(x, y, z, GetObjectSize()); + ang = GetOrientation(); + } + + Position pos(x, y, z, ang); + return SummonGameObject(entry, pos, rot, respawnTime); +} + Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint32 duration, CreatureAI* (*GetAI)(Creature*)) { TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 4e8b37a086d..5b7b324a70e 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -646,9 +646,10 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation Scenario* GetScenario() const; - TempSummon* SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const; + TempSummon* SummonCreature(uint32 id, Position const& pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const; TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0) const; - GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime /* s */); + GameObject* SummonGameObject(uint32 entry, Position const& pos, G3D::Quat const& rot, uint32 respawnTime /* s */); + GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, G3D::Quat const& rot, uint32 respawnTime /* s */); Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); void SummonCreatureGroup(uint8 group, std::list* list = NULL); -- cgit v1.2.3