From 9c5388c70eb2fb86f752ddc8ad9951f3ba5794e6 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Tue, 21 Nov 2023 18:04:44 -0800 Subject: [PATCH] feat: Add ability to toggle skipping of cinematics (#1312) * Cinematics: Add ability to toggle skipping them * Add docs * Move sections --- dCommon/dEnums/ePlayerFlag.h | 3 ++- dGame/dGameMessages/GameMessageHandler.cpp | 9 +++++++++ dGame/dGameMessages/GameMessages.cpp | 9 +++++++++ dGame/dUtilities/SlashCommandHandler.cpp | 16 ++++++++++++++++ docs/Commands.md | 3 ++- resources/worldconfig.ini | 4 ++++ 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/dCommon/dEnums/ePlayerFlag.h b/dCommon/dEnums/ePlayerFlag.h index fefdfb67..01adcb0e 100644 --- a/dCommon/dEnums/ePlayerFlag.h +++ b/dCommon/dEnums/ePlayerFlag.h @@ -166,7 +166,8 @@ enum ePlayerFlag : int32_t { NJ_LIGHTNING_SPINJITZU = 2031, NJ_ICE_SPINJITZU = 2032, NJ_FIRE_SPINJITZU = 2033, - NJ_WU_SHOW_DAILY_CHEST = 2099 + NJ_WU_SHOW_DAILY_CHEST = 2099, + DLU_SKIP_CINEMATICS = 1'000'000, }; #endif //!__EPLAYERFLAG__H__ diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index 40293fbe..55151242 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -34,6 +34,8 @@ #include "eMissionTaskType.h" #include "eReplicaComponentType.h" #include "eConnectionType.h" +#include "ePlayerFlag.h" +#include "dConfig.h" using namespace std; @@ -173,6 +175,13 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System GameMessages::SendPlayerReady(entity, sysAddr); GameMessages::SendPlayerReady(Game::zoneManager->GetZoneControlObject(), sysAddr); + if (Game::config->GetValue("allow_players_to_skip_cinematics") != "1" + || !entity->GetCharacter() + || !entity->GetCharacter()->GetPlayerFlag(ePlayerFlag::DLU_SKIP_CINEMATICS)) return; + entity->AddCallbackTimer(0.5f, [entity, sysAddr]() { + if (!entity) return; + GameMessages::SendEndCinematic(entity->GetObjectID(), u"", sysAddr); + }); break; } diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 7fb9c259..4cddebff 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -43,6 +43,7 @@ #include "eControlScheme.h" #include "eStateChangeType.h" #include "eConnectionType.h" +#include "ePlayerFlag.h" #include #include @@ -5161,6 +5162,14 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* en } else if (iMissionState == eMissionState::READY_TO_COMPLETE || iMissionState == eMissionState::COMPLETE_READY_TO_COMPLETE) { missionComponent->CompleteMission(missionID); } + + if (Game::config->GetValue("allow_players_to_skip_cinematics") != "1" + || !player->GetCharacter() + || !player->GetCharacter()->GetPlayerFlag(ePlayerFlag::DLU_SKIP_CINEMATICS)) return; + player->AddCallbackTimer(0.5f, [player]() { + if (!player) return; + GameMessages::SendEndCinematic(player->GetObjectID(), u"", player->GetSystemAddress()); + }); } void GameMessages::HandleRequestLinkedMission(RakNet::BitStream* inStream, Entity* entity) { diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index f4a21cab..8444bba7 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -85,6 +85,7 @@ #include "CDObjectsTable.h" #include "CDZoneTableTable.h" +#include "ePlayerFlag.h" void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entity* entity, const SystemAddress& sysAddr) { auto commandCopy = command; @@ -171,6 +172,21 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } + if (chatCommand == "toggleskipcinematics" && (Game::config->GetValue("allow_players_to_skip_cinematics") == "1" || entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER)) { + auto* character = entity->GetCharacter(); + if (!character) return; + bool current = character->GetPlayerFlag(ePlayerFlag::DLU_SKIP_CINEMATICS); + character->SetPlayerFlag(ePlayerFlag::DLU_SKIP_CINEMATICS, !current); + if (!current) { + ChatPackets::SendSystemMessage(sysAddr, u"You have elected to skip cinematics. Note that not all cinematics can be skipped, but most will be skipped now."); + } else { + ChatPackets::SendSystemMessage(sysAddr, u"Cinematics will no longer be skipped."); + } + + return; + } + + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //HANDLE ALL NON GM SLASH COMMANDS RIGHT HERE! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/docs/Commands.md b/docs/Commands.md index 71a3da43..16202056 100644 --- a/docs/Commands.md +++ b/docs/Commands.md @@ -14,6 +14,8 @@ |resurrect|`/resurrect`|Resurrects the player.|| |requestmailcount|`/requestmailcount`|Sends notification with number of unread messages in the player's mailbox.|| |who|`/who`|Displays in chat all players on the instance.|| +|togglenameplate|`/togglenameplate`|Turns the nameplate above your head that is visible to other players off and on.|8 or if `allow_nameplate_off` is set to exactly `1` in the settings| +|toggleskipcinematics|`/toggleskipcinematics`|Skips mission and world load related cinematics.|8 or if `allow_players_to_skip_cinematics` is set to exactly `1` in the settings then 0| ## Moderation Commands @@ -49,7 +51,6 @@ These commands are primarily for development and testing. The usage of many of t |Command|Usage|Description|Admin Level Requirement| |--- |--- |--- |--- | -|togglenameplate|`/togglenameplate`|Turns the nameplate above your head that is visible to other players off and on.|8 or if `allow_nameplate_off` is set to exactly `1` in the settings| |fix-stats|`/fix-stats`|Resets skills, buffs, and destroyables.|| |join|`/join `|Joins a private zone with given password.|| |leave-zone|`/leave-zone`|If you are in an instanced zone, transfers you to the closest main world. For example, if you are in an instance of Avant Gardens Survival or the Spider Queen Battle, you are sent to Avant Gardens. If you are in the Battle of Nimbus Station, you are sent to Nimbus Station.|| diff --git a/resources/worldconfig.ini b/resources/worldconfig.ini index 0b15973d..7f296afe 100644 --- a/resources/worldconfig.ini +++ b/resources/worldconfig.ini @@ -61,6 +61,7 @@ allow_nameplate_off=0 # Turn logging of IP addresses for anti-cheat reporting on (1) or off(0) log_ip_addresses_for_anti_cheat=1 +# These are the 5 items items that are shown in the "Help" menu in-game along with their coresponding descriptions below. help_0_summary=Got an issue? help_1_summary=Stuck loading? help_2_summary=Missing features? @@ -72,3 +73,6 @@ help_1_description=Try switching networks, using a VPN, or using your phone's ho help_2_description=While DarkflameServer is a mostly complete emulator, there are still some features that aren't implemented. You can track these on the GitHub issues page.

help_3_description=Skill issue!

help_4_description=Visit Discussions on the DarkflameServer GitHub page
to ask questions and collaborate with other devs!

+ +# Toggleable quality of life feature to allow users to skip most cinematics. +allow_players_to_skip_cinematics=0