void ObjectController::_handleFindFriendDBReply(uint64 retCode,string friendName)
{
	PlayerObject*	player	= dynamic_cast<PlayerObject*>(mObject);
	friendName.convert(BSTRType_Unicode16);
	if(retCode == 0)
	{
		gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed_noname","","",L"",0,"","",friendName.getUnicode16());
		return;
	}

	PlayerObject*	searchObject	= dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(retCode));

	if(!searchObject)
	{
		gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed","","",L"",0,"","",friendName.getUnicode16());
		return;
	}

	//are we on our targets friendlist???
	if(!searchObject->checkFriendList(player->getFirstName().getCrc()))
	{
		gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed","","",L"",0,"","",friendName.getUnicode16());
		return;
	}

	Datapad* thePad = dynamic_cast<Datapad*>(searchObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));

	if(thePad && thePad->getCapacity())
	{
		//the datapad automatically checks for waypoint caspacity and gives the relevant error messages
		thePad->requestNewWaypoint(searchObject->getFirstName().getAnsi(),searchObject->mPosition,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
	}
}
Esempio n. 2
0
void ObjectController::_handleWaypoint(uint64 targetId, Message* message, ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	player			= dynamic_cast<PlayerObject*>(mObject);
    Datapad* datapad			= player->getDataPad();
    BString			waypoint_data;
    glm::vec3       waypoint_position;

    // Before anything else verify the datapad can hold another waypoint.
    if(! datapad->getCapacity()) {
        gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "too_many_waypoints"), player);
        return;
    }

    // Read in any waypoint data that may have been sent:
    //  [SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>
    message->getStringUnicode16(waypoint_data);

    // Check and see if any parameters were passed to the /waypoint command. For
    // immediate purposes the length can be used to tell if anything or nothing was passed.
    if (waypoint_data.getLength()) {
        int count = swscanf(waypoint_data.getUnicode16(), L"%f %f %f", &waypoint_position.x, &waypoint_position.y, &waypoint_position.z);

        // If there are an invalid number of items then disregard and notify the player of the correct
        // format for the /waypoint command.
        if (count < 2 || count > 3) {
            gMessageLib->SendSystemMessage(L"[SYNTAX] /waypoint <x> <z> or /waypoint <x> <y> <z>", player);
            return;
        }

        // If the item count is 2 it means no y value was set in the /waypoint command so
        // update the waypoint_position data values accordingly.
        if (count == 2) {
            waypoint_position.z = waypoint_position.y;
            waypoint_position.y = 0;
        }

        // Validate the position values.
        if (waypoint_position.x < -8192 || waypoint_position.x > 8192 ||
                waypoint_position.y < -500 || waypoint_position.y > 500 ||
                waypoint_position.z < -8192 || waypoint_position.z > 8192) {
            gMessageLib->SendSystemMessage( L"[SYNTAX] Invalid range for /waypoint. x = -8192/8192 y = -500/500 z = -8192/8192", player);
            return;
        }
    } else {
        // If no parameters were passed to the /waypoint command use the current world position.
        waypoint_position = player->getWorldPosition();
    }

    datapad->requestNewWaypoint("Waypoint", waypoint_position, static_cast<uint16>(gWorldManager->getZoneId()), Waypoint_blue);
}
Esempio n. 3
0
////=============================================================================
////
//// survey event
////
//
void ArtisanManager::surveyEvent(PlayerObject* player, CurrentResource* resource, SurveyTool* tool)
{
    if(tool && resource && player->isConnected())
    {
        Datapad* datapad					= player->getDataPad();
        ResourceLocation	highestDist		= gMessageLib->sendSurveyMessage(tool->getInternalAttribute<uint16>("survey_range"),tool->getInternalAttribute<uint16>("survey_points"),resource,player);

        // this is 0, if resource is not located
        if(highestDist.position.y == 5.0)
        {
			std::string name("Resource Survey");
			std::u16string name_u16(name.begin(), name.end());

            std::shared_ptr<WaypointObject>	waypoint = datapad->getWaypointByName(name_u16);

            // remove the old one
            if(waypoint)
            {
                datapad->updateWaypoint(waypoint->getId(), waypoint->getName(), glm::vec3(highestDist.position.x,0.0f,highestDist.position.z),
                                        static_cast<uint16>(gWorldManager->getZoneId()), player->getId(), WAYPOINT_ACTIVE);
            
            }
            else
            {
                // create a new one
                if(datapad->getCapacity())
                {
                    gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "survey_waypoint"), player);
                    //gMessageLib->sendSystemMessage(this,L"","survey","survey_waypoint");
                }
                //the datapad automatically checks if there is room and gives the relevant error message
				std::string name("Resource Survey");
				std::u16string name_u16(name.begin(), name.end());
                datapad->requestNewWaypoint(name_u16, glm::vec3(highestDist.position.x,0.0f,highestDist.position.z),static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
            }

            gMissionManager->checkSurveyMission(player,resource,highestDist);
        }
    }

    player->getSampleData()->mPendingSurvey = false;
}
Esempio n. 4
0
void GroupManager::sendGroupMissionUpdate(GroupObject* group)
{
	// this procedure ensures, that in case of a change in the mission pool of the group
	// all players get updated Mission waypoints
	// it concerns all players of the group on the zone, but not on other zones


	//get us the mission nearest to the most players on the Zone
	MissionObject* mission = getZoneGroupMission(group->getPlayerList());

	if(!mission)
		return;

	//now set the GroupWaypoint for all onZone groupmembers
	Uint64List::iterator playerListIt = group->getPlayerList()->begin();
	while(playerListIt != group->getPlayerList()->end())
	{
		PlayerObject*	player		= dynamic_cast<PlayerObject*> (gWorldManager->getObjectById((*playerListIt)));
		Datapad*		datapad		= dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
		WaypointObject*	waypoint	= datapad->getWaypointByName("@group:groupwaypoint");

		// remove the old one
		if(waypoint)
		{
			gMessageLib->sendUpdateWaypoint(waypoint,ObjectUpdateAdd,player);
			datapad->removeWaypoint(waypoint);
			gObjectFactory->deleteObjectFromDB(waypoint);

		}
		else
		// create a new one
		if(datapad->getCapacity())
		{
			datapad->requestNewWaypoint("@group:groupwaypoint",mission->getDestination().Coordinates,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
			gMessageLib->sendSystemMessage(player,L"","group","groupwaypoint");
		}

		
		playerListIt++;
	}
}
Esempio n. 5
0
void Deed::handleObjectMenuSelect(uint8 messageType,Object* srcObject)
{
	if(PlayerObject* player = dynamic_cast<PlayerObject*>(srcObject))
	{
		switch(messageType)
		{
			case radId_itemUse:
			{
				if(this->getItemType() >= ItemType_Deed_X34 && this->getItemType() <= ItemType_Deed_Swoop) //landspeeder x34, speederbike, swoop
				{
					// create the vehicle and put in datapad
					Datapad*		datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));

					if(datapad->getCapacity())
					{
						gVehicleFactory->createVehicle(this->getItemType(),player);

						Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
						inventory->removeObject(this);
						gMessageLib->sendDestroyObject(this->getId(),player);
						gObjectFactory->deleteObjectFromDB(this);
						gWorldManager->destroyObject(this);
					}
					else
					{
						gMessageLib->sendSystemMessage(player,L"Error datapad at max capacity. Couldn't create the vehicle.");
					}
				}
				else
				{
					//enter deed placement mode
					StructureDeedLink* data = gStructureManager->getDeedData(this->getItemType());
					if(!data)
					{
						return;
					}
					if(player->getParentId())
					{
						gMessageLib->sendSystemMessage(player,L"","player_structure","not_inside");
						return;
					}

					//check available Lots and remove ... grml
					if(!player->useLots(data->requiredLots))
					{
						gMessageLib->sendSystemMessage(player, L"","player_structure","not_enough_lots","","",L"",data->requiredLots);
						return;
					}

					//TODO
					//check for city boundaries
					
					//check if were allowed to build that structure on this planet
					if((data->placementMask&gWorldManager->getZoneId()) == gWorldManager->getZoneId())
					{
						//sadly the client wont inform us when the player hit escape
						gMessageLib->sendEnterStructurePlacement(this,data->structureObjectString,player);
						gStructureManager->UpdateCharacterLots(player->getId());
					}
					else
					{
						//we cannot differ whether its a no build planet
						//or just the house type isnt permitted here
						//wrong_planet 
						//not_permitted
						gMessageLib->sendSystemMessage(player, L"","player_structure","wrong_planet","","",L"",data->requiredLots);
						gStructureManager->UpdateCharacterLots(player->getId());
						return;
					}

				}
			}
			break;
			default: break;
		}


	}
}
Esempio n. 6
0
void Deed::handleObjectMenuSelect(uint8 messageType,Object* srcObject)
{
    if(PlayerObject* player = dynamic_cast<PlayerObject*>(srcObject))
    {
        switch(messageType)
        {
        case radId_itemUse:
        {

            if(this->getItemType() >= ItemType_Deed_X34 && this->getItemType() <= ItemType_Deed_Swoop) //landspeeder x34, speederbike, swoop
            {
                // create the vehicle and put in datapad
                Datapad*		datapad = player->getDataPad();

                if(datapad->getCapacity())
                {
                    gVehicleControllerFactory->createVehicle(this->getItemType(),player);

                    //parent container can be every backpack / inventory / cell // chest
                    //cave - we shouldnt be able to use it in a cell otherwise we need to think about sending updates to all players watching

                    ObjectContainer* parentContainer = dynamic_cast<ObjectContainer*>(gWorldManager->getObjectById(this->getParentId()));
                    if(!parentContainer)
                    {
                        gLogger->log(LogManager::DEBUG,"Deed::handleObjectMenuSelect: couldnt cast deeds parent %I64u !",this->getParentId());
                        return;
                    }
                    parentContainer->removeObject(this);

                    //cave if were in a cell or it is an opened container we need to identify all onlookers and update them
                    gMessageLib->sendDestroyObject(this->getId(),player);
                    gObjectFactory->deleteObjectFromDB(this);
                    gWorldManager->destroyObject(this);
                }
                else
                {
                    gMessageLib->SendSystemMessage(L"Error datapad at max capacity. Couldn't create the vehicle.", player);
                }
            }
            else
            {
                unsigned int itemType = this->getItemType();

                //Is it a city hall?
                if(itemType ==  1566 ||itemType == 1567 || itemType == 1568)
                {
                    if(PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(this->getOwner())))
                    {
                        if(!player->checkSkill(623)) // Must be a novice Politician
                        {
                            gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "place_cityhall"), player);
                            return;
                        }
                    }
                }

                //check the region whether were allowed to build
                if(gStructureManager->checkNoBuildRegion(player))
                {
                    return;
                }

                //enter deed placement mode
                StructureDeedLink* data = gStructureManager->getDeedData(this->getItemType());
                if(!data)
                {
                    return;
                }
                if(player->getParentId())
                {
                    gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "not_inside"), player);
                    return;
                }

                //check available Lots and remove ... grml
                if(!player->useLots(data->requiredLots))
                {
                    gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "not_enough_lots", 0, 0, 0, data->requiredLots, 0.0f), player);
                    return;
                }

                //TODO
                //check for city boundaries

                //check if were allowed to build that structure on this planet

                uint64 zoneId = (uint64)pow(2.0,(int)gWorldManager->getZoneId());
                uint64 mask = data->placementMask;
                if((mask&zoneId) == zoneId)
                {
                    //sadly the client wont inform us when the player hit escape
                    gMessageLib->sendEnterStructurePlacement(this,data->structureObjectString,player);
                    gStructureManager->UpdateCharacterLots(player->getId());
                }
                else
                {
                    //we cannot differ whether its a no build planet
                    //or just the house type isnt permitted here
                    //wrong_planet
                    //not_permitted
                    gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "wrong_planet", 0, 0, 0, data->requiredLots, 0.0f), player);
                    gStructureManager->UpdateCharacterLots(player->getId());
                    return;
                }

            }
        }
        break;
        default:
            break;
        }


    }
}