//====================================================================================================================== // //handles the logout via /logout command // void ObjectController::_handleClientLogout(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties) { PlayerObject* player = dynamic_cast<PlayerObject*>(mObject); // gLogger->hexDump(message->getData(),message->getSize()); //make sure we cannot use the /logout multiple times //as this will invalidate our disconnect lists if(player->checkPlayerCustomFlag(PlayerCustomFlag_LogOut)) { return; } player->togglePlayerCustomFlagOn(PlayerCustomFlag_LogOut); uint32 logout = gWorldConfig->getConfiguration<uint32>("Player_LogOut_Time",(uint32)30); uint32 logoutSpacer = gWorldConfig->getConfiguration<uint32>("Player_LogOut_Spacer",(uint32)5); if(logoutSpacer > logout) logoutSpacer = logout; if(logoutSpacer < 1) logoutSpacer = 1; if(logout < logoutSpacer) logout = logoutSpacer; if(logout > 300) logout = 300; // schedule execution addEvent(new LogOutEvent(Anh_Utils::Clock::getSingleton()->getLocalTime()+((logout-logoutSpacer)*1000),logoutSpacer*1000),logoutSpacer*1000); gMessageLib->SendSystemMessage(::common::OutOfBand("logout", "time_left", 0, 0, 0, logout), player); }
void ObjectController::_handleSitServer(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties) { PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject); if(playerObject) { BString data; glm::vec3 chair_position; uint64 chairCell = 0; uint32 elementCount = 0; if(playerObject->checkPlayerCustomFlag(PlayerCustomFlag_LogOut)) { playerObject->togglePlayerFlagOff(PlayerCustomFlag_LogOut); gMessageLib->SendSystemMessage(::common::OutOfBand("logout", "aborted"), playerObject); } // see if we need to get out of sampling mode if(playerObject->getSamplingState()) { gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_cancel"), playerObject); playerObject->setSamplingState(false); } message->getStringUnicode16(data); //Should be okay even if data is null! (I hope) // sitting on chair if(data.getLength()) { elementCount = swscanf(data.getUnicode16(), L"%f,%f,%f,%"WidePRIu64, &chair_position.x, &chair_position.y, &chair_position.z, &chairCell); if(elementCount == 4) { // outside playerObject->updatePosition(chairCell,chair_position); //this->mDirection = Anh_Math::Quaternion(); if(chairCell) { gMessageLib->sendDataTransformWithParent053(playerObject); } else { gMessageLib->sendDataTransform053(playerObject); } //gMessageLib->sendUpdateMovementProperties(playerObject); //gMessageLib->sendPostureAndStateUpdate(playerObject); gMessageLib->sendSitOnObject(playerObject); } } // sitting on ground else { //gMessageLib->sendPostureUpdate(playerObject); //gMessageLib->sendSelfPostureUpdate(playerObject); } gStateManager.setCurrentPostureState(playerObject, CreaturePosture_Sitting); } }
bool HandleBurstRun(Object* object, Object* target, Message* message, ObjectControllerCmdProperties* cmd_properties) { PlayerObject* player = dynamic_cast<PlayerObject*>(object); if (!player) { return false; } //can we burst run right now ?? if(player->checkPlayerCustomFlag(PlayerCustomFlag_BurstRun)) { gMessageLib->SendSystemMessage(L"You are already running as hard as you can.", player); return false; } if(player->checkPlayerCustomFlag(PlayerCustomFlag_BurstRunCD)) { gMessageLib->SendSystemMessage(OutOfBand("combat_effects", "burst_run_wait"), player); return false; } // Create a pre-command processing event. auto pre_execute_event = std::make_shared<PreCommandExecuteEvent>(object->getId()); pre_execute_event->target_id(0); // This command never has a target. pre_execute_event->command_crc(cmd_properties->mCmdCrc); // Trigger a pre-command execute event and get the result. This allows // any listeners a last chance to veto the processing of the command. if (!gEventDispatcher.Deliver(pre_execute_event).get()) { return false; } // Update the player's speed modifier. player->setCurrentSpeedModifier(player->getCurrentSpeedModifier()*2); gMessageLib->sendUpdateMovementProperties(player); // Update the player's locomotion to a running state. player->states.setLocomotion(CreatureLocomotion_Running); // Toggle the flags for the burst run effect and the cool-down timer on the corresponding command. player->togglePlayerCustomFlagOn(PlayerCustomFlag_BurstRunCD); player->togglePlayerCustomFlagOn(PlayerCustomFlag_BurstRun); //Send the burst run system message to the player gMessageLib->SendSystemMessage(L"You run as hard as you can!", player); //Now send the burst run combat spam message to InRange gMessageLib->sendCombatSpam(player, player, 0, "cbt_spam", "burstrun_start"); // Duration of the burst run effect in seconds. uint32_t effect_duration_sec = gWorldConfig->getConfiguration<uint32_t>("Player_BurstRun_Time", 60); // Create a delayed event for the end of the burst run and attach a custom // callback to be executed 60 seconds after being triggered. auto burst_end_event = std::make_shared<BurstRunEndEvent>(object->getId(), effect_duration_sec * 1000, [player] { // Make sure the target for the event is still valid and that their burst run flag is still set. if(player && player->checkPlayerCustomFlag(PlayerCustomFlag_BurstRun)) { // Return the player to normal movement. player->setCurrentSpeedModifier(player->getBaseSpeedModifier()); gMessageLib->sendUpdateMovementProperties(player); // Update the player's locomotion to a walking state. player->states.setLocomotion(CreatureLocomotion_Walking); // Remove the burst run flag. player->togglePlayerCustomFlagOff(PlayerCustomFlag_BurstRun); // Alert the player the burst run has ended and that they are now tired. gMessageLib->SendSystemMessage(OutOfBand("cbt_spam", "burstrun_stop_single"), player); gMessageLib->sendCombatSpam(player, player, 0, "cbt_spam", "burstrun_stop"); gMessageLib->SendSystemMessage(OutOfBand("combat_effects", "burst_run_tired"), player); } }); // Create a delayed event for the end of the burst run cool-down timer and attach // a custom callback to be executed 6 minutes after being triggered. auto burst_cooldown_end_event = std::make_shared<BurstRunCooldownEndEvent>(object->getId(), static_cast<uint64_t>(cmd_properties->mDelayMultiplier) * 1000, [player] { // Make sure the target for the event is still valid and that their burst run cool-down flag is still set. if(player && player->checkPlayerCustomFlag(PlayerCustomFlag_BurstRunCD)) { // Turn off the burst run cool-down flag and alert the player. player->togglePlayerCustomFlagOff(PlayerCustomFlag_BurstRunCD); gMessageLib->SendSystemMessage(OutOfBand("combat_effects", "burst_run_not_tired"), player); } }); // Chain the two events together so that they are called in the appropriate order. burst_end_event->next(burst_cooldown_end_event); // Notify any curious listeners of the event. gEventDispatcher.Notify(burst_end_event); return true; }