------------------------------------------------------------
--     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=110,left=80,allvis=0;
function StartMission()
  StartDialog("Dialog2");
end;


--info:top=150,left=80,allvis=0;
function GoTo_Station()
  nav_target = CreateNavPoint("", xyz_trade, "nav_void.dds", RGB(255,255,255));
  LineToStation = CreateLine(NP_PORTAL_R, nav_target, RGB(20,80,220), .3, TRUE, .2, 1);
  flight_kfni1:Move(MINING:GetPosition()+Vector3(30, 20, -30));
  flight_kfni2:Escort(ship_kfni1_1);
  flight_kfni3:Escort(ship_merc1_1);
  flight_kfni4:Escort(ship_merc1_1);
  flight_merc1:Move(xyz_trade+Vector3(0, 40, 0));
  Timer_Seq(10, Test_Distance);
  NewTrigger("inside", TrueCondition, Near_Station, ship_merc1_1, xyz_trade, 100);
  LaVertiSpeaker:Message("#L_LaVerti_01", 4, "Path_Dialog_1");
end;


--info:top=180,left=140,allvis=0;
function Test_Distance()
  if (flight_merc1:IsAlive()) then
    posLaVerti=ship_merc1_1:GetPosition();
    if (not(HeroSpeaker:IsInBase())) and (not(HeroSpeaker:IsBasePilot())) then
      HeroShip = HeroSpeaker:GetShip();
      posHero = HeroShip:GetPosition();
      if (posHero.x==0) and (posHero.y==0) and (posHero.z==0) then
        HeroDistance = 0;
      else
        HeroDistance = VectorLength(posHero,posLaVerti);
      end;
    else
      HeroDistance = 0;
    end;
    if (not(LastochkaSpeaker:IsInBase())) and (not(LastochkaSpeaker:IsBasePilot())) then
      LastochkaShip = LastochkaSpeaker:GetShip();
      posLastochka = LastochkaShip:GetPosition();
      if (posLastochka.x==0) and (posLastochka.y==0) and (posLastochka.z==0) then
        LastochkaDistance = 0;
      else
        LastochkaDistance = VectorLength(posLastochka,posLaVerti);
      end;
    else
      LastochkaDistance = 0;
    end;
    if (not(SedoySpeaker:IsInBase())) and (not(SedoySpeaker:IsBasePilot())) then
      SedoyShip = SedoySpeaker:GetShip();
      posSedoy = SedoyShip:GetPosition();
      if (posSedoy.x==0) and (posSedoy.y==0) and (posSedoy.z==0) then
        SedoyDistance = 0;
      else
        SedoyDistance = VectorLength(posSedoy,posLaVerti);
      end;
    else
      SedoyDistance = 0;
    end;
    mainDistance = VectorLength(mothership:GetPosition(),posLaVerti);
    if (HeroDistance>300) or (LastochkaDistance>300) or (SedoyDistance>300) or (mainDistance>300) then
      Timer_Seq(1, Attack_Caravan);
    else
      Timer_Seq(10, Test_Distance);
    end;
  end;
end;


--info:top=210,left=100,allvis=0;
function Path_Dialog_1()
  KfniSpeaker:Message("#L_kfni_02", 4, "Path_Dialog_2");
end;


--info:top=250,left=100,allvis=0;
function Path_Dialog_2()
  LaVertiSpeaker:Message("#L_LaVerti_02", 5, "Path_Dialog_3");
end;


--info:top=290,left=100,allvis=0;
function Path_Dialog_3()
  KfniSpeaker:Message("#L_kfni_03", 5, "Path_Dialog_4");
end;


--info:top=330,left=100,allvis=0;
function Path_Dialog_4()
  LaVertiSpeaker:Message("#L_LaVerti_03", 5, "Path_Dialog_5");
end;


--info:top=370,left=100,allvis=0;
function Path_Dialog_5()
  KfniSpeaker:Message("#L_kfni_04", 10, "Path_Dialog_6");
end;


--info:top=410,left=100,allvis=0;
function Path_Dialog_6()
  LaVertiSpeaker:Message("#L_LaVerti_04", 5);
end;


--info:top=440,left=80,allvis=0;
function Near_Station()
  RemovePost("mail_009a_5");
  RemovePost("mail_009a_6");
  RemovePost("mail_009c_1");
  LineToStation:Delete();
  LineToStation = NIL;
  nav_target:Delete();
  nav_target = NIL;
  SetQuestState("quest_9c_02", QUEST_DONE);
  SetNormalTimeMode();
  flight_merc1:Stop();
  MothershipFlight:Stop();
  flight_merc3 = Merc_Group:CreateFlight("flight_merc3");
  flight_merc3:AddShip(ship_merc1_1);
  flight_merc4 = Merc_Group:CreateFlight("flight_merc4");
  flight_merc4:AddShip(ship_merc1_2);
  flight_merc4:AddShip(ship_merc1_3);
  flight_merc4:AddShip(ship_merc1_4);
  flight_merc4:AddShip(ship_merc1_5);
  flight_merc1:Delete();
  flight_merc2:Escort(ship_merc1_2);
  DispSpeaker:Message("#L_disp_01", 4, "Near_St_1");
end;


--info:top=480,left=80,allvis=0;
function Near_St_1()
  LaVertiSpeaker:Message("#L_LaVerti_05", 4, "Near_St_2");
end;


--info:top=520,left=80,allvis=0;
function Near_St_2()
  DispSpeaker:Message("#L_disp_02", 6, "Kruger_Come");
end;


--info:top=560,left=80,allvis=0;
function Kruger_Come()
  mRadar = Player_Group:CreateRadar(PORTAL_R:GetPosition(), 300, 0.1);
  Anim_1 = CreateMovie(_TARGETCAM);
  Anim_1:SetLength(50);
  Anim_1:SetInterpolate(_LINEAR);
  Anim_1:SetTarget(PORTAL_R);
  Anim_1:InitMovie(1, TRUE, 1);
  Anim_1:AddPosKey(PORTAL_R:GetPosition()+Vector3(-100, 50, 0), 0);
  Anim_1:AddScriptKey("First_Parti", 1);
  Anim_1:AddScriptKey("Second_Parti", 13);
  Anim_1:AddScriptKey("Third_Parti", 25);
  Anim_1:AddScriptKey("Fourth_Parti", 37);
  Anim_1:Play();
  Anim_1:AttachEscapeScript("What_Next");
  Anim_1:AttachAction("What_Next_Dialog");
  KrugerSpeaker:Message("#L_Kruger_01", 14, "Kruger_Come_2");
end;


--info:top=600,left=270,allvis=0;
function Kruger_Come_2()
  KrugerSpeaker:Message("#L_Kruger_11", 16, "Kruger_Come_3");
end;


--info:top=640,left=270,allvis=0;
function Kruger_Come_3()
  KrugerSpeaker:Message("#L_Kruger_12", 12);
end;


--info:top=710,left=100,allvis=0;
function First_Parti()
  PORTAL_R:Start(5, 0);
  NewFlight("Pirate_Group", "pir1", "Butcher_pir1", "PirateSuperAce", PORTAL_R:GetPosition()+Vector3(-15, 0, 0), Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir2", PORTAL_R:GetPosition()+Vector3(-10, 10, 0), 1, 17, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir3", PORTAL_R:GetPosition()+Vector3(-10, 10, 10), 1, 15, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir4", PORTAL_R:GetPosition()+Vector3(-10, 10, -10), 2, 15, Vector3(-1, 0, 0));
  flight_pir2:Escort(ship_pir1_1);
  flight_pir3:Escort(ship_pir1_1);
  flight_pir4:Escort(ship_pir1_1);
  ship_pir1_1:ApplyImpulse(10, Vector3(-1, 0, 0));
  flight_pir1:Move(PORTAL_R:GetPosition()+Vector3(-75, 0, 40));
end;


--info:top=710,left=200,allvis=0;
function Second_Parti()
  PORTAL_R:Start(5, 0);
  NewFlight("Pirate_Group", "pir5", "Butcher_pir1", "PirateSuperAce", PORTAL_R:GetPosition()+Vector3(-15, 0, 0), Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir6", PORTAL_R:GetPosition()+Vector3(-10, 10, 0), 1, 17, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir7", PORTAL_R:GetPosition()+Vector3(-10, 10, 10), 1, 15, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir8", PORTAL_R:GetPosition()+Vector3(-10, 10, -10), 2, 15, Vector3(-1, 0, 0));
  flight_pir6:Escort(ship_pir5_1);
  flight_pir7:Escort(ship_pir5_1);
  flight_pir8:Escort(ship_pir5_1);
  ship_pir5_1:ApplyImpulse(10, Vector3(-1, 0, 0));
  flight_pir5:Move(PORTAL_R:GetPosition()+Vector3(-75, 0, -40));
end;


--info:top=710,left=310,allvis=0;
function Third_Parti()
  PORTAL_R:Start(5, 0);
  NewFlight("Pirate_Group", "pir9", "Butcher_pir1", "PirateCaptain", PORTAL_R:GetPosition()+Vector3(-15, 0, 0), Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir10", PORTAL_R:GetPosition()+Vector3(-10, 10, 0), 1, 15, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir11", PORTAL_R:GetPosition()+Vector3(-10, -10, 0), 2, 15, Vector3(-1, 0, 0));
  flight_pir10:Escort(ship_pir9_1);
  flight_pir11:Escort(ship_pir9_1);
  ship_pir9_1:ApplyImpulse(10, Vector3(-1, 0, 0));
  flight_pir9:Move(PORTAL_R:GetPosition()+Vector3(-40, 0, 75));
end;


--info:top=710,left=410,allvis=0;
function Fourth_Parti()
  PORTAL_R:Start(5, 0);
  NewFlight("Pirate_Group", "pir12", "Butcher_pir1", "PirateCaptain", PORTAL_R:GetPosition()+Vector3(-15, 0, 0), Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir13", PORTAL_R:GetPosition()+Vector3(-10, 10, 0), 1, 15, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir14", PORTAL_R:GetPosition()+Vector3(-10, -10, 0), 2, 15, Vector3(-1, 0, 0));
  flight_pir13:Escort(ship_pir12_1);
  flight_pir14:Escort(ship_pir12_1);
  ship_pir12_1:ApplyImpulse(10, Vector3(-1, 0, 0));
  flight_pir12:Move(PORTAL_R:GetPosition()+Vector3(-40, 0, -75));
end;


--info:top=610,left=40,allvis=0;
function What_Next()
  StopHere();
-- если анимашка была прервана, то запускаем дубль создания пиратов.
  if not(flight_pir1) then
    NewFlight("Pirate_Group", "pir1", "Butcher_pir1", "PirateSuperAce", PORTAL_R:GetPosition()+Vector3(-75, 0, 40), Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir2", PORTAL_R:GetPosition()+Vector3(-70, 10, 40), 1, 17, Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir3", PORTAL_R:GetPosition()+Vector3(-70, 10, 50), 1, 15, Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir4", PORTAL_R:GetPosition()+Vector3(-70, 10, 30), 2, 15, Vector3(-1, 0, 0));
    flight_pir2:Escort(ship_pir1_1);
    flight_pir3:Escort(ship_pir1_1);
    flight_pir4:Escort(ship_pir1_1);
  end;
  if not(flight_pir5) then
    NewFlight("Pirate_Group", "pir5", "Butcher_pir1", "PirateSuperAce", PORTAL_R:GetPosition()+Vector3(-75, 0, -40), Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir6", PORTAL_R:GetPosition()+Vector3(-70, 10, -40), 1, 17, Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir7", PORTAL_R:GetPosition()+Vector3(-70, 10, -30), 1, 15, Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir8", PORTAL_R:GetPosition()+Vector3(-70, 10, -50), 2, 15, Vector3(-1, 0, 0));
    flight_pir6:Escort(ship_pir5_1);
    flight_pir7:Escort(ship_pir5_1);
    flight_pir8:Escort(ship_pir5_1);
  end;
  if not(flight_pir9) then
    NewFlight("Pirate_Group", "pir9", "Butcher_pir1", "PirateCaptain", PORTAL_R:GetPosition()+Vector3(-40, 0, 75), Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir10", PORTAL_R:GetPosition()+Vector3(-35, 10, 75), 1, 15, Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir11", PORTAL_R:GetPosition()+Vector3(-35, -10, 75), 2, 15, Vector3(-1, 0, 0));
    flight_pir10:Escort(ship_pir9_1);
    flight_pir11:Escort(ship_pir9_1);
  end;
  if not(flight_pir12) then
    NewFlight("Pirate_Group", "pir12", "Butcher_pir1", "PirateCaptain", PORTAL_R:GetPosition()+Vector3(-40, 0, -75), Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir13", PORTAL_R:GetPosition()+Vector3(-35, 10, -75), 1, 15, Vector3(-1, 0, 0));
    NewPirateFlight("Pirate_Group", "pir14", PORTAL_R:GetPosition()+Vector3(-35, -10, -75), 2, 15, Vector3(-1, 0, 0));
    flight_pir13:Escort(ship_pir12_1);
    flight_pir14:Escort(ship_pir12_1);
  end;
  Timer_Seq(1, What_Next_Dialog);
end;


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

function What_Next_Dialog()
  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() >= 6) then
      choose_pilot();
    else
      What_Next_Dialog_1();
    end;
  else
    What_Next_Dialog_1();
  end; 
end;

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


--info:top=750,left=80,allvis=0;
--------------------------------------------------------------------------------
function What_Next_Dialog_1()
--------------------------------------------------------------------------------
  Player_Group:DeleteRadar(mRadar);
  flight_merc4:Move(MINING:GetPosition()+Vector3(-30, 20, -30));
  if (Player_Group:HavePerk("F_of_Merchant")) then
    StartDialog("Dialog3");
  else
    StartDialog("Dialog4");
  end;
end;


--info:top=810,left=20,allvis=0;
function LaVerti_Right()
  lMission = 1;
  trig_AttackLaVerti:Delete();
  trig_AttackLaVerti = NIL;
  trig_AttackKfni:Delete();
  trig_AttackKfni = NIL;
  new_SetAllGroupRelations(rel_kfniwar, groups_for_rel);
  new_SetGroupRelations("Kfni_Group", PLAYER_GROUP, "W");
  SetAllDied({flight_kfni01,flight_kfni02,flight_kfni3,flight_kfni4}, Pirates_Come);
end;


--info:top=850,left=20,allvis=0;
function Pirates_Come()
  if (flight_pir5) and (flight_pir9) and (flight_pir12) then
    Timer_Seq(1, LaVerti_Dialog);
  else
    Timer_Seq(10, Pirates_Come);
  end;
end;


--info:top=890,left=20,allvis=0;
function LaVerti_Dialog()
  flight_pir5:Delete();
  flight_pir6:Delete();
  flight_pir7:Delete();
  flight_pir8:Delete();
  NewPirateFlight("Pirate_Group", "pir5", xyz_trade+Vector3(315, 0, 0), 3, 17, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir6", xyz_trade+Vector3(320, 10, 0), 1, 17, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir7", xyz_trade+Vector3(320, 10, 10), 1, 15, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir8", xyz_trade+Vector3(320, 10, -10), 2, 15, Vector3(-1, 0, 0));
  flight_pir6:Escort(ship_pir5_1);
  flight_pir7:Escort(ship_pir5_1);
  flight_pir8:Escort(ship_pir5_1);
  flight_pir5:Move(xyz_trade+Vector3(0, 40, 0));
  flight_pir9:Move(MINING:GetPosition()+Vector3(-40, 0, -75));
  flight_pir12:Move(MINING:GetPosition()+Vector3(40, 0, -75));
  NewTrigger("f_object_inside", TrueCondition, Kruger_Dialog, flight_pir5, mothership, 75);
  StartDialog("Dialog5");
end;


--info:top=930,left=20,allvis=0;
function Kruger_Dialog()
  flight_pir5:Stop();
  StartDialog("Dialog6");
end;


--info:top=970,left=20,allvis=0;
function Kruger_Attack()
  new_SetAllGroupRelations(rel_allwar, groups_for_rel);
  SetAllDied({flight_pir5,flight_pir6,flight_pir7,flight_pir8,flight_merc3}, Kill_Kruger);
end;


--info:top=810,left=270,allvis=0;
function LaVerti_Lie()
  lMission = 2;
  trig_AttackLaVerti:Delete();
  trig_AttackLaVerti = NIL;
  count = flight_merc4:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_merc4:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetPosition(xyz_trade+Vector3(300+i*5, 0, 300+i*5));
  end;
  count = flight_merc2:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_merc2:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetPosition(xyz_trade+Vector3(300+i*5, 30, 300+i*5));
  end;
  flight_merc2:Escort(ship_merc1_2);
  flight_merc4:Move(MINING:GetPosition()+Vector3(-30, 20, -30));
  new_SetAllGroupRelations(rel_mercwar, groups_for_rel);
  flight_merc3:Move(PORTAL_R:GetPosition()+Vector3(-15, 0, 0));
  NewTrigger("f_died", TrueCondition, Pursuit_or_Defence, flight_merc3);
end;


--info:top=850,left=270,allvis=0;
function Pursuit_or_Defence()
  SetNormalTimeMode();
  MothershipFlight:Stop();
  new_SetAllGroupRelations(rel_neutral, groups_for_rel);
  new_SetAllGroupRelations(rel_pirwar, groups_for_rel);
  lNear = 1;
  StartDialog("Dialog7");
end;


--info:top=890,left=210,allvis=0;
function Pursuit()
  AddQuest("quest_9c_05", "#L_Quest_9c_05a", "#L_Quest_9c_05b", QUEST_PROCESS);
  trig_KillMining = NewTrigger("f_inside", TrueCondition, Kill_Mining, flight_merc4, MINING:GetPosition(), 150);
  trig_DiedF4 = NewTrigger("f_died", TrueCondition, Died_Flight4, flight_merc4);
  trig_GoOut = NewTrigger("outside", TrueCondition, Is_Far, mothership, xyz_trade+Vector3(125, 0, 0), 250);
  Timer_Seq(20, First_Wave);
end;


--info:top=900,left=460,allvis=0;
function Defence()
  lMission = 5;
  AddQuest("quest_9c_06", "#L_Quest_9c_06a", "#L_Quest_9c_06b", QUEST_PROCESS);
  trig_GoOut = NewTrigger("outside", TrueCondition, Is_Far, mothership, xyz_trade+Vector3(125, 0, 0), 250);
  Timer_Seq(20, First_Wave);
end;


--info:top=940,left=460,allvis=0;
function Is_Far()
  lNear = 0;
  trig_GoOut:Delete();
  trig_GoOut = NIL;
  countK = 0;
  if (flight_kfni01:IsAlive()) then
    trig_DiedKfni1 = NewTrigger("f_died", DiedConditionK, final_Failed_2, flight_kfni01);
    countK = countK + 1;
  end;
  if (flight_kfni02:IsAlive()) then
    trig_DiedKfni2 = NewTrigger("f_died", DiedConditionK, final_Failed_2, flight_kfni02);
    countK = countK + 1;
  end;
  if (flight_kfni3:IsAlive()) then
    trig_DiedKfni3 = NewTrigger("f_died", DiedConditionK, final_Failed_2, flight_kfni3);
    countK = countK + 1;
  end;
  if (flight_kfni4:IsAlive()) then
    trig_DiedKfni4 = NewTrigger("f_died", DiedConditionK, final_Failed_2, flight_kfni4);
    countK = countK + 1;
  end;
  trig_ComeIn = NewTrigger("inside", TrueCondition, Is_Near, mothership, xyz_trade+Vector3(125, 0, 0), 245);
end;


--info:top=970,left=500,allvis=0;
function DiedConditionK()
  countK = countK - 1;
  if (countK==0) then
    return TRUE;
  end;
  return FALSE;
end;


--info:top=980,left=360,allvis=0;
function Is_Near()
  lNear = 1;
  trig_ComeIn:Delete();
  trig_ComeIn = NIL;
  if (trig_DiedKfni1) then
    trig_DiedKfni1:Delete();
    trig_DiedKfni1 = NIL;
  end;
  if (trig_DiedKfni2) then
    trig_DiedKfni2:Delete();
    trig_DiedKfni2 = NIL;
  end;
  if (trig_DiedKfni3) then
    trig_DiedKfni3:Delete();
    trig_DiedKfni3 = NIL;
  end;
  if (trig_DiedKfni4) then
    trig_DiedKfni4:Delete();
    trig_DiedKfni4 = NIL;
  end;
  trig_GoOut = NewTrigger("outside", TrueCondition, Is_Far, mothership, xyz_trade+Vector3(125, 0, 0), 250);
end;


--info:top=930,left=280,allvis=0;
function Kill_Mining()
  trig_GoOut:Delete();
  trig_GoOut = NIL;
  trig_DiedF4:Delete();
  if (ship_merc1_2:IsAlive()) then ship_merc1_2:Blow(); end;
  if (ship_merc1_3:IsAlive()) then ship_merc1_3:Blow(); end;
  if (ship_merc1_4:IsAlive()) then ship_merc1_4:Blow(); end;
  if (ship_merc1_5:IsAlive()) then ship_merc1_5:Blow(); end;
  flight_kfni1:Blow();
  flight_kfni2:Blow();
  SetQuestState("quest_9c_05", QUEST_FAILED);
  if (lNear==0) then
    trig_Return = NewTrigger("inside", TrueCondition, Go_Defence, mothership, xyz_trade+Vector3(125, 0, 0), 240);
    AddQuest("quest_9c_06", "#L_Quest_9c_06a", "#L_Quest_9c_06b", QUEST_PROCESS);
  end;
end;


--info:top=930,left=140,allvis=0;
function Died_Flight4()
  trig_KillMining:Delete();
  SetQuestState("quest_9c_05", QUEST_DONE);
  if (lNear==0) then
    trig_Return = NewTrigger("inside", TrueCondition, Go_Defence, mothership, xyz_trade+Vector3(125, 0, 0), 240);
    AddQuest("quest_9c_06", "#L_Quest_9c_06a", "#L_Quest_9c_06b", QUEST_PROCESS);
  end;
end;


--info:top=970,left=140,allvis=0;
function Go_Defence()
  GuardSpeaker:Message("#L_guard_04", 10, "Go_Defence_1");
end;


--info:top=1010,left=140,allvis=0;
function Go_Defence_1()
  SedoySpeaker:Message("#L_Sedoy_06", 10, "Go_Defence_2");
end;


--info:top=1050,left=140,allvis=0;
function Go_Defence_2()
  LastochkaSpeaker:Message("#L_Lastochka_07", 4);
end;


--info:top=990,left=250,allvis=0;
function First_Wave()
  flight_pir12:Delete();
  flight_pir13:Delete();
  flight_pir14:Delete();
  NewPirateFlight("Pirate_Group", "pir12", xyz_trade+Vector3(465, 0, 0), 3, 17, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir13", xyz_trade+Vector3(470, 10, 0), 1, 15, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir14", xyz_trade+Vector3(470, 10, 10), 2, 15, Vector3(-1, 0, 0));
  flight_pir13:Escort(ship_pir12_1);
  flight_pir14:Escort(ship_pir12_1);
  flight_pir12:Move(xyz_trade+Vector3(0, 40, 0));
  count = 3;
  trig_PirF12 = NewTrigger("f_died", DiedCondition, Second_Wave, flight_pir12);
  trig_PirF13 = NewTrigger("f_died", DiedCondition, Second_Wave, flight_pir13);
  trig_PirF14 = NewTrigger("f_died", DiedCondition, Second_Wave, flight_pir14);
  trig_FirstWaveAttack = NewTrigger("f_inside", TrueCondition, First_Wave_Attack, flight_pir12, xyz_trade, 150);
end;


--info:top=1420,left=430,allvis=0;
function First_Wave_Attack()
  flight_pir12:Stop();
end;


--info:top=1030,left=250,allvis=0;
function Second_Wave()
  if (lNear==0) then
    GuardSpeaker:Message("#L_guard_01", 10);
  else
    GuardSpeaker:Message("#L_guard_05", 5);
  end;
  if (flight_kfni01:IsAlive()) then flight_kfni01:Patrol({xyz_trade+Vector3(100,0,0),xyz_trade+Vector3(100,-20,-50)}, TRUE); end;
  if (flight_kfni02:IsAlive()) then flight_kfni02:Patrol({xyz_trade+Vector3(-100,0,0),xyz_trade+Vector3(0,-10,-100)}, TRUE); end;
  if (flight_kfni3:IsAlive()) then flight_kfni3:Move(xyz_trade+Vector3(100,40,20)); end;
  if (flight_kfni4:IsAlive()) then flight_kfni4:Move(xyz_trade+Vector3(100,40,-20)); end;
  flight_pir9:Delete();
  flight_pir10:Delete();
  flight_pir11:Delete();
  NewPirateFlight("Pirate_Group", "pir9", xyz_trade+Vector3(465, 0, 0), 3, 17, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir10", xyz_trade+Vector3(470, 10, 0), 1, 15, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir11", xyz_trade+Vector3(470, 10, 10), 2, 15, Vector3(-1, 0, 0));
  flight_pir10:Escort(ship_pir9_1);
  flight_pir11:Escort(ship_pir9_1);
  flight_pir9:Move(xyz_trade+Vector3(0, 40, 0));
  count = 3;
  trig_PirF9 = NewTrigger("f_died", DiedCondition, Third_Wave, flight_pir9);
  trig_PirF10 = NewTrigger("f_died", DiedCondition, Third_Wave, flight_pir10);
  trig_PirF11 = NewTrigger("f_died", DiedCondition, Third_Wave, flight_pir11);
  trig_SecondWaveAttack = NewTrigger("f_inside", TrueCondition, Second_Wave_Attack, flight_pir9, xyz_trade, 150);
end;


--info:top=1060,left=280,allvis=0;
function Second_Wave_Attack()
  flight_pir9:Stop();
end;


--info:top=1080,left=250,allvis=0;
function Third_Wave()
  if (lNear==0) then
    GuardSpeaker:Message("#L_guard_02", 5);
  else
    GuardSpeaker:Message("#L_guard_06", 6);
  end;
  if (flight_kfni01:IsAlive()) then flight_kfni01:Patrol({xyz_trade+Vector3(100,0,0),xyz_trade+Vector3(100,-20,-50)}, TRUE); end;
  if (flight_kfni02:IsAlive()) then flight_kfni02:Patrol({xyz_trade+Vector3(-100,0,0),xyz_trade+Vector3(0,-10,-100)}, TRUE); end;
  if (flight_kfni3:IsAlive()) then flight_kfni3:Move(xyz_trade+Vector3(100,40,20)); end;
  if (flight_kfni4:IsAlive()) then flight_kfni4:Move(xyz_trade+Vector3(100,40,-20)); end;
  flight_pir5:Delete();
  flight_pir6:Delete();
  flight_pir7:Delete();
  flight_pir8:Delete();
  NewPirateFlight("Pirate_Group", "pir5", xyz_trade+Vector3(465, 0, 0), 3, 17, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir6", xyz_trade+Vector3(470, 10, 0), 1, 17, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir7", xyz_trade+Vector3(470, 10, 10), 1, 15, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir8", xyz_trade+Vector3(470, 10, -10), 2, 15, Vector3(-1, 0, 0));
  flight_pir6:Escort(ship_pir5_1);
  flight_pir7:Escort(ship_pir5_1);
  flight_pir8:Escort(ship_pir5_1);
  flight_pir5:Move(xyz_trade+Vector3(0, 40, 0));
  count = 4;
  trig_PirF5 = NewTrigger("f_died", DiedCondition, Defence_Done, flight_pir5);
  trig_PirF6 = NewTrigger("f_died", DiedCondition, Defence_Done, flight_pir6);
  trig_PirF7 = NewTrigger("f_died", DiedCondition, Defence_Done, flight_pir7);
  trig_PirF8 = NewTrigger("f_died", DiedCondition, Defence_Done, flight_pir8);
  trig_ThirdWaveAttack = NewTrigger("f_inside", TrueCondition, Third_Wave_Attack, flight_pir5, xyz_trade, 150);
end;


--info:top=1110,left=280,allvis=0;
function Third_Wave_Attack()
  flight_pir5:Stop();
end;


--info:top=1130,left=250,allvis=0;
function Defence_Done()
  ship1 = CreateCarcass("Jaguar_kfni3", xyz_trade+Vector3(20, 10, -10), Vector3(1,0,0)); 
  ship1:AssignPilot(CheSpeaker);
  CheFlight = Player_Group:CreateFlight("CheFlight");
  CheFlight:AddShip(ship1);
  CheFlight:Escort(mothership);
  if (trig_ComeIn) then
    trig_ComeIn:Delete();
    trig_ComeIn = NIL;
  end;
  if (trig_GoOut) then
    trig_GoOut:Delete();
    trig_GoOut = NIL;
  end;
  if (lNear==0) then
    if (flight_kfni01:IsAlive()) then flight_kfni01:Blow(); end;
    if (flight_kfni02:IsAlive()) then flight_kfni02:Blow(); end;
    if (flight_kfni3:IsAlive()) then flight_kfni3:Blow(); end;
    if (flight_kfni4:IsAlive()) then flight_kfni4:Blow(); end;
    if (GetQuestState("quest_9c_06")==QUEST_PROCESS) then SetQuestState("quest_9c_06", QUEST_FAILED); end;
  elseif (lMission==5) then
    if (GetQuestState("quest_9c_06")==QUEST_PROCESS) then SetQuestState("quest_9c_06", QUEST_DONE); end;
    StartDialog("Dialog8");
  elseif (flight_kfni1:IsAlive()) then
    count = flight_kfni1:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_kfni1:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_trade+Vector3(250+i*5, 0, 250+i*5));
    end;
    flight_kfni1:Move(xyz_trade+Vector3(100, 20, 50));
    count = flight_kfni2:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_kfni2:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_trade+Vector3(270+i*5, 0, 250+i*5));
    end;
    flight_kfni2:Escort(ship_kfni1_1);
    count = flight_kfni5:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_kfni5:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_trade+Vector3(290+i*5, 0, 250+i*5));
    end;
    flight_kfni5:Escort(ship_kfni1_1);
    if (GetQuestState("quest_9c_06")==QUEST_PROCESS) then SetQuestState("quest_9c_06", QUEST_DONE); end;
    StartDialog("Dialog9");
  else
    count = flight_kfni5:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_kfni5:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_trade+Vector3(250+i*5, 0, 250+i*5));
    end;
    flight_kfni5:Move(xyz_trade+Vector3(100, 20, 50));
    if (GetQuestState("quest_9c_06")==QUEST_PROCESS) then SetQuestState("quest_9c_06", QUEST_DONE); end;
    StartDialog("Dialog10");
  end;
end;


--info:top=1470,left=440,allvis=0;
function New_Fighters()
  mothership:AddShipToInventory("EvilEye_pl1", 1);
  mothership:AddShipToInventory("Hrimturs_pl1", 1);
  mothership:AddShipToInventory("TieFly_pl1", 1);
  nav_AttackPoint = CreateNavPoint("", Vector3(400, 0, -500), "nav_default.dds", RGB(255,255,255));
  NewTrigger("inside", TrueCondition, Ready_Attack, mothership, Vector3(400, 0, -500), 100);
  if (flight_kfni01:IsAlive()) then flight_kfni01:Move(Vector3(390, 20, -500)); end;
  if (flight_kfni02:IsAlive()) then flight_kfni02:Move(Vector3(390, -20, -500)); end;
  if (flight_kfni3:IsAlive()) then flight_kfni3:Move(Vector3(380, 5, -480)); end;
  if (flight_kfni4:IsAlive()) then flight_kfni4:Move(Vector3(380, -5, -520)); end;
  if (lMission==2) or (lMission==3) then
    if (flight_kfni1:IsAlive()) then
      flight_kfni1:Move(Vector3(400, 0, -500));
      flight_kfni2:Escort(ship_kfni1_1);
      flight_kfni5:Escort(ship_kfni1_1);
    else
      flight_kfni5:Move(Vector3(400, 0, -500));
    end;
  end;
  AddQuest("quest_9c_07", "#L_Quest_9c_07a", "#L_Quest_9c_07b", QUEST_PROCESS);
  SetAllDied({flight_pir1,flight_pir2,flight_pir3,flight_pir4}, Kill_Kruger);
end;


--info:top=1510,left=440,allvis=0;
function Ready_Attack()
  SetNormalTimeMode();
  nav_AttackPoint:Delete();
  nav_AttackPoint = NIL;
  GuardSpeaker:Message("#L_guard_07", 15, "Begin_Attack");
end;


--info:top=1550,left=440,allvis=0;
function Begin_Attack()
  HeroSpeaker:Message("#L_Hero_05", 4);
  if (flight_kfni01:IsAlive()) then flight_kfni01:Move(Vector3(640, 20, -150)); end;
  if (flight_kfni02:IsAlive()) then flight_kfni02:Move(Vector3(640, -20, -150)); end;
  if (flight_kfni3:IsAlive()) then flight_kfni3:Move(Vector3(630, 5, -130)); end;
  if (flight_kfni4:IsAlive()) then flight_kfni4:Move(Vector3(630, -5, -170)); end;
  if (lMission==2) or (lMission==3) then
    if (flight_kfni1:IsAlive()) then
      flight_kfni1:Move(Vector3(650, 0, -150));
      flight_kfni2:Escort(ship_kfni1_1);
      flight_kfni5:Escort(ship_kfni1_1);
    else
      flight_kfni5:Move(Vector3(650, 0, -150));
    end;
  end;
  NewTrigger("inside", TrueCondition, KFNI_Attack_Pirates, mothership, PORTAL_R:GetPosition()+Vector3(-75, 0, 40), 200);
end;


--info:top=1590,left=440,allvis=0;
function KFNI_Attack_Pirates()
  if (flight_kfni01:IsAlive()) then flight_kfni01:Move(PORTAL_R:GetPosition()+Vector3(-65, 20, 40)); end;
  if (flight_kfni02:IsAlive()) then flight_kfni02:Move(PORTAL_R:GetPosition()+Vector3(-65, -20, 40)); end;
  if (flight_kfni3:IsAlive()) then flight_kfni3:Move(PORTAL_R:GetPosition()+Vector3(-55, 5, 60)); end;
  if (flight_kfni4:IsAlive()) then flight_kfni4:Move(PORTAL_R:GetPosition()+Vector3(-55, -5, 20)); end;
  if (lMission==2) or (lMission==3) then
    if (flight_kfni1:IsAlive()) then
      flight_kfni1:Move(PORTAL_R:GetPosition()+Vector3(-75, 0, 40));
      flight_kfni2:Escort(ship_kfni1_1);
      flight_kfni5:Escort(ship_kfni1_1);
    else
      flight_kfni5:Move(PORTAL_R:GetPosition()+Vector3(-75, 0, 40));
    end;
  end;
end;


--info:top=820,left=780,allvis=0;
function Brandere()
  lMission = 3;
  ship1 = CreateCarcass("Jaguar_kfni3", xyz_trade+Vector3(20, 10, -10), Vector3(1,0,0)); 
  ship1:AssignPilot(CheSpeaker);
  CheFlight = Player_Group:CreateFlight("CheFlight");
  CheFlight:AddShip(ship1);
  CheFlight:Escort(mothership);
  trig_Timer = NewTrigger("timer", TrueCondition, Blow_MotherShip, 180);
  Timer_Seq(1, Remove_Pers);
end;


--info:top=850,left=830,allvis=0;
function Blow_MotherShip()
  mothership:Blow();
end;


--info:top=870,left=780,allvis=0;
function Remove_Pers()
  if (HeroSpeaker:IsInBase()) or (HeroSpeaker:IsBasePilot()) or (LastochkaSpeaker:IsInBase()) or (LastochkaSpeaker:IsBasePilot()) or (SedoySpeaker:IsInBase()) or (SedoySpeaker:IsBasePilot()) then
    SysSpeaker:Message("#L_sysmsg_01",10,"Remove_Pers");
  else
    trig_Timer:Delete();
    HeroShip = HeroSpeaker:GetShip();
    HeroFlight = HeroSpeaker:GetFlight();
    LastochkaShip = LastochkaSpeaker:GetShip();
    LastochkaFlight = LastochkaSpeaker:GetFlight();
    SedoyShip = SedoySpeaker:GetShip();
    SedoyFlight = SedoySpeaker:GetFlight();
    CreateFadeScreen(12, 1, 1);
    Timer_Seq(11, Go_Attack);
    Timer_Seq(13, Brandere_Animation);
  end;
end;


--info:top=910,left=780,allvis=0;
function Brandere_Animation()
  mRadar = Player_Group:CreateRadar(Vector3(500, 0, -450), 250, 0.1);
  xyz_flight5 = Vector3(500, 0, -470);
  xyz_flight9 = Vector3(500, 0, -430);
  count = flight_pir5:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_pir5:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetPosition(xyz_flight5+Vector3(200+i*5, 0, i*5));
  end;
  count = flight_pir6:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_pir6:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetPosition(xyz_flight5+Vector3(220+i*5, 0, 20+i*5));
  end;
  count = flight_pir7:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_pir7:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetPosition(xyz_flight5+Vector3(220+i*5, 0, -20+i*5));
  end;
  count = flight_pir8:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_pir8:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetPosition(xyz_flight5+Vector3(220+i*5, -20, i*5));
  end;
  flight_pir8:Escort(ship_pir5_1);
  flight_pir7:Escort(ship_pir5_1);
  flight_pir8:Escort(ship_pir5_1);
  flight_pir5:Move(Vector3(500, 0, -470));
  count = flight_pir9:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_pir9:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetPosition(xyz_flight9+Vector3(200+i*5, 0, i*5));
  end;
  count = flight_pir10:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_pir10:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetPosition(xyz_flight9+Vector3(220+i*5, 0, 20+i*5));
  end;
  count = flight_pir11:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_pir11:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetPosition(xyz_flight9+Vector3(220+i*5, 0, -20+i*5));
  end;
  flight_pir10:Escort(ship_pir9_1);
  flight_pir11:Escort(ship_pir9_1);
  flight_pir9:Move(Vector3(500, 0, -430));
  HeroShip:SetPosition(Vector3(150, 0, -450));
  HeroShip:SetOrientation(CreateQuaternionFromVector3(Vector3(1, 0, 0)));
  LastochkaShip:SetPosition(Vector3(140, 0, -460));
  LastochkaShip:SetOrientation(CreateQuaternionFromVector3(Vector3(1, 0, 0)));
  SedoyShip:SetPosition(Vector3(140, 0, -440));
  SedoyShip:SetOrientation(CreateQuaternionFromVector3(Vector3(1, 0, 0)));
  LastochkaFlight:Escort(HeroShip);
  SedoyFlight:Escort(HeroShip);
  HeroFlight:Move(Vector3(470, 0, -450));
  mothership:AddShipToInventory("Excalibur_pl2", 2);
  mothership:AddShipToInventory("Raptor_pl1", 1);
  MothershipFlight:Move(Vector3(500, 0, -450));

  Anim_1 = CreateMovie(_ASIMUTHCAM);
  Anim_1:SetLength(30);
  Anim_1:SetInterpolate(_LINEAR);
  Anim_1:SetTarget(HeroShip);
  Anim_1:InitMovie(1, TRUE, 2);
  Anim_1:AddKeys(270, 75, 60, 0);
  Anim_1:AddScriptKey("Anim_Dialog_1", 1);
  Anim_1:AddScriptKey("Anim_Dialog_2", 6);
  Anim_1:AddScriptKey("Anim_Dialog_3", 13);
  Anim_1:AttachEscapeScript("Brandere_Escape");

  Anim_2 = CreateMovie(_FREECAM);
  Anim_2:SetLength(36);
  Anim_2:SetInterpolate(_LINEAR);
  Anim_2:InitMovie(1, TRUE, 2);
  Anim_2:AddPosKey(Vector3(420, 30, -450), 0);
  Anim_2:AddOrientKey(Quaternion(0.1060, 0.6859, -0.1020, 0.7127), 0)
  Anim_2:AddScriptKey("Anim_Dialog_4", 1);
  Anim_2:AddScriptKey("Anim_Dialog_5", 8);
  Anim_2:AddScriptKey("Anim_Dialog_6", 17);
  Anim_2:AddScriptKey("Anim_Dialog_7", 27);
  Anim_2:AddScriptKey("Anim_Dialog_8", 30);
  Anim_2:AddScriptKey("Anim_Dialog_9", 35);
  Anim_2:AttachEscapeScript("Brandere_Escape");

  Anim_3 = CreateMovie(_TARGETCAM);
  Anim_3:SetLength(25);
  Anim_3:SetInterpolate(_LINEAR);
  Anim_3:SetTarget(mothership);
  Anim_3:InitMovie(1, TRUE, 2);
  Anim_3:AddPosKey(Vector3(570, 30, -480), 0);
  Anim_3:AddScriptKey("Anim_Dialog_10", 1);
  Anim_3:AddScriptKey("Anim_Dialog_11", 6);
  Anim_3:AddScriptKey("Anim_Dialog_12", 11);
  Anim_3:AddScriptKey("Anim_Dialog_13", 18);
  Anim_3:AttachEscapeScript("Brandere_Escape");
  Anim_3:AttachAction("Brandere_Final");

  PlayList({Anim_1,Anim_2,Anim_3});
end;


--info:top=940,left=920,allvis=0;
function Anim_Dialog_1()
  LastochkaSpeaker:Message("#L_Lastochka_08", 4);
end;


--info:top=970,left=920,allvis=0;
function Anim_Dialog_2()
  SedoySpeaker:Message("#L_Sedoy_07", 6);
end;


--info:top=1000,left=920,allvis=0;
function Anim_Dialog_3()
  HeroSpeaker:Message("#L_Hero_06", 11);
end;


--info:top=1030,left=920,allvis=0;
function Anim_Dialog_4()
  KrugerSpeaker:Message("#L_Kruger_03", 7);
end;


--info:top=1060,left=920,allvis=0;
function Anim_Dialog_5()
  HeroSpeaker:Message("#L_Hero_07", 8);
end;


--info:top=1090,left=920,allvis=0;
function Anim_Dialog_6()
  KrugerSpeaker:Message("#L_Kruger_04", 10);
end;


--info:top=1120,left=920,allvis=0;
function Anim_Dialog_7()
  HeroSpeaker:Message("#L_Hero_08", 3);
end;


--info:top=1150,left=920,allvis=0;
function Anim_Dialog_8()
  HeroShip:Move(Vector3(490, 0, -465));
  LastochkaShip:Move(Vector3(490, 0, -475));
  SedoyShip:Move(Vector3(490, 0, -435));
  KrugerSpeaker:Message("#L_Kruger_05", 5);
  new_SetAllGroupRelations(rel_pirwar, groups_for_rel);
end;


--info:top=1180,left=920,allvis=0;
function Anim_Dialog_9()
  HeroShip:Blow();
  LastochkaShip:Blow();
  SedoyShip:Blow();
  flight_pir5:Blow();
  flight_pir6:Blow();
  flight_pir7:Blow();
  flight_pir8:Blow();
  flight_pir9:Blow();
  flight_pir10:Blow();
  flight_pir11:Blow();
  mothership:SetPosition(Vector3(350, 0, -450));
  if (not(CheSpeaker:IsInBase())) and (not(CheSpeaker:IsBasePilot())) then
    CheShip = CheSpeaker:GetShip();
    CheFlight = CheSpeaker:GetFlight();
    CheShip:SetPosition(Vector3(330, 0, -470));
    CheFlight:Escort(mothership);
  end;
  MothershipFlight:Move(Vector3(500, 0, -450));
end;


--info:top=1210,left=920,allvis=0;
function Anim_Dialog_10()
  LastochkaSpeaker:Message("#L_Lastochka_09", 3);
end;


--info:top=1240,left=920,allvis=0;
function Anim_Dialog_11()
  CheSpeaker:Message("#L_Che_01", 4);
end;


--info:top=1270,left=920,allvis=0;
function Anim_Dialog_12()
  SedoySpeaker:Message("#L_Sedoy_08", 7);
end;


--info:top=1300,left=920,allvis=0;
function Anim_Dialog_13()
  CheSpeaker:Message("#L_Che_02", 6);
end;


--info:top=1040,left=680,allvis=0;
function Brandere_Escape()
  if (HeroShip:IsAlive()) then
    HeroShip:SetPosition(xyz_flight5+Vector3(-5, 0, 5));
    HeroShip:Blow();
  end;
  if (LastochkaShip:IsAlive()) then
    LastochkaShip:SetPosition(xyz_flight5+Vector3(-5, 0, 5));
    LastochkaShip:Blow();
  end;
  if (SedoyShip:IsAlive()) then
    SedoyShip:SetPosition(xyz_flight5+Vector3(-5, 0, 5));
    SedoyShip:Blow();
  end;
  if (flight_pir5:IsAlive()) then
    count = flight_pir5:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_pir5:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_flight5+Vector3(i*5, 0, i*5));
    end;
    count = flight_pir6:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_pir6:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_flight5+Vector3(20+i*5, 0, 20+i*5));
    end;
    count = flight_pir7:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_pir7:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_flight5+Vector3(20+i*5, 0, -20+i*5));
    end;
    count = flight_pir8:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_pir8:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_flight5+Vector3(20+i*5, -20, i*5));
    end;
    flight_pir5:Blow();
    flight_pir6:Blow();
    flight_pir7:Blow();
    flight_pir8:Blow();
  end;
  if (flight_pir9:IsAlive()) then
    count = flight_pir9:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_pir9:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_flight9+Vector3(i*5, 0, i*5));
    end;
    count = flight_pir10:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_pir10:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_flight9+Vector3(20+i*5, 0, 20+i*5));
    end;
    count = flight_pir11:GetPilotCount();
    for i=0,count,1 do
      pilot_tmp = flight_pir11:GetPilotByNumber(i);
      ship_tmp = pilot_tmp:GetShip();
      ship_tmp:SetPosition(xyz_flight9+Vector3(20+i*5, 0, -20+i*5));
    end;
    flight_pir9:Blow();
    flight_pir10:Blow();
    flight_pir11:Blow();
  end;
  mothership:SetPosition(Vector3(450, 0, -450));
  if (not(CheSpeaker:IsInBase())) and (not(CheSpeaker:IsBasePilot())) then
    CheShip = CheSpeaker:GetShip();
    CheFlight = CheSpeaker:GetFlight();
    CheShip:SetPosition(Vector3(430, 0, -470));
    CheFlight:Escort(mothership);
  end;
  MothershipFlight:Move(Vector3(500, 0, -450));
  new_SetAllGroupRelations(rel_pirwar, groups_for_rel);
  Timer_Seq(1, Brandere_Final);
end;


--info:top=1100,left=780,allvis=0;
function Brandere_Final()
  Player_Group:DeleteRadar(mRadar);
  LastochkaSpeaker:Message("#L_Lastochka_10", 3, "After_Brandere_1");
end;


--info:top=1140,left=780,allvis=0;
function After_Brandere_1()
  CheSpeaker:Message("#L_Che_03", 10, "After_Brandere_2");
end;


--info:top=1180,left=780,allvis=0;
function After_Brandere_2()
  GuardSpeaker:Message("#L_guard_08", 5, "After_Brandere_3");
end;


--info:top=1220,left=780,allvis=0;
function After_Brandere_3()
  LastochkaSpeaker:Message("#L_Lastochka_11", 1, "After_Brandere_4");
end;


--info:top=1260,left=780,allvis=0;
function After_Brandere_4()
  SedoySpeaker:Message("#L_Sedoy_09", 2, "After_Brandere_5");
end;


--info:top=1300,left=780,allvis=0;
function After_Brandere_5()
  HeroSpeaker:Message("#L_Hero_09", 8);
  NewTrigger("inside", TrueCondition, Pirates_Attack, mothership, xyz_trade, 700);
  AddQuest("quest_9c_06", "#L_Quest_9c_06a", "#L_Quest_9c_06b", QUEST_PROCESS);
end;


--info:top=1340,left=780,allvis=0;
function Pirates_Attack()
  flight_pir12:Delete();
  flight_pir13:Delete();
  flight_pir14:Delete();
  NewPirateFlight("Pirate_Group", "pir12", xyz_trade+Vector3(465, 0, 0), 3, 17, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir13", xyz_trade+Vector3(470, 10, 0), 1, 15, Vector3(-1, 0, 0));
  NewPirateFlight("Pirate_Group", "pir14", xyz_trade+Vector3(470, 10, 10), 2, 15, Vector3(-1, 0, 0));
  flight_pir13:Escort(ship_pir12_1);
  flight_pir14:Escort(ship_pir12_1);
  flight_pir12:Move(xyz_trade+Vector3(0, 40, 0));
  SetAllDied({flight_pir12,flight_pir13,flight_pir14}, Defence_Done_2);
  trig_FirstWaveAttack = NewTrigger("f_inside", TrueCondition, First_Wave_Attack, flight_pir12, xyz_trade, 150);
end;


--info:top=1380,left=780,allvis=0;
function Defence_Done_2()
  SetQuestState("quest_9c_06", QUEST_DONE);
  StartDialog("Dialog13");
end;


--info:top=820,left=600,allvis=0;
function Attack_Pirates()
  lMission = 4;
  ship1 = CreateCarcass("Jaguar_kfni3", xyz_trade+Vector3(20, 10, -10), Vector3(1,0,0)); 
  ship1:AssignPilot(CheSpeaker);
  CheFlight = Player_Group:CreateFlight("CheFlight");
  CheFlight:AddShip(ship1);
  CheFlight:Escort(mothership);
  flight_pir5:Move(Vector3(0, -150, -400));
  flight_pir12:Move(Vector3(600, 150, 0));
  AddQuest("quest_9c_04", "#L_Quest_9c_04a", "#L_Quest_9c_04b", QUEST_PROCESS);
  new_SetAllGroupRelations(rel_pirwar, groups_for_rel);
  count = 14;
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir1);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir2);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir3);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir4);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir5);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir6);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir7);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir8);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir9);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir10);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir11);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir12);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir13);
  NewTrigger("f_died", DiedCondition, Kill_Kruger, flight_pir14);
  NewTrigger("outside", TrueCondition, Go_Attack, mothership, xyz_trade+Vector3(125, 0, 0), 250);
  NewTrigger("inside", TrueCondition, Pirates_Return, mothership, PORTAL_R:GetPosition()+Vector3(-75, 0, 40), 200);
end;


--info:top=1220,left=470,allvis=0;
function DiedCondition()
  count = count - 1;
  if (count==0) then
    return TRUE;
  end;
  return FALSE;
end;


--info:top=940,left=670,allvis=0;
function Go_Attack()
  flight_merc2:Delete();
  flight_merc3:Delete();
  flight_merc4:Delete();
end;


--info:top=870,left=600,allvis=0;
function Pirates_Return()
  if (flight_pir5:IsAlive()) then flight_pir5:Move(PORTAL_R:GetPosition()+Vector3(-100, 0, 60)); end;
  if (flight_pir12:IsAlive()) then flight_pir12:Move(PORTAL_R:GetPosition()+Vector3(-100, 0, -20)); end;
end;


--info:top=1620,left=250,allvis=0;
function Kill_Kruger()
  Kruger_Pod = CreateCarcass("Escape_Pod_R", mothership:GetPosition()+Vector3(50, -10, 60), Vector3(1, 0, 0));
  FocusOn({Kruger_Pod}, Vector3(0,0.3,1), 2);
  KrugerSpeaker:Message("#L_Kruger_02", 6, "Sedoy_Attack");
end;


--info:top=1660,left=250,allvis=0;
function Sedoy_Attack()
  SedoySpeaker:Message("#L_Sedoy_02", 3);
  if (not(SedoySpeaker:IsInBase())) and (not(SedoySpeaker:IsBasePilot())) and (SedoySpeaker:IsCanSayReplica()) then
    SedoyFlight = SedoySpeaker:GetFlight();
    SedoyFlight:Attack(Kruger_Pod);
    SedoyShip = SedoySpeaker:GetShip();
    FocusOn({SedoyShip}, Vector3(0,0.3,1), 25);
  else
    MothershipFlight:Attack(Kruger_Pod);
    FocusOn({mothership}, Vector3(0,0.3,1), 45);
  end;
  Timer_Seq(7, Blow_Pod);
  NewTrigger("died", TrueCondition, Kruger_Died_1, Kruger_Pod);
end;


--info:top=1690,left=290,allvis=0;
function Blow_Pod()
  if (Kruger_Pod:IsAlive()) then Kruger_Pod:Blow(); end;
end;


--info:top=1710,left=250,allvis=0;
function Kruger_Died_1()
  Kruger_Pod = NIL;
  LastochkaSpeaker:Message("#L_Lastochka_03", 7, "Kruger_Died_2");
end;


--info:top=1750,left=250,allvis=0;
function Kruger_Died_2()
  SedoySpeaker:Message("#L_Sedoy_03", 15, "Kruger_Died_3");
end;


--info:top=1790,left=250,allvis=0;
function Kruger_Died_3()
  HeroSpeaker:Message("#L_Hero_03", 10, "Kruger_Died_4");
end;


--info:top=1830,left=250,allvis=0;
function Kruger_Died_4()
  SetQuestLabel("Kruger", "died");
  if (lMission==1) then
    SedoySpeaker:Message("#L_Sedoy_04", 6, "final_Failed_1");
  elseif (lMission==4) then
    SetQuestLabel("m9cDionis", "defence");
    SedoySpeaker:Message("#L_Sedoy_04", 6);
    NewTrigger("inside", TrueCondition, After_Full_Victory, mothership, xyz_trade, 150);
  elseif (lMission==2) or (lMission==3) or (lMission==5) then
    StopHere();
    SetQuestLabel("m9cDionis", "defence");
    SetQuestState("quest_9c_07", QUEST_DONE);
    StartDialog("Dialog11");
  end;
end;


--info:top=1870,left=300,allvis=0;
function After_Full_Victory()
  SetNormalTimeMode();
  MothershipFlight:Stop();
  SetQuestState("quest_9c_04", QUEST_DONE);
  StartDialog("Dialog12");
end;


--info:top=1900,left=340,allvis=0;
function New_Fighters_2()
  mothership:AddShipToInventory("EvilEye_pl1", 1);
  mothership:AddShipToInventory("Hrimturs_pl1", 1);
  mothership:AddShipToInventory("TieFly_pl1", 1);
end;


--info:top=1920,left=250,allvis=0;
function To_Transports()
  if (flight_kfni01:IsAlive()) then flight_kfni01:Move(xyz_trade+Vector3(100, -20, -50)); end;
  if (flight_kfni02:IsAlive()) then flight_kfni02:Move(xyz_trade+Vector3(50, 30, 50)); end;
  if (flight_kfni1:IsAlive()) then flight_kfni1:Move(MINING:GetPosition()+Vector3(30, 20, -30)); end;
  if (flight_kfni2:IsAlive()) then flight_kfni2:Move(MINING:GetPosition()+Vector3(30, -20, -30)); end;
  if (flight_kfni3:IsAlive()) then flight_kfni3:Move(xyz_trade+Vector3(100, 20, 30)); end;
  if (flight_kfni4:IsAlive()) then flight_kfni4:Move(xyz_trade+Vector3(100, 20, -30)); end;
  if (flight_kfni5:IsAlive()) then flight_kfni5:Move(MINING:GetPosition()+Vector3(-30, 20, -30)); end;
  AddQuest("quest_9c_08", "#L_Quest_9c_08a", "#L_Quest_9c_08b", QUEST_PROCESS);
  NewFlight("Kfni_Group", "rad1", "Walrus_kfni2", "KfniPilot", Vector3(-100, 0, 200), Vector3(0.5, 0, -0.5));
  NewShip("rad1_2", "Walrus_kfni2", "KfniPilot", Vector3(-120, 0, 180), Vector3(0.5, 0, -0.5));
  flight_rad1:AddShip(ship_rad1_2);
  NewShip("rad1_3", "Walrus_kfni2", "KfniPilot", Vector3(-120, 0, 220), Vector3(0.5, 0, -0.5));
  flight_rad1:AddShip(ship_rad1_3);
  NewKfniFlight("Kfni_Group", "rad2", Vector3(-110, 20, 210), 1, 14, Vector3(0.5, 0, -0.5));
  flight_rad2:Escort(ship_rad1_1);
  nav_Transports = CreateNavPoint("", Vector3(-100, 0, 200), "nav_default.dds", RGB(255,255,255));
  nav_current = CreateNavPoint("", mothership:GetPosition(), "nav_void.dds", RGB(255,255,255));
  LineToTransport = CreateLine(nav_current, nav_Transports, RGB(20,80,220), .3, TRUE, .2, 1);
  NewTrigger("inside", TrueCondition, Transport_Ready, mothership, Vector3(-100, 0, 200), 100);
end;


--info:top=1960,left=250,allvis=0;
function Transport_Ready()
  lMission = 6;
  LineToTransport:Delete();
  LineToTransport = NIL;
  nav_current:Delete();
  nav_current = NIL;
  nav_Transports:Delete();
  nav_Transports = NIL;
  pilot_rad1_1:Message("#L_kfni_05", 12);
  ship_rad1_1:ComeToPortal(PORTAL_R);
  SetQuestState("quest_9c_08", QUEST_DONE);
  AddQuest("quest_9c_09", "#L_Quest_9c_09a", "#L_Quest_9c_09b", QUEST_PROCESS);
  trig_AttackKfni:Delete();
  trig_AttackKfni = NewTrigger("reps", TrueCondition, Attack_KfniCaravan, Player_Group, Kfni_Group, RELATION_WAR);
  NewTrigger("f_object_inside", PortalCondition, PortalAction, flight_rad1, PORTAL_R, 25);
end;


--info:top=2000,left=100,allvis=0;
function Attack_KfniCaravan()
  lMission = 0;
  SetQuestState("quest_9c_09", QUEST_FAILED);
  if (CheSpeaker:IsInBase()) or (CheSpeaker:IsBasePilot()) then
    mothership:Blow();
  elseif (CheSpeaker:IsCanSayReplica()) then
    CheShip = CheSpeaker:GetShip();
    CheFlight = CheSpeaker:GetFlight();
    if (CheFlight:GetPilotCount()==1) then
      Player_Group:RemoveFlight(CheFlight);
      Kfni_Group:AddFlight(CheFlight);
      CheFlight:Attack(mothership);
    else
      NewCheFlight = Kfni_Group:CreateFlight("NewCheFlight");
      NewCheFlight:AddShip(CheShip);
      NewCheFlight:Attack(mothership);
    end;
  else
    local Player_Team = CreateTeam(PLAYER_TEAM);
    Player_Team:RemovePilot(CheSpeaker);
    CheSpeaker:Kill();
    CheSpeaker = NIL;
  end;
end;


--info:top=1990,left=300,allvis=0;
function PortalCondition()
  PORTAL_R:Start(5, 0);
  return TRUE;
end;


--info:top=2020,left=300,allvis=0;
function PortalAction()
  flight_rad1:Delete();
  flight_rad2:Delete();
end;


--info:top=1890,left=70,allvis=0;
function final_Failed_1()
  lMission = 0;
  LastochkaSpeaker:Message("#L_Lastochka_04", 10);
  AddQuest("quest_9c_03", "#L_Quest_9c_03a", "#L_Quest_9c_03b", QUEST_PROCESS);
end;


--info:top=990,left=460,allvis=0;
function final_Failed_2()
  lMission = 0;
  if (flight_pir5:IsAlive()) then
    flight_pir5:Move(Vector3(3000, 500, -3000));
    trig_PirF5:Delete();
  end;
  if (flight_pir6:IsAlive()) then
    flight_pir6:Move(Vector3(3020, 500, -3020));
    trig_PirF6:Delete();
  end;
  if (flight_pir7:IsAlive()) then
    flight_pir7:Move(Vector3(3040, 500, -3040));
    trig_PirF7:Delete();
  end;
  if (flight_pir8:IsAlive()) then
    flight_pir8:Move(Vector3(3060, 500, -3060));
    trig_PirF8:Delete();
  end;
  if (flight_pir9:IsAlive()) then
    flight_pir9:Move(Vector3(3080, 500, -3080));
    trig_PirF9:Delete();
  end;
  if (flight_pir10:IsAlive()) then
    flight_pir10:Move(Vector3(3100, 500, -3100));
    trig_PirF10:Delete();
  end;
  if (flight_pir11:IsAlive()) then
    flight_pir11:Move(Vector3(3120, 500, -3120));
    trig_PirF11:Delete();
  end;
  if (flight_pir12:IsAlive()) then
    flight_pir12:Move(Vector3(3140, 500, -3140));
    trig_PirF12:Delete();
  end;
  if (flight_pir13:IsAlive()) then
    flight_pir13:Move(Vector3(3160, 500, -3160));
    trig_PirF13:Delete();
  end;
  if (flight_pir14:IsAlive()) then
    flight_pir14:Move(Vector3(3180, 500, -3180));
    trig_PirF14:Delete();
  end;
  LastochkaSpeaker:Message("#L_Lastochka_05", 4, "final_Failed_2_1");
end;


--info:top=1030,left=460,allvis=0;
function final_Failed_2_1()
  HeroSpeaker:Message("#L_Hero_04", 6, "final_Failed_2_2");
end;


--info:top=1070,left=460,allvis=0;
function final_Failed_2_2()
  SedoySpeaker:Message("#L_Sedoy_05", 10);
  AddQuest("quest_9c_03", "#L_Quest_9c_03a", "#L_Quest_9c_03b", QUEST_PROCESS);
end;


--info:top=110,left=290,allvis=0;
function StartInitMission()
  MercTeam = CreateTeam("Merc");
  KfniTeam = CreateTeam("Kfni");
  PirateTeam = CreateTeam("Pirates");
  
  MothershipPilot = mothership:GetPilot();
  MothershipFlight = MothershipPilot:GetFlight();
  
  Player_Group = MothershipPilot:GetGroup();
  Merc_Group = MercTeam:CreateGroup("Merc_Group");
  Kfni_Group = KfniTeam:CreateGroup("Kfni_Group");
  Pirate_Group = PirateTeam:CreateGroup("Pirate_Group");
  groups_for_rel = {Merc_Group,Kfni_Group,Pirate_Group,Player_Group};
  rel_neutral = {{"N"},
                 {"N","N"},
                 {"N","N","N"}};
  rel_kfniwar = {{"X"},
                 {"X","X"},
                 {"X","W","X"}};
  rel_allwar = {{"X"},
                 {"X","X"},
                 {"W","W","W"}};
  rel_pirwar = {{"X"},
                 {"X","W"},
                 {"X","X","W"}};
  rel_mercwar = {{"W"},
                 {"X","X"},
                 {"W","X","X"}};
  new_SetAllGroupRelations(rel_neutral, groups_for_rel);
  new_SetGroupRelations("Kfni_Group", "KfniGroup_1", "F");
  
  HeroSpeaker = GetPilot("Hero");
  LastochkaSpeaker = GetPilot("Lastochka");
  SedoySpeaker = GetPilot("Sedoy");
  CheSpeaker = CreatePilot("Che");
  GuardSpeaker = CreatePilot("m9c_Guard");
  LaVertiSpeaker = CreatePilot("m9c_LaVerti");
  KrugerSpeaker = CreatePilot("m9c_Kruger");
  KfniSpeaker = CreatePilot("KfniAce");
  DispSpeaker = CreatePilot("DispetcherKFNI");
  SysSpeaker = CreatePilot("Hint");

-- караван Ла'Верти
  NewFlight("Merc_Group", "merc1", "Arba", "Trader", PORTAL_R:GetPosition()+Vector3(-30, 5, -60), Vector3(-1, 0, 0));
  NewShip("merc1_2", "Btransport", "Trader", PORTAL_R:GetPosition()+Vector3(-10, 5, -80), Vector3(-1, 0, 0));
  flight_merc1:AddShip(ship_merc1_2);
  NewShip("merc1_3", "Btransport", "Trader", PORTAL_R:GetPosition()+Vector3(-10, 5, -40), Vector3(-1, 0, 0));
  flight_merc1:AddShip(ship_merc1_3);
  NewShip("merc1_4", "Walrus_tr8", "Trader", PORTAL_R:GetPosition()+Vector3(-10, 25, -60), Vector3(-1, 0, 0));
  flight_merc1:AddShip(ship_merc1_4);
  NewShip("merc1_5", "Walrus_tr9", "Trader", PORTAL_R:GetPosition()+Vector3(-10, -15, -60), Vector3(-1, 0, 0));
  flight_merc1:AddShip(ship_merc1_5);
  NewGreenFlight("Merc_Group", "merc2", PORTAL_R:GetPosition()+Vector3(-10, 25, -80), 1, 10, Vector3(-1, 0, 0));
  flight_merc2:Escort(ship_merc1_1);

  trig_AttackLaVerti = NewTrigger("reps", TrueCondition, Attack_Caravan, Player_Group, Merc_Group, RELATION_WAR);

-- патруль КФНИ
  NewKfniFlight("Kfni_Group", "kfni1", PORTAL_R:GetPosition()+Vector3(-40, 10, 0), 1, 16, Vector3(1, 0, 0));
  NewKfniFlight("Kfni_Group", "kfni2", PORTAL_R:GetPosition()+Vector3(-40, 30, 0), 1, 16, Vector3(1, 0, 0));
  NewKfniFlight("Kfni_Group", "kfni3", PORTAL_R:GetPosition()+Vector3(-60, 10, 20), 1, 14, Vector3(1, 0, 0));
  NewKfniFlight("Kfni_Group", "kfni4", PORTAL_R:GetPosition()+Vector3(-60, 10, -20), 1, 14, Vector3(1, 0, 0));
  NewKfniFlight("Kfni_Group", "kfni5", MINING:GetPosition()+Vector3(-30, 20, -30), 1, 14, Vector3(1, 0, 0));

  trig_AttackKfni = NewTrigger("reps", TrueCondition, Attack_Caravan, Player_Group, Kfni_Group, RELATION_WAR);
  SetQuestLabel("Kruger", "yes");
-- метка миссии
  lMission = 0;
end;


--info:top=260,left=290,allvis=0;
function Attack_Caravan()
  new_SetAllGroupRelations(rel_allwar, groups_for_rel);
  SetQuestState("quest_9c_02", QUEST_FAILED);
  SetQuestLabel("Kruger", "no");
  KfniSpeaker:Message("#L_kfni_01", 3, "After_Attack_Caravan");
end;


--info:top=300,left=290,allvis=0;
function After_Attack_Caravan()
  SedoySpeaker:Message("#L_Sedoy_01", 4);
end;


--info:top=70,left=80,allvis=0;
function ACTION_INIT()
  StartInitMission();

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


--info:top=70,left=570,allvis=0;
function ACTION_LEAVELOCATION()
  if (LineToStation) then LineToStation:Delete(); end;
  if (nav_target) then nav_target:Delete(); end;
  if (nav_AttackPoint) then nav_AttackPoint:Delete(); end;
  if (LineToTransport) then LineToTransport:Delete(); end;
  if (nav_current) then nav_current:Delete(); end;
  if (nav_Transports) then nav_Transports:Delete(); end;
  if (lMission==6) then
    QuestActionDone();
  else
    if (GetQuestState("quest_9c_01")~=QUEST_NOINIT) then RemoveQuest("quest_9c_01"); end;
    if (GetQuestState("quest_9c_02")~=QUEST_NOINIT) then RemoveQuest("quest_9c_02"); end;
    if (GetQuestState("quest_9c_03")~=QUEST_NOINIT) then RemoveQuest("quest_9c_03"); end;
    if (GetQuestState("quest_9c_04")~=QUEST_NOINIT) then RemoveQuest("quest_9c_04"); end;
    if (GetQuestState("quest_9c_05")~=QUEST_NOINIT) then RemoveQuest("quest_9c_05"); end;
    if (GetQuestState("quest_9c_06")~=QUEST_NOINIT) then RemoveQuest("quest_9c_06"); end;
    if (GetQuestState("quest_9c_07")~=QUEST_NOINIT) then RemoveQuest("quest_9c_07"); end;
    if (GetQuestState("quest_9c_08")~=QUEST_NOINIT) then RemoveQuest("quest_9c_08"); end;
    if (CheSpeaker) then
      if (CheSpeaker:IsAlive()) then
        if (CheSpeaker:GetSide()==PLAYER_TEAM) then
          Player_Team = CreateTeam(PLAYER_TEAM);
          Player_Team:RemovePilot(CheSpeaker);
          CheSpeaker:Kill();
        end;
      end;
    end;
    if (GetQuestLabel("Kruger")=="yes") then
      AddPost("book009c_2");
    elseif (GetQuestLabel("Kruger")=="no") then
      AddPost("book009c_7");
    else
      AddPost("book009c_3");
    end;
    QuestActionDone();
    ClearQuests();
    PauseInMissionActivity("__start_Mission8d", 1);
  end;

  return TRUE;
end;


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

  return TRUE;
end;
