Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Zoom in and out for Daemonion
- -- by Alundaio
- -- additions by Daemonion
- ------------------------------------------------------------
- -- 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
- -----------------------------------------------------------
- -- [section] = { sound, fov }
- local sections_zoom_in = {
- ["wpn_pm"] = {[[weapons\in]],74},
- }
- local sections_zoom_out = {
- ["wpn_pm"] = [[weapons\out]],
- }
- ------------------------------------------------------------
- -- goes in function actor_binder:on_item_take
- function weapon_perspective_take ()
- if (isWeapon(obj)) then
- local sec = obj:section()
- local ini = system_ini()
- -- Check system ini if section with the postfix "_actor" exists
- if (ini:section_exist(sec.."_actor")) then
- alife():release( alife():object(obj:id()),true )
- alife():create(sec.."_actor",db.actor:position(),0,0,0)
- end
- end
- -- goes in function actor_binder:on_item_drop
- function weapon_perspective_drop ()
- if (isWeapon(obj) and string.find(obj:section(),"_actor")) then
- local sec = string.gsub(obj:section(),"_actor","")
- alife():release( alife():object(obj:id()),true )
- alife():create(sec,db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id())
- 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