From 723f236db4f44bbca69c7a523892c80910bfedbc Mon Sep 17 00:00:00 2001 From: Zin <62830952+Zintixx@users.noreply.github.com> Date: Tue, 12 May 2026 18:58:43 -0700 Subject: [PATCH 1/3] Parse Dungeon Reward Coupon --- Maple2.File.Parser/Maple2.File.Parser.csproj | 2 +- Maple2.File.Parser/TableParser.cs | 13 ++++++++++++ .../Xml/Table/DungeonRewardCoupon.cs | 21 +++++++++++++++++++ Maple2.File.Tests/TableParserTest.cs | 7 +++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 Maple2.File.Parser/Xml/Table/DungeonRewardCoupon.cs diff --git a/Maple2.File.Parser/Maple2.File.Parser.csproj b/Maple2.File.Parser/Maple2.File.Parser.csproj index a76ec8b..4fafe91 100644 --- a/Maple2.File.Parser/Maple2.File.Parser.csproj +++ b/Maple2.File.Parser/Maple2.File.Parser.csproj @@ -13,7 +13,7 @@ MapleStory2, File, Parser, m2d, xml true - 2.4.9 + 2.4.10 net8.0 README.md enable diff --git a/Maple2.File.Parser/TableParser.cs b/Maple2.File.Parser/TableParser.cs index 3fe2149..9cc0574 100644 --- a/Maple2.File.Parser/TableParser.cs +++ b/Maple2.File.Parser/TableParser.cs @@ -23,6 +23,7 @@ public class TableParser { private readonly XmlSerializer dungeonRoundDataSerializer; private readonly XmlSerializer dungeonRankRewardSerializer; private readonly XmlSerializer dungeonConfigSerializer; + private readonly XmlSerializer dungeonRewardCouponSerializer; private readonly XmlSerializer enchantScrollSerializer; private readonly XmlSerializer fishSerializer; private readonly XmlSerializer fishHabitatSerializer; @@ -126,6 +127,7 @@ public TableParser(M2dReader xmlReader, string language) { dungeonRoundDataSerializer = new XmlSerializer(typeof(DungeonRoundDataRoot)); dungeonRankRewardSerializer = new XmlSerializer(typeof(DungeonRankRewardRoot)); dungeonConfigSerializer = new XmlSerializer(typeof(DungeonConfigRoot)); + dungeonRewardCouponSerializer = new XmlSerializer(typeof(DungeonRewardCouponRoot)); enchantScrollSerializer = new XmlSerializer(typeof(EnchantScrollRoot)); fishSerializer = new XmlSerializer(typeof(FishRoot)); fishHabitatSerializer = new XmlSerializer(typeof(FishHabitatRoot)); @@ -1636,4 +1638,15 @@ public IEnumerable ParseJobTableNew() { yield return (entry.id, entry); } } + + public IEnumerable<(int Id, DungeonRewardCoupon Coupon)> ParseDungeonRewardCoupon() { + string xml = Sanitizer.RemoveSpaces(xmlReader.GetString(xmlReader.GetEntry("table/na/dungeonrewardcoupon.xml"))); + var reader = XmlReader.Create(new StringReader(xml)); + var data = dungeonRewardCouponSerializer.Deserialize(reader) as DungeonRewardCouponRoot; + Debug.Assert(data != null); + + foreach (DungeonRewardCoupon entry in data.dungeonRewardCoupon) { + yield return (entry.id, entry); + } + } } diff --git a/Maple2.File.Parser/Xml/Table/DungeonRewardCoupon.cs b/Maple2.File.Parser/Xml/Table/DungeonRewardCoupon.cs new file mode 100644 index 0000000..2fd4d00 --- /dev/null +++ b/Maple2.File.Parser/Xml/Table/DungeonRewardCoupon.cs @@ -0,0 +1,21 @@ +using System.Xml.Serialization; + +namespace Maple2.File.Parser.Xml.Table; + +// ./data/xml/table/na/dungeonrewardcoupon.xml +[XmlRoot("ms2")] +public class DungeonRewardCouponRoot { + [XmlElement] public List dungeonRewardCoupon; +} + +public class DungeonRewardCoupon { + [XmlAttribute] public int id; + [XmlAttribute] public string ticketTag; + [XmlAttribute] public int baseItemID; + [XmlAttribute] public int maxExtraCount; + [XmlElement] public List baseRate; +} + +public class DungeonRewardBaseRate { + [XmlAttribute] public int v; +} diff --git a/Maple2.File.Tests/TableParserTest.cs b/Maple2.File.Tests/TableParserTest.cs index 6d2d52d..5548065 100644 --- a/Maple2.File.Tests/TableParserTest.cs +++ b/Maple2.File.Tests/TableParserTest.cs @@ -787,4 +787,11 @@ public void TestClubBuff() { continue; } } + + [TestMethod] + public void TestDungeonRewardCoupon() { + foreach ((_, _) in _parser.ParseDungeonRewardCoupon()) { + continue; + } + } } From d3c437e7c537621abb8ea22e7da75e205cb4f3c5 Mon Sep 17 00:00:00 2001 From: Zin <62830952+Zintixx@users.noreply.github.com> Date: Tue, 12 May 2026 19:03:09 -0700 Subject: [PATCH 2/3] Update TableParser.cs --- Maple2.File.Parser/TableParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Maple2.File.Parser/TableParser.cs b/Maple2.File.Parser/TableParser.cs index 9cc0574..94c0208 100644 --- a/Maple2.File.Parser/TableParser.cs +++ b/Maple2.File.Parser/TableParser.cs @@ -1640,7 +1640,7 @@ public IEnumerable ParseJobTableNew() { } public IEnumerable<(int Id, DungeonRewardCoupon Coupon)> ParseDungeonRewardCoupon() { - string xml = Sanitizer.RemoveSpaces(xmlReader.GetString(xmlReader.GetEntry("table/na/dungeonrewardcoupon.xml"))); + string xml = Sanitizer.RemoveSpaces(xmlReader.GetString(xmlReader.GetEntry($"table/{locale}/dungeonrewardcoupon.xml"))); var reader = XmlReader.Create(new StringReader(xml)); var data = dungeonRewardCouponSerializer.Deserialize(reader) as DungeonRewardCouponRoot; Debug.Assert(data != null); From a1e0074a222eba28f3c90e8bf7aef421ea622cee Mon Sep 17 00:00:00 2001 From: Zin <62830952+Zintixx@users.noreply.github.com> Date: Tue, 12 May 2026 19:24:38 -0700 Subject: [PATCH 3/3] Parse Npc Stat Factor --- Maple2.File.Parser/ServerTableParser.cs | 13 ++++++++++ .../Server/NpcStatFactorByPlayerCount.cs | 24 +++++++++++++++++++ Maple2.File.Tests/ServerTableParserTest.cs | 10 ++++++++ 3 files changed, 47 insertions(+) create mode 100644 Maple2.File.Parser/Xml/Table/Server/NpcStatFactorByPlayerCount.cs diff --git a/Maple2.File.Parser/ServerTableParser.cs b/Maple2.File.Parser/ServerTableParser.cs index 88e5000..972419b 100644 --- a/Maple2.File.Parser/ServerTableParser.cs +++ b/Maple2.File.Parser/ServerTableParser.cs @@ -59,6 +59,7 @@ public class ServerTableParser { private readonly XmlSerializer itemOptionVariationSerializer; private readonly XmlSerializer itemOptionRandomSerializer; private readonly XmlSerializer constantsSerializer; + private readonly XmlSerializer npcStatFactorByPlayerCountSerializer; public ServerTableParser(M2dReader xmlReader) { this.xmlReader = xmlReader; @@ -101,6 +102,7 @@ public ServerTableParser(M2dReader xmlReader) { itemOptionVariationSerializer = new XmlSerializer(typeof(ItemOptionVariationRoot)); itemOptionRandomSerializer = new XmlSerializer(typeof(ItemOptionRandomRoot)); constantsSerializer = new XmlSerializer(typeof(Constants)); + npcStatFactorByPlayerCountSerializer = new XmlSerializer(typeof(NpcStatFactorByPlayerCountRoot)); // var seen = new HashSet(); // this.bankTypeSerializer.UnknownAttribute += (sender, args) => { @@ -702,4 +704,15 @@ public ServerTableParser(M2dReader xmlReader) { yield return (key.key, key); } } + + public IEnumerable ParseNpcStatFactorByPlayerCount() { + string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry("table/Server/npcStatFactorByPlayerCount.xml"))); + var reader = XmlReader.Create(new StringReader(xml)); + var data = npcStatFactorByPlayerCountSerializer.Deserialize(reader) as NpcStatFactorByPlayerCountRoot; + Debug.Assert(data != null); + + foreach (NpcStatFactorByPlayerCount entry in data.PlayerCountFactor) { + yield return (entry); + } + } } diff --git a/Maple2.File.Parser/Xml/Table/Server/NpcStatFactorByPlayerCount.cs b/Maple2.File.Parser/Xml/Table/Server/NpcStatFactorByPlayerCount.cs new file mode 100644 index 0000000..a0b3a55 --- /dev/null +++ b/Maple2.File.Parser/Xml/Table/Server/NpcStatFactorByPlayerCount.cs @@ -0,0 +1,24 @@ +using System.Xml.Serialization; + +namespace Maple2.File.Parser.Xml.Table.Server; + +// ./data/server/table/Server/npcStatFactorByPlayerCount.xml +[XmlRoot("ms2")] +public class NpcStatFactorByPlayerCountRoot { + [XmlElement] public List PlayerCountFactor; +} + +public partial class NpcStatFactorByPlayerCount { + [XmlAttribute] public int factorID; + [XmlAttribute] public int @class; + [XmlAttribute] public int playerCount; + [XmlAttribute] public float hpRate; + [XmlAttribute] public float papRate; + [XmlAttribute] public int papValue; + [XmlAttribute] public float mapRate; + [XmlAttribute] public int mapValue; + [XmlAttribute] public float nddRate; + [XmlAttribute] public int nddValue; + [XmlAttribute] public float capRate; + [XmlAttribute] public int capValue; +} diff --git a/Maple2.File.Tests/ServerTableParserTest.cs b/Maple2.File.Tests/ServerTableParserTest.cs index 044e873..c7d3814 100644 --- a/Maple2.File.Tests/ServerTableParserTest.cs +++ b/Maple2.File.Tests/ServerTableParserTest.cs @@ -1,5 +1,6 @@ using Maple2.File.Parser; using Maple2.File.Parser.Xml.Table; +using Maple2.File.Parser.Xml.Table.Server; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Maple2.File.Tests; @@ -445,5 +446,14 @@ public void TestConstants() { continue; } } + + [TestMethod] + public void TestNpcStatFactorByPlayerCount() { + var parser = new ServerTableParser(TestUtils.ServerReader); + + foreach (NpcStatFactorByPlayerCount _ in parser.ParseNpcStatFactorByPlayerCount()) { + continue; + } + } }