PDA

View Full Version : Proposed improvement to variable numbers in effects



bmos
March 6th, 2021, 17:02
In 3.5E ruleset's function evalAbilityHelper, there is a simple change that can be made to allow easier automation of effects.
Specifically, this also allows 1/3 or 1/4 instead of only 1/2 multipliers used for things like [CL] or [LVL].


local sSign, sModifier, sShortAbility = sEffectAbility:match("^%[([%+%-]?)([H%d]?)([A-Z][A-Z][A-Z]?)%]$");
can be changed to

local sSign, sModifier, sShortAbility = sEffectAbility:match("^%[([%+%-]?)([HTQ%d]?)([A-Z][A-Z][A-Z]?)%]$");

and


if nAbility then
if sSign == "-" then
nAbility = 0 - nAbility;
end
if sModifier == "H" then
if nAbility > 0 then
nAbility = math.floor(nAbility / 2);
else
nAbility = math.ceil(nAbility / 2);
end
elseif sModifier then
nAbility = nAbility * (tonumber(sModifier) or 1);
end
end

must be changed to

if nAbility then
if sSign == "-" then
nAbility = 0 - nAbility;
end
if sModifier == "H" then
if nAbility > 0 then
nAbility = math.floor(nAbility / 2);
else
nAbility = math.ceil(nAbility / 2);
end
elseif sModifier == "T" then
if nAbility > 0 then
nAbility = math.floor(nAbility / 3);
else
nAbility = math.ceil(nAbility / 3);
end
elseif sModifier == "Q" then
if nAbility > 0 then
nAbility = math.floor(nAbility / 4);
else
nAbility = math.ceil(nAbility / 4);
end
elseif sModifier then
nAbility = nAbility * (tonumber(sModifier) or 1);
end
end



also, in evalEffect there is a change:


if rEffectComp.remainder[i]:match("^%[([%+%-]?)([H%d]?)([A-Z][A-Z][A-Z]?)%]$") then
must be changed to

if rEffectComp.remainder[i]:match("^%[([%+%-]?)([HTQ%d]?)([A-Z][A-Z][A-Z]?)%]$") then

I wrote this modification personally and (with my permission) it has been used in Kelrugem's FullOverlayPackage.
I have never applied any specific license to this code, nor has Kel. If I understand recent discussion about some licenses making changes not eligible for use in core rulesets, this means this change should be usable by SmiteWorks with Kel and my express permission for FG to use this code however they like in perpetuity. I hereby grant an unlimited license in perpetuity for use of this change if SmiteWorks would like. I hope Kel will also confirm this (and that it makes this eligible).

Kelrugem
March 6th, 2021, 18:28
Yeah, of course there is an okay from my side, too :D

dellanx
March 6th, 2021, 23:44
Wow!

Svandal
March 7th, 2021, 09:07
Just a question. Cant you put in
if sSign == "/" then
nAbility = nAbility / (toNumber(sModifier) or 1)

With the math floor and math ceiling.

I have not coded anything in FG, so I am guessing at this point. And writing from a phone. But will not something like this work with all numbers?
And this looks like you could also include + and - ?
if sSign == "+" then
nAbility = nAbility + (toNumber(sModifier) or 1)


But it looks like it would be better will a full rewrite if we want all algebra expressions avalible

Edit: I think the above is to simplified, you probobly have to do some string manipulation. Maybe I should see if I the time to look into this in order to actually suggest something right ��

Svandal
March 7th, 2021, 13:58
Actually, why would not 0.5 work as sModifier here as divided by 2? If you do a math floor you would get a whole number?

elseif sModifier then
nAbility = nAbility * (tonumber(sModifier) or 1);
end

Kelrugem
March 7th, 2021, 14:50
You do not need a separate if-clause for the positive sign :) The positive sign won't change anything in the number, you only need to change the sign when there is a minus in front :) (so, the sign is about changing the global sign of the overall number; I think you misunderstood a bit that part)

And yes, instead of H, T and Q etc. one could maybe try to combine it with the multiplication of numbers already existing :) (though the T might get problematic as decimal, so, one may need to add support of "1/3" as multiplier in the effect string) However, then the code needs to be rewritten, 0.5 etc. are for example not supported as multipliers, only total numbers with one digit. The string pattern stuff of lua is messy, that is probably why FG uses H instead of 1/2 or 0.5. But I never really messed with that a lot, so, I am not experienced with that kind of lua stuff

bmos
March 7th, 2021, 15:01
I initially did try the approach of numbers rather than letters, but the HTQ approach is much better because existing effects will not have to be rewritten. Since I'm trying to get this incorporated into the ruleset, a slight modification that should not bring in any compatibility issues is far superior to a fairly big change like that.

SmiteWorks seems to consider the 3.5E ruleset 'done,' so small changes with big benefits should be a lot more appealing.

As far as I know, there is no need for multipliers, as you can just enter the same effect multiple times:

Power Attack (1-H); ATK: -1 [-QBAB] ,melee; DMG: 1 [QBAB] ,melee; DMG: 1 [QBAB] ,melee
(edited based on Svandal's advice about CMB)

Svandal
March 8th, 2021, 06:03
I initially did try the approach of numbers rather than letters, but the HTQ approach is much better because existing effects will not have to be rewritten. Since I'm trying to get this incorporated into the ruleset, a slight modification that should not bring in any compatibility issues is far superior to a fairly big change like that.

SmiteWorks seems to consider the 3.5E ruleset 'done,' so small changes with big benefits should be a lot more appealing.

As far as I know, there is no need for multipliers, as you can just enter the same effect multiple times:

Power Attack (1-H); ATK: -1 [-QBAB] ,melee; CMB: -1 [-QBAB] ,melee; DMG: 1 [QBAB] ,melee; DMG: 1 [QBAB] ,melee

Thanks for the explanation. Third and quarter effects would be really helpfull, and it would be great if it gets incorporated into fantasy grounds.

I might only be thinking about Kels extension. Damage reduction and spell resistace. Spell resistance 5+lvl
Or right combination with barbarians who get DR lvl/2 +2. I think DR if I remember correctly that DR stack in FG but not with Kels extension (cause it should not).
And I actually did not think about adding the same effect several times to add (or substract) them together😁.

By the way, ATK effects also affects CMB since CMB is an attack roll. So in your example cmb rolls will get -2 per 4 levels.

bmos
March 8th, 2021, 20:15
I might only be thinking about Kels extension. Damage reduction and spell resistace. Spell resistance 5+lvlCan't you use
"SR: 5 [LVL]"
and
"DR: 2 [HLVL]"
?

Svandal
March 8th, 2021, 21:07
Can't you use
"SR: 5 [LVL]"
and
"DR: 2 [HLVL]"
?

Because that is multiplying the numbers, while I want to add them together?
I have never tried, but I always assumed the number in front is a multiplier, since it says so in the wiki
https://www.fantasygrounds.com/wiki/index.php/3.5E_Effects
And it says so in the code?
elseif sModifier then
nAbility = nAbility * (tonumber(sModifier) or 1);
end

Svandal
March 8th, 2021, 21:15
Ok, I had to test it, and I am a bit speechless. When did they change the mathematical definition of multiplying to mean adding stuff together. I can brlive I never tried this.

Thanks bmos for showing me this ��

Kelrugem
March 8th, 2021, 21:54
Ok, I had to test it, and I am a bit speechless. When did they change the mathematical definition of multiplying to mean adding stuff together. I can brlive I never tried this.

Thanks bmos for showing me this 

That was always like this :D a modifier outside the brackets and separated by a space is added, a modifier in the square brackets is a multiplier :)

So: 2 [STR] = 2 + "STR-mod", and [2STR] = 2 * "STR-mod" :)

Kelrugem
March 9th, 2021, 22:51
Ui, your request got added, @bmos!

Thanks SmiteWorks :D

bmos
March 9th, 2021, 22:55
That's awesome!!
Thanks for letting me know :)

Moon Wizard
March 9th, 2021, 23:12
Yeah, the biggest issue was adding it to the half dozen other rulesets using similar code/logic. :)

JPG