Tutorial: Scripted Last edited 1 year ago2022-09-01 12:15:07 UTC

Download attachment

Animation

A lot of questions on the forums have been about specific scripting techniques. But I think the main thing everyone wanted to know, was how to get monsters to do what the mapper wanted them to do. I would like you to take the time to read the following before you go any further...

Q. Half-Life is full of scripts for most of the model class monsters, so why can't I get them to do what I want?
A. That is because the animation tools in Half-Life were designed to enhance the game they were never designed to give you total flexibility as a post game mapper!. Having said that, there are ways to get your monsters to do things and the idea of this tutorial is to get aquatinted with the basics, so you can get an understanding of how the scripted_sequence and aiscripted_sequence work. This guide is not written to enable you to make a brilliant, awe inspiring scripted event...

I am going to add to this tutorial as we go along, I will try to include things that people want, but I don't want to cover ground that has been done by other sites, and to that end I will list those web sites that are worth a look for more information on scripting.

The first part of this tutorial will be Getting Barney [bob] to open a door. I have built a simple room with a glass divider and two doors. I have placed a Barney on one side of the glass and an info_player_start on the other side of the glass. I have also added an aiscripted_sequence close to the door. There is also another Barney [bill], but more about him later.
Object PropertiesObject Properties
NOTE: I have used an aiscripted_sequence because I like them. The main difference between a scripted_sequence and an aiscripted_sequence is that no matter what happens, the "aiscript" will continue to run. You cannot distract Barney from doing what the script has called him to do, even if you kill him he will complete the script and then die.

Ok, so what's with the settings?

Give your Barney a Name (targetname). I called mine bob You need a name so you can enter that as the Target Monster in the scripted_sequence.

Set up a trigger_once to trigger the aiscripted_sequence. Set it's target as the name of your aiscripted_sequence [in this case door_1_open].

The Door needs a Name for the aiscripted_sequence to target so that when "bob" finishes performing his script, it will open.

The aiscripted_sequence for the opening door:

Angles

Armidillo came up with a good sugestion, mentioning the Pitch Yaw Roll (Y Z X) settings of your aiscripted_sequence or scripted_sequence. These are important, you need the sequence to face in the direction that you want it to be performed. So in the example map, the scripted_sequence for the "security door" (not the one that opens) is set to 270 in the little compass, or 0 270 0 in the Pitch Yaw Roll (y Z X) property. The easiest way I have found to work out which way that really is, is to look at the Top View (x/y) 2D view and have the compass pointing the way you want the script to be acted. It really is that simple. Some earlier versions of WorldCraft have trouble with the compass and so does Hammer 3.5. It pays to select another property and then check that the new compass bearing has been picked up by the property box in the Pitch Yaw Roll (Y Z X) property. The Default is 0 0 0 which will leave the script acting to the left of the Hammer screen.
Ok, that is all you need to use for this example. There are other properties and Flags, but they are not needed for what we want to do.

Second Script

The second scripted_sequence is adjacent the security door. The settings are similar, but I have added in a multimanager and a trigger auto, so that "bob" will knock on the security door with the flashlight animation until the door opening script is triggered. Because the multimanager is looped, bob will return to knocking on the security door after opening the inital door for you.

The multimanager in the example map has been looped [see SlayerA's Multimanager tutorial for more information]. The only other settings that need to be added is the Repeatable Flag. Without it, Barney [bob] will only knock on the door once, regardless of what his idle animation is. The scripted sequence needs to know that the animation can be repeated, and that is why we check the flag. Adding the same animation in the idle animation field does not automatically mean that Barney will perform that animation once he has completed the Action Animation... It works with some animations for some monsters and not others. That is why there is a second Barney [bill]. He is there to show you what it would look like without the multimanager and trigger_auto and repeatable flag.

Action Animation

An animation is a set function that the model will perform when it is called to do so. These animations are sometimes referred to as scripts. The best way to view the animations is with a model viewer like HLMV v1.25. You can cycle through each model and it's animations and then enter the name of the animation in the Action Animation field. In the example map I have used unlatch and Flashlight but with the Barney model there are a few others you could try, like buttonpush or intropush. Animations with "intro" before them are specific to a cut scene of the game, and sometimes require furniture or other prefabs to work correctly.

Just a few more things about scripted sequences, they should be triggered. That way you can control the sequence. If you add a Name (Targetname) to an aiscripted_sequence or a scripted_sequence, the Target Monster will still act on the animation when the map loads. You must add a trigger to get the sequence to run when you want it to run. Once they are triggered, whatever you put in their Target field will be activated at the end of the script. You can enhance this with Multimanagers and that will give you timing and flexibility.
BarneyBarney
So that is the start of this tutorial...
Not much is it? well it is a start. If you have set it up right, Barney will walk towards the security door and perform the flashlight animation. If you move down the hallway you will trigger the door opening aiscripted sequence and Barney [bob] will stop his original animation and come over and open the door for you. He will then go back to hammering on the security door. Barney [bill] will knock once on the glass, and then stand around looking stupid.

I will add to this in the coming weeks, but while your waiting, head on over to 69th Vlatitude, the spawning tank, Collective or Planethalflife for more specific tutorials. A google search for Half-Life scripted sequences brings up a heap of sites, and a lot of them cover stuff like zombies breaking through doors, retinal scanners and general movement.

There are also some scripted example maps in the Map Vault under 'Example Maps' made by our members, check them out.. they are good.

As I said in the beginning, the animations were designed to enhance the gameplay, not to let you build what you wanted. Cool looking scripts that didn't appear in the game usually come from someone doing a lot of coding, model manipulation and stuff we don't really cover at TWHL, unless one of the members has time to write the tutorial??.

Scientist Animations

Ok, Just to add a bit of volume to this tutorial and to give you an idea of what we are talking about, here is a list of all the available animations for the scientist model. Some of them are only applicable to dead scientists and others are used in conjunction with furniture/architecture, like the opening scenes. The idea of this list is to give you something to play with, try them out...

If you haven't viewed these sequences with HLMV or something similar, Then get with the program folks and get viewing!

Disclaimer: I have not actually run all these animations through a scripted_sequence, but I have viewed them all with HLMV. Some of my previous testing indicated animations that looped, and others that didn't when you would expect them to be the other way around. Some of them just don't do what you would expect them to and some don't want to work at all but as I said before, they were not made so you could do cool animations and scripts... They are there for the original game.

Scripted sequences available: As you can see by that little list for the scientist, I am reluctant to spend the next two years checking every animation and writing them down. Lame.. sure is, So If you're really interested, you can find the rest of the scripts at :Planet Halflife, The Half-Life Workshop "Monsterscripts" by Otis. Or by checking the old Wavelength site for a text list by Spider.

7 Comments

Commented 14 years ago2009-08-29 14:13:27 UTC Comment #100593
omg this is so messed up :D
Commented 14 years ago2010-02-24 18:23:49 UTC Comment #100594
tHANKS ur the best
Commented 3 years ago2020-09-10 20:18:29 UTC Comment #102910
why you don't make an examples for full scripts ?
Commented 3 years ago2021-01-23 11:19:38 UTC Comment #103202
How do you get an NPC to walk around "randomly"? I just want to make harmless, killable NPCs to walk around with custom .wav files when they are killed or are "used"
Commented 3 years ago2021-03-11 09:38:20 UTC Comment #103404
How to make monster walk/run to scripted_sequence with using command?
Commented 1 year ago2022-05-03 20:02:48 UTC Comment #104374
i guess you cant.
Commented 1 year ago2022-05-03 20:03:55 UTC Comment #104375
@varhansen To make that you will have to create/edit an entitie for Half-Life. And that, means creating a mod. But if you dont want that, i guess you can use the cockroach NPC?

You must log in to post a comment. You can login or register a new account.