Fantasy Grounds Fridays Pre
Page 18 of 18 First ... 8161718
  1. #171
    Quote Originally Posted by bmos View Post
    Ammunition Manager v1.9 now automates blind-fight's re-roll-on-miss function for players and NPCs.
    The special circumstance of blink is not included in the automation at this time.
    EDIT: this is not quite right by the rules. will continue working on it.

    Kelrugem, perhaps you can bring this into your extension?
    I add my special ability search function:
    Code:
    ---    This function checks NPCs and PCs for special abilities.
    local function hasSpecialAbility(rActor, sSearchString, bFeat, bTrait, bSpecialAbility, bEffect)
        if not rActor or not sSearchString then
            return false
        end
        local nodeActor = rActor.sCreatureNode;
    
        if bEffect and EffectManager35E.hasEffectCondition(rActor, sSearchString) then
            return true
        end
    
        local sSearchString = string.lower(sSearchString);
        local sSearchString = string.gsub(sSearchString, '%-', '%%%-');
        if ActorManager.isPC(nodeActor) then
            if bFeat then
                for _,vNode in pairs(DB.getChildren(nodeActor .. '.featlist')) do
                    local sFeatName = StringManager.trim(DB.getValue(vNode, 'name', ''):lower());
                    if sFeatName and string.match(sFeatName, sSearchString .. ' %d+', 1) or string.match(sFeatName, sSearchString, 1) then
                        return true
                    end
                end
            end
            if bTrait then
                for _,vNode in pairs(DB.getChildren(nodeActor .. '.traitlist')) do
                    local sTraitName = StringManager.trim(DB.getValue(vNode, 'name', ''):lower());
                    if sTraitName and string.match(sTraitName, sSearchString .. ' %d+', 1) or string.match(sTraitName, sSearchString, 1) then
                        return true
                    end
                end
            end
            if bSpecialAbility then
                for _,vNode in pairs(DB.getChildren(nodeActor .. '.specialabilitylist')) do
                    local sSpecialAbilityName = StringManager.trim(DB.getValue(vNode, 'name', ''):lower());
                    if sSpecialAbilityName and string.match(sSpecialAbilityName, sSearchString .. ' %d+', 1) or string.match(sSpecialAbilityName, sSearchString, 1) then
                        return true
                    end
                end
            end
        else
            local sSpecialQualities = string.lower(DB.getValue(nodeActor .. '.specialqualities', ''));
            local sSpecAtks = string.lower(DB.getValue(nodeActor .. '.specialattacks', ''));
            local sFeats = string.lower(DB.getValue(nodeActor .. '.feats', ''));
    
            if bFeat and string.find(sFeats, sSearchString) then
                return true
            elseif bSpecialAbility and (string.find(sSpecAtks, sSearchString) or string.find(sSpecialQualities, sSearchString)) then
                return true
            end
        end
        
        return false
    end
    and modify this part of onMissChance:
    Code:
        if nTotal <= nMissChance then
            rMessage.text = rMessage.text .. " [MISS]";
            removeVar = true;
            if rTarget then
                rMessage.icon = "roll_attack_miss";
                ActionAttack.clearCritState(rSource, rTarget);
                -- KEL Adding Save Overlay
                if rRoll.actionStuffForOverlay == "true" then
                    TokenManager2.setSaveOverlay(ActorManager.getCTNode(rTarget), -3);
                end
                -- END
            else
                rMessage.icon = "roll_attack";
            end
        else
    to be this:
    Code:
        if nTotal <= nMissChance and hasSpecialAbility(rSource, "Blind-Fight", true, false, false, true) then -- bmos adding blind-fight
            if string.match(rMessage.text, "%[BLIND%-FIGHT%]") or
                string.match(rMessage.text, "%[ATTACK.*%((%w+)%)%]") ~= 'M' or
                (EffectManager35E.hasEffect(rTarget, "Incorporeal") and not EffectManager35E.hasEffect(rSource, "Incorporeal")) then
                
                rMessage.text = rMessage.text .. " [MISS]";
                removeVar = true;
                if rTarget then
                    rMessage.icon = "roll_attack_miss";
                    ActionAttack.clearCritState(rSource, rTarget);
                    -- KEL Adding Save Overlay
                    if rRoll.actionStuffForOverlay == "true" then
                        TokenManager2.setSaveOverlay(ActorManager.getCTNode(rTarget), -3);
                    end
                    -- END
                else
                    rMessage.icon = "roll_attack";
                end
            else
                rMessage.text = rMessage.text .. " [MISS]";
                removeVar = true;
                if nMissChance > 0 then
                    local aMissChanceDice = { "d100" };
                    if not UtilityManager.isClientFGU() then
                        table.insert(aMissChanceDice, "d10");
                    end
                    local rMissChanceRoll = { sType = "misschance", sDesc = string.gsub(rMessage.text, " %[MISS%]", "") .. " [BLIND-FIGHT]", aDice = aMissChanceDice, nMod = 0, fullattack = rRoll.fullattack, actionStuffForOverlay = rRoll.actionStuffForOverlay };
                    ActionsManager.roll(rSource, rTarget, rMissChanceRoll);
                    -- KEL compatibility test with mirror image handler
                else
                    rMessage.icon = "roll_attack";
                end
            end -- end bmos adding blind-fight
        elseif nTotal <= nMissChance then
            rMessage.text = rMessage.text .. " [MISS]";
            removeVar = true;
            if rTarget then
                rMessage.icon = "roll_attack_miss";
                ActionAttack.clearCritState(rSource, rTarget);
                -- KEL Adding Save Overlay
                if rRoll.actionStuffForOverlay == "true" then
                    TokenManager2.setSaveOverlay(ActorManager.getCTNode(rTarget), -3);
                end
                -- END
            else
                rMessage.icon = "roll_attack";
            end
        else
    Hi

    Just wanted to finally add this Is this still the most recent way to add the code, or should I be aware of any changes? (but I will surely check the code, so, if I find any other better way, then I'll let you know )
    Last edited by Kelrugem; November 20th, 2021 at 23:31.

  2. #172
    bmos's Avatar
    Join Date
    Jun 2019
    Location
    Maine, USA
    Posts
    2,205
    Quote Originally Posted by Kelrugem View Post
    Hi

    Just wanted to finally add this Is this still the most recent way to add the code, or should I be aware of any changes? (but I will surely check the code, so, if I find any other better way, then I'll let you know )
    Yes, I added in 1.9 and removed in 1.10 (the feb ruleset update), so there wasn't ever any improvement to that code.
    You can see all the code changes that 1.9 had over 1.8 here: https://github.com/bmos/FG-Ammunitio...re/v1.8...v1.9
    Last edited by bmos; November 21st, 2021 at 14:45.
    bmos' extensions
    he/him | Discord Tag: wil.thieme#3396

  3. #173
    Quote Originally Posted by bmos View Post
    Yes, I added in 1.9 and removed in 1.10 (the feb ruleset update), so there wasn't ever any improvement to that code.
    You can see all the code changes that 1.9 had over 1.8 here: https://github.com/bmos/FG-Ammunitio...re/v1.8...v1.9
    Nice, thanks a lot

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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