------------------------------------------------------------
--     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()
  if (lChase=="yes") then
    NewTrigger("f_died", TrueCondition, Dikkens_ComeOn, flight_tri1);
  else
    Timer_Seq(20, Dikkens_ComeOn);
  end;
end;


--info:top=150,left=80,allvis=0;
function Dikkens_ComeOn()
  PORTAL_L:Start(8, 0);
  NewInocoFlight("Dikkens_Group", "ino1", PORTAL_D:GetPosition()+Vector3(0,0,20), 1, 14, Vector3(0,0,1));
  NewInocoFlight("Dikkens_Group", "ino2", PORTAL_D:GetPosition()+Vector3(10,10,15), 1, 13, Vector3(0,0,1));
  NewInocoFlight("Dikkens_Group", "ino3", PORTAL_D:GetPosition()+Vector3(-10,10,15), 1, 13, Vector3(0,0,1));
  flight_ino2:Escort(ship_ino1_1);
  flight_ino3:Escort(ship_ino1_1);
  flight_ino1:Move(PORTAL_D:GetPosition()+Vector3(30,0,80));
  if (lChase=="yes") then
    NewTriadaFlight("Defend_Group", "tri2", PORTAL_D:GetPosition() + Vector3(200, 10, 350), 1, 13, Vector3(0, 0, -1));
    NewTriadaFlight("Defend_Group", "tri3", PORTAL_D:GetPosition() + Vector3(230, 10, 333), 1, 14, Vector3(0, 0, -1));
    NewTriadaFlight("Defend_Group", "tri4", PORTAL_D:GetPosition() + Vector3(270, 10, 317), 1, 13, Vector3(0, 0, -1));
    flight_tri2:Attack(mothership);
    flight_tri3:Attack(mothership);
    flight_tri4:Attack(mothership);
    trig_FB2Near = NewTrigger("f_object_inside", TrueCondition, Lastochka_Remark, flight_tri2, mothership, 100);
    trig_FB3Near = NewTrigger("f_object_inside", TrueCondition, Lastochka_Remark, flight_tri3, mothership, 100);
    trig_FB4Near = NewTrigger("f_object_inside", TrueCondition, Lastochka_Remark, flight_tri4, mothership, 100);
    SetAllDied({flight_tri2,flight_tri3,flight_tri4}, Next_Ambush);
  else
    NewTriadaFlight("Defend_Group", "tri2", PORTAL_D:GetPosition() + Vector3(200, 10, 450), 1, 14, Vector3(0, 0, -1));
    NewTriadaFlight("Defend_Group", "tri3", PORTAL_D:GetPosition() + Vector3(230, 10, 433), 1, 13, Vector3(0, 0, -1));
    NewTriadaFlight("Defend_Group", "tri4", PORTAL_D:GetPosition() + Vector3(270, 10, 417), 1, 14, Vector3(0, 0, -1));
    NewTriadaFlight("Defend_Group", "tri5", PORTAL_D:GetPosition() + Vector3(300, 10, 400), 1, 13, Vector3(0, 0, -1));
    flight_tri2:Attack(mothership);
    flight_tri3:Attack(mothership);
    flight_tri4:Attack(mothership);
    flight_tri5:Attack(mothership);
    SetAllDied({flight_tri2,flight_tri3,flight_tri4,flight_tri5}, GoTo_Station);
  end;
  Timer_Seq(10,Next_ComeOn);
end;


--info:top=180,left=140,allvis=0;
function Lastochka_Remark()
  trig_FB2Near:Activate(FALSE);
  trig_FB3Near:Activate(FALSE);
  trig_FB4Near:Activate(FALSE);
  LastochkaSpeaker:Message("#L_Lastochka_02",4);
end;


--info:top=210,left=140,allvis=0;
function Next_ComeOn()
--  NewInocoFlight("Dikkens_Group", "ino4", PORTAL_D:GetPosition()+Vector3(0,0,20), 1, 14, Vector3(0,0,1));
--  NewInocoFlight("Dikkens_Group", "ino5", PORTAL_D:GetPosition()+Vector3(10,10,15), 1, 13, Vector3(0,0,1));
--  NewInocoFlight("Dikkens_Group", "ino6", PORTAL_D:GetPosition()+Vector3(-10,10,15), 1, 13, Vector3(0,0,1));
--  flight_ino4:Escort(ship_ino1_1);
--  flight_ino5:Escort(ship_ino4_1);
--  flight_ino6:Escort(ship_ino4_1);
  flight_ino1:Escort(mothership);
  LineToStation = CreateLine(NP_PORTAL_D, np_triada, RGB(20,80,220), .3,TRUE,.2, 1);
end;


--info:top=250,left=130,allvis=0;
function Next_Ambush()
  DikkensSpeaker:Message("#L_Dikkens_04",5);
  NewTriadaFlight("Defend_Group", "tri1", TRIADA:GetPosition() + Vector3(-200, 10, -300), 1, 4, Vector3(0, 0, -1));
  NewTriadaFlight("Defend_Group", "tri2", TRIADA:GetPosition() + Vector3(-175, 10, -325), 1, 6, Vector3(0, 0, -1));
  NewTriadaFlight("Defend_Group", "tri3", TRIADA:GetPosition() + Vector3(-150, 10, -350), 1, 5, Vector3(0, 0, -1));
  NewTriadaFlight("Defend_Group", "tri4", TRIADA:GetPosition() + Vector3(-125, 10, -375), 1, 7, Vector3(0, 0, -1));
  NewTriadaFlight("Defend_Group", "tri5", TRIADA:GetPosition() + Vector3(-100, 10, -400), 1, 6, Vector3(0, 0, -1));
  flight_tri1:Attack(mothership);
  flight_tri2:Attack(mothership);
  flight_tri3:Attack(mothership);
  flight_tri4:Attack(mothership);
  flight_tri5:Attack(mothership);
  trig_F1Near = NewTrigger("f_object_inside", TrueCondition, Chase_ComeOn, flight_tri1, mothership, 150);
  trig_F2Near = NewTrigger("f_object_inside", TrueCondition, Chase_ComeOn, flight_tri2, mothership, 150);
  trig_F3Near = NewTrigger("f_object_inside", TrueCondition, Chase_ComeOn, flight_tri3, mothership, 150);
  trig_F4Near = NewTrigger("f_object_inside", TrueCondition, Chase_ComeOn, flight_tri4, mothership, 150);
  trig_F5Near = NewTrigger("f_object_inside", TrueCondition, Chase_ComeOn, flight_tri5, mothership, 150);
  count = 5;
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri1);
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri2);
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri3);
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri4);
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri5);
end;


--info:top=300,left=210,allvis=0;
function Chase_ComeOn()
  count = count + 6;
  NewTriadaFlight("Defend_Group", "tri6", PORTAL_D:GetPosition() + Vector3(50, 10, 150), 1, 14, Vector3(0, 0, 1));
  NewTriadaFlight("Defend_Group", "tri7", PORTAL_D:GetPosition() + Vector3(80, 10, 133), 1, 13, Vector3(0, 0, 1));
  NewTriadaFlight("Defend_Group", "tri8", PORTAL_D:GetPosition() + Vector3(120, 10, 117), 1, 14, Vector3(0, 0, 1));
  NewTriadaFlight("Defend_Group", "tri9", PORTAL_D:GetPosition() + Vector3(150, 10, 100), 1, 13, Vector3(0, 0, 1));
  NewTriadaFlight("Defend_Group", "tri10", PORTAL_D:GetPosition() + Vector3(120, 30, 117), 1, 14, Vector3(0, 0, 1));
  NewTriadaFlight("Defend_Group", "tri11", PORTAL_D:GetPosition() + Vector3(80, 30, 133), 1, 13, Vector3(0, 0, 1));
  flight_tri6:Move(mothership:GetPosition()+Vector3(-30, 10, -50));
  flight_tri7:Move(mothership:GetPosition()+Vector3(-30, 30, -50));
  flight_tri8:Move(mothership:GetPosition()+Vector3(-60, 10, -30));
  flight_tri9:Move(mothership:GetPosition()+Vector3(-40, 10, -40));
  flight_tri10:Move(mothership:GetPosition()+Vector3(-60, 30, -30));
  flight_tri11:Move(mothership:GetPosition()+Vector3(-40, -20, -40));
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri6);
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri7);
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri8);
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri9);
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri10);
  NewTrigger("f_died", DiedCondition, GoTo_Station, flight_tri11);
  trig_F1Near:Activate(FALSE);
  trig_F2Near:Activate(FALSE);
  trig_F3Near:Activate(FALSE);
  trig_F4Near:Activate(FALSE);
  trig_F5Near:Activate(FALSE);
  StartDialog("Dialog5");
end;


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


--info:top=340,left=260,allvis=0;
function Inoco_Attack_Chase()
  flight_ino1:Move(mothership:GetPosition()+Vector3(-70, 10, -110));
  count = flight_ino1:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_ino1:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetGodMode();
  end;
  flight_ino2:Move(mothership:GetPosition()+Vector3(-80, 10, -120));
  count = flight_ino2:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_ino2:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetGodMode();
  end;
  flight_ino3:Move(mothership:GetPosition()+Vector3(-75, 30, -115));
  count = flight_ino3:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_ino3:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetGodMode();
  end;
end;


--info:top=390,left=80,allvis=0;
function GoTo_Station()
  flight_ino1:Escort(mothership);
  count = flight_ino1:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_ino1:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetGodMode(FALSE);
  end;
  flight_ino2:Escort(mothership);
  count = flight_ino2:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_ino2:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetGodMode(FALSE);
  end;
  flight_ino3:Escort(mothership);
  count = flight_ino3:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_ino3:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:SetGodMode(FALSE);
  end;
  DikkensSpeaker:Message("#L_Dikkens_05",5);
  NewTriadaFlight("Defend_Group", "tri1", TRIADA:GetPosition() + Vector3(-50, 10, -50), 1, 4, Vector3(0, 0, -1));
  NewTriadaFlight("Defend_Group", "tri2", TRIADA:GetPosition() + Vector3(-60, 10, -60), 1, 6, Vector3(0, 0, -1));
  NewTriadaFlight("Defend_Group", "tri3", TRIADA:GetPosition() + Vector3(-100, 10, -20), 1, 5, Vector3(0, 0, -1));
  NewTriadaFlight("Defend_Group", "tri4", TRIADA:GetPosition() + Vector3(-90, 10, 0), 1, 4, Vector3(0, 0, -1));
  NewTrigger("inside", TrueCondition, Final_Attack, mothership, TRIADA:GetPosition(), 200);
end;


--info:top=430,left=80,allvis=0;
function Final_Attack()
  LineToStation:Delete();
  SetQuestState("quest_8e_03", QUEST_DONE);
  count = 0;
  if ((flight_tri1) and (flight_tri1:IsAlive())) then
    NewTrigger("f_died", DiedCondition, No_Final, flight_tri1);
    count = count + 1;
  end; 
  if ((flight_tri2) and (flight_tri2:IsAlive())) then
    NewTrigger("f_died", DiedCondition, No_Final, flight_tri2);
    count = count + 1;
  end; 
  if ((flight_tri3) and (flight_tri3:IsAlive())) then
    NewTrigger("f_died", DiedCondition, No_Final, flight_tri3);
    count = count + 1;
  end; 
  if ((flight_tri4) and (flight_tri4:IsAlive())) then
    NewTrigger("f_died", DiedCondition, No_Final, flight_tri4);
    count = count + 1;
  end;
  if (count>0) then 
    SedoySpeaker:Message("#L_Sedoy_01",5,"Next_Final");
  else
    SedoySpeaker:Message("#L_Sedoy_01",5,"No_Final");
  end;
end;


--info:top=470,left=80,allvis=0;
function Next_Final()
  HeroSpeaker:Message("#L_Hero_04",4);
end;


--info:top=510,left=80,allvis=0;
function No_Final()
  if (flight_ino1:IsAlive()) then flight_ino1:Stop(); end;
  if (flight_ino2:IsAlive()) then flight_ino2:Stop(); end;
  if (flight_ino3:IsAlive()) then flight_ino3:Stop(); end;
  NewTriadaFlight("Defend_Group", "tri1", mothership:GetPosition() + Vector3(50, 40, 70), 2, 17, Vector3(-0.5, 0, -0.5));
  count = flight_tri1:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_tri1:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  NewTriadaFlight("Defend_Group", "tri2", mothership:GetPosition() + Vector3(60, 30, 60), 2, 17, Vector3(-0.5, 0, -0.5));
  count = flight_tri2:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_tri2:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  LastochkaSpeaker:Message("#L_Lastochka_03",3);
  Timer_Seq(5,Grey_ComeOn);
end;


--info:top=550,left=80,allvis=0;
function Grey_ComeOn()
  NewGreyFlight("Grey_Group", "gr1", mothership:GetPosition() + Vector3(100, 40, 100), 1, 17, Vector3(-0.5, 0, -0.5));
  count = flight_gr1:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_gr1:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  NewGreyFlight("Grey_Group", "gr2", mothership:GetPosition() + Vector3(110, 30, 90), 1, 17, Vector3(-0.5, 0, -0.5));
  count = flight_gr2:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_gr2:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  new_SetGroupRelations("Grey_Group","Defend_Group","W");
  SetAllDied({flight_tri1,flight_tri2}, Grey_Dialog);
end;


--info:top=590,left=80,allvis=0;
function Grey_Dialog()
  trig_AttackDikkens:Activate(FALSE);
  StartDialog("Dialog6");
end;


--info:top=630,left=80,allvis=0;
function Uel_ComeOn()
  CreatePortalGlow(mothership:GetPosition()+Vector3(-60, 0, -60), Vector3(0.5, 0, 0.5), 5);
  NewFlight("Uel_Group", "uel1", "Manticore_ino1", "Uel", mothership:GetPosition()+Vector3(-58, 0, -58), Vector3(0.5, 0, 0.5));
  ship_uel1_1:SetGodMode();
  NewInocoFlight("Uel_Group", "uel2", mothership:GetPosition()+Vector3(-58, 20, -58), 1, 16, Vector3(0.5, 0, 0.5));
  NewInocoFlight("Uel_Group", "uel3", mothership:GetPosition()+Vector3(-66, -15, -50), 1, 16, Vector3(0.5, 0, 0.5));
  NewInocoFlight("Uel_Group", "uel4", mothership:GetPosition()+Vector3(-50, -15, -66), 1, 16, Vector3(0.5, 0, 0.5));
  flight_uel2:Escort(ship_uel1_1);
  flight_uel3:Escort(ship_uel1_1);
  flight_uel4:Escort(ship_uel1_1);
  Timer_Seq(5,Uel_Dialog);
end;


--info:top=670,left=80,allvis=0;
function Uel_Dialog()
  StartDialog("Dialog7");
end;


--info:top=710,left=80,allvis=0;
function Grey_GoOut()
  CreatePortalGlow(ship_gr1_1:GetPosition()+Vector3(30, 0, 30), Vector3(-0.5, 0, -0.5), 5);
  flight_gr1:Move(ship_gr1_1:GetPosition()+Vector3(30, 0, 30));
  flight_gr2:Move(ship_gr1_1:GetPosition()+Vector3(30, 0, 30));
  Timer_Seq(5,Grey_Out);
  DikkensSpeaker:Message("#L_Dikkens_06",10,"Sedoy_Remark");
end;


--info:top=740,left=120,allvis=0;
function Grey_Out()
  flight_gr1:Delete();
  flight_gr2:Delete();
  NewTriadaFlight("Imu_Group", "imu1", TRIADA:GetPosition() + Vector3(-200, 10, -300), 1, 18, Vector3(0, 0, -1));
  NewTriadaFlight("Imu_Group", "imu2", TRIADA:GetPosition() + Vector3(-190, 10, -310), 1, 17, Vector3(0, 0, -1));
  NewTriadaFlight("Imu_Group", "imu3", TRIADA:GetPosition() + Vector3(-180, 10, -320), 1, 18, Vector3(0, 0, -1));
  NewTriadaFlight("Imu_Group", "imu4", TRIADA:GetPosition() + Vector3(-170, 10, -330), 1, 17, Vector3(0, 0, -1));
  NewTriadaFlight("Imu_Group", "imu5", TRIADA:GetPosition() + Vector3(-160, 10, -340), 1, 18, Vector3(0, 0, -1));
  NewTriadaFlight("Imu_Group", "imu6", TRIADA:GetPosition() + Vector3(-150, 10, -350), 2, 18, Vector3(0, 0, -1));
  NewTriadaFlight("Imu_Group", "imu7", TRIADA:GetPosition() + Vector3(-140, 10, -360), 2, 17, Vector3(0, 0, -1));
  NewTriadaFlight("Imu_Group", "imu8", TRIADA:GetPosition() + Vector3(-130, 10, -370), 2, 18, Vector3(0, 0, -1));
  NewTriadaFlight("Imu_Group", "imu9", TRIADA:GetPosition() + Vector3(-120, 10, -380), 2, 17, Vector3(0, 0, -1));
  NewTriadaFlight("Imu_Group", "imu10", TRIADA:GetPosition() + Vector3(-110, 10, -390), 2, 18, Vector3(0, 0, -1));
  flight_imu1:Move(mothership:GetPosition()+Vector3(-150, 10, -70));
  flight_imu2:Escort(ship_imu1_1);
  flight_imu3:Escort(ship_imu1_1);
  flight_imu4:Escort(ship_imu1_1);
  flight_imu5:Escort(ship_imu1_1);
  flight_imu6:Escort(ship_imu1_1);
  flight_imu7:Escort(ship_imu1_1);
  flight_imu8:Escort(ship_imu1_1);
  flight_imu9:Escort(ship_imu1_1);
  flight_imu10:Escort(ship_imu1_1);
end;


--info:top=760,left=80,allvis=0;
function Sedoy_Remark()
  SedoySpeaker:Message("#L_Sedoy_02",5,"Aia_ComeOn");
end;


--info:top=800,left=80,allvis=0;
function Aia_ComeOn()
  AiaSpeaker:Message("#L_Aia_01",6);
  NewFlight("Aia_Group", "aia1", "Rhino_tri1", "Aia", mothership:GetPosition()+Vector3(0, 0, -120), Vector3(0, 0, 1));
  ship_aia1_1:PlayFX("Cloak Out.shfx");
  ship_aia1_1:SetGodMode();
  NewTriadaFlight("Aia_Group", "aia2", mothership:GetPosition() + Vector3(-114, 10, -37), 1, 17, Vector3(1, 0, 0));
  count = flight_aia2:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_aia2:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
    ship_tmp:SetGodMode();
  end;
  NewTriadaFlight("Aia_Group", "aia3", mothership:GetPosition() + Vector3(-71, 10, 97), 1, 18, Vector3(0.5, 0, -0.5));
  count = flight_aia3:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_aia3:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
    ship_tmp:SetGodMode();
  end;
  NewTriadaFlight("Aia_Group", "aia4", mothership:GetPosition() + Vector3(71, 10, 97), 1, 17, Vector3(-0.5, 0, -0.5));
  count = flight_aia4:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_aia4:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
    ship_tmp:SetGodMode();
  end;
  NewTriadaFlight("Aia_Group", "aia5", mothership:GetPosition() + Vector3(114, 10, -37), 1, 18, Vector3(-1, 0, 0));
  count = flight_aia5:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_aia5:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
    ship_tmp:SetGodMode();
  end;
  NewTriadaFlight("Aia_Group", "aia6", mothership:GetPosition() + Vector3(-71, 10, -97), 2, 18, Vector3(0.5, 0, 0.5));
  count = flight_aia6:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_aia6:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  NewTriadaFlight("Aia_Group", "aia7", mothership:GetPosition() + Vector3(-114, 10, 37), 2, 17, Vector3(1, 0, 0));
  count = flight_aia7:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_aia7:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  NewTriadaFlight("Aia_Group", "aia8", mothership:GetPosition() + Vector3(0, 10, 120), 2, 18, Vector3(0, 0, -1));
  count = flight_aia8:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_aia8:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  NewTriadaFlight("Aia_Group", "aia9", mothership:GetPosition() + Vector3(114, 10, 37), 2, 17, Vector3(-1, 0, 0));
  count = flight_aia9:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_aia9:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  NewTriadaFlight("Aia_Group", "aia10", mothership:GetPosition() + Vector3(71, 10, -97), 2, 18, Vector3(-0.5, 0, 0.5));
  count = flight_aia10:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_aia10:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  Timer_Seq(5,Aia_Dialog);
end;


--info:top=840,left=80,allvis=0;
function Aia_Dialog()
  flight_aia2:Escort(ship_aia1_1);
  flight_aia3:Escort(ship_aia1_1);
  flight_aia4:Escort(ship_aia1_1);
  flight_aia5:Escort(ship_aia1_1);
  flight_aia6:Escort(ship_aia1_1);
  flight_aia7:Escort(ship_aia1_1);
  flight_aia8:Escort(ship_aia1_1);
  flight_aia9:Escort(ship_aia1_1);
  flight_aia10:Escort(ship_aia1_1);
  StartDialog("Dialog8");
end;


--info:top=880,left=80,allvis=0;
function Imu_ComeOn()
  Timer_Seq(5,Final_Dialog);
end;


--info:top=920,left=80,allvis=0;
function Final_Dialog()
  StartDialog("Dialog9");
end;


--info:top=960,left=80,allvis=0;
function All_Fight()
  new_SetAllGroupRelations(rel_allwars, groups_for_rel);
  SedoySpeaker:Message("#L_Sedoy_03",5);
  Timer_Seq(10,Where_GoOut);
  Timer_Seq(90, Uel_GoOut);
end;


--info:top=1000,left=80,allvis=0;
function Where_GoOut()
  lMission = 0;
  local inventory = GetInventory();
  while (inventory:IsExist("bomb_m")==TRUE) do
    inventory:DeleteModule("bomb_m");
  end;
  StartDialog("Dialog10");
end;


--info:top=1110,left=140,allvis=0;
function GoTo_XT20()
  LineToPortal = CreateLine(np_triada, NP_PORTAL_R, RGB(20,80,220), .3,TRUE,.2, 1);
end;


--info:top=1110,left=40,allvis=0;
function GoTo_XT93()
  LineToPortal = CreateLine(np_triada, NP_PORTAL_L, RGB(20,80,220), .3,TRUE,.2, 1);
end;


--info:top=1110,left=240,allvis=0;
function GoTo_XT52()
  LineToPortal = CreateLine(np_triada, NP_PORTAL_D, RGB(20,80,220), .3,TRUE,.2, 1);
end;


--info:top=1000,left=280,allvis=0;
function Uel_GoOut()
  local pos = ship_uel1_1:GetPosition();
  local orn = ship_uel1_1:GetVectorOrientation();
  local glow_orn = ship_uel1_1: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;
  CreatePortalGlow(pos+orn, glow_orn, 5);
  flight_uel1:Move(pos+orn);
  ship_uel1_1:PlayFX("Portal Out.shfx");
  Timer_Seq(5,Uel_Out);
end;


--info:top=1040,left=280,allvis=0;
function Uel_Out()
  flight_uel1:Delete();
  if (flight_uel2) and (flight_uel2:IsAlive()) then flight_uel2:Delete(); end;
  if (flight_uel3) and (flight_uel3:IsAlive()) then flight_uel3:Delete(); end;
  if (flight_uel4) and (flight_uel4:IsAlive()) then flight_uel4:Delete(); end;
  new_SetAllGroupRelations(rel_allvspl, groups_for_rel);
end;


--info:top=110,left=350,allvis=0;
function StartInitMis()
  InocoTeam = CreateTeam("Inoco");
  TriadaTeam = CreateTeam("Triada");
  GreyTeam = CreateTeam("Grey");

  MothershipPilot = mothership:GetPilot();
  MothershipFlight = MothershipPilot:GetFlight();

  Player_Group = MothershipPilot:GetGroup();
  Dikkens_Group = InocoTeam:CreateGroup("Dikkens_Group");
  Uel_Group = InocoTeam:CreateGroup("Uel_Group");
  Defend_Group = TriadaTeam:CreateGroup("Defend_Group");
  Aia_Group = TriadaTeam:CreateGroup("Aia_Group");
  Imu_Group = TriadaTeam:CreateGroup("Imu_Group");
  Grey_Group = GreyTeam:CreateGroup("Grey_Group");
  groups_for_rel = {Dikkens_Group,Uel_Group,Defend_Group,Aia_Group,Imu_Group,Grey_Group,Player_Group};
  rel_neutral = {{"N"},
                 {"W","N"},
                 {"N","N","N"},
                 {"N","N","N","N"},
                 {"N","N","N","N","N"},
                 {"N","N","W","N","N","N"}};
  rel_allwars = {{"W"},
                 {"X","X"},
                 {"X","X","X"},
                 {"X","X","X","W"},
                 {"X","X","X","X","X"},
                 {"X","X","X","X","X","X"}};
  rel_allvspl = {{"X"},
                 {"X","X"},
                 {"W","W","X"},
                 {"W","W","X","N"},
                 {"X","X","X","X","X"},
                 {"W","W","X","W","W","X"}};
  new_SetAllGroupRelations(rel_neutral, groups_for_rel);

  HeroSpeaker = GetPilot("Hero");
  LastochkaSpeaker = GetPilot("Lastochka");
  SedoySpeaker = GetPilot("Sedoy");
  DikkensSpeaker = CreatePilot("m7f_Dikkens");
  GreySpeaker = CreatePilot("m8e_Unknown");
  AiaSpeaker = CreatePilot("Aia");

  lChase = GetQuestLabel("Chase");
  lMission = 1;
  StopDocking(TRIADA);

  flight_tri01:Delete();
  flight_tri03:Delete();
  flight_tri04:Delete();
  flight_tri05:Delete();
  flight_tri06:Delete();
  if (lChase=="yes") then
    NewTriadaFlight("Defend_Group", "tri1", PORTAL_D:GetPosition() + Vector3(-20, 10, 70), 1, 14, Vector3(0, 0, -1));
  end;
  trig_AttackDikkens = NewTrigger("reps", TrueCondition, If_Attack_InoCo, Player_Group, Inoco_Group, RELATION_WAR);

  Teleporter:Delete();
  Teleporter = CreateTrigger();
  Teleporter:AttachEvent(_EVENT_TIMER); 
  Teleporter:SetTime(3);
  Teleporter:AttachCondition(TrueCondition);
  Teleporter:AttachAction(My_TeleporterAction);
end;


--info:top=150,left=350,allvis=0;
function If_Attack_InoCo()
  DikkensSpeaker:Message("#L_Dikkens_07",5);
  mothership:Blow();
end;


--info:top=150,left=490,allvis=0;
function My_TeleporterAction()
  if (lMission==1) then
    mothership:Blow();
  else
    SetInitTeamRelation("Triada",PLAYER_TEAM,GetGroupRelation(TriadaGroup_1,PLAYER_GROUP));
    SetInitTeamRelation("Pirates",PLAYER_TEAM,GetGroupRelation(PiratesGroup_1,PLAYER_GROUP));
    TeleportToLocation(dest_location);
  end;
end;


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

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


--info:top=70,left=570,allvis=0;
function ACTION_LEAVELOCATION()
  if (lMission==1) then
    mothership:Blow();
  else
    if (GetQuestLabel("Gunslinger")=="Yes") then
      AddPost("book008e_4");
    else
      AddPost("book008e_5");
    end;
    QuestActionDone();
    ClearQuests();
    SetInitTeamRelation("Triada", PLAYER_TEAM, RELATION_WAR);
    if (dest_location=="xt93") then
      QuestStart("mission_8e_1");
    elseif (dest_location=="xt20") then
      QuestStart("mission_8e_2");
    elseif (dest_location=="xt52") then
      QuestStart("mission_8e_3");
    else
      mothership:Blow();
    end;
  end;

  return TRUE;
end;


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

  return TRUE;
end;
