Exemplo n.º 1
0
GameObject* Transport::CreateGOPassenger(uint32 guid, GameObjectData const* data)
{
    Map* map = GetMap();
    GameObject* go = new GameObject();

    if (!go->LoadGameObjectFromDB(guid, map, false))
    {
        delete go;
        return NULL;
    }

    float x = data->posX;
    float y = data->posY;
    float z = data->posZ;
    float o = data->orientation;

    go->SetTransport(this);
    go->m_movementInfo.transport.guid = GetGUID();
    go->m_movementInfo.transport.pos.Relocate(x, y, z, o);  // m_movementInfo.transport.pos.m_positionX = offset
    go->m_movementInfo.transport.seat = -1;
    CalculatePassengerPosition(x, y, z, &o);                // This method transforms supplied transport offsets into global coordinates offset > worldpos
    go->Relocate(x, y, z, o);                               // me->m_positionX = worldpos
    go->RelocateStationaryPosition(x, y, z, o);             // this->gameobject->m_stationaryPosition  x=worldpos
    go->m_updateFlag |= UPDATEFLAG_GO_TRANSPORT_POSITION;

    if (!go->IsPositionValid())
    {
        TC_LOG_ERROR("entities.transport", "GameObject (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", go->GetGUIDLow(), go->GetEntry(), go->GetPositionX(), go->GetPositionY());
        delete go;
        return NULL;
    }

    if (!map->AddToMap(go))
    {
        delete go;
        return NULL;
    }

    _staticPassengers.insert(go);
    return go;
}
Exemplo n.º 2
0
void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket)
{
    ObjectGuid guid;
    recvPacket >> guid;

    DEBUG_LOG("WORLD: Received opcode CMSG_GAMEOBJ_REPORT_USE guid: %s", guid.GetString().c_str());

    // ignore for remote control state
    if (!_player->IsSelfMover())
        return;

    GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid);
    if (!go)
        return;

    if (!go->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
        return;

    _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, go->GetEntry());
}
Exemplo n.º 3
0
void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket)
{
    uint64 guid;
    recvPacket >> guid;

    sLog.outDebug( "WORLD: Recvd CMSG_GAMEOBJ_REPORT_USE Message [in game guid: %u]", GUID_LOPART(guid));

    // ignore for remote control state
    if(_player->m_mover != _player)
        return;

    GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid);
    if(!go)
        return;

    if(!go->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
        return;

    _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, go->GetEntry());
}
Exemplo n.º 4
0
void WorldSession::HandleLootReleaseOpcode( WorldPacket & recv_data )
{
	if(!_player->IsInWorld()) return;
	uint64 guid;

	recv_data >> guid;

	WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, 9);
	data << guid << uint8( 1 );
	SendPacket( &data );

	_player->SetLootGUID(0);
	_player->RemoveFlag(UNIT_FIELD_FLAGS, U_FIELD_ANIMATION_LOOTING);
	_player->m_currentLoot = 0;

	if(UINT32_LOPART(GUID_HIPART(guid)) == HIGHGUID_UNIT)
	{
		Creature* pCreature = _player->GetMapMgr()->GetCreature(guid);
		if(!pCreature)
			return;
		// remove from looter set
		pCreature->loot.looters.erase(_player->GetGUID());
		if(!pCreature->loot.gold)
		{			
			for(std::vector<__LootItem>::iterator i=pCreature->loot.items.begin();i!=pCreature->loot.items.end();i++)
			if(i->iItemsCount)
			{
				ItemPrototype *proto=ItemPrototypeStorage.LookupEntry(i->item.itemid);
				if(proto->Class != 12)
				return;
				if(_player->HasQuestForItem(i->item.itemid))
				return;
			}
			pCreature->BuildFieldUpdatePacket(_player, UNIT_DYNAMIC_FLAGS, 0);

			if(!pCreature->Skinned)
			{
				if(lootmgr.IsSkinnable(pCreature->GetEntry()))
				{
					pCreature->BuildFieldUpdatePacket(_player, UNIT_FIELD_FLAGS, U_FIELD_FLAG_SKINNABLE);
				}
			}
		}
	}
	else if(UINT32_LOPART(GUID_HIPART(guid)) == HIGHGUID_GAMEOBJECT)
	{	   
		GameObject* pGO = _player->GetMapMgr()->GetGameObject(guid);
		if(!pGO)
			return;
		pGO->loot.looters.erase(_player->GetGUID());
		//GO MUST DISAPPEAR AFTER LOOTING,
		//FIX ME: respawn time of GO must be added,15 minutes by default
		//if this is not fishing bobber despawn it
		if(pGO->GetUInt32Value(GAMEOBJECT_TYPE_ID)==GAMEOBJECT_TYPE_FISHINGNODE)
		{
			if(pGO->IsInWorld())
			{
				pGO->RemoveFromWorld();
			}
			delete pGO;
		}
		else
		{
			uint32 DespawnTime = 0;
			if(sQuestMgr.GetGameObjectLootQuest(pGO->GetEntry()))
				DespawnTime = 120000;	   // 5 min for quest GO,
			else
			{
				DespawnTime = 900000;	   // 15 for else
			}


			pGO->Despawn(DespawnTime);
		}
	}
	else if(UINT32_LOPART(GUID_HIPART(guid)) == HIGHGUID_CORPSE)
	{
		Corpse *pCorpse = objmgr.GetCorpse(guid);
		if(pCorpse) 
			pCorpse->SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, 0);
	}
	else if(UINT32_LOPART(GUID_HIPART(guid)) == HIGHGUID_PLAYER)
	{
		Player *plr = objmgr.GetPlayer(guid);
		if(plr)
		{
			plr->bShouldHaveLootableOnCorpse = false;
			plr->RemoveFlag(UNIT_DYNAMIC_FLAGS, U_DYN_FLAG_LOOTABLE);
		}
	}
	else if(UINT32_LOPART(GUID_HIPART(guid)))
	{
		// suicide!
		_player->GetItemInterface()->SafeFullRemoveItemByGuid(guid);
	}
}
Exemplo n.º 5
0
void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data )
{
    ObjectGuid guid;

    recv_data >> guid;

    DEBUG_LOG("WORLD: Recvd CMSG_GAMEOBJ_USE Message guid: %s", guid.GetString().c_str());

    // ignore for remote control state
    if (!_player->IsSelfMover())
        return;

    GameObject *obj = GetPlayer()->GetMap()->GetGameObject(guid);
    if(!obj)
        return;

    // Never expect this opcode for some type GO's
    if (obj->GetGoType() == GAMEOBJECT_TYPE_GENERIC)
    {
        sLog.outError("HandleGameObjectUseOpcode: CMSG_GAMEOBJ_USE for not allowed GameObject type %u (Entry %u), didn't expect this to happen.", obj->GetGoType(), obj->GetEntry());
        return;
    }

    obj->Use(_player);
}
Exemplo n.º 6
0
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;
}
        void Dragonspireroomcheck()
        {
            Creature* mob = NULL;
            GameObject* rune = NULL;

            for (uint8 i = 0; i < 7; ++i)
            {
                bool _mobAlive = false;
                rune = instance->GetGameObject(go_roomrunes[i]);
                if (rune && rune->GetGoState() == GO_STATE_ACTIVE)
                {
                    for (uint8 ii = 0; ii < 5; ++ii)
                    {
                        mob = instance->GetCreature(runecreaturelist[i][ii]);
                        if (mob && mob->IsAlive())
                            _mobAlive = true;
                    }
                }

                if (!_mobAlive && rune->GetGoState() == GO_STATE_ACTIVE)
                {
                    HandleGameObject(0, false, rune);

                    switch (rune->GetEntry())
                    {
                        case GO_HALL_RUNE_1:
                            SetBossState(DATA_HALL_RUNE_1, DONE);
                            break;
                        case GO_HALL_RUNE_2:
                            SetBossState(DATA_HALL_RUNE_2, DONE);
                            break;
                        case GO_HALL_RUNE_3:
                            SetBossState(DATA_HALL_RUNE_3, DONE);
                            break;
                        case GO_HALL_RUNE_4:
                            SetBossState(DATA_HALL_RUNE_4, DONE);
                            break;
                        case GO_HALL_RUNE_5:
                            SetBossState(DATA_HALL_RUNE_5, DONE);
                            break;
                        case GO_HALL_RUNE_6:
                            SetBossState(DATA_HALL_RUNE_6, DONE);
                            break;
                        case GO_HALL_RUNE_7:
                            SetBossState(DATA_HALL_RUNE_7, DONE);
                            break;
                        default:
                            break;
                    }
                }
            }

            if (GetBossState(DATA_HALL_RUNE_1) == DONE && GetBossState(DATA_HALL_RUNE_2) == DONE && GetBossState(DATA_HALL_RUNE_3) == DONE &&
                GetBossState(DATA_HALL_RUNE_4) == DONE && GetBossState(DATA_HALL_RUNE_5) == DONE && GetBossState(DATA_HALL_RUNE_6) == DONE &&
                GetBossState(DATA_HALL_RUNE_7) == DONE)
            {
                SetBossState(DATA_DRAGONSPIRE_ROOM, DONE);
                if (GameObject* door1 = instance->GetGameObject(go_emberseerin))
                    HandleGameObject(0, true, door1);
                if (GameObject* door2 = instance->GetGameObject(go_doors))
                    HandleGameObject(0, true, door2);
            }
        }
Exemplo n.º 8
0
void GameObject::UseFishingNode(Player *player)
{
	sEventMgr.RemoveEvents( this );
	if( GetUInt32Value( GAMEOBJECT_FLAGS ) != 32 ) // Clicking on the bobber before something is hooked
	{
		player->GetSession()->OutPacket( SMSG_FISH_NOT_HOOKED );
		EndFishing( player, true );
		return;
	}
	
	/* Unused code: sAreaStore.LookupEntry(GetMapMgr()->GetAreaID(GetPositionX(),GetPositionY()))->ZoneId*/
	uint32 zone = player->GetAreaID();
	if( zone == 0 ) // If the player's area ID is 0, use the zone ID instead
		zone = player->GetZoneId();

	FishingZoneEntry *entry = FishingZoneStorage.LookupEntry( zone );
	if( entry == NULL ) // No fishing information found for area or zone, log an error, and end fishing
	{
		sLog.outError( "ERROR: Fishing zone information for zone %d not found!", zone );
		EndFishing( player, true );
		return;
	}
	uint32 maxskill = entry->MaxSkill;
	uint32 minskill = entry->MinSkill;

	if( player->_GetSkillLineCurrent( SKILL_FISHING, false ) < maxskill )	
		player->_AdvanceSkillLine( SKILL_FISHING, float2int32( 1.0f * sWorld.getRate( RATE_SKILLRATE ) ) );

	GameObject * school = NULL;
	this->AquireInrangeLock(); //make sure to release lock before exit function !
	for ( InRangeSet::iterator it = GetInRangeSetBegin(); it != GetInRangeSetEnd(); ++it )
	{
		if ( (*it) == NULL || (*it)->GetTypeId() != TYPEID_GAMEOBJECT || (*it)->GetUInt32Value(GAMEOBJECT_TYPE_ID) != GAMEOBJECT_TYPE_FISHINGHOLE)
			continue;
		school = static_cast<GameObject *>( *it );
		if ( !isInRange( school, (float)school->GetInfo()->sound1 ) )
		{
			school = NULL;
			continue;
		}
		else
			break;
	}
	this->ReleaseInrangeLock();

	if ( school != NULL ) // open school loot if school exists
	{
		lootmgr.FillGOLoot( &school->loot, school->GetEntry(), school->GetMapMgr() ? ( school->GetMapMgr()->iInstanceMode ? true : false ) : false );
		player->SendLoot( school->GetGUID(), LOOT_FISHING );
		EndFishing( player, false );
		school->CatchFish();
		if ( !school->CanFish() )
			sEventMgr.AddEvent( school, &GameObject::Despawn, ( 1800000 + RandomUInt( 3600000 ) ), EVENT_GAMEOBJECT_EXPIRE, 10000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT ); // respawn in 30 - 90 minutes
	}
	else if( Rand( ( ( player->_GetSkillLineCurrent( SKILL_FISHING, true ) - minskill ) * 100 ) / maxskill ) ) // Open loot on success, otherwise FISH_ESCAPED.
	{
		lootmgr.FillFishingLoot( &loot, zone );
		player->SendLoot( GetGUID(), LOOT_FISHING );
		EndFishing( player, false );
	}
	else // Failed
	{
		player->GetSession()->OutPacket( SMSG_FISH_ESCAPED );
		EndFishing( player, true );
	}

}
Exemplo n.º 9
0
    static void SendSelectionInfo(Player* player, uint32 GObjectID, bool isHex, bool add) // Sends an addon message for selected objects list
    {
        if (!player || !GObjectID)
            return;
        
        std::ostringstream ss;
        if (!add)
            if(!isHex)
                ss << "GOMOVE|REMOVE|" << std::dec << (uint32)GObjectID <<"||0";
            else
                ss << "GOMOVE|REMOVE|" << "0x" << std::hex << GObjectID <<"||0";
        else
        {
            GameObject* object = GetObjectByGObjectID(player, GObjectID, isHex);
            if(!object)
                return;
            if(!isHex)
                ss <<"GOMOVE|ADD|" << std::dec << (uint32)GObjectID << std::dec <<"|"<< object->GetName() <<"|"<< object->GetEntry();
            else
                ss <<"GOMOVE|ADD|" << "0x" << std::hex << GObjectID << std::dec <<"|"<< object->GetName() <<"|"<< object->GetEntry();
        }

        SendAddonMessage(player, ss.str().c_str());
    }
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
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 << GObj->GetUInt32Value(GAMEOBJECT_STATE)<< "\n"
		<< MSG_COLOR_GREEN << "flags: " << MSG_COLOR_LIGHTBLUE << GObj->GetUInt32Value(GAMEOBJECT_FLAGS)<< "\n"
		<< MSG_COLOR_GREEN << "dynflags:" << MSG_COLOR_LIGHTBLUE << GObj->GetUInt32Value(GAMEOBJECT_DYN_FLAGS) << "\n"
		<< MSG_COLOR_GREEN << "faction: " << MSG_COLOR_LIGHTBLUE << GObj->GetUInt32Value(GAMEOBJECT_FACTION)<< "\n"
		<< MSG_COLOR_GREEN << "Type: "  << MSG_COLOR_LIGHTBLUE << GObj->GetUInt32Value(GAMEOBJECT_TYPE_ID)  << " -- ";

	switch( GObj->GetUInt32Value(GAMEOBJECT_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;
	default:							sstext << "Unknown.";	break;
	}

	sstext
		<< "\n"
		<< MSG_COLOR_GREEN << "Distance: " << MSG_COLOR_LIGHTBLUE << GObj->CalcDistance((Object*)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;
}
Exemplo n.º 12
0
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;
}
Exemplo n.º 13
0
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;
}
Exemplo n.º 14
0
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session)
{
	GameObject *GObj = m_session->GetPlayer()->GetSelectedGo();
	if( GObj == NULL )
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}

	if( GObj->IsInBg() )
	{
		RedSystemMessage(m_session, "GameObjects can't be deleted in Battlegrounds");
		return true;
	}

	if( GObj->m_spawn != NULL && GObj->m_spawn->entry == GObj->GetEntry() )
	{
		uint32 cellx = uint32(((_maxX-GObj->m_spawn->x)/_cellSize));
		uint32 celly = uint32(((_maxY-GObj->m_spawn->y)/_cellSize));

		if( cellx < _sizeX && celly < _sizeY )
		{
			CellSpawns * sp = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsList( cellx, celly );
			if( sp != NULL )
			{
				for( GOSpawnList::iterator itr = sp->GOSpawns.begin(); itr != sp->GOSpawns.end(); ++itr )
					if( (*itr) == GObj->m_spawn )
					{
						sp->GOSpawns.erase( itr );
						break;
					}
			}
			GObj->DeleteFromDB();
			delete GObj->m_spawn;
			GObj->m_spawn = NULL;
		}
	}
	sGMLog.writefromsession(m_session,"deleted game object entry %u on map %u at X:%f Y:%f Z:%f Name %s", GObj->GetEntry(),GObj->GetMapId(),GObj->GetPositionX(),GObj->GetPositionY(),GObj->GetPositionZ(),GameObjectNameStorage.LookupEntry(GObj->GetEntry())->Name);
	GObj->Despawn(0, 0); // We do not need to delete the object because GameObject::Despawn with no time => ExpireAndDelete() => _Expire() => delete GObj;

	m_session->GetPlayer()->m_GM_SelectedGO = 0;

  /*  std::stringstream sstext;

	GameObject *GObj = m_session->GetPlayer()->m_GM_SelectedGO;
	if( !GObj )
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}

	GObj->GetMapMgr()->GetBaseMap()->GetTemplate()->RemoveIndex<GameObject>(GObj);	// remove index
	GObj->Despawn(3600000);
	GObj->DeleteFromDB();
	sObjHolder.Delete<GameObject>(GObj);

	m_session->GetPlayer()->m_GM_SelectedGO = NULL;

	GreenSystemMessage(m_session, "GameObject successfully deleted from world and database !");
*/
	return true;
}
Exemplo n.º 15
0
bool ChatHandler::HandleGOScale(const char* args, WorldSession* m_session)
{
	GameObject* go = m_session->GetPlayer()->GetSelectedGo();
	if(!go)
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}
	if(!args)
	{
		RedSystemMessage(m_session, "Invalid syntax. Should be .gobject scale 1.0");
		return false;
	}
	float scale = (float)atof(args);
	if(!scale) scale = 1;
	go->SetScale(scale);
	BlueSystemMessage(m_session, "Set scale to %.3f", scale);
	sGMLog.writefromsession(m_session, "set scale on gameobject %s to %.3f, entry %u", GameObjectNameStorage.LookupEntry(go->GetEntry())->Name, scale, go->GetEntry());
	uint32 NewGuid = m_session->GetPlayer()->GetMapMgr()->GenerateGameobjectGuid();
	go->RemoveFromWorld(true);
	go->SetNewGuid(NewGuid);
	go->PushToWorld(m_session->GetPlayer()->GetMapMgr());
	go->SaveToDB();
	//lets reselect the object that can be really annoying...
	m_session->GetPlayer()->m_GM_SelectedGO = NewGuid;
	return true;
}
Exemplo n.º 16
0
    static bool GOMove_Command(ChatHandler* handler, const char* args)
    {
        if (!args)
            return false;

        char* ID_t = strtok((char*)args, " ");
        if (!ID_t)
            return false;
        uint32 ID = (uint32)atol(ID_t);

        char* GObjectID_C = strtok(NULL, " ");
        uint32 GObjectID = 0;
        bool isHex = false;
        if (GObjectID_C)
        {
            GObjectID = strtoul(GObjectID_C, NULL, 0); // can take in hex as well as dec
            isHex = (std::string(GObjectID_C).find("0x") != std::string::npos);
        }

        char* ARG_t = strtok(NULL, " ");
        uint32 ARG = 0;
        if (ARG_t)
            ARG = (uint32)atol(ARG_t);

        WorldSession* session = handler->GetSession();
        Player* player = session->GetPlayer();
        uint64 playerGUID = player->GetGUID();

        if (ID < SPAWN) // no args
        {
            if (ID >= DELET && ID <= GOTO) // has target (needs retrieve gameobject)
            {
                GameObject* target = GetObjectByGObjectID(player, GObjectID, isHex);
                if (!target)
                    ChatHandler(player->GetSession()).PSendSysMessage("Object GUID: %u not found. Temp(%u)", GObjectID, isHex ? 1 : 0);
                else
                {
                    float x,y,z,o;
                    target->GetPosition(x,y,z,o);
                    uint32 p = target->GetPhaseMask();
                    switch(ID)
                    {
                    case DELET: DeleteObject(target/*, isHex ? GObjectID : 0*/); SendSelectionInfo(player, GObjectID, isHex, false); break;
                    case X: SpawnObject(player,player->GetPositionX(),y,z,o,p,true,GObjectID, isHex);      break;
                    case Y: SpawnObject(player,x,player->GetPositionY(),z,o,p,true,GObjectID, isHex);      break;
                    case Z: SpawnObject(player,x,y,player->GetPositionZ(),o,p,true,GObjectID, isHex);      break;
                    case O: SpawnObject(player,x,y,z,player->GetOrientation(),p,true,GObjectID, isHex);    break;
                    case GOTO: player->TeleportTo(target->GetMapId(), x,y,z,o);                     break;
                    case RESPAWN: SpawnObject(player,x,y,z,o,p,false,target->GetEntry(), isHex);           break;
                    case GROUND:
                        {
                            float ground = target->GetMap()->GetHeight(target->GetPhaseMask(), x, y, MAX_HEIGHT);
                            if(ground != INVALID_HEIGHT)
                                SpawnObject(player,x,y,ground,o,p,true,GObjectID, isHex);
                        } break;
                    }
                }
            }
            else
            {
                switch(ID)
                {
                case TEST: session->SendAreaTriggerMessage(player->GetName().c_str());      break;
                case FACE: { float piper2 = M_PI/2; float multi = player->GetOrientation()/piper2; float multi_int = floor(multi); float new_ori = (multi-multi_int > 0.5f) ? (multi_int+1)*piper2 : multi_int*piper2; player->SetFacingTo(new_ori); } break;
                case SAVE: SaveObject(player, GObjectID, isHex);                                   break;
                case SELECTNEAR:
                    {
                        GameObject* object = handler->GetNearbyGameObject();
                        object = GetClosestGObjectID(player, object);
                        if (!object)
                            ChatHandler(player->GetSession()).PSendSysMessage("No objects found");
                        else
                        {
                            bool isHex = (object->GetGUIDHigh() != HIGHGUID_GAMEOBJECT);
                            SendSelectionInfo(player, isHex ? object->GetGUIDHigh() : object->GetDBTableGUIDLow() ? object->GetDBTableGUIDLow() : object->GetGUIDLow(), isHex, true);
                            session->SendAreaTriggerMessage("Selected %s", object->GetName().c_str());
                        }
                    } break;
                }
            }
        }
        else if (ARG && ID >= SPAWN)
        {
            if (ID >= NORTH && ID <= PHASE)
            {
                GameObject* target = GetObjectByGObjectID(player, GObjectID, isHex);
                if (!target)
                    ChatHandler(player->GetSession()).PSendSysMessage("Object GUID: %u not found. Temporary: %s", GObjectID, isHex ? "true" : "false");
                else
                {
                    float x,y,z,o;
                    target->GetPosition(x,y,z,o);
                    uint32 p = target->GetPhaseMask();
                    switch(ID)
                    {
                    case NORTH: SpawnObject(player,x+((float)ARG/100),y,z,o,p,true,GObjectID, isHex);                        break;
                    case EAST: SpawnObject(player,x,y-((float)ARG/100),z,o,p,true,GObjectID, isHex);                         break;
                    case SOUTH: SpawnObject(player,x-((float)ARG/100),y,z,o,p,true,GObjectID, isHex);                        break;
                    case WEST: SpawnObject(player,x,y+((float)ARG/100),z,o,p,true,GObjectID, isHex);                         break;
                    case NORTHEAST: SpawnObject(player,x+((float)ARG/100),y-((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case SOUTHEAST: SpawnObject(player,x-((float)ARG/100),y-((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case SOUTHWEST: SpawnObject(player,x-((float)ARG/100),y+((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case NORTHWEST: SpawnObject(player,x+((float)ARG/100),y+((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case UP: SpawnObject(player,x,y,z+((float)ARG/100),o,p,true,GObjectID, isHex);                           break;
                    case DOWN: SpawnObject(player,x,y,z-((float)ARG/100),o,p,true,GObjectID, isHex);                         break;
                    case RIGHT: SpawnObject(player,x,y,z,o-((float)ARG/100),p,true,GObjectID, isHex);                        break;
                    case LEFT: SpawnObject(player,x,y,z,o+((float)ARG/100),p,true,GObjectID, isHex);                         break;
                    case PHASE: SpawnObject(player,x,y,z,o,ARG,true,GObjectID, isHex);                                       break;
                    }
                }
            }
            else
            {
                switch(ID)
                {
                case SPAWN:
                    {
                        if (SpawnObject(player, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),  player->GetOrientation(), player->GetPhaseMaskForSpawn(), false, ARG, false, true))
                            SpawnQue[player->GetGUID()] = ARG;
                    } break;
                case SPAWNSPELL:
                    {
                        SpawnQue[player->GetGUID()] = ARG;
                    } break;
                case SELECTALLNEAR:
                    { 
                        if (ARG > 5000)
                            ARG = 5000;

                        QueryResult result = WorldDatabase.PQuery("SELECT guid, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%u' AND position_x BETWEEN '%f'-'%u' AND '%f'+'%u' AND position_y BETWEEN '%f'-'%u' AND '%f'+'%u' AND position_z BETWEEN '%f'-'%u' AND '%f'+'%u' ORDER BY order_ ASC LIMIT 100",
                            player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetPositionX(), ARG, player->GetPositionX(), ARG, player->GetPositionY(), ARG, player->GetPositionY(), ARG, player->GetPositionZ(), ARG, player->GetPositionZ(), ARG);

                        if (result)
                        {
                            do
                            {
                                Field* fields   = result->Fetch();
                                uint32 guidLow  = fields[0].GetUInt32();

                                if (GameObject* object = GetObjectByGObjectID(player, guidLow, false))
                                    SendSelectionInfo(player, guidLow, false, true);
                            }
                            while (result->NextRow());
                        }
                        for(std::set<uint32>::const_iterator it = GObjects.begin(); it != GObjects.end();)
                        {
                            GameObject* temp = player->GetGameObject(*it);
                            if(!temp)
                            {
                                GObjects.erase(*it++);
                                continue;
                            }
                            if(temp->IsWithinDistInMap(player, ARG))
                                SendSelectionInfo(player, (*it), true, true);
                            ++it;
                        }
                    } break;
                }
            }
        }
        else
            return false;
        return true;
    }
Exemplo n.º 17
0
bool ChatHandler::HandleGOSelect(const char* args, WorldSession* m_session)
{
	GameObject* GObj = NULL;
	GameObject* GObjs = m_session->GetPlayer()->GetSelectedGo();

	std::set<Object*>::iterator Itr = m_session->GetPlayer()->GetInRangeSetBegin();
	std::set<Object*>::iterator Itr2 = m_session->GetPlayer()->GetInRangeSetEnd();
	float cDist = 9999.0f;
	float nDist = 0.0f;
	bool bUseNext = false;

	if(args)
	{
		if(args[0] == '1')
		{
			if(GObjs == NULL)
				bUseNext = true;

			for(;; Itr++)
			{
				if(Itr == Itr2 && GObj == NULL && bUseNext)
					Itr = m_session->GetPlayer()->GetInRangeSetBegin();
				else if(Itr == Itr2)
					break;

				if((*Itr)->IsGameObject())
				{
					// Find the current go, move to the next one
					if(bUseNext)
					{
						// Select the first.
						GObj = TO< GameObject* >(*Itr);
						break;
					}
					else
					{
						if(((*Itr) == GObjs))
						{
							// Found him. Move to the next one, or beginning if we're at the end
							bUseNext = true;
						}
					}
				}
			}
		}
	}
	if(!GObj)
	{
		for(; Itr != Itr2; Itr++)
		{
			if((*Itr)->IsGameObject())
			{
				if((nDist = m_session->GetPlayer()->CalcDistance(*Itr)) < cDist)
				{
					cDist = nDist;
					nDist = 0.0f;
					GObj = TO_GAMEOBJECT(*Itr);
				}
			}
		}
	}


	if(GObj == NULL)
	{
		RedSystemMessage(m_session, "No inrange GameObject found.");
		return true;
	}

	m_session->GetPlayer()->m_GM_SelectedGO = GObj->GetGUID();

	GreenSystemMessage(m_session, "Selected GameObject [ %s ] which is %.3f meters away from you.",
	                   GameObjectNameStorage.LookupEntry(GObj->GetEntry())->Name, m_session->GetPlayer()->CalcDistance(GObj));

	return true;
}
Exemplo n.º 18
0
    bool EffectDummy(Unit* pCaster, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Object* pTarget, ObjectGuid /*originalCasterGuid*/) override
    {
 #if defined (WOTLK) || defined (CATA)
        if (uiSpellId == SPELL_ANUNIAQS_NET)
        {
            GameObject* pGOTarget = pTarget->ToGameObject();
            if (uiEffIndex == EFFECT_INDEX_0)
            {
                if (pGOTarget->GetRespawnTime() != 0 || pGOTarget->GetEntry() != GO_TASTY_REEF_FISH || pCaster->GetTypeId() != TYPEID_PLAYER)
                    return true;

                if (urand(0, 3))
                {
                    if (Item* pItem = ((Player*)pCaster)->StoreNewItemInInventorySlot(ITEM_TASTY_REEF_FISH, 1))
                        ((Player*)pCaster)->SendNewItem(pItem, 1, true, false);
                }
                else
                {
                    if (Creature* pShark = pCaster->SummonCreature(NPC_REEF_SHARK, pGOTarget->GetPositionX(), pGOTarget->GetPositionY(), pGOTarget->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OOC_DESPAWN, 30000))
                        pShark->AI()->AttackStart(pCaster);
                }

                pGOTarget->SetLootState(GO_JUST_DEACTIVATED);
                return true;
            }
            return true;
        }
 #endif
        if (uiSpellId == SPELL_CAST_FISHING_NET)
        {
            GameObject* pGOTarget = pTarget->ToGameObject();
            if (uiEffIndex == EFFECT_INDEX_0)
            {
                if (pGOTarget->GetRespawnTime() != 0 || pGOTarget->GetEntry() != GO_RED_SNAPPER || pCaster->GetTypeId() != TYPEID_PLAYER)
                {
                    return true;
                }

                if (urand(0, 2))
                {
                    if (Creature* pMurloc = pCaster->SummonCreature(NPC_ANGRY_MURLOC, pCaster->GetPositionX(), pCaster->GetPositionY() + 20.0f, pCaster->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OOC_DESPAWN, 10000))
                    {
                        pMurloc->AI()->AttackStart(pCaster);
                    }
                }
                else
                {
                    if (Item* pItem = ((Player*)pCaster)->StoreNewItemInInventorySlot(ITEM_RED_SNAPPER, 1))
                    {
                        ((Player*)pCaster)->SendNewItem(pItem, 1, true, false);
                    }
                }

                pGOTarget->SetLootState(GO_JUST_DEACTIVATED);
                return true;
            }
            return true;
        }

        return false;
    }
Exemplo n.º 19
0
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;
}
Exemplo n.º 20
0
void InstanceScript::DoUseDoorOrButton(uint64 uiGuid, uint32 uiWithRestoreTime, bool bUseAlternativeState)
{
    if (!uiGuid)
        return;

    GameObject* go = instance->GetGameObject(uiGuid);

    if (go)
    {
        if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR || go->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
        {
            if (go->getLootState() == GO_READY)
                go->UseDoorOrButton(uiWithRestoreTime, bUseAlternativeState);
            else if (go->getLootState() == GO_ACTIVATED)
                go->ResetDoorOrButton();
        }
        else
            SF_LOG_ERROR("misc", "SD2: Script call DoUseDoorOrButton, but gameobject entry %u is type %u.", go->GetEntry(), go->GetGoType());
    }
}
Exemplo n.º 21
0
inline void Map::_ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const
{
    bool bOpen = false;
    uint32 guid = scriptInfo->ToggleDoor.GOGuid;
    int32 nTimeToToggle = std::max(15, int32(scriptInfo->ToggleDoor.ResetDelay));
    switch (scriptInfo->command)
    {
    case SCRIPT_COMMAND_OPEN_DOOR:
        bOpen = true;
        break;
    case SCRIPT_COMMAND_CLOSE_DOOR:
        break;
    default:
        sLog->outError("%s unknown command for _ScriptProcessDoor.", scriptInfo->GetDebugInfo().c_str());
        return;
    }
    if (!guid)
        sLog->outError("%s door guid is not specified.", scriptInfo->GetDebugInfo().c_str());
    else if (!source)
        sLog->outError("%s source object is NULL.", scriptInfo->GetDebugInfo().c_str());
    else if (!source->isType(TYPEMASK_UNIT))
        sLog->outError("%s source object is not unit (TypeId: %u, Entry: %u, GUID: %u), skipping.", scriptInfo->GetDebugInfo().c_str(),
                       source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
    else
    {
        WorldObject* wSource = dynamic_cast <WorldObject*> (source);
        if (!wSource)
            sLog->outError("%s source object could not be casted to world object (TypeId: %u, Entry: %u, GUID: %u), skipping.",
                           scriptInfo->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
        else
        {
            GameObject* pDoor = _FindGameObject(wSource, guid);
            if (!pDoor)
                sLog->outError("%s gameobject was not found (guid: %u).", scriptInfo->GetDebugInfo().c_str(), guid);
            else if (pDoor->GetGoType() != GAMEOBJECT_TYPE_DOOR)
                sLog->outError("%s gameobject is not a door (GoType: %u, Entry: %u, GUID: %u).",
                               scriptInfo->GetDebugInfo().c_str(), pDoor->GetGoType(), pDoor->GetEntry(), pDoor->GetGUIDLow());
            else if (bOpen == (pDoor->GetGoState() == GO_STATE_READY))
            {
                pDoor->UseDoorOrButton(nTimeToToggle);

                if (target && target->isType(TYPEMASK_GAMEOBJECT))
                {
                    GameObject* goTarget = target->ToGameObject();
                    if (goTarget && goTarget->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
                        goTarget->UseDoorOrButton(nTimeToToggle);
                }
            }
        }
    }
}
Exemplo n.º 22
0
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;

	//go->AddToWorld();

	if(Save == true)
	{
		// If we're saving, create template and add index
		go->SaveToDB();
	}
	return true;
}
Exemplo n.º 23
0
// 62 fields, [7]-[68]
void BattlefieldTB::FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& packet)
{
    packet.Worldstates.emplace_back(uint32(TB_WS_ALLIANCE_ATTACKING_SHOW), int32(IsWarTime() && GetAttackerTeam() == TEAM_ALLIANCE ? 1 : 0));
    packet.Worldstates.emplace_back(uint32(TB_WS_HORDE_ATTACKING_SHOW), int32(IsWarTime() && GetAttackerTeam() == TEAM_HORDE ? 1 : 0));

    // Not sure if TB
    //packet.Worldstates.emplace_back(uint32(TB_WS_9_UNKNOWN), int32(1));

    packet.Worldstates.emplace_back(uint32(TB_WS_SOUTH_DAMAGED_NEUTRAL), int32(0));
    packet.Worldstates.emplace_back(uint32(TB_WS_SOUTH_INTACT_NEUTRAL), int32(0));

    packet.Worldstates.emplace_back(uint32(TB_WS_PROGRESS_SHOW), int32(0));

    // Buildings/bases
    for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
    {
        uint8 i = TB_BASE_COUNT;
        switch (itr->second->GetCapturePointEntry())
        {
            case GO_CAPTURE_POINT_NORTH_A_DEFENDING:
            case GO_CAPTURE_POINT_NORTH_H_DEFENDING:
                i = TB_BASE_IRONCLAD_GARRISON;
                break;
            case GO_CAPTURE_POINT_EAST_A_DEFENDING:
            case GO_CAPTURE_POINT_EAST_H_DEFENDING:
                i = TB_BASE_SLAGWORKS;
                break;
            case GO_CAPTURE_POINT_WEST_A_DEFENDING:
            case GO_CAPTURE_POINT_WEST_H_DEFENDING:
                i = TB_BASE_WARDENS_VIGIL;
                break;
            default:
                continue;
        }

        TeamId team = TEAM_NEUTRAL;
        bool controlled = false;
        bool capturing = false;

        switch (itr->second->GetObjectiveState())
        {
            case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE:
            case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE:
                controlled = true;
                team = itr->second->GetTeamId();
                break;
            case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE:
            case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE:
                team = TEAM_ALLIANCE;
                capturing = true;
                break;
            case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE:
            case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE:
                team = TEAM_HORDE;
                capturing = true;
                break;
            default:
                team = TEAM_NEUTRAL;
                break;
        }

        packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsControlled[TEAM_ALLIANCE]), int32(team == TEAM_ALLIANCE && controlled ? 1 : 0));
        packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsCapturing[TEAM_ALLIANCE]), int32(team == TEAM_ALLIANCE && capturing ? 1 : 0));
        packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsNeutral), int32(team == TEAM_NEUTRAL ? 1 : 0));
        packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsCapturing[TEAM_HORDE]), int32(team == TEAM_HORDE && capturing ? 1 : 0));
        packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsControlled[TEAM_HORDE]), int32(team == TEAM_HORDE && controlled ? 1 : 0));
    }

    packet.Worldstates.emplace_back(uint32(TB_WS_TOWERS_DESTROYED_SHOW), int32(GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED)));
    packet.Worldstates.emplace_back(uint32(TB_WS_BUILDINGS_CAPTURED_SHOW), int32(IsWarTime() ? 1 : 0));
    packet.Worldstates.emplace_back(uint32(TB_WS_BUILDINGS_CAPTURED), int32(GetData(BATTLEFIELD_TB_DATA_BUILDINGS_CAPTURED)));
    packet.Worldstates.emplace_back(uint32(TB_WS_TOWERS_DESTROYED), int32(0));

    packet.Worldstates.emplace_back(uint32(TB_WS_TIME_BATTLE_END_SHOW), int32(IsWarTime() ? 1 : 0));

    packet.Worldstates.emplace_back(uint32(TB_WS_STATE_BATTLE), int32(IsWarTime() ? 1 : 0));
    packet.Worldstates.emplace_back(uint32(TB_WS_STATE_PREPARATIONS), int32(GetState() == BATTLEFIELD_WARMUP ? 1 : 0));

    // Not sure if TB
    //packet.Worldstates.emplace_back(uint32(TB_WS_35_UNKNOWN), int32(0));
    //packet.Worldstates.emplace_back(uint32(TB_WS_36_UNKNOWN), int32(0));
    //packet.Worldstates.emplace_back(uint32(TB_WS_37_UNKNOWN), int32(0));

    // Unused tower icons
    packet.Worldstates.emplace_back(uint32(TB_WS_WEST_DAMAGED_NEUTRAL), int32(0));
    packet.Worldstates.emplace_back(uint32(TB_WS_WEST_INTACT_NEUTRAL), int32(0));
    packet.Worldstates.emplace_back(uint32(TB_WS_EAST_DAMAGED_NEUTRAL), int32(0));
    packet.Worldstates.emplace_back(uint32(TB_WS_EAST_INTACT_NEUTRAL), int32(0));

    // Towers/spires
    for (uint8 i = 0; i < TB_TOWERS_COUNT; i++)
    {
        // Find gameobject
        for (ObjectGuid guid : Towers)
        {
            GameObject* tower = GetGameObject(guid);
            if (!tower || tower->GetEntry() != TBTowers[i].entry)
                continue;

            TeamId team = GetDefenderTeam(); // 0-false -> alliance; 1-true -> horde
            bool intact = tower->GetDestructibleState() == GO_DESTRUCTIBLE_INTACT;
            bool damaged = tower->GetDestructibleState() == GO_DESTRUCTIBLE_DAMAGED;
            bool destroyed = tower->GetDestructibleState() == GO_DESTRUCTIBLE_DESTROYED;

            packet.Worldstates.emplace_back(uint32(TBTowers[i].wsIntact[TEAM_ALLIANCE]), int32(!team && intact ? 1 : 0));
            packet.Worldstates.emplace_back(uint32(TBTowers[i].wsDamaged[TEAM_ALLIANCE]), int32(!team && damaged ? 1 : 0));
            packet.Worldstates.emplace_back(uint32(TBTowers[i].wsDestroyed), int32(destroyed ? 1 : 0));
            packet.Worldstates.emplace_back(uint32(TBTowers[i].wsDamaged[TEAM_HORDE]), int32(team && damaged ? 1 : 0));
            packet.Worldstates.emplace_back(uint32(TBTowers[i].wsIntact[TEAM_HORDE]), int32(team && intact ? 1 : 0));
        }
    }

    packet.Worldstates.emplace_back(uint32(TB_WS_TIME_NEXT_BATTLE_SHOW), int32(!IsWarTime() ? 1 : 0));

    packet.Worldstates.emplace_back(uint32(TB_WS_ALLIANCE_CONTROLS_SHOW), int32(!IsWarTime() && GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0));
    packet.Worldstates.emplace_back(uint32(TB_WS_HORDE_CONTROLS_SHOW), int32(!IsWarTime() && GetDefenderTeam() == TEAM_HORDE ? 1 : 0));

    packet.Worldstates.emplace_back(uint32(TB_WS_TIME_BATTLE_END), int32(IsWarTime() ? time(NULL) + (m_Timer / 1000) : 0));
    packet.Worldstates.emplace_back(uint32(TB_WS_TIME_NEXT_BATTLE), int32(!IsWarTime() ? time(NULL) + (m_Timer / 1000) : 0));

    // Not sure if TB
    //packet.Worldstates.emplace_back(uint32(TB_WS_65_UNKNOWN), int32(0));
    //packet.Worldstates.emplace_back(uint32(TB_WS_66_UNKNOWN), int32(0));

    packet.Worldstates.emplace_back(uint32(TB_WS_KEEP_ALLIANCE), int32(GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0));
    packet.Worldstates.emplace_back(uint32(TB_WS_KEEP_HORDE), int32(GetDefenderTeam() == TEAM_HORDE ? 1 : 0));
}
Exemplo n.º 24
0
bool ChatHandler::HandleGOInfo(const char *args, WorldSession *m_session)
{
	std::string name;
	GameObjectInfo *GOInfo = NULL;
	GameObject *GObj = NULL;

	GObj = m_session->GetPlayer()->m_GM_SelectedGO;
	if( !GObj )
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}

	switch( GObj->GetUInt32Value(GAMEOBJECT_TYPE_ID) )
	{
	case GAMEOBJECT_TYPE_DOOR:		  name = "Door";	break;
	case GAMEOBJECT_TYPE_BUTTON:		name = "Button";	break;
	case GAMEOBJECT_TYPE_QUESTGIVER:	name = "Quest Giver";	break;
	case GAMEOBJECT_TYPE_CHEST:		 name = "Chest";	break;
	case GAMEOBJECT_TYPE_BINDER:		name = "Binder";	break;
	case GAMEOBJECT_TYPE_GENERIC:	   name = "Generic";	break;
	case GAMEOBJECT_TYPE_TRAP:		  name = "Trap";	break;
	case GAMEOBJECT_TYPE_CHAIR:		 name = "Chair";	break;
	case GAMEOBJECT_TYPE_SPELL_FOCUS:   name = "Spell Focus";	break;
	case GAMEOBJECT_TYPE_TEXT:		  name = "Text";	break;
	case GAMEOBJECT_TYPE_GOOBER:		name = "Goober";	break;
	case GAMEOBJECT_TYPE_TRANSPORT:	 name = "Transport";	break;
	case GAMEOBJECT_TYPE_AREADAMAGE:	name = "Area Damage";	break;
	case GAMEOBJECT_TYPE_CAMERA:		name = "Camera";	break;
	case GAMEOBJECT_TYPE_MAP_OBJECT:	name = "Map Object";	break;
	case GAMEOBJECT_TYPE_MO_TRANSPORT:  name = "Mo Transport";	break;
	case GAMEOBJECT_TYPE_DUEL_ARBITER:  name = "Duel Arbiter";	break;
	case GAMEOBJECT_TYPE_FISHINGNODE:   name = "Fishing Node";	break;
	case GAMEOBJECT_TYPE_RITUAL:		name = "Ritual";	break;
	case GAMEOBJECT_TYPE_MAILBOX:	   name = "Mailbox";	break;
	case GAMEOBJECT_TYPE_AUCTIONHOUSE:  name = "Auction House";	break;
	case GAMEOBJECT_TYPE_GUARDPOST:	 name = "Guard Post";	break;
	case GAMEOBJECT_TYPE_SPELLCASTER:  name = "Spell Caster";	break;
	case GAMEOBJECT_TYPE_MEETINGSTONE:  name = "Meeting Stone";	break;
	case GAMEOBJECT_TYPE_FLAGSTAND:	 name = "Flag Stand";	break;
	case GAMEOBJECT_TYPE_FISHINGHOLE:   name = "Fishing Hole";	break;
	case GAMEOBJECT_TYPE_FLAGDROP:	  name = "Flag Drop";	break;
	default:							name = "Unknown type.";	break;
	}

	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.");
		return true;
	}
	else
	{
	BlueSystemMessage(m_session,"Informations:");
	GreenSystemMessage(m_session,"Entry:%s %d",MSG_COLOR_LIGHTBLUE, GObj->GetEntry());
	GreenSystemMessage(m_session,"Model:%s %d",MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_DISPLAYID));
	GreenSystemMessage(m_session,"State:%s %d",MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_STATE));
	GreenSystemMessage(m_session,"Flags:%s %d",MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_FLAGS));
	GreenSystemMessage(m_session,"DynFlags:%s %d",MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_DYN_FLAGS));
	GreenSystemMessage(m_session,"Faction:%s %d",MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_FACTION));
	GreenSystemMessage(m_session,"TypeID:%s %d",MSG_COLOR_LIGHTBLUE, GObj->GetUInt32Value(GAMEOBJECT_TYPE_ID));
	GreenSystemMessage(m_session,"Type:%s %s", MSG_COLOR_LIGHTBLUE, name.c_str());
	GreenSystemMessage(m_session," "); //force whitespace line :/
	GreenSystemMessage(m_session,"Distance:%s %d metres",MSG_COLOR_LIGHTBLUE, uint32(GObj->CalcDistance((Object*)m_session->GetPlayer()))); //brackets much :D
	GreenSystemMessage(m_session,"Name:%s %s",MSG_COLOR_LIGHTBLUE, GOInfo->Name);
	GreenSystemMessage(m_session,"Size:%s %f",MSG_COLOR_LIGHTBLUE, GObj->GetFloatValue(OBJECT_FIELD_SCALE_X));
	}
	return true;
}
Exemplo n.º 25
0
void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recv_data)
{
    ObjectGuid guid;

    recv_data >> guid;

    DEBUG_LOG("WORLD: Received opcode CMSG_GAMEOBJ_USE guid: %s", guid.GetString().c_str());

    // ignore for remote control state
    if (!_player->IsSelfMover())
        return;

    GameObject* obj = _player->GetMap()->GetGameObject(guid);
    if (!obj)
        return;

    if (!obj->IsWithinDistInMap(_player, obj->GetInteractionDistance()))
        return;

    // Additional check preventing exploits (ie loot despawned chests)
    if (!obj->IsSpawned())
    {
        sLog.outError("HandleGameObjectUseOpcode: CMSG_GAMEOBJ_USE for despawned GameObject (Entry %u), didn't expect this to happen.", obj->GetEntry());
        return;
    }

    // Never expect this opcode for some type GO's
    if (obj->GetGoType() == GAMEOBJECT_TYPE_GENERIC)
    {
        sLog.outError("HandleGameObjectUseOpcode: CMSG_GAMEOBJ_USE for not allowed GameObject type %u (Entry %u), didn't expect this to happen.", obj->GetGoType(), obj->GetEntry());
        return;
    }

    // Never expect this opcode for non intractable GO's
    if (obj->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT))
    {
        sLog.outError("HandleGameObjectUseOpcode: CMSG_GAMEOBJ_USE for GameObject (Entry %u) with non intractable flag (Flags %u), didn't expect this to happen.", obj->GetEntry(), obj->GetUInt32Value(GAMEOBJECT_FLAGS));
        return;
    }

    obj->Use(_player);
}
Exemplo n.º 26
0
bool ChatHandler::HandleGOEnable(const char* args, WorldSession* m_session)
{
	GameObject* GObj = m_session->GetPlayer()->GetSelectedGo();
	if(!GObj)
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}
	if(GObj->GetUInt32Value(GAMEOBJECT_DYNAMIC) == 1)
	{
		// Deactivate
		GObj->SetUInt32Value(GAMEOBJECT_DYNAMIC, 0);
		BlueSystemMessage(m_session, "Gameobject deactivated.");
	}
	else
	{
		// /Activate
		GObj->SetUInt32Value(GAMEOBJECT_DYNAMIC, 1);
		BlueSystemMessage(m_session, "Gameobject activated.");
	}
	sGMLog.writefromsession(m_session, "activated/deactivated gameobject %s, entry %u", GameObjectNameStorage.LookupEntry(GObj->GetEntry())->Name, GObj->GetEntry());
	return true;
}
Exemplo n.º 27
0
//Optional uiWithRestoreTime. If not defined, autoCloseTime will be used (if not 0 by default in *_template)
void ScriptedInstance::DoUseDoorOrButton(uint64 uiGuid, uint32 uiWithRestoreTime, bool bUseAlternativeState)
{
    if (!uiGuid)
        return;

    GameObject* pGo = instance->GetGameObject(uiGuid);

    if (pGo)
    {
        if (pGo->GetGoType() == GAMEOBJECT_TYPE_DOOR || pGo->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
        {
            if (pGo->getLootState() == GO_READY)
                pGo->UseDoorOrButton(uiWithRestoreTime,bUseAlternativeState);
            else if (pGo->getLootState() == GO_ACTIVATED)
                pGo->ResetDoorOrButton();
        }
        else
            error_log("SD2: Script call DoUseDoorOrButton, but gameobject entry %u is type %u.",pGo->GetEntry(),pGo->GetGoType());
    }
}
Exemplo n.º 28
0
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;
}
Exemplo n.º 29
0
GameObject* Transport::CreateGOPassenger(uint32 guid, GameObjectData const* data)
{
    Map* map = GetMap();
    GameObject* go = new GameObject();

    if (!go->LoadGameObjectFromDB(guid, map, false))
    {
        delete go;
        return NULL;
    }

    float x = data->posX;
    float y = data->posY;
    float z = data->posZ;
    float o = data->orientation;

    go->SetTransport(this);
    go->m_movementInfo.transport.guid = GetGUID();
    go->m_movementInfo.transport.pos.Relocate(x, y, z, o);
    CalculatePassengerPosition(x, y, z, &o);
    go->Relocate(x, y, z, o);

    if (!go->IsPositionValid())
    {
        TC_LOG_ERROR(LOG_FILTER_TRANSPORTS, "GameObject (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", go->GetGUIDLow(), go->GetEntry(), go->GetPositionX(), go->GetPositionY());
        delete go;
        return NULL;
    }

    if (!map->AddToMap(go))
    {
        delete go;
        return NULL;
    }

    _staticPassengers.insert(go);
    return go;
}
Exemplo n.º 30
0
void WorldSession::HandleMeetingStoneJoinOpcode(WorldPacket & recv_data)
{
	ObjectGuid guid;

	recv_data >> guid;

	DEBUG_LOG("WORLD: Recvd CMSG_MEETINGSTONE_JOIN Message guid: %s", guid.GetString().c_str());

	// ignore for remote control state
	if (!_player->IsSelfMover())
		return;

	GameObject *obj = GetPlayer()->GetMap()->GetGameObject(guid);
	if (!obj)
		return;

	// Never expect this opcode for some type GO's
	if (obj->GetGoType() != GAMEOBJECT_TYPE_MEETINGSTONE)
	{
		sLog.outError("HandleMeetingStoneJoinOpcode: CMSG_MEETINGSTONE_JOIN for not allowed GameObject type %u (Entry %u), didn't expect this to happen.", obj->GetGoType(), obj->GetEntry());
		return;
	}
	GameObjectInfo const *gInfo = ObjectMgr::GetGameObjectInfo(obj->GetEntry());

	if (Group *grp = _player->GetGroup())
	{
		if(!grp->IsLeader(_player->GetGUID()))
		{
			SendMeetingstoneFailed(MEETINGSTONE_FAIL_PARTYLEADER);

			obj->Use(_player);

			return;
		}

		if(grp->isRaidGroup())
		{
			SendMeetingstoneFailed(MEETINGSTONE_FAIL_RAID_GROUP);

			obj->Use(_player);
			return;
		}

		if(grp->IsFull())
		{
			SendMeetingstoneFailed(MEETINGSTONE_FAIL_FULL_GROUP);

			obj->Use(_player);
			return;
		}



	}


	SendMeetingstoneSetqueue(gInfo->meetingstone.areaID, MEETINGSTONE_STATUS_JOINED_QUEUE);

	if (Group *grp = _player->GetGroup())
	{
		AddGroupToQueue(grp->GetId(), gInfo->meetingstone.areaID);
	}
	else {

		AddPlayerToQueue(_player, gInfo->meetingstone.areaID);
	}

	LFGLoop();
	obj->Use(_player);
}