//Line
#include "maps\header.ini"

int time,timewin=0;
int unit,i;
int timedeath[2]={1,1};
int tp_x[2]=  {4758, 222};
int tp_y[2]=  {276,  468};
int tp_map[2]={0,   2};
int tp_dir[2]={192,   96};
int tp_no=2,tp_in=-1,tp_go=0;//if tp_go!=0 then Flagman(0) отъехал от входного телепортера

main()
{
  iff(1)
  {
    SetVid(199,VID_CHILD+15,-322);SetVid(74,VID_CHILD+15,322);
    SetVid(19,VID_CHILD+2,321);SetVid(19,VID_CHILD+4,321);SetVid(19,VID_CHILD+5,321);
    SetVid(24,VID_CHILD+2,321);SetVid(24,VID_CHILD+4,321);SetVid(24,VID_CHILD+5,321);
    SetVid(33,VID_CHILD+2,321);SetVid(33,VID_CHILD+4,321);SetVid(33,VID_CHILD+5,321);
    SetVid(43,VID_CHILD+2,321);SetVid(43,VID_CHILD+4,321);SetVid(43,VID_CHILD+5,321);
    SetVid(79,VID_CHILD+2,321);SetVid(79,VID_CHILD+4,321);SetVid(79,VID_CHILD+5,321);
    SetVid(81,VID_CHILD+2,321);SetVid(81,VID_CHILD+4,321);SetVid(81,VID_CHILD+5,321);
    SetVid(132,VID_CHILD+2,321);SetVid(132,VID_CHILD+4,321);SetVid(132,VID_CHILD+5,321);
    SetVid(138,VID_CHILD+2,321);SetVid(138,VID_CHILD+4,321);SetVid(138,VID_CHILD+5,321);
    SetVid(143,VID_CHILD+2,321);SetVid(143,VID_CHILD+4,321);SetVid(143,VID_CHILD+5,321);
    SetVid(140,VID_CHILD+15,321);SetVid(221,VID_CHILD+15,321);SetVid(314,VID_CHILD+15,321);
    SetVid(348,VID_CHILD+15,321);SetVid(350,VID_CHILD+15,321);SetVid(237,VID_CHILD+14,367);
    if(opt_detail) SetWind(25,200);//сила, направление
    gammamenu=64;SetGamma(gamma=1879);
/*    for(i=0;i<tp_no;i++) if(old_n_map==tp_map[i]) tp_in=i;
    if(tp_in<0)
      for(i=tp_no-1;i>=0;i--) if( map&(1<<(tp_map[i]-1)) ) tp_in=i;*/
    if(tp_in<0) tp_in=0;
    SetPosition(tp_x[tp_in],tp_y[tp_in]);
  }
  if(Tact()) return;
  iff(1)
  {
    MaxUnit(V_M_CHOPPER,3);time=GetTime();
    SetFlagman(0,Create(kassandra,tp_x[tp_in],tp_y[tp_in],0));
    Action(Flagman(0),act_changeaction,act_stand,tp_dir[tp_in]);
    Create(V_TP_EFFECT,tp_x[tp_in],tp_y[tp_in],10);
    PlayMusic(music1=6,music2=7,music3=6,music4=7);
    AddCommand(GetObject(V_M_AIRPORT,332,138),act_uncom,0,0);
    AddCommand(GetObject(V_M_AIRPORT,332,138),act_attack,Flagman(0),0);
  }
/*  if((GetTime()-time)>10000)
  {
    time=GetTime();Create(V_FLYBUSH,0,Random(4000),80);
  }*/
  for(i=0;i<tp_no;i++)
  {
    if(!GetObject(V_TELEPORT,tp_x[i],tp_y[i]))
      if(!timedeath[i]) timedeath[i]=GetTime();
      else if((GetTime()-timedeath[i])>4000)
        { Create(V_TELEPORT,tp_x[i],tp_y[i],0);timedeath[i]=0; }
/*    iff( SizeTo(Flagman(0),tp_x[i],tp_y[i])<30 && tp_go )
    {
      Create(V_TP_EFFECT,tp_x[i],tp_y[i],10);NextNMap(tp_map[i]);
    }*/
  }
//  if(Action(Flagman(0),act_askitem,V_ARTEFACT1,0))
    iff(SizeTo(Flagman(0),tp_x[1],tp_y[1])<30 && GetObject(V_TELEPORT,tp_x[1],tp_y[1]))
    {
      Create(V_TP_EFFECT,tp_x[1],tp_y[1],10);
      Win();
      Action(Flagman(0),act_destroy,0,0);
    }
}