PDA

View Full Version : How to add new Derived Stat tutorial



Ikael
February 23rd, 2015, 19:23
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!!



<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:



<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:



<template name="DerviedStatExample2">
<derbase>
<setup>
<node>
<full>main.xp</full>
</node>
<division>5</division>
</setup>
</derbase>
</template>


"Half of Fighting + 2"



<template name="DerviedStatExample3">
<derbase>
<setup>
<skill>
<half>Fighting</half>
</skill>
<modifier>2</modifier>
</setup>
</derbase>
</template>


"Average of Spirit and Vigor"



<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:



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!

Coanunn
July 11th, 2015, 20:24
Ok, so I played with this some today and the instructions here are excellent, thank you. That said I have an interesting stat to create that actually uses another derived stat in it's calculation. Is there a way I can do (half (spirit+Derived Stat A))+2?

I tried this and I honestly didn't expect it to work but wasn't sure if there was any way to reference a created derived stat in this fashion.

<template name="DerviedStat_Sanity">
<derbase>
<setup>
<node>
<half>Cha_Humanity</half>
</node>
<attribute>
<half>Spirit</half>
</attribute>
<modifier>2</modifier>
</setup>
</derbase>
</template>

Ikael
July 28th, 2015, 16:47
Ok, so I played with this some today and the instructions here are excellent, thank you. That said I have an interesting stat to create that actually uses another derived stat in it's calculation. Is there a way I can do (half (spirit+Derived Stat A))+2?

I tried this and I honestly didn't expect it to work but wasn't sure if there was any way to reference a created derived stat in this fashion.

If I recall right, yes you can reference another created stat. Just use the name which you gave it in LUA registration phase. Ie. In your case the third parameter in lua should be Cha_Humanity

Hope this helps and sorry for late answer

Dr0W
August 10th, 2015, 13:28
Thanks a lot for the Tutorial Ikael. I've achieved to add 3 new Derived stats for Interface Zero 2.0 (while the official one doesn't come out), attached my extension if it interests anyone for using or learning.

Edit: Updated the extension, there was a miscalculation on Street Cred derived stat.

Doswelk
August 12th, 2015, 23:34
I think you will find that IZ 2.0 will be around soon... :)

Dr0W
August 12th, 2015, 23:47
I'm saving my credits for it.

Mask_of_winter
August 13th, 2015, 03:11
I think you will find that IZ 2.0 will be around soon... :)

promises, promises :P

Dr0W
August 13th, 2015, 16:44
Holy Sh.. Doswelk! It's already out!

kylania
August 13th, 2015, 17:02
Holy Sh.. Doswelk! It's already out!

https://www.fantasygrounds.com/store/product.xcp?id=GMGIZ20FG

Deryl
June 23rd, 2022, 12:09
Hello Ikael,
I am fairly new to Fantasy Grounds and I am in need to add a derived stat to my Savage World campaign. I stumbled upon this tutorial, but I still have a couple of questions. Where do I place the xml-File? Does it have to be in the campaign directory e.g.:

...\Fantasy Grounds\campaigns\SevenWorlds

Which lua-File do I have to update and where to place it? In the above directory there is the CampaignRegistry.lua file. Do I use that one?

Best wishes and keep up the good work.
Deryl

Moon Wizard
June 23rd, 2022, 18:36
It will need to be an "extension" that modifies the base behavior of the game system ruleset. The example in post #4 from DroW is one example where someone used that information.

Any extensions need to be bundled correctly, and placed in the "extensions" subfolder of the FG data folder.

If you are interested in modding the system through extensions, you should probably start reviewing the basics in the Developer section of the wiki:
https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644285/Developer+Guide

Regards,
JPG

Deryl
June 23rd, 2022, 21:12
It will need to be an "extension" that modifies the base behavior of the game system ruleset. The example in post #4 from DroW is one example where someone used that information.

Any extensions need to be bundled correctly, and placed in the "extensions" subfolder of the FG data folder.

If you are interested in modding the system through extensions, you should probably start reviewing the basics in the Developer section of the wiki:
https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644285/Developer+Guide

Regards,
JPG

Thanks for the quick answer and the link to the developer Wiki. I will try to work from here. I figured out already, that I have to use extension.
Best Regards
Deryl

dmbrown
December 20th, 2023, 18:06
I there a way to have a derived stat calculated by subtracting another derived stat? I am able to half and add to, but not subtract from. I am trying to update the Realms of Cthulhu extension so that it correctly determines the Sanity stat, which is calculated by taking (half of Spirit) +2 - corruption.

Jiminimonka
December 20th, 2023, 21:17
I there a way to have a derived stat calculated by subtracting another derived stat? I am able to half and add to, but not subtract from. I am trying to update the Realms of Cthulhu extension so that it correctly determines the Sanity stat, which is calculated by taking (half of Spirit) +2 - corruption.

The first post by Ikael is still valid. There is an extension on the forge by Lonewolf which implements a derived stat, take a look at that and the first post and you will work it out methinks.

dmbrown
December 20th, 2023, 22:08
Thanks for the help, but I've looked at Ikael's post in the begining and haven't seen any information as to how to subtract. There are ones for halving, sum, division, multiplying, min and average.

It looks like the Lonewolf one just adds an extra derived stat and doesn't use other stats to affect it. Maybe when Ikael comes back in the future or someone else before that might have an answer.

Jiminimonka
December 20th, 2023, 22:17
Thanks for the help, but I've looked at Ikael's post in the begining and haven't seen any information as to how to subtract. There are ones for halving, sum, division, multiplying, min and average.

It looks like the Lonewolf one just adds an extra derived stat and doesn't use other stats to affect it. Maybe when Ikael comes back in the future or someone else before that might have an answer.

I think you use <modifier></modifier> to subtract. Is Corruption in this case also a Derived Stat?

dmbrown
December 20th, 2023, 22:45
That works to add, but I couldn’t get it to subtract. Maybe I am missing some thing. I was trying to see if I could get it to work partly to learn more about what was possible and also that I would like to run some Savage Cthulhu in the future.

Thanks for all the updates you do to the Savage Rifts stuff. I have almost everything for it and plan to play that sometime in the future when my players know Savage Worlds well enough.

Jiminimonka
December 21st, 2023, 06:49
That works to add, but I couldn’t get it to subtract. Maybe I am missing some thing. I was trying to see if I could get it to work partly to learn more about what was possible and also that I would like to run some Savage Cthulhu in the future.

Thanks for all the updates you do to the Savage Rifts stuff. I have almost everything for it and plan to play that sometime in the future when my players know Savage Worlds well enough.

I will have a look at the weekend see if I can figure it out.

In Horror Companion (SWADE) Sanity got "removed" and Fear expanded to make Sanity a role-play element rather than a stat.

Thanks for buying the Savage Rifts stuff, I put a lot of time into that (and still do).

dmbrown
December 21st, 2023, 19:13
Thanks for taking a look.

It shows that you put a lot of time into your conversions as they are very well done. I’ll grab the horror companion when it goes on sale.

Mike Serfass
December 21st, 2023, 22:59
dmbronw, can you post a code snippet?

dmbrown
December 22nd, 2023, 02:20
Sure. Here is the code I took from Ikael's extension to try to get to work:


<root version="3.0">
<properties>
<name>Realms of Cthulhu</name>
<version>1.7</version>
<author>Aki Heikkinen (Ikael)</author>
<description>Realms of Cthulhu Derived Stats and Madness</description>
<ruleset>
<name>SavageWorlds</name>
</ruleset>
<ruleset>
<name>SWD</name>
</ruleset>
<loadorder>15</loadorder>
</properties>
<announcement text="Realms of Cthulhu v1.7" font="emotefont" icon="wildcard" />
<base>
<script name="RealmsOfCthulhuLauncher" file="launcher.lua"/>
<icon name="indicator_penalty_madness" file="indicator_penalty_madness.png" />
<template name="derivedstat_sanity">
<derbase>
<setup>
<attribute>
<half>spirit</half>
</attribute>
<modifier>2</modifier>
<node>
<!--<modifier>corruption</modifier>-->
<subtract>5</subtract>
</node>
<!--<subtraction>corruption</subtraction>-->
</setup>
</derbase>
</template>
<template name="ct_derivedstats">
<ct_derivedstats_base>
<entryColumns>5</entryColumns>
</ct_derivedstats_base>
</template>
<template name="ct_damagetypetitles">
<ct_damagetypetitles_base>
<entryWidth>32</entryWidth>
</ct_damagetypetitles_base>
</template>
<template name="ct_client_damagetypetitles">
<ct_damagetypetitles_base>
<entryWidth>32</entryWidth>
</ct_damagetypetitles_base>
</template>
</base>
</root>


You can see all the things I tried to do. There weren't any subtraction tags mentioned in Ikael's post, but I gave it a shot. The modifier tag only ever seems to add. I am trying to take half of spirt add 2 and then subtract the corruption derived stat. Thanks in advance for any help.

Mike Serfass
December 22nd, 2023, 06:23
According to post 2 & 3, you can reference a derived stat.
To subtract, multiple by -1 then add that. So try

<multiplier>-1</multiplier>
then

<modifier>derivedstat_corruption</modifier>
assuming that it can take a reference to a number in addition to a hard-coded number.
If the node doesn't work with a reference to a value, try adding type="number" to modifier like this

<modifier type="number">derivedstat_corruption</modifier>

dmbrown
December 22nd, 2023, 16:54
Thanks for the help and the great extensions you make.

The code snippets did not work and it appears if you put a "-" in front of the number/variable it will just ignore it. So it seems maybe you can't subtract.