script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 0;
    let life = 0;
    let kaku = 10;
    let score = 200;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\zakotank2.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
    @Initialize(){
        SetLife( 125 );
        SetInvincibility( 10 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(arg==0){
           if( (|angle|) ==1){Tmove1;}
           if( (|angle|) ==2){Tmove2;}
           if( (|angle|) ==3){Tmove3;}
        }
        else{setmove(angle,arg);}
        Tshot;
    }
    @MainLoop {
        rate=life-GetLife;
        life=GetLife;
        if(phase==1&&GetLife<=100){
           phase-=1;
           PlaySE(se3);
           Tdeath(4,24,2,1);
           CreateEnemyFromFile(GetCurrentScriptDirectory~"landitem.txt",mapx,mapy, 0, 0, 2);
        }
        if(GetX<12||GetX>436||GetY<16){
           SetInvincibility( 5 );
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1000){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX, GetY, 24);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        lv=GetCommonData("rank");
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 1, 1, 48, 48 );
        SetGraphicAngle(0,0,angle);
	DrawGraphic( GetX(), GetY() );
        SetGraphicRect( 48, 1, 96, 48 );
        SetGraphicAngle(0,0,GetAngleToPlayer()-GetAngleToPlayer()%12+6);
	DrawGraphic( GetX(), GetY() );
    }

    task Tshot{
        yield;
        wait(60+sin(GetCommonData("ransu")*73)*20);
        SetCommonData("ransu",GetCommonData("ransu")+1);
        loop{
           if(GetX>42&&GetX<406&&GetY>16&&GetY<(250+rank*15)&&(GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2>150^2){
              let p=GetAngleToPlayer();
              p+=-p%12+6;
              let a=0;
              loop(3+rank/2){
                 CreateShotFromScript( "shot1",GetX()+cos(p)*22, GetY()+sin(p)*22, 2.3+a*(0.5+ex*0.2), p, 0, 06);
                 a++;
              }
              if(ex==1){
                 let a=0;
                 loop(2+rank/2){
                    CreateShotFromScript( "shot1",GetX()+cos(p)*22, GetY()+sin(p)*22, 2.65+a*(0.5+ex*0.2), p+8, 0, 04);
                    CreateShotFromScript( "shot1",GetX()+cos(p)*22, GetY()+sin(p)*22, 2.65+a*(0.5+ex*0.2), p-8, 0, 04);
                    a++;
                 }
              }
           }
           wait(92-lv*16);
        }
    }
    task Tmove1{
        let a=angle;
        angle=90;
        yield;
        SetMovePosition02( GetX(), GetY()+60, 40);
        wait(40);
        SetMovePosition02( GetX()-24*a, GetY()+35, 30);
        angle=90+45*a;
        wait(30);
        SetMovePosition02( GetX()-1000*a, GetY+500, 1000);
        angle=90+90*a;
    }
    task Tmove2{
        let a=angle;
        a/=2;
        angle=90;
        yield;
        SetMovePosition02( GetX(), GetY()+120, 80);
        wait(80);
        SetMovePosition02( GetX()-24*a, GetY()+35, 30);
        angle=90+45*a;
        wait(30);
        SetMovePosition02( GetX()-1000*a, GetY+500, 1000);
        angle=90+90*a;
    }
    task Tmove3{
        let a=angle;
        a/=3;
        angle=90*a;
        yield;
        SetMovePosition02( GetX()-100, GetY()+200*a, 200);
        wait(200);
        SetMovePosition02( GetX()-35, GetY()+24*a, 30);
        angle=180-45*a;
        wait(30);
        SetMovePosition02( GetX()-600, GetY(), 400);
        angle=180;
    }

   task setmove(a,t) {
      loop(t) {
         mapx+=cos(a)*0.8;mapy-=sin(a)*0.8;
         yield;
      }
   }



    #include_function".\efanction.txt"
}

#include_script".\escript.txt"