Advertisement
Guest User

Untitled

a guest
Nov 27th, 2012
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1.     static bool HandleGameObjectHausCommand(ChatHandler* handler, char const* args)
  2.     {
  3.         uint32 objectId = 1234;
  4.  
  5.  
  6.         const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId);
  7.  
  8.         Player* player = handler->GetSession()->GetPlayer();
  9.         float x = float(player->GetPositionX());
  10.         float y = float(player->GetPositionY());
  11.         float z = float(player->GetPositionZ());
  12.         float o = float(player->GetOrientation());
  13.         Map* map = player->GetMap();
  14.  
  15.         GameObject* object = new GameObject;
  16.         uint32 guidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
  17.  
  18.         if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
  19.         {
  20.             delete object;
  21.             return false;
  22.         }
  23.  
  24.         // fill the gameobject data and save to the db
  25.         object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMaskForSpawn());
  26.  
  27.         // this will generate a new guid if the object is in an instance
  28.         if (!object->LoadGameObjectFromDB(guidLow, map))
  29.         {
  30.             delete object;
  31.             return false;
  32.         }
  33.  
  34.         // TODO: is it really necessary to add both the real and DB table guid here ?
  35.         sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow));
  36.  
  37.         handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), guidLow, x, y, z);
  38.         return true;
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement