Advertisement
Daemonion

full

Dec 15th, 2012
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 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\in]],74},
  9. }
  10.  
  11. local sections_zoom_out = {
  12.     ["wpn_pm"] = [[weapons\out]],
  13. }
  14.  
  15. -------------------
  16. -- debug
  17. -------------------
  18. function printf(text,...)
  19.     if not (text) then return end
  20.     local i = 0
  21.     local p = {...}
  22.     local function sr(a)
  23.         i = i + 1
  24.         return tostring(p[i])
  25.     end
  26.     local output = string.gsub(text,"%%s",sr)
  27.     get_console():execute(output)
  28.     --get_console():execute("load ~#I#:"..output)
  29. end
  30.  
  31. -------------------
  32. -- goes in stalker_binder:update()
  33. -------------------
  34. function actor_on_update()
  35.     --printf("device fov = %s",device().fov)
  36.     --printf("test")
  37.     local wpn = db.actor:active_item()
  38.     if (wpn) then
  39.         if (sections_zoom_in[wpn:section()]) then
  40.             if (sections_zoom_in[wpn:section()][2] and device().fov < sections_zoom_in[wpn:section()][2]) then
  41.                 if not (actor_scope) then
  42.                     actor_scope = true
  43.                     actor_on_weapon_zoom_in(wpn)
  44.                     printf("actor update zoomed in")
  45.                 end
  46.             else
  47.                 if (actor_scope) then
  48.                     actor_scope = nil
  49.                     actor_on_weapon_zoom_out(wpn)
  50.                     printf("actor update zoomed out")
  51.                 end
  52.             end
  53.         else
  54.             if (actor_scope) then
  55.                 actor_scope = nil
  56.                 actor_on_weapon_zoom_out(wpn)
  57.                 printf("actor update catch all")
  58.             end
  59.         end
  60.     end
  61. end
  62.  
  63. -------------------
  64. -- actor_on_weapon_zoom_in(wpn)
  65. -------------------
  66. function actor_on_weapon_zoom_in(wpn)
  67.     --local snd = sound_object("weapons\in")
  68.     local snd = sections_zoom_in[wpn:section()] and sections_zoom_in[wpn:section()][1] and get_sound(sections_zoom_in[wpn:section()][1])
  69.     if (snd) then
  70.         snd:play_at_pos (db.actor, db.actor:position())
  71.         --snd:play_at_pos(db.actor,db.actor:position(),0)
  72.     end
  73. end
  74.  
  75. -------------------
  76. -- actor_on_weapon_zoom_out(wpn)
  77. -------------------
  78. function actor_on_weapon_zoom_out(wpn)
  79.     --local snd = sound_object("weapons\out")
  80.     local snd = sections_zoom_out[wpn:section()] and get_sound(sections_zoom_out[wpn:section()])
  81.     if (snd) then
  82.         snd:play_at_pos (db.actor, obj:position())
  83.         --snd:play_at_pos(db.actor,db.actor:position(),0)
  84.     end
  85. end
  86.  
  87.  
  88. function get_sound(snd)
  89.     if snd then
  90.         return sound_object(snd)
  91.     end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement