------------------------------------------------------------
--     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=160,left=80,allvis=0;
function StartMission()
  SetNormalTimeMode();
  MothershipFlight:Stop();
  LineToAlice:Delete();
--------------------------------------------------------------------------------
--  StartDialog("Dialog3");
  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
      StartDialog("Dialog3");
    end;
  else
    StartDialog("Dialog3");
  end; 
end;

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



--info:top=200,left=80,allvis=0;
function finMission()
  SetQuestState("quest_9b_02", QUEST_DONE);
  Alice_Group:RemoveFlight(AliceFlight);
  Player_Group:AddFlight(AliceFlight);
  AliceFlight:Escort(mothership);
  AddQuest("quest_9b_03", "#L_Quest_9b_03a", "#L_Quest_9b_03b", QUEST_PROCESS);
  LineToPortal = CreateLine(nav_Alice, NP_PORTAL_L, RGB(20,80,220), .3, TRUE, .2, 1);
end;


--info:top=120,left=80,allvis=0;
function StartInitMission()
  UssTeam = CreateTeam("Uss");

  MothershipPilot = mothership:GetPilot();
  MothershipFlight = MothershipPilot:GetFlight();
  
  Player_Group = MothershipPilot:GetGroup();
  Alice_Group = UssTeam:CreateGroup("Alice_Group");
  new_SetGroupRelations("Alice_Group", "PiratesGroup_1", "N");   
  new_SetGroupRelations("Alice_Group", PLAYER_GROUP, "N");   
  
  HeroSpeaker = GetPilot("Hero");
  LastochkaSpeaker = GetPilot("Lastochka");
  SedoySpeaker = GetPilot("Sedoy");
  ItanSpeaker = GetPilot("m9b_Fry");
  AlisaSpeaker = CreatePilot("Alisa");
  
  nav_Alice = CreateNavPoint("#L_nav_01", Vector3(500, 100, -600), "nav_default.dds", RGB(255,255,255));
  last_loc = GetLastLocation();
  if (last_loc=="el_ariash") then
    LineToAlice = CreateLine(NP_PORTAL_R, nav_Alice, RGB(20,80,220), .3, TRUE, .2, 1);
  elseif (last_loc=="kadi") then
    LineToAlice = CreateLine(NP_PORTAL_L, nav_Alice, RGB(20,80,220), .3, TRUE, .2, 1);
  else
    LineToAlice = CreateLine(NP_PORTAL_U, nav_Alice, RGB(20,80,220), .3, TRUE, .2, 1);
  end;
  local ship1 = CreateCarcass("EvilEye_uss2", Vector3(500, 100, -600), Vector3(0.5,0,0.5)); 
  ship1:AssignPilot(AlisaSpeaker);
  AliceFlight = Alice_Group:CreateFlight("AliceFlight");
  AliceFlight:AddShip(ship1);
  
  trig_MeetAlice = NewTrigger("inside", TrueCondition, StartMission, mothership, Vector3(500, 100, -600), 100);
end;


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

  return TRUE;
end;


--info:top=80,left=570,allvis=0;
function ACTION_LEAVELOCATION()
  if (GetQuestState("quest_9b_02")==QUEST_PROCESS) then
    LineToAlice:Delete();
    nav_Alice:Delete();
  elseif (GetQuestState("quest_9b_03")==QUEST_PROCESS) then
    LineToPortal:Delete();
    nav_Alice:Delete();
    QuestActionDone();
  end;

  return TRUE;
end;


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

  return TRUE;
end;
