script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 7;
    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\itemc.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
    @Initialize(){
        SetLife( 140 );
        SetInvincibility( 20 );
        SetSpeed(1.2);
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        Tshot1;Tmove;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 40);}
           PlaySE(se2);
           let bomb = GetCurrentScriptDirectory~"bomb.txt";
           CreateEnemyFromFile(bomb,GetX,GetY, 0, 0, 0);
           Tdeath(5,48,2,1);
        }
        if(phase>=1){
           SetCollisionA(GetX, GetY, 40);
           SetCollisionB(GetX, GetY, 24);
        }
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 1, 1, 128, 128 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY() );
    }

    task Tshot1{
        yield;
        wait(60);
        loop{
           if(GetX>62&&GetX<396&&GetY<200){
              let a=0;
              let p=GetAngleToPlayer;
              p+=-p%12+6;
              loop(3+rank/2){
                 if(phase==0){return;}
                 SetShotDirectionType(ABSOLUTE);
                 let b=-1;
                 loop(3){
                    CreateShotFromScript( "shot1",GetX(), GetY(), 3, p+b*30, 0, 06);
                    b++;
                 }
                 a++;
                 wait(5);
              }
           }
           if(lv==0){wait(40-rank*4);}
           wait(10);
        }
    }
    task Tmove {
        SetInvincibility( 60 );
        SetMovePosition02(GetX, GetY+120, 60);
        wait(60);
        SetMovePosition02(GetX, GetY+80, 250);
        wait(250);
        SetMovePosition02(GetX, GetY+360, 180);
        wait(180);
        VanishEnemy();
    }




    #include_function".\efanction.txt"
}

#include_script".\escript.txt"