script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 0;
    let life = 0;
    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\zakoheli3.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
    @Initialize(){
        SetLife( 103 );
        SetInvincibility( 15 );
        SetSpeed(3.3);
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        Tmove;Tshot1;
    }
    @MainLoop {
        rate=life-GetLife;
        life=GetLife;
        if(phase==1&&GetLife<=100){
           phase-=1;
           PlaySE(se3);
           Tdeatha(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);
        }
        lv=GetCommonData("rank");
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 48, 0, 96, 48 );
        SetGraphicAngle(0,40,-time*17);
	DrawGraphic( GetX(), GetY()+10 );
        SetGraphicRect( 0, 0, 48, 48 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY()+4);
        SetGraphicRect( 96, 0, 144, 48 );
        SetGraphicAngle(0,30,GetAngleToPlayer);
	DrawGraphic( GetX(), GetY());
    }

    task Tshot1{
        yield;
        wait(15);
        let a=0;
        let b=0;
        while(b<35){
           let p=GetAngleToPlayer;
           p+=-p%12+6;
           CreateShotFromScript( "shot3",GetX(), GetY(), 0.04+ex*0.02, p, 0, 06);
           if(ex==1){
              CreateShotFromScript( "shot3",GetX(), GetY(), 0.02+ex*0.01, p+20, 0, 06);
              CreateShotFromScript( "shot3",GetX(), GetY(), 0.02+ex*0.01, p-20, 0, 06);
           }
           a++;
           b+=28-lv*5;
           wait(28-lv*5);
        }
        wait(30);
        loop{
           if(GetX>32&&GetX<416&&GetY>16&&GetY<400){
              SetShotDirectionType(ABSOLUTE);
              let p=GetAngleToPlayer;
              p+=-p%12+6;
              let a=0;
              loop(1+ex){
                 CreateShotFromScript( "shot1",GetX()+cos(p)*20, GetY()+sin(p)*14, 1.5+a, p, 0, 12);
                 a++;
              }
           }
           wait(55-lv*10);
        }
    }
    task Tmove {
        yield;
        SetMovePosition03(GetX+cos(angle)*240,GetY+sin(angle)*240,30,4);
        wait(80);
        let p=GetAngleToPlayer;
        p+=-p%12+6;
        SetMovePosition01(GetX+cos(p)*500,GetY+sin(p)*500,2.5);
        wait(200);
        VanishEnemy();
    }


    #include_function".\efanction.txt"
}

#include_script".\escript.txt"