Proximity Triggers & NPC's? Created 17 years ago2006-12-23 08:28:52 UTC by Strider Strider

Created 17 years ago2006-12-23 08:28:52 UTC by Strider Strider

Posted 17 years ago2006-12-23 08:28:52 UTC Post #207278
Righty-o, i'm looking at making something sorta complex here (to me anyway).

I'm looking to trigger certain events when a certain npc comes within and leaves a certain proximity of me (or when i enter a proximity of him). When he is within say 200 units of me, i'd like him to have his usual enemy AI, but when he is beyond those 200 units, i'd like him to have a friendly AI. Don't ask me why, please. There are a bunch of other things i'm looking to trigger when he is within/beyond the proximity, but i can handle those.

AI changes are done via ai_relationships, am i right? I'm pretty sure i can figure the AI side of things out. The proximity trigger is what i really need some help with. Any ideas? Help appreciated as always.
Strider StriderTuned to a dead channel.
Posted 17 years ago2006-12-23 08:57:53 UTC Post #207282
Make a cylinder with a 200 unit radius and tie it to a trigger_multiple. Give it the name of the NPC in the Parent property. Tell it to work only for clients.
Make it trigger whatever you need.

I'm not sure if the opposite would work: giving the trigger_multiple a parent name of !player so it moves along with you...
Posted 17 years ago2006-12-23 09:10:31 UTC Post #207283
Yeah, i thought about doing that but seeing as i want a different event triggered on entering/exiting the field, it wouldn't really work.
Strider StriderTuned to a dead channel.
Posted 17 years ago2006-12-23 09:17:13 UTC Post #207285
Why not? You can trigger events with OnStartTouch/OnEndTouch
right?
Posted 17 years ago2006-12-23 09:18:31 UTC Post #207286
Oh right.. yeah that should work. I'm going to go slap myself in the head now. Thanks. :glad:
Strider StriderTuned to a dead channel.
Posted 17 years ago2006-12-23 11:12:29 UTC Post #207292
now post dumptruck lady like a good strider..

and get working on the xmas GTM or i will cry on you, and you wont be winning a certain award...
Archie ArchieGoodbye Moonmen
Posted 17 years ago2006-12-23 11:37:17 UTC Post #207294
I guess i won't be winning then.

EDIT: I have another question, is it possible to hide or toggle the weapon an npc is carrying? So one minute he's running around with a shotgun, then when i trigger something, it either turns invisible or is removed (i'm happy with either) and can later be restored?
Strider StriderTuned to a dead channel.
Posted 17 years ago2006-12-23 13:24:22 UTC Post #207297
Edit: no idea... If those weapons had a name, you could trigger them with a point_clientcommand and ent_fire + something...
Posted 17 years ago2006-12-23 23:51:47 UTC Post #207358
Alright, i've figured this much out thanks to you:

The weapon doesn't need to be named, just the npc carrying it and it already is. Using the command ent_fire npcname_weapon there are some inputs such as hideweapon (which works perfectly, only there is no command i can find to show the weapon again) or alpha which doesn't seem to work at all (and would be perfect if it did). I'm gonna' need to play with these settings some more.
Strider StriderTuned to a dead channel.
Posted 17 years ago2006-12-24 01:22:16 UTC Post #207362
An npc_combine_s has HolsterWeapon and UnholsterWeapon inputs. Might those work?
Posted 17 years ago2006-12-24 06:37:58 UTC Post #207375
Tried them, and they don't seem to work. Thanks though.
Strider StriderTuned to a dead channel.
Posted 17 years ago2006-12-24 15:09:05 UTC Post #207411
You may be able to use scripted sequences to achieve something close, with Action Animation = draw pistol, PostIdle loop = idle angry.

Looking in the SDK, I haven't figured out yet how to put the NPC into combat mode to get the idle angry part, but there is an animation ACT_METROPOLICE_DRAW_PISTOL (for instance) which you can use with a metro police.

From the code, it appears that, if the npc is in a combat state, ACT_IDLE will get translated into ACT_IDLE_ANGRY and the npc will stand with weapon drawn. Otherwise, ACT_IDLE causes the npc to go to the normal (weapon at side) stance.

So, without being in combat state the result is a quick draw followed by normal idle = not what you need
Posted 17 years ago2006-12-24 17:00:44 UTC Post #207421
BUMP: (in case strider read the previous post)

You should be able to use ai_relationship entities.

Set the NPCs disposition to LIKE until the !player triggers the prox trigger. Then trigger an ai_relationship and have the ai_relationship change the NPC's disposition to HATE (or FEAR?). When the player leaves the prox trigger (OnEndTouch or the like), trigger another ai_relationship to change the NPC's disposition back to LIKE and he'll reholster his weapon.

EDIT: I tried it and it should do what you've described.

ai_relationship named ai_like, starts enabled, subject: the npc, object: !player, disposition: Like

ai_relationship named ai_hate, starts disabled, subject: the npc, object: !player, disposition: Hate

Setup a trigger_multiple near (or Parented to) the npc.

Trigger ai_hate OnStartTouch. Trigger ai_like OnEndTouch.

When the player gets near the npc, he draws his pistol and begins firing. When the player runs away, the npc holsters his weapon and goes to an idle animation.
Posted 17 years ago2006-12-26 06:37:29 UTC Post #207558
I messed around with the ai_relationship entity before and already got the result i wanted. When you approach the combine, he attacks you, when you move away he becomes friendly and follows you due to another ai entity. As to why i want him to do this, it doesn't matter. It was just an experiment where i wanted an invisible 'stealth' combine to stalk you around, become visible when he attacks you up close, and goes invisible when you run away from him. It all works perfectly except for his gun remaining visible... oh well.
Strider StriderTuned to a dead channel.
You must be logged in to post a response.