Advertisement
Guest User

daemonion_sound.script

a guest
Dec 11th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. -- Zoom in and out for Daemonion
  2. -- by Alundaio
  3.  
  4.  
  5.  
  6. --                          [section]  = { sound, fov }
  7. local sections_zoom_in = {
  8.                             ["wpn_pm"] = {[[weapons\nv_start]],54},
  9.  
  10. }
  11.  
  12. local sections_zoom_out = {
  13.                             ["wpn_pm"] = [[weapons\nv_off]],
  14.  
  15. }
  16.  
  17. -------------------
  18. -- goes in stalker_binder:update()
  19. -------------------
  20. function actor_on_update()
  21.     local wpn = db.actor:active_item()
  22.     if (wpn) then
  23.         if (sections_zoom_in[wpn:section()]) then
  24.             if (sections_zoom_in[wpn:section()][2] and device().fov < sections_zoom_in[wpn:section()][2]) then
  25.                 if not (actor_scope) then
  26.                     actor_scope = true
  27.                     actor_on_weapon_zoom_in(wpn)
  28.                 end
  29.             else
  30.                 if (actor_scope) then
  31.                     actor_scope = nil
  32.                     actor_on_weapon_zoom_out(wpn)
  33.                 end
  34.             end
  35.         else
  36.             if (actor_scope) then
  37.                 actor_scope = nil
  38.                 actor_on_weapon_zoom_out(wpn)
  39.             end
  40.         end
  41.     end
  42. end
  43.  
  44. -------------------
  45. -- actor_on_weapon_zoom_in(wpn)
  46. -------------------
  47. function actor_on_weapon_zoom_in(wpn)
  48.     local snd = sections_zoom_in[wpn:section()] and sections_zoom_in[wpn:section()][1] and get_sound(sections_zoom_in[wpn:section()][1])
  49.     if (snd) then
  50.         snd:play_at_pos(db.actor,db.actor:position(),0)
  51.     end
  52. end
  53.  
  54. -------------------
  55. -- actor_on_weapon_zoom_out(wpn)
  56. -------------------
  57. function actor_on_weapon_zoom_out(wpn)
  58.     local snd = sections_zoom_out[wpn:section()] and get_sound(sections_zoom_out[wpn:section()])
  59.     if (snd) then
  60.         snd:play_at_pos(db.actor,db.actor:position(),0)
  61.     end
  62. end
  63.  
  64.  
  65. function get_sound(snd)
  66.     if snd then
  67.         return sound_object(snd)
  68.     end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement