

-- (all ?) alife infos in task_sim.script
-- all level jump targets in level_tasks.script

-- Sid's preconditions
----------------------
function precon_wounded_flash_needed(actor, trader)
	return not has_alife_info("tutorial_wounded_give_info")
end

function precon_wounded_flash_done(actor, trader)
	return has_alife_info("tutorial_wounded_give_info")
end

function precon_strelok_flash_needed(actor, trader)
	return not xr_conditions_impl.actor_has_object(actor, "gunslinger_flash")
end

function precon_agro_docs_needed(actor, trader)
	return not xr_conditions_impl.actor_has_object(actor, "quest_case_02")
end

function precon_agro_task_started(actor, trader)
	return has_alife_info("agroprom_military_case")
end

function precon_agro_not_finished(actor, trader)
	return not has_alife_info("agroprom_military_case_done")
end

-- Sid's functions
------------------
function give_money(actor, npc)
	dialogs.relocate_money(actor, 100000, "in")
end

function give_wounded_flash(actor, trader)
	dialogs.relocate_item_section(actor, "esc_wounded_flash", "in")
end

function give_strelok_flash(actor, trader)
	dialogs.relocate_item_section(actor, "gunslinger_flash", "in")
end

function give_agroprom_documents(actor, trader)
	dialogs.relocate_item_section(actor, "quest_case_02", "in")
end

function open_duty_blockpost(actor, trader)
	db.actor:give_info_portion("gar_free_pass")
end

function play_sid_wassup(actor, trader)
	local snd_obj = xr_sound.get_safe_sound_object([[trader_cheat\sid_wassup]])
	snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
end

-- Snitch' preconditions
------------------------

function play_snitch_marky_wassup(actor, trader)
	local snd_obj = xr_sound.get_safe_sound_object([[trader_cheat\snitch_marky_wassup]])
	snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
end

-- garbage precons
function precon_first_meeting(actor, trader)
	return not (has_alife_info("esc_fox_thanks") and has_alife_info("gar_hellcar_dialog_end") and has_alife_info("garbage_meetstalker_done"))
end

function precon_not_first_meeting(actor, trader)
	return (has_alife_info("esc_fox_thanks") and has_alife_info("gar_hellcar_dialog_end") and has_alife_info("garbage_meetstalker_done"))
end

-- darkvalley precons
function precon_X18_docs_needed(actor, trader)
	return not xr_conditions_impl.actor_has_object(actor, "dar_document4")
end

function precon_X18_started(actor, trader)
	return has_alife_info("bar_darklab_document_start")
end

function precon_X18_done(actor, trader)
	return has_alife_info("bar_darklab_document_done")
end

function precon_X18_not_done(actor, trader)
	return not has_alife_info("bar_darklab_document_done")
end

-- yantar precons
function precon_X16_docs_needed(actor, trader)
	return not xr_conditions_impl.actor_has_object(actor, "lab_x16_documents")
end

function precon_X16_started(actor, trader)
	return has_alife_info("bar_x16_documents_start")
end

function precon_X16_not_done(actor, trader)
	return not has_alife_info("bar_x16_documents_done")
end

-- guide precon
function precon_decoder_needed(actor, trader)
	return not xr_conditions_impl.actor_has_object(actor, "decoder")
end

function precon_guide_was_here(actor, trader)
	return has_alife_info("yan_provodnik_spawn")
end

function precon_guide_not_met(actor, trader)
	return not has_alife_info("esc_find_doctor_done")
end

-- brain scorcher precons
function got_brain_scorcher_task(actor, trader)
	return has_alife_info("bar_deactivate_radar_start")
end

function brain_scorcher_not_down(actor, trader)
	return not has_alife_info("bar_deactivate_radar_done")
end


-- Snitch' functions
--------------------

function play_snitch_wassup(actor, trader)
	local snd_obj = xr_sound.get_safe_sound_object([[trader_cheat\snitch_marky_wassup_44]])
	snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
end

-- garbage tasks
function end_fox_talk(actor, trader)
	db.actor:give_info_portion("escape_fox_heal")
	db.actor:give_info_portion("garbage_meetstalker_start")
	db.actor:give_info_portion("esc_fox_thanks")
end

function end_bes_talk(actor, trader)
	db.actor:give_info_portion("gar_hellcar_help")
	db.actor:give_info_portion("gar_bandits_killed")
	db.actor:give_info_portion("gar_hellcar_dialog_end")	
end

function end_seriy_talk(actor, trader)
	db.actor:give_info_portion("garbage_meetstalker_done") 	
end

-- darkvalley tasks
function has_entered_bandits_base(actor, trader)
	db.actor:give_info_portion("val_actor_on_bandits_base") 
end

function got_borov_key(first_speaker, second_speaker)
	first_speaker:transfer_item(first_speaker:object("borov_flash"), second_speaker)
end

function left_bandits_base(actor, trader)
	db.actor:give_info_portion("val_actor_leave_bandits_base") 
end

function x18_door_open(actor, trader)
	db.actor:give_info_portion("val_x18_door_open") 
end

function got_docs(actor, trader)
	dialogs.relocate_item_section(actor, "dar_document4", "in")
	db.actor:give_info_portion("bar_darklab_document_gain") 
end

-- yantar tasks

function found_x16(actor, trader)
	dialogs.relocate_item_section(actor, "good_psy_helmet", "in")
	db.actor:give_info_portion("labx16_find") 
end

function deactivated_x16(actor, trader)
	db.actor:give_info_portion("yan_labx16_switcher_3_off")
	db.actor:give_info_portion("yan_labx16_switcher_3_end")
	db.actor:give_info_portion("yan_labx16_switcher_2_off")
	db.actor:give_info_portion("yan_labx16_switcher_2_end")
	db.actor:give_info_portion("yan_labx16_switcher_1_off")
	db.actor:give_info_portion("yan_labx16_switcher_1_end")
	db.actor:give_info_portion("yan_labx16_switcher_primary_off")
	db.actor:give_info_portion("yan_kill_brain_done")
end

function found_ghost(first_speaker, second_speaker)
	dialogs.relocate_item_section(db.actor, "outfit_stalker_m1", "in")
	dialogs.relocate_item_section(db.actor, "lab_x16_documents", "in")
	first_speaker:transfer_item(first_speaker:object("yantar_ghost_pda"), second_speaker)
	db.actor:give_info_portion("yan_has_ghost_pda")
	db.actor:give_info_portion("yantar_find_ghost_task_end")
	db.actor:give_info_portion("yan_x16_documents_gain")
	db.actor:give_info_portion("yantar_tunnel_finish")
	db.actor:give_info_portion("yan_provodnik_spawn")
end

-- guide tasks
function met_guide(actor, trader)
	dialogs.relocate_item_section(db.actor, "decoder", "in")
	db.actor:give_info_portion("pri_monolith_decoder_got")
	db.actor:give_info_portion("esc_find_doctor_done")
end

-- brain scorcher tasks
function shut_down_brain_scorcher(actor, trader)
	db.actor:give_info_portion("rad_antennas_reached")
	db.actor:give_info_portion("rad_bun_found")
	db.actor:give_info_portion("bun_antenna_off")
	db.actor:give_info_portion("bar_deactivate_radar_done")
end
	
	
------------------------------------------------------------------------------------------


-- to be completed - some other time
function jump_to_pripyat(actor, trader)
	-- 91 105 419 420 446
	--105 some stalker
	--137 rookie camp
	--278 railway bridge
	--418 military blockpost
	-- fucked up id with sid
	
	local sim = alife ()
	if sim ~= nil then 
    	local obj = sim:object (91)
    	if obj ~= nil then 
    		level.map_add_object_spot(obj.id, "level_changer", "to_pripyat")
    		-- on_actor_in_zone
    	end
    end
end


