
Now, T2 allows you to use ammo directly out of inventory if your quiver is empty, so the usual plan to avoid running out of ammo is simpy to carry several stacks. You can do that in T4 too, of course, but you have to spend a turn manually swapping in the new ammo when the old one runs out, and swapping them all back in one at a time to reload them can be a headache.
Well, my T2 module has an option to auto-wield ammo that you shoot from inventory, and with a bit of work, I figured I could get something like it to work here — hence my new Auto-Swap Ammo addon. Here's how it works:
- Tag your wielded ammo with "AMMO:SWAP:primary" (without the quotes). In your inventory, tag any ammo that you want to use with auto-swapping with "AMMO:SWAP" (again, without quotes).
- If you try to use an archery talent while your wielded ammo is empty, the game will pop up an inventory dialog listing your (non-empty) tagged ammos, to let you pick one to wield (or if there's only one, it'll just wield it directly). We hook in at the Archery:hasArcheryWeapon() level, which I think basically every archery-related talent calls at some point, so this should work for everything (he said, probably jynxing it…
).
- When you're done and want to rest to reload your ammo, we do the reverse: if your wielded ammo is full and any of your tagged ammo in inventory isn't, the game will swap one in for it to reload it (random, I think, except that the "primary" ammo gets priority).
- Finally, once all your tagged ammos are fully reloaded, if you aren't wielding the one tagged "primary", that one will get swapped back in.
[And I can see where some would consider this cheating, so it probably won't be a candidate for inclusion in ZOmnibus or ZOmnibus Lite.]
[Implementation notes:]
Code: Select all
Hooks:
ToME:load [to hang our callbacks on the Shoot talent]
Superload:
mod.class.interface.Archery:
hasArcheryWeapon() [to auto-swap ammo when using talents]