Mobile APCs
Table of Contents

Overview

battle01_t.jpg

An armored car provides some much-needed aid to the enemy with its heavy weapons and can add some spice to a map. The intent of this article is to show you how to spawn APCs and move on their own through the world with a mapadd script. How exactly you use them is left to your imagination.

It can be helpful while going through this page to run SMOD in a window so you can quickly and easily switch back and forth.
You can do this by right-clicking on it in your Steam games menu, choosing Properties, choosing Set Launch Options, and adding -window.

The reader should already be familiar with mapadd syntax, grabbing coordinates, using the input/output system, and other basics.

This page makes use of these entities:
npc_apcdriver
path_corner / path_track
prop_vehicle_apc
point_teleport

Be sure to run through the APC and driver pages for functions that aren't touched on here (like FireMissileAt for force-firing).

How-To

You can start by planning out a route for the vehicle to take and grab coordinates for points along the way. For best results, you'll want to use as few points as possible and they all should be in straight lines from each other. Once you've got all your coordinates, use them to set up a path_corner at each point:

    "path_corner" // Track begin
        {
        "origin" "-1500 -1501 -144"
        "keyvalues"
            {
            "targetname" "Ranger_n00" // Name of this track piece.
            "target" "Ranger_n01" // Name of the next track piece.
            }
        }

These entities are basically a kind of node you can use to direct NPCs down a path (or set of paths). Using the target keyvalue, you can link all of them together so the APC will go from point to point on its own.

Speaking of APCs, there still isn't one here to boss around. Grab some coordinates near the first track and be sure to make one in the Entities section, since having it inside a label will crash the game.

    "prop_vehicle_apc"
        {
        "origin" "-1728 -1501 -80"
        "angle" "0 0 0"
        "keyvalues"
            {
            "targetname" "Ranger"
            "model" "models/combine_apc.mdl"
            "vehiclescript" "scripts/vehicles/apc_npc.txt"
            "solid" "6"
            }
        }

The above sets the model of the APC, gives it the relevant vehicle script, and sets it so the model's bounding box will determine how it handles collisions. Once that's taken care of, it'll need a driver like that below:

    "npc_apcdriver"
        {
        "relation" "gn1" // Neutral toward player and won't fire.
        "keyvalues"
            {
            "targetname" "Ranger_Drive"
            "spawnflags" "256"    // Long range behavior.
            "vehicle" "Ranger"
            "driverminspeed" "10" // Needs to be set to ensure it can drive.  Sets 10% maximum speed as the lowest speed the APC will move at.
            "drivermaxspeed" "30"
            }
        }

Once the APC's ready to go, the driver needs to be ordered to the first node in the path. One way to automatically do it is to add an event block to the script. It works similarly to an ordinary output:

    "event"
        {
        "targetname" "Ranger_Drive" // This is an entity we want to manipulate.
        "action" "GoToPathCorner"   // An input on the entity we want to use.
        "value" "Ranger_n00"        // A value associated with the input, if any.
        "delaytime" "1"             // Delay in seconds before firing this event.  1 second delay to ensure the path is set up before firing.
        }

Once the driver's made it to the first in the path, he'll continue along the path and then slam on the brakes once he's out of track. He'll remain where he is until he's ordered elsewhere.

Other things to note:

  • Drivers are very clumsy and make wide turns, so try to keep as straightforward (and open) a path as possible. Fewer points mean fewer potential problems, so you should strictly limit how many points they travel across.
  • Avoid turns, especially tighter ones that drivers can't handle. If the driver overshoots a point in the path, they'll back up or turn around to get to it before continuing on and look silly doing it.
  • The APC model's physics can be odd and may cause it to spawn in a different direction each time you restart the map. You can fix this by inserting a point_teleport in the Entities section, using it at the start to teleport the APC to its position.
  • For the above reasons, you should mostly forgo driving and treat APCs like machinegun nests instead of vehicles. Use them for locking down areas or supporting their fellow soldiers.
  • path_track points (like those used for dropships) can be used in place of path_corners if you prefer them.

Wrap-Up

The purpose of this page along with the other mapadd pages, is to serve as a starting point for your own script ideas. Keep in mind that just about anything's possible, it's just a matter of figuring how to get there.

The example script this article is based on can be downloaded below for reference.

downloadac.png


Customization

Mapadd Command Reference (Non-LUA)Command Reference (LUA)Getting StartedPorts 'n' Doors
Alarm, Alarm!Color Correction in SMODDoor BreachingMobile APCsWorking With Dropships
Supply Drop (LUA)Countdown (LUA)
kh0rn3's Mapadd Generator
Scripts addcontentsoverride_classsmod_custom_explosivesmodaclistSMOD Soundscripts

npc_gib_modelnpc_replace_modelnpc_shieldsetnpc_weapon_randomizenpc_weaponweight

excludeweaponsweapon_categoryweapon_customConsole Command List
Other Crosshair CustomizationGenerating AI NodesUsing the NodemakerSubViewCam
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License