Try / OpenGothic

Reimplementation of Gothic 2 Notr
MIT License
1.07k stars 78 forks source link

Rework `canSense` and `canSee` functions #589

Closed thokkat closed 1 month ago

thokkat commented 2 months ago

I reworked some functions based on testing:

~This fixes Lares not stopping if guiding the player and shattered golem not attacking~ was already fixed by https://github.com/Try/OpenGothic/commit/b4ee93d764738431bf77994b559450122a38398a. The check for empty aiQueue causes problems with G1 percs because npcs have often some AI_Wait call in script loop. This has been introduced once to fix some sneaking issues. To compensate walkbit is now used instead of bodystate for sneak mode testing.

thokkat commented 1 month ago

@Try I edited the start post. Basically this cleans up/aligns more with vanilla and prepares introduction for percs used only in G1.

Try commented 1 month ago

Checking the mater of PR (mostly on sleeping golem):

With 'npc_canseenpc' there are 2 options:

I've asked on discord about this - then will do rewrite based on it

Try commented 1 month ago

closing as idea been fully reworked here: fccda5b

thokkat commented 1 month ago

Close to starting position where sheep is, if npc is spawned via insert command he wants to attack the monsters in the cave below and gets stuck. Doesn't happen before rework.

Try commented 1 month ago

Checked it - it seems npc can 'hear' another one. Current idea on how-to solve this case is to restrict hearing sense. In vanilla npc wont 'hear' player, unless player moves. Checking for BS_STAND seem to work

thokkat commented 1 month ago

In vanilla npc wont 'hear' player, unless player moves

Hmm when I gave npc's only hear sense AssessPlayer function was never triggered which made me think this sense is unused.

Try commented 1 month ago

Hmm when I gave npc's only hear sense AssessPlayer function was never triggered which made me think this sense is unused

AFAIR, hear is used when you entering someone else's house

thokkat commented 1 month ago

I tested with all senses disabled and npc reactions still work when entering a house. Only disabling EnterRoom and QuietSound passive percs would make npcs ignore player.

Try commented 1 month ago

I tested with all senses disabled and npc reactions still work when entering a house.

I'm de confirming: when testing on Harad's house. Sneak-in works, as long as player in 'sneak-mode'. Going from sneak to regular walk, alarms Brian and Harad, even if player is inside inner area (bedroom?)

thokkat commented 1 month ago

I'm de confirming:

Yes what I said was for normal walking, same as you describe when going from sneak to walk. But this recognition works with no senses enabled at all. That would mean passive perc activation is not connected to senses and it's still unclear if Hear sense is ever needed.

Try commented 1 month ago

That would mean passive perc activation is not connected to senses and it's still unclear if Hear sense is ever needed.

It was hard to test in vanilla for me; So far:

Here I've been using console commands to edit senses, and this may affect methodology. And case with senses = 1 - mean that at some point senses were reset to defaults by the game (possibly call to Perception_Set_Normal)

thokkat commented 1 month ago

Here I've been using console commands to edit senses, and this may affect methodology.

I directly edited Perception.d to prevent overwriting and running game with reparsed scripts.

senses = 0 - completely disables reaction for entering the house

My test house was behind Zuris, but Harald is same. Set senses to zero in script or left it default and used marvin, reaction still works.

thokkat commented 1 month ago

video how it looks for me:

https://github.com/Try/OpenGothic/assets/100468436/2d1c819b-b7b0-4162-b3ff-2080be5a8623

Try commented 1 month ago

video how it looks for me:

My testing case was almost same, except I've entered building while sneaking. Once asserted that there is not early alarm - cancel sneak, and made a noise. How this case works for you? Are they reacting anyway?

thokkat commented 1 month ago

How this case works for you? Are they reacting anyway?

Sometimes they react on first step, sometimes it takes more but then they react. Behavior is same with default senses and senses=0.

In marvin g there is P.detect output. From testing it looks like this shows yes if a perc is triggered with player as source. Walking only one step at a time seems to trigger AssessQuietSound only every second step which would explain the above.

Try commented 1 month ago

Started new issue to track sound-senses: https://github.com/Try/OpenGothic/issues/604