WiseNPC04: Strider walk, patrol and attack

From Valve Developer Community
Jump to: navigation, search


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

I’m not sure how we should label npc_strider. It’s not like other ground based NPC’s. Not only because it’s so tall but also because the AI is much different. It is a marvelous character to work with but you may do better to think of it along the lines of the helicopter.

There are three modes of attack for npc_strider:

  1. Minigun. (Able to shoot at a wide area.)
  2. Cannon. (Bluish beam that alters time and space.)
  3. Legs. (Used to impale players and citizens on the ground.)

When you use Striders in your map the surrounding geometry is very important. Since they are so tall you need to allow about 540 units. They are fairly wide so allow for 300 units. Keep in mind the Strider can crouch and it will step over very tall objects.

Placement of the path_corner and info_node_air_hint for Striders is in the air where the Strider will go through them. These can be stacked on top of each other so they look in Hammer like one object or you can place them next to each other, up to you.

The info_node_air_hint must be set to a Strider node.

In this example I’ve created 4 path_corner entities and each one has a info_node_air_hint placed under it. As mentioned the info_node_air_hint could be placed over the path_corner and grouped with it, this preference has no effect on the outcome in the game.

I haven’t set a starting path_corner for this Strider. We’ll set the starting path_corner with a trigger. The Strider in this example will go to the path_corner and then use each of them in the correct order, as specified in the properties for each path_corner.

As part of the shared AI for the Strider and Scanner you can use them together to suggest navigation as the npc_cscanner can not only follow the Strider but can also relay target locations. (d3_c17_12b features this.)

For the Strider in this example I haven’t changed any properties other than giving it a name.

When the map starts we spawn the Strider with a point_template.

  • Name: strider_template
  • Template 1: strider_1
  • Flags: Preserve entity names

We also need to add an ai_relationship so the Strider has a disposition towards the Player.

  • Name: ssrelation
  • Subject: strider_1
  • Target: !player
  • Disposition: Neutral
  • Disposition priority: 100
  • Start Active: Yes
  • Reciprocal: No

We will encourage the Strider to walk using an aiscripted_schedule.

  • Name: striderwalking
  • Target NPC: strider_1
  • All in radius: No
  • AI state set to: Set state to ALERT
  • Schedule to run: Walk Goal Path
  • Interruptability: Death
  • Goal entity: strider_1_path_1

In this example I’ve used a trigger_once that the Player will spawn in.

WiseNPC04 trigger o.png

Notice that from this one trigger all of the events for our Strider are fired off at once. The importance here is placed on the timing, which is done by simply adding delays as needed. With the Outputs above we now have:

  1. Strider spawns.
  2. Crouches down then stand.
  3. Begins its patrol route around the map in a circle.
  4. After one minute begins to Hate the Player.
  5. Once it finds the Player it will fire the Minigun and Cannon.
  6. Six seconds later it Likes the Player once more then Breaks into pieces.

See also