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


int unit,i,birth,tp[4]={0,0,0,0};//if tp!=0 then начинать телепортацию в позицию tp
int timedeath[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int tp_time[20]={4   ,4   ,4   ,4   ,60  ,/*30  ,30  */,30  ,30  ,40  ,20  ,20  ,40  ,20  ,180 ,90  ,90  ,20  ,20  ,20  ,20  ,20  };//rebirth time
int tp_item[20]={129 ,129 ,129 ,129 ,272 ,/*233 ,233 */,233 ,233 ,273 ,230 ,230 ,275 ,230 ,277 ,231 ,102 ,114 ,114 ,114 ,114 ,114 };
int tp_x[20]=   {436 ,1927,2116,340 ,1189,/*1218,1156*/,1220,1154,1175,1248,1306,1152,762 ,1765,1757,932 ,422 ,100 ,2227,2253,125 };
int tp_y[20]=   {160 ,197 ,1270,1156, 737,/*711 ,761 */, 763,713 ,116 ,1472,130 ,1472,1381,1490,1448,1032,1411,815 ,485 ,530 ,866 };
int tp_dir[4]=  {90  ,160 ,205 ,16};

NetCreatePlayer()
{
  weapon[n_flagman*4]=V_FLAGMANHEAD12;weapon[1+n_flagman*4]=0;weapon[2+n_flagman*4]=0;weapon[3+n_flagman*4]=0;kassandra=V_TRANSMISSION1;
  birth=Random(3);
  while( unit=AskPlace(kassandra,tp_x[birth],tp_y[birth],0) )
    if(GetUnitVid(unit)==V_TRANSMISSION1 || GetUnitVid(unit)==V_TRANSMISSION2 || GetUnitVid(unit)==V_TRANSMISSION3)
      if(birth<3) birth++;else birth=0;
    else Action(unit,act_death,0,0);
  SetFlagman(n_flagman,Create(kassandra,tp_x[birth],tp_y[birth],0));
  Action(Flagman(n_flagman),act_setarmy,n_flagman,0);
  Action(Flagman(n_flagman),act_changeaction,act_stand,tp_dir[birth]);
  Create(V_TP_EFFECT,tp_x[birth],tp_y[birth],10);
  if(GetNetInfo(NET_NUMPLAYER)==n_flagman) SetPosition(tp_x[birth],tp_y[birth]);
  Action(Flagman(n_flagman),act_setstate,(n_flagman<<12)+Action(Flagman(n_flagman),act_getstate,0,0),0);
  Action(Flagman(n_flagman),act_changeweapon,weapon[n_flagman*4],0);
  net_birth[n_flagman]=0;
}

main()
{
  iff(1)
  {
    SetVid(199,VID_CHILD+15,-320);SetVid(74,VID_CHILD+15,320);
    SetVid(19,VID_CHILD+2,319);SetVid(19,VID_CHILD+4,319);SetVid(19,VID_CHILD+5,319);
    SetVid(24,VID_CHILD+2,319);SetVid(24,VID_CHILD+4,319);SetVid(24,VID_CHILD+5,319);
    SetVid(33,VID_CHILD+2,319);SetVid(33,VID_CHILD+4,319);SetVid(33,VID_CHILD+5,319);
    SetVid(43,VID_CHILD+2,319);SetVid(43,VID_CHILD+4,319);SetVid(43,VID_CHILD+5,319);
    SetVid(79,VID_CHILD+2,319);SetVid(79,VID_CHILD+4,319);SetVid(79,VID_CHILD+5,319);
    SetVid(81,VID_CHILD+2,319);SetVid(81,VID_CHILD+4,319);SetVid(81,VID_CHILD+5,319);
    SetVid(132,VID_CHILD+2,319);SetVid(132,VID_CHILD+4,319);SetVid(132,VID_CHILD+5,319);
    SetVid(138,VID_CHILD+2,319);SetVid(138,VID_CHILD+4,319);SetVid(138,VID_CHILD+5,319);
    SetVid(143,VID_CHILD+2,319);SetVid(143,VID_CHILD+4,319);SetVid(143,VID_CHILD+5,319);
    SetVid(140,VID_CHILD+15,319);SetVid(221,VID_CHILD+15,319);SetVid(314,VID_CHILD+15,319);
    SetVid(348,VID_CHILD+15,319);SetVid(350,VID_CHILD+15,319);SetVid(237,VID_CHILD+14,60);
    SetGamma(gamma=2166);
    if(opt_detail) SetWind(25,200);//сила, направление
    MaxUnit(V_FLYBUSH,10);
    for(n_flagman=0;n_flagman<GetNetInfo(NET_NOPLAYER);n_flagman++) NetCreatePlayer();
    PlayMusic(music1=5,music2=5,music3=5,music4=5);
  }
  if(NetTact()) return;


  for(i=0;i<20;i++)
  {
    if(!GetObject(tp_item[i],tp_x[i],tp_y[i]))
      if(!timedeath[i]) timedeath[i]=GetTime();
      else if((GetTime()-timedeath[i])>tp_time[i]*1000)
      {
        Create(tp_item[i],tp_x[i],tp_y[i],0);timedeath[i]=0;
        if(i>3) Create(V_TP_EFFECT,tp_x[i],tp_y[i],0);
      }
  }
  for(n_flagman=0;n_flagman<GetNetInfo(NET_NOPLAYER);n_flagman++)
    if(Flagman(n_flagman))
    {
      if(tp[n_flagman])//teleport kassandra to tp0 from tp1
        if((GetTime()-startnextmap)>400)
        {
          tp[n_flagman]=Random(3);
          while(unit=AskPlace(kassandra,tp_x[tp[n_flagman]],tp_y[tp[n_flagman]],0))
            Action(unit,act_death,0,0);
          Action(Flagman(n_flagman),act_changecoor,tp_x[tp[n_flagman]],tp_y[tp[n_flagman]]);
          Create(V_TP_EFFECT,tp_x[tp[n_flagman]],tp_y[tp[n_flagman]],10);
          tp[n_flagman]=0;
        } else;
      else if(SizeTo(Flagman(n_flagman),423,1407)<30)
      {
        tp[n_flagman]=1;startnextmap=GetTime();
        Create(V_TP_EFFECT,423,1407,10);Effect(eff_bnuke);
      }
    } else //if player is die
    {
      if(net_birth[n_flagman])
        if( (GetTime()-net_birth[n_flagman])>3000 )
          NetCreatePlayer();
    }
}
