Skip to content

Commit

Permalink
compatibility with Ammunition Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
bmos committed Aug 23, 2021
1 parent 3cb89cc commit 1f4dd3c
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions campaign/scripts/char_weapon_adnd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,35 @@ function onAttackAction(draginfo)
local rAction = CharWeaponManager.buildAttackAction(nodeChar, nodeWeapon);

-- Decrement ammo
CharWeaponManager.decrementAmmo(nodeChar, nodeWeapon);

-- bmos removing redundant ammo counting
-- for compatibility with ammunition tracker, make this change in your char_weapon.lua
if not AmmunitionManager then
CharWeaponManager.decrementAmmo(nodeChar, nodeWeapon);
end
-- end bmos removing redundant ammo counting

-- Perform action
local rActor = ActorManager.getActor("pc", nodeChar);

-- add itemPath to rActor so that when effects are checked we can
-- make compare against action only effects
local _, sRecord = DB.getValue(nodeWeapon, "shortcut", "", "");
-- make compare against action only effects
local _, sRecord = DB.getValue(nodeWeapon, "shortcut", "", "");
rActor.itemPath = sRecord;
-- end Adanced Effects Piece ---

ActionAttack.performRoll(draginfo, rActor, rAction);
return true;
end
-- bmos only allowing attacks when ammo is sufficient
-- for compatibility with ammunition tracker, make this change in your char_weapon.lua
-- this if section replaces the two commented out lines above:
-- "ActionAttack.performRoll(draginfo, rActor, rAction);" and "return true;"
local nMaxAmmo = DB.getValue(nodeWeapon, 'maxammo', 0)
local nMaxAttacks = nMaxAmmo - DB.getValue(nodeWeapon, 'ammo', 0)
if not AmmunitionManager or (not (nMaxAmmo > 0) or (nMaxAttacks >= 1)) then
ActionAttack.performRoll(draginfo, rActor, rAction);
return true;
else
ChatManager.Message(Interface.getString("char_message_atkwithnoammo"), true, rActor);
end
-- end bmos only allowing attacks when ammo is sufficientend

function onDamageChanged()
local nodeWeapon = getDatabaseNode();
Expand All @@ -108,8 +123,8 @@ function onDamageAction(draginfo)
local rActor = ActorManager.getActor("pc", nodeChar);

-- add itemPath to rActor so that when effects are checked we can
-- make compare against action only effects
local _, sRecord = DB.getValue(nodeWeapon, "shortcut", "", "");
-- make compare against action only effects
local _, sRecord = DB.getValue(nodeWeapon, "shortcut", "", "");
rActor.itemPath = sRecord;
-- end Adanced Effects Piece ---

Expand Down

0 comments on commit 1f4dd3c

Please sign in to comment.