#Title[dʏU]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let count = 0;
	#include_function ".\eW.txt"

	@Initialize{
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(5000);
	SetTimer(99);
	SetDamageRate(100,50);

	LoadGraphic(imgboss73);
	LoadGraphic(imgwitch);
	SetTexture(imgboss73);
	SetGraphicRect(0,0,127,127);
	Shot(2);
	SetText("֐ulԑnp@- Lv.66-v");
	}

	@MainLoop{
	count++;
	if(count == 120){CreateEnemyFromScript("WITCH",GetCenterX,GetCenterY,0,0,1);}
	if(count == 240){SetText("");}
	ChackBonus;
	SetCollisionA(GetX,GetY,24);
	SetCollisionB(GetX,GetY,24);
	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	MasicPointAddNormal(10);
	DeleteGraphic(imgboss73);
	DeleteGraphic(imgknight);
	}

	task Move(){
	loop{
	yield;
	}
	}

	task Shot(level){
	function Wait(time){loop(time){yield;}}

	Wait(260);
	loop{
	AroundToShot(GetX + rand(-160,160),GetY + rand(-70,70),rand(48,96),32 + level * 4,20,1.2,rand(0,360),0,false,false,RED01,20);
	Wait(50 - level * 5);
	}
	}
}

script_enemy WITCH
{
#include_function ".\eW.txt"


	//ʒu
	let xini    =GetX;
	let yini    =GetCenterY;

	@Initialize{
	SetLife(50000);
	SetScore(10000);
	SetDamageRateEx(100,0,10,0);

	SetTexture(imgwitch);
	SetGraphicRect(0,0,127,127);
	Shot(GetArgument);
	Move();
	SetMovePosition02(xini,yini,60);
	}

	@MainLoop{
	SetCollisionB(GetX,GetY,8);
	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	}



	task Shot(level){

	task MasicShot(n,level){
	let obj = Obj_Create(OBJ_SHOT);
	let bullet = [RED11,GREEN11,BLUE11,ORANGE11,PURPLE11,YELLOW11,AQUA11];
	let a = rand_int(0,6);
	Obj_SetX(obj, GetX);
	Obj_SetY(obj, GetY);
	Obj_SetSpeed(obj, 2);
	Obj_SetAngle(obj, GetAngleToPlayer + n);
	ObjShot_SetGraphic(obj, WHITE03);
	ObjShot_SetDelay(obj, 40);
	ObjShot_SetBombResist(obj,true);
			
	let count = 0;
	while( !Obj_BeDeleted(obj) ){
	loop(35 - level * 5){yield;}

	BreakStarShot(Obj_GetX(obj) + rand(-24,24),Obj_GetY(obj) + rand(-24,24),bullet[a],level);
	a++;
	if(a > 6){a = 0;}
	count++;
	if(count == 20 + level * 3){Obj_Delete(obj);}
	}
	}

	function BreakStarShot(x,y,bullet,level){
	let way = level * 2 + 3;
	let addangle = 360 / way;
	let angle = rand(0,360);

	loop(way){
	CreateShotA(1,x,y,30);
	SetShotDataA(1,0,0,angle,0,0,0,bullet);
	SetShotDataA(1,150,NULL,NULL,0,0.024,rand(1.7,2 + level * 0.4),bullet);
	FireShot(1);
	angle += addangle;
	}
	}

	let wait = 250;

	loop{
	let n = (level * 2 - 2) * 20;
	loop(wait){yield;	if(OnBomb == true){wait -= 1;	if(wait < 100){wait = 100;}}}
	loop(level * 4 + -3){MasicShot(n,level); n += 20;}
	wait -= 5;
	if(wait < 80){wait = 250 - level * 30;}
	}
	}

	task Move{
	loop{
	yield;
	}
	}
}