let point = 0;
let Remi = false;
let mc = 0;
let m_time = 0;

task maple(type){
	let start = rand(0,119);
	if(type==2){
		Bright(objBoss,60);
		PlaySound("Charge5",95,0);
		TCharge01(objBoss,3,40,255,128,92);
		ascent(i in 0..20){
		etama(i*10+rand(0,50),20,i,start,1);
		etama(i*10+rand(0,50),20,i,start,-1);
		yield;
		}
	}
	if(type==0){
		Bright(objBoss,60);
		PlaySound("Charge2",95,0);
		TCharge01(objBoss,3,40,255,128,92);
		ascent(i in 0..20){
		etama(i*10+rand(0,50),20,i,start,1);
		etama(i*10+rand(0,50),20,i,start,-1);
		yield;
		}
	}
	if(type==1){
		Bright(objBoss,120);
		PlaySound("Charge1",95,0);
		TCharge01(objBoss,3,110,256,128,92);
		ascent(i in 0..40){
		etama(i*8+rand(0,50),20,i,start,1);
		etama(i*8+rand(0,50),20,i,start,-1);
		yield;
		}
	}
	if(type==3){
		Bright(objBoss,120);
		PlaySound("Charge3",95,0);
		TCharge01(objBoss,3,110,256,128,92);
		ascent(i in 0..40){
		etama(i*8+rand(0,50),20,i,start,1);
		etama(i*8+rand(0,50),20,i,start,-1);
		yield;
		}
	}
	}

task etama(r,a,n,start,way){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/lightc.png";
	let dir = rand(0,359);
	let angle = rand(0,359);
	let size = 0.5+r/300;
	let s = size;
	let ra = r;
	let c = 0;
	let m = -10;
	let alpha = 0;
	let set = 360/a;
	let color = 0;
	let alphaplus = 255/ra;
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,50,50);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	ObjRender_SetAlpha(obj,0);
	Obj_SetRenderPriorityI(obj,25);
	while(r>0 && !Obj_IsDeleted(objBoss)){
	ObjRender_SetPosition(obj,GetEnemyX+r*cos(dir),GetEnemyY+r*sin(dir),0);
	ObjRender_SetAngleXYZ(obj,0,0,angle+c*100*way);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	color = (64+alpha);
	ObjRender_SetColor(obj,color+alpha*2.5*sin(n*set+start+150),color+alpha*2.5*sin(n*set+270+start),color+alpha*2.5*sin(n*set+30+start));
	if(r>ra/2){alpha += alphaplus+1;}
	else{
	alpha -= alphaplus;
	if(alpha<=0){Obj_Delete(obj);}
	}
	size -= 0.01;
	r -= 8+c;
	c -= n/1200;
	yield;
	}
	Obj_Delete(obj);
}

task MapleExplode{
	let px = GetEnemyX;
	let py = GetEnemyY;
	ascent(i in 0..120){
	Explode(rand(1,10),rand(0,359),rand(2,5));
	}
	task Explode(spd,dir,size){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/eff2.png";
	let r = 0;
	let angle = rand(0,359);
	let alpha = 255;
	let minus = 256/(size/0.03);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,32,226,64,254);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetAlpha(obj,255);
	while(alpha>0){
	ObjRender_SetPosition(obj,px+r*cos(dir),py+r*sin(dir),0);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetAngleXYZ(obj,0,0,angle);
	ObjRender_SetAlpha(obj,alpha);
	alpha -= minus;
	angle += size;
	r+= spd;
	spd -= 0.03;
	size -= 0.01;
	yield;
	}
	}
	}
	
task SetImageAndTail(obj,r1,r2,r3,r4,angleY){
	ObjSprite2D_SetSourceRect(obj,r1,r2,r3,r4);
	MarisaTail(obj,r1,r2,r3,r4,angleY);
	ObjRender_SetAngleY(objBoss,angleY);
	}
	
task MarisaTail(boss,r1,r2,r3,r4,ang){
	m_time++;
	mc++;
	if(m_time%4==0){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/boss.png";
	LoadTexture(img);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj, r1, r2, r3, r4);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	ObjRender_SetScaleXYZ(obj,1,1,1);
	ObjRender_SetAngleXYZ(obj,0,ang,0);
	if(!Obj_IsDeleted(boss)){
	ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
	}
	if(ObjRender_GetX(boss)==0 && ObjRender_GetY(boss) ==0){Obj_Delete(obj);}
	Obj_SetRenderPriority(obj,0.3);
	ManageScale;
	ManageAlpha;
	task ManageScale{
		ascent(i in 0..20){
		ObjRender_SetScaleXYZ(obj,1+i*0.08,1+i*0.08,1);
		yield;
		}
	}
	task ManageAlpha{
		descent(i in 0..20){
		if(!Obj_IsDeleted(boss)){
		ObjRender_SetColor(obj,i*6+60*sin(mc),i*6+60*sin(mc+120),i*6+60*sin(mc+240));
		yield;
		}
		}
	Obj_Delete(obj);
	}
	}
	}

task manageSprite{
		let f = 0;
		while(f<=24 && idle == false  && atk == false){
		if(f<12){
		SetImageAndTail(objBoss, 256, 256, 384, 384,ang);
		}
		if(f>=12 && f<24){
		SetImageAndTail(objBoss, 256, 384, 384, 512,ang);
		}
		f+=1;
		yield;
		}
		while(ObjMove_GetSpeed(objBoss) > 1){
		MarisaTail(objBoss,256,384,384,512,ang);
		yield;
		}
		while(f>=24 && idle == false  && atk == false){
		if(f<12){
		SetImageAndTail(objBoss, 256, 256, 384, 384,ang);
		}
		if(f>=12 && f<24){
		SetImageAndTail(objBoss, 256, 384, 384, 512,ang);
		}
		f-=2;
		yield;
		}
		idle = true;
	}

task attack(time,type){
	let f2 = 0;
	let px = 128;
	let py = 128;
	atk = true;
	idle = false;
		if(type==1){
		loop(8){SetImageAndTail(objBoss, px*4, py*0, px*5, py*1,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*4, py*1, px*5, py*2,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*4, py*2, px*5, py*3,ang);yield;}
		loop(time-48){MarisaTail(objBoss, px*4, py*2, px*5, py*3,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*4, py*2, px*5, py*3,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*4, py*1, px*5, py*2,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*4, py*0, px*5, py*1,ang);yield;}
		}
		if(type==2){
		loop(8){SetImageAndTail(objBoss, px*5, py*0, px*6, py*1,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*5, py*1, px*6, py*2,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*5, py*2, px*6, py*3,ang);yield;}
		loop(time-48){MarisaTail(objBoss, px*5, py*2, px*6, py*3,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*5, py*2, px*6, py*3,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*5, py*1, px*6, py*2,ang);yield;}
		loop(8){SetImageAndTail(objBoss, px*5, py*0, px*6, py*1,ang);yield;}
		}
		atk = false;
	}
	
task magiccircle(boss,size,type){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/MG.png";
	let spin = 0;
	let s = 0;
	LoadTexture(img);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,256,256);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetAlpha(obj,192);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	while(!Obj_IsDeleted(boss)){
	spin += 2;
	let timer = ObjEnemyBossScene_GetInfo(objScene, INFO_TIMERF);
	ObjRender_SetAngleXYZ(obj,0,0,spin*2);
	ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
	ObjRender_SetColor(obj,192+32*sin(spin),192+32*sin(spin+180),0);
	if(type==true){
	ObjRender_SetScaleXYZ(obj,size*1.1+0.1*sin(spin),size*1.1+0.1*sin(spin),0);
	}
	ObjMove_SetPosition(obj,GetEnemyX,GetEnemyY);
	yield;
	}
	Obj_Delete(obj);
	}
	

task Cutin(text,textwidth){
	EffText;
	SpellAttack;
	task EffText{
	let scale=4;
	let py = 0;
	let acc = 0;
	let acc2 = 0;
	let alpha = 0;
	let yscale = 0;
	let objTxt=ObjText_Create;
	TScale;
	ObjText_SetText(objTxt,text);
	ObjText_SetFontSize(objTxt,textwidth);
	//ObjText_SetFontColorTop(objTxt,128,255,0);
	//ObjText_SetFontColorBottom(objTxt,192,255,0);
	ObjText_SetFontBorderType(objTxt,BORDER_FULL);
	ObjText_SetFontBorderColor(objTxt,0,0,0);
	ObjText_SetFontBorderWidth(objTxt,1);
	ObjText_SetHorizontalAlignment(objTxt,ALIGNMENT_RIGHT);
	ObjText_SetMaxWidth(objTxt,380);
	Obj_SetRenderPriority(objTxt,0.8);
	ObjRender_SetPosition(objTxt,-300,300,0);
	ObjText_SetAutoTransCenter(objTxt,true);
		task TScale{
		DrawLine;
		ascent(i in 0..30){
		ObjRender_SetAlpha(objTxt,i*12);
		ObjRender_SetScaleXYZ(objTxt,scale,scale,1);
		ObjRender_SetPosition(objTxt,-310+i*10,300,0);
		scale -= 0.1;
		yield;
		}
		loop(57){
		ObjRender_SetPosition(objTxt,-20,300+py,0);
		py += acc;
		acc += 0.1;
		yield;
		}
		ObjRender_SetPosition(objTxt,0,-240,0);
		loop(40){
		ObjRender_SetPosition(objTxt,-20,-240+py,0);
		py += acc;
		acc -= 0.16;
		yield;
		}
		let alpha_t = 255;
		while(!Obj_IsDeleted(objBoss)){
			if(GetPlayerY>100 && alpha_t<255){alpha_t+=10;}
			if(GetPlayerY<=100 && alpha_t>100){alpha_t-=10;}
			ObjRender_SetAlpha(objTxt,alpha_t);
		yield;
		}
			loop(20){
				alpha-=12.75;
				yscale+=0.05;
				ObjRender_SetAlpha(objTxt,alpha);
				ObjRender_SetScaleXYZ(objTxt,yscale,yscale,1);
				yield;
			}
			Obj_Delete(objTxt);
		}
			task DrawLine{
			let obj=ObjPrim_Create(OBJ_SPRITE_2D);
			let img=GCSD~"img/line.png";
			let size = 0.75;
			let color = 0;
			let c = 0;
			ObjPrim_SetTexture(obj,img);
			ObjSprite2D_SetSourceRect(obj,0,0,256,36);
			ObjSprite2D_SetDestCenter(obj);
			ObjRender_SetBlendType(obj,BLEND_ALPHA);
			ObjRender_SetScaleXYZ(obj,size*1.75,size,size);
			ObjRender_SetAngleXYZ(obj,0,0,ang);
			let alpha_t = 0;
			let t = 0;
			while(!Obj_IsDeleted(objBoss)){
			ObjRender_SetPosition(obj,ObjRender_GetX(objTxt)+240,ObjRender_GetY(objTxt)+8,0);
			if(t>100){
			if(GetPlayerY>100 && alpha_t<255){alpha_t+=10;}
			if(GetPlayerY<=100 && alpha_t>100){alpha_t-=10;}
			}
			ObjRender_SetAlpha(obj,alpha_t);
			t++;
			yield;
			}
			Obj_Delete(obj);
			}
	}
	
	let cut=ObjPrim_Create(OBJ_SPRITE_2D);
	let path=GCSD~"img/cut.png";
	LoadTexture(path);
	ObjPrim_SetTexture(cut,path);
	ObjSprite2D_SetSourceRect(cut,0,0,512,512);
	ObjRender_SetScaleXYZ(cut,0.75,0.75,1.1);
  	ObjSprite2D_SetDestCenter(cut);
	ObjRender_SetPosition(cut,416,120,0);
	Obj_SetRenderPriority(cut,0.22);
	//ObjRender_SetBlendType(cut,BLEND_ADD_ARGB);
	TCut;
	
	task TTail(px,py,alpha,num,t){
		wait(t);
		let tail=ObjPrim_Create(OBJ_SPRITE_2D);
		let path=GCSD~"img/cut.png";
		let sc = 0.75;
		LoadTexture(path);
		ObjPrim_SetTexture(tail,path);
		ObjSprite2D_SetSourceRect(tail,0,0,512,512);
		ObjSprite2D_SetDestCenter(tail);
		Obj_SetRenderPriority(tail,0.21);
		ObjRender_SetBlendType(tail,BLEND_ADD_ARGB);
		descent(i in 0..30){
		ObjRender_SetPosition(tail,px-20,py,0);
		ObjRender_SetScaleXYZ(tail,sc,sc,1.1);
		ObjRender_SetColor(tail,alpha*i/90,alpha*i/120,alpha*i/90);
		sc+=0.015;
		yield;
		}
		Obj_Delete(tail);
	}

	task TCut{
		
		let speed=1;
		let alpha = 0;
		let count = 0;
		ObjRender_SetAlpha(cut,0);
		ObjRender_SetY(cut,175);
		descent(i in 10..70){
			alpha = 255-i*255/70+60;
			ObjRender_SetX(cut,ObjRender_GetX(cut)-speed*5);
			ObjRender_SetY(cut,ObjRender_GetY(cut)+speed*i/20);
			ObjRender_SetAlpha(cut,alpha);
			if(i%2==0){TTail(ObjRender_GetX(cut),ObjRender_GetY(cut),alpha/2,count,15);}
			speed=i/65;
			count++;
			yield;
			}
		ascent(p in 0..60){
		ObjRender_SetX(cut,ObjRender_GetX(cut)-speed*5); 
		ObjRender_SetY(cut,ObjRender_GetY(cut)+speed*0.1);
		if(p%3==0){TTail(ObjRender_GetX(cut),ObjRender_GetY(cut),alpha/3,count,15);}
		speed = 10/65;
		count++;
		yield;
		}
		ascent(i in 10..60){
			alpha = 255-i*255/60;
			ObjRender_SetX(cut,ObjRender_GetX(cut)-speed*6);
			ObjRender_SetY(cut,ObjRender_GetY(cut)+speed*0);
			ObjRender_SetAlpha(cut,alpha);
			if(i%2==0){TTail(ObjRender_GetX(cut),ObjRender_GetY(cut),alpha/2,count,15);}
			speed=i/55;
			count++;
			yield;
			}
		Obj_Delete(cut);
		}
}

task SpellAttack{
	let s = 1;
	ascent(j in 0..10){
	ascent(i in 0..9){
	Attack(stgx-600+i*230*cos(-60),stgy+175+j*34+i*78*sin(-60),0,60,s);
	}
	s = -s;
	}
	ascent(i in 0..7){
	Attack(stgx+100,stgy+140,120,i*360/7,1);
	Attack(stgx+100,stgy+140,150,i*360/7,-1);
	Attack(stgx+100,stgy+140,180,i*360/7,-1);
	}
		task Attack(x,y,r,ang,way){
		let obj=ObjPrim_Create(OBJ_SPRITE_2D);
		let img=GCSD~"img/circle.png";
		let size = 1;
		let color = 0;
		let c = 0;
		ObjPrim_SetTexture(obj,img);
		ObjSprite2D_SetSourceRect(obj,102,0,120,128);
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetPosition(obj,stgx,stgx,0);
		ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
		ObjRender_SetScaleXYZ(obj,size,size,size);
		ObjRender_SetAngleXYZ(obj,0,0,ang);
		ManageAlpha;
			if(r==0){
				while(!Obj_IsDeleted(obj)){
				ObjRender_SetPosition(obj,x,y,0);
				x+=1.25*way*cos(ang-90);
				y+= 1.25*way*sin(ang-90);
				yield;
				}
			}
			else {
				while(!Obj_IsDeleted(obj)){
				ObjRender_SetAngleXYZ(obj,0,0,getDotAngle(x,y,ObjRender_GetX(obj),ObjRender_GetY(obj)));
				ObjRender_SetPosition(obj,x+r*cos(ang+c),y+r*sin(ang+c),0);
				c-= 1.25*way;
				yield;
				}
			}
			task ManageAlpha{
			ascent(i in 0..30){
			ObjRender_SetColor(obj,i*5,i*5,i*5);
			yield;
			}
			wait(90);
			descent(i in 0..30){
			ObjRender_SetColor(obj,i*5,i*5,i*5);
			yield;
			}
			Obj_Delete(obj);
			}
		}
	}
	
	task IsDelete(obj){
	while(!Obj_IsDeleted(objBoss)){yield;}
	Obj_Delete(obj);
	}

task Bright(boss,t){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/bright.png";
	let c = 0;
	let set = 360/(t*3);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,64,64);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	ObjRender_SetScaleXYZ(obj,6,6,0);
	Obj_SetRenderPriorityI(obj,25);
	IsDelete(obj);
	if(t==60){
		ascent(i in 0..30){
		ObjRender_SetColor(obj,i*8*sin(c+60),i*8*sin(c+180),i*8*sin(c+300));
		ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
		c+=set;
		yield;
		}
		descent(i in 0..30){
		ObjRender_SetColor(obj,i*8*sin(c+60),i*8*sin(c+180),i*8*sin(c+300));
		ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
		c+=set;
		yield;
		}
	}
	if(t==120){
		ascent(i in 0..60){
		ObjRender_SetColor(obj,i*4*sin(c+60),i*4*sin(c+180),i*4*sin(c+300));
		ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
		c+=set;
		yield;
		}
		descent(i in 0..60){
		ObjRender_SetColor(obj,i*4*sin(c+60),i*4*sin(c+180),i*4*sin(c+300));
		ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
		c+=set;
		yield;
		}
	}
	Obj_Delete(obj);
	}
	
task DrawAll{
	DrawDifficulty;
	DrawName;
	DrawScore;
	}
	
task DrawDifficulty{
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"font/Moderate.png";
	let c = 255;
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,16);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,stgx+335,30,0);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(obj,1.15,1.15,0);
	ObjRender_SetColor(obj,c,c,c);
	Obj_SetRenderPriority(obj,1);
	}
	
task DrawName{
	let objText = ObjText_Create();
	ObjText_SetText(objText, "Kirisame Marisa");
	ObjText_SetFontSize(objText, 15);
	ObjText_SetFontColorTop(objText, 255, 255, 255);
	ObjText_SetFontColorBottom(objText, 0, 255, 255);
	ObjText_SetFontBorderType(objText, BORDER_SHADOW);
	ObjText_SetFontBorderColor(objText,0, 128, 128);
	ObjText_SetFontBorderWidth(objText, 2);
	ObjRender_SetPosition(objText,0,14,0);
	}
	
task DrawScore{
	//Score;
	//BonusText;
	task Score{
		let objText = ObjText_Create();
		let alpha = 0;
		let c = 0;
		ObjText_SetFontSize(objText, 13);
		ObjText_SetFontColorTop(objText, 255, 255, 255);
		ObjText_SetFontColorBottom(objText, 255, 255, 255);
		ObjText_SetFontBorderType(objText, BORDER_FULL);
		ObjText_SetFontBorderColor(objText,128, 128, 128);
		ObjText_SetFontBorderWidth(objText, 2);
		ObjRender_SetPosition(objText,305,41,0);
			while(!Obj_IsDeleted(objText)){
			if(c>150){
			if(GetPlayerY>100 && alpha<255){alpha+=10;}
			if(GetPlayerY<=100 && alpha>100){alpha-=10;}
			}
			ObjText_SetText(objText,IntToString(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_SPELL_SCORE)));
			ObjRender_SetAlpha(objText,alpha);
			c++;
			yield;
			}
		}
		task BonusText{
		let objText = ObjText_Create();
		let alpha = 0;
		let c = 0;
		ObjText_SetText(objText,"Bonus :");
		ObjText_SetFontSize(objText, 13);
		ObjText_SetFontColorTop(objText, 255, 255, 255);
		ObjText_SetFontColorBottom(objText, 255, 255, 255);
		ObjText_SetFontBorderType(objText, BORDER_FULL);
		ObjText_SetFontBorderColor(objText,128, 128, 128);
		ObjText_SetFontBorderWidth(objText, 2);
		ObjRender_SetPosition(objText,235,41,0);
			while(!Obj_IsDeleted(objText)){
			if(c>150){
			if(GetPlayerY>100 && alpha<255){alpha+=10;}
			if(GetPlayerY<=100 && alpha>100){alpha-=10;}
			}
			ObjRender_SetAlpha(objText,alpha);
			c++;
			yield;
			}
		}
	}
	



function TCharge01(boss,size,frame,r,g,b){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/charge.png";
	let set = 360/(frame*4);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
	ObjRender_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	Obj_SetRenderPriorityI(obj,25);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=10;
		let alpha=255/l;
		loop(l){
			ObjRender_SetAlpha(obj,alpha);
			alpha+=255/(l*2);
			yield;
			}
		}
	task TShrink{
		let l=frame;
		let a = size*2/l/l;
		ascent(i in 0..l){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
			ObjRender_SetColor(obj,128+64*sin(i*set+120),128+64*sin(i*set+240),128+64*sin(i*set+0));
			size = size-i*a;
			if(Obj_IsDeleted(objBoss)){Obj_Delete(obj);}
			yield;
			}
		Obj_Delete(obj);
		
	}
}

function SCharge01(boss,size,frame,r,g,b){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/charge.png";
	let set = 360/(frame*4);
	let ang = rand(0,360);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
	ObjRender_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	Obj_SetRenderPriorityI(obj,25);
	ObjRender_SetAngleXYZ(obj,ang,ang+180,0);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=10;
		let alpha=255/l;
		loop(l){
			ObjRender_SetAlpha(obj,alpha);
			alpha+=255/(l*2);
			yield;
			}
		}
	task TShrink{
		let l=frame;
		let a = size*2/l/l;
		ascent(i in 0..l){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
			ObjRender_SetColor(obj,r,g,b);
			size = size-i*a;
			if(Obj_IsDeleted(objBoss)){Obj_Delete(obj);}
			yield;
			}
		Obj_Delete(obj);
		
	}
}

function NCharge01(boss,size,frame,r,g,b){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/charge.png";
	let set = 360/(frame*4);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
	ObjRender_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	Obj_SetRenderPriorityI(obj,25);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=10;
		let alpha=255/l;
		loop(l){
			ObjRender_SetAlpha(obj,alpha);
			alpha+=255/(l*2);
			yield;
			}
		}
	task TShrink{
		let l=frame;
		let a = size*2/l/l;
		ascent(i in 0..l){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
			ObjRender_SetColor(obj,r,g,b);
			size = size-i*a;
			if(Obj_IsDeleted(objBoss)){Obj_Delete(obj);}
			yield;
			}
		Obj_Delete(obj);
		
	}
}

function TCharge02(x,y,size,frame,r,g,b){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/charge.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,x,y,0);
	ObjRender_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetColor(obj,r,g,b);
	Obj_SetRenderPriorityI(obj,25);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=10;
		let alpha=255/l;
		loop(l){
			ObjRender_SetAlpha(obj,alpha);
			alpha+=255/(l*2);
			yield;
			}
		}
	task TShrink{
			let a = size/frame;
			loop(frame){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			ObjRender_SetPosition(obj,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),0);
			size = size-a;
			if(Obj_IsDeleted(objBoss)){Obj_Delete(obj);}
			yield;
			}
		Obj_Delete(obj);
		
	}
}
	
task effbreak(shot,size,t){
		if(!Obj_IsDeleted(shot)){
		fragment(shot,size,1);
		spongy(shot,t);
		}
	}
	
task fragment(shot,size,num){
		if(!Obj_IsDeleted(shot)){
		loop(num){
		realTask;
		}
		}
			task realTask{
			let obj=ObjPrim_Create(OBJ_SPRITE_2D);
			let img=GCSD~"img/effbreak.png";
			let s = rand(0.8,1.2)+size;
			let pic = ObjShot_GetImageID(shot);
			let color = GetShotDataInfoA1(pic,TARGET_ENEMY,INFO_DELAY_COLOR);
			let rect = [0,0,32,32];
			ObjPrim_SetTexture(obj,img);
			ObjSprite2D_SetSourceRect(obj,rect[0],rect[1],rect[2],rect[3]);
			ObjSprite2D_SetDestCenter(obj);
			ObjRender_SetScaleXYZ(obj,s,s,0);
			ObjRender_SetAngleXYZ(obj,0,0,rand(0,359));
			ObjRender_SetBlendType(obj,BLEND_ALPHA);
			ObjRender_SetColor(obj,color[0],color[1],color[2]);
			Obj_SetRenderPriority(obj,0.21);
			ObjShot_SetIntersectionEnable(shot,false);
			let x = ObjMove_GetX(shot);
			let y = ObjMove_GetY(shot);
			if(x!=0 && y!=0){
			ascent(i in 0..7){
			ObjRender_SetPosition(obj,x,y,0);
			ObjSprite2D_SetSourceRect(obj,rect[0],rect[1],rect[2],rect[3]);
			rect[0] = rect[0]+32;
			rect[2] = rect[2]+32;
			wait(3);
			}
			}
			Obj_Delete(obj);
			}
		}
	
task spongy(shot,t){
		let cloud = ObjShot_GetImageID(shot);
		if(cloud<141 || cloud>149){
		let obj=ObjPrim_Create(OBJ_SPRITE_2D);
		if(!Obj_IsDeleted(shot)){
		let img=GCSD~"Shot/Default_Shot.png";
		let s = 1;
		let adc = false;
		let rect = GetShotDataInfoA1(cloud,TARGET_ENEMY,INFO_RECT);
		let dir = ObjMove_GetAngle(shot)+90;
		ObjPrim_SetTexture(obj,img);
		ObjSprite2D_SetSourceRect(obj,rect[0],rect[1],rect[2],rect[3]);
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetPosition(obj,ObjMove_GetX(shot),ObjMove_GetY(shot),0);
		ObjRender_SetAngleXYZ(obj,0,0,dir);
		ObjRender_SetBlendType(obj,BLEND_ALPHA);
	 if( (cloud>=161 && cloud<=168) || (cloud>=21 && cloud<=28) || (cloud>=101 && cloud<=108) || (cloud>=211 && cloud<=218) || (cloud>=351 && cloud<=358) || (cloud>=151 && cloud<=158)){
	 adc = true;
	 ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	 }
		if(cloud>=41){
		ascent(i in 0..t){
		ObjRender_SetScaleXYZ(obj,s,s,0);
		if(adc==false){ObjRender_SetAlpha(obj,255-i*255/t);}
		if(adc==true){ObjRender_SetColor(obj,255-i*255/t,255-i*255/t,255-i*255/t);}
		s += 0.1;
		yield;
		}
		}
		Obj_Delete(obj);
		}
		}
		}
	

task TWaveCircle() // from sample script
{
	//レンダリングターゲットに使用するテクスチャ
	let renderTexture = GetReservedRenderTargetName(0);

	let frame = 0; //フレーム
	let baseEffectRadius = 144; //基準エフェクト半径
	let outerFluct = 16; //エフェクト半径の最大変化量
	let effectRadius = 0; //エフェクト半径
	let circleVertexCount = 16; //円をあらわすのに使用する頂点の数
	let innerCircleCount = 4;

	let priEffectMin = 20; //エフェクトをかける最小優先度
	let priEffectMax = 28; //エフェクトをかける最大優先度

	//背景のみエフェクトの対象とする
	//エフェクトの描画でまかなえるため、
	//優先度20〜28の通常描画を無効にする。
	SetInvalidRenderPriorityA1(priEffectMin, priEffectMax);


	let frameWidth = GetStgFrameWidth();
	let frameHeight = GetStgFrameHeight();
	let frameLeft = GetStgFrameLeft();
	let frameRight = frameLeft + frameWidth;
	let frameTop = GetStgFrameTop();
	let frameBottom = frameTop + frameHeight;

	//--------------------------------
	//円形の影
	let path = GetCurrentScriptDirectory() ~ "Effect02.png";
	let objShadow = ObjPrim_Create(OBJ_SPRITE_2D); //2Dスプライトオブジェクト生成
	Obj_SetRenderPriorityI(objShadow, 25); //描画優先度を設定
	ObjPrim_SetTexture(objShadow, path); //テクスチャを設定
	ObjRender_SetBlendType(objShadow, BLEND_MULTIPLY);
	ObjSprite2D_SetSourceRect(objShadow, 1, 1, 255, 255); //描画元設定(44, 54)-(71,105)
	ObjSprite2D_SetDestCenter(objShadow);
	ObjRender_SetScaleXYZ(objShadow, 1.2, 1.2, 0);


	//--------------------------------
	//円内
	let objInnerC = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	Obj_SetRenderPriorityI(objInnerC, priEffectMax + 1);
	ObjPrim_SetTexture(objInnerC, renderTexture);
	ObjPrim_SetVertexCount(objInnerC, 6 * circleVertexCount * innerCircleCount);

	//円外〜エフェクト枠
	let objOuterC = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	Obj_SetRenderPriorityI(objOuterC, priEffectMax + 1);
	ObjPrim_SetTexture(objOuterC, renderTexture); //テクスチャを設定
	ObjPrim_SetVertexCount(objOuterC, 3 * circleVertexCount);

	//エフェクト枠外オブジェクト
	let objOuterE = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
	Obj_SetRenderPriorityI(objOuterE, priEffectMax + 1);
	ObjPrim_SetTexture(objOuterE, renderTexture); //テクスチャを設定


	//ボスのライフが0になるまでエフェクトをかける。
	let objEnemy = GetEnemyBossObjectID[0];
	while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)
	{
		//エフェクト半径
		effectRadius = baseEffectRadius + outerFluct * sin(frame*4);

		let enemyX = ObjMove_GetX(objEnemy); //敵座標X
		let enemyY = ObjMove_GetY(objEnemy); //敵座標Y
		let circleLeft = enemyX - effectRadius + frameLeft; //エフェクト円の左端
		let circleRight = enemyX + effectRadius + frameLeft; //エフェクト円の右端
		let circleTop = enemyY - effectRadius + frameTop; //エフェクト円の上端
		let circleBottom = enemyY + effectRadius + frameTop; //エフェクト円の下端

		//--------------------------------
		//優先度20〜28(背景)をエフェクト用のテクスチャに描画
		RenderToTextureA1(renderTexture, priEffectMin, priEffectMax, true);

		//--------------------------------
		//影
		ObjRender_SetPosition(objShadow, enemyX, enemyY, 0);

		//--------------------------------
		//円内
		//エフェクト内円を描画
		//ゆらいでいる部分
		ObjRender_SetPosition(objInnerC, -frameLeft, -frameTop, 0);
		ascent(let iPosI in 0 .. circleVertexCount) 
		{
			let xyOldRadius = 0;
			ascent(let iCircle in 0 .. innerCircleCount) 
			{
				let vertexIndex = (iPosI * innerCircleCount + iCircle) * 6;
				let angle1 =  iPosI * (360 / circleVertexCount);
				let angle2 =  (iPosI + 1) * (360 / circleVertexCount);

				//テクスチャのUV座標
				let uvRadius1 = iCircle * effectRadius / innerCircleCount;
				let uvRadius2 = (iCircle + 1) * effectRadius / innerCircleCount;

				//テクスチャのUV座標と描画先のXY座標を変化させることでゆらぎを表現する
				let xyRadius1t = iCircle * effectRadius / innerCircleCount;
				let xyRadius2t = (iCircle + 1) * effectRadius / innerCircleCount;
				let xyRadius1 = xyOldRadius;
				let xyBias = (xyRadius2t - xyRadius1t) / 2 + (xyRadius2t - xyRadius1t) * sin(frame*16 + (iCircle * 360 / innerCircleCount)) / 4;
				let xyRadius2 = xyRadius2t + xyBias / ((innerCircleCount - iCircle + 1) / 2);

				xyOldRadius = xyRadius2;
				if(iCircle == innerCircleCount - 1)
				{
					xyRadius2 = uvRadius2;
				}

				//上記の頂点座標を設定
				let leftBias = enemyX + frameLeft;
				let topBias = enemyY + frameTop;
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex  , leftBias + xyRadius1 * cos(angle1), topBias + xyRadius1 * sin(angle1), 0);
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+1, leftBias + xyRadius2 * cos(angle1), topBias + xyRadius2 * sin(angle1), 0);
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+2, leftBias + xyRadius1 * cos(angle2), topBias + xyRadius1 * sin(angle2), 0);
			
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+3, leftBias + xyRadius1 * cos(angle2), topBias + xyRadius1 * sin(angle2), 0);
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+4, leftBias + xyRadius2 * cos(angle1), topBias + xyRadius2 * sin(angle1), 0);
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+5, leftBias + xyRadius2 * cos(angle2), topBias + xyRadius2 * sin(angle2), 0);

				ObjPrim_SetVertexUVT(objInnerC, vertexIndex  , leftBias + uvRadius1 * cos(angle1), topBias + uvRadius1 * sin(angle1));
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+1, leftBias + uvRadius2 * cos(angle1), topBias + uvRadius2 * sin(angle1));
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+2, leftBias + uvRadius1 * cos(angle2), topBias + uvRadius1 * sin(angle2));
			
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+3, leftBias + uvRadius1 * cos(angle2), topBias + uvRadius1 * sin(angle2));
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+4, leftBias + uvRadius2 * cos(angle1), topBias + uvRadius2 * sin(angle1));
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+5, leftBias + uvRadius2 * cos(angle2), topBias + uvRadius2 * sin(angle2));

			}
		}


		//--------------------------------
		//円外〜エフェクト枠
		//揺らいでいる円の外側から矩形までを埋める
		ObjRender_SetPosition(objOuterC, -frameLeft, -frameTop, 0);
		ascent(let iPosO in 0 .. circleVertexCount) 
		{
			let angle1 = iPosO * (360 / circleVertexCount);
			let angle2 = (iPosO + 1) * (360 / circleVertexCount);
			let rectX = 0;
			let rectY = 0;
			if(angle1 >= 0 && angle1 < 90)
			{
				rectX = circleRight;
				rectY = circleBottom;
			}
			else if(angle1 >= 90 && angle1 < 180)
			{
				rectX = circleLeft;
				rectY = circleBottom;
			}
			else if(angle1 >= 180 && angle1 < 270)
			{
				rectX = circleLeft;
				rectY = circleTop;
			}
			else if(angle1 >= 270 && angle1 < 360)
			{
				rectX = circleRight;
				rectY = circleTop;
			}
			let vertexIndex = iPosO * 3;
			ObjPrim_SetVertexPosition(objOuterC, vertexIndex, enemyX + effectRadius * cos(angle1) + frameLeft, enemyY + effectRadius * sin(angle1) + frameTop, 0);
			ObjPrim_SetVertexPosition(objOuterC, vertexIndex+1, rectX, rectY, 0);
			ObjPrim_SetVertexPosition(objOuterC, vertexIndex+2, enemyX + effectRadius * cos(angle2) + frameLeft, enemyY + effectRadius * sin(angle2) + frameTop, 0);

			ObjPrim_SetVertexUVT(objOuterC, vertexIndex, enemyX + effectRadius * cos(angle1) + frameLeft, enemyY + effectRadius * sin(angle1) + frameTop);
			ObjPrim_SetVertexUVT(objOuterC, vertexIndex+1, rectX, rectY);
			ObjPrim_SetVertexUVT(objOuterC, vertexIndex+2, enemyX + effectRadius * cos(angle2) + frameLeft, enemyY + effectRadius * sin(angle2) + frameTop);
			
		}
		

		//--------------------------------
		//エフェクト枠外
		//エフェクト枠外の背景を描画する
		ObjSpriteList2D_ClearVertexCount(objOuterE);
		ObjRender_SetPosition(objOuterE, -frameLeft, -frameTop, 0);
		ObjSpriteList2D_SetSourceRect(objOuterE, frameLeft, frameTop, frameRight, circleTop + 1);
		ObjSpriteList2D_SetDestRect(objOuterE, frameLeft, frameTop, frameRight, circleTop + 1);
		ObjSpriteList2D_AddVertex(objOuterE);

		ObjSpriteList2D_SetSourceRect(objOuterE, frameLeft, circleTop, circleLeft + 1, circleBottom);
		ObjSpriteList2D_SetDestRect(objOuterE, frameLeft, circleTop, circleLeft + 1, circleBottom);
		ObjSpriteList2D_AddVertex(objOuterE);

		ObjSpriteList2D_SetSourceRect(objOuterE, circleRight, circleTop, frameRight, circleBottom);
		ObjSpriteList2D_SetDestRect(objOuterE, circleRight, circleTop, frameRight, circleBottom);
		ObjSpriteList2D_AddVertex(objOuterE);

		ObjSpriteList2D_SetSourceRect(objOuterE, frameLeft, circleBottom, frameRight, frameBottom);
		ObjSpriteList2D_SetDestRect(objOuterE, frameLeft, circleBottom, frameRight, frameBottom);
		ObjSpriteList2D_AddVertex(objOuterE);

		frame++;
		yield;
	}

	//エフェクト用オブジェクト削除
	Obj_Delete(objInnerC);
	Obj_Delete(objOuterC);
	Obj_Delete(objOuterE);
	Obj_Delete(objShadow);
	ClearInvalidRenderPriority();
}