Distance parameters for A_Look, A_Look2 and A_TurretLook

Moderator: GZDoom Developers

User avatar
Skippy
Posts: 695
Joined: Sun Nov 20, 2005 9:57 am
Location: Belfast, NI

Distance parameters for A_Look, A_Look2 and A_TurretLook

Post by Skippy »

I'd like to suggest the addition of two parameters to the A_Look, A_Look2 and A_TurretLook action functions.

dist_sight would specify the radius, in mapunits, within which the function call looks for valid targets by LOS. (This obviously has no use in A_TurretLook.)

dist_sound works the same way, but for noise targets instead.
User avatar
Kate
... in loving memory ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Post by Kate »

This could be useful for creating short-sighted monsters that won't react beyond a certain point.

If possible, there should also probably be an exclude range that would be the reverse, causing the monster not to detect you if you're closer than a certain range. Combining the two would create a "doughnut" effect where the monster will only notice you between x and y ranges, which I could imagine could be useful for robotic enemies, like a turret that can see you from a distance thanks to a camera or sensor, but won't notice you if you're standing under it.
User avatar
Skippy
Posts: 695
Joined: Sun Nov 20, 2005 9:57 am
Location: Belfast, NI

Post by Skippy »

Awesome idea Kate, I'd definitely have a use for an exclude parameter(s).
User avatar
Kate
... in loving memory ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Post by Kate »

And now into Pipe Dream world...

FOV would give an approximate angle of the field of view of the actor, inside of which it will notice you. An FOV of 360 would be the same as specifying the +LOOKALLAROUND flag. Obviously this would also be useless for A_Look2/A_TurretLook.

Though FOV could probably be better specified as an actor property instead of an argument, that way it can be inhereted.

Edit: Hence the pipe dream remark. =S
Last edited by Kate on Wed Oct 03, 2007 5:07 am, edited 1 time in total.
User avatar
Skippy
Posts: 695
Joined: Sun Nov 20, 2005 9:57 am
Location: Belfast, NI

Post by Skippy »

I wouldn't hold your breath. :?
On Oct 22 2006, Skippy wrote:My second suggestion is an additonal actor property for DECORATE: FOV (int angle). This property would determine the width of the angle in front of the actor within which they can see targets. The default would be 180, which appears to be the standard logic for enemies (as any time you venture further than level with them in their peripheral vision, they wake up). Values of, say, 30 would mean that enemies would only detect targets moving directly in front of them, and a value of 360 would be equivalent to setting the +LOOKSALLAROUND flag (cf the Archvile).
EDIT: nothing wrong with dreaming. Great minds think alike :lol:
ant1991331
Posts: 598
Joined: Fri Jun 24, 2005 3:19 am
Location: Makin tracks with jetboots

Post by ant1991331 »

I think A_JumpIfCloser in the See state would be a good alternative for this.
User avatar
Skippy
Posts: 695
Joined: Sun Nov 20, 2005 9:57 am
Location: Belfast, NI

Post by Skippy »

I assume you mean something like this?

Code: Select all

Spawn:
   POSS AB 4 A_Look
   Loop
See:
   TNT1 A 0 A_JumpIfCloser(128, "WakeUp")
   Goto Spawn
WakeUp:
   POSS ABCD 4 A_Chase
   etc.
This would crash due to an infinite loop if the player gets into the enemy's field of vision but outside of the specified range. Even if we increase the duration of the A_JumpIfCloser call, from a technical standpoint such a hack is unsatisfactory. At best, all it would do is stop the enemy from reacting to seeing the player - the enemy would still assign the player as its target the minute the player stepped into its field of vision, and would continually jump between the Spawn and See states until the player wandered into range.

This creates all kinds of side-effects e.g. the player enters LOS of the enemy from a far distance, then is able to navigate around and behind the enemy without entering the range specified by A_JumpIfCloser. The enemy has seen the player already, and is now just waiting for the player to get into range. Thus, even if the player 'sneaks up' behind the enemy while the enemy is facing the other direction, the enemy will still 'wake up' and go after the player once the player is close enough, as the enemy set the player as its target the minute he wandered into LOS. Co-op play in which only one player gets in range could also be screwed up. A_JumpIfCloser also can't distinguish between visual and noise targets, one of the core requirements of this feature suggestion.

It would also require an explicit A_PlaySound call for the enemy's 'wake up' sound, as defining a seesound property would result in the sound looping indefinitely until the player gets in range (as the enemy would, as I've said, simply be jumping between the Spawn and See states.)

Lastly, the Missile and Melee states would require modification to jump past the distance check in the first line of the See state. Basically, the whole idea is a little too hackish (and believe me, I've really, really tried). :?
User avatar
Kate
... in loving memory ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Re: Distance parameters for A_Look, A_Look2 and A_TurretLook

Post by Kate »

I understand why this is not working now.

In order for A_JumpIfCloser to work, it needs a target. In order for A_Look to work, it needs no target, as it looks for a target, and jumps to a see state if it has one.

See the problem here?

That causes an infinite loop because A_Look forces the actor directly into it's see state because it sees that the actor already has a target (which is needed for A_JumpIfCloser to work), which jumps back to the Spawn state without a delay, resulting in an endless back and forth ping-pong between Spawn and See states.

What's really needed here is a way of being able to clear the target for a specified actor only, rather than all of the actors in the current sector as is done for [wiki]A_ClearSoundTarget[/wiki].

A code pointer to unset the calling actor's target would be enough to solve this.

EDIT: And if ACS also had this ability, it could be combined with SetActorState to make a monster completely forget about it's target.

Hmm, thinking further into it, parameters would probably be needed for this case, mainly the ability to turn off LOS and/or noise checks separately, and a state to jump to rather than being hard-coded directly to the See state.
Last edited by Kate on Tue Dec 11, 2007 4:12 pm, edited 1 time in total.
User avatar
Skippy
Posts: 695
Joined: Sun Nov 20, 2005 9:57 am
Location: Belfast, NI

Re: Distance parameters for A_Look, A_Look2 and A_TurretLook

Post by Skippy »

SnowKate709 wrote:What's really needed here is a way of being able to clear the target for a specified actor only, rather than all of the actors in the current sector as is done for [wiki]A_ClearSoundTarget.[/wiki]
Does A_ClearSoundTarget even work? I've never had any success with it or with [wiki]A_KlaxonBlare[/wiki]'s supposed 'clear target' functionality (as you know, I filed a bug report about it). If you had a demo showing A_ClearSoundTarget working correctly I could stop thinking I'm insane and/or stupid.
SnowKate709 wrote:A code pointer to unset the calling actor's target would be enough to solve this.

EDIT: And if ACS also had this ability, it could be combined with SetActorState to make a monster completely forget about it's target.
Absolutely, completely seconded, thirded, and everything after that. :lol:
User avatar
Kate
... in loving memory ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Re: Distance parameters for A_Look, A_Look2 and A_TurretLook

Post by Kate »

Hmm.

I was working on this and in around a day or so I managed to make a working implementation of the following:

Code: Select all

A_LookEx(int flags, fixed minseedist, fixed maxseedist, fixed maxheardist, fixed fov, state seestate)
flags are as follows:
  • 1 (LOF_NOSIGHTCHECK) - Don't process sight checks (makes monster blind).
  • 2 (LOF_NOSOUNDCHECK) - Don't process sound target checks (makes monster deaf).
  • 4 (LOF_DONTCHASEGOAL) - Don't leave to chase after a goal from this state, even if we have one.
  • 8 (LOF_NOSEESOUND) - Don't play the actor's sight sound if it wakes up from this state.
  • 16 (LOF_FULLVOLSEESOUND) - Play the see sound globally at full volume (like a boss)
minseedist is the "exclude range" (minimum sight distance) of the monster in map units; if greater than 0, the monster will not see a player who is closer than this. If this is set, the monster also will not wake up if "touched" (so it can be set smaller than the radius to prevent the monster from reacting if the player comes up from behind).

maxseedist is the maximum view distance of the monster, in map units. it will not see any players farther away than this. 0 means unlimited (as in doom).

maxheardist is the maximum earshot of the monster, it will not react to sounds from players farther away than this. 0 means unlimited (as in doom).

fov is the field of view of the monster; a narrower fov means the player has to be more centered in front of the monster for it to notice the player. setting this to 0 uses the old default of 180 degrees, smaller values make the fov narrower, larger values wider. 360 means look in all directions.

seestate is the state the monster will jump to if it acquires a target. Default is "See" (as in doom).

Problems:
  • Ignores the +LOOKALLAROUND actor flag (haven't gotten to that just yet, will in a bit), I'll probably just have it force the FOV to 360. AMBUSH works as expected, and takes sight distances into account.
  • Due to the way friendly monster logic works, it doesn't do anything special with friendlies. It does currently work with thing_hate, though.
  • maxheardist does not play well with the old sound target handling code. If the compat option is on and you fire in the sector the monster is in, it will wake up if you come within hearing distance of the monster, regardless of your visibility or whether you made another sound or not afterward (since the sound target is assigned to the sector rather than the actor). I'm not exactly sure how to fix this.
  • For some reason my general sanity checks for the parameters were causing the code not to work as expected, so I had to remove them. As a result it is feasable to pass it entirely invalid values which will cause unpredictable behavior or possible crashes. I'll try fixing this once I figure out what's making them not work.

Code: Select all

A_ClearTarget
Makes the calling actor forget about it's target, sound target, and last target. You can call this before jumping back to a monster's idle states to make a monster "give up" trying to chase after it's target after a while (for ex. if it's too far away), after which it will just go back to being bored or whatever.

I'll post the code if anyone wants it. I didn't modify the original sight check code, instead I made copies of the functions in question and edited those, so it's pretty just an addition to the existing behavior. The binary is here if you want to mess around with it to find other problems or things I missed.

(This is my first time actually ever compiling something with mingw so I probably missed some kind of optimization somewhere which explains the obscene file size)
Last edited by Kate on Thu Dec 20, 2007 3:55 pm, edited 3 times in total.
User avatar
Nash
 
 
Posts: 17296
Joined: Mon Oct 27, 2003 12:07 am
Twitch ID: nashmuhandes
Github ID: nashmuhandes
Location: Kuala Lumpur, Malaysia

Re: Distance parameters for A_Look, A_Look2 and A_TurretLook

Post by Nash »

Please post the code so that the developers can take a look at it.
User avatar
Kate
... in loving memory ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Re: Distance parameters for A_Look, A_Look2 and A_TurretLook

Post by Kate »

Alright. Give me a bit to copy the added stuff into new files so I can post that as well...

Also, nice cat.

Here. Since I didn't modify any existing code I just copied the lines that were added to the original files and pasted them into separate files. The file names are the respective files where they belong. You can add these in whatever order works and it should work as intended, the new functions for the cpp files were added at the end, and the h and wadsrc files were added near the counterparts they're based off of (A_LookEx under A_Look) or close to the end (A_ClearTarget).
Last edited by Kate on Thu Dec 20, 2007 2:04 pm, edited 1 time in total.
User avatar
Nash
 
 
Posts: 17296
Joined: Mon Oct 27, 2003 12:07 am
Twitch ID: nashmuhandes
Github ID: nashmuhandes
Location: Kuala Lumpur, Malaysia

Re: Distance parameters for A_Look, A_Look2 and A_TurretLook

Post by Nash »

Just tried your binary. Hey, this is nice. Could be used to make stealth-based mods. I've also always wanted to create monsters in Doom that would give up chasing after you but didn't think it was possible before this.

You really should post the code.

BTW, thanks for the compliment. He was my little buddy for 17 years. Had to euthanize and bury him yesterday due to an uncurable tumour. =( I'm still having a hard time trying to accept that he's gone...
User avatar
Kate
... in loving memory ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Re: Distance parameters for A_Look, A_Look2 and A_TurretLook

Post by Kate »

Aw. =( I send consolences ♥

Unfortunately I've never been able to own a cat because I'm highly allergic to them. x.x

Anyway, this is kinda my first time ever coding in C++ (insert people gasping like I committed heresy) so it might be a bit messy or weird. I'm used to Python's OOP so that kinda helped me out with this. Everything else I just learned to do along the way. Constructive comments would be appreciated.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48040
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Distance parameters for A_Look, A_Look2 and A_TurretLook

Post by Graf Zahl »

Added - with a small change. Full volume see sound is no longer dependent on MF2_BOSS but on a new function flag called LOF_FULLVOLSEESOUND. I also renamed LOF_NOWAKEUPSOUND to LOF_NOSEESOUND.

I kept the A_LookEx code in a separate file because I don't want to add such a large chunk to an already quite large file.

Return to “Closed Feature Suggestions”