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

task maple(type){ // Choose which type you want to use
	let start = rand(0,0);
	if(type==2){ // Very common type
		Bright(objBoss,60);
		PlaySound("Charge5",95,0);
		TCharge01(objBoss,3,50,255,128,92);
		ascent(i in 0..40){
		etama(i*7.5+rand(0,25),20,i/2,start,1);
		etama(i*7.5+rand(0,25),20,i/2,start,-1);
		wait(i%2);
		}
	}
	if(type==0){ // like the type 2 but change a sound effect
		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){ // for a long concentration
		Bright(objBoss,120);
		PlaySound("Charge1",95,0);
		TCharge01(objBoss,3,110,256,128,92);
		ascent(i in 0..60){
		etama(i*7+rand(0,25),20,i/10,start,1);
		etama(i*7+rand(0,25),20,i/10,start,-1);
		yield;
		}
	}
	if(type==3){ //for a long concentration, change a sound effect
		Bright(objBoss,120);
		PlaySound("Charge3",95,0);
		TCharge01(objBoss,3,110,256,128,92);
		ascent(i in 0..40){
		etama(i*8+rand(25,50),20,i/30,start,1);
		etama(i*8+rand(25,50),20,i/30,start,-1);
		yield;
		}
	}
	}

task etama(r,a,n,start,way){ // task for draw a maple
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/bloom.png";
	let dir = rand(0,359);
	let angle = rand(0,359);
	let size = 0.25+r/600;
	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,64,64);
	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 = (0+alpha);
	ObjRender_SetColor(obj,0,color+alpha*2.5,color+alpha*2.5);
	if(r>ra/2){alpha += alphaplus+1;}
	else{
	alpha -= alphaplus;
	if(alpha<=0){Obj_Delete(obj);}
	}
	size -= 0.01;
	r -= 8+c;
	c += n/300;
	yield;
	}
	Obj_Delete(obj);
}

task MapleExplode{ // task for explode maples
	let px = GetEnemyX;
	let py = GetEnemyY;
	ascent(i in 0..120){
	Explode(GetEnemyX,GetEnemyY,rand(1,7),rand(0,359),rand(1,3));
	}
	}
	
	task Explode(px,py,spd,dir,size){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/eff.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_ADD_ARGB);
	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*1.5;
	r+= spd;
	spd -= 0.02;
	size -= 0.01;
	yield;
	}
	}
	
task SetImageAndTail(obj,r1,r2,r3,r4,angleY){ // Set images rects for the boss, also set the auras
	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){ // task for the aura (rainbow aura)
	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.1,1+i*0.1,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{ // Manage movement sprite
		let f = 0;
		idle = false;
		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>=0 && 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-=3;
		yield;
		}
		idle = true;
	}

task attack(delay,time,type){ // Manage attack pose
	let f2 = 0;
	let px = 128;
	let py = 128;
	atk = true;
	idle = false;
		if(type==1){
		loop(6){SetImageAndTail(objBoss, px*4, py*0, px*5, py*1,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*1, px*5, py*2,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*2, px*5, py*3,ang);yield;}
		loop(6+delay-24){SetImageAndTail(objBoss, px*4, py*3, px*5, py*4,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*5,py*0, px*6, py*1,ang);yield;}
		loop(6+time-12){SetImageAndTail(objBoss, px*5, py*1, px*6, py*2,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*3, px*5, py*4,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*2, px*5, py*3,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*1, px*5, py*2,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*0, px*5, py*1,ang);yield;}
		atk = false;
		idle = true;
		}
		if(type==2){
		loop(6){SetImageAndTail(objBoss, px*4, py*0, px*5, py*1,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*1, px*5, py*2,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*2, px*5, py*3,ang);yield;}
		loop(6+delay-24){SetImageAndTail(objBoss, px*4, py*3, px*5, py*4,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*5,py*2, px*6, py*3,ang);yield;}
		loop(6+time-12){SetImageAndTail(objBoss, px*5, py*3, px*6, py*4,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*3, px*5, py*4,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*2, px*5, py*3,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*1, px*5, py*2,ang);yield;}
		loop(6){SetImageAndTail(objBoss, px*4, py*0, px*5, py*1,ang);yield;}
		}
		atk = false;
		idle = true;
	}
	
task magiccircle(boss,size,type){ // draw magic circle
	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_RGB);
	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){ // cut-in function , a lot of things run here
	EffText;
	SpellAttack;
	task EffText{
	let scale=3.9;
	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,255,255,128);
	ObjText_SetFontColorBottom(objTxt,255,128,128);
	ObjText_SetFontBorderType(objTxt,BORDER_SHADOW);
	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,-295+i*10,300,0);
		scale -= 0.1;
		yield;
		}
		loop(57){
		ObjRender_SetPosition(objTxt,-5,300+py,0);
		py += acc;
		acc += 0.1;
		yield;
		}
		ObjRender_SetPosition(objTxt,0,-240,0);
		loop(40){
		ObjRender_SetPosition(objTxt,-5,-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.95,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)+200,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{ // task for draw spell attack images
	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){ // task for draw light circle , I can't describe it, so try it yourself
	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,0,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,0,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,0,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,0,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{ // Draw everything you have to draw, right now I move this function to system instead
	DrawName;
	}
	
task DrawName{
	let objText = ObjText_Create();
	let alpha = 255;
	ObjText_SetText(objText, "Konpaku Youmu");
	ObjText_SetFontSize(objText, 12);
	ObjText_SetFontColorTop(objText, 255, 255, 255);
	ObjText_SetFontColorBottom(objText, 0, 255, 128);
	ObjText_SetFontBorderType(objText, BORDER_SHADOW);
	ObjText_SetFontBorderColor(objText,0, 128, 128);
	ObjText_SetFontBorderWidth(objText, 2);
	ObjRender_SetPosition(objText,0,12,0);
	while(!Obj_IsDeleted(objText)){
	if(GetPlayerY>80 && alpha<255){alpha+=10;}
	if(GetPlayerY<=80 && alpha>100){alpha-=10;}
	ObjRender_SetAlpha(objText,alpha);
	yield;
	}
	}
	
task DrawScore{ // Draw score text
	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,43,0);
			while(!Obj_IsDeleted(objBoss)){
			if(c>150){
			if(GetPlayerY>100 && alpha<255){alpha+=10;}
			if(GetPlayerY<=100 && alpha>100){alpha-=10;}
			}
			if(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_PLAYER_SHOOTDOWN_COUNT)==0 && ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_PLAYER_SPELL_COUNT)==0 ){
			ObjText_SetText(objText,IntToString(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_SPELL_SCORE)));
			}
			else{
			ObjText_SetText(objText,IntToString(0));
			}
			ObjRender_SetAlpha(objText,alpha);
			c++;
			yield;
			}
			Obj_Delete(objText);
		}
		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,43,0);
			while(!Obj_IsDeleted(objBoss)){
			if(c>150){
			if(GetPlayerY>100 && alpha<255){alpha+=10;}
			if(GetPlayerY<=100 && alpha>100){alpha-=10;}
			}
			ObjRender_SetAlpha(objText,alpha);
			c++;
			yield;
			}
			Obj_Delete(objText);
		}
	}
	



function TCharge01(boss,size,frame,r,g,b){ // Draw a charge circle that has an acceleration on shrinking
	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,0,128+64*sin(i*set+240),64+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){ //Draw a charge circle that has no acceleration on shrinking
	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){ // task for call other functions
		if(!Obj_IsDeleted(shot)){
		fragment(shot,size,1);
		spongy(shot,t);
		}
	}
	
task fragment(shot,size,num){ // Bullet clear effect from UFO,TD
		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){ // make bullet slightly grow and fade it's alpha/color
		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 TMotionBlur(time) // from Sample Script
{
	//レンダリングターゲットに使用するテクスチャ
	let renderTexture = [GetReservedRenderTargetName(0), GetReservedRenderTargetName(1)];

	//モーションブラーでの描画でまかなえるため、
	//優先度20〜79の通常描画を無効にする。
	SetInvalidRenderPriorityA1(20, 79);

	//現フレームを描画するオブジェクト
	let objCurentFrame = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objCurentFrame, 80);//優先度80に描画する
	ObjRender_SetPermitCamera(objCurentFrame, false);

	//過去フレーム用オブジェクト
	let objOldFrame = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objOldFrame, 0);
	ObjRender_SetPermitCamera(objOldFrame, false);
	ObjRender_SetAlpha(objOldFrame, 214);//α値はモーションブラーの強さになります
	Obj_SetVisible(objOldFrame, false);//過去フレーム用なので通常の描画がされないようにします。

	//ボスのライフが0になるまでモーションブラーをかける。
	let frame = 0;
	loop(time)
	{
		let currentFrameTexture = renderTexture[frame % 2];

		//優先度20〜79(STGフレーム全体)をテクスチャに描画する。
		RenderToTextureA1(currentFrameTexture, 20, 79, true);

		if(frame >= 1) 
		{
			//前フレームを現フレームに半透明描画
			//0フレーム目は前フレームがないためこの処理は行わない。
			let oldFrameTexture = renderTexture[(frame - 1) % 2];
			ObjPrim_SetTexture(objOldFrame, oldFrameTexture);
			ObjSprite2D_SetSourceRect(objOldFrame, 32, 16, 416, 464);
			ObjSprite2D_SetDestRect(objOldFrame, 32, 16, 416, 464);
			RenderToTextureB1(currentFrameTexture, objOldFrame, false);
		}

		//現フレーム描画用オブジェクトを設定
		ObjPrim_SetTexture(objCurentFrame, currentFrameTexture);
		ObjSprite2D_SetSourceRect(objCurentFrame, 32, 16, 416, 464);
		ObjSprite2D_SetDestRect(objCurentFrame, 32, 16, 416, 464);

		frame++;
		yield;
	}

	//モーションブラー用オブジェクト削除
	Obj_Delete(objCurentFrame);
	Obj_Delete(objOldFrame);
	ClearInvalidRenderPriority();
}