i'm trying to create a custom gambler perk deck, i want on ammo pickup to get health but not ammo. then with a new throwable you convert health into ammo. While the injector is active you get an increase on ammo pickup range (must stack with scavenger).
I now little about the code yet, but I thought to add a playeraction and register a function on Message.OnAmmoPickup I just dont know when to unregister the message, as it should be always running. Or do I add a PostHook to check_skills in PlayerManager and register/unregister the message there?
I saw this code in lib/units/pickups/ammoclip.lua AmmoClip:_pickup
for _, weapon in ipairs(available_selections) do
if not self._weapon_category or self._weapon_category == weapon.unit:base():weapon_tweak_data().categories[1] then
success, add_amount = weapon.unit:base():add_ammo(1, self._ammo_count)
I presume the if is to get if the weapon has pickup enabled? (i.e not rpg, etc) then ammo is increased with weapon.unit:base():add_ammo(1, self._ammo_count)
below in the file we see
if picked_up then
if not unit:character_damage():is_downed() and player_manager:has_category_upgrade("temporary", "loose_ammo_restore_health") and not player_manager:has_activate_temporary_upgrade("temporary", "loose_ammo_restore_health") then
player_manager:activate_temporary_upgrade("temporary", "loose_ammo_restore_health")
...
(bunch of code)
...
damage_ext:restore_health(restore_value, true)
Mentions of loose or temporary_loose are related to gambler, then line
damage_ext:restore_health(restore_value, true) restores health.
I would do on OnAmmoPickup function get local_player() from managers.player then character_damage() and do restore_health(). but how to remove ammo pickup? Or overwrite with a hook and set to 0.
Or should I just add a hook and rewrite _pickup function? then I can include an additional if to check for upgrade_value and see if the player is using my perk deck to not execute add_ammo() then i can add health on this file as well, but couldn't that break others mods?
Anyway for the ammo pickup range i have no ideia. I'm looking at mods that other players created and saw that injector stuff goes to projectilestweakdata in lib/tweak_data/blackmarket, where you register a new throwable.
thank you