WiseNPC01

From Valve Developer Community
Revision as of 07:47, 24 February 2008 by Plykkegaard (talk | contribs) (wiseNPC01 a tutorial ported from sdknuts.net originally created by wisemx)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Look, run and walk

Note.pngNote:This is part of a series of tutorials on NPC’s.

To make the NPC look in a direction or to run and walk can be done with a scripted_sequence. Here’s an Scripted_sequence in-depth look at the scripted_sequence.

Look, run and walkl

In this example we are going to:

  • Wake Alyx.
  • Make her to look in our direction.
  • Make her run far away.
  • Finally she will walk back then die.

We are not going to use Face Poser for this. We are not going to use scripts that need to be loaded.

The first thing to do is place your NPC in the map and give it a name.

Note: I’ve created a displacement for the floor area to illustrate something. The info_node_hint entities on the ground are necessary and will not work if they are buried in the displacement. Raise them up above displacement floors.


For this example I’m using 3 scripted_sequence entities to control Alyx.

WiseNPC01 02.jpg

Give each of your scripted_sequence entities a name. Set the Target NPC property to the name of your NPC, in this example it’s walking.

The Move to Position property is the one that will do the work for us. For each of the 3 scripted_sequence entities Move to Position is:

  • walking_seq01 No - Turn to Face
  • walking_seq02 Run
  • walking_seq03 Walk

The scripted_sequence has a Next Script property you can use.

In this example our second scripted_sequence has walking_seq03 specified for the Next Script. So when Alyx runs to script #2 she will then walk to #3.

To begin the sequence of events I’m using a logic_auto. No changes are made to the logic_auto but these Outputs are added:

Class: logic_auto
Keyvalues Comments
My output Target entity Target input Parameter Delay Only once Comments
Entity-output-icon.png OnMapSpawn walking wake
Entity-output-icon.png OnMapSpawn walking_seq01 BeginSequence 3.00
Entity-output-icon.png OnMapSpawn walking_seq02 BeginSequence 5.00

On the ground between the scripted_sequence entities I’ve placed info_node_hint entities to give the NPC a walking path. Even with the scripted_sequence entities setup properly your NPC won’t walk or run without the info_node_hint entities.

At the final scripted_sequence I’ve created a trigger_once to kill the NPC. OnTrigger, walking, SetHealth, 0

Class: trigger_once
Keyvalues Comments
My output Target entity Target input Parameter Delay Only once Comments
Entity-output-icon.png OnTrigger walking SetHealth 0


In each of these Outputs walking is the name of our NPC Alyx.

When the map loads the logic_auto will begin the sequences, when Alyx gets to sequence #2 it will activate sequence #3 and when Alyx gets to sequence #3 she will step into the trigger and activate the output above, which will cause her to die.

Wrap up

There’s a lot more you can do, hopefully this article have stimulated your imagination.

Credits