From fcf0bf08432f2c247c83df91da4d08290988136e Mon Sep 17 00:00:00 2001 From: Naruse <71993948+DevilProMT@users.noreply.github.com> Date: Wed, 29 Apr 2026 16:00:10 +0800 Subject: [PATCH] add call item --- Common/Data/Excel/CallItemExcel.cs | 24 +++++++++++++ Common/Data/GameData.cs | 1 + .../Message/LanguageCHS.cs | 4 ++- .../Message/LanguageCHT.cs | 4 ++- .../Message/LanguageEN.cs | 4 ++- GameServer/Command/Commands/CommandGiveAll.cs | 36 +++++++++++++++++++ GameServer/Game/Inventory/InventoryManager.cs | 21 +++++++++++ 7 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 Common/Data/Excel/CallItemExcel.cs diff --git a/Common/Data/Excel/CallItemExcel.cs b/Common/Data/Excel/CallItemExcel.cs new file mode 100644 index 0000000..2c1fb60 --- /dev/null +++ b/Common/Data/Excel/CallItemExcel.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace MikuSB.Data.Excel; + +[ResourceEntity("call_item.json")] +public class CallItemExcel : ExcelResource +{ + public uint Genre { get; set; } + public uint Detail { get; set; } + public uint Particular { get; set; } + public uint Level { get; set; } + public string I18n { get; set; } = ""; + + public override uint GetId() + { + return (uint)I18n.GetHashCode(); + } + + public override void Loaded() + { + GameData.CallItemData.Add(GetId(), this); + } +} diff --git a/Common/Data/GameData.cs b/Common/Data/GameData.cs index b1d9454..1a90c0c 100644 --- a/Common/Data/GameData.cs +++ b/Common/Data/GameData.cs @@ -24,6 +24,7 @@ public static class GameData public static Dictionary DailyLevelData { get; private set; } = []; public static Dictionary ProfileData { get; private set; } = []; public static Dictionary CardSkinPartsData { get; private set; } = []; + public static Dictionary CallItemData { get; private set; } = []; } public static class GameResourceTemplateId diff --git a/Common/Internationalization/Message/LanguageCHS.cs b/Common/Internationalization/Message/LanguageCHS.cs index 67821b0..f9f5ac4 100644 --- a/Common/Internationalization/Message/LanguageCHS.cs +++ b/Common/Internationalization/Message/LanguageCHS.cs @@ -35,6 +35,7 @@ public class ServerTextCHS /// public class WordTextCHS { + public string CallItem => "召唤道具"; public string SkinPart => "皮肤部件"; public string Profile => "个人资料"; public string WeaponSkin => "武器皮肤"; @@ -244,7 +245,8 @@ public class GiveAllTextCHS "用法:/giveall weaponskin -p<特定>\n" + "用法:/giveall card -p<特定> -l<等級>" + "用法:/giveall profile -g<类型> -p<特定> -l<等级>" + - "用法:/giveall skinpart -g<類型> -p<特定> -l<等級>"; + "用法:/giveall skinpart -g<類型> -p<特定> -l<等級>" + + "用法:/giveall call -g<類型> -p<特定> -l<等級>"; public string NotFound => "未找到 {0}!"; public string GiveAllItems => "已向玩家添加 {0} 个 {1}!"; } diff --git a/Common/Internationalization/Message/LanguageCHT.cs b/Common/Internationalization/Message/LanguageCHT.cs index a1ea46e..8ad0653 100644 --- a/Common/Internationalization/Message/LanguageCHT.cs +++ b/Common/Internationalization/Message/LanguageCHT.cs @@ -35,6 +35,7 @@ public class ServerTextCHT /// public class WordTextCHT { + public string CallItem => "召喚道具"; public string SkinPart => "外觀部件"; public string Profile => "個人資料"; public string WeaponSkin => "武器外觀"; @@ -244,7 +245,8 @@ public class GiveAllTextCHT "用法:/giveall weaponskin -p<特定>\n" + "用法:/giveall card -p<特定> -l<等級>" + "用法:/giveall profile -g<類型> -p<特定> -l<等級>" + - "用法:/giveall skinpart -g<類型> -p<特定> -l<等級>"; + "用法:/giveall skinpart -g<類型> -p<特定> -l<等級>" + + "用法:/giveall call -g<類型> -p<特定> -l<等級>"; public string NotFound => "未找到 {0}!"; public string GiveAllItems => "已向玩家添加 {0} 個 {1}!"; } diff --git a/Common/Internationalization/Message/LanguageEN.cs b/Common/Internationalization/Message/LanguageEN.cs index 2eb8279..03d4f66 100644 --- a/Common/Internationalization/Message/LanguageEN.cs +++ b/Common/Internationalization/Message/LanguageEN.cs @@ -35,6 +35,7 @@ public class ServerTextEN /// public class WordTextEN { + public string CallItem => "Call Item"; public string SkinPart => "Skin Part"; public string Profile => "Profile"; public string WeaponSkin => "Weapon Skin"; @@ -210,7 +211,8 @@ public class GiveAllTextEN "Usage: /giveall weaponskin -p\n" + "Usage: /giveall card -p -l" + "Usage: /giveall profile -g -p -l" + - "Usage: /giveall skinpart -g -p -l"; + "Usage: /giveall skinpart -g -p -l" + + "Usage: /giveall call -g -p -l"; public string NotFound => "{0} not found!"; public string GiveAllItems => "Added {0} {1} to player!"; } diff --git a/GameServer/Command/Commands/CommandGiveAll.cs b/GameServer/Command/Commands/CommandGiveAll.cs index b2cd3a0..161fae9 100644 --- a/GameServer/Command/Commands/CommandGiveAll.cs +++ b/GameServer/Command/Commands/CommandGiveAll.cs @@ -186,4 +186,40 @@ public class CommandGiveAll : ICommands await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems", I18NManager.Translate("Word.SkinPart"), skinPartItems.Count.ToString())); } + + [CommandMethod("call")] + public async ValueTask GiveAllCallItem(CommandArg arg) + { + if (!await arg.CheckOnlineTarget()) return; + if (await arg.GetOption('p') is not int particular) return; + if (await arg.GetOption('l') is not int level) return; + if (await arg.GetOption('g') is not int genre) return; + + var detail = arg.GetInt(0); + var player = arg.Target!.Player!; + List callItems = []; + if (detail == -1) + { + // add all + foreach (var config in GameData.CallItemData.Values) + { + var callItem = await player.InventoryManager! + .AddCallItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, config.Level, false); + if (callItem != null) callItems.Add(callItem); + } + } + else + { + var callItem = await player.InventoryManager!.AddCallItem((ItemTypeEnum)genre, (uint)detail, (uint)particular, (uint)level, false); + if (callItem == null) + { + await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.CallItem"))); + return; + } + callItems.Add(callItem); + } + if (callItems.Count > 0) await player.SendPacket(new PacketNtfCallScript(callItems)); + await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems", + I18NManager.Translate("Word.CallItem"), callItems.Count.ToString())); + } } \ No newline at end of file diff --git a/GameServer/Game/Inventory/InventoryManager.cs b/GameServer/Game/Inventory/InventoryManager.cs index 19f826f..27a8915 100644 --- a/GameServer/Game/Inventory/InventoryManager.cs +++ b/GameServer/Game/Inventory/InventoryManager.cs @@ -291,4 +291,25 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player) return skinPartInfo; } + + public async ValueTask AddCallItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true) + { + if (genre != ItemTypeEnum.TYPE_CALL) return null; + var callData = GameData.CallItemData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level); + if (callData == null) return null; + var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level); + if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null; + var callInfo = new BaseGameItemInfo + { + TemplateId = templateId, + UniqueId = InventoryData.NextUniqueUid++, + ItemType = genre, + ItemCount = 1 + }; + InventoryData.Items[callInfo.UniqueId] = callInfo; + + if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([callInfo])); + + return callInfo; + } } \ No newline at end of file