Guest User

Untitled

a guest
Jul 19th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.50 KB | None | 0 0
  1. --[[
  2. ************************************************************
  3. module stalker_injury
  4. Alundaio
  5. ************************************************************
  6. --]]
  7. local nade_disable_time = 20000
  8. local leg_cripple_time = 4000
  9. local vision_disable_time = 5000
  10. local aim_time_duration = 10000
  11.  
  12. -- Amount of time you have to shoot both limbs to get effect
  13. local upperarm_combotime = 5000
  14. local hand_combotime = 5000
  15. local leg_combotime = 5000
  16.  
  17.  
  18. --[[
  19. Set version to get different effects for module
  20. 0 - Stalker's drop active item when shot in both left hand and right hand within a small window of time
  21. 1 - Stalker's aim time is increased for a short duration when shot in both left and right hands.
  22. --]]
  23. local version = 0
  24.  
  25. class "stalker_injury"
  26. function stalker_injury:__init(obj,st)
  27. self.object = obj
  28. self.st = st
  29. self.timers = {}
  30. self.stage = nil
  31. self.injuries = {}
  32. self.hit = false
  33. end
  34.  
  35. function stalker_injury:update()
  36. local m = alun_override_manager
  37. local stage = m.get_stage(self)
  38. local timer_signal = m.get_timer(self)
  39.  
  40. if ( stage == 0 ) then
  41. if ( self.hit == false ) then
  42. return
  43. else
  44. self.hit = false
  45. end
  46.  
  47. local tg = time_global()
  48.  
  49. if ( self.injuries.head ~= nil ) then
  50. if ( tg > self.injuries.head ) then
  51. self.object:enable_vision(true)
  52. self.injuries.head = nil
  53. end
  54. end
  55.  
  56. if ( self.injuries.l_upperarm ~= nil ) then
  57. if ( tg > self.injuries.l_upperarm ) then
  58. self.object:can_throw_grenades(true)
  59. self.injuries.l_upperarm = nil
  60. end
  61. end
  62.  
  63. if ( self.injuries.r_upperarm ~= nil ) then
  64. if ( tg > self.injuries.r_upperarm ) then
  65. self.object:can_throw_grenades(true)
  66. self.injuries.r_upperarm = nil
  67. end
  68. end
  69.  
  70. if ( self.injuries.l_hand ~= nil ) then
  71. if ( tg > self.injuries.l_hand ) then
  72. self.injuries.l_hand = nil
  73. if ( self.old_aim ~= nil ) then
  74. self.object:aim_time(active_item,self.old_aim)
  75. self.old_aim = nil
  76. end
  77. end
  78. end
  79.  
  80. if ( self.injuries.r_hand ~= nil ) then
  81. if ( tg > self.injuries.r_hand ) then
  82. self.injuries.r_hand = nil
  83. if ( self.old_aim ~= nil ) then
  84. self.object:aim_time(active_item,self.old_aim)
  85. self.old_aim = nil
  86. end
  87. end
  88. end
  89.  
  90. if ( self.injuries.l_leg ~= nil ) then
  91. if ( tg > self.injuries.l_leg ) then
  92. self.injuries.l_leg = nil
  93. self.object:movement_enabled(true)
  94. end
  95. end
  96.  
  97. if ( self.injuries.r_leg ~= nil ) then
  98. if ( tg > self.injuries.r_leg ) then
  99. self.injuries.r_leg = nil
  100. self.object:movement_enabled(true)
  101. end
  102. end
  103. end
  104. end
  105.  
  106. function hit_callback(st,obj,who,bone_index,amount,local_direction)
  107. if not ( st ) then
  108. return
  109. end
  110. local m = alun_override_manager
  111.  
  112. local tg = time_global()
  113.  
  114. if ( bone_index == "from_death_callback" ) then
  115. return
  116. end
  117.  
  118. st.hit = true
  119.  
  120. if ( bone_index == 15 or bone_index == 16 ) then
  121. if ( st.injuries.head ~= nil ) then
  122. return
  123. end
  124.  
  125. st.injuries.head = tg + vision_disable_time
  126. st.object:enable_vision(false)
  127. m.debug_write("%s: I was hit in head! Fuck %s!",st.object:character_name(),who:character_name())
  128. return
  129. elseif ( bone_index == 21 ) then
  130. if ( st.injuries.l_upperarm ~= nil ) then
  131. return
  132. end
  133.  
  134. st.injuries.l_upperarm = tg + upperarm_combotime
  135.  
  136. if ( st.injuries.r_upperarm ~= nil ) then
  137. st.object:can_throw_grenades(false)
  138. st.injuries.l_upperarm = tg + nade_disable_time
  139. st.injuries.r_upperarm = tg + nade_disable_time
  140. m.debug_write("%s: Shit both my upper arms are injured! Damn %s to hell! Gah!",st.object:character_name(),who:character_name())
  141. end
  142.  
  143. return
  144. elseif ( bone_index == 34 ) then
  145. if ( st.injuries.r_upperarm ~= nil ) then
  146. return
  147. end
  148.  
  149. st.injuries.r_upperarm = tg + upperarm_combotime
  150.  
  151. if ( st.injuries.l_upperarm ~= nil ) then
  152. st.object:can_throw_grenades(false)
  153. st.injuries.l_upperarm = tg + nade_disable_time
  154. st.injuries.r_upperarm = tg + nade_disable_time
  155. m.debug_write("%s: Shit both my upper arms are injured! Damn %s to hell! Gah!",st.object:character_name(),who:character_name())
  156. end
  157.  
  158. return
  159. elseif ( bone_index == 36 ) then
  160. if ( st.injuries.r_hand ~= nil ) then
  161. return
  162. end
  163.  
  164. st.injuries.r_hand = tg + hand_combotime
  165.  
  166. local active_item = st.object:active_item()
  167.  
  168. if ( active_item and active_item:clsid() == clsid.wpn_grenade_f1_s ) then
  169. st.object:drop_item(active_item)
  170. m.debug_write("%s: Aargh shot in the hand! I dropped my grenade! %s must die!",st.object:character_name(),who:character_name())
  171. return
  172. end
  173.  
  174. if ( st.injuries.l_hand ~= nil ) then
  175. st.injuries.r_hand = tg + aim_time_duration
  176. st.injuries.l_hand = tg + aim_time_duration
  177. if ( active_item ) then
  178. if ( version == 0 ) then
  179. if ( active_item:clsid() ~= clsid.wpn_knife_s ) then
  180. st.object:drop_item(active_item)
  181. m.debug_write("%s: Gah %s I dropped my weapon!",st.object:character_name(),who:character_name())
  182. end
  183. elseif ( version == 1 ) then
  184. st.old_aim = st.object:aim_time(active_item)
  185. st.object:aim_time(active_item,st.old_aim * 2)
  186. m.debug_write("%s: Gah %s messed up my aiming!",st.object:character_name(),who:character_name())
  187. end
  188. end
  189. end
  190.  
  191. return
  192. elseif ( bone_index == 22 or bone_index == 23 ) then
  193. if ( st.injuries.l_hand ~= nil ) then
  194. return
  195. end
  196.  
  197. st.injuries.l_hand = tg + hand_combotime
  198.  
  199. local active_item = st.object:active_item()
  200.  
  201. if ( active_item and active_item:clsid() == clsid.wpn_grenade_f1_s ) then
  202. st.object:drop_item(active_item)
  203. m.debug_write("%s: Aargh shot in the hand! I dropped my grenade! %s must die!",st.object:character_name(),who:character_name())
  204. return
  205. end
  206.  
  207. if ( st.injuries.r_hand ~= nil ) then
  208. st.injuries.r_hand = tg + aim_time_duration
  209. st.injuries.l_hand = tg + aim_time_duration
  210. if ( active_item ) then
  211. if ( version == 0 ) then
  212. if ( active_item:clsid() ~= clsid.wpn_knife_s ) then
  213. st.object:drop_item(active_item)
  214. m.debug_write("%s: Gah %s I dropped my weapon!",st.object:character_name(),who:character_name())
  215. end
  216. elseif ( version == 1 ) then
  217. st.old_aim = st.object:aim_time(active_item)
  218. st.object:aim_time(active_item,st.old_aim * 2)
  219. m.debug_write("%s: Gah %s messed up my aiming!",st.object:character_name(),who:character_name())
  220. end
  221. end
  222. end
  223.  
  224. return
  225. elseif ( bone_index == 6 or bone_index == 7 or bone_index == 8 ) then
  226. if ( st.injuries.r_leg ~= nil ) then
  227. return
  228. end
  229.  
  230. st.injuries.r_leg = tg + leg_combotime
  231.  
  232. if ( st.injuries.l_leg ~= nil ) then
  233. st.injuries.l_leg = tg + leg_cripple_time
  234. st.injuries.r_leg = tg + leg_cripple_time
  235. m.debug_write("%s: ...%s shot me in my legs! I'm crippled!",st.object:character_name(),who:character_name())
  236. st.object:movement_enabled(false)
  237. end
  238.  
  239. return
  240. elseif ( bone_index == 3 or bone_index == 4 or bone_index == 5) then
  241. if ( st.injuries.l_leg ~= nil ) then
  242. return
  243. end
  244.  
  245. st.injuries.l_leg = tg + leg_combotime
  246.  
  247. if ( st.injuries.r_leg ~= nil ) then
  248. st.injuries.l_leg = tg + leg_cripple_time
  249. st.injuries.r_leg = tg + leg_cripple_time
  250. m.debug_write("%s: ...%s shot me in my legs! I'm crippled!",st.object:character_name(),who:character_name())
  251. st.object:movement_enabled(false)
  252. end
  253. return
  254. end
  255. end
  256. function evaluate_preconditions(obj,st,axr)
  257. axr_precond.add_precondition("is_alive",true,true,obj)
  258. axr_precond.add_precondition("is_community",false,true,obj,"zombied")
  259. axr_precond.add_precondition("is_trader",false,true,obj)
  260. end
Add Comment
Please, Sign In to add comment