------------------------------------------------------------
--     2008 Elite Games Team (R) All Rights Reserved      --
--             "STAR WOLVES 2: CIVIL WAR"                 --
------------------------------------------------------------

------------------------------------------------------------
-- Auto-built Quest-Action-file created by "MapBuilder2"  --
------------------------------------------------------------
--      "MapBuilder2" v.2.6 Elite Games Team              --
------------------------------------------------------------


--info:top=120,left=130,allvis=0;
function StartMission()
  StartDialog("Dialog1");
end;


--info:top=160,left=130,allvis=0;
function GoTo_Station()
  AddQuest("quest_16e_01", "#L_Quest_16e_01a", "#L_Quest_16e_01b", QUEST_PROCESS);
  nav_current = CreateNavPoint("", mothership:GetPosition(), "nav_void.dds", RGB(255,255,255), mothership);
  LineToStation = CreateLine(nav_current, np_mine, RGB(20,80,220), .3, TRUE, .2, 1);
  NewTrigger("inside", TrueCondition, Near_Station, mothership, MINE:GetPosition(), 100);
end;


--info:top=200,left=130,allvis=0;
function Near_Station()
  LineToStation:Delete();
  LineToStation = NIL;
  nav_current:Delete();
  nav_current = NIL;
  SetQuestState("quest_16e_01", QUEST_DONE);
  SetNormalTimeMode();
  MothershipFlight:Stop();
  StartDialog("Dialog2");
end;


--info:top=240,left=130,allvis=0;
function To_Matrix()
  CreateFadeScreen(3, 1, 7);
  Hero_To_Uber();
  Yana_To_Uber();
  Uel2_To_Uber(UelDSpeaker);
  Uel3_To_Uber(UelTSpeaker);
  Timer_Seq(10, In_Matrix);
end;


--info:top=290,left=390,allvis=0;
function Hero_To_Uber()
  lTreeName = HeroSpeaker:GetTreeName();
  if (lTreeName=="Hero_pil") then
    HeroPilot_To_Uber();
  elseif (lTreeName=="Hero_gun") then
    HeroGunner_To_Uber();
  elseif (lTreeName=="Hero_mis") then
    HeroMissile_To_Uber();
  elseif (lTreeName=="Hero_sys") then
    HeroSystem_To_Uber();
  else
    LOG("Script error: Unknown tree name.");
    Terminate();
  end;
end;


--info:top=340,left=140,allvis=0;
function HeroPilot_To_Uber()
  if not(HeroSpeaker:HasProperty("Piloting_1")) then
    HeroSpeaker:SetPerk("Piloting_1");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_2")) then
    HeroSpeaker:SetPerk("Piloting_2");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_3")) then
    HeroSpeaker:SetPerk("Piloting_3");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_4")) then
    HeroSpeaker:SetPerk("Piloting_4");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_5")) then
    HeroSpeaker:SetPerk("Piloting_5");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_1")) then
    HeroSpeaker:SetPerk("Pilot_1");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_2")) then
    HeroSpeaker:SetPerk("Pilot_2");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_3")) then
    HeroSpeaker:SetPerk("Pilot_3");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_4")) then
    HeroSpeaker:SetPerk("Pilot_4");
  end;
  if not(HeroSpeaker:HasProperty("Tactics")) then
    HeroSpeaker:SetPerk("Tactics");
  end;
  if not(HeroSpeaker:HasProperty("Tactics_Exp")) then
    HeroSpeaker:SetPerk("Tactics_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Elite")) then
    HeroSpeaker:SetPerk("Elite");
  end;
  if not(HeroSpeaker:HasProperty("Hard_to_Kill")) then
    HeroSpeaker:SetPerk("Hard_to_Kill");
  end;
  if not(HeroSpeaker:HasProperty("snake_attack_1")) then
    HeroSpeaker:SetPerk("snake_attack_1");
  end;
  if not(HeroSpeaker:HasProperty("snake_attack_2")) then
    HeroSpeaker:SetPerk("snake_attack_2");
  end;
  if not(HeroSpeaker:HasProperty("snake_attack_3")) then
    HeroSpeaker:SetPerk("snake_attack_3");
  end;
  if not(HeroSpeaker:HasProperty("Learner")) then
    HeroSpeaker:SetPerk("Learner");
  end;
  if not(HeroSpeaker:HasProperty("Learner_Exp")) then
    HeroSpeaker:SetPerk("Learner_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_1")) then
    HeroSpeaker:SetPerk("Gunnery_1");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_2")) then
    HeroSpeaker:SetPerk("Gunnery_2");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_3")) then
    HeroSpeaker:SetPerk("Gunnery_3");
  end;
  if not(HeroSpeaker:HasProperty("Criticals_1")) then
    HeroSpeaker:SetPerk("Criticals_1");
  end;
  if not(HeroSpeaker:HasProperty("F_Weapon_HC")) then
    HeroSpeaker:SetPerk("F_Weapon_HC");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_Rockets")) then
    HeroSpeaker:SetPerk("Missiles_Rockets");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_2")) then
    HeroSpeaker:SetPerk("Missiles_2");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_3")) then
    HeroSpeaker:SetPerk("Missiles_3");
  end;
  if not(HeroSpeaker:HasProperty("Rockets_1")) then
    HeroSpeaker:SetPerk("Rockets_1");
  end;
  if not(HeroSpeaker:HasProperty("lucky_1")) then
    HeroSpeaker:SetPerk("lucky_1");
  end;
  if not(HeroSpeaker:HasProperty("lucky_2")) then
    HeroSpeaker:SetPerk("lucky_2");
  end;
  if not(HeroSpeaker:HasProperty("F_of_Merchant")) then
    HeroSpeaker:SetPerk("F_of_Merchant");
  end;
  if not(HeroSpeaker:HasProperty("Black_Market")) then
    HeroSpeaker:SetPerk("Black_Market");
  end;
  if not(HeroSpeaker:HasProperty("Systems_1")) then
    HeroSpeaker:SetPerk("Systems_1");
  end;
  if not(HeroSpeaker:HasProperty("Systems_2")) then
    HeroSpeaker:SetPerk("Systems_2");
  end;
  if not(HeroSpeaker:HasProperty("Countermeasures")) then
    HeroSpeaker:SetPerk("Countermeasures");
  end;
  if not(HeroSpeaker:HasProperty("Shields_Op")) then
    HeroSpeaker:SetPerk("Shields_Op");
  end;
  if not(HeroSpeaker:HasProperty("Repairman")) then
    HeroSpeaker:SetPerk("Repairman");
  end;
  if not(HeroSpeaker:HasProperty("Engine_Op")) then
    HeroSpeaker:SetPerk("Engine_Op");
  end;
end;


--info:top=340,left=290,allvis=0;
function HeroGunner_To_Uber()
  if not(HeroSpeaker:HasProperty("Piloting_1")) then
    HeroSpeaker:SetPerk("Piloting_1");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_2")) then
    HeroSpeaker:SetPerk("Piloting_2");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_3")) then
    HeroSpeaker:SetPerk("Piloting_3");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_1")) then
    HeroSpeaker:SetPerk("Pilot_1");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_2")) then
    HeroSpeaker:SetPerk("Pilot_2");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_3")) then
    HeroSpeaker:SetPerk("Pilot_3");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_4")) then
    HeroSpeaker:SetPerk("Pilot_4");
  end;
  if not(HeroSpeaker:HasProperty("Hard_to_Kill")) then
    HeroSpeaker:SetPerk("Hard_to_Kill");
  end;
  if not(HeroSpeaker:HasProperty("Tactics")) then
    HeroSpeaker:SetPerk("Tactics");
  end;
  if not(HeroSpeaker:HasProperty("Tactics_Exp")) then
    HeroSpeaker:SetPerk("Tactics_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Learner")) then
    HeroSpeaker:SetPerk("Learner");
  end;
  if not(HeroSpeaker:HasProperty("Learner_Exp")) then
    HeroSpeaker:SetPerk("Learner_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_1")) then
    HeroSpeaker:SetPerk("Gunnery_1");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_2")) then
    HeroSpeaker:SetPerk("Gunnery_2");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_3")) then
    HeroSpeaker:SetPerk("Gunnery_3");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_4")) then
    HeroSpeaker:SetPerk("Gunnery_4");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_5")) then
    HeroSpeaker:SetPerk("Gunnery_5");
  end;
  if not(HeroSpeaker:HasProperty("Elite")) then
    HeroSpeaker:SetPerk("Elite");
  end;
  if not(HeroSpeaker:HasProperty("Criticals_1")) then
    HeroSpeaker:SetPerk("Criticals_1");
  end;
  if not(HeroSpeaker:HasProperty("Criticals_2")) then
    HeroSpeaker:SetPerk("Criticals_2");
  end;
  if not(HeroSpeaker:HasProperty("Criticals_3")) then
    HeroSpeaker:SetPerk("Criticals_3");
  end;
  if not(HeroSpeaker:HasProperty("F_Weapon_Laser")) then
    HeroSpeaker:SetPerk("F_Weapon_Laser");
  end;
  if not(HeroSpeaker:HasProperty("burst_1")) then
    HeroSpeaker:SetPerk("burst_1");
  end;
  if not(HeroSpeaker:HasProperty("burst_2")) then
    HeroSpeaker:SetPerk("burst_2");
  end;
  if not(HeroSpeaker:HasProperty("burst_3")) then
    HeroSpeaker:SetPerk("burst_3");
  end;
  if not(HeroSpeaker:HasProperty("snipeOut_1")) then
    HeroSpeaker:SetPerk("snipeOut_1");
  end;
  if not(HeroSpeaker:HasProperty("snipeOut_2")) then
    HeroSpeaker:SetPerk("snipeOut_2");
  end;
  if not(HeroSpeaker:HasProperty("snipeOut_3")) then
    HeroSpeaker:SetPerk("snipeOut_3");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_Rockets")) then
    HeroSpeaker:SetPerk("Missiles_Rockets");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_2")) then
    HeroSpeaker:SetPerk("Missiles_2");
  end;
  if not(HeroSpeaker:HasProperty("lucky_1")) then
    HeroSpeaker:SetPerk("lucky_1");
  end;
  if not(HeroSpeaker:HasProperty("lucky_2")) then
    HeroSpeaker:SetPerk("lucky_2");
  end;
  if not(HeroSpeaker:HasProperty("F_of_Merchant")) then
    HeroSpeaker:SetPerk("F_of_Merchant");
  end;
  if not(HeroSpeaker:HasProperty("Black_Market")) then
    HeroSpeaker:SetPerk("Black_Market");
  end;
  if not(HeroSpeaker:HasProperty("Systems_1")) then
    HeroSpeaker:SetPerk("Systems_1");
  end;
  if not(HeroSpeaker:HasProperty("Systems_2")) then
    HeroSpeaker:SetPerk("Systems_2");
  end;
  if not(HeroSpeaker:HasProperty("Countermeasures")) then
    HeroSpeaker:SetPerk("Countermeasures");
  end;
  if not(HeroSpeaker:HasProperty("Shields_Op")) then
    HeroSpeaker:SetPerk("Shields_Op");
  end;
  if not(HeroSpeaker:HasProperty("Repairman")) then
    HeroSpeaker:SetPerk("Repairman");
  end;
  if not(HeroSpeaker:HasProperty("Engine_Op")) then
    HeroSpeaker:SetPerk("Engine_Op");
  end;
end;


--info:top=340,left=450,allvis=0;
function HeroMissile_To_Uber()
  if not(HeroSpeaker:HasProperty("Piloting_1")) then
    HeroSpeaker:SetPerk("Piloting_1");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_2")) then
    HeroSpeaker:SetPerk("Piloting_2");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_3")) then
    HeroSpeaker:SetPerk("Piloting_3");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_1")) then
    HeroSpeaker:SetPerk("Pilot_1");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_2")) then
    HeroSpeaker:SetPerk("Pilot_2");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_3")) then
    HeroSpeaker:SetPerk("Pilot_3");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_4")) then
    HeroSpeaker:SetPerk("Pilot_4");
  end;
  if not(HeroSpeaker:HasProperty("Hard_to_Kill")) then
    HeroSpeaker:SetPerk("Hard_to_Kill");
  end;
  if not(HeroSpeaker:HasProperty("Tactics")) then
    HeroSpeaker:SetPerk("Tactics");
  end;
  if not(HeroSpeaker:HasProperty("Tactics_Exp")) then
    HeroSpeaker:SetPerk("Tactics_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Learner")) then
    HeroSpeaker:SetPerk("Learner");
  end;
  if not(HeroSpeaker:HasProperty("Learner_Exp")) then
    HeroSpeaker:SetPerk("Learner_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_1")) then
    HeroSpeaker:SetPerk("Gunnery_1");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_2")) then
    HeroSpeaker:SetPerk("Gunnery_2");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_3")) then
    HeroSpeaker:SetPerk("Gunnery_3");
  end;
  if not(HeroSpeaker:HasProperty("Criticals_1")) then
    HeroSpeaker:SetPerk("Criticals_1");
  end;
  if not(HeroSpeaker:HasProperty("F_Weapon_AC")) then
    HeroSpeaker:SetPerk("F_Weapon_AC");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_Rockets")) then
    HeroSpeaker:SetPerk("Missiles_Rockets");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_2")) then
    HeroSpeaker:SetPerk("Missiles_2");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_3")) then
    HeroSpeaker:SetPerk("Missiles_3");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_4")) then
    HeroSpeaker:SetPerk("Missiles_4");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_5")) then
    HeroSpeaker:SetPerk("Missiles_5");
  end;
  if not(HeroSpeaker:HasProperty("Rockets_1")) then
    HeroSpeaker:SetPerk("Rockets_1");
  end;
  if not(HeroSpeaker:HasProperty("Rockets_2")) then
    HeroSpeaker:SetPerk("Rockets_2");
  end;
  if not(HeroSpeaker:HasProperty("Elite")) then
    HeroSpeaker:SetPerk("Elite");
  end;
  if not(HeroSpeaker:HasProperty("missile_salvo_1")) then
    HeroSpeaker:SetPerk("missile_salvo_1");
  end;
  if not(HeroSpeaker:HasProperty("missile_salvo_2")) then
    HeroSpeaker:SetPerk("missile_salvo_2");
  end;
  if not(HeroSpeaker:HasProperty("missile_salvo_3")) then
    HeroSpeaker:SetPerk("missile_salvo_3");
  end;
  if not(HeroSpeaker:HasProperty("weak_spot_1")) then
    HeroSpeaker:SetPerk("weak_spot_1");
  end;
  if not(HeroSpeaker:HasProperty("weak_spot_2")) then
    HeroSpeaker:SetPerk("weak_spot_2");
  end;
  if not(HeroSpeaker:HasProperty("weak_spot_3")) then
    HeroSpeaker:SetPerk("weak_spot_3");
  end;
  if not(HeroSpeaker:HasProperty("lucky_1")) then
    HeroSpeaker:SetPerk("lucky_1");
  end;
  if not(HeroSpeaker:HasProperty("lucky_2")) then
    HeroSpeaker:SetPerk("lucky_2");
  end;
  if not(HeroSpeaker:HasProperty("F_of_Merchant")) then
    HeroSpeaker:SetPerk("F_of_Merchant");
  end;
  if not(HeroSpeaker:HasProperty("Black_Market")) then
    HeroSpeaker:SetPerk("Black_Market");
  end;
  if not(HeroSpeaker:HasProperty("Systems_1")) then
    HeroSpeaker:SetPerk("Systems_1");
  end;
  if not(HeroSpeaker:HasProperty("Systems_2")) then
    HeroSpeaker:SetPerk("Systems_2");
  end;
  if not(HeroSpeaker:HasProperty("Countermeasures")) then
    HeroSpeaker:SetPerk("Countermeasures");
  end;
  if not(HeroSpeaker:HasProperty("Shields_Op")) then
    HeroSpeaker:SetPerk("Shields_Op");
  end;
  if not(HeroSpeaker:HasProperty("Repairman")) then
    HeroSpeaker:SetPerk("Repairman");
  end;
  if not(HeroSpeaker:HasProperty("Engine_Op")) then
    HeroSpeaker:SetPerk("Engine_Op");
  end;
end;


--info:top=340,left=610,allvis=0;
function HeroSystem_To_Uber()
  if not(HeroSpeaker:HasProperty("Piloting_1")) then
    HeroSpeaker:SetPerk("Piloting_1");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_2")) then
    HeroSpeaker:SetPerk("Piloting_2");
  end;
  if not(HeroSpeaker:HasProperty("Piloting_3")) then
    HeroSpeaker:SetPerk("Piloting_3");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_1")) then
    HeroSpeaker:SetPerk("Pilot_1");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_2")) then
    HeroSpeaker:SetPerk("Pilot_2");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_3")) then
    HeroSpeaker:SetPerk("Pilot_3");
  end;
  if not(HeroSpeaker:HasProperty("Pilot_4")) then
    HeroSpeaker:SetPerk("Pilot_4");
  end;
  if not(HeroSpeaker:HasProperty("Hard_to_Kill")) then
    HeroSpeaker:SetPerk("Hard_to_Kill");
  end;
  if not(HeroSpeaker:HasProperty("Tactics")) then
    HeroSpeaker:SetPerk("Tactics");
  end;
  if not(HeroSpeaker:HasProperty("Tactics_Exp")) then
    HeroSpeaker:SetPerk("Tactics_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Elite")) then
    HeroSpeaker:SetPerk("Elite");
  end;
  if not(HeroSpeaker:HasProperty("Learner")) then
    HeroSpeaker:SetPerk("Learner");
  end;
  if not(HeroSpeaker:HasProperty("Learner_Exp")) then
    HeroSpeaker:SetPerk("Learner_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_1")) then
    HeroSpeaker:SetPerk("Gunnery_1");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_2")) then
    HeroSpeaker:SetPerk("Gunnery_2");
  end;
  if not(HeroSpeaker:HasProperty("Gunnery_3")) then
    HeroSpeaker:SetPerk("Gunnery_3");
  end;
  if not(HeroSpeaker:HasProperty("Criticals_1")) then
    HeroSpeaker:SetPerk("Criticals_1");
  end;
  if not(HeroSpeaker:HasProperty("F_Weapon_AC")) then
    HeroSpeaker:SetPerk("F_Weapon_AC");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_Rockets")) then
    HeroSpeaker:SetPerk("Missiles_Rockets");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_2")) then
    HeroSpeaker:SetPerk("Missiles_2");
  end;
  if not(HeroSpeaker:HasProperty("Missiles_3")) then
    HeroSpeaker:SetPerk("Missiles_3");
  end;
  if not(HeroSpeaker:HasProperty("Rockets_1")) then
    HeroSpeaker:SetPerk("Rockets_1");
  end;
  if not(HeroSpeaker:HasProperty("lucky_1")) then
    HeroSpeaker:SetPerk("lucky_1");
  end;
  if not(HeroSpeaker:HasProperty("lucky_2")) then
    HeroSpeaker:SetPerk("lucky_2");
  end;
  if not(HeroSpeaker:HasProperty("F_of_Merchant")) then
    HeroSpeaker:SetPerk("F_of_Merchant");
  end;
  if not(HeroSpeaker:HasProperty("Black_Market")) then
    HeroSpeaker:SetPerk("Black_Market");
  end;
  if not(HeroSpeaker:HasProperty("hack_ship_1")) then
    HeroSpeaker:SetPerk("hack_ship_1");
  end;
  if not(HeroSpeaker:HasProperty("hack_ship_2")) then
    HeroSpeaker:SetPerk("hack_ship_2");
  end;
  if not(HeroSpeaker:HasProperty("hack_ship_3")) then
    HeroSpeaker:SetPerk("hack_ship_3");
  end;
  if not(HeroSpeaker:HasProperty("Systems_1")) then
    HeroSpeaker:SetPerk("Systems_1");
  end;
  if not(HeroSpeaker:HasProperty("Systems_2")) then
    HeroSpeaker:SetPerk("Systems_2");
  end;
  if not(HeroSpeaker:HasProperty("Systems_3")) then
    HeroSpeaker:SetPerk("Systems_3");
  end;
  if not(HeroSpeaker:HasProperty("Systems_4")) then
    HeroSpeaker:SetPerk("Systems_4");
  end;
  if not(HeroSpeaker:HasProperty("Countermeasures")) then
    HeroSpeaker:SetPerk("Countermeasures");
  end;
  if not(HeroSpeaker:HasProperty("Countermeasures_Exp")) then
    HeroSpeaker:SetPerk("Countermeasures_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Shields_Op")) then
    HeroSpeaker:SetPerk("Shields_Op");
  end;
  if not(HeroSpeaker:HasProperty("Shields_Exp")) then
    HeroSpeaker:SetPerk("Shields_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Repairman")) then
    HeroSpeaker:SetPerk("Repairman");
  end;
  if not(HeroSpeaker:HasProperty("Repairman_Exp")) then
    HeroSpeaker:SetPerk("Repairman_Exp");
  end;
  if not(HeroSpeaker:HasProperty("Engine_Op")) then
    HeroSpeaker:SetPerk("Engine_Op");
  end;
  if not(HeroSpeaker:HasProperty("Engine_Exp")) then
    HeroSpeaker:SetPerk("Engine_Exp");
  end;
end;


--info:top=340,left=30,allvis=0;
function Yana_To_Uber()
  if not(YanaSpeaker:HasProperty("Piloting_1")) then
    YanaSpeaker:SetPerk("Piloting_1");
  end;
  if not(YanaSpeaker:HasProperty("Piloting_2")) then
    YanaSpeaker:SetPerk("Piloting_2");
  end;
  if not(YanaSpeaker:HasProperty("Piloting_3")) then
    YanaSpeaker:SetPerk("Piloting_3");
  end;
  if not(YanaSpeaker:HasProperty("Pilot_1")) then
    YanaSpeaker:SetPerk("Pilot_1");
  end;
  if not(YanaSpeaker:HasProperty("Pilot_2")) then
    YanaSpeaker:SetPerk("Pilot_2");
  end;
  if not(YanaSpeaker:HasProperty("Pilot_3")) then
    YanaSpeaker:SetPerk("Pilot_3");
  end;
  if not(YanaSpeaker:HasProperty("Pilot_4")) then
    YanaSpeaker:SetPerk("Pilot_4");
  end;
  if not(YanaSpeaker:HasProperty("Hard_to_Kill")) then
    YanaSpeaker:SetPerk("Hard_to_Kill");
  end;
  if not(YanaSpeaker:HasProperty("Learner")) then
    YanaSpeaker:SetPerk("Learner");
  end;
  if not(YanaSpeaker:HasProperty("Learner_Exp")) then
    YanaSpeaker:SetPerk("Learner_Exp");
  end;
  if not(YanaSpeaker:HasProperty("Gunnery_1")) then
    YanaSpeaker:SetPerk("Gunnery_1");
  end;
  if not(YanaSpeaker:HasProperty("Gunnery_2")) then
    YanaSpeaker:SetPerk("Gunnery_2");
  end;
  if not(YanaSpeaker:HasProperty("Gunnery_3")) then
    YanaSpeaker:SetPerk("Gunnery_3");
  end;
  if not(YanaSpeaker:HasProperty("burst_1")) then
    YanaSpeaker:SetPerk("burst_1");
  end;
  if not(YanaSpeaker:HasProperty("burst_2")) then
    YanaSpeaker:SetPerk("burst_2");
  end;
  if not(YanaSpeaker:HasProperty("F_Weapon_AC")) then
    YanaSpeaker:SetPerk("F_Weapon_AC");
  end;
  if not(YanaSpeaker:HasProperty("Missiles_Rockets")) then
    YanaSpeaker:SetPerk("Missiles_Rockets");
  end;
  if not(YanaSpeaker:HasProperty("Missiles_2")) then
    YanaSpeaker:SetPerk("Missiles_2");
  end;
  if not(YanaSpeaker:HasProperty("Missiles_3")) then
    YanaSpeaker:SetPerk("Missiles_3");
  end;
  if not(YanaSpeaker:HasProperty("Rockets_1")) then
    YanaSpeaker:SetPerk("Rockets_1");
  end;
  if not(YanaSpeaker:HasProperty("Systems_1")) then
    YanaSpeaker:SetPerk("Systems_1");
  end;
  if not(YanaSpeaker:HasProperty("Systems_2")) then
    YanaSpeaker:SetPerk("Systems_2");
  end;
  if not(YanaSpeaker:HasProperty("Systems_3")) then
    YanaSpeaker:SetPerk("Systems_3");
  end;
  if not(YanaSpeaker:HasProperty("Systems_4")) then
    YanaSpeaker:SetPerk("Systems_4");
  end;
  if not(YanaSpeaker:HasProperty("Elite")) then
    YanaSpeaker:SetPerk("Elite");
  end;
  if not(YanaSpeaker:HasProperty("Countermeasures")) then
    YanaSpeaker:SetPerk("Countermeasures");
  end;
  if not(YanaSpeaker:HasProperty("Countermeasures_Exp")) then
    YanaSpeaker:SetPerk("Countermeasures_Exp");
  end;
  if not(YanaSpeaker:HasProperty("Shields_Op")) then
    YanaSpeaker:SetPerk("Shields_Op");
  end;
  if not(YanaSpeaker:HasProperty("Shields_Exp")) then
    YanaSpeaker:SetPerk("Shields_Exp");
  end;
  if not(YanaSpeaker:HasProperty("Repairman")) then
    YanaSpeaker:SetPerk("Repairman");
  end;
  if not(YanaSpeaker:HasProperty("Repairman_Exp")) then
    YanaSpeaker:SetPerk("Repairman_Exp");
  end;
  if not(YanaSpeaker:HasProperty("Engine_Op")) then
    YanaSpeaker:SetPerk("Engine_Op");
  end;
  if not(YanaSpeaker:HasProperty("Engine_Exp")) then
    YanaSpeaker:SetPerk("Engine_Exp");
  end;
  if not(YanaSpeaker:HasProperty("Tech_Adaptation")) then
    YanaSpeaker:SetPerk("Tech_Adaptation");
  end;
  if not(YanaSpeaker:HasProperty("Tech_Adaptation_Alien")) then
    YanaSpeaker:SetPerk("Tech_Adaptation_Alien");
  end;
end;


--info:top=370,left=130,allvis=0;
function In_Matrix()
  new_SetGroupRelations("BerserkGroup_1", PLAYER_GROUP, "CF");
  SetTriggers_Attack_Berserk();
  Set_Targets();
  Timer_Seq(300, After_Testing);
  StartDialog("Dialog3");
end;


--info:top=410,left=50,allvis=0;
function SetTriggers_Attack_Berserk()
  lYana = 0;
  local count = flight_ber01:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber01:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber02:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber02:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber03:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber03:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber04:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber04:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber05:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber05:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber06:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber06:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber07:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber07:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber08:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber08:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber09:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber09:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber10:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber10:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber11:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber11:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber12:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber12:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber13:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber13:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber14:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber14:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber15:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber15:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber16:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber16:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber17:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber17:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber18:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber18:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
  local count = flight_ber19:GetPilotCount();
  for i=0, count, 1 do
    local pilot_tmp = flight_ber19:GetPilotByNumber(i);
    local ship_tmp = pilot_tmp:GetShip();
    NewTrigger("died", TrueCondition, Attack_Berserk, ship_tmp);
  end;
end;


--info:top=450,left=50,allvis=0;
function Attack_Berserk()
  if (lYana==0) then
    lYana = 1;
    HeroSpeaker:Message("#L_Hero_01", 4, "Yana_After_Attack");
  end;
end;


--info:top=490,left=50,allvis=0;
function Yana_After_Attack()
  YanaSpeaker:Message("#L_Yana_01", 5);
end;


--info:top=410,left=280,allvis=0;
function Set_Targets()
  posTargets = MINE:GetPosition()+Vector3(200, 0, -200);
  NewFlight("Uel_Group", "target1", "a_target", "BerserkBot", posTargets, Vector3(0, 0, 1));
  CreateNavPoint("#L_taget_buoy", posTargets, "nav_target.dds", RGB(255,255,255), ship_target1_1);
  NewFlight("Uel_Group", "target2", "a_target", "BerserkBot", posTargets+Vector3(10, 0, 0), Vector3(0, 0, 1));
  CreateNavPoint("#L_taget_buoy", posTargets+Vector3(10, 0, 0), "nav_target.dds", RGB(255,255,255), ship_target2_1);
  NewFlight("Uel_Group", "target3", "a_target", "BerserkBot", posTargets+Vector3(20, 0, 0), Vector3(0, 0, 1));
  CreateNavPoint("#L_taget_buoy", posTargets+Vector3(20, 0, 0), "nav_target.dds", RGB(255,255,255), ship_target3_1);
  NewFlight("Uel_Group", "target4", "a_target", "BerserkBot", posTargets+Vector3(0, 10, 0), Vector3(0, 0, 1));
  CreateNavPoint("#L_taget_buoy", posTargets+Vector3(0, 10, 0), "nav_target.dds", RGB(255,255,255), ship_target4_1);
  NewFlight("Uel_Group", "target5", "a_target", "BerserkBot", posTargets+Vector3(10, 10, 0), Vector3(0, 0, 1));
  CreateNavPoint("#L_taget_buoy", posTargets+Vector3(10, 10, 0), "nav_target.dds", RGB(255,255,255), ship_target5_1);
  NewFlight("Uel_Group", "target6", "a_target", "BerserkBot", posTargets+Vector3(20, 10, 0), Vector3(0, 0, 1));
  CreateNavPoint("#L_taget_buoy", posTargets+Vector3(20, 10, 0), "nav_target.dds", RGB(255,255,255), ship_target6_1);
  lTarget = 0;
  NewTrigger("f_died", TrueCondition, Attack_Target, flight_target1);
  NewTrigger("f_died", TrueCondition, Attack_Target, flight_target2);
  NewTrigger("f_died", TrueCondition, Attack_Target, flight_target3);
  NewTrigger("f_died", TrueCondition, Attack_Target, flight_target4);
  NewTrigger("f_died", TrueCondition, Attack_Target, flight_target5);
  NewTrigger("f_died", TrueCondition, Attack_Target, flight_target6);
end;


--info:top=450,left=280,allvis=0;
function Attack_Target()
  if (lTarget==0) then
    lTarget = 1;
    YanaSpeaker:Message("#L_Yana_02", 9, "After_Attack_Target_01");
  end;
end;


--info:top=490,left=280,allvis=0;
function After_Attack_Target_01()
  HeroSpeaker:Message("#L_Hero_02", 4, "After_Attack_Target_02");
end;


--info:top=530,left=280,allvis=0;
function After_Attack_Target_02()
  YanaSpeaker:Message("#L_Yana_03", 5);
end;


--info:top=520,left=130,allvis=0;
function After_Testing()
  trig_TestOutside = NewTrigger("side_outside", TrueCondition, Need_Return, PLAYER_TEAM, MINE:GetPosition(), 150);
  trig_Timer = NewTrigger("timer", TrueCondition, Test_Done, 5);
end;


--info:top=550,left=170,allvis=0;
function Need_Return()
  trig_Timer:Delete();
  trig_TestOutside:Delete();
  if (GetQuestState("quest_16e_02")~=QUEST_PROCESS) then
    AddQuest("quest_16e_02", "#L_Quest_16e_02a", "#L_Quest_16e_02b", QUEST_PROCESS);
  end;
  Timer_Seq(10, After_Testing);
end;


--info:top=580,left=130,allvis=0;
function Test_Done()
  trig_Timer:Delete();
  trig_TestOutside:Delete();
  SetQuestState("quest_16e_02", QUEST_DONE);
  SetNormalTimeMode();
--------------------------------------------------------------------------------
--  StartDialog("Dialog4");
  count_or_go_on();
--------------------------------------------------------------------------------
end;


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function count_or_go_on()
  if (pilot_El) or (pilot_Ace) or (pilot_Astra) or (pilot_Bavard) or (pilot_Joker) then
    if (count_pilots() >= 3) then
      choose_pilot();
    else
      StartDialog("Dialog4");
    end;
  else
    StartDialog("Dialog4");
  end; 
end;

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------



--info:top=620,left=130,allvis=0;
function Take_On_Crew()
  if (trig_TakeCrew) then
    trig_TakeCrew_Out:Activate();
  else
    AddPilotToPlayer(UelSpeaker);
  end;
  StartDialog("Dialog5");
end;


--info:top=680,left=260,allvis=0;
function Remove_All_Copyes()
  for i=1, getn(persTable) do
    local pilot = persTable[i];
    local Player_Team = CreateTeam(PLAYER_TEAM);
    if (pilot:IsInBase()) or (pilot:IsBasePilot()) then
      Player_Team:RemovePilot(pilot);
      pilot:Kill();
    else
      local pilotShip = pilot:GetShip();
      local pilotFlight = pilot:GetFlight();
      if (pilotFlight:GetPilotCount()==1) then
        Player_Group:RemoveFlight(pilotFlight);
        pilotFlight:Delete();
        pilot:Kill();
      else
        local NewpilotFlight = Player_Group:CreateFlight("NewpilotFlight");
        NewpilotFlight:AddShip(pilotShip);
        Player_Group:RemoveFlight(NewpilotFlight);
        NewpilotFlight:Delete();
        pilot:Kill();
      end;
    end;
  end;
  persTable = {};
end;


--info:top=680,left=30,allvis=0;
function Add_Uel2()
  Add_UelCopy("Uel2", Uel2_To_Uber);
end;


--info:top=680,left=110,allvis=0;
function Add_Uel3()
  Add_UelCopy("Uel3", Uel3_To_Uber);
end;


--info:top=680,left=190,allvis=0;
function Add_Uel4()
  Add_UelCopy("Uel4", Uel4_To_Uber);
end;


--info:top=730,left=110,allvis=0;
function Add_UelCopy(name, funcToUber)
  local count = getn(persTable);
  if (count<3) then
    local pilot = CreatePilot(name);
    funcToUber(pilot);
    AddPilotToPlayer(pilot);
    count = count + 1;
    persTable[count] = pilot;
  else
    OutputToScreenLog("#L_sys_01", 7);
  end;
end;


--info:top=750,left=30,allvis=0;
function Uel2_To_Uber(pilot)
  if not(pilot:HasProperty("Piloting_1")) then
    pilot:SetPerk("Piloting_1");
  end;
  if not(pilot:HasProperty("Piloting_2")) then
    pilot:SetPerk("Piloting_2");
  end;
  if not(pilot:HasProperty("Piloting_3")) then
    pilot:SetPerk("Piloting_3");
  end;
  if not(pilot:HasProperty("Piloting_4")) then
    pilot:SetPerk("Piloting_4");
  end;
  if not(pilot:HasProperty("Hard_to_Kill")) then
    pilot:SetPerk("Hard_to_Kill");
  end;
  if not(pilot:HasProperty("Pilot_1")) then
    pilot:SetPerk("Pilot_1");
  end;
  if not(pilot:HasProperty("Pilot_2")) then
    pilot:SetPerk("Pilot_2");
  end;
  if not(pilot:HasProperty("Pilot_3")) then
    pilot:SetPerk("Pilot_3");
  end;
  if not(pilot:HasProperty("Pilot_4")) then
    pilot:SetPerk("Pilot_4");
  end;
  if not(pilot:HasProperty("Missiles_Rockets")) then
    pilot:SetPerk("Missiles_Rockets");
  end;
  if not(pilot:HasProperty("Missiles_2")) then
    pilot:SetPerk("Missiles_2");
  end;
  if not(pilot:HasProperty("Missiles_3")) then
    pilot:SetPerk("Missiles_3");
  end;
  if not(pilot:HasProperty("Gunnery_1")) then
    pilot:SetPerk("Gunnery_1");
  end;
  if not(pilot:HasProperty("Gunnery_2")) then
    pilot:SetPerk("Gunnery_2");
  end;
  if not(pilot:HasProperty("Gunnery_3")) then
    pilot:SetPerk("Gunnery_3");
  end;
  if not(pilot:HasProperty("Gunnery_4")) then
    pilot:SetPerk("Gunnery_4");
  end;
  if not(pilot:HasProperty("Gunnery_5")) then
    pilot:SetPerk("Gunnery_5");
  end;
  if not(pilot:HasProperty("Elite")) then
    pilot:SetPerk("Elite");
  end;
  if not(pilot:HasProperty("F_Weapon_HC")) and not(pilot:HasProperty("F_Weapon_Laser")) then
    pilot:SetPerk("F_Weapon_HC");
  end;
  if not(pilot:HasProperty("finesse_1")) then
    pilot:SetPerk("finesse_1");
  end;
  if not(pilot:HasProperty("finesse_2")) then
    pilot:SetPerk("finesse_2");
  end;
  if not(pilot:HasProperty("finesse_3")) then
    pilot:SetPerk("finesse_3");
  end;
  if not(pilot:HasProperty("burst_1")) then
    pilot:SetPerk("burst_1");
  end;
  if not(pilot:HasProperty("burst_2")) then
    pilot:SetPerk("burst_2");
  end;
  if not(pilot:HasProperty("burst_3")) then
    pilot:SetPerk("burst_3");
  end;
  if not(pilot:HasProperty("burst_4")) then
    pilot:SetPerk("burst_4");
  end;
  if not(pilot:HasProperty("Systems_1")) then
    pilot:SetPerk("Systems_1");
  end;
  if not(pilot:HasProperty("Systems_2")) then
    pilot:SetPerk("Systems_2");
  end;
  if not(pilot:HasProperty("Systems_3")) then
    pilot:SetPerk("Systems_3");
  end;
  if not(pilot:HasProperty("Gun_Dispersion")) then
    pilot:SetPerk("Gun_Dispersion");
  end;
  if not(pilot:HasProperty("Countermeasures")) then
    pilot:SetPerk("Countermeasures");
  end;
  if not(pilot:HasProperty("Shields_Op")) then
    pilot:SetPerk("Shields_Op");
  end;
  if not(pilot:HasProperty("Repairman")) then
    pilot:SetPerk("Repairman");
  end;
  if not(pilot:HasProperty("Engine_Op")) then
    pilot:SetPerk("Engine_Op");
  end;
  if not(pilot:HasProperty("Fearless")) then
    pilot:SetPerk("Fearless");
  end;
end;


--info:top=780,left=90,allvis=0;
function Uel3_To_Uber(pilot)
  if not(pilot:HasProperty("Piloting_1")) then
    pilot:SetPerk("Piloting_1");
  end;
  if not(pilot:HasProperty("Piloting_2")) then
    pilot:SetPerk("Piloting_2");
  end;
  if not(pilot:HasProperty("Piloting_3")) then
    pilot:SetPerk("Piloting_3");
  end;
  if not(pilot:HasProperty("Hard_to_Kill")) then
    pilot:SetPerk("Hard_to_Kill");
  end;
  if not(pilot:HasProperty("Pilot_1")) then
    pilot:SetPerk("Pilot_1");
  end;
  if not(pilot:HasProperty("Pilot_2")) then
    pilot:SetPerk("Pilot_2");
  end;
  if not(pilot:HasProperty("Pilot_3")) then
    pilot:SetPerk("Pilot_3");
  end;
  if not(pilot:HasProperty("Pilot_4")) then
    pilot:SetPerk("Pilot_4");
  end;
  if not(pilot:HasProperty("Gunnery_1")) then
    pilot:SetPerk("Gunnery_1");
  end;
  if not(pilot:HasProperty("Gunnery_2")) then
    pilot:SetPerk("Gunnery_2");
  end;
  if not(pilot:HasProperty("Gunnery_3")) then
    pilot:SetPerk("Gunnery_3");
  end;
  if not(pilot:HasProperty("Criticals_1")) then
    pilot:SetPerk("Criticals_1");
  end;
  if not(pilot:HasProperty("Missiles_Rockets")) then
    pilot:SetPerk("Missiles_Rockets");
  end;
  if not(pilot:HasProperty("Missiles_2")) then
    pilot:SetPerk("Missiles_2");
  end;
  if not(pilot:HasProperty("Missiles_3")) then
    pilot:SetPerk("Missiles_3");
  end;
  if not(pilot:HasProperty("Missiles_4")) then
    pilot:SetPerk("Missiles_4");
  end;
  if not(pilot:HasProperty("Rockets_1")) then
    pilot:SetPerk("Rockets_1");
  end;
  if not(pilot:HasProperty("Rockets_2")) then
    pilot:SetPerk("Rockets_2");
  end;
  if not(pilot:HasProperty("missile_salvo_1")) then
    pilot:SetPerk("missile_salvo_1");
  end;
  if not(pilot:HasProperty("missile_salvo_2")) then
    pilot:SetPerk("missile_salvo_2");
  end;
  if not(pilot:HasProperty("missile_salvo_3")) then
    pilot:SetPerk("missile_salvo_3");
  end;
  if not(pilot:HasProperty("missile_salvo_4")) then
    pilot:SetPerk("missile_salvo_4");
  end;
  if not(pilot:HasProperty("weak_spot_1")) then
    pilot:SetPerk("weak_spot_1");
  end;
  if not(pilot:HasProperty("weak_spot_2")) then
    pilot:SetPerk("weak_spot_2");
  end;
  if not(pilot:HasProperty("weak_spot_3")) then
    pilot:SetPerk("weak_spot_3");
  end;
  if not(pilot:HasProperty("Elite")) then
    pilot:SetPerk("Elite");
  end;
  if not(pilot:HasProperty("Systems_1")) then
    pilot:SetPerk("Systems_1");
  end;
  if not(pilot:HasProperty("Systems_2")) then
    pilot:SetPerk("Systems_2");
  end;
  if not(pilot:HasProperty("Systems_3")) then
    pilot:SetPerk("Systems_3");
  end;
  if not(pilot:HasProperty("Missile_Range")) then
    pilot:SetPerk("Missile_Range");
  end;
  if not(pilot:HasProperty("Countermeasures")) then
    pilot:SetPerk("Countermeasures");
  end;
  if not(pilot:HasProperty("Shields_Op")) then
    pilot:SetPerk("Shields_Op");
  end;
  if not(pilot:HasProperty("Repairman")) then
    pilot:SetPerk("Repairman");
  end;
  if not(pilot:HasProperty("Engine_Op")) then
    pilot:SetPerk("Engine_Op");
  end;
  if not(pilot:HasProperty("Fearless")) then
    pilot:SetPerk("Fearless");
  end;
end;


--info:top=760,left=190,allvis=0;
function Uel4_To_Uber(pilot)
  if not(pilot:HasProperty("Piloting_1")) then
    pilot:SetPerk("Piloting_1");
  end;
  if not(pilot:HasProperty("Piloting_2")) then
    pilot:SetPerk("Piloting_2");
  end;
  if not(pilot:HasProperty("Piloting_3")) then
    pilot:SetPerk("Piloting_3");
  end;
  if not(pilot:HasProperty("Pilot_1")) then
    pilot:SetPerk("Pilot_1");
  end;
  if not(pilot:HasProperty("Pilot_2")) then
    pilot:SetPerk("Pilot_2");
  end;
  if not(pilot:HasProperty("Pilot_3")) then
    pilot:SetPerk("Pilot_3");
  end;
  if not(pilot:HasProperty("Pilot_4")) then
    pilot:SetPerk("Pilot_4");
  end;
  if not(pilot:HasProperty("Gunnery_1")) then
    pilot:SetPerk("Gunnery_1");
  end;
  if not(pilot:HasProperty("Gunnery_2")) then
    pilot:SetPerk("Gunnery_2");
  end;
  if not(pilot:HasProperty("Gunnery_3")) then
    pilot:SetPerk("Gunnery_3");
  end;
  if not(pilot:HasProperty("Missiles_Rockets")) then
    pilot:SetPerk("Missiles_Rockets");
  end;
  if not(pilot:HasProperty("Missiles_2")) then
    pilot:SetPerk("Missiles_2");
  end;
  if not(pilot:HasProperty("Missiles_3")) then
    pilot:SetPerk("Missiles_3");
  end;
  if not(pilot:HasProperty("Elite")) then
    pilot:SetPerk("Elite");
  end;
  if not(pilot:HasProperty("hack_ship_1")) then
    pilot:SetPerk("hack_ship_1");
  end;
  if not(pilot:HasProperty("hack_ship_2")) then
    pilot:SetPerk("hack_ship_2");
  end;
  if not(pilot:HasProperty("hack_ship_3")) then
    pilot:SetPerk("hack_ship_3");
  end;
  if not(pilot:HasProperty("Systems_1")) then
    pilot:SetPerk("Systems_1");
  end;
  if not(pilot:HasProperty("Systems_2")) then
    pilot:SetPerk("Systems_2");
  end;
  if not(pilot:HasProperty("Systems_3")) then
    pilot:SetPerk("Systems_3");
  end;
  if not(pilot:HasProperty("Systems_4")) then
    pilot:SetPerk("Systems_4");
  end;
  if not(pilot:HasProperty("polarization_1")) then
    pilot:SetPerk("polarization_1");
  end;
  if not(pilot:HasProperty("polarization_2")) then
    pilot:SetPerk("polarization_2");
  end;
  if not(pilot:HasProperty("polarization_3")) then
    pilot:SetPerk("polarization_3");
  end;
  if not(pilot:HasProperty("polarization_4")) then
    pilot:SetPerk("polarization_4");
  end;
  if not(pilot:HasProperty("Countermeasures")) then
    pilot:SetPerk("Countermeasures");
  end;
  if not(pilot:HasProperty("Countermeasures_Exp")) then
    pilot:SetPerk("Countermeasures_Exp");
  end;
  if not(pilot:HasProperty("Shields_Op")) then
    pilot:SetPerk("Shields_Op");
  end;
  if not(pilot:HasProperty("Shields_Exp")) then
    pilot:SetPerk("Shields_Exp");
  end;
  if not(pilot:HasProperty("Repairman")) then
    pilot:SetPerk("Repairman");
  end;
  if not(pilot:HasProperty("Repairman_Exp")) then
    pilot:SetPerk("Repairman_Exp");
  end;
  if not(pilot:HasProperty("Engine_Op")) then
    pilot:SetPerk("Engine_Op");
  end;
  if not(pilot:HasProperty("Engine_Exp")) then
    pilot:SetPerk("Engine_Exp");
  end;
  if not(pilot:HasProperty("Fearless")) then
    pilot:SetPerk("Fearless");
  end;
end;


--info:top=820,left=190,allvis=0;
function GoTo_Stock()
  if not(trig_TakeCrew) then
    LineToStock = CreateLine(np_mine, np_stock, RGB(20,80,220), .3, TRUE, .2, 1);
    trig_TakeCrew_Out = NewTrigger("outside", TrueCondition, TakeCrew_Activate, mothership, MINE:GetPosition(), 150);
    trig_TakeCrew = NewTrigger("inside", TrueCondition, Take_On_Crew, mothership, MINE:GetPosition(), 125, FALSE);
    trig_Stock = NewTrigger("inside", TrueCondition, Near_Stock, mothership, STOCK:GetDockingPosition(), 25);
  end;
end;


--info:top=850,left=220,allvis=0;
function TakeCrew_Activate()
  trig_TakeCrew:Activate();
end;


--info:top=870,left=190,allvis=0;
function Near_Stock()
  LineToStock:Delete();
  LineToStock = NIL;
  trig_StockOut = NewTrigger("outside", TrueCondition, To_Eridan, mothership, STOCK:GetDockingPosition(), 50);
end;


--info:top=910,left=190,allvis=0;
function To_Eridan()
  local pos = mothership:GetPosition();
  local orn = mothership:GetVectorOrientation();
  local glow_orn = mothership:GetVectorOrientation();
  orn.x = orn.x * 25;
  orn.y = orn.y * 25;
  orn.z = orn.z * 25;
  glow_orn.x = -glow_orn.x;
  glow_orn.y = -glow_orn.y;
  glow_orn.z = -glow_orn.z;
  tmpNull = CreateCarcass("NULL", pos+orn, glow_orn); 
  MothershipFlight:Move(pos+orn);
  tmpNull:AddMeshFX("PARTICLESYSTEM", "portal.pst", glow_orn);
  tmpNull:AddMeshFX("PARTICLESYSTEM", "portal_rotate.pst", glow_orn);
  mothership:PlayFX("Portal Out.shfx");
  Anim_1 = CreateMovie(_TARGETCAM);
  Anim_1:SetLength(5);
  Anim_1:SetInterpolate(_LINEAR);
  Anim_1:SetTarget(mothership);
  Anim_1:InitMovie(1, TRUE, 1);
  Anim_1:AddPosKey(mothership:GetPosition()+Vector3(orn.x*(-1.827)+orn.z*0.8134, 10-orn.y, orn.z*(-1.827)-orn.x*0.8134), 5);
  Anim_1:AddScriptKey("Uel_Warn", 1);
  Anim_1:Play();
  Anim_1:AttachEscapeScript("GoTo_Eridan");
  Anim_1:AttachAction("GoTo_Eridan");
end;


--info:top=940,left=220,allvis=0;
function Uel_Warn()
  UelSpeaker:Message("#L_Uel_01", 4);
end;


--info:top=960,left=190,allvis=0;
function GoTo_Eridan()
  CustomTeleportate("zebos", "eridan", "long_jump");
end;


--info:top=120,left=370,allvis=0;
function StartInitMission()
  UelTeam = CreateTeam("Berserk");
  
  MothershipPilot = mothership:GetPilot();
  MothershipFlight = MothershipPilot:GetFlight();

  Player_Group = MothershipPilot:GetGroup();
  Uel_Group = UelTeam:CreateGroup("Uel_Group");
  new_SetGroupRelations("Uel_Group", PLAYER_GROUP, "N");

  HeroSpeaker = GetPilot("Hero");
  YanaSpeaker = GetPilot("Yana");
  UelDSpeaker = GetPilot("Uel2");
  UelTSpeaker = GetPilot("Uel3");
  UelSpeaker = CreatePilot("Uel");
  Uel_To_Uber();
  persTable = {};
  persTable[1] = UelDSpeaker;
  persTable[2] = UelTSpeaker;

-- вылет мазершипа
  CreatePortalGlow(Vector3(-100, 200, -600), Vector3(0, 0, 1), 7);
  mothership:SetPosition(Vector3(-100, 200, -600));
  mothership:SetOrientation(CreateQuaternionFromVector3(Vector3(0, 0, 1)));
  mothership:PlayFX("Portal Out.shfx");
  mothership:ApplyImpulse(15, Vector3(0, 0, 1));
  FocusOn({mothership}, Vector3(0.4067, 0.4, -0.9135), 60);

  EnablePortals("zebos", "gaeon", FALSE);
  DisableRandom();
  trig_AttackBerserk = NewTrigger("reps", TrueCondition, Before_Matrix, Player_Group, BerserkGroup_1, RELATION_WAR);
end;


--info:top=150,left=400,allvis=0;
function Uel_To_Uber()
  if not(UelSpeaker:HasProperty("Piloting_1")) then
    UelSpeaker:SetPerk("Piloting_1");
  end;
  if not(UelSpeaker:HasProperty("Piloting_2")) then
    UelSpeaker:SetPerk("Piloting_2");
  end;
  if not(UelSpeaker:HasProperty("Piloting_3")) then
    UelSpeaker:SetPerk("Piloting_3");
  end;
  if not(UelSpeaker:HasProperty("Pilot_1")) then
    UelSpeaker:SetPerk("Pilot_1");
  end;
  if not(UelSpeaker:HasProperty("Pilot_2")) then
    UelSpeaker:SetPerk("Pilot_2");
  end;
  if not(UelSpeaker:HasProperty("Pilot_3")) then
    UelSpeaker:SetPerk("Pilot_3");
  end;
  if not(UelSpeaker:HasProperty("Pilot_4")) then
    UelSpeaker:SetPerk("Pilot_4");
  end;
  if not(UelSpeaker:HasProperty("Gunnery_1")) then
    UelSpeaker:SetPerk("Gunnery_1");
  end;
  if not(UelSpeaker:HasProperty("Gunnery_2")) then
    UelSpeaker:SetPerk("Gunnery_2");
  end;
  if not(UelSpeaker:HasProperty("Gunnery_3")) then
    UelSpeaker:SetPerk("Gunnery_3");
  end;
  if not(UelSpeaker:HasProperty("Missiles_Rockets")) then
    UelSpeaker:SetPerk("Missiles_Rockets");
  end;
  if not(UelSpeaker:HasProperty("Missiles_2")) then
    UelSpeaker:SetPerk("Missiles_2");
  end;
  if not(UelSpeaker:HasProperty("Missiles_3")) then
    UelSpeaker:SetPerk("Missiles_3");
  end;
  if not(UelSpeaker:HasProperty("Elite")) then
    UelSpeaker:SetPerk("Elite");
  end;
  if not(UelSpeaker:HasProperty("hack_berserk_1")) then
    UelSpeaker:SetPerk("hack_berserk_1");
  end;
  if not(UelSpeaker:HasProperty("jinxed_1")) then
    UelSpeaker:SetPerk("jinxed_1");
  end;
  if not(UelSpeaker:HasProperty("jinxed_2")) then
    UelSpeaker:SetPerk("jinxed_2");
  end;
  if not(UelSpeaker:HasProperty("summon_berserk_1")) then
    UelSpeaker:SetPerk("summon_berserk_1");
  end;
  if not(UelSpeaker:HasProperty("summon_berserk_2")) then
    UelSpeaker:SetPerk("summon_berserk_2");
  end;
  if not(UelSpeaker:HasProperty("summon_berserk_3")) then
    UelSpeaker:SetPerk("summon_berserk_3");
  end;
  if not(UelSpeaker:HasProperty("summon_berserk_4")) then
    UelSpeaker:SetPerk("summon_berserk_4");
  end;
  if not(UelSpeaker:HasProperty("Systems_1")) then
    UelSpeaker:SetPerk("Systems_1");
  end;
  if not(UelSpeaker:HasProperty("Systems_2")) then
    UelSpeaker:SetPerk("Systems_2");
  end;
  if not(UelSpeaker:HasProperty("Systems_3")) then
    UelSpeaker:SetPerk("Systems_3");
  end;
  if not(UelSpeaker:HasProperty("Systems_4")) then
    UelSpeaker:SetPerk("Systems_4");
  end;
  if not(UelSpeaker:HasProperty("polarization_1")) then
    UelSpeaker:SetPerk("polarization_1");
  end;
  if not(UelSpeaker:HasProperty("polarization_2")) then
    UelSpeaker:SetPerk("polarization_2");
  end;
  if not(UelSpeaker:HasProperty("Countermeasures")) then
    UelSpeaker:SetPerk("Countermeasures");
  end;
  if not(UelSpeaker:HasProperty("Countermeasures_Exp")) then
    UelSpeaker:SetPerk("Countermeasures_Exp");
  end;
  if not(UelSpeaker:HasProperty("Shields_Op")) then
    UelSpeaker:SetPerk("Shields_Op");
  end;
  if not(UelSpeaker:HasProperty("Shields_Exp")) then
    UelSpeaker:SetPerk("Shields_Exp");
  end;
  if not(UelSpeaker:HasProperty("Repairman")) then
    UelSpeaker:SetPerk("Repairman");
  end;
  if not(UelSpeaker:HasProperty("Repairman_Exp")) then
    UelSpeaker:SetPerk("Repairman_Exp");
  end;
  if not(UelSpeaker:HasProperty("Engine_Op")) then
    UelSpeaker:SetPerk("Engine_Op");
  end;
  if not(UelSpeaker:HasProperty("Engine_Exp")) then
    UelSpeaker:SetPerk("Engine_Exp");
  end;
  if not(UelSpeaker:HasProperty("Fearless")) then
    UelSpeaker:SetPerk("Fearless");
  end;
end;


--info:top=170,left=370,allvis=0;
function Before_Matrix()
  mothership:Blow();
end;


--info:top=80,left=130,allvis=0;
function ACTION_INIT()
  SetQuestLabel("CurrentQuest","16e");
  StartInitMission();

  Timer_Seq(5, StartMission);
  return TRUE;
end;


--info:top=80,left=570,allvis=0;
function ACTION_LEAVELOCATION()
  if (tmpNull) then tmpNull:Delete(); end;
  EnablePortals("zebos", "gaeon", TRUE);
  EnableRandom();
  SetQuestLabel("EridanPermit","yes");
  QuestActionDone();

  return TRUE;
end;


--info:top=80,left=470,allvis=0;
function ACTION_FINI()

  return TRUE;
end;
