script_enemy_main {
	let time = 0;
	let phase = 2;
	let rate = 4;
	let kaku = 30;
	let score = 800;
	let lv = 0;
	let angle = GetAngle();
	let rank = GetSpeed();
	let arg = GetArgument();
	let ex = GetCommonData("ex");
	let imgEnemy = GetCurrentScriptDirectory~"img\air4.png";
	let tama = GetCurrentScriptDirectory~"tama.txt";
	let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
	let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
	let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
	@Initialize(){
		SetLife( 250 );
		SetInvincibility( 50 );
		SetSpeed(2);
		LoadGraphic( imgEnemy );
		LoadUserShotData( tama );
		Tshot1;
		if(arg==1){Tmove1;}
		else if(arg==2){Tmove2;}
	}
	@MainLoop {
	    if(phase==2&&GetLife<=200){
	       phase-=1;
	       if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 50);}
	       PlaySE(se3);
	       Tdeath(4,50,2,0);
	       Tshot2;
	    }
	    if(phase==1&&GetLife<=100){
	       phase-=1;
	       if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 50);}
	       PlaySE(se2);
	       Tdeath(10,50,2,1);
	    }
	    if(phase>=1){
	       SetCollisionA(GetX, GetY, 48);
	       SetCollisionB(GetX, GetY, 32);
	    }
	    if(GetCommonData("kakusei")>0){lv=1}
	    else{lv=0}
	    time++;
	    yield;
	}
	@Finalize() {
	}
	@DrawLoop {
	SetTexture( imgEnemy );
        SetGraphicRect( 0, 0, 128, 96 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY() );
        if(phase==2){
        SetGraphicRect( 0, 96, 128, 192 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY()+20 );
        }
    }

    task Tshot1{
        yield;
        wait(30);
        loop{
           if(GetY<300){
              let a=0;
              let p1=atan2( GetPlayerY()-(GetY()+20), GetPlayerX()-(GetX()+33));
              let p2=atan2( GetPlayerY()-(GetY()+20), GetPlayerX()-(GetX()-33));
              loop(7){
                 if(phase<=1){return;}
                 SetShotDirectionType(ABSOLUTE);
                 let b=-1-ex;
                 loop(3+ex*2){
                    CreateShotFromScript( "shot1",GetX()+33, GetY()+20, 3, genteikaku(p1,32)+b*14, 0, 13);
                    CreateShotFromScript( "shot1",GetX()-33, GetY()+20, 3, genteikaku(p2,32)+b*14, 0, 13);
                    b++;
                 }
                 a++;
                 wait(3);
              }
           }
           wait(40-lv*20);
        }
    }
    task Tshot2{
        yield;
        wait(30);
        loop{
           let b=-1;
           if(GetX>62&&GetX<396&&GetY>16&&GetY<300){
              if(phase<=0){return;}
              let a=-2;
              let p1=atan2( GetPlayerY()-(GetY()+15), GetPlayerX()-(GetX()));
              let p2=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+30));
              let p3=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-30));
              loop(5){
                 loop(1){
                    CreateShotFromScript( "shot1",GetX()+a*6, GetY()+15-b*5, 2.7+ex, p1, 0, 06);
                    CreateShotFromScript( "shot1",GetX()+30+a*6, GetY()+b*5, 2.7+ex, p2, 0, 06);
                    CreateShotFromScript( "shot1",GetX()-30-a*6, GetY()+b*5, 2.7+ex, p3, 0, 06);
                    b++;if(b>1){b=-1}
                 }
                 a++;b++;
              }
           }
           wait(30-lv*27);
        }
    }
    task Tmove1 {
        wait(60);
        SetMovePosition02(GetX, GetY+210, 400);
        wait(400);
        SetMovePosition02(GetX, GetY+200, 100);
        wait(100);
        VanishEnemy();
    }
    task Tmove2 {
        wait(30);
        SetMovePosition02(GetX, GetY+270, 500);
        wait(500);
        SetMovePosition02(GetX, GetY+200, 100);
        wait(100);
        VanishEnemy();
    }





    #include_function".\efanction.txt"
}

#include_script".\escript.txt"