WiseSeq: Scripted Sequences

From Valve Developer Community
Jump to: navigation, search


This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.

The first thing we need is an NPC and for this example we are going to use my favorite: npc_zombie. There’s only one used in this so let’s just name it: zombie. We will need to name the entities in this tutorial so they can reference each other.

Pull up the properties for our npc_zombie and click on the “Model” tab at the top. Cycle down through the Sequence list. You can test the different animations here. For our example we are going to start the Zombie out sitting down. We will use a trigger to wake our Zombie. The Zombie will then stand up and attack us.

One flag is set for our Zombie: Template NPC. I have also created one Output for our Zombie in case it gets damaged before it is triggered.

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnDamaged zombieSeq BeginSequence 0.00 No

“zombieSeq” is the name of our scripted_sequence. This is where we will add the sequences for our Zombie to stand up and to initially use a sitting position. When we took at look at the Sequence list above we would have picked the ones that we plan on using here.

  • Name: zombieSeq
  • Target NPC: zombie
  • Pre Action Idle Animation: slump_a
  • Action Animation: slumprise_a
  • Search Radius: 512
  • Move to Position: Instantaneous
  • Flags: No Interruptions, Override AI, Priority Script

Our next entity is one npc_template_maker.

  • Name: zombieTemplate
  • Start Disabled: No
  • Num. of NPCs: 1
  • Max Live NPCs: 1
  • Name of template NPC: zombie
  • Radius: 256
  • Dest. Criterion Visible: Don’t care
  • Dest. Criterion Distance: Don’t care

One Output is needed for our npc_template_maker:

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnSpawnNPC zombieSeq MoveToPosition 0.00 No

To put all this in motion we use one trigger_once.

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnTrigger zombieSounds PlaySound 0.00 No
Io11.png OnTrigger zombieSeq BeginSequence   0.00 No

"zombieSounds" is an ambient_generic that I’ve used to play the sound of a girl screaming when the Zombie wakes. It is not needed but things like this are easy to do and make your scripted NPC’s all the better.

  • Name: zombieSounds
  • Sound Name: ambient/creatures/town_child_scream1.wav
  • Volume: 10
  • SourceEntityName: zombie

See also