View Full Version : Need help with a damage roll feature
Paul Pratt
March 2nd, 2014, 08:22
Hello,
I have used the CoreRPG and 3.5 to add some features to the Dark Heresy ruleset. There is a weapon quality in the game that allows players to roll twice for damage and pick the highest die. Based on 3.5 damage rolls, is there a way to add that to a single roll? Roll compare two die return the higher then continue the automation? It would be nice to have the report give the discarded roll, I know a few players will feel better.
Since the damage is added diretly to the CT, rolling twice, then going back to the CT to adjust the discarded roll, well, frankly defeats the awesome sauce that is the 3.5 tracker. I have struggled with this for weeks and would really like to add the feature. I just have no idea where to start.
I figured I could add a check box, if the box is checked then I could add a die to the roll. So sending two die to the action_damage was a start. From there as the process headed off to the actions_manager I got in over my head.
Ideas or pointers appreciated.
Paul
Trenloe
March 2nd, 2014, 11:10
Blackfoot did something similar for the custom ruleset he is developing - basically removing one or more dice from a damage roll, and his ruleset is based on 3.5e too. You may want to PM him or reply to this thread to see if he can give more details: https://www.fantasygrounds.com/forums/showthread.php?20489-Negative-DMG-Effects
I believe the theory behind it is that roll results include a LUA table (like an array) of dice, and you can step through each dice ("row" in the table) - find the lowest die result and remove the whole die from the table. Blackfoot may have done this or found another way...
Moon Wizard
March 2nd, 2014, 18:21
I did something similar in the 5E ruleset for advantage/disadvantage. (I.e. Roll 2 d20 dice, and choose highest/lowest). I even made the result die icon in the chat box to be green/red based on adjustment.
Things you need:
* add extra die to roll
* add info to roll data that this is a "linked" dice roll.
* if you are rolling more than 1 die originally, you also need to add info to roll data to track which particular dice are "linked".
* when the onDiceLanded event occurs, use to roll data to determine whether dice are linked (and which ones if needed).
* Build your own chat message roll result with the roll text and which dice you want to display.
Cheers,
JPG
sciencephile
March 3rd, 2014, 04:27
I will take a stab at solving this and integrating it into the Dark Heresy Ruleset (with the modifications Paul has provided). I'm at Disneyland this week but I will try to get it uploaded next week. I will then upload the new Dark Heresy ruleset with this and the modifications that Paul provided. Paul also provided a set of modified instructions which I will provide, as well (giving him credit for all of this, of course). It's nice to collaborate with someone on these sort of things rather than being a sole source provider :)
Thanks JPG for the direction on where to look for the 2 rolls.
Danny
sciencephile
March 7th, 2014, 15:46
I did something similar in the 5E ruleset for advantage/disadvantage. (I.e. Roll 2 d20 dice, and choose highest/lowest). I even made the result die icon in the chat box to be green/red based on adjustment.
Things you need:
* add extra die to roll
* add info to roll data that this is a "linked" dice roll.
* if you are rolling more than 1 die originally, you also need to add info to roll data to track which particular dice are "linked".
* when the onDiceLanded event occurs, use to roll data to determine whether dice are linked (and which ones if needed).
* Build your own chat message roll result with the roll text and which dice you want to display.
Cheers,
JPG
I can't seem to find the 5e ruleset (even in Test or Dev mode) so I'm assuming it isn't released yet. Can I get a copy of the .xml and .lua files that address the 2 rolls, keep highest/lowest as you mentioned above, please (so I can mimic what you did)? I will PM you my direct email address.
Thank you,
Danny
Zeus
March 7th, 2014, 20:12
I can't seem to find the 5e ruleset (even in Test or Dev mode) so I'm assuming it isn't released yet. Can I get a copy of the .xml and .lua files that address the 2 rolls, keep highest/lowest as you mentioned above, please (so I can mimic what you did)? I will PM you my direct email address.
Thank you,
Danny
5E is available (invite only) through the Test slot of the FG updater. Drop a PM to moon_wizard to get added to the test group. Once your added you will need to open up the Updater and re-authenticate, 5E should appear in the list of packages for download.
sciencephile
March 10th, 2014, 01:52
Nevermind. I am withdrawing my name from attempting to fix this and retiring from ruleset development. Good luck with the helm of the Dark Heresy ruleset, Paul.
Moon Wizard
March 10th, 2014, 02:47
Sciencephile,
If 5E access is issue, I will be able to get you access on Monday. I have only been able to respond via phone since mid-week, so I haven't been able to set up yet.
Regards,
JPG
sciencephile
March 10th, 2014, 02:55
Thanks. I already told Paul I will attempt to help him once he/I gets access. Part of it is that I am getting burned out trying to work within a proprietary codeset in my free time. I am managing a 20 million dollar high risk project for my day job and my evening are limited and I'm getting a bit burnt out monkeying with code on what little free time I have. I am taking second seat as Paul has done a good job modifying the ruleset.
Moon Wizard
March 11th, 2014, 02:32
Sciencephile,
I just added access to 5E for you. The functions you are looking for are ActionsManager2.encodeAdvantage and ActionsManager2.decodeAdvantage.
Cheers,
JPG
sciencephile
March 11th, 2014, 06:49
I will work with Paul to help him with the issue. Thanks for the direction and the 5e access.
Danny
Paul Pratt
March 15th, 2014, 00:20
Thanks guys. Working along and have this one almost solved, then I began to wonder how I can hide certain fields based on weapon types. For instance, I want different fields visible for use based on whether the weapon is ranged or melee. I have looked at the way the CT uses this for defense, movement, effects, etc... and I could do that, but what if I was dragging a shortcut over and dropping it. Based on melee/range have it display the fields I want. I haven't seen this yet in a ruleset to get an idea of how to proceed. Anyone seen something similar before?
Moon Wizard
March 15th, 2014, 00:25
The 3.5E and 4E rulesets do this with item records. The 3.5E ruleset does it automatically based on the value of the Type field (i.e. Weapon, Armor, something else), while the 4E ruleset has the GM specify via radio button if the item is Armor, Weapon or Other. Based on the type value, the fields in the item record window change.
Regards,
JPG
Paul Pratt
March 15th, 2014, 02:18
Thanks, Moon. I would have never thought to look at the item records.
Paul Pratt
March 18th, 2014, 09:35
Thanks for the help. So far I have been able to accomplish the goals I have set. I ran into one more issue. I have a basicnumber in a weapons list and I am trying to set it to a number from a skills list. Take a look at this please.
function setPR()
local node = getDatabaseNode().getParent();
local nPR = DB.getValue(node, "...basicskills.parry.skilltotal", 9);
weaponlistparry.setValue(nPR);
end
I set the "9" just to make sure a value would come up. It returns 9. So, I understand that I am not finding the skill node correctly. I figured if I used "getParent" I would be at the root level and I could find the skill list this way. What am I missing? Think the 3.5 structure. A weapons list with attack and damage fields on one tab, and a skill list stats and totals on another tab.
Any help is appreciated.
-Paul
Trenloe
March 18th, 2014, 16:11
I figured if I used "getParent" I would be at the root level and I could find the skill list this way. What am I missing? Think the 3.5 structure. A weapons list with attack and damage fields on one tab, and a skill list stats and totals on another tab.
getParent returns the parent of the current node - this is not the "root" level (well, certainly not the root level in terms of usual XML terminology). It is actually the equivalent of using the relative identifier ".." (the first dot points to the current node and the second goes up one level - to the parent).
As you are using relative identifiers in your nPR line of code, the 2 lines of code is the equivalent of going up 3 levels in your database structure from the current node (found with getDatabaseNode) before looking for basicskills.parry.skilltotal.
See the "node identifiers" section of this page in the ruleset modification guide for some info on relative node identifiers: https://www.fantasygrounds.com/modguide/database.xcp
Looking at the Dark Heresy ruleset, going up 3 levels from an entry in a weapon in the weapons.id-XXXXX.<your custom field> database structure. However, the basicskills database has the following structure (using the Dark Heresy ruleset from the community list):
<basicskills>
<id-00001>
<name type="string">Test Basic Skill</name>
<shortcut type="windowreference">
<class>ref_skill</class>
<recordname></recordname>
</shortcut>
<skillAdv1 type="number">0</skillAdv1>
<skillAdv2 type="number">0</skillAdv2>
<skilltotal type="number">20</skilltotal>
<skilltrained type="number">0</skilltrained>
</id-00001>
</basicskills>
Note that the database node identifier to get to this skill is basicskills.id-00001 not the name of the skill. You need to do an additional step to find the entry with name = parry.
I can't think of an easy way to do this in 1 or 2 lines of code. The way I'd do this is navigate to the <basicskills> node, use databasenode.getChildren to get all of the <id-XXXXX> nodes in the skill list and then step through each one (using "for k, childnode in pairs (basicskillsnode.getChildren()) do") looking for childnode.getValue("name") == "parry" - this will allow you to find the basicskills node with name = parry.
I have to leave for work now, so I don't have time to provide you with detailed code. But try something like this:
local node = getDatabaseNode();
-- Get the <basicskills> node - 3 levels up from the current databasenode.
local basicskillsnode = node.getChild("....basicskills");
-- Step through each childnode - id-00001, id-00002, etc.
for k, childnode in pairs (basicskillsnode.getChildren()) do
-- look through each childnode for a node with a "name" child with a value of "parry"
if childnode.getChild("name").getValue() == "parry" then
-- childnode is the basicskills node with a name of parry - i.e. basicskills.id-XXXXX.name = "parry".
nPR = childnode.getChild("skilltotal").getValue();
weaponlistparry.setValue(nPR);
-- exit the for loop
break;
end
end
Paul Pratt
March 18th, 2014, 21:32
Thanks Trenloe, I will give this a try. I read about the database last night and using the "dots" had my head spinning. I understand it better with your examples. I thought Parent sent me all the way up the food tree, I see now I wasn't even close.
Trenloe
March 18th, 2014, 21:47
Thanks Trenloe, I will give this a try. I read about the database last night and using the "dots" had my head spinning. I understand it better with your examples. I thought Parent sent me all the way up the food tree, I see now I wasn't even close.
It can certainly take a little while to get your head around it. DB.getRoot goes to the root of the database: https://www.fantasygrounds.com/refdoc/DB.xcp#getRoot
A good method to check where database nodes are actually referring to is to output getNodeName() to the console window (open the console window by typing /console in the chat window). For example, in the code I use above, to find out exactly where basicskillsnode is pointing to, try: Debug.console("basicskillsnode = " .. basicskillsnode.getNodeName());
Paul Pratt
March 19th, 2014, 03:17
Code above worked with a few changes. Had to use ..."basicskills" instead of ...."basicskills" and "Parry" for "parry". Discovering what it took to make the code above work was a great learning experience, with your examples and code, the way to navigate up and down the database is more clear ever. Thank you very much for taking the time to post.
-Paul
Trenloe
March 19th, 2014, 03:30
Code above worked with a few changes. Had to use ..."basicskills" instead of ...."basicskills" and "Parry" for "parry". Discovering what it took to make the code above work was a great learning experience, with your examples and code, the way to navigate up and down the database is more clear ever. Thank you very much for taking the time to post.
Great - glad you got it working. :)
I wasn't 100% sure how many ...'s were needed. :) Hence why I suggested the Debug.console output, which I use a lot as it is very easy to think you're at the right node in a database when you're actually not.
Just in case you're not aware (or others reading this thread aren't aware) you can check the database structure by opening the db.xml file in the campaign directory. Open it in a good text editor that highlights XML (and allows you to close and open sections, I use the free Notepad++ application, it highlights LUA code as well! :)
Nickademus
March 19th, 2014, 04:23
....it highlights LUA code as well! :)
Purdy colors.... @.@
I endorse this message.
Paul Pratt
March 20th, 2014, 08:47
I actually use SciTE -WoW interface... yes from when I worked on a few Warcraft add-ons. Great for .xml and LUA. Now if I'd get a few classes at the local college, I may actually be able to understand more. I can tweak, but starting from scratch...well that's way beyond me. Some of the work I see looking through rulesets amazes me. Bravo to the community and the willingness to assist.
Oh.. I was also able to add in another weapon feature after looking at the 5E. In Dark Heresy there is a weapon feature that has a minimum for damage rolled. It's called 'Proven". So, Proven 3 means anything less than "3" on your die counts as a 3. With a few tweaks, that is working well. Thanks Moon.
I have the set pretty much wrapped up. Images optimized, files cleaned up, and I noticed a thread about strings for localization. I will have to get that done. Only one disappointment I have is for my attack rolls, I can get double click, or the button roll to work, but not roll, drag and drop on the target in the Ct or token. The issue is in Dark Heresy the modifiers add to your base trait, Strength for instance. So base 34 plus 20 mod from effects or the modstack for an adjusted 54. The rolls total is compared to that value. Works perfect for button rolls and double click, the drag is a bummer. Tried a few things, just can't seem to find a good way to work this out.
From what I see adding an additional value, in this case "rRoll.nTarget" to the attack action table requires me to string match it thru most of the steps. I had that done, but in the end, when I dropped the roll on the CT it would always add the die value to the final. When I use the double click, or button, it works correct. Been at it for days and can't see where in the action manager it adds the die value to the drop. Yes, I had to change some values there, just a few lines. When something is dropped on a CT target or the token on the map that is targetted, that uses the same draginfo table as the double click correct?
Trenloe
March 20th, 2014, 15:18
When something is dropped on a CT target or the token on the map that is targetted, that uses the same draginfo table as the double click correct?
The draginfo is usually setup in the onDragStart event for the control, which is different from the onDoubleClick event. These events might share similar data, but each might have code that is unique to the event so I would look at the code of each of these events and see if onDragStart is ensuring all of the info you need is in the dragdata.
Paul Pratt
March 21st, 2014, 06:21
Interesting results in tonights efforts. As I understand things, in most rule sets following CoreRPG we roll a die, the result and its modifiers are then displayed in chat. I am hijaking the mod to use as part of my target number calculations. Like I mentioned above, the double click, or button roll returns fine. When I drag the roll to the CT things get odd. What I am seeing is the die total and the modifier are turned into the "total" roll when dropped on the CT. I went as far as to comment out code until things broke, then added code back in. Bottomline, the roll total and mod are passed thru the CT, now because I have the mod pointing elsewhere, namely my target value, this changes my target number to something incorrect.
Does anyone know where in CoreRPG this is happening? I am in Manager_Actions.lua mainly, I have looked thru the CT files too. If I could find this, I think I could achieve one of the last things I have on my checklist.
Moon Wizard
March 21st, 2014, 18:31
Dragging and dropping onto the CT usually just follows the chain back to ActionsManager, based on the roll type.
Dropping on CT actor list -> ct.lua : function onDrop ->
CombatManager.onDrop -> manager_combat.lua : function onDrop ->
ActionsManager.onDrop
To implement a target number, you might look at the party sheet group skill checks and group ability checks in the 3.5E ruleset. In this case, the target number is passed behind the scenes, and not stored in the draginfo number data.
Regards,
JPG
Paul Pratt
March 26th, 2014, 07:39
Finished up, working, and posted. Thanks for the help!
-Paul
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.