PDA

View Full Version : Problems creating a starwars saga ruleset based on the 4E ruleset



gandhi39
January 6th, 2017, 02:14
I'm making a StarWars RPG Saga Edition ruleset based on the existing 4E ruleset.

As my ruleset has different skills than the 4E ruleset, I had to change a few things.

My progress has been good so far, but the skills tab of the party sheet is giving me some problems.

I managed to change the labels for the specific skills on the party sheet but the skill bonus does display correctly. When I double clic or drag and drop on the chat it works as intended, but the number displayed on the party sheet is 0. I believe the problem is related to the "number_ps_skill" controls on the "ps_skills.xml" file, but I can't figure it out. I attached the file code from lines 232 to 312.

Your help is really appreciated.

Thanks in advance.


17263



<number_ps_skill name="insight">
<anchored to="name">
<top offset="-10" />
<left offset="10" />
</anchored>
<skill>Insight</skill>
</number_ps_skill>
<number_ps_skill name="perception">
<anchored to="insight" />
<skill>Perception</skill>
</number_ps_skill>

<number_ps_skill name="arcana">
<anchored to="perception">
<left offset="15" />
</anchored>
<skill>Know.: Bureaucracy</skill>
</number_ps_skill>
<number_ps_skill name="dungeoneering">
<anchored to="arcana" />
<skill>Know.: Galactic Lore</skill>
</number_ps_skill>
<number_ps_skill name="history">
<anchored to="dungeoneering" />
<skill>Know.: Life Sciences</skill>
</number_ps_skill>
<number_ps_skill name="nature">
<anchored to="history" />
<skill>Know.: Phys. Sciences</skill>
</number_ps_skill>
<number_ps_skill name="religion">
<anchored to="nature" />
<skill>Know.: Social Sciences</skill>
</number_ps_skill>

<number_ps_skill name="bluff">
<anchored to="religion">
<left offset="15" />
</anchored>
<skill>Deception</skill>
</number_ps_skill>
<number_ps_skill name="diplomacy">
<anchored to="bluff" />
<skill>Persuasion</skill>
</number_ps_skill>
<number_ps_skill name="intimidate">
<anchored to="diplomacy" />
<skill>Mechanics</skill>
</number_ps_skill>
<number_ps_skill name="streetwise">
<anchored to="intimidate" />
<skill>Use Computer</skill>
</number_ps_skill>

<number_ps_skill name="acrobatics">
<anchored to="streetwise">
<left offset="15" />
</anchored>
<skill>Acrobatics</skill>
</number_ps_skill>
<number_ps_skill name="athletics">
<anchored to="acrobatics" />
<skill>Athletics</skill>
</number_ps_skill>
<number_ps_skill name="endurance">
<anchored to="athletics" />
<skill>Endurance</skill>
</number_ps_skill>
<number_ps_skill name="heal">
<anchored to="endurance" />
<skill>Treat Injury</skill>
</number_ps_skill>
<number_ps_skill name="stealth">
<anchored to="heal" />
<skill>Stealth</skill>
</number_ps_skill>
<number_ps_skill name="thievery">
<anchored to="stealth" />
<skill>Survival</skill>
</number_ps_skill>

Trenloe
January 6th, 2017, 02:29
The links between the labels and the actual PC database fields is done in ps\scripts\manager_ps2.lua - in the linkPCSkills function. You'll see where a if .. then .. elseif statement stpes through each label name and matches this to a skill name in the FG database.

gandhi39
January 6th, 2017, 02:56
Should I put a skill listed on "data_common.lua" in the second slot?

Exemple:



elseif sLabel == "arcana" then
linkPCSkill(v, nodePS, "know.: bureaucracy");

gandhi39
January 6th, 2017, 03:01
Figured it out: it's the other way around.

Thank you very much!

gandhi39
January 6th, 2017, 03:09
Unfortunately I found another problem now.

I changed "template_char.xml" so that it would return "3" when "trained" was checked on the skill tab of the character sheet. And it worked fine when rolling from the character sheet.

But when rolling from the party sheet it keeps returning "5" instead of "3", even if the displayed total bonus is correct.

Are there other commands like those on "template_char.xml" specific for the party sheet?

17264



<template name="number_charskilltotal">
<number_linked>
<frame name="fieldlight" offset="7,5,7,5" />
<displaysign />
<rollable />
<hideonvalue>0</hideonvalue>
<source>
<name>stat</name>
<op>+</op>
</source>
<source>
<name>...encumbrance.armorcheckpenalty</name>
<op>+</op>
</source>
<source>
<name>...levelbonus</name>
<op>+</op>
</source>
<source>
<name>trained</name>
<op>+</op>
</source>
<source>
<name>misc</name>
<op>+</op>
</source>
<script>
function onSourceValue(source, sourcename)
if sourcename == "trained" then
if source.getValue() == 1 then
return 3;
end
return 0;
elseif sourcename == "...encumbrance.armorcheckpenalty" then
if StringManager.contains({"strength", "dexterity", "constitution"}, DB.getValue(window.getDatabaseNode(), "statname", "")) then
return math.min(source.getValue(), 0);
end
return 0;
end

return super.onSourceValue(source, sourcename);
end

function action(draginfo)
local nodeWin = window.getDatabaseNode();
if nodeWin then
local rActor = ActorManager.getActor("pc", nodeWin.getChild("..."));
local sLabel = DB.getValue(nodeWin, "label", "");
local sStat = DB.getValue(nodeWin, "statname", "");
ActionSkill.performRoll(draginfo, rActor, sLabel, getValue(), sStat);
end

return true;
end

function onDragStart(button, x, y, draginfo)
return action(draginfo);
end

function onDoubleClick(x,y)
return action();
end
</script>
</number_linked>
</template>

Trenloe
January 6th, 2017, 03:26
Notice that in the number_ps_skill template (used for the skill fields in the party sheet) that there is a call to the CharManager.getSkillValue function that gets the value of the skill:


<template name="number_ps_skill">
<number_ps_linked>
<anchored width="22" height="20">
<top />
<left anchor="right" offset="8" />
</anchored>
<gmrollable2 />
<script>
function onInit()
super.onInit();
if not User.isHost() then
setEnabled(false);
end
end

function action(draginfo)
if not User.isHost() then
return false;
end

if skill then
local rActor = ActorManager.getActor("pc", window.link.getTargetDatabaseNode());
local nValue = CharManager.getSkillValue(rActor, skill[1]);

local nTargetDC = DB.getValue("partysheet.skilldc", 0);
if nTargetDC == 0 then
nTargetDC = nil;
end

local bSecretRoll = (DB.getValue("partysheet.hiderollresults", 0) == 1);

ActionSkill.performRoll(draginfo, rActor, skill[1], nValue, nil, nTargetDC, bSecretRoll);
return true;
end

return false;
end

function onDragStart(button, x, y, draginfo)
return action(draginfo);
end

function onDoubleClick(x,y)
return action();
end
</script>
</number_ps_linked>
</template>

CharManager is a global package that is defined in the 4E ruleset base.xml file: <script name="CharManager" file="campaign/scripts/manager_char.lua" />

So, looking at the getSkillValue function in ampaign/scripts/manager_char.lua:


function getSkillValue(rActor, sSkill)
local nValue = 0;

local sType, nodeActor = ActorManager.getTypeAndNode(rActor);
if sType == "pc" then
local nodeSkill = nil;
for _,vNode in pairs(DB.getChildren(nodeActor, "skilllist")) do
local sName = DB.getValue(vNode, "label", "");
if sName == sSkill then
nodeSkill = vNode;
break;
end
end

if nodeSkill then
local nLevel = DB.getValue(nodeSkill, "...levelbonus", 0);
local nAbility = DB.getValue(nodeSkill, "stat", 0);
local nMisc = DB.getValue(nodeSkill, "misc", 0);

nValue = nLevel + nAbility + nMisc;

local nTrained = DB.getValue(nodeSkill, "trained", 0);
if nTrained == 1 then
nValue = nValue + 5;
end

local sAbility = DB.getValue(nodeSkill, "statname", "");
if StringManager.contains({"strength", "dexterity", "constitution"}, sAbility) then
local nACPenalty = DB.getValue(nodeSkill, "...encumbrance.armorcheckpenalty", 0);
nValue = nValue + math.min(nACPenalty, 0);
end
else
local rSkill = DataCommon.skilldata[sSkill];
if rSkill then
if rSkill.stat then
nValue = nValue + ActorManager2.getAbilityBonus(rActor, rSkill.stat);
end

if rSkill.armorcheckmultiplier then
local nArmorCheckPenalty = DB.getValue(nodeActor, "encumbrance.armorcheckpenalty", 0);
nValue = nValue + (nArmorCheckPenalty * (tonumber(rSkill.armorcheckmultiplier) or 0));
end
end
end
end

return nValue;
end

gandhi39
January 6th, 2017, 03:34
Cool! Problem solved!

How do you know all that stuff?

Trenloe
January 6th, 2017, 03:41
How do you know all that stuff?
I just look in the code. And a passing familiarity with how Fantasy Grounds does "stuff" helps. ;)

gandhi39
January 6th, 2017, 03:53
If I have a specific dex based skill (like Pilot) that I don't want to get armor check penalty, what should I do?

What about a specific cha based skill (like Use the Force) that I do want to get armor check penalty?

Trenloe
January 6th, 2017, 03:55
In the skilldata table in scripts\data_common.lua include armorcheckmultiplier = 1 with the skill entry to include/remove the armor check penalty as required. Acrobatics is an example with and Bluff is an example without the penalty.

gandhi39
January 6th, 2017, 03:58
I did so



["Pilot"] = {
stat = "dexterity",
armorcheckmultiplier = 0
},
["Ride"] = {
stat = "dexterity",
armorcheckmultiplier = 1
},
["Stealth"] = {
stat = "dexterity",
armorcheckmultiplier = 1
},
["Survival"] = {
stat = "wisdom"
},
["Treat Injury"] = {
stat = "wisdom"
},
["Use Computer"] = {
stat = "intelligence"
},
["Use the Force"] = {
stat = "charisma",
armorcheckmultiplier = 1
}



But it didn't work

17265

Trenloe
January 6th, 2017, 04:07
You don't need armorcheckmultiplier = 0 to not have the armor penalty applied, just remove the whole line.

And as an FYI (you may already know this): changes to the skilldadta table will only be populated when a new character is created, they won't change an existing character.

gandhi39
January 6th, 2017, 04:15
Unfortunately it is really not working as expected.

Perhaps it requires something more on "template_char.xml" ou "manager_char.lua".

damned
January 6th, 2017, 07:07
You are gonna have to learn how to use Find in Files feature of notepad++ or other editing tool/application.
Star with what you know and search an unpacked 4e ruleset for all instances of that... follow the breadcrumbs.

Trenloe
January 6th, 2017, 20:46
Unfortunately it is really not working as expected.
Looks like, although the 4E skilldata has the armorcheckmultiplier field, it is not being used in the 4E ruleset.

Have a look at the code in the 3.5E ruleset campaign\scripts\char_skill.lua file and the same file in the 4E ruleset. In the 4E ruleset the onStatUpdate function is hard coded to add the armor penalty to all skills based on the three physical stats, whereas in 3.5E it does it slightly differently and checks for the armorcheckmultiplier in the skilldata.

You could change char_skill.lua to do it either way - hard coded or to read the armorcheckmultiplier field. Up to you how you do it...

Trenloe
January 6th, 2017, 20:48
Guidelines on modifying a ruleset here: https://www.fantasygrounds.com/forums/showthread.php?19033-Modifying-the-3-5e-PFRPG-ruleset It's aimed at the 3.5E ruleset, but is 99% appropriate to the 4E ruleset.

gandhi39
January 7th, 2017, 05:41
4E files go like this:

template_char.xml 4E


<template name="number_charskilltotal">
<number_linked>
<frame name="fieldlight" offset="7,5,7,5" />
<displaysign />
<rollable />
<hideonvalue>0</hideonvalue>
<source>
<name>stat</name>
<op>+</op>
</source>
<source>
<name>...encumbrance.armorcheckpenalty</name>
<op>+</op>
</source>
<source>
<name>...levelbonus</name>
<op>+</op>
</source>
<source>
<name>trained</name>
<op>+</op>
</source>
<source>
<name>misc</name>
<op>+</op>
</source>
<script>
function onSourceValue(source, sourcename)
if sourcename == "trained" then
if source.getValue() == 1 then
return 3;
end
return 0;
elseif sourcename == "...encumbrance.armorcheckpenalty" then
if StringManager.contains({"strength", "dexterity", "constitution"}, DB.getValue(window.getDatabaseNode(), "statname", "")) then
return math.min(source.getValue(), 0);
end
return 0;
end

return super.onSourceValue(source, sourcename);
end

function action(draginfo)
local nodeWin = window.getDatabaseNode();
if nodeWin then
local rActor = ActorManager.getActor("pc", nodeWin.getChild("..."));
local sLabel = DB.getValue(nodeWin, "label", "");
local sStat = DB.getValue(nodeWin, "statname", "");
ActionSkill.performRoll(draginfo, rActor, sLabel, getValue(), sStat);
end

return true;
end

function onDragStart(button, x, y, draginfo)
return action(draginfo);
end

function onDoubleClick(x,y)
return action();
end
</script>
</number_linked>
</template>



record_char_skills.xml 4E


<windowclass name="char_skill">
<margins control="0,0,0,2" />
<script file="campaign/scripts/char_skill.lua" />
<sheetdata>
<button_checkbox name="showonminisheet">
<bounds>6,8,12,12</bounds>
<default>1</default>
</button_checkbox>
<button_checkbox name="classskill">
<bounds>22,8,12,12</bounds>
</button_checkbox>

<genericcontrol name="rightanchor">
<anchored width="0" height="0">
<top />
<right />
</anchored>
<invisible />
</genericcontrol>
<button_idelete name="idelete">
<anchored width="20" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
</button_idelete>
<genericcontrol name="idelete_spacer">
<anchored width="20" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<disabled />
<invisible />
</genericcontrol>
<linkfield name="shortcut">
<anchored width="20" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-2" />
</anchored>
<allowdrop />
<description field="label" />
</linkfield>
<number_charskilltotal name="total">
<anchored width="44" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
</number_charskilltotal>
<number_charskillfield name="misc">
<anchored width="32" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-15" />
</anchored>
<tabtarget prev="label" />
</number_charskillfield>
<button_checkbox name="trained">
<anchored width="32" height="12">
<top offset="6" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
</button_checkbox>
<simplenumber name="level" source="...levelbonus">
<anchored width="32" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<displaysign />
<hideonvalue>0</hideonvalue>
<disabled />
</simplenumber>
<number_charskillfield_static name="stat">
<anchored width="32" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<script>
function update(statname)
setValue(DB.getValue(window.getDatabaseNode(), "...abilities." .. statname .. ".bonus", 0));
end
</script>
</number_charskillfield_static>
<cycler_skillability name="statname">
<anchored width="32" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<script>
function onValueChanged()
window.onStatUpdate();
end
</script>
</cycler_skillability>
<genericcontrol name="armorwidget">
<anchored width="8" height="9">
<top offset="7" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
</genericcontrol>

<stringu name="label">
<anchored height="20">
<top offset="2" />
<left offset="40" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<tabtarget next="misc" />
</stringu>
</sheetdata>
</windowclass>



char_skill.lua 4E


function onStatUpdate()
stat.update(statname.getStringValue());

if StringManager.contains({"strength", "dexterity", "constitution"}, statname.getStringValue()) then
armorwidget.setIcon("char_armorcheck");
else
armorwidget.setIcon(nil);
end
end



manager_char.lua 4E


function getSkillValue(rActor, sSkill)
local nValue = 0;

local sType, nodeActor = ActorManager.getTypeAndNode(rActor);
if sType == "pc" then
local nodeSkill = nil;
for _,vNode in pairs(DB.getChildren(nodeActor, "skilllist")) do
local sName = DB.getValue(vNode, "label", "");
if sName == sSkill then
nodeSkill = vNode;
break;
end
end

if nodeSkill then
local nLevel = DB.getValue(nodeSkill, "...levelbonus", 0);
local nAbility = DB.getValue(nodeSkill, "stat", 0);
local nMisc = DB.getValue(nodeSkill, "misc", 0);

nValue = nLevel + nAbility + nMisc;

local nTrained = DB.getValue(nodeSkill, "trained", 0);
if nTrained == 1 then
nValue = nValue + 3;
end

local sAbility = DB.getValue(nodeSkill, "statname", "");
if StringManager.contains({"strength", "dexterity", "constitution"}, sAbility) then
local nACPenalty = DB.getValue(nodeSkill, "...encumbrance.armorcheckpenalty", 0);
nValue = nValue + math.min(nACPenalty, 0);
end
else
local rSkill = DataCommon.skilldata[sSkill];
if rSkill then
if rSkill.stat then
nValue = nValue + ActorManager2.getAbilityBonus(rActor, rSkill.stat);
end

if rSkill.armorcheckmultiplier then
local nArmorCheckPenalty = DB.getValue(nodeActor, "encumbrance.armorcheckpenalty", 0);
nValue = nValue + (nArmorCheckPenalty * (tonumber(rSkill.armorcheckmultiplier) or 0));
end
end
end
end

return nValue;
end

gandhi39
January 7th, 2017, 05:44
3.5 files go like this:

template_char.xml 3.5


<template name="number_charskilltotal">
<number_linked>
<frame name="fieldlight" offset="7,5,7,5" />
<displaysign />
<rollable />
<hideonvalue>0</hideonvalue>
<source><name>stat</name><op>+</op></source>
<source><name>state</name><op>+</op></source>
<source><name>...encumbrance.armormaxstatbonusactive</name></source>
<source><name>...encumbrance.armorcheckpenalty</name><op>+</op></source>
<source><name>ranks</name><op>+</op></source>
<source><name>misc</name><op>+</op></source>
<script>
function onSourceValue(source, sourcename)
if sourcename == "ranks" then
return math.floor(source.getValue());
elseif sourcename == "...encumbrance.armorcheckpenalty" then
local bMaxActive = sources["...encumbrance.armormaxstatbonusactive"].getValue();
if bMaxActive &gt; 0 then
return math.min(DB.getValue(window.getDatabaseNode(), "armorcheckmultiplier", 0) * source.getValue(), 0);
end
return 0;
elseif sourcename == "state" then
if DataCommon.isPFRPG() then
local nodeWin = window.getDatabaseNode();
if DB.getValue(nodeWin, "state", 0) == 1 then
local nRanks = DB.getValue(nodeWin, "ranks", 0);
if nRanks > 0 then
return 3;
end
end
end
return 0;
end

return super.onSourceValue(source, sourcename);
end

function action(draginfo)
local nodeWin = window.getDatabaseNode();
if nodeWin then
local rActor = ActorManager.getActor("pc", nodeWin.getChild("..."));
ActionSkill.performPCRoll(draginfo, rActor, nodeWin);
end

return true;
end

function onDragStart(button, x, y, draginfo)
return action(draginfo);
end

function onDoubleClick(x,y)
return action();
end
</script>
</number_linked>
</template>



record_char_skills.xml 3.5


<windowclass name="char_skill">
<margins control="0,0,0,2" />
<script file="campaign/scripts/char_skill.lua" />
<sheetdata>
<hn name="armorcheckmultiplier">
<script>
function onValueChanged()
window.onCheckPenaltyChange();
end
</script>
</hn>

<button_checkbox name="showonminisheet">
<bounds>6,8,12,12</bounds>
<default>1</default>
</button_checkbox>
<button_checkbox name="state">
<bounds>22,8,12,12</bounds>
<script>
function onValueChanged()
CharManager.updateSkillPoints(window.getDatabaseNo de().getChild("..."));
end
</script>
</button_checkbox>

<genericcontrol name="rightanchor">
<anchored width="0" height="0">
<top />
<right />
</anchored>
<invisible />
</genericcontrol>
<button_idelete name="idelete">
<anchored width="20" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-2" />
</anchored>
</button_idelete>
<genericcontrol name="idelete_spacer">
<anchored width="20" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-2" />
</anchored>
<disabled />
<invisible />
</genericcontrol>
<linkfield name="shortcut">
<anchored width="20" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-2" />
</anchored>
<description field="label" />
<allowdrop />
</linkfield>
<number_charskilltotal name="total">
<anchored width="44" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
</number_charskilltotal>
<number_charskillfield name="misc">
<anchored width="32" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-15" />
</anchored>
<tabtarget prev="ranks" />
</number_charskillfield>
<number_charskillfield_static name="stat">
<anchored width="32" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<script>
function update(statname)
setValue(DB.getValue(window.getDatabaseNode(), "...abilities." .. statname .. ".bonus", 0));
end
</script>
</number_charskillfield_static>
<cycler_charskillability name="statname">
<anchored width="40" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<stateframe>
<hover name="sheetfocus" offset="5,5,5,5" />
</stateframe>
<script>
function onValueChanged()
window.onStatUpdate();
end
</script>
</cycler_charskillability>
<number_charskillranks name="ranks">
<anchored width="32" height="20">
<top offset="2" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<tabtarget next="misc" prev="sublabel" />
</number_charskillranks>
<genericcontrol name="armorwidget">
<anchored width="8" height="9">
<top offset="7" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
</genericcontrol>

<stringu name="label">
<anchored height="20">
<top offset="2" />
<left offset="40" />
<right parent="rightanchor" anchor="left" relation="relative" offset="-5" />
</anchored>
<tabtarget next="sublabel" />
<script>
function onEnter()
window.windowlist.addEntry(true);
return true;
end
</script>
</stringu>
<stringu name="sublabel">
<anchored to="label" height="20">
<top anchor="bottom" />
<left />
<right />
</anchored>
<invisible />
<tabtarget next="ranks" prev="label" />
<script>
function onEnter()
window.windowlist.addNewInstance(window.label.getV alue());
return true;
end
</script>
</stringu>
</sheetdata>
</windowclass>



char_skill.lua 3.5


function updateWindow()
local sLabel = label.getValue();
local t = DataCommon.skilldata[sLabel];
if t then
setCustom(false);

if t.sublabeling then
sublabel.setVisible(true);
end

if t.armorcheckmultiplier then
armorcheckmultiplier.setValue(t.armorcheckmultipli er);
else
armorcheckmultiplier.setValue(0);
end
else
setCustom(true);
end
end

function onCheckPenaltyChange()
if armorcheckmultiplier.getValue() ~= 0 then
armorwidget.setIcon("char_armorcheck");
else
armorwidget.setIcon(nil);
end
end

gandhi39
January 7th, 2017, 05:49
continues

gandhi39
January 7th, 2017, 06:03
manager_char.lua 3.5


function getSkillValue(rActor, sSkill, sSubSkill)
local nValue = 0;
local bUntrained = false;

local rSkill = DataCommon.skilldata[sSkill];
local bTrainedOnly = (rSkill and rSkill.trainedonly);

local nodeChar = ActorManager.getCreatureNode(rActor);
if nodeChar then
local sSkillLower = sSkill:lower();
local sSubLower = nil;
if sSubSkill then
sSubLower = sSubSkill:lower();
end

local nodeSkill = nil;
for _,vNode in pairs(DB.getChildren(nodeChar, "skilllist")) do
local sNameLower = DB.getValue(vNode, "label", ""):lower();

-- Capture exact matches
if sNameLower == sSkillLower then
if sSubLower then
local sSubName = DB.getValue(vNode, "sublabel", ""):lower();
if (sSubName == sSubLower) or (sSubLower == "planes" and sSubName == "the planes") then
nodeSkill = vNode;
break;
end
else
nodeSkill = vNode;
break;
end

-- And partial matches
elseif sNameLower:sub(1, #sSkillLower) == sSkillLower then
if sSubLower then
local sSubName = sNameLower:sub(#sSkillLower + 1):match("%w[%w%s]*%w");
if sSubName and ((sSubName == sSubLower) or (sSubLower == "planes" and sSubName == "the planes")) then
nodeSkill = vNode;
break;
end
end
end
end

if nodeSkill then
local nRanks = DB.getValue(nodeSkill, "ranks", 0);
local nAbility = DB.getValue(nodeSkill, "stat", 0);
local nMisc = DB.getValue(nodeSkill, "misc", 0);

nValue = math.floor(nRanks) + nAbility + nMisc;

if DataCommon.isPFRPG() and (nRanks > 0) then
local nState = DB.getValue(nodeSkill, "state", 0);
if nState == 1 then
nValue = nValue + 3;
end
end

local nACMult = DB.getValue(nodeSkill, "armorcheckmultiplier", 0);
if nACMult ~= 0 then
local bApplyArmorMod = DB.getValue(nodeSkill, "...encumbrance.armormaxstatbonusactive", 0);
if (bApplyArmorMod ~= 0) then
local nACPenalty = DB.getValue(nodeSkill, "...encumbrance.armorcheckpenalty", 0);
nValue = nValue + (nACMult * nACPenalty);
end
end

if bTrainedOnly then
if nRanks == 0 then
bUntrained = true;
end
end
else
if rSkill then
if rSkill.stat then
nValue = nValue + ActorManager2.getAbilityBonus(rActor, rSkill.stat);
end

if rSkill.armorcheckmultiplier then
local bApplyArmorMod = DB.getValue(nodeChar, "encumbrance.armormaxstatbonusactive", 0);
if (bApplyArmorMod ~= 0) then
local nArmorCheckPenalty = DB.getValue(nodeChar, "encumbrance.armorcheckpenalty", 0);
nValue = nValue + (nArmorCheckPenalty * (tonumber(rSkill.armorcheckmultiplier) or 0));
end
end
end
bUntrained = bTrainedOnly;
end
else
bUntrained = bTrainedOnly;
end

return nValue, bUntrained;
end

gandhi39
January 7th, 2017, 06:05
I don't know how to script in lua. Unfortunately intuition is my only tool.

Any help is very appreciated.

What could I do to make 4E display the armorcheckpenalty widget and calculate de penalty into the skills tab of the character sheet as in the 3.5 ruleset (following the "armorcheckmultiplier = 1" line on data_common.lua)?