Author Topic: Determining when an enemy is idle  (Read 1960 times)

Offline Smoke39

  • Endtrail
  • ****
  • Posts: 219
  • T:REP 695
    • View Profile
Determining when an enemy is idle
« on: November 09, 2017, 09:42:14 PM »
Been trying to come up with a way to determine when an enemy is just standing or wandering around.  I tried using kActor::GetTarget(), but it seems to get set to the player once you're within a certain range, even before they notice you.  It's also non-null even before that. (edit: this was an error in my testing)

kAI::AIFlags() or the enemy's animation can check for running and attacking, but standing, turning, and walking are all used both in and out of combat.

Any ideas?
« Last Edit: November 11, 2017, 01:17:10 AM by Smoke39 »

Offline BehemothProgrammer

  • Endtrail
  • ****
  • Posts: 228
  • T:REP 810
    • View Profile
Re: Determining when an enemy is idle
« Reply #1 on: November 10, 2017, 04:52:09 PM »
The agitation value(range 0..299) of an enemy tells you if they are going after the target or not. There's no way to get the value directly but certain AIFlags can indicate it's current value. So you could try to simulate the agitation.

- If the ai sees the target then the agitation value will remain at max value 299. The AIF_SEETARGET = (1 << 9) AIFlag doesn't seem to turn off after the enemy loses sight of the target. Maybe the use of the actors CanSee function would be better instead?
- agitation > 150 means the ai is running after you
- if the AIFlag AIF_RUNNING is on then it's value is somewhere between 150 and 299
- agitation is max if AIF_HEARDLOUDNOISE = (1 << 3) or AIF_HEARDQUIETNOISE = (1 << 16) AIFlags is on
- if AIF_DAMAGEPANIC = (1 << 23) was off but is now on then agitation is 299
- takes about 12 seconds for agitation to go from 299 to 0. And about 6 seconds from 299 to 150. (goes down by intervals of 7)

Can the ai see me? (max agitation value)
- ai target is me
- can see me

Is the ai looking for me?
- target is me
- can't see me
- simulatedAgitation > 0

Is the ai wandering around?
- target is null or can't see target
- simulatedAgitation == 0
« Last Edit: November 10, 2017, 04:52:30 PM by BehemothProgrammer »
Turok 2 Co-Op Mod

QTurok | Turok: Mountain of the Sun | WolfenTurok 3D | and more...

Offline Smoke39

  • Endtrail
  • ****
  • Posts: 219
  • T:REP 695
    • View Profile
Re: Determining when an enemy is idle
« Reply #2 on: November 11, 2017, 01:34:22 AM »
I hadn't thought to just set a timer for some reason.  Durr.  Sight and sound might be interesting to mess with sometime, but I think for my current purposes considering an enemy idle 12 seconds after the last time AIF_ATTACKING or AIF_RUNNING was set is sufficient.

For the sake of documentation, since you mentioned a few, are there any other flags that aren't enumerated in the scripting engine that you're aware of?

Thanks for the insight. :)

Offline BehemothProgrammer

  • Endtrail
  • ****
  • Posts: 228
  • T:REP 810
    • View Profile
Re: Determining when an enemy is idle
« Reply #3 on: November 11, 2017, 05:22:50 PM »
Awesome. I noticed the sound flag AIF_HEARDLOUDNOISE gets turned on whenever the player moves inside the enemys loud noise radius which seems to always be set to there sight radius meaning they always go after the player when in sight. It makes me think that since the original game had a walking mode for the player that that was also a stealth concept in the game I never noticed. Makes me want to pop the original back in and just see if that's true. (edit: played the n64 version and walking does indeed prevent loud noise.)

These are the ones I know of (named from the debugai screen):
Code: [Select]
EnumAIFlags
AIF_ATTACKING = (1 << 0), //Already defined
AIF_WASSOLID = (1 << 1), //Already defined
AIF_FIRSTATTACK = (1 << 2),
AIF_HEARDLOUDNOISE = (1 << 3),
AIF_BLOWNAWAY = (1 << 4), //Already defined
AIF_GOBACKTOLEASH = (1 << 5),
AIF_RESURRECT = (1 << 6),
AIF_REGENDELAY = (1 << 8),
AIF_SEETARGET = (1 << 9),
AIF_NOCHASE = (1 << 10), //Already defined
AIF_REGENERATEANIM = (1 << 11),
AIF_NOTHINK = (1 << 12), //Already defined
AIF_RUNNING = (1 << 13), //Already defined
AIF_GETATTENTION = (1 << 14),
AIF_REGENDELAY2 = (1 << 15), //not really sure what this is
AIF_HEARDQUIETNOISE = (1 << 16),
AIF_AWAYFROMLEASH = (1 << 17),
AIF_TELEPORTAWAY = (1 << 18),
AIF_TELEPORTMOVESLOW = (1 << 19),
AIF_TELEPORTING = (1 << 20), //Already defined
AIF_WAITFORCYCLE = (1 << 22),
AIF_DAMAGEPANIC = (1 << 23)

I'm missing 7, 21 and I'm not sure what 15 is but I think it has something to do when an enemy regens.
« Last Edit: November 11, 2017, 10:51:51 PM by BehemothProgrammer »
Turok 2 Co-Op Mod

QTurok | Turok: Mountain of the Sun | WolfenTurok 3D | and more...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal