Code
src/server/scripts/World/npcs_special.cpp | 82 +++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index 6858827..b63d820 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -47,6 +47,7 @@ EndContentData */
#include "ObjectMgr.h"
#include "ScriptMgr.h"
#include "World.h"
+#include "MapManager.h"
/*########
# npc_air_force_bots
@@ -3097,6 +3098,86 @@ public:
};
};
+/*######
+## npc_go_creator
+######*/
+
+#define GOSSIP_CREATE_GO "Create gameobject"
+
+class npc_go_creator : public CreatureScript
+{
+public:
+ npc_go_creator() : CreatureScript("npc_go_creator") { }
+
+ bool OnGossipHello(Player* pPlayer, Creature* pCreature)
+ {
+ pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_CREATE_GO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
+ pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, pCreature->GetGUID());
+ return true;
+ }
+
+ bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
+ {
+ pPlayer->PlayerTalkClass->ClearMenus();
+
+ if(uiAction == GOSSIP_ACTION_INFO_DEF + 1)
+ {
+ // заполните или добавьте ещё данные для спауна!
+ GameObjectData GOData;
+ GOData.id = 191172;
+ GOData.mapid = 0;
+ GOData.spawnMask = 15;
+ GOData.phaseMask = 65535;
+ GOData.posX = 0.0f;
+ GOData.posY = 0.0f;
+ GOData.posY = 0.0f;
+ GOData.posY = 0.0f;
+ GOData.orientation = 0.0f;
+ GOData.go_state = GO_STATE_READY;
+
+ const GameObjectTemplate* pGOTemplate = sObjectMgr->GetGameObjectTemplate(GOData.id);
+
+ // не найден в таблице
+ if(!pGOTemplate)
+ {
+ pCreature->MonsterWhisper("Gameobject not found", pPlayer->GetGUID());
+ pPlayer->CLOSE_GOSSIP_MENU();
+ return false;
+ }
+ // display id не верный
+ if (pGOTemplate->displayId && !sGameObjectDisplayInfoStore.LookupEntry(pGOTemplate->displayId))
+ {
+ pCreature->MonsterWhisper("Gameobject display id not found", pPlayer->GetGUID());
+ pPlayer->CLOSE_GOSSIP_MENU();
+ return false;
+ }
+
+ uint32 GOGuidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); // тип всемирного объекта
+ Map* pMap = sMapMgr->FindMap(GOData.id);
+ GameObject* pGameObject = new GameObject;
+
+ // создание
+ if (!pGameObject->Create(GOGuidLow, pGOTemplate->entry, pMap, GOData.phaseMask, GOData.posX, GOData.posY, GOData.posZ, GOData.orientation, GOData.rotation0, GOData.rotation1, GOData.rotation2, GOData.rotation3, GOData.animprogress, GOData.go_state))
+ {
+ pCreature->MonsterWhisper("Gameobject is not created", pPlayer->GetGUID());
+ pPlayer->CLOSE_GOSSIP_MENU();
+ delete pObject;
+ return false;
+ }
+
+ // сохраняем в БД
+ pGameObject ->SaveToDB(GOData.id, GOData.spawnMask, GOData.phaseMask);
+ // добавляем в сетку
+ pGameObject ->AddGameobjectToGrid(GOGuidLow, sObjectMgr->GetGOData(GOData.id));
+
+ pCreature->MonsterWhisper("Gameobject is created", pPlayer->GetGUID());
+ }
+
+ pPlayer->CLOSE_GOSSIP_MENU();
+ return true;
+ }
+};
+
void AddSC_npcs_special()
{
new npc_air_force_bots();
@@ -3130,4 +3211,5 @@ void AddSC_npcs_special()
new npc_earth_elemental();
new npc_firework();
new npc_spring_rabbit();
+ new npc_go_creator();
}