-
March 6th, 2021, 17:02 #1
Proposed improvement to variable numbers in effects
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].
Code:local sSign, sModifier, sShortAbility = sEffectAbility:match("^%[([%+%-]?)([H%d]?)([A-Z][A-Z][A-Z]?)%]$");
Code:local sSign, sModifier, sShortAbility = sEffectAbility:match("^%[([%+%-]?)([HTQ%d]?)([A-Z][A-Z][A-Z]?)%]$");
Code: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
Code: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:
Code:if rEffectComp.remainder[i]:match("^%[([%+%-]?)([H%d]?)([A-Z][A-Z][A-Z]?)%]$") then
Code:if rEffectComp.remainder[i]:match("^%[([%+%-]?)([HTQ%d]?)([A-Z][A-Z][A-Z]?)%]$") then
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).bmos' extensions
he/them
-
March 6th, 2021, 18:28 #2
Yeah, of course there is an okay from my side, too
My extensions for 3.5e and Pathfinder
Bug reports please here
-
March 6th, 2021, 23:44 #3
Wow!
These are the modules and extensions created and/or taken over by dellanx for PFRPG.
I had a lot of help and advice from many here at FG.
Thank You!
-
March 7th, 2021, 09:07 #4
- Join Date
- Mar 2016
- Location
- Bergen
- Posts
- 313
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 rightLast edited by Svandal; March 7th, 2021 at 09:52.
-
March 7th, 2021, 13:58 #5
- Join Date
- Mar 2016
- Location
- Bergen
- Posts
- 313
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
-
March 7th, 2021, 14:50 #6
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 stuffMy extensions for 3.5e and Pathfinder
Bug reports please here
-
March 7th, 2021, 15:01 #7
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:
Code:Power Attack (1-H); ATK: -1 [-QBAB] ,melee; DMG: 1 [QBAB] ,melee; DMG: 1 [QBAB] ,melee
Last edited by bmos; March 8th, 2021 at 12:19.
bmos' extensions
he/them
-
March 8th, 2021, 06:03 #8
- Join Date
- Mar 2016
- Location
- Bergen
- Posts
- 313
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.
-
March 8th, 2021, 20:15 #9bmos' extensions
he/them
-
March 8th, 2021, 21:07 #10
- Join Date
- Mar 2016
- Location
- Bergen
- Posts
- 313
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/...p/3.5E_Effects
And it says so in the code?
elseif sModifier then
nAbility = nAbility * (tonumber(sModifier) or 1);
end
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks