Saagael
February 7th, 2020, 01:15
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:
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 know that I'll likely need to create an OOB message to handle actually setting the duration element, but I'm unable to even get the effect into the onRoll callback. Setting rActor as the effect didn't work. I haven't looked super deeply but I'm guessing there's a bunch of code in CoreRPG that's translating it and somewhere the effect gets dropped because it's not a pc or ct type.
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?
Here's some of the related functions I'm working with:
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 know that I'll likely need to create an OOB message to handle actually setting the duration element, but I'm unable to even get the effect into the onRoll callback. Setting rActor as the effect didn't work. I haven't looked super deeply but I'm guessing there's a bunch of code in CoreRPG that's translating it and somewhere the effect gets dropped because it's not a pc or ct type.
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?