Advertisement
darobrussa

Untitled

Nov 22nd, 2018
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.92 KB | None | 0 0
  1.  
  2. if RequiredScript == "lib/tweak_data/weapontweakdata" then
  3.  
  4.     Hooks:PostHook( WeaponTweakData, "init", "Tact_Reload", function(self) 
  5.         --tactical reloading shite
  6.         local tact_rel = {'deagle','colt_1911','usp','p226','g22c','glock_17','glock_18c','b92fs','ppk','mp9','new_mp5','mp7','p90','olympic','akmsu','akm','akm_gold','ak74','m16','amcar','new_m4','ak5','s552','g36','aug','saiga','new_m14','scar','fal','rpk','msr','r93','m95','famas','galil','g3','scorpion','benelli','serbu','r870','ksg','g26','spas12','l85a2','vhs','hs2000','tec9','sub2000','asval','wa2000','polymer','winchester1874','sparrow','model70','m37','china','sr2','pl14','tecci','hajk','boot','schakal','desertfox','packrat','arbiter','contraband','tti','coal','flint','siltstone','lemming','breech','basset','corgi','komodo','legacy','shepheard','shrew'}
  7.         for i, wep_id in ipairs(tact_rel) do
  8.             self[ wep_id ].tactical_reload = 1
  9.         end
  10.        
  11.         local tact_akimbo = {'x_deagle','x_1911','x_b92fs','jowi','x_usp','x_g17','x_g22c','x_sr2','x_mp5','x_akmsu','x_packrat','x_basset','x_breech','x_coal','x_hajk','x_hs2000','x_legacy','x_mp7','x_mp9','x_olympic','x_p226','x_p90','x_pl14','x_polymer','x_ppk','x_schakal','x_scorpion','x_shepheard','x_shrew','x_sparrow','x_tec9','x_usp'}
  12.         for i, wep_id in ipairs(tact_akimbo) do
  13.             self[ wep_id ].tactical_reload = 2
  14.         end
  15.     end)
  16.  
  17. elseif RequiredScript == "lib/units/weapons/newraycastweaponbase" then
  18.  
  19.     --These functions were made by Deadly Mutton Chops and B1313
  20.     --{
  21.     function NewRaycastWeaponBase:clip_full()
  22.         if self:ammo_base():weapon_tweak_data().tactical_reload then
  23.             return self:ammo_base():get_ammo_remaining_in_clip() == self:ammo_base():get_ammo_max_per_clip() + self:ammo_base():weapon_tweak_data().tactical_reload
  24.         else
  25.             return self:ammo_base():get_ammo_remaining_in_clip() == self:ammo_base():get_ammo_max_per_clip()
  26.         end
  27.     end
  28.            
  29.     function NewRaycastWeaponBase:on_reload()
  30.         local ammo_base = self._reload_ammo_base or self:ammo_base()
  31.         if ammo_base:weapon_tweak_data().uses_clip == true then
  32.             if ammo_base:get_ammo_remaining_in_clip() <= ammo_base:get_ammo_max_per_clip()  then
  33.                 ammo_base:set_ammo_remaining_in_clip(math.min(ammo_base:get_ammo_total(), ammo_base:get_ammo_max_per_clip(), ammo_base:get_ammo_remaining_in_clip() +  ammo_base:weapon_tweak_data().clip_capacity))
  34.             end
  35.         else
  36.             if ammo_base:get_ammo_remaining_in_clip() > 0 and  ammo_base:weapon_tweak_data().tactical_reload == 1 then
  37.                 ammo_base:set_ammo_remaining_in_clip(math.min(ammo_base:get_ammo_total(), ammo_base:get_ammo_max_per_clip() + 1))
  38.             elseif ammo_base:get_ammo_remaining_in_clip() > 1 and  ammo_base:weapon_tweak_data().tactical_reload == 2 then
  39.                 ammo_base:set_ammo_remaining_in_clip(math.min(ammo_base:get_ammo_total(), ammo_base:get_ammo_max_per_clip() + 2))
  40.             elseif ammo_base:get_ammo_remaining_in_clip() == 1 and  ammo_base:weapon_tweak_data().tactical_reload == 2 then
  41.                 ammo_base:set_ammo_remaining_in_clip(math.min(ammo_base:get_ammo_total(), ammo_base:get_ammo_max_per_clip() + 1))
  42.             elseif ammo_base:get_ammo_remaining_in_clip() > 0 and not  ammo_base:weapon_tweak_data().tactical_reload then
  43.                 ammo_base:set_ammo_remaining_in_clip(math.min(ammo_base:get_ammo_total(), ammo_base:get_ammo_max_per_clip()))
  44.             elseif self._setup.expend_ammo then
  45.                 ammo_base:set_ammo_remaining_in_clip(math.min(ammo_base:get_ammo_total(), ammo_base:get_ammo_max_per_clip()))
  46.             else
  47.                 ammo_base:set_ammo_remaining_in_clip(ammo_base:get_ammo_max_per_clip())
  48.                 ammo_base:set_ammo_total(ammo_base:get_ammo_max_per_clip())
  49.             end
  50.         end
  51.         managers.job:set_memory("kill_count_no_reload_" .. tostring(self._name_id), nil, true)
  52.         self._reload_ammo_base = nil
  53.     end
  54.    
  55.     function NewRaycastWeaponBase:reload_expire_t()
  56.         if self._use_shotgun_reload then
  57.             local ammo_remaining_in_clip = self:get_ammo_remaining_in_clip()
  58.             if self:get_ammo_remaining_in_clip() > 0 and  self:weapon_tweak_data().tactical_reload == 1 then
  59.                 return math.min(self:get_ammo_total() - ammo_remaining_in_clip, self:get_ammo_max_per_clip() + 1 - ammo_remaining_in_clip) * self:reload_shell_expire_t()
  60.             else
  61.                 return math.min(self:get_ammo_total() - ammo_remaining_in_clip, self:get_ammo_max_per_clip() - ammo_remaining_in_clip) * self:reload_shell_expire_t()
  62.             end
  63.         end
  64.         return nil
  65.     end
  66.    
  67.     function NewRaycastWeaponBase:update_reloading(t, dt, time_left)
  68.         if self._use_shotgun_reload and t > self._next_shell_reloded_t then
  69.             local speed_multiplier = self:reload_speed_multiplier()
  70.             self._next_shell_reloded_t = self._next_shell_reloded_t + self:reload_shell_expire_t() / speed_multiplier
  71.             if self:get_ammo_remaining_in_clip() > 0 and  self:weapon_tweak_data().tactical_reload == 1 then
  72.                 self:set_ammo_remaining_in_clip(math.min(self:get_ammo_max_per_clip() + 1, self:get_ammo_remaining_in_clip() + 1))
  73.                 return true
  74.             else
  75.                 self:set_ammo_remaining_in_clip(math.min(self:get_ammo_max_per_clip(), self:get_ammo_remaining_in_clip() + 1))
  76.                 return true
  77.             end
  78.             managers.job:set_memory("kill_count_no_reload_" .. tostring(self._name_id), nil, true)
  79.             return true
  80.         end
  81.     end
  82.     --}
  83.  
  84. elseif RequiredScript == "lib/units/weapons/shotgun/shotgunbase" then
  85.  
  86.     --These functions were made by Dumb Money Clocks and B1313
  87.     --{
  88.     function NewShotgunBase:reload_expire_t()
  89.         local ammo_remaining_in_clip = self:get_ammo_remaining_in_clip()
  90.         if self:get_ammo_remaining_in_clip() > 0 and  self:weapon_tweak_data().tactical_reload == 1 then
  91.             return math.min(self:get_ammo_total() - ammo_remaining_in_clip, self:get_ammo_max_per_clip() + 1 - ammo_remaining_in_clip) * self:reload_shell_expire_t()
  92.         else
  93.             return math.min(self:get_ammo_total() - ammo_remaining_in_clip, self:get_ammo_max_per_clip() - ammo_remaining_in_clip) * self:reload_shell_expire_t()
  94.         end
  95.     end
  96.    
  97.     function NewShotgunBase:reload_enter_expire_t()
  98.         return self:weapon_tweak_data().timers.shotgun_reload_enter or 0.3
  99.     end
  100.    
  101.     function NewShotgunBase:reload_exit_expire_t()
  102.         return self:weapon_tweak_data().timers.shotgun_reload_exit_empty or 0.7
  103.     end
  104.    
  105.     function NewShotgunBase:reload_not_empty_exit_expire_t()
  106.         return self:weapon_tweak_data().timers.shotgun_reload_exit_not_empty or 0.3
  107.     end
  108.    
  109.     function NewShotgunBase:reload_shell_expire_t()
  110.         return self:weapon_tweak_data().timers.shotgun_reload_shell or 0.56666666
  111.     end
  112.    
  113.     function NewShotgunBase:_first_shell_reload_expire_t()
  114.         return self:reload_shell_expire_t() - (self:weapon_tweak_data().timers.shotgun_reload_first_shell_offset or 0.33)
  115.     end
  116.    
  117.     function NewShotgunBase:start_reload(...)
  118.         NewShotgunBase.super.start_reload(self, ...)
  119.         self._started_reload_empty = self:clip_empty()
  120.         local speed_multiplier = self:reload_speed_multiplier()
  121.         self._next_shell_reloded_t = managers.player:player_timer():time() + self:_first_shell_reload_expire_t() / speed_multiplier
  122.     end
  123.    
  124.     function NewShotgunBase:started_reload_empty()
  125.         return self._started_reload_empty
  126.     end
  127.    
  128.     function NewShotgunBase:update_reloading(t, dt, time_left)
  129.         if t > self._next_shell_reloded_t then
  130.             local speed_multiplier = self:reload_speed_multiplier()
  131.             self._next_shell_reloded_t = self._next_shell_reloded_t + self:reload_shell_expire_t() / speed_multiplier
  132.             if self:get_ammo_remaining_in_clip() > 0 and  self:weapon_tweak_data().tactical_reload == 1 then
  133.                 self:set_ammo_remaining_in_clip(math.min(self:get_ammo_max_per_clip() + 1, self:get_ammo_remaining_in_clip() + 1))
  134.                 return true
  135.             else
  136.                 self:set_ammo_remaining_in_clip(math.min(self:get_ammo_max_per_clip(), self:get_ammo_remaining_in_clip() + 1))
  137.                 return true
  138.             end
  139.         end
  140.     end
  141.    
  142.     function SaigaShotgun:reload_expire_t()
  143.         return nil
  144.     end
  145.    
  146.     function SaigaShotgun:reload_enter_expire_t()
  147.         return nil
  148.     end
  149.    
  150.     function SaigaShotgun:reload_exit_expire_t()
  151.         return self:weapon_tweak_data().timers.reload_exit_empty or nil
  152.     end
  153.    
  154.     function SaigaShotgun:reload_not_empty_exit_expire_t()
  155.         return self:weapon_tweak_data().timers.reload_exit_not_empty or nil
  156.     end
  157.    
  158.     function SaigaShotgun:update_reloading(t, dt, time_left)
  159.     end
  160. --}
  161.    
  162. elseif RequiredScript == "lib/units/weapons/shotgun/newshotgunbase" then
  163.    
  164.     --These functions were made by Dumb Money Clocks and B1313
  165.     --{
  166.     function NewShotgunBase:reload_expire_t()
  167.         local ammo_remaining_in_clip = self:get_ammo_remaining_in_clip()
  168.         if self:get_ammo_remaining_in_clip() > 0 and  self:weapon_tweak_data().tactical_reload == 1 then
  169.             return math.min(self:get_ammo_total() - ammo_remaining_in_clip, self:get_ammo_max_per_clip() + 1 - ammo_remaining_in_clip) * self:reload_shell_expire_t()
  170.         else
  171.             return math.min(self:get_ammo_total() - ammo_remaining_in_clip, self:get_ammo_max_per_clip() - ammo_remaining_in_clip) * self:reload_shell_expire_t()
  172.         end
  173.     end
  174.    
  175.     function NewShotgunBase:reload_enter_expire_t()
  176.         return self:weapon_tweak_data().timers.shotgun_reload_enter or 0.3
  177.     end
  178.    
  179.     function NewShotgunBase:reload_exit_expire_t()
  180.         return self:weapon_tweak_data().timers.shotgun_reload_exit_empty or 0.7
  181.     end
  182.    
  183.     function NewShotgunBase:reload_not_empty_exit_expire_t()
  184.         return self:weapon_tweak_data().timers.shotgun_reload_exit_not_empty or 0.3
  185.     end
  186.    
  187.     function NewShotgunBase:reload_shell_expire_t()
  188.         return self:weapon_tweak_data().timers.shotgun_reload_shell or 0.56666666
  189.     end
  190.    
  191.     function NewShotgunBase:_first_shell_reload_expire_t()
  192.         return self:reload_shell_expire_t() - (self:weapon_tweak_data().timers.shotgun_reload_first_shell_offset or 0.33)
  193.     end
  194.    
  195.     function NewShotgunBase:start_reload(...)
  196.         NewShotgunBase.super.start_reload(self, ...)
  197.         self._started_reload_empty = self:clip_empty()
  198.         local speed_multiplier = self:reload_speed_multiplier()
  199.         self._next_shell_reloded_t = managers.player:player_timer():time() + self:_first_shell_reload_expire_t() / speed_multiplier
  200.     end
  201.    
  202.     function NewShotgunBase:started_reload_empty()
  203.         return self._started_reload_empty
  204.     end
  205.    
  206.     function NewShotgunBase:update_reloading(t, dt, time_left)
  207.         if t > self._next_shell_reloded_t then
  208.             local speed_multiplier = self:reload_speed_multiplier()
  209.             self._next_shell_reloded_t = self._next_shell_reloded_t + self:reload_shell_expire_t() / speed_multiplier
  210.             if self:get_ammo_remaining_in_clip() > 0 and  self:weapon_tweak_data().tactical_reload == 1 then
  211.                 self:set_ammo_remaining_in_clip(math.min(self:get_ammo_max_per_clip() + 1, self:get_ammo_remaining_in_clip() + 1))
  212.                 return true
  213.             else
  214.                 self:set_ammo_remaining_in_clip(math.min(self:get_ammo_max_per_clip(), self:get_ammo_remaining_in_clip() + 1))
  215.                 return true
  216.             end
  217.         end
  218.     end
  219.    
  220.     function SaigaShotgun:reload_expire_t()
  221.         return nil
  222.     end
  223.    
  224.     function SaigaShotgun:reload_enter_expire_t()
  225.         return nil
  226.     end
  227.    
  228.     function SaigaShotgun:reload_exit_expire_t()
  229.         return self:weapon_tweak_data().timers.reload_exit_empty or nil
  230.     end
  231.    
  232.     function SaigaShotgun:reload_not_empty_exit_expire_t()
  233.         return self:weapon_tweak_data().timers.reload_exit_not_empty or nil
  234.     end
  235.    
  236.     function SaigaShotgun:update_reloading(t, dt, time_left)
  237.     end
  238. --}
  239.    
  240. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement