Fix L’Hiver Mod: Monster HP sometimes increases during a fight#953
Fix L’Hiver Mod: Monster HP sometimes increases during a fight#953blackus3r wants to merge 2 commits into
Conversation
|
Hi, @blackus3r and thanks for PR! Use of head orientation is intended in this place. In original scripts, when npc sits on a chair/bench his face is oriented opposed to logical orientation, and then if you talk to them this script runs: if (Npc_CanSeeNpc(self, other))
{
AI_StartState (self, ZS_Talk, 0, ""); // keep talking while sit
}
else
{
...
AI_StartState (self, ZS_Talk, 1, ""); // standup and turn around
}; |
|
Hey @Try, What do you think about this hybrid approach? Edit: Okay, whatever. The bug is back. I need to do more testing. I'll get back to you. |
The engine treated ATR_REGENERATEHP/ATR_REGENERATEMANA as points per second, but in the original engine the value means 1 point every N seconds. Mods like L'Hiver use this attribute for monster regeneration: a value of e.g. 20 healed 20 HP per second instead of 1 HP every 20 seconds, so enemies regenerated faster than the player could damage them.
In melee the head bone of an attacking monster dives into the target; with only a few centimeters between head and target the direction of that vector is numerically meaningless and the +-100 deg view-angle check fails at random. L'Hiver's anti-exploit healing reads this as "player ran away" and restores the monster's HP mid-fight, while the monster itself drops out of its attack state. The line-of-sight ray still starts at the head bone; only the view cone is measured from the npc position, matching the original engine.
|
I'll move PR into drafts for now. one theory: maybe in L'Hiver script never meant to reach |
|
I built and tested another fix last night. However, it was very late, so I'll continue testing over the next few days to see if the bug has been fixed.
Fix 1: Measure the view cone from the NPC position instead of the head bone — collision keeps positions ~1 m apart in melee, so the direction stays stable. The line-of-sight ray still starts at the head bone. Matches original engine behavior. Fix 2 : ATR_REGENERATEHP/MANA was treated as points per second; the original engine defines it as 1 point every N seconds. A value of 20 healed 20 HP/s instead of 1 HP per 20 s. Not the cause for the wolf (attribute was 0), but would make any monster that uses it effectively unkillable. Verified: Debug logging showed 14× script heals triggered by failed sight checks after the fix, wolf fights behave normally. |
This should fix the issue described here: #813
I've tested it and it worked with L'hiver + Uriziel Mod.
Fix Npc_CanSeeNpc logic to use logical orientation instead of visual bone rotation
Previously,
Npc_CanSeeNpc(viaNpc::canRayHitPoint) relied onvisual.viewDirection(), which calculates the viewing angle dynamically from theBIP01root bone. This caused the perceived line of sight to fluctuate significantly during combat animations (e.g., when a character turns sideways to dodge or stumble).As a result, mods relying on line of sight checks during combat (like the anti-exploit healing mechanic in L'Hiver) would break, causing enemies to regenerate mid-combat because they temporarily "lost sight" of the player due to their own animation.
Using the NPC's logical
angleinstead prevents these animation-based FOV blindspots and aligns the engine's behavior correctly with original ZenGin logic.