From 024f2f4cbdd1a89fe4863e7fed101cfdc02c7eeb Mon Sep 17 00:00:00 2001 From: Crypto137 Date: Tue, 24 Jun 2025 23:59:26 +0300 Subject: [PATCH] Separate default costume functionality from the !player costume command --- docs/ServerEmu/ServerCommands.md | 18 +++---- .../Implementations/PlayerCommands.cs | 48 +++++++++++++++++-- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/docs/ServerEmu/ServerCommands.md b/docs/ServerEmu/ServerCommands.md index c95a7efa..d28215ab 100644 --- a/docs/ServerEmu/ServerCommands.md +++ b/docs/ServerEmu/ServerCommands.md @@ -1,6 +1,6 @@ # Server Commands -This list was automatically generated on `2025.06.23 01:11:09 UTC` using server version `0.7.0`. +This list was automatically generated on `2025.06.24 20:56:10 UTC` using server version `0.7.0`. To see an up to date list of all commands, type !commands in the server console or the in-game chat. When invoking a command from in-game your account has to meet the user level requirement for the command. @@ -85,6 +85,7 @@ Entity management commands. | !entity isblocked [EntityId1] [EntityId2] | No description available. | Any | Client | | !entity marker [MarkerId] | Displays information about the specified marker. | Any | Client | | !entity near [radius] | Displays all entities in a radius (default is 100). | Any | Client | +| !entity selector [pattern] | Create row entities near the avatar based on selector pattern (ignore the case). | Admin | Client | | !entity tp [pattern] | Teleports to the first entity present in the region which prototype name contains the string given (ignore the case). | Admin | Client | ## Instance @@ -171,13 +172,14 @@ Commands related to the mission system. ## Player Commands for managing player data for the invoker's account. -| Command | Description | User Level | Invoker Type | -| ------------------------------------ | ------------------------------------------------------- | ---------- | ------------ | -| !player clearconditions | Clears persistent conditions. | Any | Client | -| !player costume [name/reset/default] | Changes costume for the current avatar. | Any | Client | -| !player die | Kills the current avatar. | Any | Client | -| !player givecurrency [amount] | Gives all currencies. | Admin | Client | -| !player wipe [playerName] | Wipes all progress associated with the current account. | Any | Client | +| Command | Description | User Level | Invoker Type | +| ----------------------------- | ----------------------------------------------------------------------------------------- | ---------- | ------------ | +| !player clearconditions | Clears persistent conditions. | Any | Client | +| !player costume [name/reset] | Changes costume for the current avatar. | Admin | Client | +| !player die | Kills the current avatar. | Any | Client | +| !player disablevu | Forces the fallback costume for the current hero, reverting visual updates in some cases. | Any | Client | +| !player givecurrency [amount] | Gives all currencies. | Admin | Client | +| !player wipe [playerName] | Wipes all progress associated with the current account. | Any | Client | ## Power Commands related to the power system. diff --git a/src/MHServerEmu/Commands/Implementations/PlayerCommands.cs b/src/MHServerEmu/Commands/Implementations/PlayerCommands.cs index a13fb874..b0a87df5 100644 --- a/src/MHServerEmu/Commands/Implementations/PlayerCommands.cs +++ b/src/MHServerEmu/Commands/Implementations/PlayerCommands.cs @@ -3,6 +3,8 @@ using MHServerEmu.Core.Network; using MHServerEmu.DatabaseAccess.Models; using MHServerEmu.Games.Entities; using MHServerEmu.Games.Entities.Avatars; +using MHServerEmu.Games.Entities.Inventories; +using MHServerEmu.Games.Entities.Items; using MHServerEmu.Games.GameData; using MHServerEmu.Games.GameData.Calligraphy; using MHServerEmu.Games.GameData.Prototypes; @@ -19,7 +21,8 @@ namespace MHServerEmu.Commands.Implementations { [Command("costume")] [CommandDescription("Changes costume for the current avatar.")] - [CommandUsage("player costume [name|reset|default]")] + [CommandUsage("player costume [name|reset]")] + [CommandUserLevel(AccountUserLevel.Admin)] [CommandInvokerType(CommandInvokerType.Client)] [CommandParamCount(1)] public string Costume(string[] @params, NetClient client) @@ -32,10 +35,6 @@ namespace MHServerEmu.Commands.Implementations costumeProtoRef = PrototypeId.Invalid; break; - case "default": // This undoes visual updates for most heroes - costumeProtoRef = (PrototypeId)HardcodedBlueprints.Costume; - break; - default: var matches = GameDatabase.SearchPrototypes(@params[0], DataFileSearchFlags.SortMatchesByName | DataFileSearchFlags.CaseInsensitive, HardcodedBlueprints.Costume); @@ -65,6 +64,45 @@ namespace MHServerEmu.Commands.Implementations return $"Changing costume to {GameDatabase.GetPrototypeName(costumeProtoRef)}."; } + [Command("disablevu")] + [CommandDescription("Forces the fallback costume for the current hero, reverting visual updates in some cases.")] + [CommandInvokerType(CommandInvokerType.Client)] + public string DisableVU(string[] @params, NetClient client) + { + PlayerConnection playerConnection = (PlayerConnection)client; + Player player = playerConnection.Player; + Avatar avatar = player.CurrentAvatar; + + if (avatar == null) + return "Avatar is not available."; + + PrototypeId costumeProtoRef = PrototypeId.Invalid; + string result; + + if (avatar.EquippedCostumeRef != (PrototypeId)HardcodedBlueprints.Costume) + { + // Apply fallback costume override + costumeProtoRef = (PrototypeId)HardcodedBlueprints.Costume; + result = "Applied fallback costume override."; + } + else + { + // Revert fallback costume override if it is currently applied + Inventory costumeInv = avatar.GetInventory(InventoryConvenienceLabel.Costume); + if (costumeInv != null && costumeInv.Count > 0) + { + Item costume = avatar.Game.EntityManager.GetEntity(costumeInv.GetAnyEntity()); + if (costume != null) + costumeProtoRef = costume.PrototypeDataRef; + } + + result = "Reverted fallback costume override."; + } + + avatar.ChangeCostume(costumeProtoRef); + return result; + } + [Command("wipe")] [CommandDescription("Wipes all progress associated with the current account.")] [CommandUsage("player wipe [playerName]")]