void SurveyTool::_createRangeMenu(PlayerObject* playerObject, bool sample) { int32 surveyMod = playerObject->getSkillModValue(SMod_surveying); BStringVector availableRanges; availableRanges.push_back("64m x 3pts"); if(surveyMod >= 35) availableRanges.push_back("128m x 4pts"); if(surveyMod >= 55) availableRanges.push_back("192m x 4pts"); if(surveyMod >= 75) availableRanges.push_back("256m x 5pts"); if(surveyMod >= 100) availableRanges.push_back("320m x 5pts"); if(!sample) mSampleAfterSet = false; else mSampleAfterSet = true; gUIManager->createNewListBox(this,"handleSetRange","Survey Device","@survey:select_range",availableRanges,playerObject); }
//====================================================================================================================== void UIManager::createNewDiagnoseListBox(UICallback* callback,PlayerObject* Medic, PlayerObject* Patient) { BStringVector attributesMenu; BString FirstName = Patient->getFirstName(); FirstName.toUpper(); BString LastName = Patient->getLastName(); LastName.toUpper(); int8 title[64]; sprintf(title,"PATIENT %s %s'S WOUNDS",FirstName.getAnsi(), LastName.getAnsi()); int8 desc[512]; sprintf(desc, "Below is a listing of the Wound and Battle Fatigue levels of %s %s. Wounds are healed through /tendWound or use of Wound Medpacks. High levels of Battle Fatigue can inhibit the healing process, and Battle Fatigue can only be healed by the patient choosing to watch performing entertainers",Patient->getFirstName().getAnsi(), Patient->getLastName().getAnsi()); int8 Health[32]; sprintf(Health,"Health -- %i",Patient->getHam()->mHealth.getWounds()); attributesMenu.push_back(Health); int8 Strength[32]; sprintf(Strength,"Strength -- %i",Patient->getHam()->mStrength.getWounds()); attributesMenu.push_back(Strength); int8 Constitution[32]; sprintf(Constitution,"Constitution -- %i",Patient->getHam()->mConstitution.getWounds()); attributesMenu.push_back(Constitution); int8 Action[32]; sprintf(Action,"Action -- %i",Patient->getHam()->mAction.getWounds()); attributesMenu.push_back(Action); int8 Quickness[32]; sprintf(Quickness,"Quickness -- %i",Patient->getHam()->mQuickness.getWounds()); attributesMenu.push_back(Quickness); int8 Stamina[32]; sprintf(Stamina,"Stamina -- %i",Patient->getHam()->mStamina.getWounds()); attributesMenu.push_back(Stamina); int8 Mind[32]; sprintf(Mind,"Mind -- %i",Patient->getHam()->mMind.getWounds()); attributesMenu.push_back(Mind); int8 Focus[32]; sprintf(Focus,"Focus -- %i",Patient->getHam()->mFocus.getWounds()); attributesMenu.push_back(Focus); int8 Willpower[32]; sprintf(Willpower,"Willpower -- %i",Patient->getHam()->mWillpower.getWounds()); attributesMenu.push_back(Willpower); int8 BattleFatigue[32]; sprintf(BattleFatigue,"Battle Fatigue -- %i",Patient->getHam()->getBattleFatigue()); attributesMenu.push_back(BattleFatigue); createNewListBox(callback,"handleDiagnoseMenu",title, desc, attributesMenu, Medic, SUI_Window_ListBox,SUI_LB_OK,Patient->getId()); }
void GroupManager::_processIsmGroupLootMasterResponse(Message* message) { gLogger->logMsg("_processIsmGroupLootMasterResponse"); PlayerObject* playerObject = gWorldManager->getPlayerByAccId(message->getUint32()); // the player whos group_id has changed if(playerObject == NULL) { gLogger->logMsg("GroupManager::_processIsmGroupLootMasterResponse PlayerAccId not found"); return; } //send the SUI gLogger->logMsg("ok\n"); PlayerList inRangeMembers = playerObject->getInRangeGroupMembers(true); PlayerList::iterator it = inRangeMembers.begin(); BStringVector namesArray; while(it != inRangeMembers.end()) { namesArray.push_back((*it)->getFirstName().getAnsi()); ++it; } gUIManager->createNewPlayerSelectListBox(playerObject,"handleSetLootMaster","@group:master_looter_sui_title","@group:set_loot_type_text",namesArray,inRangeMembers,playerObject); }
void TicketCollector::_createTicketSelectMenu(PlayerObject* playerObject) { BStringVector availableTickets; uint32 zoneId = gWorldManager->getZoneId(); ObjectIDList* invObjects = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getObjects(); ObjectIDList::iterator it = invObjects->begin(); while(it != invObjects->end()) { if(TravelTicket* ticket = dynamic_cast<TravelTicket*>(gWorldManager->getObjectById((*it)))) { BString srcPoint = (int8*)((ticket->getAttribute<std::string>("travel_departure_point")).c_str()); uint16 srcPlanetId = static_cast<uint16>(gWorldManager->getPlanetIdByName((int8*)((ticket->getAttribute<std::string>("travel_departure_planet")).c_str()))); if(srcPlanetId == zoneId && strcmp(srcPoint.getAnsi(),mPortDescriptor.getAnsi()) == 0) { BString dstPoint = (int8*)((ticket->getAttribute<std::string>("travel_arrival_point")).c_str()); availableTickets.push_back(dstPoint.getAnsi()); } } ++it; } gUIManager->createNewListBox(this,"handleticketselect","select destination","Select destination",availableTickets,playerObject); }
bool ArtisanManager::setupSampleEvent(PlayerObject* player, CurrentResource* resource, SurveyTool* tool) { //EVENT WINDOW CASE int32 eventRoll = int(gRandom->getRand()%2)+1; //eventRoll = 2; //do event 1 or event 2 based on roll if(eventRoll == 1) { // setup gamble event //GAMBLE Event WindowAsyncContainerCommand* asyncContainer = new WindowAsyncContainerCommand(Window_Query_Radioactive_Sample); asyncContainer->PlayerId = player->getId(); asyncContainer->ToolId = tool->getId(); asyncContainer->CurrentResource = resource; BStringVector items; items.push_back("Ignore the concentration and continue working."); items.push_back("Attempt to recover the resources. (300 Action)"); gUIManager->createNewListBox(this,"gambleSample","@survey:gnode_t","@survey:gnode_d",items,player,SUI_Window_SmplGamble_ListBox,SUI_LB_OKCANCEL,0,0,asyncContainer); player->getSampleData()->mPendingSample = false; return true; } else { WindowAsyncContainerCommand* asyncContainer = new WindowAsyncContainerCommand(Window_Query_Radioactive_Sample); asyncContainer->PlayerId = player->getId(); asyncContainer->ToolId = tool->getId(); asyncContainer->CurrentResource = resource; //WAYP CONCENTRATION BStringVector items; items.push_back("Ignore the concentration and continue working."); items.push_back("Focus the device on the concentration"); gUIManager->createNewListBox(this,"waypNodeSample","@survey:cnode_t","@survey:cnode_d",items,player,SUI_Window_SmplWaypNode_ListBox,SUI_LB_OKCANCEL,0,0,asyncContainer); //Pause sampling player->getSampleData()->mPendingSample = false; player->getSampleData()->mSampleEventFlag = true; return true; } return false; }
void GroupManager::_processIsmGroupLootModeResponse(Message* message) { gLogger->logMsg("_processIsmGroupLootModeResponse"); PlayerObject* playerObject = gWorldManager->getPlayerByAccId(message->getUint32()); // the player whos group_id has changed if(playerObject == NULL) { gLogger->logMsg("GroupManager::processIsmGroupLootModeResponse PlayerAccId not found"); return; } //send the SUI BStringVector availableLootModes; availableLootModes.push_back("Free for all"); availableLootModes.push_back("Master Looter"); availableLootModes.push_back("Lottery"); availableLootModes.push_back("Random"); gUIManager->createNewListBox(playerObject,"handleSetLootMode","@group:set_loot_type_title","@group:set_loot_type_text",availableLootModes,playerObject,SUI_Window_SelectGroupLootMode_Listbox); }
bool Trainer::preProcessfilterConversation(ActiveConversation* av,Conversation* conversation,PlayerObject* player) { bool continueConversation = true; ConversationPage *page = conversation->getPage(2); // Page 2 is where WE have the interesting skill-options to check. // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: page->mId = %u",page->mId); setLastConversationTarget(player->getId()); std::vector<ConversationOption*>::iterator optionIt = page->mOptions.begin(); switch(page->mId) { // Lets see if we have the requriments met by this trainer. case 2: { bool noviceSkill = false; bool gotAllSkills = true; // As long as we have not detected any missing skills. uint32 skillsToLearn = 0; BStringVector skillsRequired; bool gotRequirementsForSomeSkill = false; while (optionIt != page->mOptions.end()) { Skill* skill = gSkillManager->getSkillByName((*optionIt)->mStfVariable); // requirementsMet = false; // its no skill option if (!skill) { // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: Its no skill option"); } // see if we have it already and check xp // Note: We do not handle lack of SP as an error now... that's done later in this chain of events. else if (player->checkSkill(skill->mId)) { // We already have this skill. // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: We already have this skill"); } else if (!skill->mSkillsRequired.size()) { // No skill requirements, we got a "Novice" skill from a basic profession. // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: Novice"); skillsToLearn++; gotAllSkills = false; // Do not have all skills if we end up here. noviceSkill = true; } else { // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: Do not have all skills if we end up here"); gotAllSkills = false; // Do not have all skills if we end up here. // see if we got the required skills SkillsRequiredList::iterator reqSkillIt = skill->mSkillsRequired.begin(); bool requirementsMet = true; skillsToLearn++; int8 str[128]; while (reqSkillIt != skill->mSkillsRequired.end()) { if (!player->checkSkill(*reqSkillIt)) { // we don't have the requirements // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: We don't have the requirements"); requirementsMet = false; // We should only add requirements for Novice skills (and then only for Elite Professions). if (strstr(gSkillManager->getSkillById(skill->mId)->mName.getAnsi(),"novice")) { // add it to our list sprintf(str,"@%s:%s","skl_n", gSkillManager->getSkillById(*reqSkillIt)->mName.getAnsi()); // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Skills missing = %u %s", *reqSkillIt, gSkillManager->getSkillById(*reqSkillIt)->mName.getAnsi()); skillsRequired.push_back(str); } else { break; } } ++reqSkillIt; } if (requirementsMet) { // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: We DO have the requirements, check if we have the xp for next level"); gotRequirementsForSomeSkill = true; // We DO have the requirements, check if we have the xp for next level. if (player->getXpAmount(skill->mXpType) < skill->mXpCost) { // We do not have enough of XP for training this skill. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Missing XP"); skillsToLearn--; } } else { skillsToLearn--; } } ++optionIt; } // Now we must return status of this session. if (skillsToLearn == 0) { // Either we have them all, i.e. we are a Master, or we lack xp for training OR we lack the required skills to train it. if (gotAllSkills) { // We are a Master! // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: We are a Master!"); if (!gWorldConfig->isInstance()) { gMessageLib->sendCreatureAnimation(av->getNpc(),gWorldManager->getNpcConverseAnimation(16)); // giveup } else { gMessageLib->sendCreatureAnimation(av->getNpc(),gWorldManager->getNpcConverseAnimation(16), player); // giveup } OutOfBand prose("skill_teacher", "topped_out"); if (!gWorldConfig->isInstance()) { gMessageLib->SendSpatialChat(this, prose); } else { gMessageLib->SendSpatialChat(this, prose, player); } continueConversation = false; } else if (gotRequirementsForSomeSkill) { // We lack xp for training. // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: We lack xp for training"); } else { // We do not have requirements for any skill, sounds like we are attempting an elite trainers novice skill. // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: sounds like we are attempting an elite trainers novice skill"); // createNewMessageBox(UICallback* callback,const int8* eventStr,const int8* caption,const int8* text,PlayerObject* playerObject,ui_window_types windowType = SUI_Window_MessageBox,uint8 mbType = SUI_MB_OK); // gUIManager->createNewMessageBox(NULL,"no_qualify_title","@skill_teacher:no_qualify_title","@skill_teacher:no_qualify_prompt",player,SUI_Window_MessageBox, SUI_MB_OK); // BStringVector skillsRequired; // add it to our list // int8 str[128]; // sprintf(str,"@%s:%s","cmd_n",gSkillManager->getSkillCmdById(*dancerIt).getAnsi()); // sprintf(str,"@skl_n:crafting_artisan_engineering_04"); // skillsRequired.push_back(str); if (!gWorldConfig->isInstance()) { gMessageLib->sendCreatureAnimation(av->getNpc(),gWorldManager->getNpcConverseAnimation(27)); // poke } else { gMessageLib->sendCreatureAnimation(av->getNpc(),gWorldManager->getNpcConverseAnimation(27), player); // poke } OutOfBand prose("skill_teacher", "no_qualify"); if (!gWorldConfig->isInstance()) { gMessageLib->SendSpatialChat(this, prose); } else { gMessageLib->SendSpatialChat(this, prose, player); } gUIManager->createNewListBox(NULL,"","@skill_teacher:no_qualify_title","@skill_teacher:no_qualify_prompt",skillsRequired,player); continueConversation = false; } } else { if (noviceSkill) // avaliableSkills should be 1 { if (gWorldConfig->isTutorial()) { // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: We train to Novice."); // Not implemented yet. Special handling for the Space Station Tutorial Only. } } else { // Let's select a skill to train. This is the default path. // retLinkPage = 0; // Use caller default linkPage. // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: We have some skills to train."); } } } break; default: { // gLogger->log(LogManager::DEBUG,"Trainer::preProcessfilterConversation: Default, bad page input"); } break; } return continueConversation; }
// Return pageLink for next conversation. uint32 Trainer::handleConversationEvent(ActiveConversation* av,ConversationPage* page,ConversationOption* option,PlayerObject* player) { // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: page->mId = %u",page->mId); std::vector<ConversationOption*>::iterator optionIt = page->mOptions.begin(); uint32 pageLink = page->mId; switch(page->mId) { // Select currently learnable skills case 2: { mPlayerGotRequirementsForMasterSkill = false; bool noviceSkill = false; bool gotAllSkills = true; // As long as we have not detected any missing skills. bool gotRequirementsForSomeSkill = false; uint32 skillsToLearn = 0; uint32 numberOfSkills = 0; uint32 knownSkills = 0; // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Currently learnable skills (case 2)"); while (optionIt != page->mOptions.end()) { Skill* skill = gSkillManager->getSkillByName((*optionIt)->mStfVariable); numberOfSkills++; // its no skill option if (!skill) { numberOfSkills--; // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Its no skill option"); } // see if we have it already and check xp // Note: We do not handle lack of SP as an error now... that's done later in this chain of events. else if (player->checkSkill(skill->mId)) { // We already have this skill. knownSkills++; // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: We already have this skill"); } else if (!skill->mSkillsRequired.size()) { // No skill requirements, we got a "Novice" skill from a basic profession. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Novice"); skillsToLearn++; gotAllSkills = false; // Do not have all skills if we end up here. noviceSkill = true; } else { // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Do not have all skills if we end up here"); gotAllSkills = false; // Do not have all skills if we end up here. // see if we got the required skills SkillsRequiredList::iterator reqSkillIt = skill->mSkillsRequired.begin(); bool requirementsMet = true; skillsToLearn++; while (reqSkillIt != skill->mSkillsRequired.end()) { if (!player->checkSkill(*reqSkillIt)) { // we don't have the requirements // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: We don't have the requirements"); requirementsMet = false; break; } ++reqSkillIt; } if (requirementsMet) { // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: We DO have the requirements, check if we have the xp for next level"); gotRequirementsForSomeSkill = true; // We DO have the requirements, check if we have the xp for next level. if (player->getXpAmount(skill->mXpType) < skill->mXpCost) { // We do not have enough of XP for training this skill. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Missing XP"); skillsToLearn--; } } else { skillsToLearn--; } } ++optionIt; } // Now we must return status of this session. if (skillsToLearn == 0) { // Either we have them all, i.e. we are a Master, or we lack xp for training OR we lack the required skills to train it. if (gotAllSkills) { // We are a Master! // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: We are a Master!"); pageLink = 9; } else if (gotRequirementsForSomeSkill) { // We lack xp for training. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: We lack xp for training"); pageLink = 8; } else { // This is not a valid state any more. // We do not have requirements for any skill, sounds like we are attempting an elite trainers novice skill. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: ERROR: Sounds like we are attempting an elite trainers novice skill"); pageLink = 12; } } else { if (noviceSkill) // avaliableSkills should be 1 { // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: We train to Novice."); // Not implemented yet. Special handling for the Space Station Tutorial Only. } else { if ((knownSkills + 1) == numberOfSkills) { // We have all skills except the last one, we are going for a Master skill... mPlayerGotRequirementsForMasterSkill = true; } // Let's select a skill to train. This is the default path. // retLinkPage = 0; // Use caller default linkPage. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Default, we have some skills to train."); } } } break; // Skill is selected. case 3: { // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Skill selected"); bool failed = true; Skill* skill = gSkillManager->getSkillByName(av->getTOStfVariable()); // its no skill option if (!skill) { // This is a system error. DLOG(INFO) << "Trainer::conversationEvent: ERROR: It's no skill option"; } // no skill requirements, Novice Skills have no requirements. /* else if (!skill->mSkillsRequired.size()) { // This is a system error. gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: ERROR: No skill requirements"); break; } */ else if(player->checkSkill(skill->mId)) { // This is a system failure. DLOG(INFO) << "Trainer::conversationEvent: ERROR: Player already have the skill"; } else if (player->getXpAmount(skill->mXpType) < skill->mXpCost) { // This is a system failure. DLOG(INFO) << "Trainer::conversationEvent: ERROR: Player need "<<player->getXpAmount(skill->mXpType)<<" XP, but only have "<< skill->mXpCost; } // see if we got the required skills else { SkillsRequiredList::iterator reqSkillIt = skill->mSkillsRequired.begin(); failed = false; while(reqSkillIt != skill->mSkillsRequired.end()) { // we don't have the requirements if (!player->checkSkill(*reqSkillIt)) { // This is a system failure. failed = true; break; } ++reqSkillIt; } } if (failed) { // This is a system failure. gMessageLib->SendSystemMessage(::common::OutOfBand("teaching", "learning_failed"), player); pageLink = 0; break; } // Here we start the non-fatal error processing. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Start the non-fatal error processing"); if (player->getSkillPointsLeft() < skill->mSkillPointsRequired) { // Player lack skillpoints for training this skill. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Player need %u skillpoints, but only have %u",skill->mSkillPointsRequired, player->getSkillPointsLeft()); pageLink = 10; // pageLink for this condition. break; } if (gWorldConfig->isTutorial()) { // We do not charge any cost for training in the Tutorial. pageLink = 15; } else if ((dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getCredits() < av->getDI()) && (dynamic_cast<Bank*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank))->getCredits() < av->getDI()) ) { // Player lack credits in both inventory and bank. pageLink = 11; // pageLink for this situation. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Player needs %u credits, but only have %u as cash", av->getDI(), // dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getCredits()); // System message: You lack the %DI credits required for training in %TO. gMessageLib->SendSystemMessage(::common::OutOfBand("skill_teacher", "prose_nsf", "", "", "", "", av->getTOStfFile().getAnsi(), av->getTOStfVariable().getAnsi(), av->getDI()), player); break; } else { // Let's start credit transaction for this skill... // Do that in next state... } } break; // View info about skills case 4: { bool noviceSkill = false; bool gotAllSkills = true; // As long as we have not detected any missing skills. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: View info about skills"); while(optionIt != page->mOptions.end()) { Skill* skill = gSkillManager->getSkillByName((*optionIt)->mStfVariable); // its no skill option if (skill && ! player->checkSkill(skill->mId)) { // If we end up here, we have at least some skill to train. gotAllSkills = false; // no skill requirements if (!skill->mSkillsRequired.size()) { // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Novice"); noviceSkill = true; } // see if we got the required skills else { SkillsRequiredList::iterator reqSkillIt = skill->mSkillsRequired.begin(); while(reqSkillIt != skill->mSkillsRequired.end()) { // we don't have the requirements if(!player->checkSkill(*reqSkillIt)) { break; } ++reqSkillIt; } } } ++optionIt; } // Now we must return status of this session. // We have them all, i.e. we are a Master. if (gotAllSkills) { // We are a Master! // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: We are a Master!"); pageLink = 9; } else { if (noviceSkill) // avaliableSkills should be 1 { // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: We train to Novice."); // Not implemented yet. Special handling for the Space Station Tutorial Only. } else { // Let's select a skill to train. This is the default path. // retLinkPage = 0; // Use caller default linkPage. // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Default, we have some skills to train."); } } } break; // Train the skill case 5: { bool failed = true; // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Learn request"); Skill* skill = gSkillManager->getSkillByName(av->getTOStfVariable()); // its no skill option if (!skill) { // This is a system error. } else if(player->checkSkill(skill->mId)) { // This is a system failure. } else if (player->getXpAmount(skill->mXpType) < skill->mXpCost) { // This is a system failure. } // see if we got the required skills else { failed = false; SkillsRequiredList::iterator reqSkillIt = skill->mSkillsRequired.begin(); while(reqSkillIt != skill->mSkillsRequired.end()) { // We don't have the requirements if (!player->checkSkill(*reqSkillIt)) { // This is a system failure. failed = true; break; } ++reqSkillIt; } } if (!failed) { // Let's train this skill... // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Processing %DI credit payment for %TO training."); gMessageLib->SendSystemMessage(::common::OutOfBand("skill_teacher", "prose_pay", "", "", "", "", av->getTOStfFile().getAnsi(), av->getTOStfVariable().getAnsi(), av->getDI()), player); // if (strstr(skill->mName.getAnsi(),"master")) if (mPlayerGotRequirementsForMasterSkill) { // We are going to train to Master... // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: We are going to train to Master..."); // postProcessfilter(av, page, player, 13); postProcessfilter(av, player, 13); pageLink = 0; // Terminate conversation } if (!(dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->updateCredits(-skill->mMoneyRequired))) { if (!(dynamic_cast<Bank*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank))->updateCredits(-skill->mMoneyRequired))) { // This is a system error. gMessageLib->SendSystemMessage(::common::OutOfBand("skill_teacher", "prose_nsf"), player); pageLink = 0; } } } else { // This is a system error. gMessageLib->SendSystemMessage(::common::OutOfBand("teaching", "learning_failed"), player); // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Error verifying credits"); pageLink = 0; } } break; // Train the skill in the Tutorial // NOTE: This case is never called, not even from Tutorial. case 15: { bool failed = true; // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Learn request"); Skill* skill = gSkillManager->getSkillByName(av->getTOStfVariable()); // its no skill option if (!skill) { // This is a system error. } // no skill requirements, Novice Skills have no requirements. else if(player->checkSkill(skill->mId)) { // This is a system failure. } else if (player->getXpAmount(skill->mXpType) < skill->mXpCost) { // This is a system failure. } // see if we got the required skills else { failed = false; SkillsRequiredList::iterator reqSkillIt = skill->mSkillsRequired.begin(); while(reqSkillIt != skill->mSkillsRequired.end()) { // We don't have the requirements if (!player->checkSkill(*reqSkillIt)) { // This is a system failure. failed = true; break; } ++reqSkillIt; } } if (!failed) { // We do not charge any cost for training in the Tutorial. } else { // This is a system error. gMessageLib->SendSystemMessage(::common::OutOfBand("teaching", "learning_failed"), player); // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Error verifying credits"); pageLink = 0; } } break; case 7: { // Selected more info about this skill. Skill* skill = gSkillManager->getSkillByName(av->getTOStfVariable()); if (skill) { int8 str[800]; BStringVector populatedListBox; int8 strCaption[128]; sprintf(strCaption,"@%s:%s","skl_n", skill->mName.getAnsi()); sprintf(str,"MONETARY COST"); populatedListBox.push_back(str); if (gWorldConfig->isTutorial() && (!skill->mSkillsRequired.size())) { sprintf(str,"%u credits", 0); } else { sprintf(str,"%u credits", skill->mMoneyRequired); } populatedListBox.push_back(str); sprintf(str,"SKILL POINT COST"); populatedListBox.push_back(str); sprintf(str,"%u points", skill->mSkillPointsRequired); populatedListBox.push_back(str); sprintf(str,"REQUIRED SKILLS"); populatedListBox.push_back(str); SkillsRequiredList::iterator reqSkillIt = skill->mSkillsRequired.begin(); while (reqSkillIt != skill->mSkillsRequired.end()) { // Add all skills required. // if (!player->checkSkill(*reqSkillIt)) { // We don't have this required skill sprintf(str,"@%s:%s","skl_n", gSkillManager->getSkillById(*reqSkillIt)->mName.getAnsi()); populatedListBox.push_back(str); } ++reqSkillIt; } sprintf(str,"XP COST"); populatedListBox.push_back(str); // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Skill type = %u named %s", skill->mXpType, gSkillManager->getXPTypeById(skill->mXpType).getAnsi()); if (skill->mXpCost > 0) { sprintf(str,"%s = %u", gSkillManager->getXPTypeExById(skill->mXpType).getAnsi(), skill->mXpCost); } else { sprintf(str,"%s", gSkillManager->getXPTypeExById(skill->mXpType).getAnsi()); } populatedListBox.push_back(str); sprintf(str,"You do not have this skill.\n\nDescription:\n%s", gSkillManager->getSkillInfoById(skill->mId).getAnsi()); gUIManager->createNewListBox(NULL,"",strCaption,str,populatedListBox,player); // gUIManager->createNewListBox(NULL,"",strCaption,"@ui_attrib_mod:description \n\n@ui_attrib_mod:description \n@skl_d:combat_1hsword_ability_01",populatedListBox,player); // gUIManager->createNewListBox(NULL,"",strCaption,"@ui_attrib_mod:description \n@skl_d:combat_1hsword_ability_01 Testing",populatedListBox,player); // pageLink = 4; // Back to where we come from... } else { DLOG(INFO) << "Trainer: No skill avaliable"; } } break; default: { // gLogger->log(LogManager::DEBUG,"Trainer::conversationEvent: Default Nothing"); } } return pageLink; }
void CreatureObject::die() { mIncapCount = 0; mCurrentIncapTime = 0; mFirstIncapTime = 0; // gLogger->logMsg("CreatureObject::die I'm dead"); gMessageLib->sendIncapTimerUpdate(this); if(PlayerObject* player = dynamic_cast<PlayerObject*>(this)) { gMessageLib->sendSystemMessage(player,L"","base_player","victim_dead"); player->disableAutoAttack(); } mPosture = CreaturePosture_Dead; // reset ham regeneration mHam.updateRegenRates(); gWorldManager->removeCreatureHamToProcess(mHam.getTaskId()); mHam.setTaskId(0); updateMovementProperties(); // clear states mState = 0; gMessageLib->sendPostureAndStateUpdate(this); if(PlayerObject* player = dynamic_cast<PlayerObject*>(this)) { gMessageLib->sendUpdateMovementProperties(player); gMessageLib->sendSelfPostureUpdate(player); // update duel lists PlayerList::iterator duelIt = player->getDuelList()->begin(); while(duelIt != player->getDuelList()->end()) { if((*duelIt)->checkDuelList(player)) { PlayerObject* duelPlayer = (*duelIt); duelPlayer->removeFromDuelList(player); gMessageLib->sendUpdatePvpStatus(player,duelPlayer); gMessageLib->sendUpdatePvpStatus(duelPlayer,player); } ++duelIt; } player->getDuelList()->clear(); // update defender lists ObjectIDList::iterator defenderIt = mDefenders.begin(); while (defenderIt != mDefenders.end()) { if (CreatureObject* defenderCreature = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById((*defenderIt)))) { defenderCreature->removeDefenderAndUpdateList(this->getId()); if (PlayerObject* defenderPlayer = dynamic_cast<PlayerObject*>(defenderCreature)) { gMessageLib->sendUpdatePvpStatus(this,defenderPlayer); // gMessageLib->sendDefenderUpdate(defenderPlayer,0,0,this->getId()); } // Defender not hostile to me any more. gMessageLib->sendUpdatePvpStatus(defenderCreature, player); // if no more defenders, clear combat state if (!defenderCreature->getDefenders()->size()) { defenderCreature->toggleStateOff((CreatureState)(CreatureState_Combat + CreatureState_CombatAttitudeNormal)); gMessageLib->sendStateUpdate(defenderCreature); } } // If we remove self from all defenders, then we should remove all defenders from self. Remember, we are dead. defenderIt = mDefenders.erase(defenderIt); } // bring up the clone selection window ObjectSet inRangeBuildings; BStringVector buildingNames; std::vector<BuildingObject*> buildings; BuildingObject* nearestBuilding = NULL; BuildingObject* preDesignatedBuilding = NULL; // Search for cloning facilities. gWorldManager->getSI()->getObjectsInRange(this,&inRangeBuildings,ObjType_Building,8192); ObjectSet::iterator buildingIt = inRangeBuildings.begin(); while (buildingIt != inRangeBuildings.end()) { BuildingObject* building = dynamic_cast<BuildingObject*>(*buildingIt); if (building) { // Do we have any personal clone location? if (building->getId() == player->getPreDesignatedCloningFacilityId()) { // gLogger->logMsg("Found a pre-designated cloning facility"); preDesignatedBuilding = building; } if (building->getBuildingFamily() == BuildingFamily_Cloning_Facility) { // gLogger->logMsg("Found a cloning facility"); // TODO: This code is not working as intended if player dies inside, since buildings use world coordinates and players inside have cell coordinates. // Tranformation is needed before the correct distance can be calculated. if(!nearestBuilding || (nearestBuilding != building && (glm::distance(mPosition, building->mPosition) < glm::distance(mPosition, nearestBuilding->mPosition)))) { nearestBuilding = building; } } } ++buildingIt; } if (nearestBuilding) { if (nearestBuilding->getSpawnPoints()->size()) { // buildingNames.push_back(nearestBuilding->getRandomSpawnPoint()->mName.getAnsi()); // buildingNames.push_back("Closest Cloning Facility"); buildingNames.push_back("@base_player:revive_closest"); buildings.push_back(nearestBuilding); // Save nearest building in case we need to clone when reviev times out. player->saveNearestCloningFacility(nearestBuilding); } } if (preDesignatedBuilding) { if (preDesignatedBuilding->getSpawnPoints()->size()) { // buildingNames.push_back("Pre-Designated Facility"); buildingNames.push_back("@base_player:revive_bind"); buildings.push_back(preDesignatedBuilding); } } if (buildings.size()) { // Set up revive timer in case of user don't clone. gWorldManager->addPlayerObjectForTimedCloning(player->getId(), 10 * 60 * 1000); // TODO: Don't use hardcoded value. gUIManager->createNewCloneSelectListBox(player,"cloneSelect","Select Clone Destination","Select clone destination",buildingNames,buildings,player); } else { gLogger->logMsg("No cloning facility available\n"); } } else // if(CreatureObject* creature = dynamic_cast<CreatureObject*>(this)) { // gMessageLib->sendUpdateMovementProperties(player); // gMessageLib->sendSelfPostureUpdate(player); // Who killed me // this->prepareCustomRadialMenu(this,0); // // update defender lists ObjectIDList::iterator defenderIt = mDefenders.begin(); while(defenderIt != mDefenders.end()) { // This may be optimized, but rigth now THIS code does the job. this->makePeaceWithDefender(*defenderIt); defenderIt = mDefenders.begin(); } // I'm dead. De-spawn after "loot-timer" has expired, if any. // 3-5 min. uint64 timeBeforeDeletion = (180 + (gRandom->getRand() % (int32)120)) * 1000; if (this->getCreoGroup() == CreoGroup_AttackableObject) { // timeBeforeDeletion = 2 * 1000; // Almost NOW! timeBeforeDeletion = 500; // Play the death-animation, if any. if (AttackableStaticNpc* staticNpc = dynamic_cast<AttackableStaticNpc*>(this)) { staticNpc->playDeathAnimation(); } } else if (this->getCreoGroup() == CreoGroup_Creature) { if (AttackableCreature* creature = dynamic_cast<AttackableCreature*>(this)) { creature->unequipWeapon(); // Give XP to the one(s) attacking me. // creature->updateAttackersXp(); } } if (NPCObject* npc = dynamic_cast<NPCObject*>(this)) { // Give XP to the one(s) attacking me. npc->updateAttackersXp(); } // Put this creature in the pool of delayed destruction. gWorldManager->addCreatureObjectForTimedDeletion(this->getId(), timeBeforeDeletion); // this->killEvent(); } }