Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ************************************************************
- module stalker_injury
- Alundaio
- ************************************************************
- --]]
- local nade_disable_time = 20000
- local leg_cripple_time = 4000
- local vision_disable_time = 5000
- local aim_time_duration = 10000
- -- Amount of time you have to shoot both limbs to get effect
- local upperarm_combotime = 5000
- local hand_combotime = 5000
- local leg_combotime = 5000
- --[[
- Set version to get different effects for module
- 0 - Stalker's drop active item when shot in both left hand and right hand within a small window of time
- 1 - Stalker's aim time is increased for a short duration when shot in both left and right hands.
- --]]
- local version = 0
- class "stalker_injury"
- function stalker_injury:__init(obj,st)
- self.object = obj
- self.st = st
- self.timers = {}
- self.stage = nil
- self.injuries = {}
- self.hit = false
- end
- function stalker_injury:update()
- local m = alun_override_manager
- local stage = m.get_stage(self)
- local timer_signal = m.get_timer(self)
- if ( stage == 0 ) then
- if ( self.hit == false ) then
- return
- else
- self.hit = false
- end
- local tg = time_global()
- if ( self.injuries.head ~= nil ) then
- if ( tg > self.injuries.head ) then
- self.object:enable_vision(true)
- self.injuries.head = nil
- end
- end
- if ( self.injuries.l_upperarm ~= nil ) then
- if ( tg > self.injuries.l_upperarm ) then
- self.object:can_throw_grenades(true)
- self.injuries.l_upperarm = nil
- end
- end
- if ( self.injuries.r_upperarm ~= nil ) then
- if ( tg > self.injuries.r_upperarm ) then
- self.object:can_throw_grenades(true)
- self.injuries.r_upperarm = nil
- end
- end
- if ( self.injuries.l_hand ~= nil ) then
- if ( tg > self.injuries.l_hand ) then
- self.injuries.l_hand = nil
- if ( self.old_aim ~= nil ) then
- self.object:aim_time(active_item,self.old_aim)
- self.old_aim = nil
- end
- end
- end
- if ( self.injuries.r_hand ~= nil ) then
- if ( tg > self.injuries.r_hand ) then
- self.injuries.r_hand = nil
- if ( self.old_aim ~= nil ) then
- self.object:aim_time(active_item,self.old_aim)
- self.old_aim = nil
- end
- end
- end
- if ( self.injuries.l_leg ~= nil ) then
- if ( tg > self.injuries.l_leg ) then
- self.injuries.l_leg = nil
- self.object:movement_enabled(true)
- end
- end
- if ( self.injuries.r_leg ~= nil ) then
- if ( tg > self.injuries.r_leg ) then
- self.injuries.r_leg = nil
- self.object:movement_enabled(true)
- end
- end
- end
- end
- function hit_callback(st,obj,who,bone_index,amount,local_direction)
- if not ( st ) then
- return
- end
- local m = alun_override_manager
- local tg = time_global()
- if ( bone_index == "from_death_callback" ) then
- return
- end
- st.hit = true
- if ( bone_index == 15 or bone_index == 16 ) then
- if ( st.injuries.head ~= nil ) then
- return
- end
- st.injuries.head = tg + vision_disable_time
- st.object:enable_vision(false)
- m.debug_write("%s: I was hit in head! Fuck %s!",st.object:character_name(),who:character_name())
- return
- elseif ( bone_index == 21 ) then
- if ( st.injuries.l_upperarm ~= nil ) then
- return
- end
- st.injuries.l_upperarm = tg + upperarm_combotime
- if ( st.injuries.r_upperarm ~= nil ) then
- st.object:can_throw_grenades(false)
- st.injuries.l_upperarm = tg + nade_disable_time
- st.injuries.r_upperarm = tg + nade_disable_time
- m.debug_write("%s: Shit both my upper arms are injured! Damn %s to hell! Gah!",st.object:character_name(),who:character_name())
- end
- return
- elseif ( bone_index == 34 ) then
- if ( st.injuries.r_upperarm ~= nil ) then
- return
- end
- st.injuries.r_upperarm = tg + upperarm_combotime
- if ( st.injuries.l_upperarm ~= nil ) then
- st.object:can_throw_grenades(false)
- st.injuries.l_upperarm = tg + nade_disable_time
- st.injuries.r_upperarm = tg + nade_disable_time
- m.debug_write("%s: Shit both my upper arms are injured! Damn %s to hell! Gah!",st.object:character_name(),who:character_name())
- end
- return
- elseif ( bone_index == 36 ) then
- if ( st.injuries.r_hand ~= nil ) then
- return
- end
- st.injuries.r_hand = tg + hand_combotime
- local active_item = st.object:active_item()
- if ( active_item and active_item:clsid() == clsid.wpn_grenade_f1_s ) then
- st.object:drop_item(active_item)
- m.debug_write("%s: Aargh shot in the hand! I dropped my grenade! %s must die!",st.object:character_name(),who:character_name())
- return
- end
- if ( st.injuries.l_hand ~= nil ) then
- st.injuries.r_hand = tg + aim_time_duration
- st.injuries.l_hand = tg + aim_time_duration
- if ( active_item ) then
- if ( version == 0 ) then
- if ( active_item:clsid() ~= clsid.wpn_knife_s ) then
- st.object:drop_item(active_item)
- m.debug_write("%s: Gah %s I dropped my weapon!",st.object:character_name(),who:character_name())
- end
- elseif ( version == 1 ) then
- st.old_aim = st.object:aim_time(active_item)
- st.object:aim_time(active_item,st.old_aim * 2)
- m.debug_write("%s: Gah %s messed up my aiming!",st.object:character_name(),who:character_name())
- end
- end
- end
- return
- elseif ( bone_index == 22 or bone_index == 23 ) then
- if ( st.injuries.l_hand ~= nil ) then
- return
- end
- st.injuries.l_hand = tg + hand_combotime
- local active_item = st.object:active_item()
- if ( active_item and active_item:clsid() == clsid.wpn_grenade_f1_s ) then
- st.object:drop_item(active_item)
- m.debug_write("%s: Aargh shot in the hand! I dropped my grenade! %s must die!",st.object:character_name(),who:character_name())
- return
- end
- if ( st.injuries.r_hand ~= nil ) then
- st.injuries.r_hand = tg + aim_time_duration
- st.injuries.l_hand = tg + aim_time_duration
- if ( active_item ) then
- if ( version == 0 ) then
- if ( active_item:clsid() ~= clsid.wpn_knife_s ) then
- st.object:drop_item(active_item)
- m.debug_write("%s: Gah %s I dropped my weapon!",st.object:character_name(),who:character_name())
- end
- elseif ( version == 1 ) then
- st.old_aim = st.object:aim_time(active_item)
- st.object:aim_time(active_item,st.old_aim * 2)
- m.debug_write("%s: Gah %s messed up my aiming!",st.object:character_name(),who:character_name())
- end
- end
- end
- return
- elseif ( bone_index == 6 or bone_index == 7 or bone_index == 8 ) then
- if ( st.injuries.r_leg ~= nil ) then
- return
- end
- st.injuries.r_leg = tg + leg_combotime
- if ( st.injuries.l_leg ~= nil ) then
- st.injuries.l_leg = tg + leg_cripple_time
- st.injuries.r_leg = tg + leg_cripple_time
- m.debug_write("%s: ...%s shot me in my legs! I'm crippled!",st.object:character_name(),who:character_name())
- st.object:movement_enabled(false)
- end
- return
- elseif ( bone_index == 3 or bone_index == 4 or bone_index == 5) then
- if ( st.injuries.l_leg ~= nil ) then
- return
- end
- st.injuries.l_leg = tg + leg_combotime
- if ( st.injuries.r_leg ~= nil ) then
- st.injuries.l_leg = tg + leg_cripple_time
- st.injuries.r_leg = tg + leg_cripple_time
- m.debug_write("%s: ...%s shot me in my legs! I'm crippled!",st.object:character_name(),who:character_name())
- st.object:movement_enabled(false)
- end
- return
- end
- end
- function evaluate_preconditions(obj,st,axr)
- axr_precond.add_precondition("is_alive",true,true,obj)
- axr_precond.add_precondition("is_community",false,true,obj,"zombied")
- axr_precond.add_precondition("is_trader",false,true,obj)
- end
Add Comment
Please, Sign In to add comment