bool ChatHandler::HandleGOActivate(const char* args, WorldSession* m_session) { GameObject* GObj = m_session->GetPlayer()->GetSelectedGo(); if(!GObj) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } if(GObj->GetByte(GAMEOBJECT_BYTES_1, 0) == 1) { // Close/Deactivate GObj->SetByte(GAMEOBJECT_BYTES_1, 0, 0); GObj->RemoveFlag(GAMEOBJECT_FLAGS, 1); BlueSystemMessage(m_session, "Gameobject closed."); } else { // Open/Activate GObj->SetByte(GAMEOBJECT_BYTES_1, 0, 1); GObj->SetFlag(GAMEOBJECT_FLAGS, 1); BlueSystemMessage(m_session, "Gameobject opened."); } sGMLog.writefromsession(m_session, "opened/closed gameobject %s, entry %u", GameObjectNameStorage.LookupEntry(GObj->GetEntry())->Name, GObj->GetEntry()); return true; }
bool ChatHandler::HandleGODamage(const char* args, WorldSession* m_session) { GameObject* go = m_session->GetPlayer()->m_GM_SelectedGO; if( !go ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } if(go->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_TYPE_ID) != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) { RedSystemMessage(m_session, "You must select a Destructible gameobject!"); return true; } if(!args) { RedSystemMessage(m_session, "Invalid syntax. Should be .gobject damage 1.0"); return false; } float damage = (float)atof(args); if(!damage) damage = 1; go->TakeDamage(damage); // Destroy it BlueSystemMessage(m_session, "Gameobject Damaged %u .", damage); return true; }
// Spawns the object too, without which you can not interact with the object GameObject* MapMgr::CreateAndSpawnGameObject(uint32 entryID, float x, float y, float z, float o, float scale) { GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(entryID); if(!goi) { LOG_DEBUG("Error looking up entry in CreateAndSpawnGameObject"); return NULL; } LOG_DEBUG("CreateAndSpawnGameObject: By Entry '%u'", entryID); GameObject* go = CreateGameObject(entryID); //Player *chr = m_session->GetPlayer(); uint32 mapid = GetMapId(); // Setup game object go->CreateFromProto(entryID, mapid, x, y, z, o); go->SetScale(scale); go->InitAI(); go->PushToWorld(this); // Create spawn instance GOSpawn* gs = new GOSpawn; gs->entry = go->GetEntry(); gs->facing = go->GetOrientation(); gs->faction = go->GetFaction(); gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS); gs->id = objmgr.GenerateGameObjectSpawnID(); gs->o = 0.0f; gs->o1 = go->GetParentRotation(0); gs->o2 = go->GetParentRotation(2); gs->o3 = go->GetParentRotation(3); gs->scale = go->GetScale(); gs->x = go->GetPositionX(); gs->y = go->GetPositionY(); gs->z = go->GetPositionZ(); gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0); //gs->stateNpcLink = 0; gs->overrides = go->GetOverrides(); uint32 cx = GetPosX(x); uint32 cy = GetPosY(y); GetBaseMap()->GetSpawnsListAndCreate(cx, cy)->GOSpawns.push_back(gs); go->m_spawn = gs; MapCell* mCell = GetCell(cx, cy); if(mCell != NULL) mCell->SetLoaded(); return go; }
void SSCDoors(Player * pPlayer) { //Only opens when the first one steps in, if 669 if you find a way, put it in :P (else was used to increase the time the door stays opened when another one steps on it) GameObject *door = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(803.827f, 6869.38f, -38.5434f, 184212); if (door && (door->GetByte(GAMEOBJECT_BYTES_1, 0) == 1)) { door->SetByte(GAMEOBJECT_BYTES_1, 0, 0); //sEventMgr.AddEvent(door, &GameObject::SetUInt32Value, GAMEOBJECT_STATE, 1, EVENT_SCRIPT_UPDATE_EVENT, 10000, 1, 0); } //else //{ //sEventMgr.RemoveEvents(door); //sEventMgr.AddEvent(door, &GameObject::SetUInt32Value,GAMEOBJECT_STATE, 0, EVENT_SCRIPT_UPDATE_EVENT, 10000, 1, 0); //} }
bool ChatHandler::HandleGORebuild(const char* args, WorldSession* m_session) { GameObject* go = m_session->GetPlayer()->m_GM_SelectedGO; if( !go ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } if(go->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_TYPE_ID) != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) { RedSystemMessage(m_session, "You must select a Destructible gameobject!"); return true; } go->Rebuild(); BlueSystemMessage(m_session, "Gameobject Rebuilt."); return true; }
bool ChatHandler::HandleGODestroy(const char* args, WorldSession* m_session) { GameObject* go = m_session->GetPlayer()->m_GM_SelectedGO; if( !go ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } if(go->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_TYPE_ID) != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) { RedSystemMessage(m_session, "You must select a Destructible gameobject!"); return true; } uint32 hp = go->Health; go->TakeDamage(hp); // Destroy it BlueSystemMessage(m_session, "Gameobject Destroyed."); return true; }
bool ChatHandler::HandleGOActivate(const char* args, WorldSession *m_session) { GameObject* GObj = NULL; GObj = m_session->GetPlayer()->m_GM_SelectedGO; if( !GObj ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } if(GObj->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE) == 1) { // Close/Deactivate GObj->SetByte(GAMEOBJECT_BYTES_1,GAMEOBJECT_BYTES_STATE, 0); GObj->SetUInt32Value(GAMEOBJECT_FLAGS, (GObj->GetUInt32Value(GAMEOBJECT_FLAGS)-1)); } else { // Open/Activate GObj->SetByte(GAMEOBJECT_BYTES_1,GAMEOBJECT_BYTES_STATE, 1); GObj->SetUInt32Value(GAMEOBJECT_FLAGS, (GObj->GetUInt32Value(GAMEOBJECT_FLAGS)+1)); } BlueSystemMessage(m_session, "Gameobject opened/closed."); return true; }
bool ChatHandler::HandleGOInfo(const char* args, WorldSession* m_session) { GameObjectInfo* GOInfo = NULL; GameObject* GObj = m_session->GetPlayer()->GetSelectedGo(); if(!GObj) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } SystemMessage(m_session, "%s Information:", MSG_COLOR_SUBWHITE); SystemMessage(m_session, "%s SpawnID:%s%u", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->m_spawn != NULL ? GObj->m_spawn->id : 0); SystemMessage(m_session, "%s Entry:%s%u", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetEntry()); SystemMessage(m_session, "%s Model:%s%u", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_DISPLAYID)); SystemMessage(m_session, "%s State:%s%u", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetByte(GAMEOBJECT_BYTES_1, 0)); SystemMessage(m_session, "%s flags:%s%u", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_FLAGS)); SystemMessage(m_session, "%s dynflags:%s%u", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_DYNAMIC)); SystemMessage(m_session, "%s faction:%s%u", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetFaction()); SystemMessage(m_session, "%s phase:%s%u", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetPhase()); char gotypetxt[50]; switch(GObj->GetType()) { case GAMEOBJECT_TYPE_DOOR: strcpy(gotypetxt, "Door"); break; case GAMEOBJECT_TYPE_BUTTON: strcpy(gotypetxt, "Button"); break; case GAMEOBJECT_TYPE_QUESTGIVER: strcpy(gotypetxt, "Quest Giver"); break; case GAMEOBJECT_TYPE_CHEST: strcpy(gotypetxt, "Chest"); break; case GAMEOBJECT_TYPE_BINDER: strcpy(gotypetxt, "Binder"); break; case GAMEOBJECT_TYPE_GENERIC: strcpy(gotypetxt, "Generic"); break; case GAMEOBJECT_TYPE_TRAP: strcpy(gotypetxt, "Trap"); break; case GAMEOBJECT_TYPE_CHAIR: strcpy(gotypetxt, "Chair"); break; case GAMEOBJECT_TYPE_SPELL_FOCUS: strcpy(gotypetxt, "Spell Focus"); break; case GAMEOBJECT_TYPE_TEXT: strcpy(gotypetxt, "Text"); break; case GAMEOBJECT_TYPE_GOOBER: strcpy(gotypetxt, "Goober"); break; case GAMEOBJECT_TYPE_TRANSPORT: strcpy(gotypetxt, "Transport"); break; case GAMEOBJECT_TYPE_AREADAMAGE: strcpy(gotypetxt, "Area Damage"); break; case GAMEOBJECT_TYPE_CAMERA: strcpy(gotypetxt, "Camera"); break; case GAMEOBJECT_TYPE_MAP_OBJECT: strcpy(gotypetxt, "Map Object"); break; case GAMEOBJECT_TYPE_MO_TRANSPORT: strcpy(gotypetxt, "Mo Transport"); break; case GAMEOBJECT_TYPE_DUEL_ARBITER: strcpy(gotypetxt, "Duel Arbiter"); break; case GAMEOBJECT_TYPE_FISHINGNODE: strcpy(gotypetxt, "Fishing Node"); break; case GAMEOBJECT_TYPE_RITUAL: strcpy(gotypetxt, "Ritual"); break; case GAMEOBJECT_TYPE_MAILBOX: strcpy(gotypetxt, "Mailbox"); break; case GAMEOBJECT_TYPE_AUCTIONHOUSE: strcpy(gotypetxt, "Auction House"); break; case GAMEOBJECT_TYPE_GUARDPOST: strcpy(gotypetxt, "Guard Post"); break; case GAMEOBJECT_TYPE_SPELLCASTER: strcpy(gotypetxt, "Spell Caster"); break; case GAMEOBJECT_TYPE_MEETINGSTONE: strcpy(gotypetxt, "Meeting Stone"); break; case GAMEOBJECT_TYPE_FLAGSTAND: strcpy(gotypetxt, "Flag Stand"); break; case GAMEOBJECT_TYPE_FISHINGHOLE: strcpy(gotypetxt, "Fishing Hole"); break; case GAMEOBJECT_TYPE_FLAGDROP: strcpy(gotypetxt, "Flag Drop"); break; case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING: strcpy(gotypetxt, "Destructible Building"); break; default: strcpy(gotypetxt, "Unknown."); break; } SystemMessage(m_session, "%s Type:%s%u -- %s", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetType(), gotypetxt); SystemMessage(m_session, "%s Distance:%s%f", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->CalcDistance(m_session->GetPlayer())); GOInfo = GameObjectNameStorage.LookupEntry(GObj->GetEntry()); if(!GOInfo) { RedSystemMessage(m_session, "This GameObject doesn't have template, you won't be able to get some information nor to spawn a GO with this entry."); return true; } if(GOInfo->Name) SystemMessage(m_session, "%s Name:%s%s", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GOInfo->Name); SystemMessage(m_session, "%s Size:%s%f", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetScale()); SystemMessage(m_session, "%s Parent Rotation O1:%s%f", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetParentRotation(1)); SystemMessage(m_session, "%s Parent Rotation O2:%s%f", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetParentRotation(2)); SystemMessage(m_session, "%s Parent Rotation O3:%s%f", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetParentRotation(3)); if( GOInfo->Type == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING ){ SystemMessage(m_session, "%s HP:%s%u/%u", MSG_COLOR_GREEN, MSG_COLOR_LIGHTBLUE, GObj->GetHP(), GObj->GetMaxHP() ); } return true; }
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); GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(EntryID); if(!goi) { sstext << "GameObject Info '" << EntryID << "' Not Found" << '\0'; SystemMessage(m_session, sstext.str().c_str()); return true; } LOG_DEBUG("Spawning GameObject By Entry '%u'", EntryID); sstext << "Spawning GameObject By Entry '" << EntryID << "'" << '\0'; SystemMessage(m_session, sstext.str().c_str()); Player* chr = m_session->GetPlayer(); GameObject* go = chr->GetMapMgr()->CreateGameObject(EntryID); uint32 mapid = chr->GetMapId(); float x = chr->GetPositionX(); float y = chr->GetPositionY(); float z = chr->GetPositionZ(); float o = chr->GetOrientation(); go->CreateFromProto(EntryID, mapid, x, y, z, o); go->PushToWorld(chr->GetMapMgr()); go->Phase(PHASE_SET, chr->GetPhase()); // Create spawn instance GOSpawn* gs = new GOSpawn; gs->entry = go->GetEntry(); gs->facing = go->GetOrientation(); gs->faction = go->GetFaction(); gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS); gs->id = objmgr.GenerateGameObjectSpawnID(); gs->o = 0.0f; gs->o1 = go->GetParentRotation(0); gs->o2 = go->GetParentRotation(2); gs->o3 = go->GetParentRotation(3); gs->scale = go->GetScale(); gs->x = go->GetPositionX(); gs->y = go->GetPositionY(); gs->z = go->GetPositionZ(); gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0); //gs->stateNpcLink = 0; gs->phase = go->GetPhase(); gs->overrides = go->GetOverrides(); uint32 cx = chr->GetMapMgr()->GetPosX(chr->GetPositionX()); uint32 cy = chr->GetMapMgr()->GetPosY(chr->GetPositionY()); chr->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cx, cy)->GOSpawns.push_back(gs); go->m_spawn = gs; MapCell* mCell = chr->GetMapMgr()->GetCell(cx, cy); if(mCell != NULL) mCell->SetLoaded(); if(Save == true) { // If we're saving, create template and add index go->SaveToDB(); go->m_loadedFromDB = true; } sGMLog.writefromsession(m_session, "spawned gameobject %s, entry %u at %u %f %f %f%s", GameObjectNameStorage.LookupEntry(gs->entry)->Name, gs->entry, chr->GetMapId(), gs->x, gs->y, gs->z, Save ? ", saved in DB" : ""); return true; }
bool ChatHandler::HandleGOInfo(const char *args, WorldSession *m_session) { std::stringstream sstext; GameObjectInfo *GOInfo = NULL; GameObject* GObj = NULL; GObj = m_session->GetPlayer()->m_GM_SelectedGO; if( !GObj ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } sstext << MSG_COLOR_SUBWHITE << "Informations:\n" << MSG_COLOR_GREEN << "Entry: " << MSG_COLOR_LIGHTBLUE << GObj->GetEntry() << "\n" << MSG_COLOR_GREEN << "Model: " << MSG_COLOR_LIGHTBLUE << GObj->GetUInt32Value(GAMEOBJECT_DISPLAYID)<< "\n" << MSG_COLOR_GREEN << "State: " << MSG_COLOR_LIGHTBLUE << (uint32)GObj->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE)<< "\n" << MSG_COLOR_GREEN << "flags: " << MSG_COLOR_LIGHTBLUE << GObj->GetUInt32Value(GAMEOBJECT_FLAGS)<< "\n" << MSG_COLOR_GREEN << "dynflags:" << MSG_COLOR_LIGHTBLUE << GObj->GetUInt32Value(GAMEOBJECT_DYNAMIC) << "\n" << MSG_COLOR_GREEN << "faction: " << MSG_COLOR_LIGHTBLUE << GObj->GetUInt32Value(GAMEOBJECT_FACTION)<< "\n" << MSG_COLOR_GREEN << "Type: " << MSG_COLOR_LIGHTBLUE << (uint32)GObj->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_TYPE_ID) << " -- "; switch( GObj->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_TYPE_ID) ) { case GAMEOBJECT_TYPE_DOOR: sstext << "Door"; break; case GAMEOBJECT_TYPE_BUTTON: sstext << "Button"; break; case GAMEOBJECT_TYPE_QUESTGIVER: sstext << "Quest Giver"; break; case GAMEOBJECT_TYPE_CHEST: sstext << "Chest"; break; case GAMEOBJECT_TYPE_BINDER: sstext << "Binder"; break; case GAMEOBJECT_TYPE_GENERIC: sstext << "Generic"; break; case GAMEOBJECT_TYPE_TRAP: sstext << "Trap"; break; case GAMEOBJECT_TYPE_CHAIR: sstext << "Chair"; break; case GAMEOBJECT_TYPE_SPELL_FOCUS: sstext << "Spell Focus"; break; case GAMEOBJECT_TYPE_TEXT: sstext << "Text"; break; case GAMEOBJECT_TYPE_GOOBER: sstext << "Goober"; break; case GAMEOBJECT_TYPE_TRANSPORT: sstext << "Transport"; break; case GAMEOBJECT_TYPE_AREADAMAGE: sstext << "Area Damage"; break; case GAMEOBJECT_TYPE_CAMERA: sstext << "Camera"; break; case GAMEOBJECT_TYPE_MAP_OBJECT: sstext << "Map Object"; break; case GAMEOBJECT_TYPE_MO_TRANSPORT: sstext << "Mo Transport"; break; case GAMEOBJECT_TYPE_DUEL_ARBITER: sstext << "Duel Arbiter"; break; case GAMEOBJECT_TYPE_FISHINGNODE: sstext << "Fishing Node"; break; case GAMEOBJECT_TYPE_RITUAL: sstext << "Ritual"; break; case GAMEOBJECT_TYPE_MAILBOX: sstext << "Mailbox"; break; case GAMEOBJECT_TYPE_AUCTIONHOUSE: sstext << "Auction House"; break; case GAMEOBJECT_TYPE_GUARDPOST: sstext << "Guard Post"; break; case GAMEOBJECT_TYPE_SPELLCASTER: sstext << "Spell Caster"; break; case GAMEOBJECT_TYPE_MEETINGSTONE: sstext << "Meeting Stone"; break; case GAMEOBJECT_TYPE_FLAGSTAND: sstext << "Flag Stand"; break; case GAMEOBJECT_TYPE_FISHINGHOLE: sstext << "Fishing Hole"; break; case GAMEOBJECT_TYPE_FLAGDROP: sstext << "Flag Drop"; break; case GAMEOBJECT_TYPE_MINI_GAME: sstext << "Mini Game"; break; case GAMEOBJECT_TYPE_LOTTERY_KIOSK: sstext << "Lottery Kiosk"; break; case GAMEOBJECT_TYPE_CAPTURE_POINT: sstext << "Capture Point"; break; case GAMEOBJECT_TYPE_AURA_GENERATOR: sstext << "Aura Generator"; break; case GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY: sstext << "Dungeon Difficulty"; break; case GAMEOBJECT_TYPE_BARBER_CHAIR: sstext << "Barber Chair"; break; case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING: sstext << "Destructible Building"; break; case GAMEOBJECT_TYPE_GUILD_BANK: sstext << "Guild Bank"; break; case GAMEOBJECT_TYPE_TRAPDOOR: sstext << "Trapdoor"; break; default: sstext << "Unknown."; break; } sstext << "\n" << MSG_COLOR_GREEN << "Distance: " << MSG_COLOR_LIGHTBLUE << GObj->CalcDistance(m_session->GetPlayer()); GOInfo = GameObjectNameStorage.LookupEntry(GObj->GetEntry()); if( !GOInfo ) { RedSystemMessage(m_session, "This GameObject doesn't have template, you won't be able to get some informations nor to spawn a GO with this entry."); sstext << "|r"; SystemMessage(m_session, sstext.str().c_str()); return true; } sstext << "\n" << MSG_COLOR_GREEN << "Name: " << MSG_COLOR_LIGHTBLUE << GOInfo->Name << "\n" << MSG_COLOR_GREEN << "Size: " << MSG_COLOR_LIGHTBLUE << GObj->GetFloatValue(OBJECT_FIELD_SCALE_X) << "\n" << "|r"; SystemMessage(m_session, sstext.str().c_str()); return true; }
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()); GameObject* 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; } Player* 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->PushToWorld(m_session->GetPlayer()->GetMapMgr()); // Create spawn 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->phase = 1; 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; if(Save == true) { // If we're saving, create template and add index go->SaveToDB(); } return true; }
bool ChatHandler::HandleGOInfo(const char *args, WorldSession *m_session) { std::stringstream sstext; GameObject *GObj = NULL; GObj = m_session->GetPlayer()->m_GM_SelectedGO; if( !GObj ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } WhiteSystemMessage(m_session, "Information:"); if(GObj->m_spawn) GreenSystemMessage(m_session, "SpawnID: %s%u|r", MSG_COLOR_LIGHTBLUE, GObj->m_spawn->id); GreenSystemMessage(m_session, "Entry: %s%u|r", MSG_COLOR_LIGHTBLUE, GObj->GetEntry()); GreenSystemMessage(m_session, "Model: %s%u|r", MSG_COLOR_LIGHTBLUE, GObj->GetDisplayId()); GreenSystemMessage(m_session, "State: %s%u|r", MSG_COLOR_LIGHTBLUE, GObj->GetState()); GreenSystemMessage(m_session, "flags: %s%u|r", MSG_COLOR_LIGHTBLUE, GObj->GetFlags()); GreenSystemMessage(m_session, "dynflags: %s%u|r", MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_DYNAMIC)); GreenSystemMessage(m_session, "faction: %s%u|r", MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_FACTION)); std::stringstream gottext; uint8 type = GObj->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_TYPE_ID); switch(type) { case GAMEOBJECT_TYPE_DOOR: gottext << "Door"; break; case GAMEOBJECT_TYPE_BUTTON: gottext << "Button"; break; case GAMEOBJECT_TYPE_QUESTGIVER: gottext << "Quest Giver"; break; case GAMEOBJECT_TYPE_CHEST: gottext << "Chest"; break; case GAMEOBJECT_TYPE_BINDER: gottext << "Binder"; break; case GAMEOBJECT_TYPE_GENERIC: gottext << "Generic"; break; case GAMEOBJECT_TYPE_TRAP: gottext << "Trap"; break; case GAMEOBJECT_TYPE_CHAIR: gottext << "Chair"; break; case GAMEOBJECT_TYPE_SPELL_FOCUS: gottext << "Spell Focus"; break; case GAMEOBJECT_TYPE_TEXT: gottext << "Text"; break; case GAMEOBJECT_TYPE_GOOBER: gottext << "Goober"; break; case GAMEOBJECT_TYPE_TRANSPORT: gottext << "Transport"; break; case GAMEOBJECT_TYPE_AREADAMAGE: gottext << "Area Damage"; break; case GAMEOBJECT_TYPE_CAMERA: gottext << "Camera"; break; case GAMEOBJECT_TYPE_MAP_OBJECT: gottext << "Map Object"; break; case GAMEOBJECT_TYPE_MO_TRANSPORT: gottext << "Mo Transport"; break; case GAMEOBJECT_TYPE_DUEL_ARBITER: gottext << "Duel Arbiter"; break; case GAMEOBJECT_TYPE_FISHINGNODE: gottext << "Fishing Node"; break; case GAMEOBJECT_TYPE_RITUAL: gottext << "Ritual"; break; case GAMEOBJECT_TYPE_MAILBOX: gottext << "Mailbox"; break; case GAMEOBJECT_TYPE_AUCTIONHOUSE: gottext << "Auction House"; break; case GAMEOBJECT_TYPE_GUARDPOST: gottext << "Guard Post"; break; case GAMEOBJECT_TYPE_SPELLCASTER: gottext << "Spell Caster"; break; case GAMEOBJECT_TYPE_MEETINGSTONE: gottext << "Meeting Stone"; break; case GAMEOBJECT_TYPE_FLAGSTAND: gottext << "Flag Stand"; break; case GAMEOBJECT_TYPE_FISHINGHOLE: gottext << "Fishing Hole"; break; case GAMEOBJECT_TYPE_FLAGDROP: gottext << "Flag Drop"; break; case GAMEOBJECT_TYPE_MINI_GAME: gottext << "Mini Game"; break; case GAMEOBJECT_TYPE_LOTTERY_KIOSK: gottext << "Lottery KIOSK"; break; case GAMEOBJECT_TYPE_CAPTURE_POINT: gottext << "Capture Point"; break; case GAMEOBJECT_TYPE_AURA_GENERATOR: gottext << "Aura Generator"; break; case GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY: gottext << "Dungeon Difficulty"; break; case GAMEOBJECT_TYPE_BARBER_CHAIR: gottext << "Barber Chair"; break; case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING: gottext << "Destructible Building"; break; case GAMEOBJECT_TYPE_GUILD_BANK: gottext << "Guild Bank"; break; case GAMEOBJECT_TYPE_TRAPDOOR: gottext << "Trap Door"; break; default: gottext << "Unknown."; break; } GreenSystemMessage(m_session, "Type: %s%u|r -- %s", MSG_COLOR_LIGHTBLUE, type, gottext.str().c_str()); GreenSystemMessage(m_session, "Distance: %s%f|r", MSG_COLOR_LIGHTBLUE, GObj->CalcDistance((Object*)m_session->GetPlayer())); GreenSystemMessage(m_session, "Size: %s%f|r", MSG_COLOR_LIGHTBLUE, GObj->GetFloatValue(OBJECT_FIELD_SCALE_X)); if(GObj->GetInfo()) GreenSystemMessage(m_session, "Name: %s%s|r", MSG_COLOR_LIGHTBLUE, GObj->GetInfo()->Name); GreenSystemMessage(m_session, "Phase: %s%u|r", MSG_COLOR_LIGHTBLUE, GObj->GetPhaseMask()); SystemMessage(m_session, sstext.str().c_str()); return true; }
bool ChatHandler::HandleGOSpawn(const char *args, WorldSession *m_session) { if(!args) return false; char* pEntryID = strtok((char*)args, " "); if (!pEntryID) return false; uint32 EntryID = atoi(pEntryID); if((GameObjectNameStorage.LookupEntry(EntryID) == NULL) || (objmgr.SQLCheckExists("gameobject_names", "entry", EntryID) == NULL)) { RedSystemMessage(m_session, "Invalid Gameobject ID(%u).", EntryID); return true; } bool Save = m_session->HasGMPermissions() ? true : false; char* pSave = strtok(NULL, " "); if(pSave) Save = (atoi(pSave) > 0 ? true : false); GameObject* go = m_session->GetPlayer()->GetMapMgr()->CreateGameObject(EntryID); if(go == NULL) { RedSystemMessage(m_session, "Spawn of Gameobject(%u) failed.", EntryID); return true; } go->Init(); Player* 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->CreateFromProto(EntryID,mapid,x,y,z,o); BlueSystemMessage(m_session, "Spawning Gameobject(%u) at current position", EntryID); if(Save == true) // If we're saving, create template and add index { // Create spawn 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->scale = go->GetFloatValue(OBJECT_FIELD_SCALE_X); gs->x = x; gs->y = y; gs->z = z; gs->state = go->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE); gs->phase = chr->GetPhaseMask(); go->Load(gs); go->SaveToDB(); uint32 cx = chr->GetMapMgr()->GetPosX(x); uint32 cy = chr->GetMapMgr()->GetPosY(y); chr->GetMapMgr()->AddGoSpawn(cx, cy, gs); } go->SetPhaseMask(chr->GetPhaseMask()); go->SetInstanceID(chr->GetInstanceID()); go->PushToWorld(m_session->GetPlayer()->GetMapMgr()); sWorld.LogGM(m_session, "Spawned gameobject %u at %f %f %f (%s)", EntryID, x, y, z, Save ? "Saved" : "Not Saved"); return true; }
int LuaGlobalFunctions_PerformIngameSpawn(lua_State * L) { uint32 spawntype = luaL_checkint(L, 1); uint32 entry = luaL_checkint(L, 2); uint32 map = luaL_checkint(L, 3); float x = CHECK_FLOAT(L, 4); float y = CHECK_FLOAT(L, 5); float z = CHECK_FLOAT(L, 6); float o = CHECK_FLOAT(L, 7); uint32 faction = luaL_checkint(L, 8); //also scale as percentage uint32 duration = luaL_checkint(L, 9); uint32 equip1 = luaL_optint(L, 10, 1); uint32 equip2 = luaL_optint(L, 11, 1); uint32 equip3 = luaL_optint(L, 12, 1); //13: instance id uint32 save = luaL_optint(L, 14, 0); if(x && y && z && entry) { if (spawntype == 1) //Unit { CreatureProto *p = CreatureProtoStorage.LookupEntry(entry); CreatureInfo *i = CreatureNameStorage.LookupEntry(entry); if (p == NULL || i == NULL) RET_NIL(true); MapMgr *mapMgr = sInstanceMgr.GetMapMgr(map); if (mapMgr == NULL) RET_NIL(true); int32 instanceid = luaL_optint(L, 13, mapMgr->GetInstanceID()); CreatureSpawn * sp = new CreatureSpawn(); sp->entry = entry; sp->id = objmgr.GenerateCreatureSpawnID(); sp->x = x; sp->y = y; sp->z = z; sp->o = o; sp->emote_state = 0; sp->flags = 0; sp->factionid = faction; sp->stand_state = 0; sp->phase = 1; sp->vehicle = p->vehicle_entry > 0 ? true : false; sp->Bytes = NULL; sp->ChannelData = NULL; sp->MountedDisplay = NULL; Creature * pCreature = NULL; if(sp->vehicle) { pCreature = TO_CREATURE(mapMgr->CreateVehicle(entry)); TO_VEHICLE(pCreature)->Load(sp, mapMgr->iInstanceMode, NULL); } else { pCreature = mapMgr->CreateCreature(entry); pCreature->Load(sp, mapMgr->iInstanceMode, NULL); } pCreature->m_loadedFromDB = true; pCreature->SetFaction(faction); pCreature->SetInstanceID(instanceid); pCreature->SetMapId(map); pCreature->m_noRespawn = true; pCreature->PushToWorld(mapMgr); if (duration>0) pCreature->Despawn(duration,0); if (save) pCreature->SaveToDB(); Lunar<Unit>::push(L,TO_UNIT(pCreature)); } else if (spawntype == 2) //GO { GameObjectInfo *n = GameObjectNameStorage.LookupEntry(entry); if (n == NULL) RET_NIL(true); MapMgr *mapMgr = sInstanceMgr.GetMapMgr(map); if (mapMgr == NULL) RET_NIL(true); int32 instanceid = luaL_optint(L, 13, mapMgr->GetInstanceID()); GameObject *go = mapMgr->CreateGameObject(entry); go->SetInstanceID(instanceid); go->CreateFromProto(entry,map,x,y,z,o); // Create spawn instance GOSpawn * gs = new GOSpawn; gs->entry = go->GetEntry(); gs->facing = go->GetOrientation(); gs->faction = go->GetFaction(); gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS); gs->id = objmgr.GenerateGameObjectSpawnID(); gs->scale = go->GetUInt32Value(OBJECT_FIELD_SCALE_X); gs->x = go->GetPositionX(); gs->y = go->GetPositionY(); gs->z = go->GetPositionZ(); gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0); gs->phase = 0; go->m_spawn = gs; go->PushToWorld(mapMgr); if (duration) sEventMgr.AddEvent(go,&GameObject::ExpireAndDelete,EVENT_GAMEOBJECT_UPDATE,duration,1,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); if (save) go->SaveToDB(); Lunar<GameObject>::push(L,go); } else RET_NIL(true); } else RET_NIL(true); return 1; }