Thread: PFRPG Ammunition Manager
-
August 27th, 2021, 15:30 #111
-
August 27th, 2021, 16:37 #112
Thanks all the same, but nephranka already got me the info I needed.
Here is the fix:
open AutomaticFlankingAndRange.ext\campaign\scripts\cha r_weapon_afar.lua
replace everything from "function customOnAttackAction" to the end of the file with:
Code:function customOnAttackAction(draginfo) --Debug.chat("my customOnAttackAction"); local nodeWeapon = getDatabaseNode(); local nodeChar = nodeWeapon.getChild("...") -- Build basic attack action record local rAction = CharWeaponManager.buildAttackAction(nodeChar, nodeWeapon); -- bmos removing redundant ammo counting -- for compatibility with ammunition tracker, make this change in your char_weapon.lua -- this if section replaces the commented out line above: "CharWeaponManager.decrementAmmo(nodeChar, nodeWeapon);" if not AmmunitionManager then CharWeaponManager.decrementAmmo(nodeChar, nodeWeapon); end -- end bmos removing redundant ammo counting -- Perform action local rActor = ActorManager.resolveActor(nodeChar); -- ActionAttack.performRoll(draginfo, rActor, rAction); -- return true; -- kent adding itemPath to rActor so that when effects are checked we can -- make compare against action only effects local _, sRecord = DB.getValue(nodeWeapon, "shortcut", "", ""); rActor.itemPath = sRecord; -- end kent adding itemPath to rActor so that when effects are checked we can -- 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 sufficient end
bmos' extensions
he/them
-
August 27th, 2021, 16:50 #113
Thanks bmos!
This did totally fix that issue with range & flanking. Had a few more to resolve but it is all working now.
-
August 27th, 2021, 16:54 #114
Worked like a charm. A thousand thank yous good sir!
-
August 27th, 2021, 17:13 #115bmos' extensions
he/them
-
August 27th, 2021, 17:31 #116
Totally.
In this case your fixes caught most of the others accept for Advanced effects. Once I used your link to the suggested fix (early in the thread) I was able to fold it into the advanced effects ext while we are waiting for celestian to accept the code. He did respond that he is busy with work stuff, so it might be awhile. Either way, you code worked. So, if you have the most recent version of this ext, the fix for range & flanking, and the advance effects fix then that should cover most issues. I run like 99 exts so I have a good test bed ;P
-
September 3rd, 2021, 23:32 #117
Just trying out the extension and I really like the idea! One thing though, it seems like you use the onAttack function? My Nat20 extension does too, but if you don't call the normal onAttack action it bypasses all the Nat20 code. I could try a loadorder change to see if that helps, but your extension looks like it loads in the vault so I can't debug it.
Thanks!
-
September 4th, 2021, 00:53 #118
Glad you like it and thanks for letting me know about this issue.
Because of the "hit margin tracking" feature, I need access to some numbers only accessible from inside that function.
Check the first post. All of my code is freely available on GitHub for collaboration, modification, and debugging. If you look at my onAttack function, I have separated out some "compatibility blocks" that make adding support to other extensions easy. Just change this line in your onAttack function:
Code:Comm.deliverChatMessage(rMessage);
Code:-- bmos adding hit margin tracking -- for compatibility with ammunition tracker, add this here in your onAttack function if AmmunitionManager then local nHitMargin = AmmunitionManager.calculateMargin(nDefenseVal, rAction.nTotal) if nHitMargin then table.insert(rAction.aMessages, "[BY " .. nHitMargin .. "+]") end end -- end bmos adding hit margin tracking Comm.deliverChatMessage(rMessage); -- bmos adding automatic ammunition ticker and chat messaging -- for compatibility with ammunition tracker, add this here in your onAttack function if AmmunitionManager and ActorManager.isPC(rSource) then AmmunitionManager.ammoTracker(rSource, rRoll.sDesc, rAction.sResult, true) end -- end bmos adding automatic ammunition ticker and chat messaging
Last edited by bmos; September 4th, 2021 at 01:00.
bmos' extensions
he/them
-
September 4th, 2021, 04:16 #119
Thanks bmos...I'll look into that. I think the issue for me right off the bat is that I don't have a "copy" of the onAttack function in my extension, I simply set a local array tracker for a nat20, call the original onAttack, and then generate the message for display. Because of that, I don't have visibility to the rAction struct, and pasting your code into mine wouldn't work.
In my Nat20 extension, I replaced:
Code:ActionAttack.Nat20_Original_onAttack(rSource, rTarget, rRoll)
Code:if AmmunitionManager then AmmunitionManager.onAttack_5e(rSource, rTarget, rRoll) else ActionAttack.Nat20_Original_onAttack(rSource, rTarget, rRoll) end
I'll do some more testing and update Nat20 if everything goes well.
Thanks!
-
September 4th, 2021, 04:23 #120
Ooh...also, since I saw some "suggestions" ...
How hard would it be to automatically equip and unequip ammo when loaded or unloaded? It would play well with AutomaticEffects that way.
Thanks for the cool extension!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks