PDA

View Full Version : Adding effects via code



Kelrugem
May 6th, 2019, 21:33
Hello :)

I need some help with adding effects via a code :) I have some prototype of an extension (I can somehow not add the link to it; it is in the 3.5e forum in the recent threads) which handles situation dependent saves. However, I found out that it only works for saves of NPCs but not for PCs. As far as I can see both are using the modSave function for effects in the manager_action_save.lua. My extension is based on adding an auxiliary effect to the person who has to roll the save using

local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
EffectManager.addEffect("", "", nodeActor, rEffectSpell, false);

(where rActor is the one making the save)

For NPCs that works, they get the effect rEffectSpell (in form of a string saved in rEffectSpell.sName). But for players this doesn't work. Does the addEffect works differently there? Or do I need a different command to get the node of a PC?

Thanks in advance :)

Kelrugem
May 6th, 2019, 22:36
Ok, it seemingly depends on the definition of rEffectSpell, isn't it? I just want to add some string to the effects of the actor. So far I have

rEffectSpell.nDuration = 1;
rEffectSpell.nInit = 0;
rEffectSpell.nGMOnly = 1;
rEffectSpell.sApply = "";

and .sName the corresponding string :)

Moon Wizard
May 6th, 2019, 22:44
I think that anyone will have a hard time figuring out the situation from the code snippets.

My recommendation is that you use Debug.chat or Debug.console APIs to inspect the parameter variables before you make calls, and inspect the result variables after you make calls. then, you’ll be able to review the variable values to see where the ariables qre different than what you expect.

Regards,
JPG

Kelrugem
May 6th, 2019, 22:46
I think that anyone will have a hard time figuring out the situation from the code snippets.

My recommendation is that you use Debug.chat or Debug.console APIs to inspect the parameter variables before you make calls, and inspect the result variables after you make calls. then, you’ll be able to review the variable values to see where the ariables qre different than what you expect.

Regards,
JPG

Thank you for your answer :) Yes, was not sure how to explain that without copying all of the code. I try what you mentioned :)

Kelrugem
May 6th, 2019, 23:09
Oh, wow, thank you very much for your advice! :) I was able to solve it :) The problem was that I get the charsheet-id with getNode, but I needed the CTnode and for that I have to use rather getCTNode :) Thanks :)