script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 15;
    let kaku = 50;
    let score = 4600;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let imgEnemy = GetCurrentScriptDirectory~"img\airbig1.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se9 = GetCurrentScriptDirectory~"wav\se9.wav";
    SetCommonData("haya",0);
    @Initialize(){
        SetLife( 1600 - rank*100);
        SetInvincibility( 100 );
        SetSpeed(1);
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        Tmove;Tshot1;Tshot2;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           SetCommonData("haya",1);
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 600);}
           PlaySE(se9);
           Tdeath(20,70,2,1);
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1000){VanishEnemy;}
        if(phase>=1){
           SetCollisionA(GetX, GetY, 70);
           SetCollisionB(GetX, GetY, 60);
           SetCollisionA(GetX+50, GetY, 70);
           SetCollisionB(GetX+50, GetY, 50);
           SetCollisionA(GetX-50, GetY, 70);
           SetCollisionB(GetX-50, GetY, 50);
        }
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 0, 0, 224, 224 );
        SetGraphicAngle(0,0,0);
        SetGraphicScale(1.2,1.2);
	DrawGraphic( GetX(), GetY());
        SetGraphicScale(1,1);

        SetGraphicRect( 224, 0, 352, 128 );
        SetGraphicAngle(0,30,time*11);
	DrawGraphic( GetX()-95, GetY()-35);
        SetGraphicRect( 224, 0, 352, 128 );
        SetGraphicAngle(180,30,time*11);
	DrawGraphic( GetX()+95, GetY()-35);
    }

    task Tmove{
        SetMovePosition02(GetX-370*arg, GetY+80, 230);
        wait(230);
        SetMovePosition02(GetX+140*arg, GetY, 250);
        wait(250);
        SetMovePosition02(GetX-370*arg, GetY-40, 350);
        wait(350);
        VanishEnemy();
    }
    task Tshot1{
        yield;
        wait(100);
        let a=0;
        loop{
           if(phase<=0){return;}
           if(GetX>52&&GetX<396){
              let b=0;
              loop(1+ex){
                 CreateShotFromScript( "shot5",GetX()+46, GetY()+20, 3.1+ex, a*21.3+b*180, 0, 1);
                 CreateShotFromScript( "shot5",GetX()-46, GetY()+20, 3.1+ex, -a*21.3+b*180+ex*90, 0, 1);
                 b++;
              }
           }
           wait(10-lv*5);
           a++;
        }
    }
    task Tshot2{
        yield;
        wait(150);
        let a=0;
        loop{
           if(phase<=0){return;}
           if(GetX>52&&GetX<396){
              let p=genteikaku(GetAngleToPlayer(),16);
              let b=-3-ex;
              loop(7+ex*2){
                 CreateShotFromScript( "shot1",GetX(), GetY()+50, 2.5+ex, p+b*(15-ex*5), 0, 02);
                 b++;
              }
           }
           wait(30-lv*15);
           a++;
        }
    }





    #include_function".\efanction.txt"
}

#include_script".\escript.txt"