Fix Basic Rogue Event

This commit is contained in:
Somebody
2024-08-10 15:16:29 +08:00
parent fe7c51c996
commit b8e7b41d5e
37 changed files with 225 additions and 101 deletions

View File

@@ -1,5 +0,0 @@
namespace EggLink.DanhengServer.Data.Config;
public class AnchorInfo : PositionInfo
{
}

View File

@@ -0,0 +1,62 @@
using EggLink.DanhengServer.Internationalization;
using EggLink.DanhengServer.Util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueDialogueBaseConfigInfo
{
public string OptionPath { get; set; } = string.Empty;
public string DialoguePath { get; set; } = string.Empty;
public LevelGraphConfigInfo? DialogueInfo { get; set; }
public RogueDialogueEventConfigInfo? OptionInfo { get; set; }
public void Loaded()
{
var logger = Logger.GetByClassName();
if (!string.IsNullOrEmpty(OptionPath))
{
var path = ConfigManager.Config.Path.ResourcePath + "/" + OptionPath;
var file = new FileInfo(path);
if (!file.Exists) return;
try
{
using var reader = file.OpenRead();
using StreamReader reader2 = new(reader);
var text = reader2.ReadToEnd();
var info = JsonConvert.DeserializeObject<RogueDialogueEventConfigInfo>(text);
OptionInfo = info;
}
catch (Exception ex)
{
logger.Error(
I18nManager.Translate("Server.ServerInfo.FailedToReadItem", file.Name,
I18nManager.Translate("Word.Error")), ex);
}
}
if (!string.IsNullOrEmpty(DialoguePath))
{
var path = ConfigManager.Config.Path.ResourcePath + "/" + DialoguePath;
var file = new FileInfo(path);
if (!file.Exists) return;
try
{
using var reader = file.OpenRead();
using StreamReader reader2 = new(reader);
var text = reader2.ReadToEnd().Replace("$type", "Type");
var obj = JObject.Parse(text);
var info = LevelGraphConfigInfo.LoadFromJsonObject(obj);
DialogueInfo = info;
}
catch (Exception ex)
{
logger.Error(
I18nManager.Translate("Server.ServerInfo.FailedToReadItem", file.Name,
I18nManager.Translate("Word.Error")), ex);
}
}
}
}

View File

@@ -0,0 +1,6 @@
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueDialogueEventConfigInfo
{
public List<RogueDialogueEventOptionConfigInfo> OptionList { get; set; } = [];
}

View File

@@ -0,0 +1,13 @@
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueDialogueEventOptionConfigInfo
{
public int OptionID { get; set; }
public int DisplayID { get; set; }
public int SpecialOptionID { get; set; }
public Dictionary<int, RogueDialogueEventOptionDynamicConfigInfo> DynamicMap { get; set; } = [];
public int DescValue { get; set; }
public int DescValue2 { get; set; }
public int DescValue3 { get; set; }
public int DescValue4 { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueDialogueEventOptionDynamicConfigInfo
{
public int DisplayID { get; set; }
public int DisplayID2 { get; set; }
}

View File

@@ -0,0 +1,22 @@
using EggLink.DanhengServer.Enums.Rogue;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueNPCConfigInfo
{
[JsonConverter(typeof(StringEnumConverter))]
public RogueDialogueTypeEnum DialogueType { get; set; }
public List<RogueNPCDialogueConfigInfo> DialogueList { get; set; } = [];
public void Loaded()
{
if (DialogueList.Count == 0) return;
foreach (var info in DialogueList)
{
info.Loaded();
}
}
}

View File

@@ -0,0 +1,8 @@
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueNPCDialogueConfigInfo : RogueDialogueBaseConfigInfo
{
public int DialogueProgress { get; set; }
public int UnlockID { get; set; }
public int TalkNameID { get; set; }
}

View File

@@ -0,0 +1,5 @@
namespace EggLink.DanhengServer.Data.Config.Scene;
public class AnchorInfo : PositionInfo
{
}

View File

@@ -1,7 +1,7 @@
using EggLink.DanhengServer.Enums.Scene;
using Newtonsoft.Json;
namespace EggLink.DanhengServer.Data.Config;
namespace EggLink.DanhengServer.Data.Config.Scene;
public class FloorInfo
{
@@ -42,35 +42,35 @@ public class FloorInfo
// Cache anchors
foreach (var group in Groups.Values)
foreach (var prop in group.PropList)
// Check if prop can be teleported to
if (prop.AnchorID > 0)
{
// Put inside cached teleport list to send to client when they request map info
CachedTeleports.TryAdd(prop.MappingInfoID, prop);
UnlockedCheckpoints.Add(prop);
// Force prop to be in the unlocked state
prop.State = PropStateEnum.CheckPointEnable;
}
else if (!string.IsNullOrEmpty(prop.InitLevelGraph))
{
var json = prop.InitLevelGraph;
// Hacky way to setup prop triggers
if (json.Contains("Maze_GroupProp_OpenTreasure_WhenMonsterDie"))
foreach (var prop in group.PropList)
// Check if prop can be teleported to
if (prop.AnchorID > 0)
{
//prop.Trigger = new TriggerOpenTreasureWhenMonsterDie(group.Id);
}
else if (json.Contains("Common_Console"))
{
prop.CommonConsole = true;
}
// Put inside cached teleport list to send to client when they request map info
CachedTeleports.TryAdd(prop.MappingInfoID, prop);
UnlockedCheckpoints.Add(prop);
// Clear for garbage collection
prop.ValueSource = null;
prop.InitLevelGraph = null;
}
// Force prop to be in the unlocked state
prop.State = PropStateEnum.CheckPointEnable;
}
else if (!string.IsNullOrEmpty(prop.InitLevelGraph))
{
var json = prop.InitLevelGraph;
// Hacky way to setup prop triggers
if (json.Contains("Maze_GroupProp_OpenTreasure_WhenMonsterDie"))
{
//prop.Trigger = new TriggerOpenTreasureWhenMonsterDie(group.Id);
}
else if (json.Contains("Common_Console"))
{
prop.CommonConsole = true;
}
// Clear for garbage collection
prop.ValueSource = null;
prop.InitLevelGraph = null;
}
Loaded = true;
}

View File

@@ -6,7 +6,7 @@ using EggLink.DanhengServer.Util;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace EggLink.DanhengServer.Data.Config;
namespace EggLink.DanhengServer.Data.Config.Scene;
public class GroupInfo
{

View File

@@ -1,4 +1,4 @@
namespace EggLink.DanhengServer.Data.Config;
namespace EggLink.DanhengServer.Data.Config.Scene;
public class MonsterInfo : PositionInfo
{

View File

@@ -1,4 +1,4 @@
namespace EggLink.DanhengServer.Data.Config;
namespace EggLink.DanhengServer.Data.Config.Scene;
public class NpcInfo : PositionInfo
{

View File

@@ -1,6 +1,6 @@
using EggLink.DanhengServer.Util;
namespace EggLink.DanhengServer.Data.Config;
namespace EggLink.DanhengServer.Data.Config.Scene;
public class PositionInfo
{

View File

@@ -3,7 +3,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
namespace EggLink.DanhengServer.Data.Config;
namespace EggLink.DanhengServer.Data.Config.Scene;
public class PropInfo : PositionInfo
{

View File

@@ -1,31 +0,0 @@
using EggLink.DanhengServer.Data.Config;
using Newtonsoft.Json;
namespace EggLink.DanhengServer.Data.Excel;
[ResourceEntity("RogueNPCDialogue.json")]
public class RogueNPCDialogueExcel : ExcelResource
{
public int RogueNPCID { get; set; }
public int DialogueProgress { get; set; }
public int HandbookEventID { get; set; }
public string DialoguePath { get; set; } = "";
[JsonIgnore] public DialogueInfo? DialogueInfo { get; set; }
public override int GetId()
{
return RogueNPCID * 100 + DialogueProgress;
}
public override void Loaded()
{
GameData.RogueNPCDialogueData.Add(GetId(), this);
}
public bool CanUseInVer(int version)
{
GameData.RogueHandBookEventData.TryGetValue(HandbookEventID, out var handbookEvent);
return DialogueInfo != null && handbookEvent != null && handbookEvent.EventTypeList.Contains(version);
}
}

View File

@@ -0,0 +1,28 @@
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Rogue;
namespace EggLink.DanhengServer.Data.Excel;
[ResourceEntity("RogueNPC.json")]
public class RogueNPCExcel : ExcelResource
{
public int RogueNPCID { get; set; }
public string NPCJsonPath { get; set; } = string.Empty;
public RogueNPCConfigInfo? RogueNpcConfig { get; set; }
public override int GetId()
{
return RogueNPCID;
}
public override void Loaded()
{
GameData.RogueNPCData.TryAdd(RogueNPCID, this);
}
public bool CanUseInVer(int version)
{
return RogueNpcConfig != null;
}
}

View File

@@ -1,4 +1,4 @@
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Custom;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Enums.Rogue;
@@ -201,7 +201,7 @@ public static class GameData
public static Dictionary<int, List<int>> RogueMiracleGroupData { get; set; } = [];
public static Dictionary<int, RogueMiracleDisplayExcel> RogueMiracleDisplayData { get; private set; } = [];
public static Dictionary<int, RogueMonsterExcel> RogueMonsterData { get; private set; } = [];
public static Dictionary<int, RogueNPCDialogueExcel> RogueNPCDialogueData { get; private set; } = [];
public static Dictionary<int, RogueNPCExcel> RogueNPCData { get; private set; } = [];
public static Dictionary<int, RogueRoomExcel> RogueRoomData { get; private set; } = [];
public static Dictionary<int, RogueTalentExcel> RogueTalentData { get; private set; } = [];

View File

@@ -1,5 +1,7 @@
using System.Reflection;
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Rogue;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Custom;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Enums.Rogue;
@@ -361,9 +363,9 @@ public class ResourceManager
{
Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadingItem", I18nManager.Translate("Word.DialogueInfo")));
var count = 0;
foreach (var dialogue in GameData.RogueNPCDialogueData)
foreach (var dialogue in GameData.RogueNPCData)
{
var path = ConfigManager.Config.Path.ResourcePath + "/" + dialogue.Value.DialoguePath;
var path = ConfigManager.Config.Path.ResourcePath + "/" + dialogue.Value.NPCJsonPath;
var file = new FileInfo(path);
if (!file.Exists) continue;
try
@@ -371,14 +373,11 @@ public class ResourceManager
using var reader = file.OpenRead();
using StreamReader reader2 = new(reader);
var text = reader2.ReadToEnd().Replace("$type", "Type");
var dialogueInfo = JsonConvert.DeserializeObject<DialogueInfo>(text);
var dialogueInfo = JsonConvert.DeserializeObject<RogueNPCConfigInfo>(text);
if (dialogueInfo != null)
{
dialogue.Value.DialogueInfo = dialogueInfo;
dialogue.Value.RogueNpcConfig = dialogueInfo;
dialogueInfo.Loaded();
if (dialogueInfo.DialogueIds.Count == 0)
// set to invalid
dialogue.Value.DialogueInfo = null;
count++;
}
}
@@ -390,7 +389,7 @@ public class ResourceManager
}
}
if (count < GameData.RogueNPCDialogueData.Count)
if (count < GameData.RogueNPCData.Count)
Logger.Warn(I18nManager.Translate("Server.ServerInfo.ConfigMissing",
I18nManager.Translate("Word.DialogueInfo"),
$"{ConfigManager.Config.Path.ResourcePath}/Config/Level/Rogue/Dialogue",

View File

@@ -0,0 +1,9 @@
namespace EggLink.DanhengServer.Enums.Rogue;
public enum RogueDialogueTypeEnum
{
None = 0,
Story = 1,
Event = 2,
Store = 3
}

View File

@@ -1,5 +1,5 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Enums.Scene;
using EggLink.DanhengServer.GameServer.Game.Player;

View File

@@ -1,5 +1,5 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Enums.Scene;
using EggLink.DanhengServer.GameServer.Game.Player;

View File

@@ -1,5 +1,5 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Enums.Rogue;
using EggLink.DanhengServer.Enums.Scene;

View File

@@ -1,5 +1,5 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Enums.Scene;
using EggLink.DanhengServer.GameServer.Game.Scene;

View File

@@ -359,10 +359,10 @@ public abstract class BaseRogueInstance(PlayerInstance player, int rogueVersionI
public async ValueTask<RogueEventInstance> GenerateEvent(RogueNpc npc)
{
RogueNPCDialogueExcel? dialogue;
RogueNPCExcel? dialogue;
do
{
dialogue = GameData.RogueNPCDialogueData.Values.ToList().RandomElement();
dialogue = GameData.RogueNPCData.Values.ToList().RandomElement();
} while (!dialogue.CanUseInVer(RogueType));
var instance = new RogueEventInstance(dialogue, npc, CurEventUniqueID++);

View File

@@ -8,12 +8,12 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event;
public class RogueEventInstance(int eventId, RogueNpc npc, List<RogueEventParam> optionIds, int uniqueId)
{
public RogueEventInstance(RogueNPCDialogueExcel excel, RogueNpc npc, int uniqueId) : this(excel.RogueNPCID, npc, [],
public RogueEventInstance(RogueNPCExcel excel, RogueNpc npc, int uniqueId) : this(excel.RogueNPCID, npc, [],
uniqueId) // check in RogueInstance.cs
{
foreach (var option in excel.DialogueInfo!.DialogueIds)
foreach (var option in excel.RogueNpcConfig!.DialogueList[0].OptionInfo?.OptionList ?? [])
{
GameData.DialogueEventData.TryGetValue(option, out var dialogueEvent);
GameData.DialogueEventData.TryGetValue(option.OptionID, out var dialogueEvent);
if (dialogueEvent == null) continue;
var argId = 0;
@@ -25,7 +25,7 @@ public class RogueEventInstance(int eventId, RogueNpc npc, List<RogueEventParam>
Options.Add(new RogueEventParam
{
OptionId = option,
OptionId = option.OptionID,
ArgId = argId
});
}

View File

@@ -108,8 +108,7 @@ public class RogueEventManager
await Player.SendPacket(new PacketSelectRogueCommonDialogueOptionScRsp());
return;
}
option.IsSelected = true;
await Player.SendPacket(new PacketSyncRogueCommonDialogueDataScNotify(eventInstance));
var param = dialogueEvent.RogueEffectParamList;
if (option.ArgId > 0)
@@ -138,6 +137,7 @@ public class RogueEventManager
// send rsp
await Player.SendPacket(new PacketSyncRogueCommonDialogueOptionFinishScNotify(eventInstance));
option.IsSelected = true;
await Player.SendPacket(new PacketSelectRogueCommonDialogueOptionScRsp(eventInstance));
}
}

View File

@@ -1,4 +1,4 @@
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.GameServer.Game.Rogue.Event;
using EggLink.DanhengServer.GameServer.Game.Scene;
using EggLink.DanhengServer.GameServer.Game.Scene.Entity;

View File

@@ -1,4 +1,4 @@
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.GameServer.Game.Scene;
using EggLink.DanhengServer.GameServer.Game.Scene.Entity;

View File

@@ -1,5 +1,5 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Enums.Scene;
using EggLink.DanhengServer.GameServer.Game.Player;
using EggLink.DanhengServer.GameServer.Game.Rogue.Scene.Entity;

View File

@@ -1,5 +1,5 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Database.Inventory;
using EggLink.DanhengServer.Enums.Mission;

View File

@@ -1,4 +1,4 @@
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.GameServer.Game.Battle;
using EggLink.DanhengServer.Proto;
using EggLink.DanhengServer.Util;

View File

@@ -1,4 +1,4 @@
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Enums.Scene;
using EggLink.DanhengServer.GameServer.Game.Battle;

View File

@@ -1,5 +1,5 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Enums;
using EggLink.DanhengServer.Enums.Mission;
using EggLink.DanhengServer.Enums.Scene;

View File

@@ -1,5 +1,5 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Database.Avatar;
using EggLink.DanhengServer.Enums.Scene;

View File

@@ -1,4 +1,5 @@
using EggLink.DanhengServer.Data.Config;
using EggLink.DanhengServer.Data.Config.Scene;
using EggLink.DanhengServer.Data.Config.Task;
using EggLink.DanhengServer.Data.Excel;
using EggLink.DanhengServer.Enums.Mission;

View File

@@ -13,7 +13,8 @@ public class PacketSelectRogueCommonDialogueOptionScRsp : BasePacket
{
EventUniqueId = (uint)rogueEvent.EventUniqueId,
DialogueData = rogueEvent.ToProto(),
OptionId = (uint)rogueEvent.SelectedOptionId
OptionId = (uint)rogueEvent.SelectedOptionId,
MMDFEMGOIAI = true
};
SetData(proto);

View File

@@ -11,7 +11,6 @@ public class PacketSyncRogueCommonDialogueOptionFinishScNotify : BasePacket
{
var proto = new SyncRogueCommonDialogueOptionFinishScNotify
{
DialogueData = instance.ToProto(),
EventUniqueId = (uint)instance.EventUniqueId,
OptionId = (uint)instance.SelectedOptionId,
ResultOptionInfo = instance.Options.Find(o => o.OptionId == instance.SelectedOptionId)!.ToProto()