Advertisement
Daemonion

hallp

May 21st, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. -- used for LURK 1.2
  2. -- Checks on item condition
  3. -- When condition changes (ie, when fired), a script can be injected
  4. -- In this case, we use it to play audio
  5.  
  6. local activeItem = nil --last recorded active item
  7. local oldCondition = 0 --condition of activeItem
  8.  
  9. -- TODO(AndrewD) These are for playing around... hard coded.
  10. local random_sub                        = 1
  11. local random_reflection                 = 1
  12. local hc_reflection_outdoors_left       = xr_sound.get_safe_sound_object("daemonion\\weapons\\reflection_outdoors_" ..random_reflection.. "_l")
  13. local hc_reflection_outdoors_right      = xr_sound.get_safe_sound_object("daemonion\\weapons\\reflection_outdoors_" ..random_reflection.. "_r")
  14. local hc_sub                            = xr_sound.get_safe_sound_object("daemonion\\weapons\\sub_9x18_" ..random_sub..)
  15.  
  16. function update()
  17.     if (db.actor:active_item() ~= nil) then --if any item is active
  18.         local newItem = db.actor:active_item()
  19.         local newCondition = newItem:condition()
  20.        
  21.         if activeItem == nil then --if this is the first time running
  22.             activeItem = newItem
  23.         end
  24.            
  25.         if (newItem:id() ~= activeItem:id()) then --if actor switches items, record the new information
  26.             activeItem = newItem
  27.             oldCondition = newCondition
  28.         end
  29.  
  30.         if (oldCondition > newCondition) then --if condition of the active item decreases
  31.             oldCondition = newCondition
  32.             -- TODO(AndrewD) Just playing around.  Assume this is THE place to initiate firearms sounds...
  33.             -- Assumes we are always using the makarov since i don't know how to get metadata
  34.             if not has_alife_info("interior_whitenoise_playing") then
  35.                 random_sub = math.random(1,3)
  36.                 random_reflection = math.random(1,3)
  37.                 hc_reflection_outdoors_left:play_at_pos(db.actor, vector():set(-5, 0, 1), 0, sound_object.s2d)
  38.                 hc_reflection_outdoors_right:play_at_pos(db.actor, vector():set(5, 0, 1), 0, sound_object.s2d)
  39.                 hc_sub:play_at_pos(db.actor, db.actor:position())
  40.             end
  41.         end
  42.     end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement