add call item

This commit is contained in:
Naruse
2026-04-29 16:00:10 +08:00
parent 50121d619b
commit fcf0bf0843
7 changed files with 91 additions and 3 deletions

View File

@@ -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);
}
}

View File

@@ -24,6 +24,7 @@ public static class GameData
public static Dictionary<uint, DailyLevelExcel> DailyLevelData { get; private set; } = [];
public static Dictionary<uint, ProfileExcel> ProfileData { get; private set; } = [];
public static Dictionary<uint, CardSkinPartsExcel> CardSkinPartsData { get; private set; } = [];
public static Dictionary<uint, CallItemExcel> CallItemData { get; private set; } = [];
}
public static class GameResourceTemplateId

View File

@@ -35,6 +35,7 @@ public class ServerTextCHS
/// </summary>
public class WordTextCHS
{
public string CallItem => "召唤道具";
public string SkinPart => "皮肤部件";
public string Profile => "个人资料";
public string WeaponSkin => "武器皮肤";
@@ -244,7 +245,8 @@ public class GiveAllTextCHS
"用法:/giveall weaponskin <detail/-1> -p<特定>\n" +
"用法:/giveall card <detail/-1> -p<特定> -l<等級>" +
"用法:/giveall profile <detail/-1> -g<类型> -p<特定> -l<等级>" +
"用法:/giveall skinpart <detail/-1> -g<類型> -p<特定> -l<等級>";
"用法:/giveall skinpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
"用法:/giveall call <detail/-1> -g<類型> -p<特定> -l<等級>";
public string NotFound => "未找到 {0}";
public string GiveAllItems => "已向玩家添加 {0} 个 {1}";
}

View File

@@ -35,6 +35,7 @@ public class ServerTextCHT
/// </summary>
public class WordTextCHT
{
public string CallItem => "召喚道具";
public string SkinPart => "外觀部件";
public string Profile => "個人資料";
public string WeaponSkin => "武器外觀";
@@ -244,7 +245,8 @@ public class GiveAllTextCHT
"用法:/giveall weaponskin <detail/-1> -p<特定>\n" +
"用法:/giveall card <detail/-1> -p<特定> -l<等級>" +
"用法:/giveall profile <detail/-1> -g<類型> -p<特定> -l<等級>" +
"用法:/giveall skinpart <detail/-1> -g<類型> -p<特定> -l<等級>";
"用法:/giveall skinpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
"用法:/giveall call <detail/-1> -g<類型> -p<特定> -l<等級>";
public string NotFound => "未找到 {0}";
public string GiveAllItems => "已向玩家添加 {0} 個 {1}";
}

View File

@@ -35,6 +35,7 @@ public class ServerTextEN
/// </summary>
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 <detail/-1> -p<particular>\n" +
"Usage: /giveall card <detail/-1> -p<particular> -l<level>" +
"Usage: /giveall profile <detail/-1> -g<genre> -p<particular> -l<level>" +
"Usage: /giveall skinpart <detail/-1> -g<genre> -p<particular> -l<level>";
"Usage: /giveall skinpart <detail/-1> -g<genre> -p<particular> -l<level>" +
"Usage: /giveall call <detail/-1> -g<genre> -p<particular> -l<level>";
public string NotFound => "{0} not found!";
public string GiveAllItems => "Added {0} {1} to player!";
}

View File

@@ -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<BaseGameItemInfo> 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()));
}
}

View File

@@ -291,4 +291,25 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
return skinPartInfo;
}
public async ValueTask<BaseGameItemInfo?> 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;
}
}