script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 0;
    let life = 0;
    let kaku = 40;
    let score = 1600;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let imgEnemy = GetCurrentScriptDirectory~"img\sky2.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
    @Initialize(){
        SetLife( 400 );
        SetInvincibility( 50 );
        SetSpeed(1.2);
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        Tshot1;
    }
    @MainLoop {
        rate=life-GetLife;
        life=GetLife;
        if(phase==1&&GetLife<=100){
           phase-=1;
           PlaySE(se2);
           Tdeath(14,64,2,1);
           CreateEnemyFromFile(GetCurrentScriptDirectory~"airitem.txt",GetX,GetY, -3, 0, 1);
           CreateEnemyFromFile(GetCurrentScriptDirectory~"airitem.txt",GetX+35,GetY, -3, 0, 4);
           CreateEnemyFromFile(GetCurrentScriptDirectory~"airitem.txt",GetX-35,GetY, -3, 0, 4);
        }
        if(phase>=1){
           SetCollisionA(GetX, GetY, 64);
           SetCollisionB(GetX, GetY, 32);
        }
        lv=GetCommonData("rank");
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 1, 1, 128, 128 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY() );
    }

    task Tshot1{
        yield;
        wait(50);
        loop{
           if(GetX>62&&GetX<396&&GetY<280){
              let a=0;
              loop(3+rank+ex){
                 if(phase==0){return;}
                 let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+30));
                 SetShotDirectionType(ABSOLUTE);
                 let b=-a/2;
                 loop(a+1){
                    CreateShotFromScript( "shot1",GetX()+30, GetY(), 2.1+a*0.2+ex/2, p+b*3, 0, 03);
                    b++;
                 }
                 a++;
              }
              wait(5);
              let a=0;
              loop(3+rank+ex){
                 if(phase==0){return;}
                 let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-30));
                 SetShotDirectionType(ABSOLUTE);
                 let b=-a/2;
                 loop(a+1){
                    CreateShotFromScript( "shot1",GetX()-30, GetY(), 2.1+a*0.2+ex/2, p+b*3, 0, 03);
                    b++;
                 }
                 a++;
              }
              wait(5);
              let a=0;
              loop(3+rank+ex){
                 if(phase==0){return;}
                 let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+50));
                 SetShotDirectionType(ABSOLUTE);
                 let b=-a/2;
                 loop(a+1){
                    CreateShotFromScript( "shot1",GetX()+55, GetY(), 2.1+a*0.2+ex/2, p+b*3, 0, 03);
                    b++;
                 }
                 a++;
              }
              wait(5);
              let a=0;
              loop(3+rank+ex){
                 if(phase==0){return;}
                 let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-50));
                 SetShotDirectionType(ABSOLUTE);
                 let b=-a/2;
                 loop(a+1){
                    CreateShotFromScript( "shot1",GetX()-55, GetY(), 2.1+a*0.2+ex/2, p+b*3, 0, 03);
                    b++;
                 }
                 a++;
              }
              wait(5);
           }
           wait(70-lv*12);
        }
    }
    task Tmove0 {
        SetInvincibility( 140 );
        SetMovePositionHermite(GetX+160*arg, GetY+160, 500, 90-70*arg, 100, 90, 300);
        wait(300);
        SetMovePosition02(GetX, GetY+200, 250);
        wait(250);
        SetMovePosition02(GetX, GetY+200, 100);
        wait(100);
        VanishEnemy();
    }
    task Tmove1 {
        SetInvincibility( 100 );
        SetMovePosition02(GetX, GetY+360, 400);
        wait(400);
        SetMovePosition02(GetX, GetY+200, 100);
        wait(100);
        VanishEnemy();
    }




    #include_function".\efanction.txt"
}

#include_script".\escript.txt"