Triggering something via camera alarm

A refuge for those migrating from the fallen DXEditing.com and a place for general discussion relating to Deus Ex editing (coding, mapping, etc).
User avatar
Neveos
X-51
Posts: 875
Joined: Wed Mar 03, 2010 1:29 am

Triggering something via camera alarm

Post by Neveos »

It's annoying me that the only consequence that can result from a camera alarm is that the NPCs become alerted. I'm able to turn NPCs temporarily hostile by having them view distress in other NPCs as a result of the alarm, but as for triggering bots, turrets, doors, etc, I can't seem to be able to, or think of a work around.

A similar gameplay mechanic is simply to have hostile, but defenseless NPCs patrolling an area. If they spot the player, they will trigger an alarm unit, and -that- can trigger stuff, but the camera, no.
What I do in my other free time:
http://www.youtube.com/watch?v=e3FfPUKuGsQ
DDL
Traditional Evil Scientist
Traditional Evil Scientist
Posts: 3791
Joined: Mon Oct 17, 2005 10:03 am

Re: Triggering something via camera alarm

Post by DDL »

Hrmm..try this (untested)

Code: Select all

Class SecurityCameraTrig extends SecurityCamera;

var(securityCamera) Name TriggerEventName; 

//since trigger and untrigger involve EVENT, 
//we want to retain that functionality while
//allowing the cam to trigger stuff separately,
//hence: special, camera-specific event property


function TriggerEvent(bool bTrigger)
{
	local actor A;

	bEventTriggered = bTrigger;
	bTrackPlayer = bTrigger;
	triggerTimer = 0;

	// now, the camera sounds its own alarm
	if (bTrigger)
	{
		AmbientSound = Sound'Klaxon2';
		SoundVolume = 128;
		SoundRadius = 64;
		LightHue = 0;
		MultiSkins[2] = Texture'RedLightTex';
		AIStartEvent('Alarm', EAITYPE_Audio, SoundVolume/255.0, 25*(SoundRadius+1));

		// make sure we can't go into stasis while we're alarming
		bStasis = False;
		//-DDL Added
		//Fire off any associated events
		//since we know the player is the only person who sets us off, use him
		foreach AllActors(Class'Actor', A, TriggerEventName)
		{
			A.Trigger(self,getplayerpawn());
		}
			
	}
	else
	{
		AmbientSound = Sound'CameraHum';
		SoundRadius = 48;
		SoundVolume = 192;
		LightHue = 80;
		MultiSkins[2] = Texture'GreenLightTex';
		AIEndEvent('Alarm', EAITYPE_Audio);

		// reset our stasis info
		bStasis = Default.bStasis;
		//-DDL Added
		//Untrigger here too
		foreach AllActors(Class'Actor', A, TriggerEventName)
		{
			A.UnTrigger(self,getplayerpawn());
		}
	}
}
Which is basically a security camera that now fires off a trigger when it goes alarmy (and untriggers when it calms down). Because the original camera used trigger and untrigger to propagate trigger calls (in a manner which was probably never used but that I was reluctant to fuck with in case I've missed something), I've added a separate event property, triggerevent: use this one for triggering shit via camera detection. :)


Edit: changed name property coz I'm a 'tard.
Last edited by DDL on Thu Nov 24, 2011 8:47 am, edited 1 time in total.
User avatar
Neveos
X-51
Posts: 875
Joined: Wed Mar 03, 2010 1:29 am

Re: Triggering something via camera alarm

Post by Neveos »

HAHAA!!!

I actually feel remorseful for how helpful you have been to this mod. Like, if I weren't selling clothes all day for minimum wage I would be throwing money at you.
What I do in my other free time:
http://www.youtube.com/watch?v=e3FfPUKuGsQ
User avatar
Neveos
X-51
Posts: 875
Joined: Wed Mar 03, 2010 1:29 am

Re: Triggering something via camera alarm

Post by Neveos »

Sorry I seem to be getting this error:

Image

maybe I did something wrong?
What I do in my other free time:
http://www.youtube.com/watch?v=e3FfPUKuGsQ
DDL
Traditional Evil Scientist
Traditional Evil Scientist
Posts: 3791
Joined: Mon Oct 17, 2005 10:03 am

Re: Triggering something via camera alarm

Post by DDL »

Nope, my bad: I called the new 'event' name 'triggerevent', when that's also the name of the function cameras call when alerted...I am an idiot.

I've updated the code. Sorry.
User avatar
Jonas
Off Topic Productions
Off Topic Productions
Posts: 14224
Joined: Sat Apr 24, 2004 9:21 pm
Location: Hafnia

Re: Triggering something via camera alarm

Post by Jonas »

Guess it doesn't matter now, but we have a trigger in TNM that can do this, as well as a few other things. I think it's called AIEventTrigger or something like that, you can define any AI event in the game to be its trigger condition, including alarms or distress or whatever, so it can pick up those stimuli just like any NPC and trigger whatever you set it to just like a normal trigger.
Jonas Wæver
Chief Poking Manager of TNM

I've made some videogames:
Expeditions: Rome
Expeditions: Viking
Expeditions: Conquistador
Clandestine
DDL
Traditional Evil Scientist
Traditional Evil Scientist
Posts: 3791
Joined: Mon Oct 17, 2005 10:03 am

Re: Triggering something via camera alarm

Post by DDL »

That is actually a very nice idea: I know I already HAVE the code for that, or at least could get it easily from one of the three (!!!) TNM installs on my 'pooter, but for everyone else: post the code?

I'm sure shane/nick won't mind.. :D
User avatar
Neveos
X-51
Posts: 875
Joined: Wed Mar 03, 2010 1:29 am

Re: Triggering something via camera alarm

Post by Neveos »

Jonas wrote:Guess it doesn't matter now, but we have a trigger in TNM that can do this, as well as a few other things. I think it's called AIEventTrigger or something like that, you can define any AI event in the game to be its trigger condition, including alarms or distress or whatever, so it can pick up those stimuli just like any NPC and trigger whatever you set it to just like a normal trigger.
Can't seem to figure it out.

So let's say you set AIEvent to "WeaponDrawn". When your weapon is drawn, it fires the event property, yes? How does the trigger detect that your weapon is drawn? Don't worry if you don't know. Maybe it is something like, a pawn in the collision radius of the trigger must experience the AI event? I tried drawing the weapon in the collision radius. Walking into the collision radius with it drawn. And pulling it out on an NPC set to fear it. Can't seem to make it work. Maybe I'll try other 'AIEvent's and see what happens.

Here's the code:

Code: Select all

class AIEventTrigger extends Trigger;

/*
possible events are:
Futz,
MegaFutz,
WeaponDrawn,
WeaponFire,
Carcass,
LoudNoise,
Distress,
Projectile,
Alarm,
god knows what else
*/

var() name AIEvent; 

function PostBeginPlay()
{
	Super.PostBeginPlay();
	AISetEventCallback(AIEvent, 'EventOccured');
}

singular function Touch(Actor Other)
{
	// does nothing when touched
}

function Trigger(Actor Other, Pawn Instigator)
{
	// does nothing when triggered
}

function EventOccured()
{
	local actor a;
	if (Event != '')
	{
		foreach allactors(class'actor', a, Event)
			a.Trigger(self, none);
	}

	if (bTriggerOnceOnly)
		AIClearEventCallback(AIEvent);
}

defaultproperties
{
}
What I do in my other free time:
http://www.youtube.com/watch?v=e3FfPUKuGsQ
DDL
Traditional Evil Scientist
Traditional Evil Scientist
Posts: 3791
Joined: Mon Oct 17, 2005 10:03 am

Re: Triggering something via camera alarm

Post by DDL »

Various things you can do cause you to fire off AISendEvents, and what AISetEventCallback(AIEvent, 'EventOccured'); is doing is saying "on detection of the AIevent specified, call the function EventOccured(), which then does your triggering.

This detection is not based on collision radii or anything trigger-side, it's all based on how the event itself is emitted. Also, the trigger is firing off its event entirely independently, pawns are totally not needed (though the event the trigger is firing almost certainly will involve pawns, I would guess).

Looking at deusexweapon, it seems that weapondrawn is emitted as EAITYPE_Visual, and it appears to be constant as long as the weapon is out (i.e. it's AIStartEvent, not AISendEvent, so it's a continuous broadcast, not a one-shot send off).

So I'd say it'd work as long as your trigger can see your player, but it might not consider the trigger to be something capable of seeing (if you get what I mean). Still, I'd make sure the trigger is physically able of tracing a line of sight to the player (rather than stuck in the void, for instance).

Also, make sure your weapon is one that actually emits weapondrawn signals, coz some of them don't (the PS20, the baton and the crowbar, according to the code), since if your NPC isn't reacting to your weapon either, maybe it simply isn't sending those signals.


Why not detail exactly how you have it set up?
User avatar
Neveos
X-51
Posts: 875
Joined: Wed Mar 03, 2010 1:29 am

Re: Triggering something via camera alarm

Post by Neveos »

OK yeah it works. I had it set to turn on a triggered sound which would have been playing near a phone in the next room. Apparently, when it stops seeing the gun, it triggers again, which was then turning off the sound when i went to check earlier. I found this out by placing the trigger next to a vent grate which it toggled instead. I'm idiot, essentially.

Anyway, this seems useful, but I don't know how yet (besides pulling a gun out on a baby crib and it triggering "baby crying"), and I'm wondering:

What are the names of the AI Events?
What I do in my other free time:
http://www.youtube.com/watch?v=e3FfPUKuGsQ
User avatar
Jonas
Off Topic Productions
Off Topic Productions
Posts: 14224
Joined: Sat Apr 24, 2004 9:21 pm
Location: Hafnia

Re: Triggering something via camera alarm

Post by Jonas »

Neveos wrote:

Code: Select all

/*
possible events are:
Futz,
MegaFutz,
WeaponDrawn,
WeaponFire,
Carcass,
LoudNoise,
Distress,
Projectile,
Alarm,
god knows what else
*/
Jonas Wæver
Chief Poking Manager of TNM

I've made some videogames:
Expeditions: Rome
Expeditions: Viking
Expeditions: Conquistador
Clandestine
User avatar
Neveos
X-51
Posts: 875
Joined: Wed Mar 03, 2010 1:29 am

Re: Triggering something via camera alarm

Post by Neveos »

oh I was referring to the 'god knows what else' part. The trigger is obviously extremely useful for very non-combative levels. Such levels I usually mentally refer to as "that level in N64's "Mission Impossible" that everyone loves because you don't fight anyone" http://www.youtube.com/watch?v=h4yR1ebP ... re=related
What I do in my other free time:
http://www.youtube.com/watch?v=e3FfPUKuGsQ
User avatar
Jonas
Off Topic Productions
Off Topic Productions
Posts: 14224
Joined: Sat Apr 24, 2004 9:21 pm
Location: Hafnia

Re: Triggering something via camera alarm

Post by Jonas »

Well it's possible that "god knows what else" was just put in there because you never know what weird code snippets are hidden around the classes in Deus Ex.
Jonas Wæver
Chief Poking Manager of TNM

I've made some videogames:
Expeditions: Rome
Expeditions: Viking
Expeditions: Conquistador
Clandestine
User avatar
Neveos
X-51
Posts: 875
Joined: Wed Mar 03, 2010 1:29 am

Re: Triggering something via camera alarm

Post by Neveos »

Hey, I'm sorry, but while the AIEventTrigger is essentially all I need for this function (thanks), I ran into this problem with the TrigCamera:

If I get its attention and then hide, it will crash the moment the camera stops being alert, and it gives this error (incase you know what it means. Seems to have to do with the player's "log")

Image
What I do in my other free time:
http://www.youtube.com/watch?v=e3FfPUKuGsQ
DDL
Traditional Evil Scientist
Traditional Evil Scientist
Posts: 3791
Joined: Mon Oct 17, 2005 10:03 am

Re: Triggering something via camera alarm

Post by DDL »

So...what is it triggering?
Post Reply