PDA

View Full Version : Expanding the Stat Bonuses past 102?



pauljmendoza
November 6th, 2010, 00:06
I was wondering how hard would it be to expand the Stat bonus progression past 102 (i.e. 103= +40, 104 +45, 105 +50, 106 +55, etc.) I know this can be done by just adding things to the misc. bonus column, but I would also like to expand this so the Development changes, etc.

Pretty limited right now in my .xml knowledge right now, is this incredibly hard? OR, has anyone already done this?

StuartW
November 6th, 2010, 08:07
This is quite straightforward by using an extension to override the internal bonus calculation function. Extensions are installed on the GM's machine and then apply to all games where the GM selects the extension at launch.

Anything redefined in an extension overrides the same object defined in the underlying ruleset, and in this example you just need to redefine the object that controls how abilities are laid out on the character sheet (a windowclass called 'abilitywindow'). Although this is a fairly big bit of xml, the modifications are quite minor and I've shown them in red:


<windowclass name="abilitywindow">
<sizelimits>
<maximum>
<height>20</height>
</maximum>
<minimum>
<height>20</height>
</minimum>
</sizelimits>
<script>
function refresh()
local tot;
bonus.setValue(getBonus(temp.getValue()));
tot = bonus.getValue() + race.getValue() + special.getValue();
total.setValue(tot);
dp.setValue(getDPs(temp.getValue()));
dp.setVisible(getDev());
windowlist.setDPs();
end

function getBonus()
local val = 0;
if not win or not win.temp then
return 0;
end
val = win.temp.getValue();
if val > 99 then
return (val-95)*5;
elseif val > 97 then
return 20;
elseif val > 94 then
return 15;
elseif val > 89 then
return 10;
elseif val > 74 then
return 5;
elseif val > 24 then
return 0;
elseif val > 9 then
return -5;
elseif val > 4 then
return -10;
elseif val > 2 then
return -15;
elseif val > 1 then
return -20;
else
return -25;
end end

function getDPs(val)
if val &gt; 101 then
return val-91;
elseif val &gt; 99 then
return 10;
elseif val &gt; 94 then
return 9;
elseif val &gt; 84 then
return 8;
elseif val &gt; 74 then
return 7;
elseif val &gt; 59 then
return 6;
elseif val &gt; 39 then
return 5;
elseif val &gt; 24 then
return 4;
elseif val &gt; 14 then
return 3;
elseif val &gt; 4 then
return 2;
else
return 1;
end
end

function setDev(status)
if status then
dev.setValue(1);
else
dev.setValue(0);
end
refresh();
end

function getDev()
return (dev.getValue()~=0);
end

function onInit()
refresh();
temp.getDatabaseNode().onUpdate = refresh;
race.getDatabaseNode().onUpdate = refresh;
special.getDatabaseNode().onUpdate = refresh;
end
</script>
<sheetdata>
<numbercontrol name="order">
<bounds>0,0,0,0</bounds>
<invisible/>
</numbercontrol>
<numberfieldX name="dev">
<bounds>0,0,0,0</bounds>
<invisible/>
</numberfieldX>
<stringfieldX name="label">
<anchored>
<position>insidetopleft</position>
<offset>0,4</offset>
<size>
<width>35</width>
<height>17</height>
</size>
</anchored>
<font>sheetlabel</font>
<static/>
</stringfieldX>
<numberfieldX name="temp">
<anchored>
<position>insidetopleft</position>
<offset>40,1</offset>
<size>
<width>35</width>
<height>18</height>
</size>
</anchored>
<font>sheettext</font>
<frame>
<name>modifier</name>
<offset>4,4,4,4</offset>
</frame>
<keyeditframe>
<name>sheetfocus</name>
<offset>4,4,4,4</offset>
</keyeditframe>
<script>
function onValueChanged()
if getValue() &lt; 0 or getValue() &gt; window.potential.getValue() then
setInvalid();
window.potential.setInvalid();
else
setValid();
window.potential.setValid();
end
end

function onInit()
if super
and super.onInit then
super.onInit();
end
onValueChanged();
end
</script>
<tabtarget>
<prev>special</prev>
<next>potential</next>
</tabtarget>
</numberfieldX>
<numberfieldX name="potential">
<anchored>
<to>temp</to>
<position>right</position>
<offset>5</offset>
<size>
<width>35</width>
</size>
</anchored>
<font>sheettext</font>
<frame>
<name>modifier</name>
<offset>4,4,4,4</offset>
</frame>
<keyeditframe>
<name>sheetfocus</name>
<offset>4,4,4,4</offset>
</keyeditframe>
<script>
function onValueChanged()
if getValue() &lt; 0 or getValue() &lt; window.temp.getValue() then
setInvalid();
window.temp.setInvalid();
else
setValid();
window.temp.setValid();
end
end

function onInit()
if super
and super.onInit then
super.onInit();
end
onValueChanged();
end
</script>
<tabtarget>
<prev>temp</prev>
<next>race</next>
</tabtarget>
</numberfieldX>
<numbercontrolX name="bonus">
<anchored>
<to>potential</to>
<position>right</position>
<offset>5</offset>
<size>
<width>35</width>
</size>
</anchored>
<font>sheettext</font>
<frame>
<name>modifier</name>
<offset>4,4,4,4</offset>
</frame>
<displaysign/>
<readonly/>
<hideonvalue>0</hideonvalue>
</numbercontrolX>
<numberfieldX name="race">
<anchored>
<to>bonus</to>
<position>right</position>
<offset>5</offset>
<size>
<width>35</width>
</size>
</anchored>
<font>sheettext</font>
<frame>
<name>modifier</name>
<offset>4,4,4,4</offset>
</frame>
<keyeditframe>
<name>sheetfocus</name>
<offset>4,4,4,4</offset>
</keyeditframe>
<displaysign/>
<hideonvalue>0</hideonvalue>
<tabtarget>
<prev>potential</prev>
<next>special</next>
</tabtarget>
</numberfieldX>
<numberfieldX name="special">
<anchored>
<to>race</to>
<position>right</position>
<offset>5</offset>
<size>
<width>35</width>
</size>
</anchored>
<font>sheettext</font>
<frame>
<name>modifier</name>
<offset>4,4,4,4</offset>
</frame>
<keyeditframe>
<name>sheetfocus</name>
<offset>4,4,4,4</offset>
</keyeditframe>
<displaysign/>
<hideonvalue>0</hideonvalue>
<tabtarget>
<prev>race</prev>
<next>temp</next>
</tabtarget>
</numberfieldX>
<numberfieldX name="total">
<anchored>
<to>special</to>
<position>right</position>
<offset>5</offset>
<size>
<width>35</width>
</size>
</anchored>
<font>sheettext</font>
<frame>
<name>modifier</name>
<offset>4,4,4,4</offset>
</frame>
<readonly/>
<displaysign/>
</numberfieldX>
<numbercontrolX name="dp">
<anchored>
<to>total</to>
<position>right</position>
<offset>5</offset>
<size>
<width>35</width>
</size>
</anchored>
<font>sheettext</font>
<frame>
<name>modifier</name>
<offset>4,4,4,4</offset>
</frame>
<readonly/>
</numbercontrolX>
</sheetdata>
</windowclass>

I'm not sure how you wanted DPs to progress, so I've assumed you wanted 102=11, 103=12, 104=13 etc.

The changed definition then needs packaging up into an extension by adding some enclosing xml, and saving it in a file called extension.xml


<?xml version="1.0" encoding="iso-8859-1"?>

<root version="2.0">
<properties>
<name>Extended Bonuses</name>
<version>1</version>

<author>Stuart Woodard</author>
<description>Extends ability bonuses beyond 102.</description>

<ruleset>
<name>RolemasterClassic</name>
<minrelease>1</minrelease>
</ruleset>
</properties>

<base>
YOUR WINDOWCLASS DEFINITION GOES HERE
</base>
</root>

Finally you need to save the extension.xml file in a new subdirectory of your extensions directory. Name the subdirectory something like 'extendedbonus' and put the extension.xml file in it. Your directory structure should look a bit like this:


<application data directory>
+-extensions
+-extendedbonus
+-extension.xml
The application data directory can be found from the Fantasy Grounds II program group in your Windows Start menu.

Hope that helps

Stuart

pauljmendoza
November 6th, 2010, 23:07
This more than helps. Wow thank you!

StuartW
November 7th, 2010, 07:28
If you are having difficulties, you might want to open the log window (type /console in the chat box) and see if there are any errors being reported. You can also add diagnostics to the code using the Lua 'print' command, such as print("line 7"); or print("value is "..value); and you can see which bits of code are executing and why.

Stuart

StuartW
November 7th, 2010, 07:33
I just noticed an error in the code I posted, it was lifted from another routine without me taking enough care. Replace the getBonus() function with the following:


function getBonus(val)
if val > 99 then
return (val-95)*5;
elseif val > 97 then
return 20;
elseif val > 94 then
return 15;
elseif val > 89 then
return 10;
elseif val > 74 then
return 5;
elseif val > 24 then
return 0;
elseif val > 9 then
return -5;
elseif val > 4 then
return -10;
elseif val > 2 then
return -15;
elseif val > 1 then
return -20;
else
return -25;
end
end

Sorry about that!

Stuart

pauljmendoza
November 7th, 2010, 15:23
Thank you so much for all this! I hope to get better at all this, but I am learning.

pauljmendoza
November 7th, 2010, 20:42
By the way, you should officially post this. It works very nicely!