--[[ -----------------------------------------------------------------------------------------------
 File         : xr_racya.script
 Description  : GG+racya
 Copyright    : 2009 © ФеНиКс
 Author       : Starter, ВЛАД ,ФеНиКс, ALEX BOY ,Shadows
 Last update  : 10.06.2010(by Evill Zone) 
 Modernization: by Shadows (4.07.10). Основа скрипта создана Фениксом при доработке Влада. 
 Addition     : Stalk15
--]]-----------------------------------------------------------------------------------------------


local device_active = true
local snd_obj,react
local stope = false

function item_update()
    local item = db.actor:active_item()
    if not (item and item:section() == "racya_b") then
        if snd_obj and snd_obj:playing() then
            snd_obj:stop()
        end
        return
    end
    if device_active then
        snd_obj = sound_object("characters_voice\\human_01\\bandit\\racya\\radio_voice_"..tostring(math.random(1,14)))  
        snd_obj:play_at_pos(db.actor, vector():set(0,0,0), 0, sound_object.s2d)
    for k, v in pairs (db.storage) do
        local stalker = level.object_by_id(k)
        if (stalker and IsStalker(stalker)) then
            if stalker:position():distance_to(db.actor:position()) < 10 then
                if not snd_obj:playing() then
                    react = sound_object("characters_voice\\human_01\\bandit\\no_music\\no_sound_"..tostring(math.random(1,2)))  
                    react:play_at_pos(stalker, stalker:position(), sound_object.s2d)
                    react.volume = 0.8
                end
            end
        end
    end
        device_active = false
    else
        if not snd_obj:playing() then
            device_active = true
        end
		
		    local active_item = db.actor:active_item() 
		     	if (active_item:section() == "racya_b") then
				     if level.name() == "l10_radar" and has_alife_info("bar_deactivate_radar_done") then
				         if not stope then
		                local snd_obj = xr_sound.get_safe_sound_object([[script_replics\radio\radio_voice_secret]])
					          --/ local snd_obj = xr_sound.get_safe_sound_object([[music\05_wasteland2_str_l]])
                          snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
					  news_manager.send_tip(db.actor, "Звучок спахал", 0, "freedom", 5000)
			      stope = true
               end   
            end
        end
	end
end




















