Post tutorial RSS Scripted conversations and Cameras/alarms

How to script NPCs to talk to each other and how to setup cameras/alarms

Posted by on - Intermediate Mapping/Technical

Originally posted here: nolfstuff.nolfworld.com/tutorials.htm

Written by: Linden May

Mirrored here for archival purposes

Scripted Conversations

I will explain how to make one of those funny conversations between goons that you hear through the game.

  • To make a funny conversation, you first make an AI volume, and insert 2 AIs. Then, place a 'CinematicTrigger' between the two AIs (it doesn't have to be between them, but it makes it easier to find), and a 'Trigger' where you want the player to activate the conversation (you might have to change the 'Dims' property to make sure that the player can't avoid it). Now, under the 'Targets' property of the 'Trigger', set 'TargetName1' to the name of your 'CinematicTrigger' (you can browse to it by using the 'B' button - it'll be under 'CinematicTrigger'). Set 'MessageName1' to 'msg Name_of_CinematicTrigger on', and now when the player walks past this point, the conversation will start.

    With the 'CinematicTrigger', you will have to change a few properties to get the right results:
  • 'CanSkip' - for a conversation, this should be false, I suppose;
  • 'OneTimeOnly' - should be true;
  • 'StartOn' - should be false;
  • 'RemoveBadAI' - should be false;
  • Under 'Camera', 'CreateCamera should be false;
  • Under 'KeyFramer', 'CreateKeyFramer' should be false.

    By all means fiddle with these settings, but for a conversation, the above should be used. I don't know much about the other properties at the moment.

    Under 'Dialogue', the general idea is to set 'Dialogue(n)' to the filename of the line of dialogue you want to use, minus the .wav extension (i.e. '14000' - funny by the way). Then set 'WhoPlaysDialogue(n)' to the name of the AI that you want to say the line. You can put commands under 'StartDialogueTriggerMessage(n)' and 'StartDialogueTriggerTarget(n)' to say make an AI walk off or something. I chose a conversation from 'Misfortune in Morocco, Scene 2' for my example - lines 10316 - 10335.

    Have fun!

Alarm system/Cameras

This tutorial is about adding a simple camera security system to your level. I haven't included AI to react to the alarm yet, because so far I don't know how to... The tutorial contains 3 rooms, a starting room, a room with a camera, and a room with a switch to turn off the alarm. This tutorial outlines how to use objects like 'SoundFX' and 'Switch' as well as 'Camera' and 'Trigger'. The level is based on earlier tutorials, so it will look familiar, and so I'm not going to describe how to make the doors or the rooms. I did this relatively quickly, so if you notice any gaping holes in the map or this text, email me.


The first thing to do is to find a place in the middle of your level (or wherever suitable), and add a 'SoundFX' object. For clarity, call it 'AlarmSound1', or whatever you will remember (I'll call it 'AlarmSound1' from now on). The properties that need to be set are 'Sound', which should be 'snd\event\alarm1.wav', 'OuterRadius' and 'InnerRadius' which should be set to a value that will cover the level to your satisfaction. Experimentation for the right effect will be required, I set mine to 600 each, which covered the level nicely, and wherever you go the alarm is the same volume. 'InnerRadius' sets the loud area, and 'OuterRadius' sets the quieter area, as if you are walking away from the sound.

The next thing to add is a trigger which will set off the alarm sound, and can be locked so that the alarm can't be retriggered after it is set off. Put this somewhere near 'AlarmSound1', so you can find it easily, and name it 'AlarmTrigger'. Properties that need to be set:

  • 'PlayerTrigger' = 'false' (so that the player can't trigger the alarm by walking past the trigger)
  • 'Targets' -> 'TargetName1' = 'AlarmSound1'
  • 'Targets' -> 'MessageName1' = 'msg AlarmSound1 on' (turns on the alarm sound)
  • 'Targets' -> 'TargetName2' = 'AlarmTrigger1'
  • 'Targets' -> 'MessageName1' = 'msg AlarmTrigger1 lock' (so that when the alarm is triggered, it can't be triggered again until it is unlocked)

Next, you need to add the 'SecurityCamera' object. The blue line shows the front facing point, so set 'Rotation' -> 'Yaw' to the angle you want the camera to be at at the middle of it's travel. 'Rotation' -> 'Pitch' should be set so that the camera is at the correct angle in reference to the roof. Other Properties to set:

  • 'SpotTarget' = 'AlarmTrigger1'
  • 'SpotMessage' = 'msg AlarmTrigger1 trigger' (when the camera spots the player, it triggers the 'AlarmTrigger1' object)
  • 'DeathTriggerTarget' = 'AlarmTrigger1'
  • 'DeathTriggerMessage' = 'msg AlarmTrigger1 trigger' (If the camera is destroyed by a weapon, it sets off the alarm)
  • 'Yaw1' = the angle of travel from the reference point (blue line) in one direction, in degrees. Default is -45°, which with Yaw2's default value of 45°, adds up to 90° travel.
  • 'Yaw2' = the angle of travel from the reference point (blue line) in the other direction, in degrees. Default is described above.
  • 'YawTime' = the length of time it takes the camera to travel from one extreme to the other, in seconds
  • 'VisualRange' = the distance that the camera can see the player, in DEDIT units. Default is 768 units (I don't know why! Funny value =)
  • 'Yaw1PauseTime' = the length of time that the camera pauses at the 'Yaw1' extreme, in seconds
  • 'Yaw2PauseTime' = the length of time that the camera pauses at the 'Yaw2' extreme, in seconds
  • 'SoundRadius' = the distance that the player can hear the camera moving, in DEDIT units. Default is 896 units (Another funny value =)

With what you've put in, you will now have a camera to set off the alarm. If you also want a switch to turn off the alarm, read on.

Adding a switch to turn off the alarm

So, the alarm noise was geeting on your nerves, eh? You want to turn it off? Well, add a brush that will be your switch, bind it to a 'Switch' object, call it 'AlarmSwitch1', and set these properties:

  • 'Locked' = 'True' (So that the alarm can't be turned off if it is already. Makes sense, I spose :)
  • 'OnTriggerTarget' = 'AlarmTrigger1; AlarmSound1; SecurityCamera0'
  • 'OnTriggerMessage' = 'msg AlarmTrigger1 unlock; msg AlarmSound1 off; msg SecurityCamera0 off' (Unlocks 'AlarmTrigger' so that the alarm can be triggered again, turns off the alarm sound, and shuts down the security camera)
  • 'MoveDist' = the amout of travel with reference to direction defined under 'MoveDir', in DEDIT units. I put 0 here because I didn't want the switch to move. (What the heck is he talking about? If you want a more detailed description of 'MoveDir' etc, get the Example1 tutorial - doors)
  • 'StateFlags' -> 'TriggerClose' = 'False'(The player can't trigger the switch to turn off)
  • Now set 'Targets' -> 'TargetName3' in 'AlarmTrigger' to 'AlarmSwitch1', and 'MessageName3' to 'msg AlarmSwitch1 unlock; off'. This means that when the alarm is triggered, the switch is unlocked, and you can turn the alarm off.
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.