PDA

View Full Version : Effects affecting the character sheet



Kelrugem
December 4th, 2019, 01:14
Hi :)

I got very often the request for an effect changing the caster level in 3.5e/PF1 (in combination with my IFTAG operator to allow the change of the caster level just for specific spells, but that's less of a problem). But this would need a major rewrite of the code (I guess, but I may not see an easier solution (in sense of having an effect, inside the character sheet I may have an other idea)). I had the idea that such an effect could instead affect the CL number field in the character sheet forcing to update all the spell actions, then I would avoid a major rewrite of the existing code (I hope? :D). But for this one would need to add update handlers to look at the effects of the corresponding entry in the CT (if added to the CT). Since I saw several times on the forum that someone asked about effects changing the numbers also in the character sheet, I wondered if someone tried to code something like this? I am worrying about performance when this is possible and so I wanted to ask first whether this idea is good or not :)

Thanks in advance :)

Have a nice and pleasant week :)

Kelrugem

Trenloe
December 4th, 2019, 09:42
Effects inherently impact FG actions only. They don't change the base numbers in the character sheet - and this is by design.

Effect code triggers when an action occurs (or less commonly, an event - such as ongoing damage). Therefore, the ode that checks for effects is in the action handler LUA scripts - the scripts\manager_action_XXXX.lua files.

Like you say, trying to update directly in the character sheet can lead to issues - having event handlers, going against the usual effect process, overriding preset values, etc..

So, if you want to have an effect that modifies the CL, then my recommendation would be to add effect code to the relevant action/s that it would impact (there are many examples of effect code in the manager_action_... files).

Kelrugem
December 4th, 2019, 12:36
Effects inherently impact FG actions only. They don't change the base numbers in the character sheet - and this is by design.

Effect code triggers when an action occurs (or less commonly, an event - such as ongoing damage). Therefore, the ode that checks for effects is in the action handler LUA scripts - the scripts\manager_action_XXXX.lua files.

Like you say, trying to update directly in the character sheet can lead to issues - having event handlers, going against the usual effect process, overriding preset values, etc..

So, if you want to have an effect that modifies the CL, then my recommendation would be to add effect code to the relevant action/s that it would impact (there are many examples of effect code in the manager_action_... files).

thank you :) Yeah, that is what I suspected, thanks for confirmation :) I tried the way of having the effect in the relevant actions but that is not really possible for such an effect because the data about, how the CL influences the spell action (damage formulas and so on), are not saved in the actions themselves. They just get the result/outcome of the values depending on CL, so, it is like that the character sheet tells the spell actions which damage dice etc. one has but not how these were calculated (like I tell you my solution of some mathematical problem but not how I derived that). Therefore I would need to save all the formulas using CL in the action rolls, too, such that an effect could recalculate all the values depending on the CL :) That surely needs some work and therefore I was thinking about more elegant solutions and came up with the idea of changing the CL number field instead :) Sadly, this idea would surely be a dangerous one

celestian
December 4th, 2019, 15:14
Hi :)

I got very often the request for an effect changing the caster level in 3.5e/PF1 (in combination with my IFTAG operator to allow the change of the caster level just for specific spells, but that's less of a problem). But this would need a major rewrite of the code (I guess, but I may not see an easier solution (in sense of having an effect, inside the character sheet I may have an other idea)). I had the idea that such an effect could instead affect the CL number field in the character sheet forcing to update all the spell actions, then I would avoid a major rewrite of the existing code (I hope? :D). But for this one would need to add update handlers to look at the effects of the corresponding entry in the CT (if added to the CT). Since I saw several times on the forum that someone asked about effects changing the numbers also in the character sheet, I wondered if someone tried to code something like this? I am worrying about performance when this is possible and so I wanted to ask first whether this idea is good or not :)

Thanks in advance :)

Have a nice and pleasant week :)

Kelrugem

Actually, I did just this... well, tweaking the level to cast. It's a "ARCANE:X", "DIVINE:X" or "CLASSNAME:X" effect that is applied. Then in the spell damage/duration it calculates the damage/duration with those adjustments.

Honestly, it doesn't require much work to do (for the CoreRPG/5e style effects) and if the PF stuff works the same then it should be pretty easy.



-- get sSpellType "ARCANE: X" effect modifier
local aAddDice, nAddMod, nEffectCount = EffectManager5E.getEffectsBonus(rActor, {sSpellType:upper()}, false);
if nEffectCount > 0 then
local nAddTotal = StringManager.evalDice(aAddDice, nAddMod);
nCasterLevel = nCasterLevel + nAddTotal;
end

Kelrugem
December 4th, 2019, 15:21
Actually, I did just this... well, tweaking the level to cast. It's a "ARCANE:X", "DIVINE:X" or "CLASSNAME:X" effect that is applied. Then in the spell damage/duration it calculates the damage/duration with those adjustments.

Honestly, it doesn't require much work to do (for the CoreRPG/5e style effects) and if the PF stuff works the same then it should be the same.



-- get sSpellType "ARCANE: X" effect modifier
local aAddDice, nAddMod, nEffectCount = EffectManager5E.getEffectsBonus(rActor, {sSpellType:upper()}, false);
if nEffectCount > 0 then
local nAddTotal = StringManager.evalDice(aAddDice, nAddMod);
nCasterLevel = nCasterLevel + nAddTotal;
end


Yes, but I may have to look again at the code (at the moment I was just brainstorming) :) In 3.5e/PF1 you have CL dependencies like "every third CL", "every odd/even CL" and so on for damage/heal dice, duration, save DC and so on (and sometimes there is also a cap for the allowed CL for the specific damage/duration etc.), at least these informations I have to save in the action, too, such that the CL adjustment coming from an effect is correctly accounted :) These informations are "saved in the character sheet" but in the codes of the actions themselves one only get the "results from the character sheet" about the duration etc.

Thanks a lot :) It may be indeed less cumbersome than I imagine at the moment :)

celestian
December 4th, 2019, 15:28
Yes, but I may have to look again at the code (at the moment I was just brainstorming) :) In 3.5e/PF1 you have CL dependencies like "every third CL", "every odd/even CL" and so on for damage/heal dice, duration, save DC and so on (and sometimes there is also a cap for the allowed CL for the specific damage/duration etc.), at least these informations I have to save in the action, too, such that the CL adjustment coming from an effect is correctly accounted :)

Thanks a lot :) It may be indeed less cumbersome than I imagine at the moment :)

You mean something like this? (this guy is a level 1 caster with fireball, yeah, just an example, normally he'd not get it till 5th and it would be 5d6 minimum)

https://i.imgur.com/g1OXgmZ.png

To be fair, since I already had caster level damage and duration (I've the same thing in duration) the effect level modification was easier. If PF doesn't already have that then you'd need to add that as well.

Kelrugem
December 4th, 2019, 15:39
You mean something like this? (this guy is a level 1 caster with fireball, yeah, just an example, normally he'd not get it till 5th and it would be 5d6 minimum)

https://i.imgur.com/g1OXgmZ.png

To be fair, since I already had caster level damage and duration (I've the same thing in duration) the effect level modification was easier. If PF doesn't already have that then you'd need to add that as well.

hm, okay, this looks very similar to 3.5/PF1 :) So, I now have to revisit the code, hopefully I just misunderstood something and, at the end, everything is much easier than I thought. Thanks a lot, I appreciate it :)

celestian
December 4th, 2019, 16:53
hm, okay, this looks very similar to 3.5/PF1 :) So, I now have to revisit the code, hopefully I just misunderstood something and, at the end, everything is much easier than I thought. Thanks a lot, I appreciate it :)

I thought PF had it... it's actually where I got the idea on how/where to add it in the menu system. 5E doesn't.

Look where you use the "level" for "caster level" and replace that with a variable/function where you calculate the caster's level for all adjustments.

Kelrugem
December 4th, 2019, 16:55
I thought PF had it... it's actually where I got the idea on how/where to add it in the menu system. 5E doesn't.

Look where you use the "level" for "caster level" and replace that with a variable/function where you calculate the caster's level for all adjustments.

thanks, I'll try that :)

Kelrugem
December 4th, 2019, 17:21
oki, tried it; in manager_spell.lua is the CL often used for defining damage dice etc.. What I thought is: When I click the damage button then the code will not run through manager_spell again to parse the damage dice, but actually this is what happens and therefore my effect worked :D Thanks for that, I always thought that the code for the spell parsing/definitions is not ran again when pressing the spell buttons and therefore I didn't see how one can affect the code with such an effect :D So, my problem was due to a wrong assumption on my side :)

The only (very little) problem is the spell displays in the action tab then, the effect is not affecting them of course, but when I force an update of the spell actions (by changing the CL in the sheet or adding/changing existing damage buttons or whatever) then the displays take the effects into account which could lead to confusion in certain situations :) (though I now accidentally coded some sort of effect which affects the sheet without any other problems so far... :D)

Is just a display problem, so not really important because the automation of damage etc. is not affected, but I want to fix this :)

Thanks a lot :D I should simply test a bit more and not make wrong assumptions ;)

EDIT: oh, and testing very high numbers of CL results into an error when there are then more physical dice than FGC can show (seems to be a problem with FG itself, not with the extension) :D

celestian
December 4th, 2019, 19:30
Is just a display problem, so not really important because the automation of damage etc. is not affected, but I want to fix this :)

Thanks a lot :D I should simply test a bit more and not make wrong assumptions ;)


Had a similar issue and to resolve you also need to monitor the effects.

DB.addHandler(DB.getPath(nodeCT, "effects"), "onChildUpdate", onDataChanged);

I did the same for damage pre-views as well.

Kelrugem
December 4th, 2019, 19:37
Had a similar issue and to resolve you also need to monitor the effects.

DB.addHandler(DB.getPath(nodeCT, "effects"), "onChildUpdate", onDataChanged);

I did the same for damage pre-views as well.

ah, okay, and this works well for you? My formulation of the first post was maybe not good enough but exactly this was my idea, too, but I was worrying about whether this is a good idea (because effects are normally not observed by these displays) due to performance things etc. :) (also because of Trenloe's answer but maybe he thought that I want to add these handlers now to all other fields in the character sheet, too, which may be affected by effects. But I only want to add such a thing for the CL stuff :) )

thanks, this maybe means that my initial idea is not that bad at all when there is already a ruleset doing exactly that :)

celestian
December 4th, 2019, 19:47
ah, okay, and this works well for you? My formulation of the first post was maybe not good enough but exactly this was my idea, too, but I was worrying about whether this is a good idea (because effects are normally not observed by these displays) due to performance things etc. :) (also because of Trenloe's answer but maybe he thought that I want to add these handlers now to all other fields in the character sheet, too, which may be affected by effects. But I only want to add such a thing for the CL stuff :) )

thanks, this maybe means that my initial idea is not that bad at all when there is already a ruleset doing exactly that :)

Keep in mind that's more for CT for me than players. That won't update reliably for them. I treat it kinda like the ATK:1 effect for Player Side, that effect doesn't show up on the "preview" bonus to hit but shows up in the [EFFECT: X] on the roll output.

But, both definitely will get the adjusted levels when they roll.

Kelrugem
December 4th, 2019, 19:52
Keep in mind that's more for CT for me than players. That won't update reliably for them. I treat it kinda like the ATK:1 effect for Player Side, that effect doesn't show up on the "preview" bonus to hit but shows up in the [EFFECT: X] on the roll output.

But, both definitely will get the adjusted levels when they roll.

Ah, okay, I guess I understand you :)

Thanks a lot for your help, Celestian and Trenloe, really appreciated :) Now I will play around a bit and I am optimistic that it is possible now without too much to do :)

Trenloe
December 4th, 2019, 19:59
The thing to keep in mind with using effects to modify a character sheet directly is that you will never be able to ensure that the data in the PC sheet is 100% accurate - I don't know if the DB event handler celestian posted above would trigger if the PC was removed from the CT (even accidentally) - leaving a modified character sheet. And if a PC record was exported (or accessed via manage characters) it would contain the modified data, but not the effect that modified it. Maybe edge cases, but something to consider as any opportunity for incorrect data should be avoided if possible.

Kelrugem
December 4th, 2019, 20:04
The thing to keep in mind with using effects to modify a character sheet directly is that you will never be able to ensure that the data in the PC sheet is 100% accurate - I don't know if the DB event handler celestian posted above would trigger if the PC was removed from the CT (even accidentally) - leaving a modified character sheet. And if a PC record was exported (or accessed via manage characters) it would contain the modified data, but not the effect that modified it. Maybe edge cases, but something to consider as any opportunity for incorrect data should be avoided if possible.

ah, that's a good point; indeed, that can be problematic. When I have time to look a bit more onto that then I will also test these edge cases a bit more and try to see whether there is some solution avoiding these :)

Thanks, I got a lot of nice ideas and approaches today :)

celestian
December 4th, 2019, 20:18
The thing to keep in mind with using effects to modify a character sheet directly is that you will never be able to ensure that the data in the PC sheet is 100% accurate - I don't know if the DB event handler celestian posted above would trigger if the PC was removed from the CT (even accidentally) - leaving a modified character sheet. And if a PC record was exported (or accessed via manage characters) it would contain the modified data, but not the effect that modified it. Maybe edge cases, but something to consider as any opportunity for incorrect data should be avoided if possible.

If the effect is there and then the pc is removed from the CT the update would be lost, that's the inconsistency I meant. I also do something similar for ability adjustments (so you can see them on the character sheet).

You could trigger handlers if the CT has an entry removed.

To do it like e 5e does you'd just not update the preview damage based on effects but utilize the effect if it existed when rolled.

Trenloe
December 4th, 2019, 20:22
To do it like e 5e does you'd just not update the preview damage based on effects but utilize the effect if it existed when rolled.
That's really the recommended way to do it. Standard FG rulesets don't modify any data on the PC sheet directly via effects, only when a relevant action or event occurs.

celestian
December 4th, 2019, 21:54
You could trigger handlers if the CT has an entry removed.


As a follow up, I fiddled with this during lunch and it worked. It gave me consistent results.

Thanks for pushing this topic around, it got me thinking how to resolve it ;)

Kelrugem
December 4th, 2019, 22:00
As a follow up, I fiddled with this during lunch and it worked. It gave me consistent results.

Thanks for pushing this topic around, it got me thinking how to resolve it ;)

cool :D

Then I'll probably try the same and test that a bit, too, when I got more time :D thanks for the follow-up :)