PDA

View Full Version : Party Sheet diceroll script



ThinkTank
January 1st, 2014, 01:02
I have an odd problem with the rolls made by the party sheet.

https://img607.imageshack.us/img607/7234/l0ms.jpg

The issue is that on doubleclicking the bonus box below the stat on the party sheet, some will roll and add the bonus as normal. But others only roll without the bonus.

What script file(s) should I be looking in to find the lines responsible for adding the bonus to the roll?

From what I can see everything seems correctly labelled, so its perplexing how it works with some but not all of them.

Any suggestions would be welcome.

Moon Wizard
January 1st, 2014, 21:08
It depends on the definition for that control in the party sheet.

When you look at the control definition, there will either be a script tag associated with that control, or the control will be derived from a template that has a script tag.

A good editor with multi-file searching is key to looking up assets, such as templates.

If you are not familiar with how templates work in FG, I can provide more info. The basic idea is that you can name a template asset in the ruleset files, and reference it in a windowclass definition to inherit all the XML in that template asset.

Regards,
JPG

ThinkTank
January 1st, 2014, 22:31
Thanks for the reply

At the moment I have ps_main.xml, manager_ps.lua, ps_roll_ability.lua, manager_action_ability.lua, data_common.lua, charsheet_main.xml and manager_actor.lua all adding or doing diffrent things for the same few boxs, and Im not sure which to look in (or what control deals with automaticaly adding those bonuses to a diceroll if I did).

I'll have another go at matching instances of the ones that work with those that dont and see if I've missed somthing.

Moon Wizard
January 1st, 2014, 23:50
Can you package up the ruleset into a ZIP, and share a link to download? I think it will be easier to walk through what is happening using your code as the example.

Regards,
JPG

Trenloe
January 1st, 2014, 23:57
Taking the 3.5e ruleset as an example. ps_roll_ability.lua uses "ActionAbility.performRoll(nil, v, sAbilityStat, nTargetDC, bSecretRoll);" to perform the roll.

ActionAbility is scripts\manager_action_ability.lua and the performRoll function calls getRoll in the same file that calls the following to get the stat bonus: rRoll.nMod = ActorManager2.getAbilityBonus(rActor, sAbilityStat);

ActorManager2 is scripts\manager_actor2.lua and getAbilityBonus works out the ability bonus. In here it calls: local nStatScore = getAbilityScore(rActor, sStat); - with getAbilityScore having specific code to get the value of the ability score:

if sShort == "lev" then
nStatScore = DB.getValue(nodeActor, "level", 0);
elseif sShort == "bab" then
nStatScore = DB.getValue(nodeActor, "attackbonus.base", 0);
elseif sShort == "str" then
nStatScore = DB.getValue(nodeActor, "abilities.strength.score", 0);
elseif sShort == "dex" then
nStatScore = DB.getValue(nodeActor, "abilities.dexterity.score", 0);
elseif sShort == "con" then
nStatScore = DB.getValue(nodeActor, "abilities.constitution.score", 0);
elseif sShort == "int" then
nStatScore = DB.getValue(nodeActor, "abilities.intelligence.score", 0);
elseif sShort == "wis" then
nStatScore = DB.getValue(nodeActor, "abilities.wisdom.score", 0);
elseif sShort == "cha" then
nStatScore = DB.getValue(nodeActor, "abilities.charisma.score", 0);
end

I'm guessing that as some of your statistics roll with the bonus and some don't that it might be in something similar to this that your code does not cater for all ability scores?

ThinkTank
January 2nd, 2014, 01:41
Can you package up the ruleset into a ZIP, and share a link to download? I think it will be easier to walk through what is happening using your code as the example.

Regards,
JPG

https://www.mediafire.com/download/f0vntozvfqs5bj1/IKRPG.zip

The ps will kick up a few errors when you look at it, those are things Im getting to, not related to this issue.


I'm guessing that as some of your statistics roll with the bonus and some don't that it might be in something similar to this that your code does not cater for all ability scores?

That sounds like it yes. Currently I have



elseif rActor.sType == "pc" then
if sShort == "lev" then
nStatScore = DB.getValue(rActor.nodeCreature, "level", 0);
elseif sShort == "phy" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.phy.score", 0);
elseif sShort == "spd" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.spd.score", 0);
elseif sShort == "str" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.str.score", 0);
elseif sShort == "agi" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.agi.score", 0);
elseif sShort == "prw" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.prw.score", 0);
elseif sShort == "poi" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.poi.score", 0);
elseif sShort == "int" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.int.score", 0);
elseif sShort == "arc" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.arc.score", 0);
elseif sShort == "per" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.per.score", 0);
elseif sShort == "will" then
nStatScore = DB.getValue(rActor.nodeCreature, "Willpower", 0);
end
end

return nStatScore;
end


It seems perfectly happy to work as it should with most of them, but spd, prw, and will dont get added to an ability roll when clicked from the ps.

On another note, I have no idea at all whats going on with the ps_skills, they dont seem to bare any relation to the characters skills, even after I relabled the referances; so theres another set of connections I need to go track down.

Trenloe
January 2nd, 2014, 07:12
It seems perfectly happy to work as it should with most of them, but spd, prw, and will dont get added to an ability roll when clicked from the ps.

I'd suggest double-checking in your db.xml file exactly how those abilities are being stored and that they match the node reference in the DB.getValue calls. Sorry if you've done this before...

ThinkTank
January 2nd, 2014, 08:06
All the number_ps_abilitycheck lines in ps_main.xml match up to whats in the data_common.lua and manager_actor.lua for the stats being called as far as I can see, unless my brain is just skipping somthing.

Trenloe
January 2nd, 2014, 08:39
That sounds like it yes. Currently I have



elseif rActor.sType == "pc" then
if sShort == "lev" then
nStatScore = DB.getValue(rActor.nodeCreature, "level", 0);
elseif sShort == "phy" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.phy.score", 0);
elseif sShort == "spd" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.spd.score", 0);
elseif sShort == "str" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.str.score", 0);
elseif sShort == "agi" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.agi.score", 0);
elseif sShort == "prw" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.prw.score", 0);
elseif sShort == "poi" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.poi.score", 0);
elseif sShort == "int" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.int.score", 0);
elseif sShort == "arc" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.arc.score", 0);
elseif sShort == "per" then
nStatScore = DB.getValue(rActor.nodeCreature, "stats.per.score", 0);
elseif sShort == "will" then
nStatScore = DB.getValue(rActor.nodeCreature, "Willpower", 0);
end
end

return nStatScore;
end


It seems perfectly happy to work as it should with most of them, but spd, prw, and will dont get added to an ability roll when clicked from the ps.
The code in the above function only looks at sShort which stores the first 3 characters of the ability name. Hence it would be looking for speed, prowess and willpower, not spd, prw or will as is shown above.

ThinkTank
January 2nd, 2014, 09:03
Got it, thank you. I can get on with figuring out how many things I'v broken in the skill list now :D

Moon Wizard
January 2nd, 2014, 20:45
EDIT: Trenloe beat me to it.

OK, I found it.

* The number_ps_abilitycheck template passes the target tag to the ActionAbility.performRoll call, which then calls ActorManager.getAbilityScore with that value.
* The target tag for the Speed field is "Speed".
* When this tag is passed to ActorManager.getAbilityScore, it generates a short 3-letter version of "spe".
* The code currently in ActorManager.getAbilityScore is looking for a value of "spd" for the Speed ability.

To figure it out, I used this code at line 385 in manager_actor.lua:


Debug.chat("GET ABILITY SCORE", sShort);


The getAbilityScore function was written for D&D where the short version of the ability score names are always the first 3 letters of the full ability score names. I haven't reviewed all the places that ActorManager.getAbilityBonus is called in your ruleset, but you may need to review the parameters passed to this function if you see the problem again.

You can fix this quickly by specifying the short 3 letter versions of the ability names in the <target> tag for the "number_ps_abilitycheck" controls in the PS main tab.

Cheers,
JPG