Ammunition Manager v1.9 now automates
blind-fight's re-roll-on-miss function.
The special circumstance of blink is not included in the automation at this time.
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%]") 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