Actbusy

NPCs have the ability to keep themselves busy without the need for multiple, complex, scripted sequences. The Ai_goal_actbusy entity tells an NPC or group of NPCs to keep themselves busy by acting out certain sequences and animations with the help of info_node_hint entities. Basically, the info_node_hint entity depicts which animations to play, and the ai_goal_actbusy entity picks a random node for the NPC to walk to.

In order for the info_node_hint to tell an NPC what to do, you need to write a set of instructions that are located in a text file called actbusy.txt. This file is located in your scripts folder. For example, I'm using Half-Life 2: Episode Two, so my scripts folder is located at Steamsteamappshalf life 2. If you navigate to this folder right now, there might not be anything in it. Again, we'll need to use GCFScape to extract proper files. Extracting files will let us use Valve's actbusy.txt file, but we could always create our own. If you create your own actbusy.txt file and place it in the scripts folder, it will override the packed file and there would be no need to extract the original. For the scope of this tutorial, we will be creating our own actbusy.txt file that will instruct our NPCs about actbusy sequences.

Creating the actbusy.txt file

The actbusy.txt file contains all the sequences that an info_node_hint can reference. It's very simple to create and modify this file once you understand a few basic ideas.

To start, open Notepad (or any other basic text editor) and type the following code:

"Actbusy.txt"
{
// SCRIPTS GO HERE
}

The very first line defines this text file as the proper actbusy.txt. Everything after the first opening curly brace will be an individual script. Comments can be placed in the file to make it easier to read. Any line beginning with a double backslash (//) defines a comment. The closing curly brace completes the document.

Since we've been making our NPCs sit on the floor and are familiar with that set of animations, let's create an actbusy script that will make an NPC sit on the floor for an arbitrary amount of time.

Your first actbusy script

An actbusy sequence is defined in the code like this:

"Actbusy.txt"
{
//SEQUENCE ONE
"sequence name"
{
"busy_sequence"  "<busy animation>"
"entry_sequence"  "<entry animation>"
"exit_sequence"  "<exit animation>"
"min_time"       "##.##"
"max_time"       "##.##"
"interrupts"     "<interrupt type>"
}
}

The sequence name is almost self-explanatory, but it's the string that references the info_node_hint. The busy sequence can be compared with the Action Animation of a scripted_sequence; however, the busy sequence will be looped for a random period of time between min_time and max_time. The minimum and maximum time settings are in seconds. The entry sequence is the animation to play before the busy sequence, and the exit animation is played after maximum time has elapsed or the sequence is canceled. You can specify how the sequence is interrupted with the interrupts parameter. You can only specify one out of five interrupts for your actbusy sequence:

  • BA_INT_NONE: This will stop the sequence only when the time runs out
  • BA_INT_DANGER: This stops the sequence if NPC senses danger
  • BA_INT_PLAYER: This stops the sequence if NPC sees a player or senses danger
  • BA_INT_AMBUSH: Although EP2's actbusy.txt says someone please define this - I have no idea what it does, it will interrupt the sequence if the NPC sees an enemy
  • BA_INT_COMBAT: This stops the sequence if NPC sees an enemy or signs of combat such as bullet holes

So if we want to create a script that will make an NPC sit on the floor for 5 to 10 seconds and only lets it get up when the time runs out, the actbusy.txt file will look like this:

"ActBusy.txt"
{
"sit_on_floor01"
{
"busy_sequence"    "sit_ground"
"entry_sequence"    "idle_to_sit_ground"
"exit_sequence"    "sit_ground_to_idle"
"min_time"        "5.00"
"max_time"        "10.00"
"interrupts"      "BA_INT_NONE"
}
}

Save that in your mod's scripts folder as actbusy.txt.

Making it work

Create a room with an npc_citizen, info_node_hint, and ai_goal_actbusy.

Making it work

Name the npc_citizen Archie, give him a weapon (again, purely aesthetic), and set his not commandable flag.

Open ai_goal_actbusy and modify the following properties:

  • Actors to affect: Archie
  • Start Active: yes
  • Search type: Entity name
  • Search radius: 2048

The preceding settings tell only NPCs with the name Archie to act busy, and the search radius is a decently large 2048 units.

The info_node_hint is the last entity we need to modify. Set its properties to the following:

  • Hint: world: act busy hint
  • Hint Activity: sit_on_floor01
  • Node FOV: 360 degrees
  • Start Disabled: no

The Hint type specifies the action for this node. There are a multitude of choices, each with their own function; however, in order for the actbusy routines to function properly, we need to choose world: act busy hint. This will make the hint reference the actbusy.txt file we have created. Hint activity specifies which actbusy sequence we want to play as specified in the actbusy.txt file. Since we only have one possible actbusy sequence, enter sit_on_floor01. The node FOV can be used to specify which angle an NPC can use it from.

Making it work

If the Frame of View (FOV) is set to 90 degrees, the lower NPC can use the node while the upper NPC cannot. Since we would like Archie to be able to sit on any node from any angle, we want to set this to 360 degrees. The last parameter, Start Disabled, is set to no because we want it to be active all the time.

Compile and then run the map to watch Archie sit on the floor for random periods of time.

Actbusy routines can be vastly more complex, but for simple things like this, they don't need to be. If you want to create a slew of random acts for an NPC to carry out in the background, this is the script for you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.49.247