Fantasy Grounds Fridays Pre
Page 1 of 2 12 Last
  1. #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]?)%]$");
    can be changed to
    Code:
    local sSign, sModifier, sShortAbility = sEffectAbility:match("^%[([%+%-]?)([HTQ%d]?)([A-Z][A-Z][A-Z]?)%]$");
    and

    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
    must be changed to
    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
    must be changed to
    Code:
    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).
    bmos' extensions
    he/him | Discord Tag: wil.thieme#3396

  2. #2
    Kelrugem's Avatar
    Join Date
    Sep 2018
    Location
    Geneva, Switzerland, and Lyon, France
    Posts
    3,120
    Yeah, of course there is an okay from my side, too

  3. #3

  4. #4
    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 ��
    Last edited by Svandal; March 7th, 2021 at 09:52.

  5. #5
    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

  6. #6
    Kelrugem's Avatar
    Join Date
    Sep 2018
    Location
    Geneva, Switzerland, and Lyon, France
    Posts
    3,120
    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

  7. #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
    (edited based on Svandal's advice about CMB)
    Last edited by bmos; March 8th, 2021 at 12:19.
    bmos' extensions
    he/him | Discord Tag: wil.thieme#3396

  8. #8
    Quote Originally Posted by bmos View Post
    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; 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.

  9. #9
    Quote Originally Posted by Svandal View Post
    I might only be thinking about Kels extension. Damage reduction and spell resistace. Spell resistance 5+lvl
    Can't you use
    "SR: 5 [LVL]"
    and
    "DR: 2 [HLVL]"
    ?
    bmos' extensions
    he/him | Discord Tag: wil.thieme#3396

  10. #10
    Quote Originally Posted by bmos View Post
    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/...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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Joshua Stream Pre

Log in

Log in