Can a trigger_once fire an Output only when it touches Two entities at the same time? Created 3 weeks ago2024-01-31 11:54:46 UTC by Jazveh Jazveh

Created 3 weeks ago2024-01-31 11:54:46 UTC by Jazveh Jazveh

Posted 3 weeks ago2024-01-31 11:54:46 UTC Post #348511
I am curently working on a stealth mechanic, but I'm unsure about something very important. I've set up a Neutral ai_relationship for the patroling NPC, and have parented a trigger_once to an npc_combine_s (the NPC) that acts as its Line-of-sight, and when the player "touches" it, the Relationship gets set to Hate. Also I've added trigger_multiple's as Safe zones, scattered in dark spots around the level, and had them Disable the NPC's Line-of-sight when the player is in them, and Enable it when the player exits them, but do you know if I can have the engine detect if the player is behind a wall, out of line-of-sight? As the title suggests - can I have the NPC's Line-of-sight, the parented trigger_once, check if it "touches" an info_target that's parented to the player AND another info_target that would be behind a wall, and if so, Disable itself? Or is that totally not the way to go about that... i'm having a brain fog moment on this issue. Any suggestions would be helpful!
Posted 3 weeks ago2024-02-02 20:30:05 UTC Post #348532
I've been out of Source mapping for a while, so this might be all wrong, but here's my idea.

Make a second trigger (I will call this the "wall trigger"), identical to the first (the "player trigger"), and make both into trigger_multiple. Set up a filter_activator_name to make the wall trigger react only to your wall info_target. Create a logic_relay.

Set up your player trigger to trigger the logic_relay when it detects the player, and set this up with a small delay – say, 0.1 seconds. Then set up your wall trigger to disable the logic_relay when it detects the wall, without any delay. Lastly, set up the logic_relay to perform whatever actions should be performed when the player is detected, and to disable or delete both triggers.

What's happening is this: the logic_relay does nothing but forward the "player detected" impulse from the player trigger. Think of it as a road or water pipe, stuff just gets funnelled through it. The wall trigger detects if the soldier is looking at a wall and disables the relay if so, meaning if the soldier "sees" the player "through" a wall, the pipe that passes that information on is closed and no alarm is triggered / hostile action initiated / whatever you have planned. And since the player trigger has a slight delay before it fires at the logic_relay, the wall trigger can disable it before that happens. Due to the two trigger nature, your trigger_once has to become a trigger_multiple, as it will repeatedly "see" the player through walls, and the "only once" nature is instead taken over by the logic_relay's "deleted or disable both triggers once the player is detected" output.

A simpler version of this would be to skip the relay and just make the wall trigger disable the player trigger, but I'm not sure how that could be made to work, since both could detect the player and wall simultaneously and the "player detected" output might be fired before it's disabled.

Again, I haven't done any Source mapping for years until recently, so this might be completely wrong, but that's how I would try it. If anyone has a better idea, forget I said anything.
Posted 3 weeks ago2024-02-03 10:53:20 UTC Post #348535
Thank you for your response!

Just to clarify - by player trigger do you mean the one parented to the hostile NPC? And if I rename the player, would the line-of-sight trigger stop working when they pass through it?

I will test what you suggested as soon as possible and report back.
Posted 3 weeks ago2024-02-03 12:39:59 UTC Post #348537
So for some reason whenever I set the line-of-sight trigger_multiple's Delay, it fires the Output to the logic_relay no matter what, even when the wall trigger has detected the info_target before the line-of-sight fires. Though, could the issue be in using OnStartTouch and OnEndTouch on the wall trigger to Toggle the logic_relay? I tried Enable/Disable but both options don't seem to work.
Posted 2 weeks ago2024-02-04 12:33:10 UTC Post #348545
Huh. Like I said, I've been out of it for a while, so I'm not sure, sorry. If I can find the time, I might quickly test it myself in Hammer, but I can't make promises.
Posted 2 weeks ago2024-02-04 13:22:39 UTC Post #348546
It's alright. I might just use Safe zones behind walls and when I do feel like mapping again (this issue really drained me, i've tested 90% of the entities), I'll make a level where it's designed so that it wouldn't be an issue. Though that doesn't sound very fun to me. Anyways, if you get round to trying it out, do let me know please. I'll be forever grateful.
You must be logged in to post a response.