void ObjectController::_handleHealWound(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties) { PlayerObject* Medic = dynamic_cast<PlayerObject*>(mObject); PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic)); std::string messageResponse = gMedicManager->handleMessage(message,"(action|constitution|health|quickness|stamina|strength)"); if (messageResponse.length() == 0) { //you must specify a valid wound type gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "healing_response_65"), Medic); } else { //check Medic has enough Mind Ham* ham = Medic->getHam(); if(ham->checkMainPools(0, 0, 140)) { if (gMedicManager->CheckMedicine(Medic, Target, cmdProperties, messageResponse)) { //call the event gMedicManager->startWoundTreatmentEvent(Medic); return; } } else gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "not_enough_mind"), Medic); } }
bool ArtisanManager::stopSampling(PlayerObject* player, CurrentResource* resource, SurveyTool* tool) { Ham* ham = player->getHam(); bool stop = false; if(!resource || !tool || !player->isConnected() || !player->getSamplingState()||player->getSurveyState()) { stop = true; } // you can't take sample while under attack! if(player->states.checkState(CreatureState_Combat)) { gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_cancel_attack"), player); return false; } Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory)); if(!inventory) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_gone"), player); stop = true; } tool = dynamic_cast<SurveyTool*>(inventory->getObjectById(tool->getId())); if(!tool) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_gone"), player); stop = true; } uint32 actionCost = mSampleActionCost; if(!ham->checkMainPools(0,actionCost,0)) { //return message for sampling cancel based on HAM if(ham->mAction.getCurrentHitPoints() < (int32)actionCost) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_mind"), player); stop = true; } } if (stop) { player->setSamplingState(false); gStateManager.setCurrentPostureState(player, CreaturePosture_Upright); } return stop; }
void ObjectController::_handleQuickHeal(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties) { PlayerObject* Medic = dynamic_cast<PlayerObject*>(mObject); PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic)); //check Medic has enough Mind Ham* ham = Medic->getHam(); if(ham->checkMainPools(0, 0, cmdProperties->mMindCost)) { if (gMedicManager->HealDamage(Medic, Target, 0, cmdProperties, "quickHeal")) { ham->updatePropertyValue(HamBar_Focus ,HamProperty_Wounds, 10); ham->updatePropertyValue(HamBar_Willpower ,HamProperty_Wounds, 10); ham->updateBattleFatigue(2, true); //call the event gMedicManager->startQuickHealInjuryTreatmentEvent(Medic); return; } } else gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "not_enough_mind"), Medic); }
void ObjectController::_handleTendWound(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties) { PlayerObject* Medic = dynamic_cast<PlayerObject*>(mObject); PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic)); //TODO:: add medic droid /*EMLocationType loc = Medic->getPlayerLocation(); if(loc != EMLocation_Cantina || loc != EMLocation_Camp || loc != EMLocation_PlayerStructure) { return; }*/ std::string messageResponse = gMedicManager->handleMessage(message,"(action|constitution|health|quickness|stamina|strength)"); if (messageResponse.length() == 0) { //you must specify a valid wound type gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "healing_response_65"), Medic); } else { //check Medic has enough Mind Ham* ham = Medic->getHam(); if(ham->checkMainPools(0, 0, 500)) { if (gMedicManager->HealWound(Medic, Target, 0, cmdProperties, messageResponse + "tendwound")) { ham->updatePropertyValue(HamBar_Focus ,HamProperty_Wounds, 5); ham->updatePropertyValue(HamBar_Willpower ,HamProperty_Wounds, 5); ham->updateBattleFatigue(2, true); //call the event gMedicManager->startWoundTreatmentEvent(Medic); return; } } else gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "not_enough_mind"), Medic); } }
//============================================================================= //commits the changes of the ID session // void EntertainerManager::commitIdChanges(PlayerObject* customer,PlayerObject* designer, BString hair, uint32 amount,uint8 statMigration, BString holoEmote,uint8 flagHair) { Ham* ham = designer->getHam(); if(ham->checkMainPools(0,0,66)) { //int32 mindCost = 66; designer->getHam()->updatePropertyValue(HamBar_Mind,HamProperty_CurrentHitpoints,-(66)); } const PlayerObjectSet* const inRangePlayers = customer->getKnownPlayers(); PlayerObjectSet::const_iterator itiR = inRangePlayers->begin(); int8 sql[1024]; EntertainerManagerAsyncContainer* asyncContainer; //money if(amount >0) applyMoney(customer,designer,amount); //////// //Hair// /////// if(flagHair) applyHair(customer,hair); //////////// //attributes /////////// int8 mySQL[2048]; AttributesList* aList = customer->getIdAttributesList(); AttributesList::iterator it = aList->begin(); BString data; bool firstUpdate = true; sprintf(mySQL,"UPDATE character_appearance set "); while(it != aList->end()) { gLogger->log(LogManager::DEBUG,"ID apply changes : attribute : %s crc : %u", it->first.getAnsi(),it->first.getCrc()); //apply the attributes and retrieve the data to update the db if(it->first.getCrc() != BString("height").getCrc()) { data = commitIdAttribute(customer, it->first, it->second); } else { data = commitIdheight(customer, it->second); } if (firstUpdate) { sprintf(mySQL,"%s %s",mySQL,data.getAnsi()); firstUpdate = false; } else sprintf(mySQL,"%s, %s",mySQL,data.getAnsi()); ++it; } //colors ColorList* cList = customer->getIdColorList(); ColorList::iterator cIt = cList->begin(); while(cIt != cList->end()) { gLogger->log(LogManager::DEBUG,"ID apply changes : attribute : %s crc : %u",cIt->first.getAnsi(),cIt->first.getCrc()); data = commitIdColor(customer, cIt->first, cIt->second); if(data.getLength()) { if (firstUpdate) { sprintf(mySQL,"%s %s",mySQL,data.getAnsi()); firstUpdate = false; } else sprintf(mySQL,"%s, %s",mySQL,data.getAnsi()); } ++cIt; } //do we have actual data or only the primer ??? "UPDATE character_appearance set " if(strlen(mySQL) > 33) { sprintf(sql,"%s where character_id = '%"PRIu64"'",mySQL,customer->getId()); gLogger->log(LogManager::DEBUG,"ID apply changes : sql: %s ",sql); asyncContainer = new EntertainerManagerAsyncContainer(EMQuery_NULL,0); mDatabase->ExecuteSqlAsync(this,asyncContainer,sql); } //build plus send customization //please note that hair object customizatio is send updated and maintained b ycommitIdColor customer->buildCustomization(customer->getCustomization()); gMessageLib->sendCustomizationUpdateCreo3(customer); gMessageLib->sendScaleUpdateCreo3(customer); //Holoemotes if(holoEmote.getLength()) applyHoloEmote(customer,holoEmote); //statmigration if(statMigration) { //xp in case of statmigration will be handled by the callback int8 sql[256]; asyncContainer = new EntertainerManagerAsyncContainer(EMQuery_IDMigrateStats,0); asyncContainer->customer = customer; asyncContainer->performer = designer; sprintf(sql,"SELECT target_health, target_strength, target_constitution, target_action, target_quickness, target_stamina, target_mind, target_focus, target_willpower FROM swganh.character_stat_migration where character_id = %"PRIu64"", customer->getId()); mDatabase->ExecuteSqlAsync(this,asyncContainer,sql); } else { //XP does not stack. So in the case of statmigration only 2000xp will be given //otherwise xp will be determined here // uint32 xP = 0; uint32 tempXP = 0; it = aList->begin(); while(it != aList->end()) { tempXP = getIdXP(it->first, static_cast<uint16>(it->second)); if(tempXP > xP) xP = tempXP; ++it; } cIt = cList->begin(); while(cIt != cList->end()) { tempXP = getIdXP(cIt->first, cIt->second); if(tempXP > xP) xP = tempXP; ++cIt; } if(flagHair) { tempXP = 50; if(tempXP > xP) xP = tempXP; } //only half XP if you design yourself if(designer == customer) gSkillManager->addExperience(XpType_imagedesigner,(uint32)(xP/2),designer); else gSkillManager->addExperience(XpType_imagedesigner,(uint32)xP,designer); } //empty the attribute lists aList->clear(); cList->clear(); }
bool ArtisanManager::handleRequestSurvey(Object* playerObject,Object* target,Message* message,ObjectControllerCmdProperties* cmdProperties) { PlayerObject* player = dynamic_cast<PlayerObject*>(playerObject); std::shared_ptr<SimpleEvent> start_survey_event = nullptr; if(cmdProperties) mSurveyMindCost = cmdProperties->mMindCost; // don't allow survey in buildings if(player->getParentId()) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_in_structure"), player); return false; } if(player->getPerformingState() != PlayerPerformance_None) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), player); return false; } if(player->getSurveyState()) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_cant"), player); return false; } if(player->getSamplingState()) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_sample"), player); return false; } SurveyTool* tool = dynamic_cast<SurveyTool*>(target); CurrentResource* resource = NULL; BString resourceName; message->getStringUnicode16(resourceName); resourceName.convert(BSTRType_ANSI); resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc())); if(tool && resource) { player->setSurveyState(true); // play effect std::string effect = gWorldManager->getClientEffect(tool->getInternalAttribute<uint32>("survey_effect")); gMessageLib->sendPlayClientEffectLocMessage(effect,player->mPosition,player); PlayerObjectSet* playerList = player->getKnownPlayers(); PlayerObjectSet::iterator it = playerList->begin(); while(it != playerList->end()) { gMessageLib->sendPlayClientEffectLocMessage(effect,player->mPosition,(*it)); ++it; } uint32 mindCost = mSurveyMindCost; Ham* hamz = player->getHam(); //are we able to sample in the first place ?? if(!hamz->checkMainPools(0,0,mindCost)) { int32 myMind = hamz->mAction.getCurrentHitPoints(); //return message for sampling cancel based on HAM if(myMind < (int32)mindCost) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_mind"), player); } //message for stop sampling gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_cancel"), player); player->getSampleData()->mPendingSurvey = false; hamz->updateRegenRates(); player->updateMovementProperties(); return false; } hamz->performSpecialAction(0,0,(float)mindCost,HamProperty_CurrentHitpoints); // send system message resourceName.convert(BSTRType_Unicode16); gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "start_survey", L"", L"", resourceName.getUnicode16()), player); // schedule execution start_survey_event = std::make_shared<SimpleEvent>(EventType("start_survey"),0, 5000, std::bind(&ArtisanManager::surveyEvent, this, player, resource, tool)); } else { gMessageLib->SendSystemMessage(::common::OutOfBand("ui","survey_nothingfound")); return false; } // notify any listeners if (start_survey_event) gEventDispatcher.Notify(start_survey_event); return true; }
void ArtisanManager::handleUIEvent(uint32 action,int32 element,BString inputStr,UIWindow* window) { PlayerObject* player = window->getOwner(); std::shared_ptr<SimpleEvent> sample_UI_event = nullptr; if(!player) { return; } Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory)); if(!inventory) { return; } WindowAsyncContainerCommand* asyncContainer = (WindowAsyncContainerCommand*)window->getAsyncContainer(); if(!asyncContainer) return; Ham* ham = player->getHam(); switch(window->getWindowType()) { // Sampling Radioactive Msg Box case SUI_Window_SmplRadioactive_MsgBox: { //we stopped the sampling if(action == 1) { player->getSampleData()->mPassRadioactive = false; player->getSampleData()->mPendingSample = false; gStateManager.setCurrentPostureState(player, CreaturePosture_Upright); return; } else { player->getSampleData()->mPassRadioactive = true; player->getSampleData()->mPendingSample = true; if(ham->checkMainPools(0,mSampleActionCost*2,0)) { SurveyTool* tool = dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId)); CurrentResource* resource = (CurrentResource*)asyncContainer->CurrentResource; player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 4000; sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_radioactive"),0, 4000, std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool)); } else { gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_no_action"), player); return; } } } break; case SUI_Window_SmplGamble_ListBox: { //action == 1 is cancel if(action == 1) { player->getSampleData()->mPendingSample = false; player->getSampleData()->mSampleGambleFlag = false; gStateManager.setCurrentPostureState(player, CreaturePosture_Upright); player->updateMovementProperties(); gMessageLib->sendUpdateMovementProperties(player); gMessageLib->sendPostureAndStateUpdate(player); gMessageLib->sendSelfPostureUpdate(player); return; } else { if(element == 0) { player->getSampleData()->mPendingSample = true; player->getSampleData()->mSampleGambleFlag = false; SurveyTool* tool = dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId)); CurrentResource* resource = (CurrentResource*)asyncContainer->CurrentResource; player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 1000; sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_gamble"),0, 1000, std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool)); } else { //action costs if(!ham->checkMainPools(0,mSampleActionCost*2,0)) { gStateManager.setCurrentPostureState(player, CreaturePosture_Upright); player->getSampleData()->mSampleEventFlag = false; player->getSampleData()->mSampleGambleFlag = false; gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_no_action"), player); return; } player->getSampleData()->mPendingSample = true; //determine whether gamble is good or not int32 gambleRoll = int(gRandom->getRand()%2) + 1; if(gambleRoll == 1) { player->getSampleData()->mSampleEventFlag = true; player->getSampleData()->mSampleGambleFlag = true; } else { player->getSampleData()->mSampleEventFlag = false; player->getSampleData()->mSampleGambleFlag = false; gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_fail"), player); } SurveyTool* tool = dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId)); CurrentResource* resource = (CurrentResource*)asyncContainer->CurrentResource; player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 1000; sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_gamble"),0, 1000, std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool)); } } } break; case SUI_Window_SmplWaypNode_ListBox: { if(action == 0) { //we hit ok and went for the wp if(element == 1) { player->getSampleData()->mPendingSample = false; player->getSampleData()->mSampleNodeFlag = true; player->getSampleData()->Position.x = player->mPosition.x +(((gRandom->getRand()%50)+1)); player->getSampleData()->Position.z = player->mPosition.z +(((gRandom->getRand()%50)+1)); player->getSampleData()->zone = gWorldManager->getZoneId(); player->getSampleData()->resource = (CurrentResource*)asyncContainer->CurrentResource; Datapad* datapad = player->getDataPad(); datapad->requestNewWaypoint("Resource Node", player->getSampleData()->Position ,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue); gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "node_waypoint"), player); gStateManager.setCurrentPostureState(player, CreaturePosture_Upright); return; } //we ignored the node - so continue sampling if(element == 0) { player->getSampleData()->mPendingSample = true; player->getSampleData()->mSampleGambleFlag = false; SurveyTool* tool = dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId)); CurrentResource* resource = (CurrentResource*)asyncContainer->CurrentResource; player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 10000; sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_continue"),0, 10000, std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool)); } } else { player->getSampleData()->mPendingSample = false; player->getSampleData()->mSampleNodeFlag = false; player->getSampleData()->Position.x = 0; player->getSampleData()->Position.z = 0; player->getSampleData()->resource = NULL; player->getSampleData()->zone = 0; gStateManager.setCurrentPostureState(player, CreaturePosture_Upright); return; } } break; } //notify the listeners if (sample_UI_event) gEventDispatcher.Notify(sample_UI_event); SAFE_DELETE(asyncContainer); }