Project

General

Profile

Bug #2703

OnPCHitMe is not handled correctly

Added by Thomas Staudinger almost 3 years ago. Updated 13 days ago.

Status:
Closed
Priority:
Normal
Category:
AI
Target version:
Start date:
06/17/2015
% Done:

100%

Reproducibility:
Always
Operating system:
Other
Severity:
Normal

Description

In the Bloodmoon quest "A Blocked Door" (http://www.uesp.net/wiki/Bloodmoon:A_Blocked_Door), you have to fight the Nord Hroldar the Strange hand-to-hand to get him away from a door. In vanilla he doesn't fight back, in OpenMW he switches between fighting and not fighting you. Additionally, after you beat him, he walks away but then turns around and blocks the door again (but the door can be used normally and the quest is completed anyway)

Steps to reproduce:
E.g. use the provided savegame and start punching Hroldar (Note: if you want to beat him with the character in the savegame, you probably have to use the console to set his fatigue lower or improve the PC's hand-to-hand skill, or else you wont be able to drain his fatigue by punching him)

OpenMW version: 0.36.1

Hrolgar.7z - OpenMW Save (2.44 MB) Thomas Staudinger, 06/17/2015 12:24 PM

Associated revisions

Revision 27c83195 (diff)
Added by Andrei Kortunov 19 days ago

Handle OnPCHitMe variable (bug #2703)

History

#1 Updated by scrawl . almost 3 years ago

In the vanilla engine, Hroldar won't react to attacks at all, even if you remove his script. That's weird.

#2 Updated by Amenophis . over 2 years ago

Tested again and now Hroldar fight back, but the problem with him leaving and coming back continues.

Win 10, 64 bits
OpenMW-latest-63b9b07-win64

#3 Updated by Alexei Dobrohotov about 1 year ago

  • Category set to AI

Tested again. Hroldar fights back (note: you really must use hand-to-hand) and doesn't do anything weird. Windows 10 64-bit, OpenMW revision d97e9cf, reporter's save.

#4 Updated by Alexei Dobrohotov about 1 year ago

  • Status changed from New to Resolved

#5 Updated by Alexei Dobrohotov about 1 year ago

  • Status changed from Resolved to Closed

#6 Updated by Alexei Dobrohotov about 1 year ago

  • Status changed from Closed to New

I'm blind. Sorry.

#7 Updated by Alexei Dobrohotov about 1 year ago

  • Status changed from New to Confirmed

#8 Updated by Andrei Kortunov 6 months ago

Additionally, after you beat him, he walks away but then turns around and blocks the door again

I guess it is because Hrolgar has the AiWander package with 0 distance. OpenMW forced the actor to return to the position, saved in the AWander package if the wandering distance is 0.
I cannot reproduce this part of issue after recent AiWander changes.

#9 Updated by Andrei Kortunov 6 months ago

In the vanilla engine, Hroldar won't react to attacks at all, even if you remove his script. That's weird.

Can not reproduce this behaviour in vanilla Mororwind.
When I removed the script, Hroldar fought as a common NPC.

#10 Updated by Andrei Kortunov 6 months ago

A testing script:

Begin HroldarScript

If ( OnPCHitMe ) 
    Set OnPCHitme to 0 
    MessageBox "PC Hit Me!" 
endif

End HroldarScript

In vanilla Morrowind only message box appears, the NPC does not attack you.
However, if you remove the "Set OnPCHitme to 0" line, the NPC will attack you after messagebox appears.

So I can guess that the "Set OnPCHitme to 0" line is supposed to suppress "The player attacks the NPC" event.
OpenMW does not support this trick for now.

#11 Updated by Andrei Kortunov 6 months ago

  • Subject changed from Quest: A blocked door, Hroldar fights back to OpenMW does not handle OnPCHitme correctly

Take a look at how we handle the PCSkipEquip to block an item equipping.
I suppose that OnPCHitme should be handled in the similar way.

#12 Updated by Andrei Kortunov 5 months ago

  • Operating system changed from Windows to Other

In our current implementation we start combat before we set the OnPCHitMe.

How it works in Morrowind:
1. Set the OnPCHitMe during attack event
2. Execute scripts (the script can reset the OnPCHitMe)
3. If the OnPCHitMe is still true and attacker is the player, handle the attack event, otherwise suppress it.
Not sure if it handled in the frame when the attack was happened, or in the next frame.

Can be hard to implement since scripts are executed in the separate thread in OpenMW.

#13 Updated by rot tor 4 months ago

I'm not sure if it's the same bug, but OnPCHitMe + StopCombat doesn't properly prevent attack voices and combat status in OpenMW. For "pacifist" (unable to fight) NPCs, there are two issues that can't be bypassed by different CS implementation: even if an empty attack voice is added to block the attack voices, the attack voice will bypass any Hit voice being triggered; and battle music starts (and stops), which resets music.

#14 Updated by rot tor 3 months ago

So I can guess that the "Set OnPCHitme to 0" line is supposed to suppress "The player attacks the NPC" event.

I couldn't reproduce this in vanilla for a normal NPC with value "Fight 30". The NPC still attacks. The only difference with the above testing script was the Fight value and adding "Short OnPCHitMe" (without which the script compiles but returns an error ingame).

If the NPC has 0 Fight, what I quoted is not exactly true either. The NPC doesn't attack even if "Set OnPCHitme to 0" isn't used. With 0 Fight, the simple fact of declaring "OnPCHitMe" as a local variable prevents them from attacking if you don't StartCombat manually, like MSFD reports.

#15 Updated by Andrei Kortunov 3 months ago

I'm not sure if it's the same bug

It is the same bug.

#17 Updated by Alexei Dobrohotov 2 months ago

  • Subject changed from OpenMW does not handle OnPCHitme correctly to OnPCHitMe is not handled correctly

#18 Updated by Andrei Kortunov about 2 months ago

With 0 Fight, the simple fact of declaring "OnPCHitMe" as a local variable prevents them from attacking if you don't StartCombat manually, like MSFD reports.

It is a really strange behaviour. Maybe it is a bug in original engine since Hroldar's script uses StopCombat manually to prevent fighting.
Hroldar starts attack in OpenMW only if the player's attack was unsuccessfull.

If we really want to replicate vanilla behaviour "bug-to-bug", we can modify the MechanicsManager::startCombat() to do nothing if the "OnPCHitMe" was declared in script and the Fight is 0.

#19 Updated by Nelsson Huotari about 1 month ago

I tested this today on Openmw 0.43, but the results are different. Hroldar doesn't fight back, and after beating him he walks away and seems to stay there. This sounds like the vanilla behavior?

#20 Updated by Andrei Kortunov about 1 month ago

His script is buggy. You need to successfully hit him in OpenMW with the first attack, or he will fight back, so behaviour is still different.

#21 Updated by Andrei Kortunov about 1 month ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Andrei Kortunov
  • Target version set to openmw-0.44
  • % Done changed from 0 to 100

#22 Updated by Alexei Dobrohotov 13 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF