Skip to content

Commit

Permalink
Cinematics: Add ability to toggle skipping them
Browse files Browse the repository at this point in the history
  • Loading branch information
EmosewaMC committed Nov 20, 2023
1 parent 98dc291 commit 79f9806
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
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
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 79f9806

Please sign in to comment.