script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 0;
    let life = 0;
    let kaku = 10;
    let score = 180;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\zakocannon1.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
    @Initialize(){
        SetLife( 120 );
        SetInvincibility( 10 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        Tshot;
    }
    @MainLoop {
        rate=life-GetLife;
        life=GetLife;
        if(phase==1&&GetLife<=100){
           phase-=1;
           PlaySE(se3);
           Tdeathl(mapx,mapy,4,24,2,1);
        }
        if(GetX<12||GetX>436||GetY<16){
           SetInvincibility( 5 );
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1600){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX, GetY, 24);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        lv=GetCommonData("rank");
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 1, 1, 48, 48 );
        SetGraphicAngle(0,0,angle);
	DrawGraphic( GetX(), GetY() );
        SetGraphicRect( 48, 1, 96, 48 );
        SetGraphicAngle(0,0,GetAngleToPlayer()-GetAngleToPlayer()%12+6);
	DrawGraphic( GetX(), GetY() );
    }

    task Tshot{
        yield;
        SetCommonData("ransu",GetCommonData("ransu")+1);
        wait(160+GetCommonData("ransu")%4*30-lv*25);
        loop{
           if(GetX>32&&GetX<416&&GetY>16&&GetY<(300+rank*20)&&(GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2>150^2){
              let p=GetAngleToPlayer();
              p+=-p%12+6;
              loop(3+rank/2){
                 CreateShotFromScript( "shot1",GetX()+cos(p)*15, GetY()+sin(p)*15, 2.5+ex, p+GetCommonData("ex")*3, 0, 12);
                 if(ex==1){
                    CreateShotFromScript( "shot1",GetX()+cos(p)*15, GetY()+sin(p)*15, 2.5+ex, p-3, 0, 12);
                 }
                 wait(4)
              }
           }
           wait(72-lv*13);
        }
    }


    #include_function".\efanction.txt"
}

#include_script".\escript.txt"