void MissionManager::missionFailedEntertainer(PlayerObject* player) { Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad)); if(datapad->hasMission()) //player has a mission { MissionList::iterator it = datapad->getMissions()->begin(); while(it != datapad->getMissions()->end()) { MissionObject* mission = dynamic_cast<MissionObject*>(*it); if(mission->getMissionType() == dancer || mission->getMissionType() == musician) { if(!mission->getInProgress()) { ++it; continue; } if(glm::distance(player->mPosition, mission->getDestination().Coordinates) < 20) { missionFailed(player,mission); it = datapad->removeMission(it); delete mission; return; } } ++it; } } }
void MissionManager::checkDancerMission(PlayerObject* player) { Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad)); if(datapad->hasMission()) //player has a mission { MissionList::iterator it = datapad->getMissions()->begin(); while(it != datapad->getMissions()->end()) { MissionObject* mission = dynamic_cast<MissionObject*>(*it); if(mission->getMissionType() == dancer) { if(mission->getInProgress()) { ++it; continue; } if(glm::distance(player->mPosition, mission->getDestination().Coordinates) < 20) { BuffAttribute* performance_timer = new BuffAttribute(Mission_Timer, 0,0,0); Buff* timer = Buff::SimpleBuff(player, player, 600000, 0, gWorldManager->GetCurrentGlobalTick()); timer->AddAttribute(performance_timer); player->AddBuff(timer); mission->setInProgress(true); } } ++it; } } return; }
bool MissionManager::checkCraftingMission(PlayerObject* player,NPCObject* npc) { Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad)); if(datapad->hasMission()) //player has a mission { MissionList::iterator it = datapad->getMissions()->begin(); while(it != datapad->getMissions()->end()) { MissionObject* mission = dynamic_cast<MissionObject*>(*it); if(mission->getMissionType() == crafting) { if(mission->getStartNPC() == npc) { //This is the start npc for the deliver mission char mp[10]; sprintf(mp,"m%dp",mission->getNum()); gMessageLib->sendSpatialChat(npc,player,L"",mission->getTitleFile(),mp); mission->setStartNPC(NULL); gMessageLib->sendSystemMessage(player,L"","mission/mission_generic","deliver_received_data"); MissionObject* updater = new MissionObject(); updater->clear(); updater->setId(mission->getId()); updater->getWaypoint()->setId(mission->getId()+1); 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); gMessageLib->sendMISO_Delta(updater,player); delete updater; return true; } else if(mission->getDestinationNPC() == npc && mission->getStartNPC() == NULL) { //This is the end npc for the deliver mission. char mr[10]; sprintf(mr,"m%dr",mission->getNum()); gMessageLib->sendSpatialChat(npc,player,L"",mission->getTitleFile(),mr); missionComplete(player,mission); mission->setDestinationNPC(NULL); it = datapad->removeMission(it); delete mission; return true; } } ++it; } } return false; }
void MissionManager::checkSurveyMission(PlayerObject* player,CurrentResource* resource,ResourceLocation highestDist) { Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad)); if(datapad->hasMission()) //player has a mission { MissionList::iterator it = datapad->getMissions()->begin(); while(it != datapad->getMissions()->end()) { MissionObject* mission = dynamic_cast<MissionObject*>(*it); if(mission->getMissionType() == survey) { if(mission->getTargetResource() == resource->getType()) { if(mission->getDifficulty() <= (highestDist.ratio*100)) { if(glm::distance(mission->getIssuingTerminal()->mPosition, highestDist.position) > 1024) { gLogger->logMsg("PE > 500: ready to apply new BF/wound dmg"); missionComplete(player,mission); it = datapad->removeMission(it); delete mission; return; } else { int8 sm[500]; sprintf(sm,"That resource pocket is too close (%"PRIu32" meters) to the mission giver to be useful to them. Go find one at least %"PRIu32" meters away to complete your survey mission. ", static_cast<uint32>(glm::distance(mission->getIssuingTerminal()->mPosition, highestDist.position)), (1024 - (int)glm::distance(mission->getIssuingTerminal()->mPosition, highestDist.position))); string s = BString(sm); s.convert(BSTRType_Unicode16); gMessageLib->sendSystemMessage(player,s); } } } } ++it; } } }
MissionObject* GroupManager::getZoneGroupMission(std::list<uint64>* members) { // we will iterate through all onZone groupmembers and compile a list of missions // we will find the mission nearest to the most players // and set the waypoints accordingly MissionObject* chosenMission = NULL; uint32 chosenRubberPoints = 0; if(!members->size()) return NULL; MissionGroupRangeList missionRangeList; //compile the missionlist Uint64List::iterator playerListIt = members->begin(); while(playerListIt != members->end()) { PlayerObject* groupMember = dynamic_cast<PlayerObject*> (gWorldManager->getObjectById((*playerListIt))); if(!groupMember) { playerListIt++; continue; } Datapad* datapad = dynamic_cast<Datapad*>(groupMember->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad)); MissionList* missionList = datapad->getMissions(); MissionList::iterator missionListIt = missionList->begin(); //add all Missions of the player to our List while(missionListIt != missionList->end()) { //the rubber point counter will be set to 0 initially missionRangeList.push_back(std::make_pair((*missionListIt),0)); missionListIt++; } playerListIt++; } //do we have missions in the first place ? if(!missionRangeList.size()) return NULL; //now iterate through all players and determine their nearest mission playerListIt = members->begin(); while(playerListIt != members->end()) { PlayerObject* groupMember = dynamic_cast<PlayerObject*> (gWorldManager->getObjectById((*playerListIt))); //now check for the nearest mission - increase its counter MissionGroupRangeList::iterator missionRangeListIt = missionRangeList.begin(); MissionGroupRangeList::iterator missionRangeListStorage = missionRangeList.begin(); while(missionRangeListIt != missionRangeList.end()) { MissionObject* nearestMission = NULL; float nearestDistance = 88000.0; MissionObject* currentMission = (*missionRangeListIt).first; float currentDistance = glm::distance(groupMember->mPosition, currentMission->getDestination().Coordinates); //store the nearest Mission if(currentDistance < nearestDistance) { nearestDistance = currentDistance; nearestMission = currentMission; //store the lists iterator for future reference missionRangeListStorage = missionRangeListIt; } missionRangeListIt++; } //now take the nearest Mission and give it a rubberpoint (*missionRangeListStorage).second++; //does our mission have enough rubberpoints? if((*missionRangeListStorage).second > (uint32)(members->size() /2)) { //jupp :) return (*missionRangeListStorage).first; } //remember the mission with the most rubberpoints anyway in case we dont have a clear winner if((*missionRangeListStorage).second > chosenRubberPoints) { chosenRubberPoints = (*missionRangeListStorage).second; chosenMission = (*missionRangeListStorage).first; } playerListIt++; } return chosenMission; }