let point = 0;
let Remi = false;
let mc = 0;
let m_time = 0;
task maple(type){
	
	if(type==2){
		PlaySound("Charge2",95,0);
		//Charge02(objBoss,3,60,255,0,255);
		Bright2(objBoss,60);
		ascent(i in 0..25){
		loop(i%2+1){
		etama(250+rand(0,50),8.5,1);
		}
		wait(1);
		}
		Charge02(objBoss,4,40,255,0,255);
	}
	if(type==1){
		PlaySound("Charge1",95,0);
		//TCharge01(objBoss,3,90,192,0,64);
		Bright2(objBoss,120);
		ascent(i in 0..35){
		loop(2){
		etama(180+i*1+rand(0,100),8,1);
		}
		wait(2);
		}
	}
	if(type==3){
		PlaySound("Charge3",95,0);
		//TCharge01(objBoss,3,90,192,0,64);
		Bright2(objBoss,120);
		ascent(i in 0..35){
		loop(2){
		etama(180+i*1+rand(0,100),8,1);
		}
		wait(2);
		}
	}
	
	}

task etama(r,a,type){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/eff2.png";
	let dir = rand(0,359);
	let angle = rand(0,359);
	let size = 2+r/150;
	let ra = r;
	let c = 0;
	let cp = rand(-7,7);
	let alpha = 0;
	let count = 50;
	let alphaplus = 255/ra;
	if(cp>0){cp=1;}
	else{cp=-1;}
	ObjPrim_SetTexture(obj,img);
	if(type==1){ObjSprite2D_SetSourceRect(obj,32,226,64,254);}
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetAlpha(obj,0);
	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*count*cp);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetAlpha(obj,alpha*5);
	if(r>ra/2){alpha += alphaplus+1;}
	else{
	alpha -= alphaplus;
	if(alpha<=0){Obj_Delete(obj);}
	}
	size -= 0.06;
	r -= a+c;
	c -= 0.1;
	count -= 0.2;
	yield;
	}
	Obj_Delete(obj);
}

task smaple(type,angle,sig,angular,num,time){ // A bunch of effects xD
	let start = rand(0,0);
		Bright(objBoss,60);
		PlaySound("Charge2",90,0);
		DCharge(angular,num,angle,sig,time,type); // Charge effect like DDC
		Bright(objBoss,60);
		TCharge02(objBoss,4,60,255,0,255);
	}


task MapleExplode(time,num,min,max){ // task for explode maples
	let px = GetEnemyX;
	let py = GetEnemyY;
	ascent(i in 0..time){
	loop(num){
	Explode(GetEnemyX,GetEnemyY,rand(min,max),rand(0,359),rand(1,3));
	}
	wait(i%2);
	}
	}
	
	task Explode(px,py,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 = 255/(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 && spd>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;
	}
	Obj_Delete(obj);
	}
	
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)
	if(GetCommonData("Effect",2)!=0){
	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.09,1);
		yield;
		}
		Obj_Delete(obj);
	}
	task ManageAlpha{
		descent(i in 0..20){
		if(!Obj_IsDeleted(boss)){
		ObjRender_SetColor(obj,i*6+60*sin(mc+0),i*6+60*sin(mc+120),i*6+60*sin(mc+240));
		yield;
		}
		}
		Obj_Delete(obj);
	}
	}
	}
	}

task manageSprite(ang){ // Manage movement sprite
		let f = 0;
		let mx = 0;
		if(ang==180){mx = 256;}
		let px = 128;
		idle = false;
		while(f<=24 && idle == false  && atk == false){
		if(f<12){
		SetImageAndTail(objBoss, px*0+mx, 256, px*1+mx, 384,ang);
		}
		if(f>=12 && f<24){
		SetImageAndTail(objBoss, px*1+mx, 256, px*2+mx, 384,ang);
		}
		f+=1;
		yield;
		}
		while(ObjMove_GetSpeed(objBoss)>1){
		SetImageAndTail(objBoss, px*1+mx, 256, px*2+mx, 384,ang);
		yield;
		}
		while(f>=0 && idle == false  && atk == false){
		if(f<12){
		SetImageAndTail(objBoss, px*0+mx, 256, px*1+mx, 384,ang);
		}
		if(f>=12 && f<24){
		SetImageAndTail(objBoss, px*1+mx, 256, px*2+mx, 384,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) && !Obj_IsDeleted(obj)){
	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,0,192+32*sin(spin+180),192+32*sin(spin));
	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
	let difficulty = GetCommonData("Effect",0);
	CreateCommonDataArea("SpellHistory");
	LoadCommonDataAreaA1("SpellHistory");
	let SpellDAttempt = text~GetPlayerID~"Attempt";
	let SpellDGet = text~GetPlayerID~"Get";
	let SpellVAttempt = GetAreaCommonData("SpellHistory", SpellDAttempt, 0);
	let SpellVGet = GetAreaCommonData("SpellHistory", SpellDGet, 0);
	if(!IsReplay){SpellVAttempt++;}
	SetAreaCommonData("SpellHistory", SpellDAttempt, SpellVAttempt);
	SaveCommonDataAreaA1("SpellHistory"); // I still don't understand this thing.
	EffText;
	SpellAttack;
	Value(330,"Get");
	Value(355,"Attempt");
	HistoryText;
	task Value(px,type){
		let objText = ObjText_Create();
		let alpha = 0;
		let c = 0;
		ObjText_SetFontSize(objText, 10);
		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,px,43,0);
			if(GetCommonData("IsSpell",false)==true){Stable;}
			while(GetCommonData("IsSpell",false)==true && !Obj_IsDeleted(objBoss)){
			if(c>150){
			if(GetPlayerY>100 && alpha<255){alpha+=10;}
			if(GetPlayerY<=100 && alpha>100){alpha-=10;}
			}
			if(type=="Attempt"){
			ObjText_SetText(objText,IntToString(GetAreaCommonData("SpellHistory", SpellDAttempt,SpellVAttempt)));
			}
			if(type=="Get"){
			let s = IntToString(GetAreaCommonData("SpellHistory", SpellDGet, SpellVGet));
			ObjText_SetText(objText,IntToString(GetAreaCommonData("SpellHistory", SpellDGet, SpellVGet)));
			}
			ObjRender_SetAlpha(objText,alpha);
			c++;
			yield;
			}
					task Stable{
					while(!Obj_IsDeleted(objBoss)){yield;}
						Obj_Delete(objText);
						if(type=="Get"){
						if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT) +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0 && !IsReplay){
						SpellVGet++;
						}
						SetAreaCommonData("SpellHistory", SpellDGet, SpellVGet);
						SaveCommonDataAreaA1("SpellHistory");
						}
					}
		}
		
		task HistoryText{
		let objText = ObjText_Create();
		let alpha = 0;
		let c = 0;
		ObjText_SetText(objText,"History   /");
		ObjText_SetFontSize(objText, 10);
		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,275,43,0);
			while(GetCommonData("IsSpell",false)==true && !Obj_IsDeleted(objText) && !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);
		}
	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,255);
	ObjText_SetFontColorBottom(objTxt,255,128,255);
	ObjText_SetFontBorderType(objTxt,BORDER_SHADOW);
	ObjText_SetFontBorderColor(objTxt,255,0,128);
	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,0);
			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/Cutin.png";
	LoadTexture(path);
	ObjPrim_SetTexture(cut,path);
	ObjSprite2D_SetSourceRect(cut,0,0,517,867);
	ObjRender_SetScaleXYZ(cut,0.5,0.5,1.1);
  	ObjSprite2D_SetDestCenter(cut);
	ObjRender_SetPosition(cut,416,120,0);
	//Obj_SetRenderPriority(cut,0.3);
	//ObjRender_SetBlendType(cut,BLEND_ADD_ARGB);
	TCut;
	
	task TTail(px,py,alpha,num,t){
		if(GetCommonData("Effect",2)==2){
		wait(t);
		let tail=ObjPrim_Create(OBJ_SPRITE_2D);
		let path=GCSD~"img/Cutin.png";
		let sc = 0.5;
		LoadTexture(path);
		ObjPrim_SetTexture(tail,path);
		ObjSprite2D_SetSourceRect(tail,0,0,517,867);
		ObjSprite2D_SetDestCenter(tail);
		Obj_SetRenderPriority(tail,0.21);
		ObjRender_SetBlendType(tail,BLEND_ADD_ARGB);
		descent(i in 0..15){
		ObjRender_SetPosition(tail,px,py,0);
		ObjRender_SetScaleXYZ(tail,sc,sc,0);
		ObjRender_SetColor(tail,alpha*i/15,0,alpha*i/22.5);
		sc += 0.005;
		yield;
		}
		Obj_Delete(tail);
		}
	}

	task TCut{
		
		let speed=1;
		let alpha = 0;
		let count = 0;
		ObjRender_SetAlpha(cut,alpha);
		ObjRender_SetY(cut,140);
		ObjRender_SetX(cut,384+90);
			descent(i in 10..70){
			if(i%3==0){TTail(ObjRender_GetX(cut),ObjRender_GetY(cut),alpha/2,0,0);}
			ObjRender_SetY(cut,ObjRender_GetY(cut)+i/30);
			ObjRender_SetX(cut,ObjRender_GetX(cut)-i/10);
			ObjRender_SetAlpha(cut,alpha);
			alpha+=4;
			yield;
			}
			descent(i in 0..60){
			if(i%3==0){TTail(ObjRender_GetX(cut),ObjRender_GetY(cut),alpha/2,0,0);}
			ObjRender_SetY(cut,ObjRender_GetY(cut)+10/60);
			ObjRender_SetX(cut,ObjRender_GetX(cut)-10/20);
			ObjRender_SetAlpha(cut,alpha);
			yield;
			}
			ascent(i in 10..70){
			if(i%3==0){TTail(ObjRender_GetX(cut),ObjRender_GetY(cut),alpha/2,0,0);}
			ObjRender_SetY(cut,ObjRender_GetY(cut)+i/30);
			ObjRender_SetX(cut,ObjRender_GetX(cut)-i/10);
			ObjRender_SetAlpha(cut,alpha);
			alpha-= 4;
			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) &&!Obj_IsDeleted(objBoss)){
				ObjRender_SetPosition(obj,x,y,0);
				x+=1.25*way*cos(ang-90);
				y+= 1.25*way*sin(ang-90);
				yield;
				}
				Obj_Delete(obj);
			}
			else {
				while(!Obj_IsDeleted(obj) &&!Obj_IsDeleted(objBoss)){
				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;
				}
				Obj_Delete(obj);
			}
			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 Bright(boss,t){ // task for draw light circle , I can't describe it, so try it yourself
	if(GetCommonData("Effect",2)!=0){
	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,7,7,0);
	Obj_SetRenderPriorityI(obj,25);
	if(t==60){
		ascent(i in 0..45){
		if(Obj_IsDeleted(objBoss)){break;}
		ObjRender_SetColor(obj,i*5*sin(c+90),0,i*5*sin(c+270));
		ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
		c+=set;
		yield;
		}
		descent(i in 0..45){
		if(Obj_IsDeleted(objBoss)){break;}
		ObjRender_SetColor(obj,i*5*sin(c+90),0,i*5*sin(c+270));
		ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
		c+=set;
		yield;
		}
	}
	if(t==120){
		ascent(i in 0..60){
		if(Obj_IsDeleted(objBoss)){break;}
		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){
		if(Obj_IsDeleted(objBoss)){break;}
		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 Bright2(boss,t){ // task for draw light circle , I can't describe it, so try it yourself
	if(GetCommonData("Effect",2)!=0){
	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,7,7,0);
	Obj_SetRenderPriorityI(obj,25);
	if(t==60){
		ascent(i in 0..30){
		if(Obj_IsDeleted(objBoss)){break;}
		ObjRender_SetColor(obj,i*7*sin(c+75),0,i*7*sin(c+75));
		ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
		c+=set;
		yield;
		}
		descent(i in 0..30){
		if(Obj_IsDeleted(objBoss)){break;}
		ObjRender_SetColor(obj,i*7*sin(c+75),0,i*7*sin(c+75));
		ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
		c+=set;
		yield
		}
	}
	if(t==120){
		ascent(i in 0..60){
		if(Obj_IsDeleted(objBoss)){break;}
		ObjRender_SetColor(obj,i*3*sin(c+15),i*sin(c+15),0);
		ObjRender_SetPosition(obj,ObjRender_GetX(boss),ObjRender_GetY(boss),0);
		c+=set;
		yield;
		}
		descent(i in 0..60){
		if(Obj_IsDeleted(objBoss)){break;}
		ObjRender_SetColor(obj,i*3*sin(c+15),i*sin(c+15),0);
		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, "Hata no Kokoro");
	ObjText_SetFontSize(objText, 11);
	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(objBoss)){
	if(GetPlayerY>80 && alpha<255){alpha+=10;}
	if(GetPlayerY<=80 && alpha>100){alpha-=10;}
	ObjRender_SetAlpha(objText,alpha);
	yield;
	}
	Obj_Delete(objText);
	}
	
task DCharge(angular,num,angle,sig,time,type){
	let f = 1;
	if(GetCommonData("Effect",2)==1){
	time = time/2;
	f = 2;
	}
	if(GetCommonData("Effect",2)==0){
	time = time/4;
	f = 4;
	}
	let s = 0;
	if(angular<0){s=-0;}
	ascent(i in 0..time*2){
	let w = i%2*f;
	ascent(j in 0..num){
		if(type==0){
		Doteff(objBoss,angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,"AQUA",90-w);
		Doteff(objBoss,angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,"PURPLE",90-w);
		}
		if(type==1){
		Doteff(objBoss,angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,"RED",90-w);
		Doteff(objBoss,angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,"RED",90-w);
		}
	}
	wait(w);
	}
	}
	
task DCharge2(px,py,angular,num,angle,sig,time,type){
	let f = 1;
	if(GetCommonData("Effect",2)==1){
	time = time/2;
	f = 2;
	}
	if(GetCommonData("Effect",2)==0){
	time = time/4;
	f = 4;
	}
	let s = 0;
	if(angular<0){s=-0;}
	ascent(i in 0..time*2){
	let w = i%2*f;
	ascent(j in 0..num){
		if(type==0){
		Doteff2(px,py,angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,"AQUA",90-w);
		Doteff2(px,py,angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,"PURPLE",90-w);
		}
		if(type==1){
		Doteff2(px,py,angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,"RED",90-w);
		Doteff2(px,py,angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,"RED",90-w);
		}
	}
	wait(w);
	}
	}
	
task Doteff(boss,ang,r,angular,sig,color,t){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/Dot.png";
	let v = 0;
	let t2 = t/2;
	let s = rand(1,1.25);
	let acc = ((r-v*(t2/2)))/(t2*t2);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,32,32);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	if(color=="AQUA"){
	ObjRender_SetColor(obj,32,0,255);
	}
	if(color=="PURPLE"){ObjRender_SetColor(obj,128,0,255);}
	if(color=="RED"){ObjRender_SetColor(obj,255,0,0);}
	if(color=="BLACK"){
	ObjRender_SetBlendType(obj,BLEND_MULTIPLY);
	ObjRender_SetColor(obj,0,0,0);
	ObjRender_SetScaleXYZ(obj,s,s,0);
	}
	Stable;
		loop(t/2){ 
		if(Obj_IsDeleted(objBoss)){break;}
		r -= v;
		v+= acc;
		ang+=acc*angular*5;
		yield;
		}
		loop(t/2){ 
		if(Obj_IsDeleted(objBoss)){break;}
		r -= v;
		v-= acc;
		ang+=acc*angular*5;
		yield;
		}
		descent(i in 0..30){
		if(Obj_IsDeleted(objBoss)){break;}
		ObjRender_SetAlpha(obj,i*8);
		yield;
		}
		Obj_Delete(obj);
		task Stable{
			let ra = rand(-sig,sig)/2;
			let alpha = 0;
			while(!Obj_IsDeleted(obj) && !Obj_IsDeleted(objBoss)){
			ObjRender_SetAlpha(obj,alpha);
			ObjRender_SetScaleXYZ(obj,s,s,0);
			alpha += 255/t;
			ObjRender_SetPosition(obj,ObjMove_GetX(boss)+r*cos(ang+ra),ObjMove_GetY(boss)+r*sin(ang+ra),0);
			yield;
			}
			Obj_Delete(obj);
			}
	}
	
task Doteff2(x,y,ang,r,angular,sig,color,t){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/Dot.png";
	let v = 0;
	let t2 = t/2;
	let acc = ((r-v*(t/2)))/(t2*t2);
	let alpha = 0;
	let s = rand(1,1.25);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,32,32);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	if(color=="AQUA"){ObjRender_SetColor(obj,0,0,255);}
	if(color=="PURPLE"){ObjRender_SetColor(obj,128,0,255);}
	Stable;
		loop(t/2){ 
		if(Obj_IsDeleted(objBoss)){break;}
		r -= v;
		v+= acc;
		ang+=acc*angular*5;
		yield;
		}
		loop(t/2){ 
		if(Obj_IsDeleted(objBoss)){break;}
		r -= v;
		v-= acc;
		ang+=acc*angular*5;
		yield;
		}
		descent(i in 0..30){
		if(Obj_IsDeleted(objBoss)){break;}
		ObjRender_SetAlpha(obj,i*8);
		yield;
		}
		Obj_Delete(obj);
		task Stable{
			let ra = rand(-sig,sig)/2;
			while(!Obj_IsDeleted(obj) && !Obj_IsDeleted(objBoss)){
			ObjRender_SetAlpha(obj,alpha);
			ObjRender_SetScaleXYZ(obj,s,s,0);
			alpha += 255/t;
			ObjRender_SetPosition(obj,x+r*cos(ang+ra),y+r*sin(ang+ra),0);
			yield;
			}
			Obj_Delete(obj);
			}
	}

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){
		if(Obj_IsDeleted(objBoss)){break;}
			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)){break;}
			yield;
			}
		Obj_Delete(obj);
	}
}

function TExpan(px,py,maxv,t,r,g,b){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/charge.png";
	let scale = 0;
	let v = 0;
	let malpha = 255/t;
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,px,py,0);
	ObjRender_SetColor(obj,r,g,b);
	Obj_SetRenderPriorityI(obj,25);
	Expan;
		task Expan{
			descent(i in 0..t){
			if(Obj_IsDeleted(objBoss)){break;}
			ObjRender_SetAlpha(obj,malpha*i);
			v = (i*maxv/2)/(t*t);
			scale += v;
			ObjRender_SetScaleXYZ(obj,scale,scale,0);
			yield;
			}
			Obj_Delete(obj);
		}
	}

function TCharge02(boss,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_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	Obj_SetRenderPriorityI(obj,25);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=frame;
		let alpha=255/l;
		let ra = r/l;
		let ga = g/l;
		let ba = b/l;
		loop(l){
			if(Obj_IsDeleted(objBoss)){break;}
			ObjRender_SetAlpha(obj,alpha);
			ObjRender_SetColor(obj,ra,ga,ba);
			alpha+=255/(l);
			ra += r*1.5/l;
			ga += g*1.5/l;
			ba += b*1.5/l;
			yield;
			}
			Obj_Delete(obj);
		}
	task TShrink{
			let a = size/frame;
			loop(frame){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
			size = size-a;
			if(Obj_IsDeleted(objBoss)){break;}
			yield;
			}
		Obj_Delete(obj);
		
	}
}

function Charge02(boss,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_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	Obj_SetRenderPriorityI(obj,25);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=frame;
		let alpha=255/l;
		let ra = r/l;
		let ga = g/l;
		let ba = b/l;
		loop(l){
			if(Obj_IsDeleted(objBoss)){break;}
			ObjRender_SetAlpha(obj,alpha);
			ObjRender_SetColor(obj,ra,ga,ba);
			alpha+=255/(l);
			ra += r*2/l;
			ga += g*2/l;
			ba += b*2/l;
			yield;
			}
			Obj_Delete(obj);
		}
	task TShrink{
			let a = size/frame;
			loop(frame){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
			size = size-a;
			if(Obj_IsDeleted(objBoss)){break;}
			yield;
			}
		Obj_Delete(obj);
	}
}
	
task effbreak(shot,size,t){ // task for call other functions
		if(!Obj_IsDeleted(shot)){
		fragment(shot,size,1);
			if(GetCommonData("Effect",2)==2){
			spongy(shot,0.1,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){
			if(Obj_IsDeleted(objBoss)){break;}
			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,v,t){ // make bullet slightly grow and fade it's alpha/color
		if(!Obj_IsDeleted(shot) && !Obj_IsDeleted(objBoss)){
		let cloud = ObjShot_GetImageID(shot);
		let obj=ObjPrim_Create(OBJ_SPRITE_2D);
		let img=GCSD~"Shot/ZUNShot.png";
		let s = 1;
		let adc = false;
		let rect = GetShotDataInfoA1(cloud,TARGET_ENEMY,INFO_RECT);
		let dir = ObjMove_GetAngle(shot)+90;
		let d = 0;
		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>=1 && cloud<=41) || (cloud>=58 && cloud<=73) || (cloud>=106 && cloud <=121)
	 || (cloud>=170 && cloud<=185) || (cloud>=233 && cloud<=239)
	 || (cloud>=248 && cloud <=252) || (cloud>=269 && cloud<=283)
	 || (cloud>=300 && cloud<=307) || (cloud>=340 && cloud<=346)
	 || (cloud>=355 && cloud<=362) || (cloud>=371 && cloud<=382)
	 || (cloud>=399 && cloud<=408)){
	 adc = true;
	 ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	 }
		ascent(i in 0..t){
		if(Obj_IsDeleted(objBoss)){break;}
		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 += v;
		yield;
		}
		Obj_Delete(obj);
		}
		}
	