Basic Vehicles (Savage)
Context: HL Kit … Authoring Examples … Savage Worlds Walk-Through
Overview
There are two varieties of vehicles defined within the Savage Worlds rulebook. Basic vehicles have all the standard characteristics shared by all vehicles, such as civilian cars. Complex vehicles are outfitted with a variety of weapons that must be handled appropriately and introduce a number of additional wrinkles. So we'll focus on the mechanics associated with basic vehicle in this section.
New Tags
Vehicles behave similarly to weapons and armor within Savage Worlds. As such, we'll be using the same basic approach in implementing them. The first thing we'll need to address is the assortment of tags that will be needed for vehicles. After taking a moment to review how vehicles are handled, there are three different facets of vehicles that we need to keep distinct: the type, the era, and any special characteristics. So we'll create a separate tag group for each of these facets.
We'll start with the vehicle type, of which there are three basic types defined in the core rulebook. These are ground vehicles, aircraft, and boats. Since all of our tags are defined in the file "tags.1st", open that file and locate a suitable spot to insert the new tag group (e.g. after the armor-related tags). We'll make tag group dynamic so that supplements can define new vehicle types, if necessary. We'll use an explicit order, but we'll leave gaps in the ordering so that supplements can insert new vehicle types into the list wherever they want. This yields a tag group definition that looks like the one shown below.
<group id="VehType" dynamic="yes" sequence="explicit"> <value id="Ground" name="Ground Vehicles" order="10"/> <value id="Aircraft" order="20"/> <value id="Boat" name="Boats & Ships" order="30"/> </group>
Next up is the era of the vehicle, and there are four eras addressed in the core rulebook. These are civilian, WWII military, modern military, and futuristic military. We use the same principles as above, allowing for extensibility, and end up with a tag group similar to the one below.
<group id="VehEra" dynamic="yes" sequence="explicit"> <value id="Civilian" order="10"/> <value id="WWII" name="WWII Military" order="20"/> <value id="Modern" name="Modern Military" order="30"/> <value id="Future" name="Futuristic Military" order="40"/> </group>
The final tag group we need to define is all of the various special characteristics that apply to vehicles. We'll handle this exactly like we do for weapons and armor, which yields a tag group that looks like the one below.
<group id="Vehicle"> <value id="Amphib" name="Amphibious"/> <value id="Spacecraft"/> <value id="Atmosphere" name="Atmospheric"/> <value id="Tracked"/> <value id="4WD" name="Four-Wheel Drive"/> <value id="HvyArmor" name="Heavy Armor"/> <value id="Sloped" name="Sloped Armor"/> <value id="FixedGun" name="Fixed Gun"/> <value id="HvyWeapon" name="Heavy Weapon"/> <value id="AirBags" name="Air Bags"/> <value id="Stealth" name="Stealh Paint"/> <value id="AST" name="Advanced Stealth Tech"/> <value id="AMCM" name="Anti-Missile Counter Measures"/> <value id="Stabilizer" name="Stabilizer"/> <value id="ImpStabil" name="Improved Stabilizer"/> <value id="NightVis" name="Night Vision"/> <value id="Infrared" name="Infrared Night Vision"/> </group>
New Sort Set
Since we have a variety of factors for organizing vehicles, we're going to need a new sort set to put them in the proper sequence for display. We'll use a sequence that parallels the organization in the rulebook, so we'll sort first by the vehicle type, then the era, and finally by name. This yields a sort set similar to the one below, which can be defined with other sort sets in the file "control.1st".
<sortset id="Vehicle" name="Vehicles By Type, Era, and Name"> <sortkey isfield="no" id="VehType"/> <sortkey isfield="no" id="VehEra"/> <sortkey isfield="no" id="_Name_"/> </sortset>
New Fields for Vehicles
Vehicles in Savage Worlds have a bunch of fields that need to handled properly. In addition to the fields used in the rulebook, we'll utilize the same mechanism we used for weapons and armor, in which we have a "notes" field where we synthesize all the details for display. Since we're going to be adding vehicles to the "Gear" tab, we can also associated the component with the appropriate panel. This yields an expanded definition for the "Vehicle" component that is defined in the file "equipment.str". The new component should look similar to below, including a suitable script for synthesizing the notes.
<component id="Vehicle" name="Vehicle" panellink="gear" autocompset="no"> <field id="vhAccel" name="Acceleration" type="static" maxlength="10"> </field> <field id="vhTopSpeed" name="Top Speed" type="static" maxlength="15"> </field> <field id="vhTough" name="Toughness" type="static" maxlength="10"> </field> <field id="vhArmor" name="Armor" type="static" maxlength="10"> </field> <field id="vhCrew" name="Crew" type="static" maxlength="10"> </field> <field id="vhSpecial" name="Special" type="derived" maxlength="200"> </field> <field id="vhNotes" name="Notes" type="derived" maxlength="250"> </field> <eval index="1" phase="Render" priority="1000"><![CDATA[ var special as string ~append any special attributes appropriately (if any) var attribs as string attribs = tagnames[Vehicle.?,", "] if (empty(attribs) = 0) then if (empty(special) = 0) then special &= ", " endif special &= attribs endif ~append any special details for this vehicle if (field[vhSpecial].isempty = 0) then if (empty(special) = 0) then special &= ", " endif special &= field[vhSpecial].text endif ~we've synthesized the notes for the vehicle field[vhNotes].text = special ]]></eval> </component>
Vehicle Cost as a Range
There is a key difference with how vehicles behave from normal gear, though. Many vehicles are given a price range instead of an absolute price. If we want to support this, we need to figure out a way to integrate this different behavior into the way everything is handled for gear. In order to ensure that buy/sell transaction handling all works correctly, we need to retain the use of the "grCost" field and that field must specify an explicit value to be used as the default cost.
Probably the easiest way to handle this is to define a new field in which to display the vehicle cost range. Then we simply need to decide what value we'll use for the explicit "grCost" field. The obvious choices are to always use the lowest price in the range, the highest price in the range, or the mid-point of the range. We'll standardize on the lowest price in the range.
We now need to define the new field in which the cost range will be be given. This can be done with something simple like the field definition below.
<field id="vhCost" name="Cost Range" type="static" maxlength="20"> </field>
Description Output
Since vehicles have their own custom fields, we need to handle them specially when synthesizing detailed description text for display. So open up the file "procedures.dat" and locate the Descript procedure. The first thing we need to do is specify that the vehicle details are handled in a separate procedure. In the code where each component type is handled separately, add the lines shown below to invoke the proper procedure for vehicles.
elseif (tagis[component.Vehicle] <> 0) then call InfoVeh
Once this is done, we now need to define the appropriate procedure. Scroll down a bit further in the file and add a "InfoVeh" procedure that properly synthesizes the output for the new fields we added for vehicles. We want to keep the format looking similar to the one used in the book, so we'll combine the acceleration and top speed on one line, as well as combining the toughness and armor. The new procedure should look similar to the one shown below.
<procedure id="InfoVeh" context="info"><![CDATA[ ~declare variables that are used to communicate with our caller and for temporary use var iteminfo as string ~report the acceleration and speed iteminfo = "Acc/Top Speed: " & field[vhAccel].text & "/" & field[vhTopSpeed].text & "{br}" ~report the toughness and armor iteminfo &= "Toughness (Armor): " & field[vhTough].text & " (" & field[vhArmor].text & "){br}" ~report the crew size iteminfo &= "Crew: " & field[vhCrew].text & "{br}" ]]></procedure>
Selecting Vehicles Via Gear Tab
The final step we need to deal with is making vehicles accessible to the user. We'll add vehicles to the "Gear" tab, since vehicles are in many ways more like standard gear in behavior and the "Armory" tab is already pretty packed with material. Our basic plan will be to clone the existing portal and templates for handling gear, then adapt them for use with vehicles.
The first thing we need to do is create the new portal for showing the vehicles in a table. We can copy the existing "grGear" portal and then modify it to suit our purposes. In addition to changing the portal id, we need to change the template ids, the tag expression governing the contents managed, and the various scripts that must specifically reference "vehicles" now. The result should be something similar to the portal below.
<portal id="grVehicle" style="tblNormal"> <table_dynamic component="Gear" showtemplate="grVehPick" choosetemplate="grVehThing" choosesortset="Vehicle" buytemplate="BuyCash" selltemplate="SellCash" descwidth="300"> <list>component.Vehicle</list> <titlebar><![CDATA[ @text = "Select Vehicles to Purchase from the List Below" ]]></titlebar> <headertitle><![CDATA[ @text = "Miscellaneous Vehicles" ]]></headertitle> <additem><![CDATA[ @text = "Add New Vehicle" ]]></additem> </table_dynamic> </portal>
<template id="grVehThing" name="Vehicle Thing" compset="Vehicle" marginhorz="3" marginvert="2"> <portal id="name" style="lblNormal"> <label field="name"> </label> </portal> <portal id="cost" style="lblNormal"> <label> <labeltext><![CDATA[ @text = field[grCost].text ]]></labeltext> </label> </portal> <position><![CDATA[ ~set up our dimensions, with a width that we dictate height = portal[name].height width = 250 ~if this is a "sizing" calculation, we're done if (issizing <> 0) then done endif ~position the cost portal on the far right perform portal[cost].alignedge[right,0] ~position the name on the left and let it use all available space portal[name].left = 0 portal[name].width = minimum(portal[name].width,portal[cost].left - 10) ]]></position> </template>
<template id="grVehPick" name="Vehicle Pick" compset="Vehicle" marginhorz="3" marginvert="3"> <portal id="name" style="lblNormal" showinvalid="yes"> <label field="name"> </label> </portal> <portal id="container" style="imgNormal"> <image_literal image="container.bmp" istransparent="yes"> </image_literal> <mouseinfo mousepos="middle+above"><![CDATA[ call InfoHolder ]]></mouseinfo> </portal> <portal id="info" style="actInfo"> <action action="info"> </action> <mouseinfo mousepos="middle+above"/> </portal> <portal id="delete" style="actDelete" tiptext="Click to delete this vehicle"> <action action="delete"> </action> </portal> <position><![CDATA[ ~set up our height based on our tallest portal height = portal[info].height ~if this is a "sizing" calculation, we're done if (issizing <> 0) then done endif ~center the portals vertically perform portal[info].centervert perform portal[name].centervert perform portal[delete].centervert perform portal[container].centervert ~position the delete portal on the far right perform portal[delete].alignedge[right,0] ~position the info portal to the left of the delete button perform portal[info].alignrel[rtol,delete,-8] ~position the name on the left and let it use all available space var limit as number limit = portal[info].left - portal[container].width - 5 portal[name].left = 0 portal[name].width = minimum(portal[name].width,limit) ~show the 'container' icon to the right of the name portal[container].left = portal[name].right + 5 ~if the gear can't be deleted (i.e. it's been auto-added instead of user-added, ~set the style to indicate that behavior to the user if (candelete = 0) then perform portal[name].setstyle[lblAuto] endif ]]></position> </template>
<layout id="gear"> <portalref portal="grGear" taborder="10"/> <portalref portal="grVehicle" taborder="20"/> <!-- This script sizes and positions the layout and its child visual elements. --> <position><![CDATA[ ~set all tables to span the full width of the layout portal[grGear].width = width portal[grVehicle].width = width ~position the vehicles table at the bottom with a minimum height of 2 items portal[grVehicle].maxrows = 2 portal[grVehicle].top = height - portal[grVehicle].height ~position and size the gear table to fill all remaining space portal[grGear].top = 0 portal[grGear].height = portal[grVehicle].top - 10 ~position and size the vehicle table to use the remaining space at the bottom portal[grVehicle].top = portal[grGear].bottom + 10 portal[grVehicle].height = height - portal[grVehicle].top ]]></position> </layout>