Weapons (Savage)
Context: HL Kit … Authoring 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 & "{br}" 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
We'll focus on hand weapons first. The critical issue with hand weapons is the "weapon die". The damage for most hand weapons is based on the wielder's Strength plus a weapon die. The interesting wrinkle is that the weapon die cannot exceed the wielder's Strength die. If a weapon is listed with a damage of "Str+d8" and the wielder's Strength is "d6", the actual damage is downgraded to "Str+d6". In addition, none of the benefits of the weapon (e.g. Parry bonus) are conferred if the weapon die exceeds the Strength die.
To handle this, we're going to need to add a new field to track the weapon die. Each weapon will specify the appropriate weapon die, and then we'll use an Eval script to downgrade it if the wielder's Strength die is less. The actual damage we display can then be synthesized via another script, after everything has been resolved. We'll worry about how (and whether) to confer the weapon benefits in the next section.
There are also a few weapons that don't have a weapon die and do a fixed amount of damage. For example, the Bangstick does 3d6 damage. In this case, we must not adjust the weapon damage. To handle this, we'll need to distinguish a weapon with a weapon die from a weapon without one.
The simplest solution to all of this is to use a tag to indicate the weapon die for a given weapon. If no tag is assigned to the weapon, then the damage is fixed. Otherwise, we'll use the tag to determine the weapon die and adjust it as appropriate based on the Strength.
To handle the weapon die tags, we must define a new tag group in the file "tags.1st". The tag group needs to have separate tags for each of the different die types. We can allow the tag value to be the weapon die value we want to use internally (e.g. "2" for "d4", just like we do for attributes). However, we'll make sure the name of each tag is the proper die type for display. The resulting tag group should look like the following.
<group id="WeaponDie" name="Weapon Die-Type"> <value id="2" name="d4"/> <value id="3" name="d6"/> <value id="4" name="d8"/> <value id="5" name="d10"/> <value id="6" name="d12"/> </group>
We can now add a new field in which we'll track the weapon die. As part of this field, we can define a Calculate script that interprets the tag and sets up the die type appropriately. Since the weapon die only applies to hand weapons, we'll add the handling to the "WeapMelee" component, which is in the file "equipment.str". The resulting field definition looks like below.
<field id="wpDie" name="Weapon Die" type="derived"> <calculate phase="Initialize" priority="5000"><![CDATA[ ~setup our die type based on any assigned tag @value = tagvalue[WeaponDie.?] ]]></calculate> </field>
The field is in place, so we can define the Eval script to handle the downgrading. Since we know that the weapon is failing it's strength requirement here, we can assign it a suitable tag to indicate that fact. We have to time script to occur after the Strength is resolved. If a downgrade occurs, we need to check that state before the derived traits like Parry are resolved. This means our script timing must occur right after the Strength is resolved. This yields the following Eval script.
<eval index="4" phase="Traits" priority="4000"> <after name="Calc trtFinal"/><![CDATA[ ~if the weapon die is greater than the strength die, downgrade it if (field[wpDie].value > #trait[attrStr]) then field[wpDie].value = #trait[attrStr] perform assign[Helper.BadStrReq] endif ]]></eval>
The final piece we need to deal with is displaying the damage for a weapon. When we display a thing to the user, no Calculate or Eval scripts are evaluated. That means we have two choices for displaying weapons based on their die type. The first option is to duplicate the damage within the "wpDamage" field. That's going to be error prone, so it's a poor choice. The alternative is to use a Finalize script, since a Finalize script is always evaluated for a thing. Unfortunately, Finalize scripts can't be used on text-based fields, so we can't define one for the "wpDamage" field.
The solution is to define a new value-based field and put a Finalize script on it. Within the Finalize script, we need to handle the display of both things and picks. For a thing, the Calculate script on the "wpDie" field has not been performed, so we need to pull the value from the tag. Otherwise, we can pull the value from the (possibly downgraded) field.
Since we'll want to always use this field for showing damage to the user, it needs to exist for all weapons. That means it needs to be defined on the "WeaponBase" component. If we have a ranged weapon that doesn't include the "wpDie" field, we must be careful not to try accessing the non-existent field. We can safeguard against this by checking for the "component.WeapMelee" tag before accessing the weapon die logic.
The role of our new field will be solely for display of the final damage for a weapon, so we'll name it accordingly. We also need to make sure to append any weapon bonus to the final damage. Putting all this together results in the new field definition shown below.
<field id="wpShowDmg" name="Final Damage for Display" type="derived" maxfinal="20"> <!-- If we have a weapon die, synthesize for display, else use wpDamage --> <finalize><![CDATA[ ~use the weapon die to display the damage, else use the explicit damage if (tagis[component.WeapMelee] + tagis[WeaponDie.?] < 2) then @text = field[wpDamage].text else var die as number if (@ispick = 0) then die = tagvalue[WeaponDie.?] * 2 else die = field[wpDie].value * 2 endif @text = "Str+d" & die endif ~append any weapon bonus if (field[wpBonus].value <> 0) then @text &= signed(field[wpBonus].value) endif ]]></finalize> </field>
The handling of the weapon die is now in place. However, we'll need to remember to always use the "wpShowDmg" field for displaying weapon damage. The Skeleton files assume the "wpDamage" field is used, so we need to go through everywhere and change the reference where appropriate. The list is lengthy, so we won't go through each here. You can do a search for "wpDamage" within all the data files and replace it will "wpShowDmg" anywhere that it is being used for display or output of some sort. In general, the only exception would be the definitions of weapons themselves.
Parry and Reach
There are two remaining 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. 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 prior to when the final Parry value is calculated. However, there is an important wrinkle. If the weapon die requirement is not satisfied, the Parry bonus is not applied. This means we also have to schedule our script after we downgrade the weapon die. Fortunately, there is a small window in which we can achieve this, resulting in the script below.
<eval index="5" phase="Traits" priority="5000"> <before name="Derived trtFinal"/> <after name="Downgrade Weapon Die"/><![CDATA[ if (field[grIsEquip].value <> 0) then ~negative adjustments are always applied if (field[wpParry].value < 0) then perform #traitadjust[trParry,+,field[wpParry].value,"Equipped Weapon"] ~otherwise, adjustments are only applied when the strength is satisfied elseif (tagis[Helper.BadStrReq] = 0) then perform #traitadjust[trParry,+,field[wpParry].value,"Equipped Weapon"] endif endif
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. It would be ideal if we can indicate to the user when these abilities don't apply for a weapon. We could accomplish that by highlighting the adjustments in red when the weapon does not satisfy the strength requirements. 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[wpParry].value) & "{br}" endif ~report the reach of the weapon (if any) if (field[wpReach].value > 0) then iteminfo &= "Reach: " & field[wpReach].value & "{br}" endif ~if the weapon fails its strength requirement, change color and style if (empty(special) = 0) then if (tagis[Helper.BadStrReq] <> 0) then special = "{text a00000}{i}" & special & "{/i}{text 010101}" endif 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. As we did above, we'll highlight the abilities if they aren't available due to insufficient Strength. The new lines of code should look like below.
~if the weapon fails its strength requirement, change color and style if (tagis[Helper.BadStrReq] <> 0) then iteminfo &= "{text a00000}{i}" endif ~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 ~if the weapon fails its strength requirement, restore color and style if (tagis[Helper.BadStrReq] <> 0) then iteminfo &= "{/i}{text 010101}" endif
Revised Strength Requirements
There's an important detail that we overlooked in getting the weapon die working. The way we handled things changes the way that minimum strength requirements are detected for hand weapons. As we saw a few moments ago, the Skeleton files provide basic handling that keys on the "wpStrReq" field value. The will continue to work for ranged weapons, but it no longer works for hand weapons, so we need to revise those mechanisms.
There are two separate instances on the "WeaponBase" component that deal with strength requirements. One is an Eval script and the other is a pre-requisite. Since the method is changing for hand weapons only, we have two options. We can move these existing scripts to the "WeapRange" component and then create new versions within the "WeapMelee" component. Alternately, we can adapt these scripts to handle both cases. The logic change is rather simple, so we'll choose the latter option.
Within the pre-requisite test, the only change we need to make is how we determine the minimum strength to be tested. For hand weapons, we use the weapon die if it's available. Otherwise, we use the the field value. We'll use the same test from earlier to determine which method to employ. The revised Validate script is shown below.
<validate><![CDATA[ ~if this is a pick, we're valid ~NOTE! We assume that equipping an item without the strength just applies penalties. if (@ispick <> 0) then @valid = 1 done endif ~get the minimum strength required for the weapon var minstr as number if (altthing.tagis[component.WeapMelee] + altthing.tagis[WeaponDie.?] < 2) then minstr = altthing.field[wpStrReq].value else minstr = altthing.tagvalue[WeaponDie.?] endif ~verify whether we meet the strength requirement if (#trait[attrStr] >= minstr) then @valid = 1 endif ]]></validate>
The same logic needs to be applied to the Eval script. The only other difference is that we only want to assign the "Helper.BadStrReq" tag if it's not already present. We assign that tag when we downgrade the weapon die so that we can detect it for disabled abilities like Parry. Assigning it again is rather silly (albeit harmless). The resulting Eval script should look like the one below.
<eval index="1" phase="Final" priority="5000"><![CDATA[ ~get the minimum strength required for the weapon var minstr as number if (tagis[component.WeapMelee] + tagis[WeaponDie.?] < 2) then minstr = field[wpStrReq].value else minstr = tagvalue[WeaponDie.?] endif ~if the minimum strength is satisfied, there's nothing to do if (minstr <= #trait[attrStr]) then done endif ~assign a tag to indicate the requirement isn't met ~Note: This tag may already be assigned, so don't duplicte it. if (tagis[Helper.BadStrReq] = 0) then perform assign[Helper.BadStrReq] endif ~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>
At this point, our strength requirements logic should be operating properly.
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=""> <fieldval field="wpParry" value="-1"/> <fieldval field="grCost" value="400"/> <fieldval field="gearWeight" value="12"/> <usesource source="TimeMedi"/> <usesource source="TimePowder"/> <tag group="WeaponDie" tag="5"/> <tag group="WeaponType" tag="MedBlades"/> <tag group="Equipment" tag="TwoHand"/> </thing> <thing id="wpSpear" name="Spear" compset="Melee" description=""> <fieldval field="wpParry" value="1"/> <fieldval field="wpReach" value="1"/> <fieldval field="grCost" value="100"/> <fieldval field="gearWeight" value="5"/> <usesource source="TimeMedi"/> <usesource source="TimePowder"/> <tag group="WeaponDie" tag="3"/> <tag group="WeaponType" tag="MedPoles"/> <tag group="Equipment" tag="TwoHand"/> </thing> <thing id="wpSurvKnif" name="Survival Knife" compset="Melee" description=""> <fieldval field="wpSpecial" value="Contains supplies that add +1 to Survival rolls"/> <fieldval field="grCost" value="50"/> <fieldval field="gearWeight" value="3"/> <usesource source="TimeModern"/> <tag group="WeaponDie" tag="2"/> <tag group="WeaponType" tag="ModMelee"/> <eval index="1" phase="PreTraits" priority="5000"> <before name="Calc trtFinal"/><![CDATA[ perform #traitroll[skSurvival,+,1,"Survival Knife"] ]]></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 properly as a Savage Worlds weapon. The revised version should look similar to the following. <pre> <thing id="wpUnarmed" name="Unarmed Strike" compset="Melee" description="" isunique="yes" holdable="no"> <fieldval field="wpDamage" value="Str"/> <fieldval field="wpSpecial" value=""/> <fieldval field="grCost" value="0"/> <fieldval field="gearWeight" value="0"/> <tag group="Equipment" tag="Natural"/> </thing>
Revise Table for Hand Weapons
All of the hand 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" buytemplate="BuyCash" selltemplate="SellCash" descwidth="275"> <list>component.WeapMelee</list> <candidate inheritlist="yes">!Equipment.Natural</candidate> <titlebar><![CDATA[ @text = "Select Hand Weapons to Purchase from the List Below" ]]></titlebar> <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 portal 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,340] ~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,290] ~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,190] ~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