GameObjectPointer MapScriptInterface::SpawnGameObject(uint32 Entry, float cX, float cY, float cZ, float cO, bool AddToWorld, uint32 Misc1, uint32 Misc2) { GameObjectPointer pGameObject = mapMgr->CreateGameObject(Entry); if(pGameObject == NULL || !pGameObject->CreateFromProto(Entry, mapMgr->GetMapId(), cX, cY, cZ, cO, 0.0f, 0.0f, 0.0f, 0.0f)) return NULLGOB; pGameObject->SetInstanceID(mapMgr->GetInstanceID()); pGameObject->SetPhase(1); if(AddToWorld) pGameObject->PushToWorld(mapMgr); return pGameObject; }
bool ChatHandler::HandleGOSpawn(const char *args, WorldSession *m_session) { std::stringstream sstext; char* pEntryID = strtok((char*)args, " "); if (!pEntryID) return false; uint32 EntryID = atoi(pEntryID); bool Save = false; char* pSave = strtok(NULL, " "); if (pSave) Save = (atoi(pSave)>0?true:false); OUT_DEBUG("Spawning GameObject By Entry '%u'", EntryID); sstext << "Spawning GameObject By Entry '" << EntryID << "'" << '\0'; SystemMessage(m_session, sstext.str().c_str()); GameObjectPointer go = m_session->GetPlayer()->GetMapMgr()->CreateGameObject(EntryID); if(go == NULL) { sstext << "GameObject Info '" << EntryID << "' Not Found" << '\0'; SystemMessage(m_session, sstext.str().c_str()); return true; } PlayerPointer chr = m_session->GetPlayer(); uint32 mapid = chr->GetMapId(); float x = chr->GetPositionX(); float y = chr->GetPositionY(); float z = chr->GetPositionZ(); float o = chr->GetOrientation(); go->SetInstanceID(chr->GetInstanceID()); go->CreateFromProto(EntryID,mapid,x,y,z,o,0.0f,0.0f,0.0f,0.0f); go->SetRotation(o); go->PushToWorld(m_session->GetPlayer()->GetMapMgr()); // Create sapwn instance GOSpawn * gs = new GOSpawn; gs->entry = go->GetEntry(); gs->facing = go->GetOrientation(); gs->faction = go->GetUInt32Value(GAMEOBJECT_FACTION); gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS); gs->id = objmgr.GenerateGameObjectSpawnID(); gs->orientation1 = go->GetFloatValue(GAMEOBJECT_ROTATION); gs->orientation2 = go->GetFloatValue(GAMEOBJECT_ROTATION_01); gs->orientation3 = go->GetFloatValue(GAMEOBJECT_ROTATION_02); gs->orientation4 = go->GetFloatValue(GAMEOBJECT_ROTATION_03); gs->scale = go->GetFloatValue(OBJECT_FIELD_SCALE_X); gs->x = go->GetPositionX(); gs->y = go->GetPositionY(); gs->z = go->GetPositionZ(); gs->state = go->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE); //gs->stateNpcLink = 0; uint32 cx = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX()); uint32 cy = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY()); m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cx,cy)->GOSpawns.push_back(gs); go->m_spawn = gs; //go->AddToWorld(); if(Save == true) { // If we're saving, create template and add index go->SaveToDB(); } return true; }