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\air1.png";
	let tama = GetCurrentScriptDirectory~"tama.txt";
	let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
	let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
	let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
	@Initialize(){
	    SetLife( 200 );
	    SetInvincibility( 60 );
	    SetSpeed(2);
	    LoadGraphic( imgEnemy );
	    LoadUserShotData( tama );
	    Tshot1;Tmove1;
	}
	@MainLoop {
	    if(phase==2&&GetLife<=150){
	       phase-=1;
	       if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 64);}
	       PlaySE(se3);
	       Tdeath(4,64,2,0);
	       Tshot2;
	    }
	    if(phase==1&&GetLife<=100){
	       phase-=1;
	       if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 64);}
	       PlaySE(se2);
	       Tdeath(10,64,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( 1, 1, 128, 128 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY() );
	}

	task Tshot1{
		yield;
		wait(60);
		loop{
			if(GetY<280){
				if(phase<=1){return;}
				let a=0;
				let p1=atan2( GetPlayerY()-(GetY()+12), GetPlayerX()-(GetX()+33));
				let p2=atan2( GetPlayerY()-(GetY()+12), GetPlayerX()-(GetX()-33));
				loop(1+ex*2){
					SetShotDirectionType(ABSOLUTE);
					CreateShotFromScript( "shot1",GetX()+33, GetY()+12, 3+a*0.5, genteikaku(p1,32), 0, 06);
					CreateShotFromScript( "shot1",GetX()-33, GetY()+12, 3+a*0.5, genteikaku(p2,32), 0, 06);
					if(rank>2){
						CreateShotFromScript( "shot1",GetX()+33, GetY()+12, 3+a*0.5, genteikaku(p1,32)-9, 0, 06);
						CreateShotFromScript( "shot1",GetX()-33, GetY()+12, 3+a*0.5, genteikaku(p2,32)+9, 0, 06);
					}
					a++;
				}
			}
			wait(22-lv*12-ex*5);
		}
	}
	task Tshot2{
	    yield;
	    wait(60);
	    let a=0;
	    loop{
	       if(GetX>62&&GetX<396&&GetY>16&&GetY<280){
	          let b=-3-2*ex;
	          if(phase<=0){return;}
	          loop(7+ex*4){
	                CreateShotFromScript( "shot1",GetX()+33, GetY(), 1.8+ex, 180+b*(12-4*ex)+a*4.7, 0, 13);
	                CreateShotFromScript( "shot1",GetX()-33, GetY(), 1.8+ex, 0+b*(12-4*ex)+a*4.7, 0, 13);
	                b++;
	          }
	       }
	       wait(20-lv*16);
	       a++;
	    }
	}
	task Tmove1 {
	    wait(60);
	    SetMovePosition02(GetX, GetY+250, 500);
	    wait(500);
	    SetMovePosition02(GetX, GetY+200, 100);
	    wait(100);
	    VanishEnemy();
	}




	#include_function".\efanction.txt"
}

#include_script".\escript.txt"