Thread: Performance of effects
-
September 16th, 2019, 03:15 #1
Performance of effects
Hi
I plan to extend the usage of the operator IF (and IFT) in one of my extensions by implementing some sort of inverted IF. Thence I want to improve the performance of such things like IF because users of that extension are more likely to use it then. I am looking into manager_effect_35E.lua (so it is also about 3.5e) and see the following function for testing whether some conditions for IF are met: (if you need further information then please ask; but it might be good if you know a bit that file)
Code:function checkConditionalHelper(rActor, sEffect, rTarget, aIgnore) if not rActor then return false; end local bReturn = false; for _,v in pairs(DB.getChildren(ActorManager.getCTNode(rActor), "effects")) do local nActive = DB.getValue(v, "isactive", 0); if nActive ~= 0 and not StringManager.contains(aIgnore, v.getNodeName()) then -- Parse each effect label local sLabel = DB.getValue(v, "label", ""); local bTargeted = EffectManager.isTargetedEffect(v); local aEffectComps = EffectManager.parseEffect(sLabel); -- Iterate through each effect component looking for a type match local nMatch = 0; for kEffectComp, sEffectComp in ipairs(aEffectComps) do local rEffectComp = parseEffectComp(sEffectComp); --Check conditionals if rEffectComp.type == "IF" then if not checkConditional(rActor, v, rEffectComp.remainder, nil, aIgnore) then break; end elseif rEffectComp.type == "IFT" then if not rTarget then break; end if not checkConditional(rTarget, v, rEffectComp.remainder, rActor, aIgnore) then break; end -- Check for match elseif rEffectComp.original:lower() == sEffect then if bTargeted then if EffectManager.isEffectTarget(v, rTarget) then bReturn = true; end else bReturn = true; end end end end end return bReturn; end
Code:function checkConditionalHelper(rActor, sEffect, rTarget, aIgnore) if not rActor then return false; end for _,v in pairs(DB.getChildren(ActorManager.getCTNode(rActor), "effects")) do local nActive = DB.getValue(v, "isactive", 0); if nActive ~= 0 and not StringManager.contains(aIgnore, v.getNodeName()) then -- Parse each effect label local sLabel = DB.getValue(v, "label", ""); local bTargeted = EffectManager.isTargetedEffect(v); local aEffectComps = EffectManager.parseEffect(sLabel); -- Iterate through each effect component looking for a type match local nMatch = 0; for kEffectComp, sEffectComp in ipairs(aEffectComps) do local rEffectComp = parseEffectComp(sEffectComp); --Check conditionals if rEffectComp.type == "IF" then if not checkConditional(rActor, v, rEffectComp.remainder, nil, aIgnore) then break; end elseif rEffectComp.type == "IFT" then if not rTarget then break; end if not checkConditional(rTarget, v, rEffectComp.remainder, rActor, aIgnore) then break; end -- Check for match elseif rEffectComp.original:lower() == sEffect then if bTargeted then if EffectManager.isEffectTarget(v, rTarget) then return true; end else return true; end end end end end return false; end
Am I right? Or do I miss something really crucial? I did not upload this yet because it is about effects and I am afraid of breaking the effect structure of the users of that extension
Thanks in advance
Kelrugem
PS: A similar argument for the function checkConditional, but I think that there it is less of a problemMy extensions for 3.5e and Pathfinder
Bug reports please here
-
September 16th, 2019, 19:08 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,558
Looks like there is some cleanup that could happen in those functions. These functions have evolved over time. I'll try pushing some updates to Test channel pretty soon to try some changes.
Regards,
JPG
-
September 16th, 2019, 19:10 #3My extensions for 3.5e and Pathfinder
Bug reports please here
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks