Difference between revisions of "Basic Vehicles (Savage)"

From HLKitWiki
Jump to: navigation, search
(Vehicle Cost as a Range)
(Description Output)
Line 182: Line 182:
 
===Description Output===
 
===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.
 +
 +
<pre>
 +
elseif (tagis[component.Vehicle] <> 0) then
 +
  call InfoVeh
 +
</pre>
 +
 +
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.
 +
 +
<pre>
 +
<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>
 +
</pre>
  
 
===Selecting Vehicles Via Gear Tab===
 
===Selecting Vehicles Via Gear Tab===

Revision as of 13:36, 11 January 2009

Context: HL KitAuthoring 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

Adding Basic Vehicles