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

int time,i;
int unit;
int timedeath[2]={1,0};
int tp_x[2]=  {184, 1010};
int tp_y[2]=  {3266,166};
int tp_map[2]={1,   3};
int tp_dir[2]={28,  156};
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,-200);SetVid(74,VID_CHILD+15,200);
    SetVid(19,VID_CHILD+2,116);SetVid(19,VID_CHILD+4,116);SetVid(19,VID_CHILD+5,116);
    SetVid(24,VID_CHILD+2,116);SetVid(24,VID_CHILD+4,116);SetVid(24,VID_CHILD+5,116);
    SetVid(33,VID_CHILD+2,116);SetVid(33,VID_CHILD+4,116);SetVid(33,VID_CHILD+5,116);
    SetVid(43,VID_CHILD+2,116);SetVid(43,VID_CHILD+4,116);SetVid(43,VID_CHILD+5,116);
    SetVid(79,VID_CHILD+2,116);SetVid(79,VID_CHILD+4,116);SetVid(79,VID_CHILD+5,116);
    SetVid(81,VID_CHILD+2,116);SetVid(81,VID_CHILD+4,116);SetVid(81,VID_CHILD+5,116);
    SetVid(132,VID_CHILD+2,116);SetVid(132,VID_CHILD+4,116);SetVid(132,VID_CHILD+5,116);
    SetVid(138,VID_CHILD+2,116);SetVid(138,VID_CHILD+4,116);SetVid(138,VID_CHILD+5,116);
    SetVid(143,VID_CHILD+2,116);SetVid(143,VID_CHILD+4,116);SetVid(143,VID_CHILD+5,116);
    SetVid(140,VID_CHILD+15,116);SetVid(221,VID_CHILD+15,116);SetVid(314,VID_CHILD+15,116);
    SetVid(348,VID_CHILD+15,116);SetVid(350,VID_CHILD+15,116);SetVid(237,VID_CHILD+14,60);
/*    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)
  {
    if(opt_detail) SetWind(25,200);//сила, направление
    MaxUnit(V_FLYBUSH,10);MaxUnit(V_M_GUNTANK,2);
    time=GetTime();//timedeath=timedeath2=0;
    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=2,music2=3,music3=2,music4=3);
    AddCommand(GetObject(V_TELEPORT,tp_x[1],tp_y[1]),act_uncom,0,0);
    AddCommand(GetObject(V_TELEPORT,tp_x[1],tp_y[1]),act_attack,Flagman(0),0);
    AddCommand(GetObject(V_M_PLASMATANK,746,290),act_attack,Flagman(0),0);
    AddCommand(GetObject(V_M_PLASMATANK,690,221),act_attack,Flagman(0),0);
  }
  if((GetTime()-time)>10000)
  {
    time=GetTime();Create(V_FLYBUSH,0,Random(900),80);
    if(!Random(7)) { PlaySFX(39);Create(V_METEORITRAIN,150+Random(980),1600+Random(1700),1000); }
  }
  iff(!Flagman(0)) Action(GetObject(V_TELEPORT,tp_x[1],tp_y[1]),act_clearcom,0,0);
  if(Flagman(0))
  {
    iff(SizeTo(Flagman(0),726,436)<150)
    {
      Create(V_TP_EFFECT,1014,178,10);
      Create(V_M_MINE,750,212,0);Create(V_M_MINE,918,292,0);
      Create(V_M_MINE,966,436,0);
      Create(V_M_MINE,918,596,0);Create(V_M_MINE,726,644,0);
      Create(V_M_MINE,558,580,0);
      Create(V_M_MINE,510,420,0);Create(V_M_MINE,582,276,0);
/*      Create(V_M_MINE,750,212,0);Create(V_M_MINE,846,244,0);Create(V_M_MINE,918,292,0);
      Create(V_M_MINE,966,356,0);Create(V_M_MINE,966,436,0);Create(V_M_MINE,966,512,0);
      Create(V_M_MINE,918,596,0);Create(V_M_MINE,822,628,0);Create(V_M_MINE,726,644,0);
      Create(V_M_MINE,630,628,0);Create(V_M_MINE,558,580,0);Create(V_M_MINE,510,500,0);
      Create(V_M_MINE,510,420,0);Create(V_M_MINE,534,340,0);Create(V_M_MINE,582,276,0);
      Create(V_M_MINE,654,228,0);*/
    }
    iff(SizeTo(Flagman(0),1014,195)<30)
    {
      Create(V_TP_EFFECT,tp_x[1],tp_y[1],10);
      Action(GetObject(V_TELEPORT,tp_x[1],tp_y[1]),act_clearcom,0,0);
      Win();
      Action(Flagman(0),act_destroy,0,0);
    }
    iff(SizeTo(Flagman(0),679,608)<400)
    {
      Action(GetObject(V_M_PLASMATANK,201,309),act_attack,Flagman(0),0);
      Action(GetObject(V_M_PLASMATANK,268,250),act_attack,Flagman(0),0);
    }
    iff(SizeTo(Flagman(0),560,2450)<400)
    {
      Action(GetObject(V_M_RL,560,713),act_attack,Flagman(0),0);
      Action(GetObject(V_M_RL,507,614),act_attack,Flagman(0),0);
      Action(GetObject(V_M_RL,470,516),act_attack,Flagman(0),0);
    }
    iff(SizeTo(Flagman(0),600,1450)<400)
    {
      Action(GetObject(V_M_RL,564,430),act_attack,Flagman(0),0);
      Action(GetObject(V_M_RL,501,342),act_attack,Flagman(0),0);
      Action(GetObject(V_M_RL,465,245),act_attack,Flagman(0),0);
    }
  }
  if((unit=GetObject(V_M_GUNTANK,tp_x[1],tp_y[1])) && !(128&Action(unit,act_getbehave,0,0)))
  {
    Action(unit,act_setbehave,128|Action(unit,act_getbehave,0,0),0);
    if(!Random(2)) Action(unit,act_additem,V_AMMO2,0);
    if(!Random(2)) Action(unit,act_additem,V_MEDIC,0);
  }
//  iff(SizeTo(Flagman(0),tp_x[tp_in],tp_y[tp_in])>40) tp_go=1;
  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]);
    }*/
  }
}
