

--[[ ---------------------------------------------------------------------------------------------------
 File        : kvest_main_functions.script
 Description : main function for kvest
 Copyright   : 2010 © Stalk15
 Author      : Stalk15
 Last update : 21.07.2010 
--]]----------------------------------------------------------------------------------------------------


--/ Спавн обьектов и другие дейсвия для квестов при определенных условиях(вызов из актор-апдейта)
local stope = false   --/ flag_trigger
local stope2 = false   --/ flag_trigger
local stope3 = false   --/ flag_trigger

function Sistem_main_functions_for_kvest_update()
  --/Спавн новичка и выдача квеста "Поговорить с ним"
   if db.actor:object("dar_document4") then	
	    if level.name() == "l01_escape" then
	       if not stope then
	           alife():create("esc_nub", vector():set(324.700,16.04,-10.688),577681,2)
			     db.actor:give_info_portion("esc_kvest_talk_noobychu_start")  --/Выдача квеста
	               news_manager.send_tip(db.actor, "Новичок заспавнен", 0, "trader", 20000)
	             stope = true   --/ flag_trigger
                  end
	                end 
	          end
	       --/Выполнение квеста "Убить Стрелка"
	                if has_alife_info("freeplay_activated1") and not has_alife_info("esc_kill_strelok_done") then
	                        db.actor:give_info_portion("esc_kill_strelok_done")
							 db.actor:give_info_portion("esc_kvest_search_provodnik_start")
		                 -- news_manager.send_tip(db.actor, "Поршень esc_kill_strelok_done получен", 0, "trader", 20000)
                       end   
	        --/Спавн Дегтярева, Ковальского и Бродяги
	                        if has_alife_info("esc_kill_strelok_done") and not has_alife_info("esc_spawn_free_nps_in_pripyat") then
		                        if level.name() == "pripyat" then
			                        alife():create("cop_cov", vector():set(144.700,-0.09,-190.688),374276,3765)
			                            alife():create("cop_deg", vector():set(144.700,-0.09,-190.688),374276,3765)
					                   --    alife():create("upi_bro", vector():set(-395.10,12.32,10.688),51661,3708)
			                             db.actor:give_info_portion("esc_spawn_free_nps_in_pripyat")
			                         --  news_manager.send_tip(db.actor, "Спавн Дегтярева Ковальского и Бродяги завершен", 0, "trader", 20000)
                                    end	
									end
					       --/Выдаем квест "Поговорить с Лексом"
		                        if has_alife_info("esc_find_doctor_start") and not has_alife_info("esc_kvest_talk_with_mar_lex_start") then
				                    if level.name() == "l03_agroprom" then
	 	                                db.actor:give_info_portion("esc_kvest_talk_with_mar_lex_start")
			                             kvest_texts.start_kvest_talk_with_lex()
                                    end
								end
			            if db.actor:object("doc_7") and db.actor:object("doc_8") then
						    if not stope2 then
						    news_manager.send_tip(db.actor, "Переходы заспавнены", 0, "trader", 20000)
							  stope2 = true  --/ flag_trigger
				        end
					end
				    --[[if not has_alife_info("jup_kvest_search_instr_cal_rem_start") then
				        if level.name() == "jupiter" then
					      kvest_texts.soobch_irbis_search_instr_prosba()
				            db.actor:give_info_portion("jup_kvest_search_instr_cal_rem_start")
			           end
					     end]]
					        if has_alife_info("mar_kvest_search_dragons_start") and not has_alife_info("mar_kvest_search_dragons_complete") then
					             if level.name() == "warlab" then
								     db.actor:give_info_portion("mar_kvest_search_dragons_complete")
									    db.actor:give_info_portion("war_kvest_talk_with_irbis_start")
                                end
							end
								--/ Система изчезновения диалогов взятия квестов у механиков
								    if has_alife_info("jup_kvest_search_instrcal_for_med_start") and has_alife_info("jup_kvest_search_instrem_for_med_start") then
                                        if not has_alife_info("jup_kvests_search_instrem_and_instrcal_for_med_complete") then									
                                            db.actor:give_info_portion("jup_kvests_search_instrem_and_instrcal_for_med_complete")	
										end
									end	
								    if has_alife_info("jup_kvest_search_instrcal_for_dragon_ska_start") and has_alife_info("jup_kvest_search_instrem_for_dragon_ska_start") then
                                        if not has_alife_info("jup_kvests_search_instrem_and_instrcal_for_dragon_ska_starts") then									
                                            db.actor:give_info_portion("jup_kvests_search_instrem_and_instrcal_for_dragon_ska_starts")											
                                    end
								end
								            if has_alife_info("jup_kvest_search_instrcal_for_shurup_start") and has_alife_info("jup_kvest_search_instrem_for_shurup_start") then
                                                 if not has_alife_info("jup_kvests_search_instrem_and_instrcal_for_shurup_starts") then									
                                                      db.actor:give_info_portion("jup_kvests_search_instrem_and_instrcal_for_shurup_starts")
                                                end
											end
			                if has_alife_info("esc_kvest_search_provodnik_start") then
					            if level.name() == "lost_village" then
							        if not stope3 then
					                    alife():create("vil_prov", vector():set(25.10,-3.08,1.688),21222,3332)
							    stope3 = true  --/ flag_trigger
                             end
                         end
                     end
					if has_alife_info("war_kvest_search_docs_for_irbis_start") and not has_alife_info("jup_kvest_search_instrrem_cal_for_dragon_ska_start") then
					    if level.name() == "jupiter" then
				     db.actor:give_info_portion("jup_kvest_search_instrrem_cal_for_dragon_ska_start")
                end
		end
end
	
--/
function kvest_search_dodge_update()
    this.search_dodge_complete()
	this.dodge_ryadom()
end		
	
--/Нашли додж	
function search_dodge_complete()
   local car_dodge = level_object_by_sid(15002) 
      if car_dodge then
	     if car_dodge:position():distance_to(db.actor:position()) < 5 then
            return true
         else
       return false
     end
   end
end		
		
		
--/Нашли додж	
local dodge = false   --/ flag_trigger
function dodge_ryadom()
   local car_dodge = level_object_by_sid(15002) 
     local upi_kur = level_object_by_sid(151) 
      if car_dodge and upi_kur then
		   if distance_between(car_dodge, upi_kur) < 27 then
		     if not dodge then
              db.actor:give_info_portion("jup_dodge_ryadom")
		    dodge = true 
		  end
       end
   end		
end		
		
		
--/Убиваем 7 Бандосов		
function kill_7_bandits()		
    if has_alife_info("gar_kill_bandit_1") and
         has_alife_info("gar_kill_bandit_2") and
            has_alife_info("gar_kill_bandit_3") and
                  has_alife_info("gar_kill_bandit_4") and
                     has_alife_info("gar_kill_bandit_5") and
                  has_alife_info("gar_kill_bandit_6") and
             has_alife_info("gar_kill_bandit_7") then		
          db.actor:give_info_portion("gar_kill_bandits_complete")	
       return true 	
         else
		  return false 
     end		
end			
		
		
		
	
		
		
		