Creating squads

You'll probably notice that the NPCs fend for themselves. There's no communication, there's no guarding one another, they run as individuals, and they die alone. Squads can be used to change battle behavior and amplify the effect of a group in combat.

Your first squad

The only way to create a squad is to give a group of NPCs the same squad name. In fact, that's really all the work you have to do! NPCs within the same squad will call out enemies, cover each other, inform squad mates of enemy locations, and call for help when they need it. So long as you have a decent array of navigation and hint nodes, simply assigning NPCs to a squad is all the work needed to increase their effectiveness in the battle.

Your first squad

Scripting a flank

Using some entities we've learned about already, we can script a flank on the citizens inside the house. Select six of the combine soldiers and assign them the names alpha_soldier01-alpha_soldier06. Put them in a squad called alpha. We will be using a math_counter entity to initiate the flank. When three members of the alpha squad are killed, the other three will run around the side of the house to try to flank the citizens. We'll be using an aiscripted_schedule entity that tells the remaining members of the alpha squad to initiate the flanking maneuvre.

Creating a schedule and a path

Place an aiscripted_schedule entity near the side entrance of the house, along with a path of about 4 to 5 path_corners leading from the front corner, around the house, and inside the house. Name the path_corners alpha_flank01-alpha_flank05. You already have some experience with aiscripted schedules, but we're going to override the AI and force them to complete this schedule in the middle of a battle.

Creating a schedule and a path

Aiscripted schedules

Here is how you can set up this schedule:

Name: alpha_start_flank
Target NPC: alpha_soldier*
All in Radius: Yes
Schedule to run: Run Goal Path
Interruptability: Death
Goal Entity: alpha_path01

Remember that an asterisk after a name will find all entities matching the base name. Setting the target NPC entity to alpha_soldier* will find alpha_soldier01-06. When you see All in radius = yes, this means it will find all matching NPCs instead of stopping the moment any one is found. Schedule to run is self-explanatory; run along the goal path. Interruptability set to death means so long as the NPC is alive, it will complete the script—nothing can stop the soldiers except a few well-placed bullets. Goal entity is the start of our path; in this case, alpha_path01. The soldiers will automatically follow the other path_corners entity until the end and resume their normal AI behavior once there.

Aiscripted schedule flags

There are a few flags we want to set as well that are mentioned as follows:

Repeatable: No
Search Cyclically: Yes
Don't Complain: Yes

We only want this script to run once, so there's no reason for it to be repeatable. Search cyclically will ensure that each NPC found will run the schedule. Don't complain will prevent any navigation errors from being displayed on the console.

Math counter

The math counter entity will trigger an output when its internal counter reaches a certain value. For us, we want it to trigger an output when the counter reaches 3. Place a math_counter entity and check out the properties, as shown in the following image:

Math counter

Let's examine some of the math_counter properties:

Math counter

An output can trigger when the counter value reaches either minimum or maximum legal value. In our case, we want to fire an output when Maximum Legal Value reaches 3. The output will look like this:

OnHitMax > alpha_start_flank > StartSchedule > 0.00ms Delay

Setting up our soldiers

The math_counter property needs inputs before it can start counting. The soldiers (npc_combine_s) have outputs that are triggered to death. So, when a soldier in alpha squad is killed, we want to increase our math_counter by 1.

OnDeath > alpha_killed > add > 1 > 0.00s Delay

Any input over 3 will have no effect.

That's it, we're all set up. You'll see the soldiers run to flank the citizens inside the house once enough of them have gotten shot down. The citizens, although fewer in number, are pretty well-guarded and will probably win the fight. Try changing the soldier weapon types, aggression (the Tactical variant property), and grenade count to sway the battle outcome.

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

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