本文整理汇总了C++中GameObject::GetOrientation方法的典型用法代码示例。如果您正苦于以下问题:C++ GameObject::GetOrientation方法的具体用法?C++ GameObject::GetOrientation怎么用?C++ GameObject::GetOrientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject::GetOrientation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleGOSpawn
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;
}
示例2: TeleportTransport
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
Map const* oldMap = GetMap();
if (oldMap->GetId() != newMapid)
{
Map* newMap = sMapMgr->CreateBaseMap(newMapid);
Map::PlayerList const& oldPlayers = GetMap()->GetPlayers();
if (!oldPlayers.isEmpty())
{
UpdateData data;
BuildOutOfRangeUpdateBlock(&data);
WorldPacket packet;
data.BuildPacket(&packet);
for (Map::PlayerList::const_iterator itr = oldPlayers.begin(); itr != oldPlayers.end(); ++itr)
if (itr->GetSource()->GetTransport() != this)
itr->GetSource()->SendDirectMessage(&packet);
}
UnloadStaticPassengers();
GetMap()->RemoveFromMap<Transport>(this, false);
SetMap(newMap);
Map::PlayerList const& newPlayers = GetMap()->GetPlayers();
if (!newPlayers.isEmpty())
{
for (Map::PlayerList::const_iterator itr = newPlayers.begin(); itr != newPlayers.end(); ++itr)
{
if (itr->GetSource()->GetTransport() != this)
{
UpdateData data;
BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
WorldPacket packet;
data.BuildPacket(&packet);
itr->GetSource()->SendDirectMessage(&packet);
}
}
}
for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();)
{
WorldObject* obj = (*itr++);
switch (obj->GetTypeId())
{
case TYPEID_UNIT:
if (!IS_PLAYER_GUID(obj->ToUnit()->GetOwnerGUID())) // pets should be teleported with player
obj->ToCreature()->FarTeleportTo(newMap, x, y, z, obj->GetOrientation());
break;
case TYPEID_GAMEOBJECT:
{
GameObject* go = obj->ToGameObject();
go->GetMap()->RemoveFromMap(go, false);
Relocate(x, y, z, go->GetOrientation());
SetMap(newMap);
newMap->AddToMap(go);
break;
}
case TYPEID_PLAYER:
if (!obj->ToPlayer()->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT))
_passengers.erase(obj);
break;
default:
break;
}
}
GetMap()->AddToMap<Transport>(this);
}
else
{
// Teleport players, they need to know it
for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
if ((*itr)->GetTypeId() == TYPEID_PLAYER)
(*itr)->ToUnit()->NearTeleportTo(x, y, z, GetOrientation());
}
UpdatePosition(x, y, z, GetOrientation());
}
示例3: HandleGameObjectMoveCommand
//move selected object
static bool HandleGameObjectMoveCommand(ChatHandler* handler, char const* args)
{
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
if (!id)
return false;
ObjectGuid::LowType guidLow = strtoull(id, nullptr, 10);
if (!guidLow)
return false;
GameObject* object = NULL;
// by DB guid
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
handler->SetSentErrorMessage(true);
return false;
}
char* toX = strtok(NULL, " ");
char* toY = strtok(NULL, " ");
char* toZ = strtok(NULL, " ");
float x, y, z;
if (!toX)
{
Player* player = handler->GetSession()->GetPlayer();
player->GetPosition(x, y, z);
}
else
{
if (!toY || !toZ)
return false;
x = (float)atof(toX);
y = (float)atof(toY);
z = (float)atof(toZ);
if (!MapManager::IsValidMapCoord(object->GetMapId(), x, y, z))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, object->GetMapId());
handler->SetSentErrorMessage(true);
return false;
}
}
object->DestroyForNearbyPlayers();
object->RelocateStationaryPosition(x, y, z, object->GetOrientation());
object->GetMap()->GameObjectRelocation(object, x, y, z, object->GetOrientation());
object->SaveToDB();
handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetGUID().ToString().c_str());
return true;
}
示例4: Update
void instance_maraudon::Update(uint32 uiDiff)
{
if (m_uiSpawnTimer <= uiDiff)
{
m_uiSpawnTimer = 5000;
GameObject* pGo = instance->GetGameObject(m_uiLarvaSpewerGUID);
if (!pGo || pGo->GetGoState() == GO_STATE_ACTIVE)
return;
Map::PlayerList const& L = instance->GetPlayers();
if (L.isEmpty())
return;
bool spawn = false;
for (Map::PlayerList::const_iterator i = L.begin(); i != L.end(); ++i)
{
Player* P = i->getSource();
if (P && P->isAlive() && P->GetDistance(pGo) <= 45.0f)
{
spawn = true;
break;
}
}
if (spawn)
{
float coord_dif[2];
for (int i = 0; i < 2; i++)
coord_dif[i] = (float)urand(-3,4);
if (Creature* C = pGo->SummonCreature(NPC_LARVA,pGo->GetPositionX()+coord_dif[0],pGo->GetPositionY()+coord_dif[1],pGo->GetPositionZ(),pGo->GetOrientation(),TEMPSUMMON_CORPSE_TIMED_DESPAWN,3000))
C->SetInCombatWithZone();
//Unit* target = C->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
//if (target && C->AI())
// C->AI()->AttackStart(target);
}
}
else
m_uiSpawnTimer -= uiDiff;
}
示例5: OnUse
bool OnUse(Player* player, Item* /*pItem*/, SpellCastTargets const & /*targets*/)
{
GameObject* go = NULL;
for (uint8 i = 0; i < CaribouTrapsNum; ++i)
{
go = player->FindNearestGameObject(CaribouTraps[i], 5.0f);
if (go)
break;
}
if (!go)
return false;
if (go->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, true) || go->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, false) || go->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 2.0f))
return true;
float x, y, z;
go->GetClosePoint(x, y, z, go->GetObjectSize() / 3, 7.0f);
go->SummonGameObject(GO_HIGH_QUALITY_FUR, go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), 0, 0, 0, 0, 0, 1000);
if (TempSummon* summon = player->SummonCreature(NPC_NESINGWARY_TRAPPER, x, y, z, go->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000))
{
summon->SetVisible(false);
summon->SetReactState(REACT_PASSIVE);
summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
}
return false;
}
示例6: Update
//.........这里部分代码省略.........
for (uint8 u = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H); u < (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_2_A : BG_IC_NPC_GLAIVE_THROWER_2_H); u++)
{
if (Creature* glaiveThrower = GetBGCreature(u))
{
if (!glaiveThrower->isAlive())
glaiveThrower->Respawn(true);
}
}
docksTimer = DOCKS_UPDATE_TIME;
} else nodePoint[i].timer -= diff;
}
}
if (nodePoint[i].nodeType == NODE_TYPE_WORKSHOP)
{
if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A ||
nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H)
{
if (siegeEngineWorkshopTimer <= diff)
{
uint8 siegeType = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_A : BG_IC_NPC_SIEGE_ENGINE_H);
if (Creature* siege = GetBGCreature(siegeType)) // this always should be true
{
if (siege->isAlive())
{
if (siege->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_UNK_14|UNIT_FLAG_OOC_NOT_ATTACKABLE))
// following sniffs the vehicle always has UNIT_FLAG_UNK_14
siege->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_OOC_NOT_ATTACKABLE);
else
siege->SetHealth(siege->GetMaxHealth());
}
else
siege->Respawn(true);
}
// we need to confirm this, i am not sure if this every 3 minutes
for (uint8 u = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_A : BG_IC_NPC_DEMOLISHER_1_H); u < (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_4_A : BG_IC_NPC_DEMOLISHER_4_H); u++)
{
if (Creature* demolisher = GetBGCreature(u))
{
if (!demolisher->isAlive())
demolisher->Respawn(true);
}
}
siegeEngineWorkshopTimer = WORKSHOP_UPDATE_TIME;
} else siegeEngineWorkshopTimer -= diff;
}
}
// the point is waiting for a change on his banner
if (nodePoint[i].needChange)
{
if (nodePoint[i].timer <= diff)
{
uint32 nextBanner = GetNextBanner(&nodePoint[i], nodePoint[i].faction, true);
nodePoint[i].last_entry = nodePoint[i].gameobject_entry;
nodePoint[i].gameobject_entry = nextBanner;
// nodePoint[i].faction = the faction should be the same one...
GameObject* banner = GetBGObject(nodePoint[i].gameobject_type);
if (!banner) // this should never happen
return;
float cords[4] = {banner->GetPositionX(), banner->GetPositionY(), banner->GetPositionZ(), banner->GetOrientation() };
DelObject(nodePoint[i].gameobject_type);
AddObject(nodePoint[i].gameobject_type, nodePoint[i].gameobject_entry, cords[0], cords[1], cords[2], cords[3], 0, 0, 0, 0, RESPAWN_ONE_DAY);
GetBGObject(nodePoint[i].gameobject_type)->SetUInt32Value(GAMEOBJECT_FACTION, nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_Factions[1] : BG_IC_Factions[0]);
UpdateNodeWorldState(&nodePoint[i]);
HandleCapturedNodes(&nodePoint[i], false);
SendMessage2ToAll(LANG_BG_IC_TEAM_HAS_TAKEN_NODE, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL, (nodePoint[i].faction == TEAM_ALLIANCE ? LANG_BG_IC_ALLIANCE : LANG_BG_IC_HORDE), nodePoint[i].string);
nodePoint[i].needChange = false;
nodePoint[i].timer = BANNER_STATE_CHANGE_TIME;
} else nodePoint[i].timer -= diff;
}
}
if (resourceTimer <= diff)
{
for (uint8 i = 0; i < NODE_TYPE_DOCKS; i++)
{
if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A ||
nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H)
{
factionReinforcements[nodePoint[i].faction] += 1;
RewardHonorToTeam(RESOURCE_HONOR_AMOUNT, nodePoint[i].faction == TEAM_ALLIANCE ? ALLIANCE : HORDE);
UpdateWorldState((nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_ALLIANCE_RENFORT : BG_IC_HORDE_RENFORT), factionReinforcements[nodePoint[i].faction]);
}
}
resourceTimer = IC_RESOURCE_TIME;
} else resourceTimer -= diff;
}
示例7: PostUpdateImpl
void BattlegroundIC::PostUpdateImpl(uint32 diff)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
if (!doorsClosed)
{
if (closeFortressDoorsTimer <= diff)
{
GetBGObject(BG_IC_GO_DOODAD_ND_HUMAN_GATE_CLOSEDFX_DOOR01)->RemoveFromWorld();
GetBGObject(BG_IC_GO_DOODAD_ND_WINTERORC_WALL_GATEFX_DOOR01)->RemoveFromWorld();
GetBGObject(BG_IC_GO_DOODAD_ND_HUMAN_GATE_CLOSEDFX_DOOR02)->RemoveFromWorld();
GetBGObject(BG_IC_GO_DOODAD_ND_WINTERORC_WALL_GATEFX_DOOR02)->RemoveFromWorld();
GetBGObject(BG_IC_GO_DOODAD_ND_HUMAN_GATE_CLOSEDFX_DOOR03)->RemoveFromWorld();
GetBGObject(BG_IC_GO_DOODAD_ND_WINTERORC_WALL_GATEFX_DOOR03)->RemoveFromWorld();
GetBGObject(BG_IC_GO_ALLIANCE_GATE_1)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
GetBGObject(BG_IC_GO_HORDE_GATE_1)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
GetBGObject(BG_IC_GO_ALLIANCE_GATE_2)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
GetBGObject(BG_IC_GO_HORDE_GATE_2)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
GetBGObject(BG_IC_GO_ALLIANCE_GATE_3)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
GetBGObject(BG_IC_GO_HORDE_GATE_3)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
doorsClosed = true;
} else closeFortressDoorsTimer -= diff;
}
for (uint8 i = NODE_TYPE_REFINERY; i < MAX_NODE_TYPES; ++i)
{
if (nodePoint[i].nodeType == NODE_TYPE_DOCKS)
{
if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A ||
nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H)
{
if (nodePoint[i].timer <= diff)
{
// we need to confirm this, i am not sure if this every 3 minutes
for (uint8 j = 0; j < MAX_CATAPULTS_SPAWNS_PER_FACTION; ++j)
{
uint8 type = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H)+j;
if (Creature* catapult = GetBGCreature(type))
if (!catapult->IsAlive())
{
// Check if creature respawn time is properly saved
RespawnMap::iterator itr = respawnMap.find(catapult->GetGUIDLow());
if (itr == respawnMap.end() || time(NULL) < itr->second)
continue;
catapult->Relocate(BG_IC_DocksVehiclesCatapults[j].GetPositionX(), BG_IC_DocksVehiclesCatapults[j].GetPositionY(), BG_IC_DocksVehiclesCatapults[j].GetPositionZ(), BG_IC_DocksVehiclesCatapults[j].GetOrientation());
catapult->Respawn(true);
respawnMap.erase(itr);
}
}
// we need to confirm this is blizzlike, not sure if it is every 3 minutes
for (uint8 j = 0; j < MAX_GLAIVE_THROWERS_SPAWNS_PER_FACTION; ++j)
{
uint8 type = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H)+j;
if (Creature* glaiveThrower = GetBGCreature(type))
if (!glaiveThrower->IsAlive())
{
// Check if creature respawn time is properly saved
RespawnMap::iterator itr = respawnMap.find(glaiveThrower->GetGUIDLow());
if (itr == respawnMap.end() || time(NULL) < itr->second)
continue;
glaiveThrower->Relocate(BG_IC_DocksVehiclesGlaives[j].GetPositionX(), BG_IC_DocksVehiclesGlaives[j].GetPositionY(), BG_IC_DocksVehiclesGlaives[j].GetPositionZ(), BG_IC_DocksVehiclesGlaives[j].GetOrientation());
glaiveThrower->Respawn(true);
respawnMap.erase(itr);
}
}
docksTimer = DOCKS_UPDATE_TIME;
}
else
nodePoint[i].timer -= diff;
}
}
if (nodePoint[i].nodeType == NODE_TYPE_WORKSHOP)
{
if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A ||
nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H)
{
if (siegeEngineWorkshopTimer <= diff)
{
uint8 siegeType = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_A : BG_IC_NPC_SIEGE_ENGINE_H);
if (Creature* siege = GetBGCreature(siegeType)) // this always should be true
if (!siege->IsAlive())
{
// Check if creature respawn time is properly saved
RespawnMap::iterator itr = respawnMap.find(siege->GetGUIDLow());
if (itr == respawnMap.end() || time(NULL) < itr->second)
continue;
siege->Relocate(BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(), BG_IC_WorkshopVehicles[4].GetPositionZ(), BG_IC_WorkshopVehicles[4].GetOrientation());
siege->Respawn(true);
respawnMap.erase(itr);
}
//.........这里部分代码省略.........
示例8: EventCaptureBase
void AlteracValley::EventCaptureBase(Player *src,uint32 bannerslot)
{
if(!gcbanner[bannerslot])
return;
/*uint64 guid = src->GetGUID();
std::map<uint64, BattlegroundScore>::iterator itr = m_PlayerScores.find(guid);
if(itr == m_PlayerScores.end())
{
SendMessageToPlayer(src, "INTERNAL ERROR: Could not find in internal player score map!", true);
return;
}
itr->second.FlagCaptures++;
UpdatePVPData();*/
//uint32 rbasesfield = src->m_bgTeam ? AB_HORDE_CAPTUREBASE : AB_ALLIANCE_CAPTUREBASE;
uint32 goentry = 0;
if(bannerslot < 6) // outside flags are diferent
goentry = src->m_bgTeam ? 178393:178389;
else
goentry = src->m_bgTeam ? 178946:178935;
GameObject *pcbanner = src->GetCurrentBattleground()->SpawnGameObject(goentry, 30, gcbanner[bannerslot]->GetPositionX(), gcbanner[bannerslot]->GetPositionY(), gcbanner[bannerslot]->GetPositionZ(), gcbanner[bannerslot]->GetOrientation(), 32, src->m_bgTeam ?84:83, 1);
pcbanner->SetFloatValue(GAMEOBJECT_ROTATION_02,gcbanner[bannerslot]->GetFloatValue(GAMEOBJECT_ROTATION_02));
pcbanner->SetFloatValue(GAMEOBJECT_ROTATION_03,gcbanner[bannerslot]->GetFloatValue(GAMEOBJECT_ROTATION_03));
pcbanner->SetUInt32Value(GAMEOBJECT_STATE, 1);
pcbanner->SetUInt32Value(GAMEOBJECT_TYPE_ID, 1);
pcbanner->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pcbanner->AddToWorld();
if(pcbanner->GetInfo()->sound3)
{
pcbanner->pcbannerAura = src->GetCurrentBattleground()->SpawnGameObject(pcbanner->GetInfo()->sound3, 30, pcbanner->GetPositionX(), pcbanner->GetPositionY(), pcbanner->GetPositionZ(), pcbanner->GetOrientation(), 32, 114, 5);
pcbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_02,pcbanner->GetFloatValue(GAMEOBJECT_ROTATION_02));
pcbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_03,pcbanner->GetFloatValue(GAMEOBJECT_ROTATION_03));
pcbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_STATE, 1);
pcbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_TYPE_ID, 6);
pcbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pcbanner->pcbannerAura->AddToWorld();
}
if(gcbanner[bannerslot]->pcbannerAura)
{
if( gcbanner[bannerslot]->pcbannerAura->IsInWorld() )
gcbanner[bannerslot]->pcbannerAura->RemoveFromWorld();
delete gcbanner[bannerslot]->pcbannerAura;
}
if( gcbanner[bannerslot]->IsInWorld() )
gcbanner[bannerslot]->RemoveFromWorld();
delete gcbanner[bannerslot];
gcbanner[bannerslot] = NULL;
// Play sound
WorldPacket pkt;
pkt.Initialize(SMSG_PLAY_SOUND);
pkt << uint32(src->m_bgTeam ? SOUND_HORDE_CAPTURE : SOUND_ALLIANCE_CAPTURE);
SendPacketToAll(&pkt);
char message[300];
static char *resnames[11] = {"Frostworlf Gravyard","Iceblood Graveyard","Stormpike Gravyard",
"Stoneheart gravyard","Relief Hunt","Stormpike Aid Station",
"Iceblood Tower","Stoneheart Bunker","Icewing Bunker",
"Stormpike North Bunker","Stormpike South Bunker"};
snprintf(message, 300, "The %s has taken the %s!", src->m_bgTeam ? "Horde" : "Alliance" , resnames[bannerslot] );
WorldPacket *data = BuildMessageChat(src->m_bgTeam ? 0x54:0x53, 0x27, message, 0);
SendPacketToAll(data);
delete data;
}
示例9: SpawnBattleground
void AlteracValley::SpawnBattleground()
{
// Alliance Gate
/*GameObject *gate = SpawnGameObject(180255, 529, 1284.597290, 1281.166626, -15.977916, 0.706859, 32, 114, 1.5799990);
gate->SetFloatValue(GAMEOBJECT_ROTATION,0.0129570);
gate->SetFloatValue(GAMEOBJECT_ROTATION_01,-0.0602880);
gate->SetFloatValue(GAMEOBJECT_ROTATION_02,0.3449600);
gate->SetFloatValue(GAMEOBJECT_ROTATION_03,0.9365900);
m_Gates.insert(gate);
// Horde Gate
gate = SpawnGameObject(180256, 529, 708.0902710, 708.4479370, -17.3898964, -2.3910990, 32, 114, 1.5699990);
gate->SetFloatValue(GAMEOBJECT_ROTATION,0.0502910);
gate->SetFloatValue(GAMEOBJECT_ROTATION_01,0.0151270);
gate->SetFloatValue(GAMEOBJECT_ROTATION_02,0.9292169);
gate->SetFloatValue(GAMEOBJECT_ROTATION_03,-0.3657840);
m_Gates.insert(gate);*/
// -- Places Banners --
// Frostworlf gravyard
GameObject *pbanner = SpawnGameObject(178393 ,30 ,-1083.244385 ,-345.994507 ,55.124435 ,4.596910, 32, 84, 1);
pbanner->SetUInt32Value(GAMEOBJECT_STATE, 1);
pbanner->SetUInt32Value(GAMEOBJECT_TYPE_ID, 1);
pbanner->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pbanner->AddToWorld();
if(pbanner->GetInfo()->sound3)
{
pbanner->pcbannerAura = SpawnGameObject(pbanner->GetInfo()->sound3, 30, pbanner->GetPositionX(), pbanner->GetPositionY(), pbanner->GetPositionZ(), pbanner->GetOrientation(), 32, 114, 5);
pbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_02,pbanner->GetFloatValue(GAMEOBJECT_ROTATION_02));
pbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_03,pbanner->GetFloatValue(GAMEOBJECT_ROTATION_03));
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_STATE, 1);
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_TYPE_ID, 6);
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pbanner->pcbannerAura->AddToWorld();
}
pbanner->bannerslot = 0;
// Iceblood graveyard
pbanner = SpawnGameObject(178393, 30 ,-612.329285 ,-396.660095 ,60.858463 ,2.916166, 32, 84, 1);
pbanner->SetUInt32Value(GAMEOBJECT_STATE, 1);
pbanner->SetUInt32Value(GAMEOBJECT_TYPE_ID, 1);
pbanner->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pbanner->AddToWorld();
if(pbanner->GetInfo()->sound3)
{
pbanner->pcbannerAura = SpawnGameObject(pbanner->GetInfo()->sound3, 30, pbanner->GetPositionX(), pbanner->GetPositionY(), pbanner->GetPositionZ(), pbanner->GetOrientation(), 32, 114, 5);
pbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_02,pbanner->GetFloatValue(GAMEOBJECT_ROTATION_02));
pbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_03,pbanner->GetFloatValue(GAMEOBJECT_ROTATION_03));
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_STATE, 1);
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_TYPE_ID, 6);
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pbanner->pcbannerAura->AddToWorld();
}
pbanner->bannerslot = 1;
// Stormpike gravyard
pbanner = SpawnGameObject(178389, 30 ,669.968567 ,-293.467468 ,30.283821 ,3.152932, 32, 83, 1);
pbanner->SetUInt32Value(GAMEOBJECT_STATE, 1);
pbanner->SetUInt32Value(GAMEOBJECT_TYPE_ID, 1);
pbanner->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pbanner->AddToWorld();
if(pbanner->GetInfo()->sound3)
{
pbanner->pcbannerAura = SpawnGameObject(pbanner->GetInfo()->sound3, 30, pbanner->GetPositionX(), pbanner->GetPositionY(), pbanner->GetPositionZ(), pbanner->GetOrientation(), 32, 114, 5);
pbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_02,pbanner->GetFloatValue(GAMEOBJECT_ROTATION_02));
pbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_03,pbanner->GetFloatValue(GAMEOBJECT_ROTATION_03));
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_STATE, 1);
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_TYPE_ID, 6);
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pbanner->pcbannerAura->AddToWorld();
}
pbanner->bannerslot = 2;
// Stoneheart gravyard
pbanner = SpawnGameObject(178389, 30 ,78.205989 ,-405.1715 ,47.11583 ,1.535766, 32, 83, 1);
pbanner->SetUInt32Value(GAMEOBJECT_STATE, 1);
pbanner->SetUInt32Value(GAMEOBJECT_TYPE_ID, 1);
pbanner->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pbanner->AddToWorld();
if(pbanner->GetInfo()->sound3)
{
pbanner->pcbannerAura = SpawnGameObject(pbanner->GetInfo()->sound3, 30, pbanner->GetPositionX(), pbanner->GetPositionY(), pbanner->GetPositionZ(), pbanner->GetOrientation(), 32, 114, 5);
pbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_02,pbanner->GetFloatValue(GAMEOBJECT_ROTATION_02));
pbanner->pcbannerAura->SetFloatValue(GAMEOBJECT_ROTATION_03,pbanner->GetFloatValue(GAMEOBJECT_ROTATION_03));
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_STATE, 1);
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_TYPE_ID, 6);
pbanner->pcbannerAura->SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100);
pbanner->pcbannerAura->AddToWorld();
}
pbanner->bannerslot = 3;
//.........这里部分代码省略.........
示例10: HandleGOSpawn
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;
}
示例11: HandleGameObjectUseOpcode
void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
uint64 guid;
uint32 spellId = OPEN_CHEST;
const GameObjectInfo *info;
recv_data >> guid;
sLog.outDebug( "WORLD: Recvd CMSG_GAMEOBJ_USE Message [guid=%u]", guid);
GameObject *obj = ObjectAccessor::GetGameObject(*_player, guid);
if(!obj) return;
//obj->SetUInt32Value(GAMEOBJECT_FLAGS,2);
//obj->SetUInt32Value(GAMEOBJECT_FLAGS,2);
// default spell caster is player that use GO
Unit* spellCaster = GetPlayer();
// default spell target is player that use GO
Unit* spellTarget = GetPlayer();
if (Script->GOHello(_player, obj))
return;
switch(obj->GetGoType())
{
case GAMEOBJECT_TYPE_DOOR: //0
obj->SetUInt32Value(GAMEOBJECT_FLAGS,33);
obj->SetUInt32Value(GAMEOBJECT_STATE,0); //open
//obj->SetUInt32Value(GAMEOBJECT_TIMESTAMP,0x465EE6D2); //load timestamp
obj->SetLootState(GO_CLOSED);
obj->SetRespawnTime(5); //close door in 5 seconds
return;
case GAMEOBJECT_TYPE_BUTTON: //1
obj->SetUInt32Value(GAMEOBJECT_FLAGS,33);
obj->SetUInt32Value(GAMEOBJECT_STATE,0); //open
obj->SetLootState(GO_CLOSED);
obj->SetRespawnTime(2); //close in 1 seconds
// activate script
sWorld.ScriptsStart(sButtonScripts, obj->GetDBTableGUIDLow(), spellCaster, obj);
return;
case GAMEOBJECT_TYPE_QUESTGIVER: //2
_player->PrepareQuestMenu( guid );
_player->SendPreparedQuest( guid );
return;
//Sitting: Wooden bench, chairs enzz
case GAMEOBJECT_TYPE_CHAIR: //7
info = obj->GetGOInfo();
if(info)
{
//spellId = info->data0; // this is not a spell or offset
_player->TeleportTo(obj->GetMapId(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),false,false);
_player->SetFlag(UNIT_FIELD_BYTES_1,PLAYER_STATE_SIT_LOW_CHAIR); // Using (3 + spellId) was wrong, this is a number of slot for chair/bench, not offset
_player->SetStandState(PLAYER_STATE_SIT_LOW_CHAIR);
return;
}
break;
//big gun, its a spell/aura
case GAMEOBJECT_TYPE_GOOBER: //10
info = obj->GetGOInfo();
spellId = info ? info->data10 : 0;
break;
case GAMEOBJECT_TYPE_SPELLCASTER: //22
obj->SetUInt32Value(GAMEOBJECT_FLAGS,2);
info = obj->GetGOInfo();
if(info)
{
spellId = info->data0;
if (spellId == 0)
spellId = info->data3;
//guid=_player->GetGUID();
}
break;
case GAMEOBJECT_TYPE_CAMERA: //13
info = obj->GetGOInfo();
if(info)
{
uint32 cinematic_id = info->data1;
if(cinematic_id)
{
WorldPacket data(SMSG_TRIGGER_CINEMATIC, 4);
data << cinematic_id;
_player->GetSession()->SendPacket(&data);
}
return;
}
break;
//.........这里部分代码省略.........
示例12: OnUse
bool OnUse(Player* player, Item* /*item*/, SpellCastTargets const & /*targets*/) override
{
GameObject* go = nullptr;
for (uint8 i = 0; i < CaribouTrapsNum; ++i)
{
go = player->FindNearestGameObject(CaribouTraps[i], 5.0f);
if (go)
break;
}
if (!go)
return false;
if (go->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, true) || go->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, false) || go->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 2.0f))
return true;
float x, y, z;
go->GetClosePoint(x, y, z, go->GetCombatReach() / 3, 7.0f);
go->SummonGameObject(GO_HIGH_QUALITY_FUR, *go, QuaternionData(), 1);
if (TempSummon* summon = player->SummonCreature(NPC_NESINGWARY_TRAPPER, x, y, z, go->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000))
{
summon->SetVisible(false);
summon->SetReactState(REACT_PASSIVE);
summon->SetImmuneToPC(true);
}
return false;
}
示例13: HandleGOSpawn
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;
}
sLog.outDebug("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);
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);
/* fuck blizz coordinate system */
go->SetFloatValue(GAMEOBJECT_ROTATION_02, sinf(o / 2));
go->SetFloatValue(GAMEOBJECT_ROTATION_03, cosf(o / 2));
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->o = go->GetFloatValue(GAMEOBJECT_ROTATION);
gs->o1 = go->GetFloatValue(GAMEOBJECT_ROTATION_01);
gs->o2 = go->GetFloatValue(GAMEOBJECT_ROTATION_02);
gs->o3 = 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->GetUInt32Value(GAMEOBJECT_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;
MapCell * mCell = m_session->GetPlayer()->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, m_session->GetPlayer()->GetMapId(), gs->x, gs->y, gs->z, Save ? ", saved in DB" : "" );
return true;
}
示例14: ItemUse_item_pile_fake_furs
bool ItemUse_item_pile_fake_furs(Player *pPlayer, Item * /*pItem*/, SpellCastTargets const & /*targets*/)
{
GameObject *pGo = NULL;
for (uint8 i = 0; i < CaribouTrapsNum; ++i)
{
pGo = pPlayer->FindNearestGameObject(CaribouTraps[i], 5.0f);
if (pGo)
break;
}
if (!pGo)
return false;
if (pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, true) || pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, false) || pGo->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 2.0f))
return true;
float x, y, z;
pGo->GetClosePoint(x, y, z, pGo->GetObjectSize() / 3, 7.0f);
pGo->SummonGameObject(GO_HIGH_QUALITY_FUR, pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ(), 0, 0, 0, 0, 0, 1000);
if (TempSummon* summon = pPlayer->SummonCreature(NPC_NESINGWARY_TRAPPER, x, y, z, pGo->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000))
{
summon->SetVisibility(VISIBILITY_OFF);
summon->SetReactState(REACT_PASSIVE);
summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
}
return false;
}
示例15: HandleGameObjectMoveCommand
//move selected object
static bool HandleGameObjectMoveCommand(ChatHandler* handler, char const* args)
{
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
if (!id)
return false;
ObjectGuid::LowType guidLow = atoul(id);
if (!guidLow)
return false;
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
handler->SetSentErrorMessage(true);
return false;
}
char* toX = strtok(nullptr, " ");
char* toY = strtok(nullptr, " ");
char* toZ = strtok(nullptr, " ");
float x, y, z;
if (!toX)
{
Player* player = handler->GetSession()->GetPlayer();
player->GetPosition(x, y, z);
}
else
{
if (!toY || !toZ)
return false;
x = (float)atof(toX);
y = (float)atof(toY);
z = (float)atof(toZ);
if (!MapManager::IsValidMapCoord(object->GetMapId(), x, y, z))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, object->GetMapId());
handler->SetSentErrorMessage(true);
return false;
}
}
Map* map = object->GetMap();
object->Relocate(x, y, z, object->GetOrientation());
object->SaveToDB();
// Generate a completely new spawn with new guid
// 3.3.5a client caches recently deleted objects and brings them back to life
// when CreateObject block for this guid is received again
// however it entirely skips parsing that block and only uses already known location
object->Delete();
object = new GameObject();
if (!object->LoadFromDB(guidLow, map, true))
{
delete object;
return false;
}
handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId());
return true;
}