Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Zoom in and out for Daemonion
- -- by Alundaio
- -- [section] = { sound, fov }
- local sections_zoom_in = {
- ["wpn_pm"] = {[[weapons\in]],74},
- }
- local sections_zoom_out = {
- ["wpn_pm"] = [[weapons\out]],
- }
- -------------------
- -- debug
- -------------------
- function printf(text,...)
- if not (text) then return end
- local i = 0
- local p = {...}
- local function sr(a)
- i = i + 1
- return tostring(p[i])
- end
- local output = string.gsub(text,"%%s",sr)
- get_console():execute(output)
- --get_console():execute("load ~#I#:"..output)
- end
- -------------------
- -- goes in stalker_binder:update()
- -------------------
- function actor_on_update()
- --printf("device fov = %s",device().fov)
- --printf("test")
- local wpn = db.actor:active_item()
- if (wpn) then
- if (sections_zoom_in[wpn:section()]) then
- if (sections_zoom_in[wpn:section()][2] and device().fov < sections_zoom_in[wpn:section()][2]) then
- if not (actor_scope) then
- actor_scope = true
- actor_on_weapon_zoom_in(wpn)
- printf("actor update zoomed in")
- end
- else
- if (actor_scope) then
- actor_scope = nil
- actor_on_weapon_zoom_out(wpn)
- printf("actor update zoomed out")
- end
- end
- else
- if (actor_scope) then
- actor_scope = nil
- actor_on_weapon_zoom_out(wpn)
- printf("actor update catch all")
- end
- end
- end
- end
- -------------------
- -- actor_on_weapon_zoom_in(wpn)
- -------------------
- function actor_on_weapon_zoom_in(wpn)
- --local snd = sound_object("weapons\in")
- local snd = sections_zoom_in[wpn:section()] and sections_zoom_in[wpn:section()][1] and get_sound(sections_zoom_in[wpn:section()][1])
- if (snd) then
- snd:play_at_pos (db.actor, db.actor:position())
- --snd:play_at_pos(db.actor,db.actor:position(),0)
- end
- end
- -------------------
- -- actor_on_weapon_zoom_out(wpn)
- -------------------
- function actor_on_weapon_zoom_out(wpn)
- --local snd = sound_object("weapons\out")
- local snd = sections_zoom_out[wpn:section()] and get_sound(sections_zoom_out[wpn:section()])
- if (snd) then
- snd:play_at_pos (db.actor, obj:position())
- --snd:play_at_pos(db.actor,db.actor:position(),0)
- end
- end
- function get_sound(snd)
- if snd then
- return sound_object(snd)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement