1 Year Ago
Refactor weapon_medkit (#1943) * Refactor weapon_medkit - Removed the ammo/idle timers and converted them to predicted netvars like weapon_fists - Divided up the Primary/SecondaryAttack functions into SWEP:CanHeal(entity), SWEP:DoHeal(entity), SWEP:HealEntity(entity), and SWEP:HealFail(entity) - Changed many constants to class variables to promote addon SWEP modification instead of copying and modifying the code - Heal success/failures now punishes both primary and secondary fire no matter which heal type it is to prevent being able to interrupt the medpack animation with the opposite heal type attack - Removed SWEP.MaxAmmo as SWEP.Primary.ClipSize was already serving its purpose - General optimisations/cleanup * Hanging space cleanup * GetHealth->Health * Remove default SWEP:Reload Doesn't cause issues currently, just doesn't need to call DefaultReload * Final cleanup - Changed Ammo to an empty string. "none" makes no difference - Only update the NextAmmoRegen netvar if ammo was given. Prevents regen from being on a constant cycle instead of action-based - Changed TakePrimaryAmmo to a plain SetClip1 to match what's done in SWEP:Think + skip some unnecessary logic * Small fixes - GetClip1->Clip1 - math.min(..., 0)->math.max(..., 0) when setting the clip - preventing it from being set negative instead of always being set to 0 - Healing sets the NextAmmoRegen to ensure regen always happens AmmoRegenFrequency seconds after the last heal * Use the local in CustomAmmoDisplay * deuglify trace code --------- Co-authored-by: Rubat <3299036+robotboy655@users.noreply.github.com>