Skip to content

Commit

Permalink
feat: Add ability to toggle skipping of cinematics (#1312)
Browse files Browse the repository at this point in the history
* Cinematics: Add ability to toggle skipping them

* Add docs

* Move sections
  • Loading branch information
EmosewaMC authored Nov 22, 2023
1 parent 1a19915 commit 9c5388c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dCommon/dEnums/ePlayerFlag.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
9 changes: 9 additions & 0 deletions dGame/dGameMessages/GameMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "eMissionTaskType.h"
#include "eReplicaComponentType.h"
#include "eConnectionType.h"
#include "ePlayerFlag.h"
#include "dConfig.h"

using namespace std;

Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 9 additions & 0 deletions dGame/dGameMessages/GameMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "eControlScheme.h"
#include "eStateChangeType.h"
#include "eConnectionType.h"
#include "ePlayerFlag.h"

#include <sstream>
#include <future>
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 16 additions & 0 deletions dGame/dUtilities/SlashCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
3 changes: 2 additions & 1 deletion docs/Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 <password>`|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.||
Expand Down
4 changes: 4 additions & 0 deletions resources/worldconfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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.<br/><br/>
help_3_description=Skill issue!<br/><br/>
help_4_description=Visit Discussions on the DarkflameServer GitHub page<br/>to ask questions and collaborate with other devs!<br/><br/>

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

0 comments on commit 9c5388c

Please sign in to comment.