script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 1;
    let kaku = 10;
    let score = 80;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let imgEnemy = GetCurrentScriptDirectory~"img\zakoheli2.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
    @Initialize(){
        SetLife( 120 );
        SetInvincibility( 10 );
        SetSpeed(3.3);
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        Tmove;Tshot1;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 25);}
           PlaySE(se3);
           Tdeath(2,24,2,1);
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1000){VanishEnemy;}
        if(phase>=1){
           SetCollisionA(GetX, GetY, 24);
           SetCollisionB(GetX, GetY, 16);
        }
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 96, 0, 144, 48 );
        SetGraphicAngle(0,30,GetAngleToPlayer);
	DrawGraphic( GetX(), GetY());
        SetGraphicRect( 0, 0, 48, 48 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY()-8);
        SetGraphicRect( 48, 0, 96, 48 );
        SetGraphicAngle(0,30,-time*17);
	DrawGraphic( GetX(), GetY()-14 );
    }

    task Tshot1{
        yield;
        wait(50);
        loop{
           if(phase<=0){return;}
           if(GetX>32&&GetX<416&&GetY>16&&GetY<400){
              SetShotDirectionType(ABSOLUTE);
              let p=genteikaku(GetAngleToPlayer(),24);
              let a=0;
              loop(4+ex*2){
                 CreateShotFromScript( "shot1",GetX()+cos(p)*20, GetY()+sin(p)*14, 3+a*0.17+ex, p, 0, 13);
                 a++;
              }
           }
           if(lv==0){wait(60-rank*10);}
           wait(6);
        }
    }
    task Tmove {
        yield;
        SetMovePosition03(GetX+180*arg,GetY+100,30,4);
        wait(70);
        SetMovePosition03(GetX-260*arg,GetY+40,30,3);
        wait(100);
        SetMovePosition03(GetX+260*arg,GetY+40,30,3);
        wait(100);
        SetMovePosition03(GetX,GetY-180,0,3);
        wait(60);
        VanishEnemy();
    }


    #include_function".\efanction.txt"
}

#include_script".\escript.txt"