STAR TREK 2d20
Page 18 of 53 First ... 8161718192028 ... Last
  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 22:31.

  2. #172
    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 13:45.

  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

  4. #174
    Quote Originally Posted by bmos View Post
    Code:
            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
    By the way, the CharManager contains functons hasFeat and hasTrait for PCs, they look similar what you do in that case but are a bit different. Where there some specific concerns you had in the string checks you wanted to get resolved which is why there are some differences? Seemingly something about hyphens? But what does the %d+ do in the string match? (probably allowing numbers which are ignored then for the check?) (and the ,1? )

    My knowledge about string comparisons is basically zero and I find the documentation about it often utterly confusing which is why I usually avoid any string comparisons (if you have any good documentation about string stuff in Lua I would be happy )

    I will handle the remaining code different. I want to automate the blind fight differently. The blind fight will be checked before the defense values are checked such that I can counter bonuses coming from invisibility (melee), and attackers with that ability simply gain advantage on their miss chance roll, using my base code of that (as you may have seen I already added effects for advantage on attacks and so on) I want to add ethereal as counter effect to blind-fight in order to support stuff like blink and ethereal creatures in general
    Last edited by Kelrugem; November 28th, 2021 at 13:00.

  5. #175
    Quote Originally Posted by Kelrugem View Post
    By the way, the CharManager contains functons hasFeat and hasTrait for PCs, they look similar what you do in that case but are a bit different. Where there some specific concerns you had in the string checks you wanted to get resolved which is why there are some differences? Seemingly something about hyphens? But what does the %d+ do in the string match? (and the ,1? )

    My knowledge about string comparisons is basically zero and I find the documentation about it often utterly confusing which is why I usually avoid any string comparisons (if you have any good documentation about string stuff in Lua I would be happy )

    I will handle the remaining code different. I want to automate the blind fight differently. The blind fight will be checked before the defense values are checked such that I can counter bonuses coming from invisibility (melee), and attackers with that ability simply gain advantage on their miss chance roll, using my base code of that (as you may have seen I already added effects for advantage on attacks and so on) I want to add ethereal as counter effect to blind-fight in order to support stuff like blink and ethereal creatures in general
    Yeah, lua's pattern recognition was hard to learn but is pretty powerful.
    This is my go-to reference link for string.match, although there are still a few things it doesn't explain well.
    This is my go to for string.find.
    Happy to help if you have questions.

    If I remember correctly, I wrote my own function for that because I wanted it to handle PC special abilities and NPCs as well. I think the 3.5E CharManager functions just work for PCs.
    If I was writing that again, I'd do it differently.

    Those sound like great improvements.
    Last edited by bmos; November 28th, 2021 at 13:09.

  6. #176
    Quote Originally Posted by bmos View Post
    Yeah, lua's pattern recognition was hard to learn but is pretty powerful: https://riptutorial.com/lua/example/...ttern-matching
    Happy to help if you have questions.
    If I remember correctly, I wrote my own because I wanted it to handle PC special abilities and NPCs as well.
    Thanks for the link

    Yeah, the NPC stuff I have seen It was just about the part with PCs because I was thinking about to replace these specific if-clauses for PCs with the existing functions (although they are rarely used in the code, besides two weapon fighting, slow and steady, multitalented and skilled no other feat or trait is automated. Hence, I doubt that these functions will get updated in the future. But if they get updated, your function could profit from such an update if using these instead)

  7. #177
    Quote Originally Posted by Kelrugem View Post
    Thanks for the link

    Yeah, the NPC stuff I have seen It was just about the part with PCs because I was thinking about to replace these specific if-clauses for PCs with the existing functions (although they are rarely used in the code, besides two weapon fighting, slow and steady, multitalented and skilled no other feat or trait is automated. Hence, I doubt that these functions will get updated in the future. But if they get updated, your function could profit from such an update if using these instead)
    There are other things going on in that function too though that I forget haha

    At the very least, it ignores numbers at the end of a feat/trait name like "armor expert 1" and "Armor Expert 2".
    It also looks at Effects in case things are added temporarily.

    And ",1" just means it's starting at the first character of the string it's searching.
    Last edited by bmos; November 28th, 2021 at 13:11.

  8. #178
    Quote Originally Posted by bmos View Post
    There are other things going on in that function too though that I forget haha
    aaah, I see, thanks

  9. #179
    Bmos, thank you for listening to my (and others) feedback and removing the RELD from weapons that don't use ammunition.

    It was a small thing, but it was annoying.

    Absolutely fantastic extension.
    Last edited by BushViper; December 5th, 2021 at 23:33.

  10. #180
    Quote Originally Posted by BushViper View Post
    Bmos, thank you for listening to my (and others) feedback and removing the RELD from weapons that don't use ammunition.
    You're very welcome. Thank you for the feedback
    I don't use FantasyGrounds right now, so I'm mostly relying on users to suggest improvements!

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in