From 73384e56d48cd0495c4926f163e435d75660624f Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 23 Jun 2015 00:05:51 +0200 Subject: Core/Garrisons: Implemented spawning "Finalize Garrison Plot" gameobjects when building under construction is ready --- src/server/game/Garrison/Garrison.cpp | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/server/game/Garrison/Garrison.cpp') diff --git a/src/server/game/Garrison/Garrison.cpp b/src/server/game/Garrison/Garrison.cpp index 12c924c1f30..99db2336566 100644 --- a/src/server/game/Garrison/Garrison.cpp +++ b/src/server/game/Garrison/Garrison.cpp @@ -649,16 +649,39 @@ GameObject* Garrison::Plot::CreateGameObject(Map* map, GarrisonFactionIndex fact } Position const& pos = PacketInfo.PlotPos; - GameObject* go = new GameObject(); - if (!go->Create(map->GenerateLowGuid(), entry, map, 0, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), - 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_ACTIVE)) + GameObject* building = new GameObject(); + if (!building->Create(map->GenerateLowGuid(), entry, map, 0, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), + 0.0f, 0.0f, 0.0f, 0.0f, 255, GO_STATE_READY)) { - delete go; + delete building; return nullptr; } - BuildingInfo.Guid = go->GetGUID(); - return go; + if (BuildingInfo.CanActivate() && BuildingInfo.PacketInfo && !BuildingInfo.PacketInfo->Active) + { + if (FinalizeGarrisonPlotGOInfo const* finalizeInfo = sGarrisonMgr.GetPlotFinalizeGOInfo(PacketInfo.GarrPlotInstanceID)) + { + Position const& pos2 = finalizeInfo->FactionInfo[faction].Pos; + GameObject* finalizer = new GameObject(); + if (finalizer->Create(map->GenerateLowGuid(), finalizeInfo->FactionInfo[faction].GameObjectId, map, 0, pos2.GetPositionX(), pos2.GetPositionY(), + pos2.GetPositionZ(), pos2.GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 255, GO_STATE_READY)) + { + // set some spell id to make the object delete itself after use + finalizer->SetSpellId(finalizer->GetGOInfo()->goober.spell); + finalizer->SetRespawnTime(0); + + if (uint16 animKit = finalizeInfo->FactionInfo[faction].AnimKitId) + finalizer->SetAIAnimKitId(animKit); + + map->AddToMap(finalizer); + } + else + delete finalizer; + } + } + + BuildingInfo.Guid = building->GetGUID(); + return building; } void Garrison::Plot::DeleteGameObject(Map* map) -- cgit v1.2.3