How to add new Derived Stat tutorial
Savage Worlds ruleset provides way to easily add new derived stats. You will still need to be able to create extensions for Fantasy Grounds to achive this, but if you're able to do it it will be piece of cake. This tutorial does not teach you how to do extension as is, you can find other fine documentations how to do them.
There is only two things you need to do:
- Create new xml template defining how new derived stat's base value is calculated. If you don't care about this, you can use default template: derivedstat_default instead
- Register new derived stat in lua script.
XML-template
The following shows you what you can do in the template definition, there are several predefined values you can use. don't be scared yet, this only demonstrates everything you can do in the template, but you must only define things you actually need!!
Code:
<template name="DerivedStatTemplate"> <!-- name of the template, should be unique -->
<derbase>
<setup> <!-- within setup you can define how base value is calculated -->
<attribute> <!-- base value can be from set of attributes -->
<sum/> <!-- you can define one of these values: sum, min, max, avg if nothing is included sum will be used -->
<min/>
<max/>
<avg/>
<half>Agility</half> <!-- you can include either half of full value -->
<full>Smarts</full>
</attribute>
<node> <!-- base value can be from any other nodes -->
<sum/>
<min/>
<max/>
<avg/>
<half>main.xp</half>
<full>pace</full>
</node>
<skill> <!-- base value can be from any skill -->
<sum/>
<min/>
<max/>
<avg/>
<half>Fighting</half>
<full>Notice</full>
</skill>
<division>2</division> <!-- value can be divided by someting -->
<multiplier>3</multiplier> <!-- value can be multiplied by someting -->
<modifier>1</modifier> <!-- value can be modified by something -->
</setup>
</derbase>
</template>
- Basically Derived stat's base value can be calculated from attribute, skill or any other numberic node value OR any combination of these three. Let's call these "sources"
- You can get either half or full value from above sources. For instance "Half of Fighting"
- You can define one -- and only one of following: sum, min, max, avg. These values will determine how multiple sources are included in. If you define sum, then all values from different sources are summed together. In case of min or max only the minimum or maximum value from all possible sources counts. In case of avg the average o all source value is taken. Note that even if you are able to define these into different type of sources, only ONE and ONLY ONE is applied. If nothing is defined, then sum will be used.
- After "sources" you can adjust the final value by providing division, multiplier and/or modifier.
For example to define derived stat that's base value is "Minimum of Half of Notice or Half of Streetwise, + 2" you would define following:
Code:
<template name="ExampleDerivedStat1">
<derbase>
<setup>
<skill>
<min/>
<half>Notice</half>
<half>Streetwise</half>
</skill>
<modifier>2</modifier>
</setup>
</derbase>
</template>
To define "one fifth of your current experience" you define following:
Code:
<template name="DerviedStatExample2">
<derbase>
<setup>
<node>
<full>main.xp</full>
</node>
<division>5</division>
</setup>
</derbase>
</template>
"Half of Fighting + 2"
Code:
<template name="DerviedStatExample3">
<derbase>
<setup>
<skill>
<half>Fighting</half>
</skill>
<modifier>2</modifier>
</setup>
</derbase>
</template>
"Average of Spirit and Vigor"
Code:
<template name="DerviedStatExample4">
<derbase>
<setup>
<attribute>
<avg/>
<full>Spirit</full>
<full>Vigor</full>
</attribute>
</setup>
</derbase>
</template>
Like mentioned above if you really don't care about calculation of base value you can skip this phase
Register new Derived Stat in Lua
This is the one-liner you must use to register your derived stat:
Code:
DerivedStatManager.registerDerivedStat("LongName", "ShortName", "NodeName", "DerivedStatTemplate", {charsheet=true, minisheet=true, npc=true, ct=true, ct_client=true})
- The first argument is the name of the derived stat
- The second argument is the short name of the derived stat
- The third argument is the nodename of your derived stat. This should be unique!
- The fourth argument is name of the xml-template you just define. Alternatively if you skipped the phase you should use value derivedstat_default
- The last argument define in which view the derived stat is displayed in. There are following supported values: charsheet, minisheet, npc, ct and ct_client. If the value is set true then it's showed in. Values must be given within {}'s since they are a list.
Give this a try and give us feedback!