Advertisement
offyerrocker

sentrygunweapon.lua

Aug 5th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1. local color_standard = Color('197FFF')   -- Blue (Standard)
  2. local color_ap = Color('19FF19')         -- Green (AP)
  3. local color_broken = Color('FF1919')     -- Red (Standard)
  4.  
  5. Hooks:PostHook(SentryGunWeapon, "init", "sentrylasers_init", function(self, unit)
  6. --  Log("FOUND INIT SENTRYGUNWEAPON",{color = Color.red})
  7.     self._laser_align = self._laser_align or self._unit:get_object(Idstring("fire"))
  8. end)
  9. Hooks:PostHook(SentryGunWeapon, "_init", "sentrylasers__init", function(self, unit)
  10. --  Log("FOUND _INIT SENTRYGUNWEAPON",{color = Color.blue})
  11.     self._laser_align = self._laser_align or self._unit:get_object(Idstring("fire"))
  12. end)
  13.  
  14. Hooks:PostHook(SentryGunWeapon, "setup", "sentrylasers_setup", function(self, setup_data, damage_multiplier)
  15.     if self._laser_unit and self._laser_align and self._unit:movement():team().id == "criminal1" then
  16.         self._laser_unit:base():set_color(color_standard)
  17.     elseif not self._laser_unit then
  18. --      Log("Sentry Lasers: No <self._laser_unit> found for setup!")
  19.         self._laser_align = self._laser_align or self._unit:get_object(Idstring("fire"))
  20.     end
  21. end)
  22.  
  23. Hooks:PostHook(SentryGunWeapon, "_set_fire_mode", "sentrylasers__set_fire_mode", function(self, use_armor_piercing)
  24.     if self._laser_unit and self._laser_align then
  25.         if use_armor_piercing then
  26.             self._laser_unit:base():set_color(color_ap)
  27.         else
  28.             self._laser_unit:base():set_color(color_standard)
  29.         end
  30.     elseif not self._laser_unit then
  31. --      Log("Sentry Lasers: No <self._laser_unit> found for setfiremode!")
  32.         self._laser_align = self._laser_align or self._unit:get_object(Idstring("fire"))      
  33.     end
  34. end)
  35.  
  36. Hooks:PostHook(SentryGunWeapon, "stop_autofire", "SentryGunWeapon_stop_autofire", function(self)
  37.     if self._laser_unit and self._laser_align and self:out_of_ammo() then
  38.         self._laser_unit:base():set_color(color_broken)          -- Red (No ammo)
  39.     elseif not self._laser_unit then
  40. --      Log("Sentry Lasers: No <self._laser_unit> found for stopautofire!")
  41.         self._laser_align = self._laser_align or self._unit:get_object(Idstring("fire"))
  42.     end
  43. end)
  44. --from offy with love <3
  45. --...again
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement