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 3 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. |
Hm, look like a hack rather: it's very counter-intuitive to use head-bone as a reference for view direction, but logical position for view origin. When you mention that it matches original behavior, did you had some specific test setup?
That looks solid. |
|
I phrased that too strongly. I didn’t compare it against the ZenGin binary, and I don’t have a proper setup to test the original engine. So this is based on debugging and observed behavior, not on a direct verification. What led to the change was a debug log from a wolf fight in L’Hiver + Uriziel. In melee, the attacker’s head bone can move directly into the target. That makes the head-to-target vector extremely short, so the calculated angle is basically just numerical noise. The ±100° check then fails more or less randomly. L’Hiver’s anti-exploit script treats that failed sight check as if the player had broken line of sight or run away, so it heals the enemy. When the cone is calculated from the body position instead, the vector stays stable and the check no longer flickers. About the head-bone/position inconsistency: in the current version, combat no longer uses the head bone for the facing direction at all. It now uses the logical angle, which is also what the AI and turn logic use as the actual facing direction. The head bone’s So in combat it is position plus logical angle. Only for MOBSI it is position plus the actual head direction. If that is still too much for one PR, I can also remove the MOBSI special case and keep only the combat change. |

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.