/* * Player Accepted Mission */ void MissionManager::missionRequest(PlayerObject* player, uint64 mission_id) { Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad)); //Move the mission from the player's mission bag to his datapad. MissionBag* mission_bag = dynamic_cast<MissionBag*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_MissionBag)); MissionObject* mission = mission_bag->getMissionById(mission_id); if(mission == NULL) { gLogger->logMsgF("ERROR: Failed to retrieve mission with id %"PRIu64". Unable to accept mission!", MSG_HIGH, mission_id); return; } //automatically checks the datapads capacity if(!datapad->addMission(mission)) { gMessageLib->sendSystemMessage(player,L"","mission/mission_generic","too_many_missions"); return; } mission_bag->removeMission(mission); gMessageLib->sendContainmentMessage(mission->getId(), datapad->getId(), 0xffffffff, player); //Replace it with a new mission. mission_bag->spawnNAdd(); //Send MissionGenericResponse to tell the client its been accepted gMessageLib->sendMissionGenericResponse(mission,player); //Update the name and mission waypoint MissionObject* updater = new MissionObject(); updater->clear(); updater->setId(mission->getId()); updater->setNameFile(mission->getTitleFile().getRawData()); updater->setName(mission->getTitle().getRawData()); if(mission->getMissionType() != survey) { updater->getWaypoint()->setId(mission->getId()+1); if(mission->getMissionType() == deliver || mission->getMissionType() == crafting) { updater->getWaypoint()->setCoords(mission->getStart().Coordinates); updater->getWaypoint()->setPlanetCRC(mission->getStart().PlanetCRC); } else { updater->getWaypoint()->setCoords(mission->getDestination().Coordinates); updater->getWaypoint()->setPlanetCRC(mission->getDestination().PlanetCRC); } char name[150]; sprintf(name, "@%s:%s",mission->getTitleFile().getRawData(),mission->getTitle().getRawData()); updater->getWaypoint()->setName(name); updater->getWaypoint()->setActive(true); } else { gMessageLib->sendSystemMessage(player,L"","mission/mission_generic","survey_start"); } //Accept the mission let the player know gMessageLib->sendPlayMusicMessage(WMSound_Mission_Accepted,player); //3887, 'sound/music_mission_accepted.snd' gMessageLib->sendMISO_Delta(updater,player); mission->sendAttributes(mission->getOwner()); delete updater; if(mission->getMissionType() == recon) mission->setTaskId(gWorldManager->addMissionToProcess(mission)); //check if we need to inform our group if((mission->getMissionType() == destroy)&&(player->getGroupId() != 0)) { // we are in a group and just accepted a destroy mission // check the missions and update the nearest waypoint GroupObject* group = gGroupManager->getGroupObject(player->getGroupId()); gGroupManager->sendGroupMissionUpdate(group); } return; }
void ObjectController::_handleGetAttributesBatch(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties) { PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject); BString requestStr; BStringVector dataElements; BStringVector dataElements2; uint16 elementCount; message->getStringUnicode16(requestStr); requestStr.convert(BSTRType_ANSI); requestStr.getRawData()[requestStr.getLength()] = 0; elementCount = requestStr.split(dataElements,' '); if(!elementCount) { return; } Message* newMessage; for(uint16 i = 0; i < elementCount; i++) { uint64 itemId = boost::lexical_cast<uint64>(dataElements[i].getAnsi()); Object* object = gWorldManager->getObjectById(itemId); if(object == NULL) { // could be a resource Resource* resource = gResourceManager->getResourceById(itemId); if(resource != NULL) { resource->sendAttributes(playerObject); continue; } //could be a schematic! Datapad* datapad = playerObject->getDataPad(); ManufacturingSchematic* schem = datapad->getManufacturingSchematicById(itemId); if(schem != NULL) { schem->sendAttributes(playerObject); continue; } MissionObject* mission = datapad->getMissionById(itemId); if(mission != NULL) { mission->sendAttributes(playerObject); continue; } IntangibleObject* data = datapad->getDataById(itemId); if(data != NULL) { data->sendAttributes(playerObject); continue; } // TODO: check our datapad items if(playerObject->isConnected()) { // default reply for schematics gMessageFactory->StartMessage(); gMessageFactory->addUint32(opAttributeListMessage); gMessageFactory->addUint64(itemId); gMessageFactory->addUint32(0); //gMessageFactory->addUint16(0); //gMessageFactory->addUint32(40); newMessage = gMessageFactory->EndMessage(); (playerObject->getClient())->SendChannelAUnreliable(newMessage, playerObject->getAccountId(), CR_Client, 8); } //finally, when we are crafting this could be the new item, not yet added to the worldmanager?? if(playerObject->getCraftingSession()) { if(playerObject->getCraftingSession()->getItem()&&playerObject->getCraftingSession()->getItem()->getId() == itemId) { playerObject->getCraftingSession()->getItem()->sendAttributes(playerObject); } } } else { // Tutorial: I (Eru) have to do some hacks here, since I don't know how to get the info of what object the client has selected (by single click) in the Inventory. if (gWorldConfig->isTutorial()) { // Let's see if the actual object is the food item "Melon" in our inventory. if (dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getId() == object->getParentId()) { //uint64 id = object->getId(); // Is it an Item? Item* item = dynamic_cast<Item*>(object); // Check if this item is a food item. if (item) { if (item->getItemFamily() == ItemFamily_Foods) { playerObject->getTutorial()->tutorialResponse("foodSelected"); } } } } object->sendAttributes(playerObject); } } }