script_enemy_main
{
	let frame=-100;
	let itemval=0;
	let cutin=GetCurrentScriptDirectory~"img\lilyw_cutin.png";
	#include_function ".\spellcard.txt";
	#include_function ".\boss2anim.txt";
    #include_function ".\..\lib\enemyfunctions.txt"
	
task attack{
	Concentration01(50);
	PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
	loop(50){yield;}
	let angle=GetAngleToPlayer;
	ascent(i in -3..4){
		PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
		PlaySEDelay(GetCurrentScriptDirectory~"sound\BulletWave.wav", 120);
		bomb(angle+i*25);
		loop(5){yield;}
	}
	loop(50){yield;}
	move;
	loop(50){yield;}
	Concentration01(50);
	PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
	loop(50){yield;}
	let angle=GetAngleToPlayer;
	descent(i in -3..4){
		PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
		PlaySEDelay(GetCurrentScriptDirectory~"sound\BulletWave.wav", 120);
		bomb(angle+i*25);
		loop(5){yield;}
	}
	loop(50){yield;}
	move;
	loop(50){yield;}
	Concentration01(50);
	PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
	loop(50){yield;}
	let angle=GetAngleToPlayer;
	ascent(i in 0..12){
		PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
		PlaySEDelay(GetCurrentScriptDirectory~"sound\BulletWave.wav", 120);
		bomb(angle+i*30);
		bomb(angle-i*30);
		loop(5){yield;}
	}
	loop(50){yield;}
	move;
	loop(50){yield;}
	attack;
}

task bomb(ang){
	let angle=0;
	let obj=Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, GetX, GetY);
	Obj_SetSpeed(obj, 3);
	Obj_SetAngle(obj, ang);
	ObjShot_SetGraphic(obj, 236);
	ObjShot_SetDelay(obj, 15);
	ObjShot_ToItem(obj, false);
	while(Obj_BeDeleted(obj)==false){
		if(Obj_GetSpeed(obj)>0){Obj_SetSpeed(obj, Obj_GetSpeed(obj)-0.025);}
		if(Obj_GetSpeed(obj)<=0){
			angle=rand(0, 359);
			ascent(i in 0..14){
				ascent(j in 0..10){
					pellet(Obj_GetX(obj), Obj_GetY(obj), angle+i*180/7, 47+i, j*3);
				}
			}
			ObjShot_FadeDelete(obj);
		}
		yield;
	}
}

task pellet(x, y, ang, graphic, d){
	let obj=Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, x, y);
	Obj_SetSpeed(obj, 3);
	Obj_SetAngle(obj, ang);
	ObjShot_SetGraphic(obj, graphic);
	ObjShot_SetDelay(obj, d);
	ObjShot_ToItem(obj, false);
}

sub move{
	let x=GetPlayerX+rand(-100, 100);
	let y=rand(70, 130);
	while(x>GetClipMaxX-20 || x<GetClipMinX+20){
		x=GetPlayerX+rand(-100, 100);
	}
	SetMovePosition03(x, y, 10, 4);
}

task PlaySEDelay(string, time){
	loop(time){yield;}
	PlaySE(string);
}

	@Initialize
	{
		SetInvincibility(600);
		SetLife(350);
		SetDamageRate(40,40);

		SetMovePosition02(GetCenterX,120,20);
		LoadGraphic(cutin);
		CutIn(YOUMU, "Spring Sign ''Rainbow Explosion''",cutin,0,0,350,438);
		LoadUserShotData(GetCurrentScriptDirectory~"supershot.txt");

		SetCommonData("ONSPELL", "TRUE");
		spellbonus;
		timer;
		SetCommonData("timercount", 6000);
	}
	
	@MainLoop
	{
		SetCollisionA(GetX(),GetY(),24);
		SetCollisionB(GetX(),GetY(),24);
		frame++;
		if(frame==100){attack;}
		yield;
}
	
	@Finalize
	{
		if(spbonus==1){
			loop(35){ItemDrop(0, GetX, GetY);}
			itemval=rand_int(1, 50);
				if(itemval==1){ItemDrop(2, GetX, GetY);}
				if(itemval==11){ItemDrop(3, GetX, GetY);}
				if(itemval==21){ItemDrop(5, GetX, GetY);}
				if(itemval==31){ItemDrop(7, GetX, GetY);}
				if(itemval==41){ItemDrop(9, GetX, GetY);}
			itemval=rand_int(1, 5);
				loop(itemval){ItemDrop(6, GetX, GetY);}
		}
			loop(15){ItemDrop(0, GetX, GetY);}
		SetCommonData("ONSPELL", "FALSE");
	}
	
	@DrawLoop
	{
		anim_idle;
	}
}