Difference between revisions of "Weapons (Savage)"

From HLKitWiki
Jump to: navigation, search
Line 7: Line 7:
 
===Weapons in General===
 
===Weapons in General===
  
There is only one facet of weapons in general that is distinct from our default behaviors. Both hand weapons and ranged weapons can possess the armor piercing attribute, with a corresponding rating being specified. Since there is a rating involved, we need to add a new field to the "BaseWeapon" component in order to track the rating. You'll find the component in the file "equipment.pri", and the new field should look similar to the one shown below.
+
There is only one facet of weapons in general that is distinct from the default behaviors of the Skeleton files. Both hand weapons and ranged weapons can possess the "armor piercing" attribute, with a corresponding rating being specified. Since there is a rating involved, we need to add a new field to the "BaseWeapon" component in order to track the rating. You'll find the component in the file "equipment.str", and the new field should look similar to the one shown below.
  
 
<pre>
 
<pre>
Line 26: Line 26:
 
</pre>
 
</pre>
  
The final thing we need to do is add the armor piercing rating to the special notes that are shown for weapons on the Armory tab. The notes to be displayed are synthesized into the "wpNotes" field for weapons via an Eval script within the "BaseWeapon" component. Locate this script and add the appropriate new code to include the armor piercing rating at the start. The new code should look similar to the lines below.
+
The final thing we need to do is add the armor piercing rating to the special notes that are shown for weapons on the Armory tab. The notes to be displayed are synthesized into the "wpNotes" field for weapons via an Eval script within the "WeaponBase" component. Locate this script and add the appropriate new code to include the armor piercing rating at the start. The new code should look similar to the lines below.
  
 
<pre>
 
<pre>
Line 40: Line 40:
 
===Minimum Strength Requirement===
 
===Minimum Strength Requirement===
  
Weapons may be specified as having a minimum strength requirement. If a weapon is equipped when that requirement is not meant, using the weapon incurs a penalty of -1 for each step of shortfall. The Skeleton files provide some basic mechanisms for managing the strength requirement, but we must apply the penalty appropriately ourselves. Open the file "equipment.pri" and locate the "BaseWeapon" component. The first Eval script handles the minimum strength requirement logic, applying a penalty to the weapon and having a place to apply a more general penalty. Within Savage Worlds, there is no generalized penalty, so those lines can be deleted from the script. The penalty adjustment applied is currently a flat "-1", so we must change it to represent the shortfall. The net result is a revised Eval script that looks similar to the following script.
+
Weapons may be specified as having a minimum strength requirement. If a weapon is equipped when that requirement is not meant, using the weapon incurs a penalty of -1 for each step of shortfall. The Skeleton files provide some basic mechanisms for managing the strength requirement, but we must apply the penalty appropriately ourselves. Open the file "equipment.str" and locate the "WeaponBase" component. The first Eval script handles the minimum strength requirement logic, applying a penalty to the weapon and having a place to apply a more general penalty. Within Savage Worlds, there is no generalized penalty, so those lines can be deleted from the script. The penalty adjustment applied is currently a flat "-1", so we must change it to represent the shortfall. The net result is a revised Eval script that looks similar to the following script.
  
 
<pre>
 
<pre>
<eval value="1" phase="Final" priority="5000"><![CDATA[
+
<eval index="1" phase="Final" priority="5000"><![CDATA[
 
   ~if the minimum strength is satisfied, there's nothing to do
 
   ~if the minimum strength is satisfied, there's nothing to do
 
     if (field[wpStrReq].value <= #trait[attrStr]) then
 
     if (field[wpStrReq].value <= #trait[attrStr]) then
 
       done
 
       done
 
       endif
 
       endif
 +
 
   ~assign a tag to indicate the requirement isn't met
 
   ~assign a tag to indicate the requirement isn't met
 
   perform assign[Helper.BadStrReq]
 
   perform assign[Helper.BadStrReq]
 +
 
   ~apply any penalty required with the specific weapon
 
   ~apply any penalty required with the specific weapon
 
   field[wpPenalty].value = #trait[attrStr] - field[wpStrReq].value
 
   field[wpPenalty].value = #trait[attrStr] - field[wpStrReq].value
 +
 
   ~if not equipped, there's nothing more to do
 
   ~if not equipped, there's nothing more to do
 
   if (field[grIsEquip].value = 0) then
 
   if (field[grIsEquip].value = 0) then
Line 61: Line 64:
 
===Weapon Categories===
 
===Weapon Categories===
  
In the same way we encountered for basic gear, weapons in Savage Worlds are grouped into categories or types. If we want our weapons to be displayed to the user in appropriate groupings to match the rulebook, we'll need to manage these groupings. This entails the creation of a new tag group that we'll call "WeaponType" and for which we'll define tags for each grouping. We can then assign that appropriate tag to each weapon. We could potentially create separate tag groups for hand weapons and ranged weapons, but there is no real benefit in doing it, so we'll just use a single tag group for all weapons. As we did for basic gear, the tag group needs to be assigned the "explicit" sequencing behavior, and each tag needs to be assigned an appropriate "order" attribute to designate the proper sort order to match the rulebook. The net result is a tag group that looks like the following.
+
In the same way we encountered for basic gear, weapons in Savage Worlds are grouped into categories or types. If we want our weapons to be displayed to the user in appropriate groupings to match the rulebook, we'll need to manage these groupings. This entails the creation of a new tag group that we'll call "WeaponType" and for which we'll define tags for each grouping. This gets added to the file "tags.1st". We can then assign the appropriate tag to each weapon. We could potentially create separate tag groups for hand weapons and ranged weapons, but there is no real benefit in doing it, so we'll just use a single tag group for all weapons. As we did for basic gear, the tag group needs to be assigned the "explicit" sequencing behavior, and each tag needs to be assigned an appropriate "order" attribute to designate the proper sort order to match the rulebook. The net result is a tag group that looks like the following.
  
 
<pre>
 
<pre>
Line 84: Line 87:
 
</pre>
 
</pre>
  
With the weapon type available, we need to put it to use. This will be done through a new sort set that parallels what we did for basic gear, and we'll call it "Weapon". The sort set sorts first on the weapon type and then on the name of the thing, which results in the following definition.
+
With the weapon type available, we need to put it to use. This will be done through a new sort set that parallels what we did for basic gear, and we'll call it "Weapon". The sort set first sorts on the weapon type and then on the name of the thing, which results in the following definition to be added to the file "control.1st".
  
 
<pre>
 
<pre>
Line 354: Line 357:
 
~only show the special portal if there are special abilities/notes to view
 
~only show the special portal if there are special abilities/notes to view
 
portal[special].visible = 1 - field[wpNotes].isempty  
 
portal[special].visible = 1 - field[wpNotes].isempty  
</pre>
 
 
===Ranged Weapons===
 
 
Ranged weapons introduce four new variable ratings that need to be tracked, as well as a handful of special attributes that are either present or not. The variable  ratings corresponding to the following characteristics: rate of fire, number of shots, number of actions to reload, and ammunition type. They can be managed via new fields that we'll add to the "WeapRange" component, which is defined in the file "equipment.pri". They should look similar to the field definitions provided below.
 
 
<pre>
 
<field
 
  id="wpReload"
 
  name="Actions to Reload"
 
  type="static">
 
  </field>
 
 
<field
 
  id="wpFireRate"
 
  name="Rate of Fire"
 
  type="static"
 
  defvalue="1"
 
  maxlength="10">
 
  </field>
 
 
<field
 
  id="wpShots"
 
  name="Number of Shots"
 
  type="static">
 
  </field>
 
 
<field
 
  id="wpAmmo"
 
  name="Ammunition"
 
  type="static"
 
  maxlength="10">
 
  </field>
 
</pre>
 
 
The special attributes represent facets of weapons that are optionally present, such as snap fire, double tap, three-round burst, etc. All of these are either present or not, so they can be best represented as individual tags. The Skeleton files provide a tag group intended just for this purpose, with the id "Weapon". So we can add each of the tags we need to this tag group in the file "tags.1st". Whichever tags apply to a given weapon can simply be assigned to the thing. The revised tag group should look similar to the example shown below.
 
 
<pre>
 
<group
 
  id="Weapon">
 
  <value id="SpecRange" name="Range is special"/>
 
  <value id="SnapFire" name="Snap Fire"/>
 
  <value id="DoubleTap" name="Double Tap"/>
 
  <value id="HvyWeapon" name="Heavy Weapon"/>
 
  <value id="HighExplos" name="High Explosive"/>
 
  <value id="ThreeRound" name="Three-Round Burst"/>
 
  <value id="NoMove" name="May Not Move"/>
 
  <value id="Revolver"/>
 
  <value id="SemiAuto" name="Semi-Auto"/>
 
  <value id="FullAuto" name="Full-Auto"/>
 
  <value id="Shotgun"/>
 
  </group>
 
</pre>
 
 
Just like we did for hand weapons, the new fields and attributes need to be included within the weapon description details. The description for ranged weapons is handled by the "InfoRange" procedure within the file "procedures.dat". We only add the new information when it applies. This yields code that should look similar to the following.
 
 
<pre>
 
<procedure id="InfoRange" context="info"><![CDATA[
 
  ~declare variables that are used to communicate with our caller
 
  var iteminfo as string
 
  ~start with generic details for all weapons
 
  call InfoWeapon
 
  ~add the range details for the weapon
 
  iteminfo &= "Range: " & field[wpRange].text & "\n"
 
  ~report the fire rate of the weapon (if any)
 
  iteminfo &= "Rate of Fire: " & field[wpFireRate].text & "\n"
 
  ~report the number of shots for the weapon (if any)
 
  if (field[wpShots].value > 0) then
 
    iteminfo &= "# Shots: " & field[wpShots].value & "\n"
 
    endif
 
  ~report the number of actions to reload the weapon (if any)
 
  if (field[wpReload].value > 0) then
 
    iteminfo &= "Actions to Reload: " & field[wpReload].value & "\n"
 
    endif
 
  ~report the ammunition for the weapon (if any)
 
  if (field[wpAmmo].isempty = 0) then
 
    iteminfo &= "Ammunition: " & field[wpAmmo].text & "\n"
 
    endif
 
  ]]></procedure>
 
</pre>
 
 
We also need to add the new fields and attribute to the special notes shown for weapons on the Armory tab. This can be done via the Eval script within the "WeapRange" component that performs this function. The exception is the ammunition type, which doesn't belong here and can be accessed via the description text if the user wants to reference that info. The code parallels what we've already done for hand weapons, which results in a revised script that look like the following.
 
 
<pre>
 
<eval value="2" phase="Render" priority="2000"><![CDATA[
 
  var special as string
 
  ~report the rate of fire for the weapon
 
  if (empty(special) = 0) then
 
    special &= ", "
 
    endif
 
  special &= "RoF " & field[wpFireRate].text
 
~report the number of shots for the weapon (if any)
 
  if (field[wpShots].value <> 0) then
 
    if (empty(special) = 0) then
 
      special &= ", "
 
      endif
 
    special &= "Shots " & field[wpShots].value
 
    endif
 
  ~report the reload actions of the weapon (if any)
 
  if (field[wpReload].value <> 0) then
 
    if (empty(special) = 0) then
 
      special &= ", "
 
      endif
 
    special &= "Reload " & field[wpReload].value & " action(s)"
 
    endif
 
  ~prepend any existing special details with the notes for this weapon
 
  if (empty(special) = 0) then
 
    if (field[wpNotes].isempty = 0) then
 
      special &= ", "
 
      endif
 
    field[wpNotes].text = special & field[wpNotes].text
 
    endif
 
  ]]></eval>
 
</pre>
 
 
===Add Ranged Weapons===
 
 
We can now begin adding all of the various ranged weapons to the data files. As with hand weapons, they should be added to the file "thing_armory.dat". A few examples are provided below. You can either add the rest or pull them out of the complete Savage Worlds data files that are provided.
 
 
<pre>
 
<thing
 
  id="wpCrossbow"
 
  name="Crossbow"
 
  compset="Ranged"
 
  description="Description goes here">
 
  <fieldval field="wpDamage" value="2d6"/>
 
  <fieldval field="wpShort" value="15"/>
 
  <fieldval field="wpMedium" value="30"/>
 
  <fieldval field="wpLong" value="60"/>
 
  <fieldval field="wpStrReq" value="3"/>
 
  <fieldval field="wpPiercing" value="2"/>
 
  <fieldval field="wpReload" value="1"/>
 
  <fieldval field="grCost" value="500"/>
 
  <fieldval field="grWeight" value="10"/>
 
  <usesource id="TimeMedi"/>
 
  <tag group="WeaponType" tag="MedRange"/>
 
  <tag group="Equipment" tag="TwoHand"/>
 
  </thing>
 
 
<thing
 
  id="wpColt1911"
 
  name="Colt 1911"
 
  compset="Ranged"
 
  description="Description goes here">
 
  <fieldval field="wpDamage" value="2d6+1"/>
 
  <fieldval field="wpShort" value="12"/>
 
  <fieldval field="wpMedium" value="24"/>
 
  <fieldval field="wpLong" value="48"/>
 
  <fieldval field="wpPiercing" value="1"/>
 
  <fieldval field="wpShots" value="7"/>
 
  <fieldval field="wpAmmo" value=".45"/>
 
  <fieldval field="grCost" value="200"/>
 
  <fieldval field="grWeight" value="4"/>
 
  <usesource id="TimeModern"/>
 
  <tag group="WeaponType" tag="ModPistol"/>
 
  <tag group="Weapon" tag="DoubleTap"/>
 
  <tag group="Weapon" tag="SemiAuto"/>
 
  </thing>
 
 
<thing
 
  id="wpBarrett"
 
  name="Barrett"
 
  compset="Ranged"
 
  description="Description goes here">
 
  <fieldval field="wpDamage" value="2d10"/>
 
  <fieldval field="wpShort" value="50"/>
 
  <fieldval field="wpMedium" value="100"/>
 
  <fieldval field="wpLong" value="200"/>
 
  <fieldval field="wpStrReq" value="4"/>
 
  <fieldval field="wpPiercing" value="4"/>
 
  <fieldval field="wpShots" value="11"/>
 
  <fieldval field="wpAmmo" value=".50"/>
 
  <fieldval field="grCost" value="750"/>
 
  <fieldval field="grWeight" value="35"/>
 
  <usesource id="TimeModern"/>
 
  <tag group="WeaponType" tag="ModRifle"/>
 
  <tag group="Weapon" tag="SnapFire"/>
 
  <tag group="Weapon" tag="HvyWeapon"/>
 
  <tag group="Equipment" tag="TwoHand"/>
 
  </thing>
 
</pre>
 
 
===Revise Table for Ranged Weapons===
 
 
With all of the ranged weapons in place, we can now revise how they are managed visually within the table. The table portal for ranged weapons is named "arRange" within the file "tab_armory.dat". After a quick review, there are only two things that we need to change, and those are the same changes we already made to the "arMelee" table portal above. We first need to increase the width of the area for showing weapon descriptions, so we add the "descwidth" attribute to the "table_dynamic" element with a value of either 275 or 300. Then we add the "choosesortset" attribute to the same "table_dynamic" element and assign it the unique id of our custom sort set, which is "Weapon".
 
 
===Weapon Attack Calculations===
 
 
Early in the overall development process for these data files, we determined that Savage Worlds calculated the attack for weapons very differently from the default logic provided by the Skeleton files, so we disabled it. Now that we have all the various weapons in place, it's a perfect time to re-visit that and get it working correctly. The "wpNetAtk" field within the "BaseWeapon" component is provided for exactly this purpose. However, that field is value-based and it needs to be text-based so that it can display something like "d8+2". This means our first task is to change the "wpNetAtk" field to be text-based, which we can do by assigning it a "maxlength" attribute of "50". The revised field should look similar to the following.
 
 
<pre>
 
<field
 
  id="wpNetAtk"
 
  name="Net Attack"
 
  type="derived"
 
  maxlength="50">
 
  </field>
 
</pre>
 
 
Once we change the field's nature, we are going to get a variety of compiler errors, since there are a handful of places where the field is accessed as a value-based field. Try compiling the file and use the list of errors to locate the handful of locations where the field usage needs to be adjusted. All you should need to do is change references to "field[wpNetAtk].value" over to "field[wpNetAtk].text".
 
 
While we're mucking with fields, we might as well address another need. In order to independently synthesize an appropriately adjusted trait roll for the weapon attacks, those scripts will need to access the net bonus/penalty for the particular trait. Currently, that information is tracked across three separate fields, so we need to introduce a new field that calculates the net adjustment and can be readily accessed. We'll call our new field "trtNetRoll", and it must be generated after any penalties are applied due to the load limit, so we'll base our timing on the script we defined earlier that performs that role. In the end, our new field should look a lot like the definition below.
 
 
<pre>
 
<field
 
  id="trtNetRoll"
 
  name="Net Roll Bonus"
 
  type="derived"
 
  calcphase="Traits"
 
  calcprior="9000">
 
  <calculate name="Calc trtNetRoll">
 
    <after name="Apply LoadLimit"/><![CDATA[
 
    @value = field[trtRoll].value + field[trtProf].value + herofield[acNetPenal].value
 
    ]]></calculate>
 
  </field>
 
</pre>
 
 
The logic we'll want to use when synthesizing the net attack for display will be very similar to the logic used to generate the final trait rolls for display within the "trtDisplay" field. Consequently, our next task should be to carve out that logic for re-use by putting it into a procedure. Once it's in a procedure, it can be used from both the current script that synthesizes "trtDisplay" and any other script that synthesizes "wpNetAtk". 
 
 
Looking closely at the logic, there are two distinct values that must be passed into the procedure, with a since string being returned for use by the caller. The two inbound values are the die type for the trait and any bonus/penalty to the roll. Based on these two inputs, our procedure can interpret the values correctly and synthesize the appropriate string for display to the user. The only thing special we need to do is ensure that the die type is properly bounded, just like is already done within the logic that synthesizes "trtDisplay". In the end, we should end up with a procedure that looks very similar to the one provided below.
 
 
<pre>
 
<procedure id="FinalRoll" scripttype="none"><![CDATA[
 
  ~declare variables that are used to communicate with our caller
 
  var finaldie as number
 
  var finalbonus as number
 
  var finaltext as string
 
  ~bound our final die type appropriately
 
  var final as number
 
  final = finaldie
 
  if (final < 2) then
 
    final = 2
 
  elseif (final > 6) then
 
    final = 6
 
    endif
 
  ~convert the final value for the trait to the proper die type for display
 
  var dietype as number
 
  dietype = final * 2
 
  finaltext = "d" & dietype
 
  ~if there are any bonuses or penalties on the roll, append those the final result
 
  if (finalbonus <> 0) then
 
    finaltext &= signed(finalbonus)
 
    endif
 
  ]]></procedure>
 
</pre>
 
 
Once the procedure is in place, we need to revise the Eval script that synthesizes the "trtDisplay" field so that it uses the new procedure. The net result should closely parallel the revised script below.
 
 
<pre>
 
<eval value="4" phase="Render" priority="5000" name="Calc trtDisplay">
 
  <after name="Calc trtNetRoll"/>
 
  <after name="Calc trtFinal"/><![CDATA[
 
  ~if this is a derived trait, our display text is the final value
 
  if (tagis[component.Derived] <> 0) then
 
    field[trtDisplay].text = field[trtFinal].value
 
    done
 
    endif
 
  ~calculate the net bonuses and penalties for the roll
 
  var finalbonus as number
 
  finalbonus = field[trtNetRoll].value
 
  ~generate the appropriate results for display
 
  var finaldie as number
 
  var finaltext as string
 
  finaldie = field[trtFinal].value
 
  call FinalRoll
 
  ~put the final result into the proper field
 
  field[trtDisplay].text = finaltext
 
  ]]></eval>
 
</pre>
 
 
We've now got all of the pieces in place to be able to properly synthesize the "wpNetAtk" field for display to the user. There are two separate scripts in the file "equipment.pri" that synthesize the "wpNetAtk" field - one for ranged weapons and another for hand weapons. We need two separate scripts because one is based on the "Shooting" skill, while the other is based on the "Fighting" skill. We'll start by modifying the Eval script within the "WeapRange" component. The timing does not need to be touched, but we otherwise need to replace the script with revised logic that is similar to the synthesis of "trtDisplay" above and uses the "Shooting"  skill. The key differences are two-fold. First, the bonus needs to incorporate both any bonus/penalty from the trait and any separate bonus/penalty from the weapon itself. Second, we need to handle the case where the character does not possess the needed skill. If not, then the die type will be zero due to the use of the "childfound." transition, which the procedure will bound as if it's a "d4". We must also apply the appropriate "-2" adjustment to the roll for being unskilled. The net result should yield a script that looks similar to the one below.
 
 
<pre>
 
<eval value="1" phase="Final" priority="7000" name="Calc wpNetAtk">
 
  <after name="Calc trtNetRoll"/>
 
  <after name="Calc trtFinal"/><![CDATA[
 
  ~start with the bonuses and penalties associated with the weapon
 
  var finalbonus as number
 
  finalbonus = field[wpBonus].value + field[wpPenalty].value
 
  ~apply the appropriate adjustment for the associated skill
 
  if (hero.childexists[skShooting] = 0) then
 
    finalbonus -= 2
 
  else
 
    finalbonus += hero.child[skShooting].field[trtNetRoll].value
 
    endif
 
  ~get the proper die type for the associated skill
 
  var finaldie as number
 
  finaldie = hero.childfound[skShooting].field[trtFinal].value
 
  ~generate the appropriate results for display
 
  var finaltext as string
 
  call FinalRoll
 
  ~put the final result into the proper field
 
  field[wpNetAtk].text = finaltext
 
  ]]></eval>
 
</pre>
 
 
We can now define a very similar Eval script for the "WeapMelee" component that synthesizes the net attack based on the "Fighting" skill. The existing script can have the comments removed from around it and can then have its contents replaced with the revised logic shown below.
 
 
<pre>
 
<eval value="2" phase="Final" priority="7000" name="Calc wpNetAtk">
 
  <after name="Calc trtNetRoll"/>
 
  <after name="Calc trtFinal"/><![CDATA[
 
  ~start with the bonuses and penalties associated with the weapon
 
  var finalbonus as number
 
  finalbonus = field[wpBonus].value + field[wpPenalty].value
 
  ~apply the appropriate adjustment for the associated skill
 
  if (hero.childexists[skFighting] = 0) then
 
    finalbonus -= 2
 
  else
 
    finalbonus += hero.child[skFighting].field[trtNetRoll].value
 
    endif
 
  ~get the proper die type for the associated skill
 
  var finaldie as number
 
  finaldie = hero.childfound[skFighting].field[trtFinal].value
 
  ~generate the appropriate results for display
 
  var finaltext as string
 
  call FinalRoll
 
  ~put the final result into the proper field
 
  field[wpNetAtk].text = finaltext
 
  ]]></eval>
 
</pre>
 
 
===Ammunition===
 
 
The final aspect of weapons that we need to address is ammunition. All ammunition is actually purchased and managed as gear via the Gear tab, but we'll address it as part of the weapons. There really isn't anything to deal with for ammunition, except that we need to add a new tag for the new type of gear. Once that's done, it's just a matter of adding all of the appropriate entries for each type of ammunition. A couple of examples are provided below. You can either add the rest or pull them out of the complete Savage Worlds data files that are provided.
 
 
<pre>
 
<thing
 
  id="eqBulletSm"
 
  name="Bullets (Small)"
 
  compset="Ammunition"
 
  lotsize="50"
 
  stacking="merge"
 
  description="Includes .22 to .32 caliber weapons">
 
  <fieldval field="grCost" value=".2"/>
 
  <fieldval field="grWeight" value=".06"/>
 
  <tag group="GearType" tag="Ammo"/>
 
  </thing>
 
 
<thing
 
  id="eqLsrBatt"
 
  name="Laser Battery"
 
  compset="Ammunition"
 
  lotsize="1"
 
  stacking="merge"
 
  description="Provides one full load of shots for the laser pistol, rifle, or MG">
 
  <fieldval field="grCost" value="25"/>
 
  <fieldval field="grWeight" value="1"/>
 
  <usesource id="TimeFuture"/>
 
  <tag group="GearType" tag="Ammo"/>
 
  </thing>
 
 
</pre>
 
</pre>

Revision as of 04:10, 18 December 2008

Context: HL KitAuthoring Examples … Savage Worlds Walk-Through 

Overview

Now that basic gear is in, this section will examine a more complex type of equipment: weapons. We'll continue with the same process we began in the previous chapter, assessing the differences between the Savage Worlds game system and the default mechanisms provided by the Skeleton data files.

Weapons in General

There is only one facet of weapons in general that is distinct from the default behaviors of the Skeleton files. Both hand weapons and ranged weapons can possess the "armor piercing" attribute, with a corresponding rating being specified. Since there is a rating involved, we need to add a new field to the "BaseWeapon" component in order to track the rating. You'll find the component in the file "equipment.str", and the new field should look similar to the one shown below.

<field
  id="wpPiercing
  name="Armor Piercing"
  type="static">
  </field>

Once the new field is added, we then need to include it in the description text for the weapon. All descriptions are routed through the assorted procedures in the file "procedures.dat", so open that file. Locate the "InfoWeapon" procedure, which synthesizes the generic details of all weapons. Insert the necessary lines of script code to include the armor piercing rating within the details. It's probably best to only include the info for weapons that possess a non-zero armor piercing rating, so the new code should look similar to the lines below.

~report the armor piercing rating of the weapon (if any)
if (field[wpPiercing].value > 0) then
  iteminfo &= "Armor Piercing: " & field[wpPiercing].value & "\n"
  endif

The final thing we need to do is add the armor piercing rating to the special notes that are shown for weapons on the Armory tab. The notes to be displayed are synthesized into the "wpNotes" field for weapons via an Eval script within the "WeaponBase" component. Locate this script and add the appropriate new code to include the armor piercing rating at the start. The new code should look similar to the lines below.

~report the armor piercing rating of the weapon (if any)
if (field[wpPiercing].value > 0) then
  if (empty(special) = 0) then
    special &= ", "
    endif
  special &= "AP " & field[wpPiercing].value
  endif 

Minimum Strength Requirement

Weapons may be specified as having a minimum strength requirement. If a weapon is equipped when that requirement is not meant, using the weapon incurs a penalty of -1 for each step of shortfall. The Skeleton files provide some basic mechanisms for managing the strength requirement, but we must apply the penalty appropriately ourselves. Open the file "equipment.str" and locate the "WeaponBase" component. The first Eval script handles the minimum strength requirement logic, applying a penalty to the weapon and having a place to apply a more general penalty. Within Savage Worlds, there is no generalized penalty, so those lines can be deleted from the script. The penalty adjustment applied is currently a flat "-1", so we must change it to represent the shortfall. The net result is a revised Eval script that looks similar to the following script.

<eval index="1" phase="Final" priority="5000"><![CDATA[
  ~if the minimum strength is satisfied, there's nothing to do
    if (field[wpStrReq].value <= #trait[attrStr]) then
      done
      endif

  ~assign a tag to indicate the requirement isn't met
  perform assign[Helper.BadStrReq]

  ~apply any penalty required with the specific weapon
  field[wpPenalty].value = #trait[attrStr] - field[wpStrReq].value

  ~if not equipped, there's nothing more to do
  if (field[grIsEquip].value = 0) then
    done
    endif
  ]]></eval> 

Weapon Categories

In the same way we encountered for basic gear, weapons in Savage Worlds are grouped into categories or types. If we want our weapons to be displayed to the user in appropriate groupings to match the rulebook, we'll need to manage these groupings. This entails the creation of a new tag group that we'll call "WeaponType" and for which we'll define tags for each grouping. This gets added to the file "tags.1st". We can then assign the appropriate tag to each weapon. We could potentially create separate tag groups for hand weapons and ranged weapons, but there is no real benefit in doing it, so we'll just use a single tag group for all weapons. As we did for basic gear, the tag group needs to be assigned the "explicit" sequencing behavior, and each tag needs to be assigned an appropriate "order" attribute to designate the proper sort order to match the rulebook. The net result is a tag group that looks like the following.

<group
  id="WeaponType"
  sequence="explicit">
  <value id="MedBlades" name="Medieval Blades" order="1"/>
  <value id="MedAxes" name="Medieval Axes and Mauls" order="2"/>
  <value id="MedPoles" name="Medieval Pole Arms" order="3"/>
  <value id="ModMelee" name="Modern Melee" order="4"/>
  <value id="FutMelee" name="Futuristic Melee" order="5"/>
  <value id="MedRange" name="Medieval Ranged" order="10"/>
  <value id="Black" name="Black Powder" order="11"/>
  <value id="ModPistol" name="Modern Pistol" order="12"/>
  <value id="ModSMG" name="Modern Submachine Gun" order="13"/>
  <value id="ModShotgun" name="Modern Shotgun" order="14"/>
  <value id="ModRifle" name="Modern Rifle" order="15"/>
  <value id="ModAssault" name="Modern Assault Rifle" order="16"/>
  <value id="ModMachine" name="Modern Machine Gun" order="17"/>
  <value id="FutRange" name="Futuristic Ranged" order="18"/>
  </group>

With the weapon type available, we need to put it to use. This will be done through a new sort set that parallels what we did for basic gear, and we'll call it "Weapon". The sort set first sorts on the weapon type and then on the name of the thing, which results in the following definition to be added to the file "control.1st".

<sortset
  id="Weapon"
  name="Weapon By Type and Name">
  <sortkey isfield="no" id="WeaponType"/>
  <sortkey isfield="no" id="_Name_"/>
  </sortset> 

Hand Weapons

There are two aspects of hand weapons that differ from what's provided by the Skeleton files. The first is the parry adjustment, and the second is the weapon's reach. As with how we handled armor piercing, both of these aspects are numeric ratings, so we'll add new fields to track both of them. Since these aspects only apply to hand weapons, we'll add them to the "WeapMelee" component, which is in the file "equipment.pri". The new fields should look similar to the ones shown below.

<field
  id="wpParry"
  name="Parry Adjustment"
  type="static">
  </field>

<field
  id="wpReach"
  name="Reach Distance"
  type="static">
  </field> 

With the tracking of the Parry adjustment, we need to apply that adjustment appropriately when the weapon is equipped. That entails defining a new Eval script for the component. All it needs to do is apply the proper adjustment to Parry, which is achieved via the script below.

<eval value="4" phase="PreTraits" priority="5000">
  <before name="Calc trtFinal"/><![CDATA[
  if (field[grIsEquip].value <> 0) then
    #traitbonus[trParry] += field[wpParry].value
    endif
  ]]></eval> 

Again as we did for armor piercing, we need to add these ratings to the weapon description details. This can be done within the "InfoMelee" procedure within the file "procedures.dat". Since the rulebook omits these ratings unless they are non-zero, we'll do the same within the description text. This yields code that should look similar to the following.

~report the parry adjustment of the weapon (if any)
if (field[wpParry].value <> 0) then
  iteminfo &= "Parry Adjustment: " & signed(field[wpPiercing].value) & "\n"
  endif 
~report the reach of the weapon (if any)
if (field[wpReach].value > 0) then
  iteminfo &= "Reach: " & field[wpReach].value & "\n"
  endif

Our last task is to add these two ratings to the special notes shown for weapons on the Armory tab. This can be done via the Eval script within the "WeapMelee" component that performs this function. Since the logic is basically the same, we can use the code from adding the armor piercing as a template. The new lines of code should look like below.

~report the parry adjustment of the weapon (if any)
if (field[wpParry].value <> 0) then
  if (empty(special) = 0) then
    special &= ", "
    endif
  special &= "Parry " & signed(field[wpParry].value)
  endif
~report the reach rating of the weapon (if any)
if (field[wpReach].value <> 0) then
  if (empty(special) = 0) then
    special &= ", "
    endif
  special &= "Reach " & field[wpReach].value
  endif 

Add Hand Weapons

Everything is now in place for us to start adding all of the various hand weapons to the data files. All weapons should be added to the file "thing_armory.dat". A few examples are provided below. You can either add the rest or pull them out of the complete Savage Worlds data files that are provided.

<thing
  id="wpGreatswd"
  name="Greatsword"
  compset="Melee"
  description="Description goes here">
  <fieldval field="wpDamage" value="Str+4"/>
  <fieldval field="wpStrReq" value="5"/>
  <fieldval field="wpParry" value="-1"/>
  <fieldval field="grCost" value="400"/>
  <fieldval field="grWeight" value="12"/>
  <usesource id="TimeMedi"/>
  <usesource id="TimePowder"/>
  <tag group="WeaponType" tag="MedBlades"/>
  <tag group="Equipment" tag="TwoHand"/>
  </thing>

<thing
  id="wpSpear"
  name="Spear"
  compset="Melee"
  description="Description goes here">
  <fieldval field="wpDamage" value="Str+2"/>
  <fieldval field="wpStrReq" value="3"/>
  <fieldval field="wpParry" value="1"/>
  <fieldval field="wpReach" value="1"/>
  <fieldval field="grCost" value="250"/>
  <fieldval field="grWeight" value="5"/>
  <usesource id="TimeMedi"/>
  <usesource id="TimePowder"/>
  <tag group="WeaponType" tag="MedPoles"/>
  <tag group="Equipment" tag="TwoHand"/>
  </thing>

<thing
  id="wpSurvKnif"
  name="Survival Knife"
  compset="Melee"
  description="Description goes here">
  <fieldval field="wpDamage" value="Str+1"/>
  <fieldval field="wpSpecial" value="Contains supplies that add +1 to Survival rolls"/>
  <fieldval field="grCost" value="50"/>
  <fieldval field="grWeight" value="3"/>
  <usesource id="TimeModern"/>
  <tag group="WeaponType" tag="ModMelee"/>
  <eval value="1" phase="PreTraits" priority="5000">
    <before name="Calc trtFinal"/><![CDATA[
    #traitroll[skSurvival] += 1
    ]]></eval>
  </thing>

While we're adding all of the hand weapons, we also need to revamp the provided "Unarmed Strike" weapon so that it behaves as a Savage Worlds weapon. The revised version should look similar to the following.

<thing
  id="wpUnarmed"
  name="Unarmed Strike"
  compset="Melee"
  description="Description goes here"
  isunique="yes"
  holdable="no">
  <fieldval field="wpDamage" value="Str"/>
  <fieldval field="wpSpecial" value=""/>
  <fieldval field="grCost" value="0"/>
  <fieldval field="grWeight" value="0"/>
  <tag group="Equipment" tag="Natural"/>
  </thing> 

Revise Table for Hand Weapons

All of the weapons are in place, so we can now revise how the weapons are managed visually within the table. The entirety of the "Amory" tab is defined within the file "tab_armory.dat", so that's where we'll be making our next changes. The table portal for hand weapons is named "arMelee". 

We'll start with the same two changes we made to the table for showing basic gear. First, the width of the area for showing weapons descriptions is too narrow, so add the "descwidth" attribute to the "table_dynamic" element with a value of either 275 or 300. Second, we need to sort the weapons using the sort set we just defined for weapons. So add the "choosesortset" attribute to the same "table_dynamic" element and assign it the unique id of our new sort set: "Weapon".

The next thing we need to adjust is that the Skeleton files we inherited refer to "Melee Weapons", while Savage Worlds uses the term "Hand Weapons". Internally, this distinction is not important, but we want everything to look familiar to users. So we need to modify the scripts within the "headertitle" and "additem" elements to change the terms used.

After making the above changes, we should end up with a revised "arMelee" portal that looks similar to the one below.

<portal
  id="arMelee"
  style="tblNormal">
  <table_dynamic
    component="Gear"
    showtemplate="arWpnPick"
    choosetemplate="arWpnThing"
    choosesortset="Weapon"
    addspace="2"
    buytemplate="BuyCash"
    selltemplate="SellCash"
    descwidth="275">
    <list>component.WeapMelee</list>
    <candidate>component.WeapMelee & !Equipment.Natural</candidate>
    <description><![CDATA[
      var descript as string
      call Descript
      @text = descript
      ]]></description>
    <headertitle><![CDATA[
      @text = "Hand Weapons"
      ]]></headertitle>
    <additem><![CDATA[
      @text = "Add New Hand Weapons"
      ]]></additem>
    </table_dynamic>
  </portal>

We should now ask ourselves if there are any of the new fields that we'd like to see shown for weapons that have been added to the character. The two solid candidates are the Parry adjustment and the AP rating for the weapon. Whenever a weapon is equipped, any Parry adjustment is automatically applied, so it's not something that the user can forget to add, which means it's really not important to remind the user about it. The AP rating, though, it quite different. It's very important that the user not forget about an AP rating for a wielded weapon, so we really should make a point of showing it. 

Showing the AP rating within the template entails a number of additions and revisions. It all centers upon the template, which is named "arWpnPick" and will be found in the file "tab_armory.dat". Before we proceed, note that this one template is used for both hand weapons and ranged weapons, so our additions will appear for both weapon types unless we takes steps to only show it for one type. Since the AP rating is highly applicable for both weapon types, we'll just add it so that it's visible for all weapons.

The first thing we need to do is add a new portal to the template. Since we want the new portal to appear between the damage rating and any range information for the weapon, we'll position the new portal between those two portals within the template. If we use a field-based label portal, we'll only be able to display the raw value, which won't be very clear to the user. So we'll use a script-based label portal instead, allowing us to include a useful prefix and display the AP rating in the form "AP2". This means our new field should look similar to the one below.

<portal
  id="piercing"
  style="lblDisable">
  <label>
    <labeltext><![CDATA[
      if (field[wpPiercing].value > 0) then
        @text = "AP" & field[wpPiercing].value
      else
        @text = ""
        endif
      ]]></labeltext>
    </label>
  </portal>

Once the portal has been added, we now need to position it properly. In order to make room for it, we'll also need to nudge around some of the other portals. After a little bit of experimenting, a suitable result can be achieved, yielding the following new Position script.

~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[attack].centervert
perform portal[damage].centervert
perform portal[piercing].centervert
perform portal[range].centervert
perform portal[special].centervert
perform portal[gearmanage].centervert
perform portal[delete].centervert
perform portal[strreq].centervert
perform portal[heldby].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,-6]
position the gear portal to the left of the info button
perform portal[gearmanage].alignrel[rtol,info,-6]
~position the special portal to the left of the gear button
perform portal[special].alignrel[rtol,gearmanage,-6]
~position the range portal to the left of the delete button; we want the
~damage to be centered in its own column relative to a centerpoint position
perform portal[range].centerpoint[horz,335]
~position the AP portal to the left of the range column; we want the AP to
~be centered in its own column relative to a centerpoint position
perform portal[piercing].centerpoint[horz,280]
~position the damage portal to the left of the AP column; we want the damage
~to be centered in its own column relative to a centerpoint position
perform portal[damage].centerpoint[horz,240]
~position the attack portal to the left of damage column; we want the
~attack to be centered in its own column relative to a centerpoint position
perform portal[attack].centerpoint[horz,195]
~position the name on the left and let it use all available space
var limit as number
limit = portal[attack].left - 8 - portal[heldby].width - 5 - portal[strreq].width - 2
portal[name].left = 0
portal[name].width = minimum(portal[name].width,limit)
~show the 'strength requirement' icon to the right of the name
perform portal[strreq].alignrel[ltor,name,2]
portal[strreq].visible = tagis[Helper.BadStrReq]
~show the 'held by' icon to the right of the strenght requirement if appropriate
if (portal[strreq].visible = 0) then
  portal[heldby].left = portal[strreq].left
else
  perform portal[heldby].alignrel[ltor,strreq,5]
  endif
portal[heldby].visible = isgearheld
~if this is not a ranged weapon, hide the range portal
if (tagis[component.WeapRange] = 0) then
  portal[range].visible = 0
  endif
~only show the special portal if there are special abilities/notes to view
portal[special].visible = 1 - field[wpNotes].isempty