Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perceptions framework refinements #604

Closed
Try opened this issue Apr 15, 2024 · 8 comments
Closed

Perceptions framework refinements #604

Try opened this issue Apr 15, 2024 · 8 comments

Comments

@Try
Copy link
Owner

Try commented Apr 15, 2024

Followup to discussing here: #589

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

This behavior observed by @thokkat, with .senses = 0, overridden in Perception.d.

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.

In OpenGothic, entering building already emits PERC_ASSESSENTERROOM and PERC_ASSESSQUIETSOUND is wired to ground-sounds, and then feed into senses-framework at WorldObjects::tick. Naturally those perc's are emitted only by player.

@Try
Copy link
Owner Author

Try commented Apr 15, 2024

Current idea is to:

  • bypass senses framework, for PERC_ASSESSENTERROOM/PERC_ASSESSQUIETSOUND and instead loop overs npc's in nearby.
  • remove SENSE_HEAR process from canSense

@Try
Copy link
Owner Author

Try commented Apr 16, 2024

In G1 npc also react inaccurate (or rather do not react) on same PERC_*

@Try
Copy link
Owner Author

Try commented Apr 16, 2024

Both cases should be fixed now, by 42770ae

One other case I'm not sure about is G1 script:

func void B_AssessQuietSound ()
{
	if (Npc_GetDistToItem(self, item) > PERC_DIST_DIALOG)   // what item?
	{
		return;
	};
	....

If player takes item, item wont exist anymore. Maybe bug, maybe this is case of game-logic bleed into UI

@thokkat
Copy link
Contributor

thokkat commented Apr 17, 2024

bypass senses framework, for PERC_ASSESSENTERROOM/PERC_ASSESSQUIETSOUND

With senses=0 a lot of passive percs if not all could be triggered. In Percption.d there is a comment

Passive perceptions are sense-independent (they always go to all NPCs, regardless of whether they are seen/heard or not)

I know comments are sometimes wrong/outdated but here it would support the testing results.

in opengothic npc react only if aiQueue is empty and there is no pending waits (aiWait)

This was introduced in 47c552a to fix npc waking up while sneaking. What was working was using walkmode instead of bodystate. This prevents sending perc if e.g. opening a chest.

- if(ev.groundSounds>0 && isPlayer() && (bodyStateMasked()!=BodyState::BS_SNEAK))
+ if(ev.groundSounds>0 && isPlayer() && (wlkMode&WalkBit::WM_Sneak)!=WalkBit::WM_Sneak)
  world().sendPassivePerc(*this,*this,*this,PERC_ASSESSQUIETSOUND);

One other case I'm not sure about is G1 script

From testing: When just walking around item was never valid making function return early. If dropping something item refers to it.

@Try
Copy link
Owner Author

Try commented Apr 17, 2024

Passive perceptions are sense-independent (they always go to all NPCs, regardless of whether they are seen/heard or not)

Hm, G1-scripts? Can find this lines, for some reason. Do you know what passive mean in regard to perception? Afair at least PERC_ASSESSPLAYER/PERC_ASSESSENEMY cannot work across the wall, so they have to respect distance and ray-cast

@thokkat
Copy link
Contributor

thokkat commented Apr 17, 2024

Hm, G1-scripts?

G2 scripts, comments after FUNC VOID InitPerceptions().

Do you know what passive mean in regard to perception?

Asked that myself too. Found explanation by Ikarus creator some time ago:

A distinction is made between active (searching) and passive (event-driven) perception. Active perception is a perception that is constantly running and checks itself whether something interesting is happening (a prominent example is PERC_ASSESSPLAYER, the constant observation of the player). You could say that the perception triggers a reaction on its own.
Passive perception is a perception that is triggered by very specific events (damage, killing other npcs, mob movement, taking items, etc.). You could say that an event triggers the perception that triggers a reaction. (Strictly speaking, all perceptions can be seen as passive perceptions).

source:
https://forum.worldofplayers.de/forum/threads/747056-Konstanter-Abstand-zu-einem-NPC?p=11695762&viewfull=1#post11695762

As I understand it: What's handled in Npc::perceptionProcess are the active ones with ASSESSITEM/ASSESSFIGHTER missing/unused, others are passive.

Afair at least PERC_ASSESSPLAYER/PERC_ASSESSENEMY cannot work across the wall, so they have to respect distance and ray-cast

When I tested with smell sense only at Harald location AssessPlayer function triggered for thief guild npcs and Gritta in Thorben's house. See sense only should behave how you described, has to be in viewing angle + visibility.

@Try
Copy link
Owner Author

Try commented Apr 18, 2024

Asked that myself too. Found explanation by Ikarus creator some time ago:

Found a better explanation in G2-scripts:

//
//	PERCEPTIONS	( ACTIVE )
//
CONST INT PERC_ASSESSPLAYER  = 1;
CONST INT PERC_ASSESSENEMY   = 2;
CONST INT PERC_ASSESSFIGHTER = 3;
CONST INT PERC_ASSESSBODY    = 4;
CONST INT PERC_ASSESSITEM    = 5;
...
//
//	PERCEPTIONS	( PASSIVE )
//
CONST INT PERC_ASSESSMURDER  = 6;
// all else

Try added a commit that referenced this issue Apr 20, 2024
@Try Try closed this as completed Apr 30, 2024
@thokkat
Copy link
Contributor

thokkat commented May 6, 2024

Two things observed during testing:

Npcs wake up if player is picking a lock in sneak mode. Could be resolved by the mentioned above, use walkmode instead of bodystate for sneak testing.

AssessEnterRoom not sent while sneaking is incorrect. Test case can be house behind Zuris. Guard reacts on enter if sneaking. Openend #618 which fixes a bug that prevented this test case from working in OpenGothic.

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

No branches or pull requests

2 participants