-
February 7th, 2020, 01:15 #1
Setting the Duration of an Effect with a Die Roll
I'm currently working on a custom ruleset and one thing I'd like to be able to do is have it so that when an effect is added to an actor on the CT, roll a die and have the duration of the effect set to the result of the die. I'm able to initiate the roll when the effect is added to the actor, but I'm having trouble getting the result to post back to the effect. Specifically, I am currently unable to get the effect's database node in the onRoll event of the dice action.
Here's some of the related functions I'm working with:
Code:function onEffectAddStart(rEffect) local sTimer = string.match(rEffect.sName, "TIMER:%s*(%S+)%s*"); if sTimer then ActionTimer.performRoll(nil, nil, sTimer, rEffect, false); end end function performRoll(draginfo, rActor, sDie, rEffect, bSecretRoll) local rRoll = {}; rRoll.sType = "timer"; rRoll.aDice = { }; rRoll.sDesc = "[TIMER]"; rRoll.bSecret = bSecretRoll; if rEffect then rRoll.rEffect = rEffect; end rRoll.aDice, rRoll.nMod = StringManager.convertStringToDice(sDie) ActionsManager.performAction(draginfo, rActor, rRoll); end function onRoll(rSource, rTarget, rRoll) Debug.chat(rRoll.rEffect); local rMessage = ActionsManager.createActionMessage(rSource, rRoll); rMessage.icon = "action_timer"; Comm.deliverChatMessage(rMessage); end
I'm hoping there's some way of doing this, possibly used in another ruleset or extension I've not looked at. Otherwise I think that means I'd have to reimplement ActionManager.performAction to work with this. Is there some other function that might do this?
-
February 7th, 2020, 01:44 #2
I do this in the AD&D 2e ruleset.
You can track what I do at getPowerRoll(rActor, nodeAction, sSubRoll). I also do it by level at getLevelBasedDurationValue(nodeAction). Both in scripts/manager_power.lua.
The bit of code is here in getPowerRoll()
Code:-- roll dice for duration if exists --celestian local nRollDuration = 0; local dDurationDice = DB.getValue(nodeAction, "durdice"); local nModDice = DB.getValue(nodeAction, "durmod", 0); local nDurationValue = PowerManager.getLevelBasedDurationValue(nodeAction); if (nDurationValue > 0) then nModDice = nModDice + nDurationValue; end if (dDurationDice and dDurationDice ~= "") then nRollDuration = StringManager.evalDice(dDurationDice, nModDice); else nRollDuration = nModDice; end
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
February 7th, 2020, 09:46 #3
How were you doing this? My experience is that the database node object can't be passed through the whole action process, which is asynchronous and uses OOB messaging. But you can add the database node name as a string and then use that to access the data later in the process.
Something like rRoll.sDBnode = dbnode.getNodeName()
https://www.fantasygrounds.com/refdo...cp#getNodeName
As an aside : I also seem to remember experiencing issues passing a LUA table (such as rActor) through OOB messaging, so I just keep the data in the OOB messaging table to simple strings and numbers.Last edited by Trenloe; February 7th, 2020 at 09:52.
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!
-
February 7th, 2020, 10:51 #4Private 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!
-
February 7th, 2020, 14:00 #5
Thanks! I did, and I managed to find the solution, which turned out to be waaaay easier than I expected. I didn't realize that just adding dice to the roll that's used as part of the base effect action would set the duration, but it does! Thanks for pointing me in the right direction.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks