Advertisement
Guest User

NPCWeaponBase.lua

a guest
Sep 15th, 2016
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1. --CloneClass(NPCRaycastWeaponBase)
  2. local init_original = NPCRaycastWeaponBase.init
  3. function NPCRaycastWeaponBase:init(unit)
  4.   init_original(self, unit)
  5.     if self._name_id then
  6.         log(self._name_id)
  7.     end
  8.     NPCWeap:setup_weapon(self._unit, self._name_id)
  9.     if NPCWeap.weapons[self._name_id] then
  10.         local truee = true
  11.         local falsee = false
  12.         local object = self._unit:get_object(Idstring("g_attachment_peqbox"))
  13.         if object then
  14.             if object:visibility() == true then
  15.             end
  16.         end
  17.     end
  18. end
  19.  
  20. function NPCRaycastWeaponBase:set_laser_enabled(state, npc_weapon_customize)
  21.     if state then
  22.         if alive(self._laser_unit) then
  23.             return
  24.         end
  25.         local spawn_rot = self._obj_fire:rotation()
  26.         local spawn_pos = self._obj_fire:position()
  27.         if not npc_weapon_customize then
  28.             spawn_pos = spawn_pos - spawn_rot:y() * 8 + spawn_rot:z() * 2 - spawn_rot:x() * 1.5
  29.         else
  30.             spawn_pos = spawn_pos - spawn_rot:y() * 8 + spawn_rot:z() * 2 - spawn_rot:x() * 1.5
  31.         end
  32.         self._laser_unit = World:spawn_unit(Idstring("units/payday2/weapons/wpn_npc_upg_fl_ass_smg_sho_peqbox/wpn_npc_upg_fl_ass_smg_sho_peqbox"), spawn_pos, spawn_rot)
  33.         self._unit:link(self._obj_fire:name(), self._laser_unit)
  34.         self._laser_unit:base():set_npc()
  35.         self._laser_unit:base():set_on()
  36.         self._laser_unit:base():set_color_by_theme("cop_sniper")
  37.         self._laser_unit:base():set_max_distace(10000)
  38.         if npc_weapon_customize then
  39.             self._laser_unit:get_object(Idstring("g_peqbox")):set_visibility(false)
  40.             self._laser_unit:get_object(Idstring("g_laser")):set_visibility(false)
  41.             self._laser_unit:get_object(Idstring("g_indicator")):set_visibility(false)
  42.             log("set_objects_invis")
  43.         end
  44.     elseif alive(self._laser_unit) then
  45.         self._laser_unit:set_slot(0)
  46.         self._laser_unit = nil
  47.     end
  48. end
  49.  
  50. function NPCRaycastWeaponBase:set_flashlight_enabled(enabled)
  51.     if not self._flashlight_data then
  52.         return
  53.     end
  54.     log("set_flashlight_enabled")
  55.     self._flashlight_data.enabled = enabled
  56.     if managers.game_play_central:flashlights_on() and enabled then
  57.         self._flashlight_data.light:set_enable(self._flashlight_light_lod_enabled)
  58.         self._flashlight_data.effect:activate()
  59.         self._flashlight_data.on = true
  60.     else
  61.         self._flashlight_data.light:set_enable(false)
  62.         self._flashlight_data.effect:kill_effect()
  63.         self._flashlight_data.on = false
  64.     end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement