Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function fade_in(cur_amb_vol, timer, counter)
- if fade_in_check_time ~= nil and time_global() - fade_in_check_time <= timer then return end
- fade_in_check_time = time_global()
- if cur_amb_vol<ambient_vol then
- cur_amb_vol=cur_amb_vol+counter
- if cur_amb_vol>ambient_vol then cur_amb_vol=ambient_vol end
- --printf("fade_in:SET = "..ambient_vol)
- get_console():execute('snd_volume_music '..cur_amb_vol)
- end
- end
- local function fade_out(cur_amb_vol, timer, counter)
- if fade_out_check_time ~= nil and time_global() - fade_out_check_time <= timer then return end
- fade_out_check_time = time_global()
- if cur_amb_vol>0 then
- cur_amb_vol=cur_amb_vol-counter
- if cur_amb_vol<0 then cur_amb_vol=0 end
- --printf("fade_out:SET = "..ambient_vol)
- get_console():execute('snd_volume_music '..cur_amb_vol)
- end
- end
- function fades()
- --' Distemper 05.2008 --
- local actor = db.actor
- if actor:alive() then
- local playing_back = IsDynamicMusic()
- local actor_pos = actor:position()
- for k, object in pairs(npc_table) do
- local object_id = object:id()
- if not playing_back and play_combat ~= 0 then
- stop_combat(object_id)
- elseif playing_back then
- if object:alive() then
- if play_local_combat(actor, object, actor_pos, object_id) then
- break
- end
- play_local_suspence(actor, object, actor_pos, object_id)
- end
- end
- end
- end
- --' end --
- local cur_amb_vol = get_console():get_float('snd_volume_music')
- if music then
- fade_out(cur_amb_vol, 100, 0.1)
- else
- if db.storage.silence_zone_table and actor:alive() then
- local actor_pos = actor:position()
- local flag = 0
- for k,v in pairs(db.storage.silence_zone_table) do
- local zone = db.zone_by_name[v]
- if zone:inside(actor_pos) then
- flag = 1
- break
- end
- end
- if flag == 1 then
- fade_out(cur_amb_vol, 1000, 0.1)
- else
- fade_in(cur_amb_vol, 1000, 0.05)
- end
- else
- fade_in(cur_amb_vol, 100, 0.05)
- end
- end
- end
- function restore_ambient_on_end()
- if music_obj and music_obj:playing() then music_obj:stop() end
- --printf("restore_ambient_on_end:SET = "..ambient_vol)
- get_console():execute('snd_volume_music '..ambient_vol)
- end
- function main_menu_on()
- --printf("main_menu_on:SET = "..ambient_vol)
- get_console():execute('snd_volume_music '..ambient_vol)
- end
- function main_menu_off()
- local cur_amb = get_console():get_float('snd_volume_music')
- if cur_amb~=ambient_vol then
- ambient_vol = cur_amb
- end
- --printf("main_menu_off:SET = "..ambient_vol)
- get_console():execute('snd_volume_music '..ambient_vol)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement