5E Product Walkthrough Playlist
Page 1 of 2 12 Last
  1. #1

    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?

  2. #2

    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");

  3. #3
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,406
    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!

  4. #4

    Join Date
    Apr 2007
    Location
    Mississippi, USA
    Posts
    1,093
    Quote Originally Posted by Trenloe View Post
    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.
    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.

  5. #5
    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
    Regards,
    JPG

  6. #6

    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);
    draginfo is a dragdata object and the throwdice function that I was using before creates one somehow without any drags on the screen. If there was some documentation about how the 4E rule set worked this would be vastly easier. Instead I'm having to track through miles of code from table to table to try to figure out how to do the simplest things.

  7. #7
    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

  8. #8

    Join Date
    Apr 2007
    Location
    Mississippi, USA
    Posts
    1,093
    Quote Originally Posted by Moon Wizard View Post
    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
    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.

  9. #9

    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?

  10. #10

    Join Date
    Apr 2007
    Location
    Mississippi, USA
    Posts
    1,093
    Just a follow up, it works flawlessly now.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in