From a5d0788488dd2997be9b68eeddd82c1bbdb964c1 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 29 Jun 2025 14:18:59 -0700 Subject: [PATCH] feat: barfight (#1839) --- dGame/dUtilities/SlashCommandHandler.cpp | 12 ++++++++++-- dGame/dUtilities/SlashCommands/DEVGMCommands.cpp | 13 +++++++++++++ dGame/dUtilities/SlashCommands/DEVGMCommands.h | 1 + docs/Commands.md | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index b79c0c2c..ffa9ff8e 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -1445,12 +1445,20 @@ void SlashCommandHandler::Startup() { }; RegisterCommand(removeIgnoreCommand); - Command shutdownCommand{ + Command command{ .help = "Shuts this world down", .info = "Shuts this world down", .aliases = {"shutdown"}, .handle = DEVGMCommands::Shutdown, .requiredLevel = eGameMasterLevel::DEVELOPER }; - RegisterCommand(shutdownCommand); + RegisterCommand(command); + + RegisterCommand({ + .help = "Turns all players' pvp mode on", + .info = "Turns all players' pvp mode on", + .aliases = {"barfight"}, + .handle = DEVGMCommands::Barfight, + .requiredLevel = eGameMasterLevel::DEVELOPER + }); } diff --git a/dGame/dUtilities/SlashCommands/DEVGMCommands.cpp b/dGame/dUtilities/SlashCommands/DEVGMCommands.cpp index a4ca77d3..be2b80be 100644 --- a/dGame/dUtilities/SlashCommands/DEVGMCommands.cpp +++ b/dGame/dUtilities/SlashCommands/DEVGMCommands.cpp @@ -1633,4 +1633,17 @@ namespace DEVGMCommands { if (character) LOG("Mythran (%s) has shutdown the world", character->GetName().c_str()); Game::OnSignal(-1); } + + void Barfight(Entity* entity, const SystemAddress& sysAddr, const std::string args) { + auto* const characterComponent = entity->GetComponent(); + if (!characterComponent) return; + + for (auto* const player : PlayerManager::GetAllPlayers()) { + auto* const pCharacterComponent = player->GetComponent(); + if (pCharacterComponent) pCharacterComponent->SetPvpEnabled(args == "start"); + Game::entityManager->SerializeEntity(player); + } + const auto msg = u"Pvp has been turned on for all players by " + GeneralUtils::ASCIIToUTF16(characterComponent->GetName()); + ChatPackets::SendSystemMessage(UNASSIGNED_SYSTEM_ADDRESS, msg, true); + } }; diff --git a/dGame/dUtilities/SlashCommands/DEVGMCommands.h b/dGame/dUtilities/SlashCommands/DEVGMCommands.h index 811979f9..a583342d 100644 --- a/dGame/dUtilities/SlashCommands/DEVGMCommands.h +++ b/dGame/dUtilities/SlashCommands/DEVGMCommands.h @@ -74,6 +74,7 @@ namespace DEVGMCommands { void CastSkill(Entity* entity, const SystemAddress& sysAddr, const std::string args); void DeleteInven(Entity* entity, const SystemAddress& sysAddr, const std::string args); void Shutdown(Entity* entity, const SystemAddress& sysAddr, const std::string args); + void Barfight(Entity* entity, const SystemAddress& sysAddr, const std::string args); } #endif //!DEVGMCOMMANDS_H diff --git a/docs/Commands.md b/docs/Commands.md index a0272c22..d9bacf70 100644 --- a/docs/Commands.md +++ b/docs/Commands.md @@ -114,6 +114,7 @@ These commands are primarily for development and testing. The usage of many of t |addfaction|`/addfaction `|Add the faction to the users list of factions|8| |getfactions|`/getfactions`|Shows the player's factions|8| |setrewardcode|`/setrewardcode `|Sets the rewardcode for the account you are logged into if it's a valid rewardcode, See cdclient table `RewardCodes`|8| +|barfight|`/barfight start`|Starts a barfight (turns everyones pvp on)|8| |crash|`/crash`|Crashes the server.|9| |rollloot|`/rollloot `|Given a `loot matrix index`, look for `item id` in that matrix `amount` times and print to the chat box statistics of rolling that loot matrix.|9| |castskill|`/castskill `|Casts the skill as the player|9|