Overview
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:
|
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.
|
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:
|
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:
|
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.
Customization |