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::getRadioactiveSample(PlayerObject* player, CurrentResource* resource, SurveyTool* tool) { uint32 resType = resource->getType()->getCategoryId(); uint16 resPE = resource->getAttribute(ResAttr_PE); //these are the radioactive types if(resType == 477 || resType == 476 /* || resType == 475*/) { //did we already warn the player on the wounds ??? if(!player->getSampleData()->mPassRadioactive) { //UI Integration WindowAsyncContainerCommand* asyncContainer = new WindowAsyncContainerCommand(Window_Query_Radioactive_Sample); asyncContainer->PlayerId = player->getId(); asyncContainer->ToolId = tool->getId(); asyncContainer->CurrentResource = resource; gUIManager->createNewMessageBox(this,"radioactiveSample","@survey:radioactive_sample_t","@survey:radioactive_sample_d",player,SUI_Window_SmplRadioactive_MsgBox, SUI_MB_YESNO,asyncContainer); //Pause Sampling player->getSampleData()->mPendingSample = false; return true; } Ham* hamz = player->getHam(); uint32 playerBF = hamz->getBattleFatigue(); uint32 woundDmg = 50*(1 + (playerBF/100)) + (50*(1 + (resPE/1000))); uint32 bfDmg = static_cast<uint32>(0.075*resPE); uint32 hamReduc = 100*(2+ (resPE/1000)); if(resPE >= 500) { //wound and BF dmg hamz->updateBattleFatigue(bfDmg); hamz->updatePropertyValue(HamBar_Health,HamProperty_Wounds, woundDmg); hamz->updatePropertyValue(HamBar_Action,HamProperty_Wounds, woundDmg); hamz->updatePropertyValue(HamBar_Mind,HamProperty_Wounds, woundDmg); } //this should be a timed debuff per instance -- Do not cause wounds unless potential energy >= 500 // each time a radioactive is sampled, there is a 5 minute debuff // this currently doesn't work properly as when the debuff wears off, the buff class doesn't ensure // we don't have more ham than we should. BuffAttribute* healthdebuffAttribute = new BuffAttribute(attr_health, -(int)hamReduc,0,hamReduc); Buff* healthdebuff = Buff::SimpleBuff(player, player, 300000,0, gWorldManager->GetCurrentGlobalTick()); healthdebuff->AddAttribute(healthdebuffAttribute); player->AddBuff(healthdebuff,true); healthdebuffAttribute = new BuffAttribute(attr_action, -(int)hamReduc,0,hamReduc); healthdebuff = Buff::SimpleBuff(player, player, 300000, 0, gWorldManager->GetCurrentGlobalTick()); healthdebuff->AddAttribute(healthdebuffAttribute); player->AddBuff(healthdebuff,true); } else return false; return true; }
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 WorldManager::savePlayerSync(uint32 accId,bool remove) { PlayerObject* playerObject = getPlayerByAccId(accId); Ham* ham = playerObject->getHam(); mDatabase->destroyResult(mDatabase->executeSynchSql("UPDATE characters SET parent_id=%"PRIu64",oX=%f,oY=%f,oZ=%f,oW=%f,x=%f,y=%f,z=%f,planet_id=%u WHERE id=%"PRIu64"",playerObject->getParentId() ,playerObject->mDirection.x,playerObject->mDirection.y,playerObject->mDirection.z,playerObject->mDirection.w ,playerObject->mPosition.x,playerObject->mPosition.y,playerObject->mPosition.z ,mZoneId,playerObject->getId())); mDatabase->destroyResult(mDatabase->executeSynchSql("UPDATE character_attributes SET health_current=%u,action_current=%u,mind_current=%u" ",health_wounds=%u,strength_wounds=%u,constitution_wounds=%u,action_wounds=%u,quickness_wounds=%u" ",stamina_wounds=%u,mind_wounds=%u,focus_wounds=%u,willpower_wounds=%u,battlefatigue=%u,posture=%u,moodId=%u,title=\'%s\'" ",character_flags=%u,states=%"PRIu64",language=%u, group_id=%"PRIu64" WHERE character_id=%"PRIu64"", ham->mHealth.getCurrentHitPoints() - ham->mHealth.getModifier(), //Llloydyboy Added the -Modifier so that when buffs are reinitialised, it doesn't screw up HAM ham->mAction.getCurrentHitPoints() - ham->mAction.getModifier(), //Llloydyboy Added the -Modifier so that when buffs are reinitialised, it doesn't screw up HAM ham->mMind.getCurrentHitPoints() - ham->mMind.getModifier(), //Llloydyboy Added the -Modifier so that when buffs are reinitialised, it doesn't screw up HAM ham->mHealth.getWounds(), ham->mStrength.getWounds(), ham->mConstitution.getWounds(), ham->mAction.getWounds(), ham->mQuickness.getWounds(), ham->mStamina.getWounds(), ham->mMind.getWounds(), ham->mFocus.getWounds(), ham->mWillpower.getWounds(), ham->getBattleFatigue(), playerObject->states.getPosture(), playerObject->getMoodId(), playerObject->getTitle().getAnsi(), playerObject->getPlayerFlags(), playerObject->states.getAction(), playerObject->getLanguage(), playerObject->getGroupId(), playerObject->getId())); gBuffManager->SaveBuffs(playerObject, GetCurrentGlobalTick()); if(remove) destroyObject(playerObject); }
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); } }
void CampRegion::applyHAMHealing(Object* object) { PlayerObject* player = dynamic_cast<PlayerObject*>(object); //Make sure it's a player. if(player == NULL) return; Ham* hamz = player->getHam(); //Heal the Ham int32 HealthRegenRate = hamz->getHealthRegenRate(); int32 ActionRegenRate = hamz->getActionRegenRate(); int32 MindRegenRate = hamz->getMindRegenRate(); //Because we tick every 2 seconds, we need to double this. HealthRegenRate += (int32)(HealthRegenRate * mHealingModifier) * 2; ActionRegenRate += (int32)(ActionRegenRate * mHealingModifier) * 2; MindRegenRate += (int32)(MindRegenRate * mHealingModifier) * 2; if(hamz->mHealth.getModifiedHitPoints() - hamz->mHealth.getCurrentHitPoints() > 0) { //Regen Health int32 oldVal = hamz->mHealth.getCurrentHitPoints(); hamz->updatePropertyValue(HamBar_Health,HamProperty_CurrentHitpoints, HealthRegenRate); mHealingDone += hamz->mHealth.getCurrentHitPoints() - oldVal; } if(hamz->mAction.getModifiedHitPoints() - hamz->mAction.getCurrentHitPoints() > 0) { //Regen Action int32 oldVal = hamz->mAction.getCurrentHitPoints(); hamz->updatePropertyValue(HamBar_Action,HamProperty_CurrentHitpoints, ActionRegenRate); mHealingDone += hamz->mAction.getCurrentHitPoints() - oldVal; } if(hamz->mMind.getModifiedHitPoints() - hamz->mMind.getCurrentHitPoints() > 0) { //Regen Mind int32 oldVal = hamz->mMind.getCurrentHitPoints(); hamz->updatePropertyValue(HamBar_Mind, HamProperty_CurrentHitpoints, MindRegenRate); mHealingDone += hamz->mMind.getCurrentHitPoints() - oldVal; } }
void CampRegion::applyWoundHealing(Object* object) { PlayerObject* player = dynamic_cast<PlayerObject*>(object); //gLogger->logMsg("APPLYING WOUND HEALING!"); //Make sure it's a player. if(player == NULL) return; Ham* hamz = player->getHam(); if(hamz->mHealth.getWounds() > 0) { hamz->updatePropertyValue(HamBar_Health ,HamProperty_Wounds, -1); mHealingDone++; } if(hamz->mStrength.getWounds() > 0) { hamz->updatePropertyValue(HamBar_Strength ,HamProperty_Wounds, -1); mHealingDone++; } if(hamz->mConstitution.getWounds() > 0) { hamz->updatePropertyValue(HamBar_Constitution ,HamProperty_Wounds, -1); mHealingDone++; } if(hamz->mAction.getWounds() > 0) { hamz->updatePropertyValue(HamBar_Action ,HamProperty_Wounds, -1); mHealingDone++; } if(hamz->mQuickness.getWounds() > 0) { hamz->updatePropertyValue(HamBar_Quickness ,HamProperty_Wounds, -1); mHealingDone++; } if(hamz->mStamina.getWounds() > 0) { hamz->updatePropertyValue(HamBar_Stamina ,HamProperty_Wounds, -1); mHealingDone++; } if(hamz->mMind.getWounds() > 0) { hamz->updatePropertyValue(HamBar_Mind ,HamProperty_Wounds, -1); mHealingDone++; } if(hamz->mFocus.getWounds() > 0) { hamz->updatePropertyValue(HamBar_Focus ,HamProperty_Wounds, -1); mHealingDone++; } if(hamz->mWillpower.getWounds() > 0) { hamz->updatePropertyValue(HamBar_Willpower ,HamProperty_Wounds, -1); mHealingDone++; } }
//============================================================================= //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); }
//============================================================================= // // database callback // void ObjectController::handleDatabaseJobComplete(void* ref,DatabaseResult* result) { ObjControllerAsyncContainer* asyncContainer = reinterpret_cast<ObjControllerAsyncContainer*>(ref); switch(asyncContainer->mQueryType) { case OCQuery_StatRead: { if(!asyncContainer->playerObject) break; Ham* ourHam = asyncContainer->playerObject->getHam(); StatTargets theTargets; DataBinding* binding = mDatabase->createDataBinding(9); binding->addField(DFT_uint32,offsetof(StatTargets,TargetHealth),4,0); binding->addField(DFT_uint32,offsetof(StatTargets,TargetStrength),4,1); binding->addField(DFT_uint32,offsetof(StatTargets,TargetConstitution),4,2); binding->addField(DFT_uint32,offsetof(StatTargets,TargetAction),4,3); binding->addField(DFT_uint32,offsetof(StatTargets,TargetQuickness),4,4); binding->addField(DFT_uint32,offsetof(StatTargets,TargetStamina),4,5); binding->addField(DFT_uint32,offsetof(StatTargets,TargetMind),4,6); binding->addField(DFT_uint32,offsetof(StatTargets,TargetFocus),4,7); binding->addField(DFT_uint32,offsetof(StatTargets,TargetWillpower),4,8); uint64 count = result->getRowCount(); //make sure we have some values set in case the statmigration table wont hold anything on us if(count != 1) { ourHam->setTargetStatValue(HamBar_Health,ourHam->getPropertyValue(HamBar_Health,HamProperty_BaseHitpoints)); ourHam->setTargetStatValue(HamBar_Strength,ourHam->getPropertyValue(HamBar_Strength,HamProperty_BaseHitpoints)); ourHam->setTargetStatValue(HamBar_Constitution,ourHam->getPropertyValue(HamBar_Constitution,HamProperty_BaseHitpoints)); ourHam->setTargetStatValue(HamBar_Action,ourHam->getPropertyValue(HamBar_Action,HamProperty_BaseHitpoints)); ourHam->setTargetStatValue(HamBar_Quickness,ourHam->getPropertyValue(HamBar_Quickness,HamProperty_BaseHitpoints)); ourHam->setTargetStatValue(HamBar_Stamina,ourHam->getPropertyValue(HamBar_Stamina,HamProperty_BaseHitpoints)); ourHam->setTargetStatValue(HamBar_Mind,ourHam->getPropertyValue(HamBar_Mind,HamProperty_BaseHitpoints)); ourHam->setTargetStatValue(HamBar_Focus,ourHam->getPropertyValue(HamBar_Focus,HamProperty_BaseHitpoints)); ourHam->setTargetStatValue(HamBar_Willpower,ourHam->getPropertyValue(HamBar_Willpower,HamProperty_BaseHitpoints)); } else { result->getNextRow(binding,&theTargets); ourHam->setTargetStatValue(HamBar_Health,theTargets.TargetHealth); ourHam->setTargetStatValue(HamBar_Strength,theTargets.TargetStrength); ourHam->setTargetStatValue(HamBar_Constitution,theTargets.TargetConstitution); ourHam->setTargetStatValue(HamBar_Action,theTargets.TargetAction); ourHam->setTargetStatValue(HamBar_Quickness,theTargets.TargetQuickness); ourHam->setTargetStatValue(HamBar_Stamina,theTargets.TargetStamina); ourHam->setTargetStatValue(HamBar_Mind,theTargets.TargetMind); ourHam->setTargetStatValue(HamBar_Focus,theTargets.TargetFocus); ourHam->setTargetStatValue(HamBar_Willpower,theTargets.TargetWillpower); } mDatabase->destroyDataBinding(binding); gMessageLib->sendStatMigrationStartMessage(asyncContainer->playerObject); } break; case OCQuery_FindFriend: { DataBinding* binding = mDatabase->createDataBinding(1); binding->addField(DFT_uint64,0,8); uint64 ret = 0; uint64 count = result->getRowCount(); result->getNextRow(binding,&ret); mDatabase->destroyDataBinding(binding); if(count == 0) ret = 0; _handleFindFriendDBReply(ret,asyncContainer->mString); } break; case OCQuery_AddFriend: { DataBinding* binding = mDatabase->createDataBinding(1); binding->addField(DFT_uint32,0,4); uint32 ret = 0; //uint64 count = result->getRowCount(); result->getNextRow(binding,&ret); mDatabase->destroyDataBinding(binding); _handleAddFriendDBReply(ret,asyncContainer->mString); } break; case OCQuery_RemoveFriend: { DataBinding* binding = mDatabase->createDataBinding(1); binding->addField(DFT_uint32,0,4); uint32 ret = 0; //uint64 count = result->getRowCount(); result->getNextRow(binding,&ret); mDatabase->destroyDataBinding(binding); _handleRemoveFriendDBReply(ret,asyncContainer->mString); } break; case OCQuery_AddIgnore: { DataBinding* binding = mDatabase->createDataBinding(1); binding->addField(DFT_uint32,0,4); uint32 ret = 0; //uint64 count = result->getRowCount(); result->getNextRow(binding,&ret); mDatabase->destroyDataBinding(binding); _handleAddIgnoreDBReply(ret,asyncContainer->mString); } break; case OCQuery_RemoveIgnore: { DataBinding* binding = mDatabase->createDataBinding(1); binding->addField(DFT_uint32,0,4); uint32 ret = 0; //uint64 count = result->getRowCount(); result->getNextRow(binding,&ret); mDatabase->destroyDataBinding(binding); _handleRemoveIgnoreDBReply(ret,asyncContainer->mString); } break; case OCQuery_CloneAtPreDes: { if (!asyncContainer->playerObject) break; if (!result->getRowCount()) { break; } DataBinding* binding = mDatabase->createDataBinding(9); binding->addField(DFT_uint32,offsetof(PlayerObject,mHam.mHealth.mWounds),4,0); binding->addField(DFT_uint32,offsetof(PlayerObject,mHam.mStrength.mWounds),4,1); binding->addField(DFT_uint32,offsetof(PlayerObject,mHam.mConstitution.mWounds),4,2); binding->addField(DFT_uint32,offsetof(PlayerObject,mHam.mAction.mWounds),4,3); binding->addField(DFT_uint32,offsetof(PlayerObject,mHam.mQuickness.mWounds),4,4); binding->addField(DFT_uint32,offsetof(PlayerObject,mHam.mStamina.mWounds),4,5); binding->addField(DFT_uint32,offsetof(PlayerObject,mHam.mMind.mWounds),4,6); binding->addField(DFT_uint32,offsetof(PlayerObject,mHam.mFocus.mWounds),4,7); binding->addField(DFT_uint32,offsetof(PlayerObject,mHam.mWillpower.mWounds),4,8); result->getNextRow(binding,asyncContainer->playerObject); // Update HAM // asyncContainer->playerObject->getHam()->calcAllModifiedHitPoints(); asyncContainer->playerObject->getHam()->updateAllWounds(0); // Invoke the actual cloning process. SpawnPoint* sp = reinterpret_cast<SpawnPoint*>(asyncContainer->anyPtr); if (sp) { asyncContainer->playerObject->clone(sp->mCellId,sp->mDirection,sp->mPosition,true); } mDatabase->destroyDataBinding(binding); } break; default: { } break; } mDBAsyncContainerPool.free(asyncContainer); }