local weapon_hidden = 0 local time_disabled = 0 local animation_start = false local item_in_use = {} local item_not_in_use = true function Update_Animations(actor) if item_not_in_use then return end local in_use = 0 for tg_m, t in pairs(item_in_use) do in_use = in_use + 1 local remov = true local tg = time_global() - tonumber(tg_m) -- time frame of an action has been reached -> excute then clear action for milli, action in pairs(t) do remov = false if (tg > milli) then assert(loadstring(action))() item_in_use[tg_m][milli] = nil --actor:give_game_news(tostring(tg), action, "ui_iconsTotal_grouping", 0, 5000, 0) end end -- no action is left? -> clear the fx from the table if remov then in_use = in_use - 1 item_in_use[tg_m] = nil end end item_not_in_use = (in_use == 0) end function menu_play(itm) -- return "Play" name local p = itm:parent() if not (p and p:id() == 0) then return end return game.translate_string("st_use") end function use_weapon(f) local hidden = weapon_hidden weapon_hidden = weapon_hidden + f * 2 - 1 if weapon_hidden == 0 then db.actor:restore_weapon() elseif hidden == 0 then db.actor:hide_weapon() end end function play_continuous_effect(period) --if (not opt.enable_animations) then return end local tot = 0 local one_p = 5600 --3801 local num = math.ceil(period/one_p) if (time_global() > time_disabled) then local tg = tostring(time_global()) item_not_in_use = false item_in_use[tg] = {} item_in_use[tg][0] = "moon_cotz_instruments.use_weapon(0)" item_in_use[tg][1] = "xr_effects.disable_ui_inventory(db.actor, nil)" item_in_use[tg][2] = "xr_effects.disable_ui_lite_with_imput(db.actor, nil)" item_in_use[tg][550] = "level.add_cam_effector('camera_effects\\\\instrument_play.anm', 8053, false,'')" tot = 550 for i=1,num-1 do tot = tot + one_p item_in_use[tg][tot] = "level.add_cam_effector('camera_effects\\\\instrument_play.anm', 8053, false,'')" end tot = tot + one_p item_in_use[tg][tot] = "xr_effects.enable_ui_lite_with_imput(db.actor, nil)" --item_in_use[tg][tot + 1399] = "xr_effects.enable_imput(db.actor, nil)" item_in_use[tg][tot + 1999] = "moon_cotz_instruments.use_weapon(1)" end end function use_guitar(obj) local n = math.random(28) local snd = sound_object("music\\guitar_" .. tostring(n)) if (not snd) then return end local period = snd:length() -- _G.mus_vol = get_console():get_float("snd_volume_music") snd:play_no_feedback(db.actor, 0, 0, db.actor:position(), 1.0, 1.0) -- get_console():execute("snd_volume_music 0") play_continuous_effect(period) -- get_console():execute("snd_volume_music "..tostring(_G.mus_vol)) end function use_harmonica(obj) local n = math.random(5) local snd = sound_object("music\\harmonica_" .. tostring(n)) if (not snd) then return end local period = snd:length() _G.mus_vol = get_console():get_float("snd_volume_music") snd:play_no_feedback(db.actor, 0, 0, db.actor:position(), 1.0, 1.0) get_console():execute("snd_volume_music 0") play_continuous_effect(period) get_console():execute("snd_volume_music "..tostring(_G.mus_vol)) end local function actor_on_update() if (not db.actor) then return end local tg = time_global() cam_dist = db.actor:bone_position("bip01_head"):distance_to_sqr(device().cam_pos) Update_Animations(actor) end function on_game_start() RegisterScriptCallback("actor_on_update",actor_on_update) end