-
June 13th, 2014, 14:24 #1
Saint
- Join Date
- Apr 2007
- Location
- Mississippi, USA
- Posts
- 1,093
Convert 4E healing surge value into a dice roll
I've delved into the code of both the coreRPG ruleset and the 4E rulset, which I'm using as a base for another ruleset.
My problem is I want to change the static healing surge value into a dice roll. I've swapped out on the character sheet the static box for a dice box that you can drag dice onto. I've manage to get all the data inside the right function so when you hit the use a healing surge button it actually gets called and I echoed the data I needed to the console so I know that's working.
My question is what kind of code do I actually need to make FG roll and return a result to me? Can someone explain the process in detail or point me to a way to get a die roll and result?Support:
https://support.fantasygrounds.com/
-
June 13th, 2014, 23:27 #2
Saint
- Join Date
- Apr 2007
- Location
- Mississippi, USA
- Posts
- 1,093
for example I use this and it seems to work fine but I get no return value from it:
Code:nSurges = Comm.throwDice("dice", dice, conMod, "recovery");
Support:
https://support.fantasygrounds.com/
-
June 13th, 2014, 23:46 #3
You might want to have a look at the 4E \scripts\manager_action_heal.lua file that deals with heal actions.
And have a look for "ActionHeal.performRoll" within manager_char.lua for an example of how the heal action is started.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
June 14th, 2014, 01:59 #4
Saint
- Join Date
- Apr 2007
- Location
- Mississippi, USA
- Posts
- 1,093
I've looked at all that. I can't find the definition of the various tables I'm supposed to pass into it, and it doesn't really tell me how to get a return value. The idea is that I'm altering the "useHealingSurge" function to roll dice so that anywhere that a healing surge is used it will roll dice.
Support:
https://support.fantasygrounds.com/
-
June 14th, 2014, 06:12 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
The individual data structures for each ruleset are very specific to that ruleset, so least likely to be documented vs. documenting CoreRPG functionality.
I'm not familiar with 13th Age, but it sounds like a healing surge just becomes a standard self-healing roll at that point.
The chain of calls I followed to reconstruct the data structure: -> CharManager.onPowerAbilityAction(draginfo, nodeAbility, subtype) -> rActor, rAction = CharManager.getAdvancedRollStructures("heal", nodeAbility) -> ActionHeal.performRoll(draginfo, rActor, rAction)
Try something like:
(Note: This example rolls "2d6+5". To customize for your stuff, you'll need to build a dice string using StringManager.convertDiceToString.)
Code:function useHealingSurge(nodeChar) local rActor = ActorManager.getActor("pc", nodeChar); -- Get the character's current wounds value local nWounds = DB.getValue(nodeChar, "hp.wounds", 0); -- If the character is not wounded, then let the user know and exit if nWounds <= 0 then ChatManager.Message(Interface.getString("message_charhsnotwounded"), false, rActor); return; end -- Determine whether the character has any healing surges remaining local nSurgesUsed = DB.getValue(nodeChar, "hp.surgesused", 0); local nSurgesMax = DB.getValue(nodeChar, "hp.surgesmax", 0); if nSurgesUsed >= nSurgesMax then ChatManager.Message(Interface.getString("message_charhsempty"), false, ActorManager.getActor("pc", nodeChar)); return; end local rAction = {}; rAction.name = "Healing Surge"; rAction.sTargeting = "self"; rAction.clauses = {}; local rActionClause = {}; rActionClause.dicestr = "2d6+5"; rActionClause.stat = {}; rActionClause.cost = 1; rActionClause.basemult = 0; table.insert(rAction.clauses, rActionClause); ActionHeal.performRoll(nil, rActor, rAction); end
JPG
-
June 14th, 2014, 06:45 #6
Saint
- Join Date
- Apr 2007
- Location
- Mississippi, USA
- Posts
- 1,093
How do you create a dragdata object without there being a drag? Its required for the function that does rolls
Code:ActionsManager.performAction(draginfo, rActor, rRoll);
Support:
https://support.fantasygrounds.com/
-
June 14th, 2014, 07:33 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
You'll see in the example that I'm passing nil as the draginfo object when calling ActionHeal, since useHealingSurge does not get a draginfo parameter. It assumes you just want to auto-roll. This is consistent with healing surges in 4E, since they do not have a rolling component.
If you wanted to make the healing surge roll draggable: you could also pass draginfo from an onDragStart event to useHealingSurge, add that parameter to the useHealingSurge function and provide that parameter to ActionHeal.performRoll.
By passing nil for draginfo parameter, all the ActionX and ActionManager scripts assume you are double click rolling or button rolling.
Regards,
JPG
-
June 14th, 2014, 08:21 #8
Saint
- Join Date
- Apr 2007
- Location
- Mississippi, USA
- Posts
- 1,093
Sorry, I didn't refresh my browser and somehow missed your example post. Yeah, actually 13th age uses level * dietype + con mod. However I have the dice in a string from the dice box I put in, so all I needed to know was how to get the roll part working and you explained it perfectly. I can probably figure it out from here. Thank you for your help.
Support:
https://support.fantasygrounds.com/
-
June 14th, 2014, 08:25 #9
Saint
- Join Date
- Apr 2007
- Location
- Mississippi, USA
- Posts
- 1,093
One question though, what is "rActionClause.stat = {};" expecting to be filled with? is it a string like "abilities.constitution.bonus" or something else?
Support:
https://support.fantasygrounds.com/
-
June 14th, 2014, 08:32 #10
Saint
- Join Date
- Apr 2007
- Location
- Mississippi, USA
- Posts
- 1,093
Just a follow up, it works flawlessly now.
Support:
https://support.fantasygrounds.com/
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks