Advertisement
offyerrocker

sentryweapon.lua

Sep 8th, 2017
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 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')     -- Blue (Standard)
  4.  
  5. Hooks:PostHook(SentryGunWeapon, "init", "SentryGunWeapon_init", function(self, unit)
  6.     self._laser_align = self._laser_align or self._unit:get_object(Idstring("fire"))
  7. end)
  8.  
  9. Hooks:PostHook(SentryGunWeapon, "setup", "SentryGunWeapon_setup", function(self, setup_data, damage_multiplier)
  10.     if self._laser_unit and self._laser_align and self._unit:movement():team().id == "criminal1" then
  11.         self._laser_unit:base():set_color(color_standard)        -- Blue (Standard)
  12.     elseif not self._laser_unit then
  13. --      log("Sentry Lasers: No <self._laser_unit> found for setup!")
  14.         self._laser_align = self._laser_align or self._unit:get_object(Idstring("fire"))
  15.     end
  16. end)
  17.  
  18. Hooks:PostHook(SentryGunWeapon, "_set_fire_mode", "SentryGunWeapon__set_fire_mode", function(self, use_armor_piercing)
  19.     if self._laser_unit and self._laser_align then
  20.         if use_armor_piercing then
  21.             self._laser_unit:base():set_color(color_ap)          -- Green (AP)
  22.         else
  23.             self._laser_unit:base():set_color(color_standard)    -- Blue (Standard)
  24.         end
  25.     elseif not self._laser_unit then
  26. --      log("Sentry Lasers: No <self._laser_unit> found for setfiremode!")
  27.         self._laser_align = self._laser_align or self._unit:get_object(Idstring("fire"))       
  28.     end
  29. end)
  30.  
  31. Hooks:PostHook(SentryGunWeapon, "stop_autofire", "SentryGunWeapon_stop_autofire", function(self)
  32.     if self._laser_unit and self._laser_align and self:out_of_ammo() then
  33.         self._laser_unit:base():set_color(color_broken)          -- Red (No ammo)
  34.     elseif not self._laser_unit then
  35. --      log("Sentry Lasers: No <self._laser_unit> found for stopautofire!")
  36.         self._laser_align = self._laser_align or self._unit:get_object(Idstring("fire"))
  37.     end
  38. end)
  39. --from offy with love <3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement