From 683ca3ffd1b7c7966928a6fb23c957413647d407 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 09:50:49 +0000 Subject: [PATCH 1/3] Give the champion tomes and life-skill books their passive bonuses From cast id 19 on, a passive skill's DATA c1 is the tome's tier, c2 its amount and c3 a second amount. Read them into BCards for every kind the client describes, and count passive skills in the experience, gold and double-drop bonuses. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014gSmkUfkSas3RmznMafvB5 --- documentation/manual-test-plan.md | 6 + .../Services/BattleService/RewardService.cs | 7 +- .../ExperienceBonusService.cs | 5 +- src/NosCore.Parser/Parsers/SkillParser.cs | 109 +++++++++++++----- .../SkillService/PassiveTomeBonusTests.cs | 60 ++++++++++ test/NosCore.Parser.Tests/SkillParserTests.cs | 45 +++++++- 6 files changed, 201 insertions(+), 31 deletions(-) create mode 100644 test/NosCore.GameObject.Tests/Services/SkillService/PassiveTomeBonusTests.cs diff --git a/documentation/manual-test-plan.md b/documentation/manual-test-plan.md index 670ff8f6e8..80d4ac278d 100644 --- a/documentation/manual-test-plan.md +++ b/documentation/manual-test-plan.md @@ -1340,6 +1340,12 @@ A character with a few Halloween Costume Scrolls (1913) in the Main bag, and a s - [ ] At champion level 10, double-click it: "You've learned a new skill", the book is used up, no gold is taken and the boost appears under Skill Info > Training - [ ] Double-click a second copy: "You've already learned" and the book stays +- [ ] At the tome's champion level, read a Bear Loa Tome (2468) with Character Info (`p`) open: the + maximum HP rises by 7000. An Eagle Loa Tome (2469) raises ranged attack by 120, ranged + defence by 60, hit rate by 240 and dodge by 120 +- [ ] Read a Vitality Guide (2721): the maximum HP and MP each rise by 3000 +- [ ] With Aurelius Roshu's Primordial History (1) known, a kill gives 5% more experience than + the same kill without it ### Mini pets diff --git a/src/NosCore.GameObject/Services/BattleService/RewardService.cs b/src/NosCore.GameObject/Services/BattleService/RewardService.cs index 749e4999a6..832604d009 100644 --- a/src/NosCore.GameObject/Services/BattleService/RewardService.cs +++ b/src/NosCore.GameObject/Services/BattleService/RewardService.cs @@ -66,6 +66,7 @@ public sealed class RewardService( IBuffService buffService, IEquipmentStatsService equipmentStatsService, ICardCatalog cardCatalog, + SkillService.IPassiveSkillService passiveSkillService, IQuestDropService questDropService, IScriptedInstanceService scriptedInstanceService, IItemDeliveryService itemDeliveryService, @@ -228,7 +229,8 @@ private bool DropRolls(DropDto drop, Services.MapInstanceGenerationService.MapIn int doubleChance = 0, noDropChance = 0; var cards = buffService.GetActiveBuffs(player).SelectMany(b => b.BCards) .Concat(equipmentStatsService.Resolve(player).BCards ?? []) - .Concat(player.MedalBCards(itemCatalog, cardCatalog)); + .Concat(player.MedalBCards(itemCatalog, cardCatalog)) + .Concat(passiveSkillService.GetBCards(player)); foreach (var bCard in cards) { switch (bCard.Effect()) @@ -250,7 +252,8 @@ private int GoldBonusPercent(PlayerComponentBundle player) var percent = 0; var cards = buffService.GetActiveBuffs(player).SelectMany(b => b.BCards) .Concat(equipmentStatsService.Resolve(player).BCards ?? []) - .Concat(player.MedalBCards(itemCatalog, cardCatalog)); + .Concat(player.MedalBCards(itemCatalog, cardCatalog)) + .Concat(passiveSkillService.GetBCards(player)); foreach (var bCard in cards) { switch (bCard.Effect()) diff --git a/src/NosCore.GameObject/Services/ExperienceService/ExperienceBonusService.cs b/src/NosCore.GameObject/Services/ExperienceService/ExperienceBonusService.cs index 9a7b898aba..17941b93a0 100644 --- a/src/NosCore.GameObject/Services/ExperienceService/ExperienceBonusService.cs +++ b/src/NosCore.GameObject/Services/ExperienceService/ExperienceBonusService.cs @@ -15,14 +15,15 @@ namespace NosCore.GameObject.Services.ExperienceService { public sealed class ExperienceBonusService(IBuffService buffService, IEquipmentStatsService equipmentStatsService, - IItemCatalog itemCatalog, ICardCatalog cardCatalog) : IExperienceBonusService + IItemCatalog itemCatalog, ICardCatalog cardCatalog, SkillService.IPassiveSkillService passiveSkillService) : IExperienceBonusService { public ExperienceBonus GetBonus(PlayerComponentBundle player) { int experience = 0, jobExperience = 0, heroExperience = 0, reputation = 0; var cards = buffService.GetActiveBuffs(player).SelectMany(b => b.BCards) .Concat(equipmentStatsService.Resolve(player).BCards ?? []) - .Concat(player.MedalBCards(itemCatalog, cardCatalog)); + .Concat(player.MedalBCards(itemCatalog, cardCatalog)) + .Concat(passiveSkillService.GetBCards(player)); foreach (var bCard in cards) { var value = BattleStatsProvider.ScaleByLevel(bCard, player.Level); diff --git a/src/NosCore.Parser/Parsers/SkillParser.cs b/src/NosCore.Parser/Parsers/SkillParser.cs index 8935c68dda..cc0413d566 100644 --- a/src/NosCore.Parser/Parsers/SkillParser.cs +++ b/src/NosCore.Parser/Parsers/SkillParser.cs @@ -33,16 +33,77 @@ public class SkillParser(IDao bCardDao, IDao combo private readonly ILogger _logger = loggerFactory.CreateLogger(); - // A training course has no BASIC line. Its kind is the TYPE cast id and its amount the - // first DATA field; the client's own tooltip names what each kind raises. - private static readonly Dictionary CourseEffects = new() + private const int DataC1 = 2; + private const int DataC2 = 3; + private const int DataC3 = 4; + + private sealed record CourseCard(BCardEffect Effect, int DataField, int Multiplier = 1, int Divisor = 1); + + private static readonly CourseCard[] MeleeTome = + [ + new(BCardEffect.AttackPowerMeleeAttacksIncreased, DataC2), + new(BCardEffect.DefenceMeleeIncreased, DataC2, Divisor: 2), + ]; + + private static readonly CourseCard[] RangedTome = + [ + new(BCardEffect.AttackPowerRangedAttacksIncreased, DataC2), + new(BCardEffect.DefenceRangedIncreased, DataC2, Divisor: 2), + new(BCardEffect.TargetAllHitRateIncreased, DataC2, Multiplier: 2), + new(BCardEffect.DodgeAndDefencePercentDodgeIncreased, DataC2), + ]; + + private static readonly CourseCard[] MagicTome = + [ + new(BCardEffect.AttackPowerMagicalAttacksIncreased, DataC2), + new(BCardEffect.DefenceMagicalIncreased, DataC2, Divisor: 2), + ]; + + private static readonly CourseCard[] AttackAndDefenceTome = + [ + new(BCardEffect.AttackPowerAllAttacksIncreased, DataC2), + new(BCardEffect.DefenceAllIncreased, DataC3), + ]; + + // A training course or tome has no BASIC line: its TYPE cast id names what it raises and + // its DATA fields carry the amounts. Courses 4 to 9 keep the amount in DATA c1; the tomes + // from 19 on keep their tier there, the amount in c2 and a second amount in c3. Where a + // tome raises several stats from one amount, the ratios are the ones its tooltip lists. + private static readonly Dictionary CourseEffects = new() { - [4] = BCardEffect.MaxHpmpMaximumHpIncreased, - [5] = BCardEffect.MaxHpmpMaximumMpIncreased, - [6] = BCardEffect.AttackPowerAllAttacksIncreased, - [7] = BCardEffect.DefenceAllIncreased, - [8] = BCardEffect.RecoveryHpRecoveryIncreased, - [9] = BCardEffect.RecoveryMpRecoveryIncreased, + [4] = [new(BCardEffect.MaxHpmpMaximumHpIncreased, DataC1)], + [5] = [new(BCardEffect.MaxHpmpMaximumMpIncreased, DataC1)], + [6] = [new(BCardEffect.AttackPowerAllAttacksIncreased, DataC1)], + [7] = [new(BCardEffect.DefenceAllIncreased, DataC1)], + [8] = [new(BCardEffect.RecoveryHpRecoveryIncreased, DataC1)], + [9] = [new(BCardEffect.RecoveryMpRecoveryIncreased, DataC1)], + [19] = [new(BCardEffect.LeonaPassiveSkillAttackIncreasedInPvp, DataC2)], + [20] = [new(BCardEffect.LeonaPassiveSkillDefenceIncreasedInPvp, DataC2)], + [21] = MeleeTome, + [22] = RangedTome, + [23] = MagicTome, + [24] = [new(BCardEffect.MaxHpmpMaximumHpIncreased, DataC2)], + [25] = [new(BCardEffect.MaxHpmpMaximumMpIncreased, DataC2)], + [26] = [new(BCardEffect.DefenceAllIncreased, DataC2)], + [27] = [new(BCardEffect.AttackPowerAllAttacksIncreased, DataC2)], + [28] = [new(BCardEffect.ElementResistanceAllIncreased, DataC2)], + [29] = [new(BCardEffect.ItemExpIncreased, DataC2)], + [30] = [new(BCardEffect.ItemIncreaseEarnedGold, DataC2)], + [31] = [new(BCardEffect.MaxHpmpMaximumHpIncreased, DataC2)], + [32] = RangedTome, + [33] = MagicTome, + [34] = MeleeTome, + [35] = [new(BCardEffect.MaxHpmpMaximumMpIncreased, DataC2)], + [36] = AttackAndDefenceTome, + [37] = AttackAndDefenceTome, + [38] = AttackAndDefenceTome, + [40] = [new(BCardEffect.MaxHpmpMaximumHpIncreased, DataC2), new(BCardEffect.MaxHpmpMaximumMpIncreased, DataC3)], + [41] = AttackAndDefenceTome, + [42] = AttackAndDefenceTome, + [43] = AttackAndDefenceTome, + [44] = [new(BCardEffect.IncreaseFairyElement, DataC2)], + [45] = [new(BCardEffect.MultAttackAllAttackIncreased, DataC2)], + [46] = [new(BCardEffect.DropX2Chance, DataC2)], }; // VNUM {VNum} // NAME {Name} @@ -118,23 +179,6 @@ public async Task InsertSkillsAsync(string folder) skill.LevelMinimum = (byte)((skill.CastId - SkillsUnlockedAtOnce) * LevelsPerUnlock); } - foreach (var course in skills.Where(s => s.SkillType == 0 && (s.BCards == null || s.BCards.Count == 0))) - { - if (CourseEffects.TryGetValue(course.CastId, out var effect)) - { - course.BCards = new List - { - new() - { - SkillVNum = course.SkillVNum, - Type = effect.Type(), - SubType = effect.SubType(), - FirstData = course.UpgradeSkill - } - }; - } - } - await skillDao.TryInsertOrUpdateAsync(skills).OrThrowAsync(); var skillVNums = skills.Select(s => s.SkillVNum).ToHashSet(); await comboDao.TryDeleteAsync(comboDao.Where(s => skillVNums.Contains(s.SkillVNum))?.Select(s => s.ComboId).ToList() ?? []).OrThrowAsync(); @@ -173,6 +217,19 @@ private List AddBCards(Dictionary chunks) list.Add(comb); } + if (list.Count == 0 && chunks["TYPE"][0][2] == "0" + && CourseEffects.TryGetValue(Convert.ToInt16(chunks["TYPE"][0][3]), out var courseCards)) + { + var skillVNum = Convert.ToInt16(chunks["VNUM"][0][2]); + list.AddRange(courseCards.Select(c => new BCardDto + { + SkillVNum = skillVNum, + Type = c.Effect.Type(), + SubType = c.Effect.SubType(), + FirstData = (short)(int.Parse(chunks["DATA"][0][c.DataField]) * c.Multiplier / c.Divisor) + })); + } + return list; } diff --git a/test/NosCore.GameObject.Tests/Services/SkillService/PassiveTomeBonusTests.cs b/test/NosCore.GameObject.Tests/Services/SkillService/PassiveTomeBonusTests.cs new file mode 100644 index 0000000000..5ed34d035f --- /dev/null +++ b/test/NosCore.GameObject.Tests/Services/SkillService/PassiveTomeBonusTests.cs @@ -0,0 +1,60 @@ +// __ _ __ __ ___ __ ___ ___ +// | \| |/__\ /' _/ / _//__\| _ \ __| +// | | ' | \/ |`._`.| \_| \/ | v / _| +// |_|\__|\__/ |___/ \__/\__/|_|_\___| +// + +using System; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Moq; +using NosCore.Data.Enumerations.Buff; +using NosCore.Data.StaticEntities; +using NosCore.GameObject.Networking.ClientSession; +using NosCore.GameObject.Services.BattleService; +using NosCore.GameObject.Services.ExperienceService; +using NosCore.GameObject.Services.SkillService; +using NosCore.Tests.Shared; + +namespace NosCore.GameObject.Tests.Services.SkillService +{ + [TestClass] + public class PassiveTomeBonusTests + { + private TestWorld World; + private ClientSession _session; + private ExperienceBonusService _bonus; + + private static readonly SkillDto PrimordialHistory = new() { SkillVNum = 104, SkillType = 0, CastId = 29 }; + + [TestInitialize] + public async Task SetupAsync() + { + World = await TestWorld.CreateAsync(); + _session = await World.CreateSessionAsync(); + var catalog = World.Freeze>(); + catalog.Setup(c => c.GetSkillBCards(It.IsAny())).Returns(Array.Empty()); + catalog.Setup(c => c.GetSkillBCards(104)).Returns(new[] + { + new BCardDto + { + SkillVNum = 104, Type = BCardEffect.ItemExpIncreased.Type(), + SubType = BCardEffect.ItemExpIncreased.SubType(), FirstData = 5 + } + }); + World.UseReal(); + _bonus = World.Create(); + } + + [TestMethod] + public void AnExperienceTomeRaisesTheExperienceEarned() + { + var before = _bonus.GetBonus(_session.Character).Experience; + + _session.Character.Skills[PrimordialHistory.SkillVNum] = + new CharacterSkill { SkillVNum = PrimordialHistory.SkillVNum, Skill = PrimordialHistory }; + + Assert.AreEqual(before + 5, _bonus.GetBonus(_session.Character).Experience); + } + } +} diff --git a/test/NosCore.Parser.Tests/SkillParserTests.cs b/test/NosCore.Parser.Tests/SkillParserTests.cs index c913dea297..c64aedac89 100644 --- a/test/NosCore.Parser.Tests/SkillParserTests.cs +++ b/test/NosCore.Parser.Tests/SkillParserTests.cs @@ -98,6 +98,7 @@ private static string CreateSkillData( byte targetRange = 0, short upgradeSkill = 0, short upgradeType = 0, + short dataThird = 0, short castTime = 0, short cooldown = 0, short mpCost = 0, @@ -115,7 +116,7 @@ private static string CreateSkillData( $"\tLEVEL\t{levelMinimum}\t-1\t-1\t-1\t-1\r\n" + $"\tEFFECT\t0\t{castEffect}\t{castAnimation}\t{effect}\t{attackAnimation}\t0\t0\t0\t0\r\n" + $"\tTARGET\t{targetType}\t{hitType}\t{range}\t{targetRange}\t0\r\n" + - $"\tDATA\t{upgradeSkill}\t{upgradeType}\t0\t0\t{castTime}\t{cooldown}\t0\t0\t{mpCost}\t0\t{itemVNum}\t0\t0\t0\t0\r\n" + + $"\tDATA\t{upgradeSkill}\t{upgradeType}\t{dataThird}\t0\t{castTime}\t{cooldown}\t0\t0\t{mpCost}\t0\t{itemVNum}\t0\t0\t0\t0\r\n" + $"\tBASIC\t{firstBasic}\r\n" + "\tBASIC\t1\t0\t0\t0\t0\t0\r\n" + "\tBASIC\t2\t0\t0\t0\t0\t0\r\n" + @@ -388,6 +389,48 @@ public async Task ATrainingCourseCarriesWhatItRaises(short kind, BCardEffect eff Assert.AreEqual(50, card.FirstData); } + // From kind 19 on, DATA c1 is the tome's tier and the amount sits in c2. + [TestMethod] + [DataRow((short)19, BCardEffect.LeonaPassiveSkillAttackIncreasedInPvp)] + [DataRow((short)24, BCardEffect.MaxHpmpMaximumHpIncreased)] + [DataRow((short)28, BCardEffect.ElementResistanceAllIncreased)] + [DataRow((short)29, BCardEffect.ItemExpIncreased)] + [DataRow((short)30, BCardEffect.ItemIncreaseEarnedGold)] + [DataRow((short)44, BCardEffect.IncreaseFairyElement)] + [DataRow((short)46, BCardEffect.DropX2Chance)] + public async Task ATomeRaisesItsStatByItsSecondDataField(short kind, BCardEffect effect) + { + await ParseOneAsync(CreateSkillData(skillVNum: 99, skillType: 0, castId: kind, upgradeSkill: 2, upgradeType: 4000)); + + var card = _savedBCards.Single(); + Assert.AreEqual(effect, card.Effect()); + Assert.AreEqual(4000, card.FirstData); + } + + [TestMethod] + public async Task ATwoAmountTomeRaisesAttackByTheFirstAndDefenceByTheSecond() + { + await ParseOneAsync(CreateSkillData(skillVNum: 121, skillType: 0, castId: 37, upgradeSkill: 3, upgradeType: 100, dataThird: 75)); + + var cards = _savedBCards.ToDictionary(c => c.Effect(), c => c.FirstData); + Assert.AreEqual(2, cards.Count); + Assert.AreEqual(100, cards[BCardEffect.AttackPowerAllAttacksIncreased]); + Assert.AreEqual(75, cards[BCardEffect.DefenceAllIncreased]); + } + + // An Eagle Loa Tome of 120 lists ranged attack 120, ranged defence 60, hit rate 240 and dodge 120. + [TestMethod] + public async Task ARangedTomeDerivesItsDefenceHitRateAndDodgeFromItsAmount() + { + await ParseOneAsync(CreateSkillData(skillVNum: 114, skillType: 0, castId: 32, upgradeSkill: 1, upgradeType: 120)); + + var cards = _savedBCards.ToDictionary(c => c.Effect(), c => c.FirstData); + Assert.AreEqual(120, cards[BCardEffect.AttackPowerRangedAttacksIncreased]); + Assert.AreEqual(60, cards[BCardEffect.DefenceRangedIncreased]); + Assert.AreEqual(240, cards[BCardEffect.TargetAllHitRateIncreased]); + Assert.AreEqual(120, cards[BCardEffect.DodgeAndDefencePercentDodgeIncreased]); + } + [TestMethod] public async Task ACourseOfAnotherKindGetsNothing() { From a40744aab3c323c77c583d501a1b85a2932c2567 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 09:54:04 +0000 Subject: [PATCH 2/3] Read monster.dat MODE settings from their own columns MODE holds four BCard groups, five empty columns and then seven settings, but the parser read each setting one column early. The last column, the card a pet grants its owner, was never imported. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014gSmkUfkSas3RmznMafvB5 --- documentation/dat/monster.dat.md | 19 +++++++-------- .../Parsers/NpcMonsterParser.cs | 16 ++++++------- .../NpcMonsterParserTests.cs | 23 ++++++++++++++++++- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/documentation/dat/monster.dat.md b/documentation/dat/monster.dat.md index 4248dea537..a0ac1c0294 100644 --- a/documentation/dat/monster.dat.md +++ b/documentation/dat/monster.dat.md @@ -12,7 +12,7 @@ HP/MP {monsterMaxHpBonus} {monsterMaxMpBonus} ITEM {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} {Drop} LEVEL {monsterLevel} - MODE 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 {AlwaysActive} {Limiter} {HpThreshold} {RangeThreshold} {CModeVNum} {CellMinRange} {Midgard} + MODE 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 {AlwaysActive} {Limiter} {HpThreshold} {RangeThreshold} {CModeVNum} {CellMinRange} {Midgard} NAME {NameI18NKey} PARTNER {partnerUnused} PETINFO {petInfoVal1} {petInfoVal2} {PetInfoVal3} {PetInfoVal4} {BaseStarRating} @@ -314,14 +314,15 @@ | 23 | Unknown | | | | | 24 | Unknown | | | | | 25 | Unknown | | | | -| 26 | Parsed | AlwaysActive | Boolean | Mode always active when non-zero | -| 27 | Parsed | Limiter | Byte | Mode limiter | -| 28 | Parsed | HpThreshold | Int16 | HP% threshold that swaps the mode / item vnum | -| 29 | Parsed | RangeThreshold | Int16 | Range threshold for mode swap | -| 30 | Parsed | CModeVNum | Int16 | c_mode vnum (transform target) | -| 31 | Parsed | CellMinRange | Int16 | Minimum cells before the mode engages | -| 32 | Parsed | Midgard | Int32 | Midgard-specific data | -| 32 | Parsed | OwnerBlessingCardId | Int16 | Negative on a pet: the card it grants its owner | +| 26 | Unknown | | | | +| 27 | Parsed | AlwaysActive | Boolean | Mode always active when non-zero | +| 28 | Parsed | Limiter | Byte | Mode limiter | +| 29 | Parsed | HpThreshold | Int16 | HP% threshold that swaps the mode / item vnum | +| 30 | Parsed | RangeThreshold | Int16 | Range threshold for mode swap | +| 31 | Parsed | CModeVNum | Int16 | c_mode vnum (transform target) | +| 32 | Parsed | CellMinRange | Int16 | Minimum cells before the mode engages | +| 33 | Parsed | Midgard | Int32 | Midgard-specific data | +| 33 | Parsed | OwnerBlessingCardId | Int16 | Negative on a pet: the card it grants its owner | ## NAME diff --git a/src/NosCore.Parser/Parsers/NpcMonsterParser.cs b/src/NosCore.Parser/Parsers/NpcMonsterParser.cs index 5070988a72..8308d36db1 100644 --- a/src/NosCore.Parser/Parsers/NpcMonsterParser.cs +++ b/src/NosCore.Parser/Parsers/NpcMonsterParser.cs @@ -138,14 +138,14 @@ public FluentParserBuilder BuildParser(string folder) .Field(x => x.CanOnlyBeDmgedByJajamaruLastSkill, "ETC", 0, 5, s => s != "0", "Only damageable by Jajamaru's final skill (Namaju)") .Field(x => x.VisibleOnMinimapAsGreenDot, "ETC", 0, 7, s => s != "0", "Renders as a green dot on the minimap") .Field(x => x.IsValhallaPartner, "ETC", 0, 9, s => s != "0", "Marks Valhalla raid partner mobs") - .Field(x => x.AlwaysActive, "MODE", 0, 26, s => s != "0", "Mode always active when non-zero") - .Field(x => x.Limiter, "MODE", 0, 27, s => Convert.ToByte(s), "Mode limiter") - .Field(x => x.HpThreshold, "MODE", 0, 28, s => Convert.ToInt16(s), "HP% threshold that swaps the mode / item vnum") - .Field(x => x.RangeThreshold, "MODE", 0, 29, s => Convert.ToInt16(s), "Range threshold for mode swap") - .Field(x => x.CModeVNum, "MODE", 0, 30, s => Convert.ToInt16(s), "c_mode vnum (transform target)") - .Field(x => x.CellMinRange, "MODE", 0, 31, s => Convert.ToInt16(s), "Minimum cells before the mode engages") - .Field(x => x.Midgard, "MODE", 0, 32, s => Convert.ToInt32(s), "Midgard-specific data") - .Field(x => x.OwnerBlessingCardId, "MODE", 0, 32, s => Convert.ToInt32(s) < 0 ? (short)-Convert.ToInt32(s) : (short)0, "Negative on a pet: the card it grants its owner") + .Field(x => x.AlwaysActive, "MODE", 0, 27, s => s != "0", "Mode always active when non-zero") + .Field(x => x.Limiter, "MODE", 0, 28, s => Convert.ToByte(s), "Mode limiter") + .Field(x => x.HpThreshold, "MODE", 0, 29, s => Convert.ToInt16(s), "HP% threshold that swaps the mode / item vnum") + .Field(x => x.RangeThreshold, "MODE", 0, 30, s => Convert.ToInt16(s), "Range threshold for mode swap") + .Field(x => x.CModeVNum, "MODE", 0, 31, s => Convert.ToInt16(s), "c_mode vnum (transform target)") + .Field(x => x.CellMinRange, "MODE", 0, 32, s => Convert.ToInt16(s), "Minimum cells before the mode engages") + .Field(x => x.Midgard, "MODE", 0, 33, s => Convert.ToInt32(s), "Midgard-specific data") + .Field(x => x.OwnerBlessingCardId, "MODE", 0, 33, s => Convert.ToInt32(s) < 0 ? (short)-Convert.ToInt32(s) : (short)0, "Negative on a pet: the card it grants its owner") .Field(x => x.Level, chunk => Level(chunk), reads: new[] { ("LEVEL", 0, 2) }, source: "LEVEL[2]", description: "Parsed by Level(chunk) helper") diff --git a/test/NosCore.Parser.Tests/NpcMonsterParserTests.cs b/test/NosCore.Parser.Tests/NpcMonsterParserTests.cs index 011cb5bc1e..7356c12ee2 100644 --- a/test/NosCore.Parser.Tests/NpcMonsterParserTests.cs +++ b/test/NosCore.Parser.Tests/NpcMonsterParserTests.cs @@ -335,8 +335,29 @@ public async Task NpcMonsterParser_ImportsABossWhoseSizeAndRangesOutgrowAByte() var monster = _savedMonsters.Single(); Assert.AreEqual(250, monster.SpriteSize); Assert.AreEqual(1000, monster.NoticeRange); - Assert.AreEqual(462, monster.CellMinRange); + Assert.AreEqual(462, monster.CModeVNum); Assert.AreEqual(0, monster.CriticalChance); } + + // MODE ends with seven settings after four BCard groups and five empty columns; the last + // one is negative on a pet that blesses its owner. + [TestMethod] + public async Task NpcMonsterParser_ReadsTheModeSettingsFromTheirOwnColumns() + { + var mode = string.Join("\t", Enumerable.Repeat("0", 25).Concat(["1", "2", "50", "3", "482", "4", "-840"])); + File.WriteAllText(Path.Combine(_tempFolder, "monster.dat"), BuildMonster(709, "zts709e", 1, mode: mode)); + var parser = new NpcMonsterParser(_skillDaoMock.Object, _bCardDaoMock.Object, _dropDaoMock.Object, + _npcMonsterSkillDaoMock.Object, _npcMonsterDaoMock.Object, NullLoggerFactory.Instance, _logLanguageMock.Object, MonsterStats); + await parser.InsertNpcMonstersAsync(_tempFolder); + + var monster = _savedMonsters.Single(); + Assert.IsTrue(monster.AlwaysActive); + Assert.AreEqual(2, monster.Limiter); + Assert.AreEqual(50, monster.HpThreshold); + Assert.AreEqual(3, monster.RangeThreshold); + Assert.AreEqual(482, monster.CModeVNum); + Assert.AreEqual(4, monster.CellMinRange); + Assert.AreEqual(840, monster.OwnerBlessingCardId); + } } } From 3474c97cda0ccd247aaae67d2f36014373f185af Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 10:27:10 +0000 Subject: [PATCH 3/3] docs: add the Golden Gloopy Cake owner blessing check Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CUfJ47EGEawjsFustqpb2f --- documentation/manual-test-plan.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/documentation/manual-test-plan.md b/documentation/manual-test-plan.md index 80d4ac278d..2a24b547d7 100644 --- a/documentation/manual-test-plan.md +++ b/documentation/manual-test-plan.md @@ -1346,6 +1346,8 @@ A character with a few Halloween Costume Scrolls (1913) in the Main bag, and a s - [ ] Read a Vitality Guide (2721): the maximum HP and MP each rise by 3000 - [ ] With Aurelius Roshu's Primordial History (1) known, a kill gives 5% more experience than the same kill without it +- [ ] Run the parser again, then send a Golden Gloopy Cake (709) out without touching the database: + the owner gets card 840 and its icon shows in the buff bar ### Mini pets