script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 5;
    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\zakocannon2.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se8 = GetCurrentScriptDirectory~"wav\se8.wav";
    @Initialize(){
        SetLife( 140 );
        SetInvincibility( 10 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        Tshot;
		Tgazou3(1,1,64,64,32);
   	layer = 0;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 45);}
           PlaySE(se8);
           Tdeath(6,30,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);
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
    }

    task Tshot{
        yield;
        wait(40+GetCommonData("ransu")%4*10);
        SetCommonData("ransu",GetCommonData("ransu")+1);
        loop{
           if(GetX>32&&GetX<416&&GetY>16&&GetY<(300+rank*20)&&(GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2>150^2){
              let p=genteikaku(GetAngleToPlayer(),24);
              loop(6+rank){
                 if(phase<=0){return;}
                 CreateShotFromScript( "shot1",GetX()+cos(p+45)*30, GetY()+sin(p+45)*30, 2.5+ex, p+ex*3, 0, 12);
                 CreateShotFromScript( "shot1",GetX()+cos(p+37)*26, GetY()+sin(p+37)*26, 2.5+ex, p, 0, 12);
                 CreateShotFromScript( "shot1",GetX()+cos(p-45)*30, GetY()+sin(p-45)*30, 2.5+ex, p-ex*3, 0, 12);
                 CreateShotFromScript( "shot1",GetX()+cos(p-37)*26, GetY()+sin(p-37)*26, 2.5+ex, p, 0, 12);
                 wait(3)
              }
           }
           if(lv==0){wait(50-rank*9);}
           wait(12);
        }
    }


    #include_function".\efanction.txt"
    #include_function".\effobj.txt"
}

#include_script".\escript.txt"