Yes, this would be best as an extension.
Printable View
Yes, this would be best as an extension.
While testing my own strike rank handling code I noticed that the existing code doesn't really work as expected.
The SR value is never updated. That's probably becausein onUptionUpdate() in ct/scripts/ct_entry.lua returns nil.Code:local nodeActor = link.getTargetDatabaseNode();
This code in getStrikeRank() in scripts/manager_gameline.lua
returns values even if the node is nil.Code:local DEX = DB.getValue(node, "abilities.dexterity", 11);
local SIZ = DB.getValue(node, "abilities.size", 11);
Following up on the previous post.
You can verify the problem by:
a) create a new campaign
b) turn on the strike ranks option
c) reload the ruleset
d) create character
e) Drag it to the CT. The SR will be 5.
f) Change the characters SIZ and DEX to 21. This should set the SR to 1. But it doesn't, it remains at 5.
g) Change SIZ and DEX to 3. This should set the SR to 7. But it doesn't, it remains at 5.
Further investigation.
DebuggingwithCode:local nodeActor = link.getTargetDatabaseNode();
I getCode:Debug.console("Node Actor 1", nodeActor)
which I'm pretty sure is not what's needed. I know that the code is old so this maybe is some code that needs to be refactored?Quote:
s'Node Actor 1' | databasenode = { combattracker.list.id-00001 }
Digging into this a bit more.
In ct/scripts/ct_entry.lua the following code, from onOPtionsUpdate()
results in a different database node then this code from linkPCFields()Code:function onOptionUpdate()
...
local nodeChar = link.getTargetDatabaseNode();
The code in linkPCFields returns the characters db node (which is what you want), while onOptionUpdate don't. Since onOptionUpdate calls getStrikeRank with no db node the SR update fails.Code:function linkPCFields()
super.linkPCFields();
local nodeChar = link.getTargetDatabaseNode();
I can get it to factor the Siz and Dex mods, but it won't factor weapon or power mods into the Strike Rank. That would require more factoring to have the players/GM to pick their action and add them to the box. Which as you can see is a bit of an undertaking.
Yes, I understand that. But, as I explained in my posts above, the existing code doesn't work. The SR is never updated because the getStrikerank funktion gets a nil value instead of a character node.
Just to avoid any misunderstandings, I'm not asking you to factor weapons or power into strike ranks, I'm going to fix that part myself. I'm just letting you know that there's a problem with the existing code, and (incidentally) that create problems down the line for my code.
Yes, I understand your request. I just wanted to be sure there was no misunderstanding with power and weapon mods to the strike rank.
Well, I got it working.
In ct/scripts/ct_entry.lua I modified onOptionUpdate() so that the DB.setValue used the database node of the CT windowlist.
I also modified linkPCFields() and added a link to a aggregated SR value that is re-calculated when the underlying data is changed.Code:function onOptionUpdate()
local sOptHRSR = OptionsManager.getOption("HRSR");
strikerank.setVisible(sOptHRSR == "on");
local nodeChar = link.getTargetDatabaseNode();
local ctNode = getDatabaseNode();
local nStrikeRank = LineManager.getLine().GetStrikeRank(nodeChar);
DB.setValue(ctNode, "strikerank", "number", nStrikeRank);
end
As an added bonus the ordering of entries worked out by itself since high DEX = low SR.Code:function linkPCFields()
super.linkPCFields();
local nodeChar = link.getTargetDatabaseNode();
if nodeChar then
pp.setLink(DB.createChild(nodeChar, "pp.current", "number"), true);
wounds.setLink(DB.createChild(nodeChar, "wounds", "number"));
hp.setLink(DB.createChild(nodeChar, "hp.max", "number"), true);
initresult.setLink(DB.createChild(nodeChar, "abilities.dexterity", "number"), true);
strikerank.setLink(DB.createChild(nodeChar, "sr.activeSR", "string"), true);
end
end
I pushed a hotfix for the strike rank issue. I would look over the code for my implementation as it is somewhat different than the approach you have made.