Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- when the player fires any weapon, it spawns a bottle of vodka at their feet
- -- I want this to ultimately play a stereo sound file (in the actor's head, see method below)
- -- As another layer, I would like the script to also read an info portion which determines what kind of environment the player is in (tunnel, house, outside, etc), THEN see what kind of weapon the actor is using, THEN pick the right audio file to use
- local activeItem = nil --last recorded active item
- local oldCondition = 0 --condition of activeItem
- local report_l = xr_sound.get_safe_sound_object ("daemonion\\misc\\rain_test_l")
- local report_r = xr_sound.get_safe_sound_object ("daemonion\\misc\\report_r")
- function update()
- if (db.actor:active_item() ~= nil) then --if any item is active
- local newItem = db.actor:active_item()
- local newCondition = newItem:condition()
- if activeItem == nil then --if this is the first time running
- activeItem = newItem
- end
- if (newItem:id() ~= activeItem:id()) then --if actor switches items, record the new information
- activeItem = newItem
- oldCondition = newCondition
- end
- if (oldCondition > newCondition) then --if condition of the active item decreases
- oldCondition = newCondition
- alife():create("vodka", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id())
- end
- end
- end
- -- example of script which reads an info_portion (interior_whitenoise_playing, when true, means the actor is indoors) and looks for a new line in the current weapon's .ltx
- -- Weapon Interior Audio Update by Daemonion
- function weapon_interior_update()
- level_tasks.proceed(self.object)
- local sec = obj:section()
- local ini = system_ini()
- if has_alife_info("interior_whitenoise_playing") then
- if (ini:section_exist(sec.."_actor_indoors")) then
- alife():release( alife():object(obj:id()),true )
- alife():create(sec.."_actor_indoors",db.actor:position(),0,0,0)
- end
- end
- if not has_alife_info("interior_whitenoise_playing") then
- if (isWeapon(obj) and string.find(obj:section(),"_actor_indoors")) then
- local sec = string.gsub(obj:section(),"_actor_indoors","")
- alife():release( alife():object(obj:id()),true )
- alife():create(sec,db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id())
- end
- end
- end
- -- example of script which plays stereo audio on the actor
- -- Rain on Clothes by Daemonion
- -- Thanks to EvanTheUseless, Decane and NatVac
- function rain_on_clothes()
- local actor = db.actor
- local rain_fps_l = xr_sound.get_safe_sound_object ("daemonion\\misc\\rain_test_l")
- local rain_fps_r = xr_sound.get_safe_sound_object ("daemonion\\misc\\rain_test_r")
- -- c_print (level.rain_factor())
- if not has_alife_info("interior_whitenoise_playing") and level.rain_factor() > 0.05 then
- -- c_print("it is raining; player is outside restrictor")
- if rain_fps_l:playing() == false and rain_fps_r:playing() == false then
- -- c_print("playing sounds")
- rain_fps_l:play_at_pos (actor, vector():set(-5, 0, 1), 0, sound_object.s2d)
- rain_fps_r:play_at_pos (actor, vector():set(5, 0, 1), 0, sound_object.s2d)
- end
- elseif level.rain_factor == 0 then
- -- c_print("not raining; stopping")
- rain_fps_l:stop()
- rain_fps_r:stop()
- elseif has_alife_info("interior_whitenoise_playing") then
- -- c_print("player indoors; audio stopped")
- rain_fps_l:stop()
- rain_fps_r:stop()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement