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\zakoair1.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se10 = GetCurrentScriptDirectory~"wav\se10.wav";
    @Initialize(){
        SetLife( 103 );
        SetInvincibility( 3 );
        SetSpeed(4.6);
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        if(angle==1){Tmove1;}
        if(angle==2){Tmove2;}
        if(angle==3){Tmove3;}
        if(angle==4){Tmove4;}
        Tshot1;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 30);}
           PlaySE(se10);
           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( 0, 0, 48, 48 );
        SetGraphicAngle(0,0,GetAngleToPlayer-90);
	DrawGraphic( GetX(), GetY());
    }

    task Tshot1{
        loop{
           if(phase<=0){return;}
           if(GetX>42&&GetX<406&&GetY>0&&GetY<320){
              SetShotDirectionType(ABSOLUTE);
              let p=GetAngleToPlayer;
              /*p+=-p%12+6;*/
              let a=0;
              loop(3+rank){
                 CreateShotFromScript( "shot1",GetX()+cos(p)*20, GetY()+sin(p)*14, 2.8, p, 0, 13);
                 if(ex==1){
                    CreateShotFromScript( "shot1",GetX()+cos(p)*20, GetY()+sin(p)*14, 3.8, p, 0, 13);
                 }
                 a++;
                 wait(2);
              }
           }
           if(lv==0){wait(16-rank*1);}
           wait(3);
        }
    }
    task Tmove1 {
        SetAngle(90-20*arg);
        loop(30){SetAngle(GetAngle+0.5*arg);yield;}
        loop(50){SetAngle(GetAngle+2*arg);yield;}
        loop(30){SetAngle(GetAngle-2*arg);yield;}
        wait(40);
        VanishEnemy();
    }
    task Tmove2 {
        SetAngle(90+104*arg);
        loop(60){SetAngle(GetAngle-0.4*arg);yield;}
        loop(45){SetAngle(GetAngle-2*arg);yield;}
        loop(50){SetAngle(GetAngle-3*arg);yield;}
        loop(25){SetAngle(GetAngle+2*arg);yield;}
        loop(40){SetAngle(GetAngle+0.5*arg);yield;}
        VanishEnemy();
    }
    task Tmove3 {
        SetAngle(90+110*arg);
        loop(40){SetAngle(GetAngle-0.5*arg);yield;}
        loop(30){SetAngle(GetAngle-2.9*arg);yield;}
        loop(10){SetAngle(GetAngle-0.3*arg);yield;}
        loop(60){SetAngle(GetAngle-2.9*arg);yield;}
        loop(70){SetAngle(GetAngle-0.3*arg);yield;}
        VanishEnemy();
    }
    task Tmove4 {
        SetAngle(90+80*arg);
        loop(30){SetAngle(GetAngle-1.5*arg);yield;}
        loop(60){SetAngle(GetAngle+1.3*arg);yield;}
        loop(40){SetAngle(GetAngle-1*arg);yield;}
        VanishEnemy();
    }


    #include_function".\efanction.txt"
}

#include_script".\escript.txt"