------------------------------------------------------------
--     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=140,left=40,allvis=0;
function StartMission_Neutral()
  SedoySpeaker:Message("#L_Sedoy_01",4,"Hero_Answer");
end;


--info:top=180,left=40,allvis=0;
function Hero_Answer()
  HeroSpeaker:Message("#L_Hero_01",5);
  SetQuestLabel("QuestPoint","1");
  Timer_Seq(1, GoTo_Station);
end;


--info:top=210,left=80,allvis=0;
function GoTo_Station()
  last_location = GetLastLocation();
  if (last_location == "argon") then
    LineToStation = CreateLine(NP_PORTAL_L, NP_TRADE_STATION, RGB(20,80,220), .3, TRUE, .2, 1);
  elseif (last_location == "corrino") then
    LineToStation = CreateLine(NP_PORTAL_R, NP_TRADE_STATION, RGB(20,80,220), .3, TRUE, .2, 1);
  else
    LineToStation = CreateLine(NP_PORTAL_U, NP_TRADE_STATION, RGB(20,80,220), .3, TRUE, .2, 1);
  end;
  NewTrigger("inside", TrueCondition, Peace_Agent_Dialog, mothership, TRADE_STATION:GetPosition(), 50);
end;


--info:top=250,left=80,allvis=0;
function Peace_Agent_Dialog()
  SetNormalTimeMode();
  LineToStation:Delete();
  LineToStation = NIL;
  StartDialog("Dialog1");
end;


--info:top=290,left=80,allvis=0;
function finMission_Peace()
  inventory = GetInventory();
  inventory:DeleteModule("Disk_for_mission8c");
  SetQuestState("quest_8c_02", QUEST_DONE);
  RemovePost("mail_008c_1");
  AddPost("news008_2");
  AddPost("news008_8");
  AddPost("news008_4");
  AddPost("news008_9");
  if (GetQuestLabel("Blow")~="Blowed") then
    SetQuestLabel("Blow","Blow");
  end;
  AddPost("news008_5");
  AddPost("news008_10");
  AddPost("news008_7");
  SetQuestLabel("QuestPoint","0");
  if (GetQuestLabel("OnRandomPortal_all")~="yes") then
    SetQuestLabel("OnRandomPortal_all","yes");
  end;
  AutoSave("#AS_mission_8_4");
end;


--info:top=130,left=540,allvis=0;
function StartMission_War()
  StartDialog("Dialog2");
end;


--info:top=170,left=540,allvis=0;
function Vks_Ambush()
  NewVksFlight("Vks_Group", "vks1", mothership:GetPosition()+Vector3(50, 20, -80), 1, 13, Vector3(-0.5,0,0.5));
  count = flight_vks1:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_vks1:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  NewVksFlight("Vks_Group", "vks2", mothership:GetPosition()+Vector3(45, 30, -90), 1, 12, Vector3(-0.5,0,0.5));
  count = flight_vks2:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_vks2:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  NewVksFlight("Vks_Group", "vks3", mothership:GetPosition()+Vector3(55, 30, -70), 1, 12, Vector3(-0.5,0,0.5));
  count = flight_vks3:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_vks3:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  Timer_Seq(5, Ambush_Dialog);
end;


--info:top=210,left=540,allvis=0;
function Ambush_Dialog()
  StartDialog("Dialog3");
end;


--info:top=250,left=320,allvis=0;
function Over_Agent()
  trig_AttackVks = NewTrigger("reps", TrueCondition, Attack_Vks, Player_Group, Vks_Group, RELATION_WAR);
  trig_Sit = NewTrigger("outside", TrueCondition, Upset_Sit, mothership, mothership:GetPosition(), 5);
  trig_NextStep = NewTrigger("timer", TrueCondition, Next_Step, 15);
end;


--info:top=590,left=520,allvis=0;
function Attack_Vks()
  trig_AttackVks:Delete();
  trig_AttackVks = NIL;
  if (trig_Sit) then
    trig_Sit:Delete();
    trig_Sit = NIL;
  end;
  if (trig_NextStep) then
    trig_NextStep:Delete();
    trig_NextStep = NIL;
  end;
  new_SetGroupRelations("Vks_Group",PLAYER_GROUP,"W");
  VksSpeaker:Message("#L_vks_01",4);
  Timer_Seq(10, Vks_Attack);
end;


--info:top=800,left=320,allvis=0;
function Vks_Attack()
  CreatePortalGlow(mothership:GetPosition()+Vector3(0, -130, 0), Vector3(0, 1, 0), 4);
  CreatePortalGlow(mothership:GetPosition()+Vector3(-110, 75, 0), Vector3(1, -0.5, 0), 4);
  CreatePortalGlow(mothership:GetPosition()+Vector3(85, 75, 85), Vector3(-0.5, -0.5, -0.5), 4);
  CreatePortalGlow(mothership:GetPosition()+Vector3(85, 75, -85), Vector3(-0.5, -0.5, 0.5), 4);
  NewVksFlight("Vks_Group", "sosgr_1", mothership:GetPosition()+Vector3(0, -120, 0), 1, 19,Vector3(0, 1, 0));
  flight_sosgr_1:Attack(mothership);
  NewVksFlight("Vks_Group", "sosgr_2", mothership:GetPosition()+Vector3(-100, 70, 0), 2, 19,Vector3(1, -0.5, 0));
  flight_sosgr_2:Attack(mothership);
  NewVksFlight("Vks_Group", "sosgr_3", mothership:GetPosition()+Vector3(80, 70, 80), 3, 19,Vector3(-0.5, -0.5, -0.5));
  flight_sosgr_3:Attack(mothership);
  NewVksFlight("Vks_Group", "sosgr_4", mothership:GetPosition()+Vector3(80, 70, -80), 3, 20,Vector3(-0.5, -0.5, 0.5));
  flight_sosgr_4:Attack(mothership);
  Anim_D = CreateMovie(_TARGETCAM);
  Anim_D:SetLength(6);
  Anim_D:SetInterpolate(_LINEAR);
  Anim_D:SetTarget(mothership);
  Anim_D:InitMovie(1, TRUE, 1);
  Anim_D:AddPosKey(mothership:GetPosition()+Vector3(60, 30, -30), 0);
  Anim_D:AddScriptKey("MShip_Blow", 4);
  Anim_D:Play();
  Anim_D:AttachEscapeScript("MShip_Blow");
  Anim_D:AttachAction("MShip_Blow");
end;


--info:top=840,left=320,allvis=0;
function MShip_Blow()
  if (mothership:IsAlive()) then
    mothership:Blow();
  end;
end;


--info:top=290,left=320,allvis=0;
function Upset_Sit()
  trig_Sit:Delete();
  trig_Sit = NIL;
  if (trig_AttackVks) then
    trig_AttackVks:Delete();
    trig_AttackVks = NIL;
  end;
  if (trig_NextStep) then
    trig_NextStep:Delete();
    trig_NextStep = NIL;
  end;
  new_SetGroupRelations("Vks_Group",PLAYER_GROUP,"W");
  VksSpeaker:Message("#L_vks_01",4);
  Timer_Seq(10, Vks_Attack);
end;


--info:top=340,left=220,allvis=0;
function Next_Step()
  trig_Sit:Delete();
  trig_Sit = NIL;
  trig_NextStep:Delete();
  trig_NextStep = NIL;
  StartDialog("Dialog4");
end;


--info:top=380,left=220,allvis=0;
function Vks_GoOut()
  flight_vks2:Escort(ship_vks1_1);
  flight_vks3:Escort(ship_vks1_1);
  flight_vks1:Move(Vector3(0,250,-3000));
  inventory = GetInventory();
  inventory:DeleteModule("Disk_for_mission8c");
  SetQuestState("quest_8c_02", QUEST_FAILED);
  RemovePost("mail_008c_1");
  SetQuestLabel("QuestPoint","2");
  SetInitTeamRelation("Vks",PLAYER_TEAM,RELATION_NEUTRAL);
  SetInitTeamRelation("Kfni", PLAYER_TEAM, RELATION_WAR);
-- оставляем возможность переписать репку
  Timer_Seq(5, What_Next);
end;


--info:top=420,left=220,allvis=0;
function What_Next()
  SetNormalTimeMode();
  lTriada = GetQuestLabel("Triada");
  lInoco = GetQuestLabel("Inoco");
  lVKS = GetQuestLabel("VKS");
  lAlex = GetQuestLabel("Alex");
  if (lAlex == "Maybe") then
    if (lVKS == "Maybe") then
      if (lTriada == "Maybe") then
        StartDialog("Dialog5");
      elseif (lInoco == "Maybe") then
        StartDialog("Dialog6");
      else
        StartDialog("Dialog7");
      end;
    else
      if (lTriada == "Maybe") then
        StartDialog("Dialog8");
      elseif (lInoco == "Maybe") then
        StartDialog("Dialog9");
      else
        StartDialog("Dialog10");
      end;
    end;
  else
    if (lVKS == "Maybe") then
      if (lTriada == "Maybe") then
        StartDialog("Dialog11");
      elseif (lInoco == "Maybe") then
        StartDialog("Dialog12");
      else
        StartDialog("Dialog13");
      end;
    else
      if (lTriada == "Maybe") then
        StartDialog("Dialog14");
      elseif (lInoco == "Maybe") then
        StartDialog("Dialog15");
      else
        StartDialog("Dialog16");
      end;
    end;
  end;
end;


--info:top=500,left=40,allvis=0;
function finMission_VKS()
  AddQuest("quest_7a", "#L_Quest_7a_a", "#L_Quest_7a_b", QUEST_PROCESS);
  CreateRoute("aurora", "corrino", "taira", "nj1", "nj2");
  AutoSave("#AS_mission_8_4");
  Long_Jump("nj2", "nj1", "");
end;


--info:top=500,left=160,allvis=0;
function finMission_Triada()
  AddQuest("quest_7b", "#L_Quest_7b_a", "#L_Quest_7b_b", QUEST_PROCESS);
  CreateRoute("aurora", "corrino", "taira", "nj1", "nj3", "prien", "kadi", "hanoi", "el_ariash", "dalled", "fiasar", "kadenoa", "kondel");
  AutoSave("#AS_mission_8_4");
  Long_Jump("kondel", "kadenoa", "");
end;


--info:top=500,left=300,allvis=0;
function finMission_Inoco()
  AddQuest("quest_7f", "#L_Quest_7f_a", "#L_Quest_7f_b", QUEST_PROCESS);
  CreateRoute("aurora", "corrino", "taira", "shula", "kruger", "fort_russ", "moscowia", "danstag", "heos", "egleon", "lidau");
  AutoSave("#AS_mission_8_4");
  Long_Jump("danstag", "moscowia", "");
end;


--info:top=500,left=440,allvis=0;
function finMission_Alex()
  AddQuest("quest_7d", "#L_Quest_7d_a", "#L_Quest_7d_b", QUEST_PROCESS);
  CreateRoute("aurora", "corrino", "taira", "nj1", "altrabon", "xt81", "xt41", "xt93", "xt45", "xt52", "xt54");
  AutoSave("#AS_mission_8_4");
  Long_Jump("xt54", "xt52", "");
end;


--info:top=500,left=570,allvis=0;
function finMission()
  AutoSave("#AS_mission_8_4");
end;


--info:top=250,left=830,allvis=0;
function Dont_Over_Agent()
  new_SetGroupRelations("Vks_Group",PLAYER_GROUP,"W");
  count = 2;
  trig_F1Vks = NewTrigger("f_died", DiedCondition, Reinforcement, flight_vks1);
  trig_F2Vks = NewTrigger("f_died", DiedCondition, Reinforcement, flight_vks2);
  trig_F3Vks = NewTrigger("f_died", DiedCondition, Reinforcement, flight_vks3);
  SetQuestLabel("QuestPoint","3");
end;


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


--info:top=290,left=830,allvis=0;
function Reinforcement()
  trig_F1Vks:Delete();
  trig_F2Vks:Delete();
  trig_F3Vks:Delete();
  NewVksFlight("Vks_Group", "vks4", mothership:GetPosition()+Vector3(-100, 20, -50), 1, 13, Vector3(0.5,0,0.5));
  count = flight_vks4:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_vks4:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  NewVksFlight("Vks_Group", "vks5", mothership:GetPosition()+Vector3(-105, 30, -50), 1, 12, Vector3(0.5,0,0.5));
  count = flight_vks5:GetPilotCount();
  for i=0,count,1 do
    pilot_tmp = flight_vks5:GetPilotByNumber(i);
    ship_tmp = pilot_tmp:GetShip();
    ship_tmp:PlayFX("Cloak Out.shfx");
  end;
  count = 3;
  if (flight_vks1:IsAlive()) then
    NewTrigger("f_died", DiedCondition, After_Fight, flight_vks1);
  elseif (flight_vks2:IsAlive()) then
    NewTrigger("f_died", DiedCondition, After_Fight, flight_vks2);
  else
    NewTrigger("f_died", DiedCondition, After_Fight, flight_vks3);
  end;
  NewTrigger("f_died", DiedCondition, After_Fight, flight_vks4);
  NewTrigger("f_died", DiedCondition, After_Fight, flight_vks5);
end;


--info:top=360,left=830,allvis=0;
function After_Fight()
  LastochkaSpeaker:Message("#L_Lastochka_01",4,"Sedoy_Remark");
end;


--info:top=400,left=830,allvis=0;
function Sedoy_Remark()
  SedoySpeaker:Message("#L_Sedoy_02",12);
  nav_current = CreateNavPoint("", mothership:GetPosition(),"nav_void.dds", RGB(255,255,255), mothership);
  nav_Hiding = CreateNavPoint("", Vector3(750, 0, 550),"nav_default.dds", RGB(255,255,255));
  LineToHiding = CreateLine(nav_current, nav_Hiding, RGB(20,80,220), .3, TRUE, .2, 1);
  NewTrigger("inside", TrueCondition, Base_Hided, mothership, Vector3(750, 0, 550), 100);
  trig_F1Pat = NewTrigger("f_object_inside", TrueCondition, Attack_Vks, flight_vksP1, mothership, 100);
  trig_F2Pat = NewTrigger("f_object_inside", TrueCondition, Attack_Vks, flight_vksP2, mothership, 100);
  trig_F3Pat = NewTrigger("f_object_inside", TrueCondition, Attack_Vks, flight_vksP3, mothership, 100);
  trig_F4Pat = NewTrigger("f_object_inside", TrueCondition, Attack_Vks, flight_vksP4, mothership, 100);
  AddQuest("quest_8c_04", "#L_Quest_8c_04a", "#L_Quest_8c_04b", QUEST_PROCESS);
end;


--info:top=440,left=830,allvis=0;
function Base_Hided()
  SetQuestState("quest_8c_04", QUEST_DONE);
  trig_F1Pat:Delete();
  trig_F2Pat:Delete();
  trig_F3Pat:Delete();
  trig_F4Pat:Delete();
  LineToHiding:Delete();
  LineToHiding = NIL;
  nav_Hiding:Delete();
  nav_Hiding = NIL;
  nav_current:Delete();
  nav_current = NIL;
  StartDialog("Dialog17");
end;


--info:top=530,left=680,allvis=0;
function Sedoy_Only()
  if (SedoySpeaker:IsInBase())or(SedoySpeaker:IsBasePilot()) then
    SysSpeaker:Message("#L_sysmsg_01",10,"Sedoy_Only");
  else
    Sedoy_GoTo_Station();
  end;
end;


--info:top=560,left=640,allvis=0;
function Sedoy_GoTo_Station()
  SedoyFlight = SedoySpeaker:GetFlight();
  if (SedoyFlight:GetPilotCount() > 1) then
    SysSpeaker:Message("#L_sysmsg_01",10,"Sedoy_Only");
  else
    inventory = GetInventory();
    inventory:DeleteModule("Disk_for_mission8c");
    Player_Group:RemoveFlight(SedoyFlight);
    SedoyFlight:Move(TRADE_STATION:GetPosition()+Vector3(50, 20, 50));
    AddQuest("quest_8c_05", "#L_Quest_8c_05a", "#L_Quest_8c_05b", QUEST_PROCESS);
    trig_Patrol = NewTrigger("f_outside", Trig_Cond, Patrol_ComeOn, SedoyFlight, mothership:GetPosition(), 250);
    trig_Final = NewTrigger("outside", Trig_Cond, Final_Attack, mothership, mothership:GetPosition(), 350);
  end;
end;


--info:top=530,left=830,allvis=0;
function Sedoy_Lastochka()
  if (SedoySpeaker:IsInBase())or(SedoySpeaker:IsBasePilot())or(LastochkaSpeaker:IsInBase())or(LastochkaSpeaker:IsBasePilot()) then
    SysSpeaker:Message("#L_sysmsg_02",10,"Sedoy_Lastochka");
  else
    Sedoy_Lastochka_GoTo_Station();
  end;
end;


--info:top=560,left=800,allvis=0;
function Sedoy_Lastochka_GoTo_Station()
  SedoyFlight = SedoySpeaker:GetFlight();
  LastochkaFlight = LastochkaSpeaker:GetFlight();
  HeroFlight = HeroSpeaker:GetFlight();
  if ((SedoyFlight:GetPilotCount() > 1)and(SedoyFlight==HeroFlight))or((LastochkaFlight:GetPilotCount() > 1)and(LastochkaFlight==HeroFlight)) then
    SysSpeaker:Message("#L_sysmsg_02",10,"Sedoy_Lastochka");
  else
    inventory = GetInventory();
    inventory:DeleteModule("Disk_for_mission8c");
    Player_Group:RemoveFlight(SedoyFlight);
    if (SedoyFlight~=LastochkaFlight) then
      Player_Group:RemoveFlight(LastochkaFlight);
      SedoyFlight:AddShip(LastochkaSpeaker:GetShip());
    end;
    SedoyFlight:Move(TRADE_STATION:GetPosition()+Vector3(50, 20, 50));
    AddQuest("quest_8c_06", "#L_Quest_8c_06a", "#L_Quest_8c_06b", QUEST_PROCESS);
    trig_Patrol = NewTrigger("f_outside", Trig_Cond, Patrol_ComeOn, SedoyFlight, mothership:GetPosition(), 250);
    trig_Final = NewTrigger("outside", Trig_Cond, Final_Attack, mothership, mothership:GetPosition(), 350);
  end;
end;


--info:top=640,left=800,allvis=0;
function Final_Attack()
  VksSpeaker:Message("#L_vks_02",4);
  Timer_Seq(1, Vks_Attack);
end;


--info:top=640,left=670,allvis=0;
function Patrol_ComeOn()
  NewVksFlight("Vks_Group", "vks1", mothership:GetPosition()+Vector3(-350, 20, -80), 1, 13, Vector3(1,0,0));
  NewVksFlight("Vks_Group", "vks2", mothership:GetPosition()+Vector3(-360, 30, -90), 1, 12, Vector3(1,0,0));
  flight_vks2:Escort(ship_vks1_1);
  flight_vks1:Move(mothership:GetPosition());
  trig_PatrolAttack = NewTrigger("group_inobject", TrueCondition, Patrol_Attack, "Vks_Group", mothership, 120);
  trig_DiedAttack1 = NewTrigger("f_died", TrueCondition, Patrol_Attack, flight_vks1);
  trig_DiedAttack2 = NewTrigger("f_died", TrueCondition, Patrol_Attack, flight_vks2);
end;


--info:top=770,left=670,allvis=0;
function Patrol_Attack()
  if (trig_PatrolAttack) then
    trig_PatrolAttack:Delete();
    trig_PatrolAttack = NIL;
  end;
  if (trig_DiedAttack1) then
    trig_DiedAttack1:Delete();
    trig_DiedAttack1 = NIL;
  end;
  if (trig_DiedAttack2) then
    trig_DiedAttack2:Delete();
    trig_DiedAttack2 = NIL;
  end;
  new_SetGroupRelations("Vks_Group", PLAYER_GROUP, "W");
  VksSpeaker:Message("#L_vks_03",5,"Hero_Call");
  SedoyFlight:Move(mothership:GetPosition()+Vector3(-50, 20, -50));
--------------------------------------------------------------------------------
--  NewTrigger("f_object_inside", TrueCondition, Return_Sedoy, SedoyFlight, mothership, 150);
  NewTrigger("f_object_inside", TrueCondition, count_or_go_on, SedoyFlight, mothership, 150);
--------------------------------------------------------------------------------
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
      Return_Sedoy();
    end;
  else
    Return_Sedoy();
  end; 
end;

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



--info:top=800,left=700,allvis=0;
function Hero_Call()
  HeroSpeaker:Message("#L_Hero_02",4);
end;


--info:top=820,left=670,allvis=0;
function Return_Sedoy()
  trig_Final:Delete();
  Player_Group:AddFlight(SedoyFlight);
  SedoyFlight:Escort(mothership);
  SetQuestState("quest_8c_02", QUEST_DONE);
  RemovePost("mail_008c_1");
  AddPost("news008_2");
  AddPost("news008_8");
  AddPost("news008_4");
  AddPost("news008_9");
  if (GetQuestLabel("Blow")~="Blowed") then
    SetQuestLabel("Blow","Blow");
  end;
  AddPost("news008_5");
  AddPost("news008_10");
  AddPost("news008_7");
  if (GetQuestState("quest_8c_05")==QUEST_PROCESS) then SetQuestState("quest_8c_05", QUEST_DONE); end;
  if (GetQuestState("quest_8c_06")==QUEST_PROCESS) then SetQuestState("quest_8c_06", QUEST_DONE); end;
  SedoySpeaker:Message("#L_Sedoy_03",4,"Mission_Done");
end;


--info:top=860,left=670,allvis=0;
function Mission_Done()
  SetQuestLabel("QuestPoint","0");
  HeroSpeaker:Message("#L_Hero_03",5);
  if (GetQuestLabel("OnRandomPortal_all")~="yes") then
    SetQuestLabel("OnRandomPortal_all","yes");
  end;
  AutoSave("#AS_mission_8_4");
end;


--info:top=530,left=1060,allvis=0;
function All_To_Station()
  if (SedoySpeaker:IsInBase())or(SedoySpeaker:IsBasePilot())or(LastochkaSpeaker:IsInBase())or(LastochkaSpeaker:IsBasePilot())or(HeroSpeaker:IsInBase())or(HeroSpeaker:IsBasePilot()) then
    SysSpeaker:Message("#L_sysmsg_03",10,"All_To_Station");
  else
    All_GoTo_Station();
  end;
end;


--info:top=570,left=1060,allvis=0;
function All_GoTo_Station()
  SedoyFlight = SedoySpeaker:GetFlight();
  LastochkaFlight = LastochkaSpeaker:GetFlight();
  HeroFlight = HeroSpeaker:GetFlight();
  if (HeroFlight~=LastochkaFlight) then
    HeroFlight:AddShip(LastochkaSpeaker:GetShip());
  end;
  if (HeroFlight~=SedoyFlight) then
    HeroFlight:AddShip(SedoySpeaker:GetShip());
  end;
  inventory = GetInventory();
  inventory:DeleteModule("Disk_for_mission8c");
  new_SetGroupRelations("Vks_Group",PLAYER_GROUP,"N");
  HeroFlight:Move(TRADE_STATION:GetPosition()+Vector3(50, 20, 50));
  NewTrigger("f_inside", Trig_Cond, Last_Dialog, HeroFlight, TRADE_STATION:GetPosition(), 120);
  NewTrigger("outside", Trig_Cond, Final_Attack, mothership, mothership:GetPosition(), 350);
  NewVksFlight("Vks_Group", "vks1", TRADE_STATION:GetPosition()+Vector3(50, 20, 50), 1, 13, Vector3(0.5,0,0.5));
  NewVksFlight("Vks_Group", "vks2", TRADE_STATION:GetPosition()+Vector3(40, 30, 40), 1, 12, Vector3(0.5,0,0.5));
end;


--info:top=610,left=1060,allvis=0;
function Last_Dialog()
  SetNormalTimeMode();
  HeroFlight:Stop();
  StartDialog("Dialog18");
end;


--info:top=650,left=1060,allvis=0;
function Last_Attack()
  new_SetGroupRelations("Vks_Group",PLAYER_GROUP,"W");
  mRadar1 = Player_Group:CreateShipAttachedRadar(HeroSpeaker:GetShip());
  flight_vksP1:Attack(HeroSpeaker:GetShip());
  flight_vksP2:Attack(HeroSpeaker:GetShip());
  flight_vksP3:Attack(HeroSpeaker:GetShip());
  flight_vksP4:Attack(HeroSpeaker:GetShip());
  Timer_Seq(1, Vks_Attack);
end;


--info:top=130,left=230,allvis=0;
function StartInitMis()
  VksTeam = CreateTeam("Vks");

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

  Player_Group = MothershipPilot:GetGroup();
  Vks_Group = VksTeam:CreateGroup("Vks_Group");
  new_SetGroupRelations("Vks_Group",PLAYER_GROUP,"N");

  HeroSpeaker = GetPilot("Hero");
  LastochkaSpeaker = GetPilot("Lastochka");
  SedoySpeaker = GetPilot("Sedoy");
  VksSpeaker = CreatePilot("VksOfficer");
  SysSpeaker = CreatePilot("Hint");

  ClearRoute();

  NewVksFlight("Vks_Group", "vksP1", Patrol_Station01:GetPosition()+Vector3(-40, 20, -50), 1, 13, Vector3(0.5,0,0.5));
  flight_vksP1:Patrol({Patrol_Station01:GetPosition()+Vector3(-40, 20, -50),Patrol_Station01:GetPosition()+Vector3(-350, 60, 100),Patrol_Station01:GetPosition()+Vector3(-600, 20, -100),Patrol_Station01:GetPosition()+Vector3(-250, -50, -300)}, TRUE);
  NewVksFlight("Vks_Group", "vksP2", Patrol_Station01:GetPosition()+Vector3(40, 20, -30), 1, 13, Vector3(0.5,0,0.5));
  flight_vksP2:Patrol({Patrol_Station01:GetPosition()+Vector3(40, 20, -30),Patrol_Station01:GetPosition()+Vector3(450, -80, 150),Patrol_Station01:GetPosition()+Vector3(350, 40, -450)}, TRUE);
  NewVksFlight("Vks_Group", "vksP3", TRADE_STATION:GetPosition()+Vector3(-80, 20, 50), 1, 13, Vector3(0.5,0,0.5));
  flight_vksP3:Patrol({TRADE_STATION:GetPosition()+Vector3(-80, 20, 50),TRADE_STATION:GetPosition()+Vector3(-350, 20, 50),TRADE_STATION:GetPosition()+Vector3(-350, 20, 350)}, TRUE);
  NewVksFlight("Vks_Group", "vksP4", TRADE_STATION:GetPosition()+Vector3(60, 20, 50), 1, 13, Vector3(0.5,0,0.5));
  flight_vksP4:Patrol({TRADE_STATION:GetPosition()+Vector3(60, 20, 50),TRADE_STATION:GetPosition()+Vector3(150, 40, 400),TRADE_STATION:GetPosition()+Vector3(400, 20, -150)}, TRUE);
end;


--info:top=80,left=80,allvis=0;
function ACTION_INIT()
  _FTrader_exclude();
  RemovePost("mail_008c_2");
  StartInitMis();

  lPoint = GetQuestLabel("QuestPoint");
  if (GetTeamRelation("Vks",PLAYER_TEAM)==RELATION_NEUTRAL) then
    if (lPoint=="0") then
      Timer_Seq(2, StartMission_Neutral);
    else
      Timer_Seq(2, GoTo_Station);
    end;
  else
    if (lPoint=="0") then
      Timer_Seq(2, StartMission_War);
    else
      Timer_Seq(2, Vks_Attack);
    end;
  end;
  return TRUE;
end;


--info:top=80,left=570,allvis=0;
function ACTION_LEAVELOCATION()
  if (LineToStation) then LineToStation:Delete(); end;
  if (GetQuestLabel("QuestPoint")=="0") then
    SetQuestLabel("CarpetBag","local");
    lPath = GetQuestLabel("Quest8cPath");
    if (lPath=="NoFight") then
      AddPost("book008c_5");
    elseif (lPath=="Contraband") then
      if (GetQuestLabel("8cShron")=="no") then
        AddPost("book008c_3");
      else
        AddPost("book008c_2");
      end;
    elseif (lPath=="VKS") then
      AddPost("book008c_4");
    elseif (lPath=="Elmister") then
      if (GetQuestLabel("Quest3Path")=="Heretic") and (GetQuestLabel("Quest5Path")=="Patrol") then
        AddPost("book008c_6");
      else
        AddPost("book008c_7");
      end;
    elseif (lPath=="NoElmister") then
      AddPost("book008c_8");
    end;
    QuestActionDone();
    ClearQuests();
    if (GetQuestState("quest_8c_02")~=QUEST_NOINIT) then RemoveQuest("quest_8c_02"); end;
    if (GetQuestState("quest_8c_04")~=QUEST_NOINIT) then RemoveQuest("quest_8c_04"); end;
    if (GetQuestState("quest_8c_05")~=QUEST_NOINIT) then RemoveQuest("quest_8c_05"); end;
    if (GetQuestState("quest_8c_06")~=QUEST_NOINIT) then RemoveQuest("quest_8c_06"); end;
    PauseInMissionActivity("__start_Mission9c", 2);
  elseif (GetQuestLabel("QuestPoint")=="2") then
    AddPost("book008c_10"); 
    QuestActionDone();
    ClearQuests();
    if (GetQuestState("quest_7a")==QUEST_PROCESS) then
      QuestStart("mission_7a");
    elseif (GetQuestState("quest_7b")==QUEST_PROCESS) then
      QuestStart("mission_7b");
    elseif (GetQuestState("quest_7d")==QUEST_PROCESS) then
      QuestStart("mission_7d");
    elseif (GetQuestState("quest_7f")==QUEST_PROCESS) then
      SetQuestLabel("InocoPermit","yes");
      if (GetQuestState("quest_8c_02")~=QUEST_NOINIT) then RemoveQuest("quest_8c_02"); end;
      QuestChoice("mission_7f_01","Danstag");
      QuestChoice("mission_7f_02","XK10");
    else
      if (GetQuestState("quest_8c_02")~=QUEST_NOINIT) then RemoveQuest("quest_8c_02"); end;
      if (dest_location=="gredos") then
        PauseInMissionActivity("__start_Mission8d", 1);
      elseif (dest_location=="argon") then
        PauseInMissionActivity("__start_Mission8d", 2);
      else
        PauseInMissionActivity("__start_Mission8d", 3);
      end;
    end;
  end;

  return TRUE;
end;


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

  return TRUE;
end;
