#include"./system/Load_AllTexture.dnh"

task Cutin(type,x,y,sca,texture,rect3,rect4,r,g,b){
	let sid			= ObjSound_Create;
	let cid			= ObjPrim_Create(OBJ_SPRITE_2D);
	let SE			= GetAreaCommonData("Option","SE_Volume",100);
	let alpha		= 0;
	let delete		= false;
	let cc			= 0;
	let movea		= 0;
	let move1		= 0;
	let moveb		= 0;
	let move2		= 0;
	let movep		= 0;
	let scax		= 1;
	let scay		= 1;

	ObjPrim_SetTexture(cid,texture);
	Obj_SetRenderPriorityI(cid,32);
	ObjRender_SetBlendType(cid,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(cid,sca[0],sca[1],0);
	ObjSprite2D_SetSourceRect(cid,0,0,rect3,rect4);
	ObjSprite2D_SetDestCenter(cid);
	
	ObjSound_Load(sid,csd~"../../se/spellcard.wav");
	ObjSound_SetVolumeRate(sid,SE);
	ObjSound_SetLoopEnable(sid,false);
	ObjSound_Play(sid);
	
	CutinShadow(type,x,y,sca,texture,rect3,rect4,10,r,g,b);
	CutinShadow(type,x,y,sca,texture,rect3,rect4,20,r,g,b);
	
	while(!Obj_IsDeleted(enm)){
		cc++;
		alternative(type)
		case("KOUMA"){ObjRender_SetPosition(cid,(CenX-move1)+x,(CenY-230)+y,0);}
		case("YOUMU"){ObjRender_SetPosition(cid,(CenX-230)+x,(CenY-330+move1)+y,0);}
		case("HUJIN"){ObjRender_SetPosition(cid,(CenX-move1)+x,(CenY-130-move2)+y,0);}
		case("TIREI"){ObjRender_SetPosition(cid,(CenX-move1)+x,(CenY-310+move2/2)+y,0);}
		
		//峠杺嫿晽偺張棟
		if(type=="KOUMA"){
			if(move1<230){movea+=2;}
			move1=230.1*sin(movea);
			if(cc==100){delete=true;}
			if(delete==true){
				scax+=0.05;
				scay+=0.05;
				ObjRender_SetScaleXYZ(cid,scax,scay,1);
			}
		}
		//梔乆柌晽偺張棟
		if(type=="YOUMU"){
			move1+=1.5;
			if(cc==100){delete=true;}
		}
		//晽恄榐晽偺張棟
		if(type=="HUJIN"){
			if(move1<230){movea+=3;}
			move1=230.1*sin(movea);
			if(move1>=230){moveb+=0.1;}
			if(cc>90&&move2<200){moveb+=movep;movep+=0.05;}
			move2=200.1*sin(moveb);
			if(cc==100){delete=true;}
		}
		//抧楈揳晽偺張棟
		if(type=="TIREI"){
			if(move1<230&&move2<200&&cc<100){
				if(move1<200){movea+=3;}
				move1=200.1*sin(movea);
				if(move2<200){moveb+=3;}
				move2=200.1*sin(moveb);
			}
			if(move1>=200&&cc<100){move1+=0.5;}
			if(move2>=200&&cc<100){move2+=0.5;}
			if(move1>=200&&cc>100){move1+=10;}
			if(move2>=200&&cc>100){move2+=10;}
			if(cc==100){delete=true;}
		}
		if(alpha<255&&delete==false){
			alternative(type)
			case("KOUMA"){alpha+=15;}
			case("YOUMU"){alpha+=15;}
			case("HUJIN"){alpha+=15;}
			case("TIREI"){alpha+=15;}
		}
		if(alpha>0&&delete==true){
			alternative(type)
			case("KOUMA"){alpha-=10;}
			case("YOUMU"){alpha-=10;}
			case("HUJIN"){alpha-=10;}
			case("TIREI"){alpha-=10;}
		}
		ObjRender_SetAlpha(cid,alpha);
		if(alpha<=0 && delete==true){
			break;
		}
		yield;
	}
	Obj_Delete(sid);
	Obj_Delete(cid);
}

task CutinShadow(type,x,y,sca,texture,rect3,rect4,delay,r,g,b){
	let cid			= ObjPrim_Create(OBJ_SPRITE_2D);
	let alpha		= 0;
	let delete		= false;
	let cc			= 0;
	let movea		= 0;
	let move1		= 0;
	let moveb		= 0;
	let move2		= 0;
	let scax		= 2;
	let scay		= 2;

	ObjPrim_SetTexture(cid,texture);
	Obj_SetRenderPriorityI(cid,31);
	ObjRender_SetBlendType(cid,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(cid,sca[0],sca[1],0);
	ObjSprite2D_SetSourceRect(cid,1,1,rect3,rect4);
	ObjSprite2D_SetDestCenter(cid);
	ObjRender_SetColor(cid,r,g,b);
	ObjRender_SetAlpha(cid,0);
	
	loop(delay){yield;}
	
	while(!Obj_IsDeleted(enm)){
		cc++;
		alternative(type)
		case("KOUMA"){ObjRender_SetPosition(cid,(CenX-move1)+x,(CenY-230)+y,0);}
		case("YOUMU"){ObjRender_SetPosition(cid,(CenX-230)+x,(CenY-330+move1)+y,0);}
		case("HUJIN"){ObjRender_SetPosition(cid,(CenX-move1)+x,(CenY-130-move2)+y,0);}
		case("TIREI"){ObjRender_SetPosition(cid,(CenX-move1)+x,(CenY-310+move2/2)+y,0);}
		
		//峠杺嫿晽偺張棟
		if(type=="KOUMA"){
			if(move1<230){movea+=1.5;}
			move1=230.1*sin(movea);
			if(cc==100){delete=true;}
			if(delete==true){
				scax+=0.05;
				scay+=0.05;
				ObjRender_SetScaleXYZ(cid,scax,scay,1);
			}
		}
		//梔乆柌晽偺張棟
		if(type=="YOUMU"){
			move1+=1.5;
			if(cc==100){delete=true;}
		}
		//晽恄榐晽偺張棟
		if(type=="HUJIN"){
			if(move1<230){movea+=3;}
			move1=230.1*sin(movea);
			if(move1>=230){moveb+=0.1;}
			if(cc>90&&move2<200){moveb+=1.5;}
			move2=200.1*sin(moveb);
			if(cc==100){delete=true;}
		}
		//抧楈揳晽偺張棟
		if(type=="TIREI"){
			if(move1<230&&move2<200&&cc<100){
				if(move1<200){movea+=3;}
				move1=200.1*sin(movea);
				if(move2<200){moveb+=3;}
				move2=200.1*sin(moveb);
			}
			if(move1>=200&&cc<100){move1+=0.5;}
			if(move2>=200&&cc<100){move2+=0.5;}
			if(move1>=200&&cc>100){move1+=10;}
			if(move2>=200&&cc>100){move2+=10;}
			if(cc==100){delete=true;}
		}
		if(alpha<128&&delete==false){
			alternative(type)
			case("KOUMA"){alpha+=15;}
			case("YOUMU"){alpha+=15;}
			case("HUJIN"){alpha+=15;}
			case("TIREI"){alpha+=15;}
		}
		if(alpha>0&&delete==true){
			alternative(type)
			case("KOUMA"){alpha-=10;}
			case("YOUMU"){alpha-=10;}
			case("HUJIN"){alpha-=10;}
			case("TIREI"){alpha-=10;}
		}
		ObjRender_SetAlpha(cid,alpha);
		if(alpha<=0 && delete==true){
			break;
		}
		yield;
	}
	Obj_Delete(cid);
}

task CutinSP2(char_sn,getspell,playspell){
	let cid1		= ObjText_Create;
	let cid2		= ObjPrim_Create(OBJ_SPRITE_2D);
	let alpha		= 0;
	let movea		= 0;
	let move1		= 0;
	let moveb		= 0;
	let move2		= 0;
	let movec		= 0;
	let move3		= 0;
	let sca1		= 2;
	let scaA		= 2;
	let sca2		= 2;
	let scaB		= 2;
	let cc			= 0;
	let mm			= 0;

	ObjText_SetText(cid1,char_sn);
	ObjText_SetFontType(cid1,"俵俽 僑僔僢僋");
	ObjText_SetFontSize(cid1,15);
	ObjText_SetHorizontalAlignment(cid1,ALIGNMENT_RIGHT);
	ObjText_SetMaxWidth(cid1,512);
	ObjText_SetFontBorderWidth(cid1,1);
	ObjText_SetFontBorderType(cid1,BORDER_FULL);
	ObjText_SetFontBorderColor(cid1,10,10,10);
	Obj_SetRenderPriorityI(cid1,81);

	ObjPrim_SetTexture(cid2,front_tex[0]);
	Obj_SetRenderPriorityI(cid2,80);
	ObjRender_SetBlendType(cid2,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(cid2,1,1,1);
	ObjSprite2D_SetSourceRect(cid2,0,0,256,50);
	ObjSprite2D_SetDestCenter(cid2);
	ObjRender_SetAlpha(cid2,alpha);
	
	Bonus();
	History(getspell,playspell);
	CutinSP4();
	MagicTimer();
	
	while(!Obj_IsDeleted(enm)){
		let EnmX		= ObjMove_GetX(enm);
		let EnmY		= ObjMove_GetY(enm);
		if(ObjRender_GetX(cid2)-80<=GetPlayerX&&ObjRender_GetX(cid2)+150>=GetPlayerX&&
		   ObjRender_GetY(cid2)-50<=GetPlayerY&&ObjRender_GetY(cid2)+50>=GetPlayerY&&move2<=-190){alpha=100;}
		if(ObjRender_GetX(cid2)-80<=EnmX&&ObjRender_GetX(cid2)+150>=EnmX&&
		   ObjRender_GetY(cid2)-50<=EnmY&&ObjRender_GetY(cid2)+50>=EnmY&&move2<=-190){alpha=100;}
		
		if(move1<270){movea+=2;}
		move1=270*sin(movea);
		if(move1>=270){cc++;}
		if(cc>15&&move2>-190){
			moveb+=mm;
			if(mm<5){mm+=0.2;}
		}
		move2=190*sin(moveb+90);
		if(move3<270){movec+=5;}//270
		move3=270*sin(movec);
		
		ObjRender_SetPosition(cid1,(MinX-352)-15+move3,MinY+210+move2,0);
		ObjRender_SetPosition(cid2,MinX+move1,MinY+195+move2,0);
		if(sca1<2){scaA+=2;}
		sca1=2*sin(scaA);
		if(sca2<3){scaB+=4;}
		sca2=3*sin(scaB);
		ObjRender_SetScaleXYZ(cid1,4-sca2,4-sca2,1);
		ObjRender_SetScaleXYZ(cid2,3-sca1,3-sca1,1);
		
		if(alpha<255){alpha+=10;}
		ObjRender_SetAlpha(cid1,alpha);
		ObjRender_SetAlpha(cid2,alpha);
		
		yield;
	}
	Obj_Delete(cid1);
	Obj_Delete(cid2);
}

task Bonus(){
	let spn0		= ObjPrim_Create(OBJ_SPRITE_2D);//Bonus
	let spn			= [ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D)];
	let alpha		= 0;
	let movea		= 0;
	let move1		= 0;
	let moveb		= 0;
	let move2		= 0;
	let cc			= 0;
	let i			= 0;
	let GetScores	= ObjEnemyBossScene_GetInfo(spl,INFO_SPELL_SCORE);
	let rect1		= [10,18,26,34,42,50,58,66,74,82];//90,98
	let rect3		= [17,25,33,41,49,57,65,73,81,89];//97,105
	
	ObjPrim_SetTexture(spn0,front_tex[0]);
	Obj_SetRenderPriorityI(spn0,82);
	ObjRender_SetBlendType(spn0,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(spn0,1,1,1);
	ObjSprite2D_SetSourceRect(spn0,10,80,41,89);
	ObjSprite2D_SetDestCenter(spn0);
	ObjRender_SetAlpha(spn0,alpha);

	loop(8){
		ObjPrim_SetTexture(spn[i],front_tex[0]);
		Obj_SetRenderPriorityI(spn[i],20);
		ObjRender_SetBlendType(spn[i],BLEND_ALPHA);
		ObjRender_SetScaleXYZ(spn[i],1,1,1);
		ObjSprite2D_SetSourceRect(spn[i],rect1[0],104,rect3[0],113);
		ObjSprite2D_SetDestCenter(spn[i]);
		ObjRender_SetAlpha(spn[i],alpha);
		i++;
	}
	i=0;

	while(!Obj_IsDeleted(enm)){
		let EnmX		= ObjMove_GetX(enm);
		let EnmY		= ObjMove_GetY(enm);
		
		if(ObjRender_GetX(spn[4])-50<=GetPlayerX&&ObjRender_GetX(spn[4])+50>=GetPlayerX&&
		   ObjRender_GetY(spn[4])-50<=GetPlayerY&&ObjRender_GetY(spn[4])+50>=GetPlayerY){alpha=100;}
		if(ObjRender_GetX(spn[4])-50<=EnmX&&ObjRender_GetX(spn[4])+50>=EnmX&&
		   ObjRender_GetY(spn[4])-50<=EnmY&&ObjRender_GetY(spn[4])+50>=EnmY){alpha=100;}
		
		GetScores	= ObjEnemyBossScene_GetInfo(spl,INFO_SPELL_SCORE);
		
		let score1  = truncate(GetScores%10);
		let score2  = truncate((GetScores%100)/10);
		let score3  = truncate((GetScores%1000)/100);
		let score4  = truncate((GetScores%10000)/1000);
		let score5  = truncate((GetScores%100000)/10000);
		let score6  = truncate((GetScores%1000000)/100000);
		let score7  = truncate((GetScores%10000000)/1000000);
		let score8  = truncate((GetScores%100000000)/10000000);
		
		let gx = ObjRender_GetX(spn[7]);
		let gy = ObjRender_GetY(spn[7]);
		
		cc++;
		ObjRender_SetPosition(spn0,MinX+228,MinY+43,0);
		ObjRender_SetPosition(spn[7],ObjRender_GetX(spn0)+30,ObjRender_GetY(spn0),0);
		ObjRender_SetPosition(spn[6],gx+7,gy,0);
		ObjRender_SetPosition(spn[5],gx+14,gy,0);
		ObjRender_SetPosition(spn[4],ObjRender_GetX(spn0)+30+21,ObjRender_GetY(spn0),0);
		ObjRender_SetPosition(spn[3],gx+28,gy,0);
		ObjRender_SetPosition(spn[2],gx+35,gy,0);
		ObjRender_SetPosition(spn[1],gx+42,gy,0);
		ObjRender_SetPosition(spn[0],gx+49,gy,0);
		
		if(cc>120&&alpha<255){alpha+=15}
		ObjRender_SetAlpha(spn0,alpha);
		loop(8){
			ObjRender_SetAlpha(spn[i],alpha);
			i++;
		}i=0;
		
		
		if(ObjEnemyBossScene_GetInfo(spl,INFO_PLAYER_SPELL_COUNT)==0&&
			ObjEnemyBossScene_GetInfo(spl,INFO_PLAYER_SHOOTDOWN_COUNT)==0){
			ObjSprite2D_SetSourceRect(spn[0],rect1[score1],104,rect3[score1],113);
			ObjSprite2D_SetSourceRect(spn[1],rect1[score2],104,rect3[score2],113);
			ObjSprite2D_SetSourceRect(spn[2],rect1[score3],104,rect3[score3],113);
			ObjSprite2D_SetSourceRect(spn[3],rect1[score4],104,rect3[score4],113);
			ObjSprite2D_SetSourceRect(spn[4],rect1[score5],104,rect3[score5],113);
			ObjSprite2D_SetSourceRect(spn[5],rect1[score6],104,rect3[score6],113);
			ObjSprite2D_SetSourceRect(spn[6],rect1[score7],104,rect3[score7],113);
			ObjSprite2D_SetSourceRect(spn[7],rect1[score8],104,rect3[score8],113);
		}
		
		if(ObjEnemyBossScene_GetInfo(spl,INFO_PLAYER_SPELL_COUNT)>0||
			ObjEnemyBossScene_GetInfo(spl,INFO_PLAYER_SHOOTDOWN_COUNT)>0){
			Obj_Delete(spn[0]);
			Obj_Delete(spn[1]);
			Obj_Delete(spn[2]);
			Obj_Delete(spn[3]);
			Obj_Delete(spn[5]);
			Obj_Delete(spn[6]);
			Obj_Delete(spn[7]);
			ObjSprite2D_SetSourceRect(spn[4],10,92,40,101);
			ObjSprite2D_SetDestCenter(spn[4]);
		}
		
		if(GetScores>=0){
			Obj_SetRenderPriorityI(spn[0],82);
			loop(6){
				Obj_SetRenderPriorityI(spn[1+i],20);
				i++;
			}i=0;
		}
		if(GetScores>=10){
			Obj_SetRenderPriorityI(spn[1],82);
			loop(5){
				Obj_SetRenderPriorityI(spn[2+i],20);
				i++;
			}i=0;
		}
		if(GetScores>=100){
			Obj_SetRenderPriorityI(spn[2],82);
			loop(4){
				Obj_SetRenderPriorityI(spn[3+i],20);
				i++;
			}i=0;
		}
		if(GetScores>=1000){
			Obj_SetRenderPriorityI(spn[3],82);
			loop(3){
				Obj_SetRenderPriorityI(spn[4+i],20);
				i++;
			}i=0;
		}
		if(GetScores>=10000){
			Obj_SetRenderPriorityI(spn[4],82);
			loop(2){
				Obj_SetRenderPriorityI(spn[5+i],20);
				i++;
			}i=0;
		}
		if(GetScores>=100000){
			Obj_SetRenderPriorityI(spn[5],82);
			Obj_SetRenderPriorityI(spn[6],20);
			Obj_SetRenderPriorityI(spn[7],20);
		}
		if(GetScores>=1000000){
			Obj_SetRenderPriorityI(spn[6],82);
			Obj_SetRenderPriorityI(spn[7],20);
		}
		if(GetScores>=10000000){
			Obj_SetRenderPriorityI(spn[7],82);
		}
		
		yield;
	}
	i=0;
	Obj_Delete(spn0);
	Obj_Delete(spn[0]);
	Obj_Delete(spn[1]);
	Obj_Delete(spn[2]);
	Obj_Delete(spn[3]);
	Obj_Delete(spn[4]);
	Obj_Delete(spn[5]);
	Obj_Delete(spn[6]);
	Obj_Delete(spn[7]);
}

task CutinSP4{
	let spn7		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn8		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn9		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn10		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn			= [ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D)];
	let alpha		= 0;
	let mc			= 0;
	let cc			= 0;
	let frag		= false;
	let pc			= 0;
	let pc2			= 1;
	let pc3			= 0;
	let pc4			= 1;
	let pc5			= 0;
	let pc6			= 1;
	let pc7			= 0;
	let pc8			= 1;
	let i			= 0;
	let i2			= 1;
	let i3			= 0;
	let i4			= 1;
	let i5			= 0;
	let i6			= 1;
	let i7			= 0;
	let i8			= 1;
	
	loop(11){
		ObjPrim_SetTexture(spn[i],front_tex[0]);
		Obj_SetRenderPriorityI(spn[i],31);
		ObjRender_SetBlendType(spn[i],BLEND_ALPHA);
		ObjRender_SetScaleXYZ(spn[i],1,1,1);
		ObjRender_SetAngleXYZ(spn[i],0,0,-35);
		ObjSprite2D_SetSourceRect(spn[i],0,496,512,512);
		ObjSprite2D_SetDestCenter(spn[i]);
		ObjRender_SetAlpha(spn[i],alpha);
		i++;
	}
	i=0;
	ObjRender_SetPosition(spn[0],CenX,CenY,0);
	ObjRender_SetPosition(spn[1],CenX,CenY-35,0);
	ObjRender_SetPosition(spn[2],CenX,CenY+35,0);
	ObjRender_SetPosition(spn[3],CenX,CenY-70,0);
	ObjRender_SetPosition(spn[4],CenX,CenY+70,0);
	ObjRender_SetPosition(spn[5],CenX,CenY-105,0);
	ObjRender_SetPosition(spn[6],CenX,CenY+105,0);
	ObjRender_SetPosition(spn[7],CenX,CenY-140,0);
	ObjRender_SetPosition(spn[8],CenX,CenY+140,0);
	ObjRender_SetPosition(spn[9],CenX,CenY-175,0);
	ObjRender_SetPosition(spn[10],CenX,CenY+175,0);
	
	ObjRender_SetPosition(spn7,CenX+120,CenY+160,0);
	ObjPrim_SetTexture(spn7,front_tex[0]);
	Obj_SetRenderPriorityI(spn7,31);
	ObjRender_SetBlendType(spn7,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(spn7,1,1,1);
	ObjRender_SetAngleXYZ(spn7,0,0,0);
	ObjRender_SetAlpha(spn7,alpha);
	ObjPrim_SetPrimitiveType(spn7,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn7,18);
	loop(18){
		ObjPrim_SetVertexPosition(spn7,i,120*sin(pc),120*cos(pc),0);
		ObjPrim_SetVertexPosition(spn7,i2,100*sin(pc2),100*cos(pc2),0);
		pc+=45;
		pc2+=45;
		i+=2;
		i2+=2;
	}
	ObjPrim_SetVertexUVT(spn7,0,0,496);  ObjPrim_SetVertexUVT(spn7,7,256,512); ObjPrim_SetVertexUVT(spn7,14,256,496);
	ObjPrim_SetVertexUVT(spn7,1,0,512);  ObjPrim_SetVertexUVT(spn7,8,0,496);   ObjPrim_SetVertexUVT(spn7,15,256,512);
	ObjPrim_SetVertexUVT(spn7,2,256,496);ObjPrim_SetVertexUVT(spn7,9,0,512);   ObjPrim_SetVertexUVT(spn7,16,0,496);
	ObjPrim_SetVertexUVT(spn7,3,256,512);ObjPrim_SetVertexUVT(spn7,10,256,496);ObjPrim_SetVertexUVT(spn7,17,0,512);
	ObjPrim_SetVertexUVT(spn7,4,0,496);  ObjPrim_SetVertexUVT(spn7,11,256,512);ObjPrim_SetVertexUVT(spn7,18,256,496);
	ObjPrim_SetVertexUVT(spn7,5,0,512);  ObjPrim_SetVertexUVT(spn7,12,0,496);
	ObjPrim_SetVertexUVT(spn7,6,256,496);ObjPrim_SetVertexUVT(spn7,13,0,512);
	
	ObjRender_SetPosition(spn8,CenX-120,CenY-160,0);
	ObjPrim_SetTexture(spn8,front_tex[0]);
	Obj_SetRenderPriorityI(spn8,31);
	ObjRender_SetBlendType(spn8,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(spn8,1,1,1);
	ObjRender_SetAngleXYZ(spn8,0,0,0);
	ObjRender_SetAlpha(spn8,alpha);
	ObjPrim_SetPrimitiveType(spn8,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn8,18);
	loop(18){
		ObjPrim_SetVertexPosition(spn8,i3,120*sin(pc3),120*cos(pc3),0);
		ObjPrim_SetVertexPosition(spn8,i4,100*sin(pc4),100*cos(pc4),0);
		pc3+=45;
		pc4+=45;
		i3+=2;
		i4+=2;
	}
	ObjPrim_SetVertexUVT(spn8,0,0,496);  ObjPrim_SetVertexUVT(spn8,7,256,512); ObjPrim_SetVertexUVT(spn8,14,256,496);
	ObjPrim_SetVertexUVT(spn8,1,0,512);  ObjPrim_SetVertexUVT(spn8,8,0,496);   ObjPrim_SetVertexUVT(spn8,15,256,512);
	ObjPrim_SetVertexUVT(spn8,2,256,496);ObjPrim_SetVertexUVT(spn8,9,0,512);   ObjPrim_SetVertexUVT(spn8,16,0,496);
	ObjPrim_SetVertexUVT(spn8,3,256,512);ObjPrim_SetVertexUVT(spn8,10,256,496);ObjPrim_SetVertexUVT(spn8,17,0,512);
	ObjPrim_SetVertexUVT(spn8,4,0,496);  ObjPrim_SetVertexUVT(spn8,11,256,512);ObjPrim_SetVertexUVT(spn8,18,256,496);
	ObjPrim_SetVertexUVT(spn8,5,0,512);  ObjPrim_SetVertexUVT(spn8,12,0,496);
	ObjPrim_SetVertexUVT(spn8,6,256,496);ObjPrim_SetVertexUVT(spn8,13,0,512);
	
	//婏悢夞(pc2)偑撪墌丄嬼悢夞(pc)偑奜墌  
	
	ObjRender_SetPosition(spn9,CenX+120,CenY+160,0);
	ObjPrim_SetTexture(spn9,front_tex[0]);
	Obj_SetRenderPriorityI(spn9,31);
	ObjRender_SetBlendType(spn9,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(spn9,1,1,1);
	ObjRender_SetAngleXYZ(spn9,0,0,0);
	ObjRender_SetAlpha(spn9,alpha);
	ObjPrim_SetPrimitiveType(spn9,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn9,18);
	loop(18){
		ObjPrim_SetVertexPosition(spn9,i5,140*sin(pc5),140*cos(pc5),0);
		ObjPrim_SetVertexPosition(spn9,i6,120*sin(pc6),120*cos(pc6),0);
		pc5+=45;
		pc6+=45;
		i5+=2;
		i6+=2;
	}
	ObjPrim_SetVertexUVT(spn9,0,0,496);  ObjPrim_SetVertexUVT(spn9,7,256,512); ObjPrim_SetVertexUVT(spn9,14,256,496);
	ObjPrim_SetVertexUVT(spn9,1,0,512);  ObjPrim_SetVertexUVT(spn9,8,0,496);   ObjPrim_SetVertexUVT(spn9,15,256,512);
	ObjPrim_SetVertexUVT(spn9,2,256,496);ObjPrim_SetVertexUVT(spn9,9,0,512);   ObjPrim_SetVertexUVT(spn9,16,0,496);
	ObjPrim_SetVertexUVT(spn9,3,256,512);ObjPrim_SetVertexUVT(spn9,10,256,496);ObjPrim_SetVertexUVT(spn9,17,0,512);
	ObjPrim_SetVertexUVT(spn9,4,0,496);  ObjPrim_SetVertexUVT(spn9,11,256,512);ObjPrim_SetVertexUVT(spn9,18,256,496);
	ObjPrim_SetVertexUVT(spn9,5,0,512);  ObjPrim_SetVertexUVT(spn9,12,0,496);
	ObjPrim_SetVertexUVT(spn9,6,256,496);ObjPrim_SetVertexUVT(spn9,13,0,512);
	
	ObjRender_SetPosition(spn10,CenX+120,CenY+160,0);
	ObjPrim_SetTexture(spn10,front_tex[0]);
	Obj_SetRenderPriorityI(spn10,31);
	ObjRender_SetBlendType(spn10,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(spn10,1,1,1);
	ObjRender_SetAngleXYZ(spn10,0,0,0);
	ObjRender_SetAlpha(spn10,alpha);
	ObjPrim_SetPrimitiveType(spn10,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn10,18);
	loop(18){
		ObjPrim_SetVertexPosition(spn10,i7,160*sin(pc7),160*cos(pc7),0);
		ObjPrim_SetVertexPosition(spn10,i8,140*sin(pc8),140*cos(pc8),0);
		pc7+=45;
		pc8+=45;
		i7+=2;
		i8+=2;
	}
	ObjPrim_SetVertexUVT(spn10,0,0,496);  ObjPrim_SetVertexUVT(spn10,7,256,512); ObjPrim_SetVertexUVT(spn10,14,256,496);
	ObjPrim_SetVertexUVT(spn10,1,0,512);  ObjPrim_SetVertexUVT(spn10,8,0,496);   ObjPrim_SetVertexUVT(spn10,15,256,512);
	ObjPrim_SetVertexUVT(spn10,2,256,496);ObjPrim_SetVertexUVT(spn10,9,0,512);   ObjPrim_SetVertexUVT(spn10,16,0,496);
	ObjPrim_SetVertexUVT(spn10,3,256,512);ObjPrim_SetVertexUVT(spn10,10,256,496);ObjPrim_SetVertexUVT(spn10,17,0,512);
	ObjPrim_SetVertexUVT(spn10,4,0,496);  ObjPrim_SetVertexUVT(spn10,11,256,512);ObjPrim_SetVertexUVT(spn10,18,256,496);
	ObjPrim_SetVertexUVT(spn10,5,0,512);  ObjPrim_SetVertexUVT(spn10,12,0,496);
	ObjPrim_SetVertexUVT(spn10,6,256,496);ObjPrim_SetVertexUVT(spn10,13,0,512);
	
	i=0;
	
	while(!Obj_IsDeleted(enm)){
		cc+=1;
		if(cc>100){frag=true;}
		ObjRender_SetAngleXYZ(spn7,0,0,cc/1*-1);
		ObjRender_SetAngleXYZ(spn8,0,0,cc/1);
		ObjRender_SetAngleXYZ(spn9,0,0,cc/1*1);
		ObjRender_SetAngleXYZ(spn10,0,0,cc/1*1);
		
		mc+=1.5;
		if(frag==false&&alpha<150){alpha+=5;}
		if(frag==true&&alpha>0){alpha-=15;}
		
		ObjSprite2D_SetSourceRect(spn[0],0+mc,496,512+mc,512);
		ObjSprite2D_SetSourceRect(spn[1],0-mc,496,512-mc,512);
		ObjSprite2D_SetSourceRect(spn[2],0-mc,496,512-mc,512);
		ObjSprite2D_SetSourceRect(spn[3],0+mc,496,512+mc,512);
		ObjSprite2D_SetSourceRect(spn[4],0+mc,496,512+mc,512);
		ObjSprite2D_SetSourceRect(spn[5],0-mc,496,512-mc,512);
		ObjSprite2D_SetSourceRect(spn[6],0-mc,496,512-mc,512);
		ObjSprite2D_SetSourceRect(spn[7],0+mc,496,512+mc,512);
		ObjSprite2D_SetSourceRect(spn[8],0+mc,496,512+mc,512);
		ObjSprite2D_SetSourceRect(spn[9],0-mc,496,512-mc,512);
		ObjSprite2D_SetSourceRect(spn[10],0-mc,496,512-mc,512);
		
		loop(11){
			ObjRender_SetAlpha(spn[i],alpha);
			i++;
		}
		i=0;
	
		
		ObjRender_SetAlpha(spn7,alpha);
		ObjRender_SetAlpha(spn8,alpha);
		ObjRender_SetAlpha(spn9,alpha);
		ObjRender_SetAlpha(spn10,alpha);
	
		if(frag==true&&alpha<=0){
			loop(11){
				Obj_Delete(spn[i]);
				i++;
			}
			i=0;
			
			Obj_Delete(spn7);
			Obj_Delete(spn8);
			Obj_Delete(spn9);
			Obj_Delete(spn10);
			break;
		}
		
		yield;
	}
	i=0;
	Obj_Delete(spn7);
	Obj_Delete(spn8);
	Obj_Delete(spn9);
	Obj_Delete(spn10);
	loop(11){
		Obj_Delete(spn[i]);
		i++;
	}
}

task CutinSP4_SUBT{
	let spn7		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn8		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn9		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn10		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn			= [ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D)];
	let alpha		= 0;
	let mc			= 0;
	let cc			= 0;
	let frag		= false;
	let pc			= 0;
	let pc2			= 1;
	let pc3			= 0;
	let pc4			= 1;
	let pc5			= 0;
	let pc6			= 1;
	let pc7			= 0;
	let pc8			= 1;
	let i			= 0;
	let i2			= 1;
	let i3			= 0;
	let i4			= 1;
	let i5			= 0;
	let i6			= 1;
	let i7			= 0;
	let i8			= 1;
	
	loop(11){
		ObjPrim_SetTexture(spn[i],front_tex[0]);
		Obj_SetRenderPriorityI(spn[i],21);
		ObjRender_SetBlendType(spn[i],BLEND_SUBTRACT);
		ObjRender_SetScaleXYZ(spn[i],1,1,1);
		ObjRender_SetAngleXYZ(spn[i],0,0,-35);
		ObjSprite2D_SetSourceRect(spn[i],0,208,600,222);
		ObjSprite2D_SetDestCenter(spn[i]);
		ObjRender_SetAlpha(spn[i],alpha);
		ObjRender_SetColor(spn[i],alpha,alpha,alpha);
		i++;
	}
	i=0;
	ObjRender_SetPosition(spn[0],CenX,CenY,0);
	ObjRender_SetPosition(spn[1],CenX,CenY-35,0);
	ObjRender_SetPosition(spn[2],CenX,CenY+35,0);
	ObjRender_SetPosition(spn[3],CenX,CenY-70,0);
	ObjRender_SetPosition(spn[4],CenX,CenY+70,0);
	ObjRender_SetPosition(spn[5],CenX,CenY-105,0);
	ObjRender_SetPosition(spn[6],CenX,CenY+105,0);
	ObjRender_SetPosition(spn[7],CenX,CenY-140,0);
	ObjRender_SetPosition(spn[8],CenX,CenY+140,0);
	ObjRender_SetPosition(spn[9],CenX,CenY-175,0);
	ObjRender_SetPosition(spn[10],CenX,CenY+175,0);
	
	ObjRender_SetPosition(spn7,CenX+120,CenY+160,0);
	ObjPrim_SetTexture(spn7,front_tex[0]);
	Obj_SetRenderPriorityI(spn7,21);
	ObjRender_SetBlendType(spn7,BLEND_SUBTRACT);
	ObjRender_SetScaleXYZ(spn7,1,1,1);
	ObjRender_SetAngleXYZ(spn7,0,0,0);
	ObjRender_SetAlpha(spn7,alpha);
	ObjPrim_SetPrimitiveType(spn7,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn7,18);
	ObjRender_SetColor(spn7,alpha,alpha,alpha);
	loop(18){
		ObjPrim_SetVertexPosition(spn7,i,120*sin(pc),120*cos(pc),0);
		ObjPrim_SetVertexPosition(spn7,i2,100*sin(pc2),100*cos(pc2),0);
		pc+=45;
		pc2+=45;
		i+=2;
		i2+=2;
	}
	ObjPrim_SetVertexUVT(spn7,0,0,58);  ObjPrim_SetVertexUVT(spn7,7,256,74); ObjPrim_SetVertexUVT(spn7,14,256,58);
	ObjPrim_SetVertexUVT(spn7,1,0,74);  ObjPrim_SetVertexUVT(spn7,8,0,58);   ObjPrim_SetVertexUVT(spn7,15,256,74);
	ObjPrim_SetVertexUVT(spn7,2,256,58);ObjPrim_SetVertexUVT(spn7,9,0,74);   ObjPrim_SetVertexUVT(spn7,16,0,58);
	ObjPrim_SetVertexUVT(spn7,3,256,74);ObjPrim_SetVertexUVT(spn7,10,256,58);ObjPrim_SetVertexUVT(spn7,17,0,74);
	ObjPrim_SetVertexUVT(spn7,4,0,58);  ObjPrim_SetVertexUVT(spn7,11,256,74);ObjPrim_SetVertexUVT(spn7,18,256,58);
	ObjPrim_SetVertexUVT(spn7,5,0,74);  ObjPrim_SetVertexUVT(spn7,12,0,58);
	ObjPrim_SetVertexUVT(spn7,6,256,58);ObjPrim_SetVertexUVT(spn7,13,0,74);
	
	ObjRender_SetPosition(spn8,CenX-120,CenY-160,0);
	ObjPrim_SetTexture(spn8,front_tex[0]);
	Obj_SetRenderPriorityI(spn8,21);
	ObjRender_SetBlendType(spn8,BLEND_SUBTRACT);
	ObjRender_SetScaleXYZ(spn8,1,1,1);
	ObjRender_SetAngleXYZ(spn8,0,0,0);
	ObjRender_SetAlpha(spn8,alpha);
	ObjPrim_SetPrimitiveType(spn8,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn8,18);
	ObjRender_SetColor(spn8,alpha,alpha,alpha);
	loop(18){
		ObjPrim_SetVertexPosition(spn8,i3,120*sin(pc3),120*cos(pc3),0);
		ObjPrim_SetVertexPosition(spn8,i4,100*sin(pc4),100*cos(pc4),0);
		pc3+=45;
		pc4+=45;
		i3+=2;
		i4+=2;
	}
	ObjPrim_SetVertexUVT(spn8,0,0,58);  ObjPrim_SetVertexUVT(spn8,7,256,74); ObjPrim_SetVertexUVT(spn8,14,256,58);
	ObjPrim_SetVertexUVT(spn8,1,0,74);  ObjPrim_SetVertexUVT(spn8,8,0,58);   ObjPrim_SetVertexUVT(spn8,15,256,74);
	ObjPrim_SetVertexUVT(spn8,2,256,58);ObjPrim_SetVertexUVT(spn8,9,0,74);   ObjPrim_SetVertexUVT(spn8,16,0,58);
	ObjPrim_SetVertexUVT(spn8,3,256,74);ObjPrim_SetVertexUVT(spn8,10,256,58);ObjPrim_SetVertexUVT(spn8,17,0,74);
	ObjPrim_SetVertexUVT(spn8,4,0,58);  ObjPrim_SetVertexUVT(spn8,11,256,74);ObjPrim_SetVertexUVT(spn8,18,256,58);
	ObjPrim_SetVertexUVT(spn8,5,0,74);  ObjPrim_SetVertexUVT(spn8,12,0,58);
	ObjPrim_SetVertexUVT(spn8,6,256,58);ObjPrim_SetVertexUVT(spn8,13,0,74);
	
	//婏悢夞(pc2)偑撪墌丄嬼悢夞(pc)偑奜墌  
	
	ObjRender_SetPosition(spn9,CenX+120,CenY+160,0);
	ObjPrim_SetTexture(spn9,front_tex[0]);
	Obj_SetRenderPriorityI(spn9,21);
	ObjRender_SetBlendType(spn9,BLEND_SUBTRACT);
	ObjRender_SetScaleXYZ(spn9,1,1,1);
	ObjRender_SetAngleXYZ(spn9,0,0,0);
	ObjRender_SetAlpha(spn9,alpha);
	ObjPrim_SetPrimitiveType(spn9,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn9,18);
	ObjRender_SetColor(spn9,alpha,alpha,alpha);
	loop(18){
		ObjPrim_SetVertexPosition(spn9,i5,140*sin(pc5),140*cos(pc5),0);
		ObjPrim_SetVertexPosition(spn9,i6,120*sin(pc6),120*cos(pc6),0);
		pc5+=45;
		pc6+=45;
		i5+=2;
		i6+=2;
	}
	ObjPrim_SetVertexUVT(spn9,0,0,58);  ObjPrim_SetVertexUVT(spn9,7,256,74); ObjPrim_SetVertexUVT(spn9,14,256,58);
	ObjPrim_SetVertexUVT(spn9,1,0,74);  ObjPrim_SetVertexUVT(spn9,8,0,58);   ObjPrim_SetVertexUVT(spn9,15,256,74);
	ObjPrim_SetVertexUVT(spn9,2,256,58);ObjPrim_SetVertexUVT(spn9,9,0,74);   ObjPrim_SetVertexUVT(spn9,16,0,58);
	ObjPrim_SetVertexUVT(spn9,3,256,74);ObjPrim_SetVertexUVT(spn9,10,256,58);ObjPrim_SetVertexUVT(spn9,17,0,74);
	ObjPrim_SetVertexUVT(spn9,4,0,58);  ObjPrim_SetVertexUVT(spn9,11,256,74);ObjPrim_SetVertexUVT(spn9,18,256,58);
	ObjPrim_SetVertexUVT(spn9,5,0,74);  ObjPrim_SetVertexUVT(spn9,12,0,58);
	ObjPrim_SetVertexUVT(spn9,6,256,58);ObjPrim_SetVertexUVT(spn9,13,0,74);
	
	ObjRender_SetPosition(spn10,CenX+120,CenY+160,0);
	ObjPrim_SetTexture(spn10,front_tex[0]);
	Obj_SetRenderPriorityI(spn10,21);
	ObjRender_SetBlendType(spn10,BLEND_SUBTRACT);
	ObjRender_SetScaleXYZ(spn10,1,1,1);
	ObjRender_SetAngleXYZ(spn10,0,0,0);
	ObjRender_SetAlpha(spn10,alpha);
	ObjPrim_SetPrimitiveType(spn10,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn10,18);
	ObjRender_SetColor(spn10,alpha,alpha,alpha);
	loop(18){
		ObjPrim_SetVertexPosition(spn10,i7,160*sin(pc7),160*cos(pc7),0);
		ObjPrim_SetVertexPosition(spn10,i8,140*sin(pc8),140*cos(pc8),0);
		pc7+=45;
		pc8+=45;
		i7+=2;
		i8+=2;
	}
	ObjPrim_SetVertexUVT(spn10,0,0,58);  ObjPrim_SetVertexUVT(spn10,7,256,74); ObjPrim_SetVertexUVT(spn10,14,256,58);
	ObjPrim_SetVertexUVT(spn10,1,0,74);  ObjPrim_SetVertexUVT(spn10,8,0,58);   ObjPrim_SetVertexUVT(spn10,15,256,74);
	ObjPrim_SetVertexUVT(spn10,2,256,58);ObjPrim_SetVertexUVT(spn10,9,0,74);   ObjPrim_SetVertexUVT(spn10,16,0,58);
	ObjPrim_SetVertexUVT(spn10,3,256,74);ObjPrim_SetVertexUVT(spn10,10,256,58);ObjPrim_SetVertexUVT(spn10,17,0,74);
	ObjPrim_SetVertexUVT(spn10,4,0,58);  ObjPrim_SetVertexUVT(spn10,11,256,74);ObjPrim_SetVertexUVT(spn10,18,256,58);
	ObjPrim_SetVertexUVT(spn10,5,0,74);  ObjPrim_SetVertexUVT(spn10,12,0,58);
	ObjPrim_SetVertexUVT(spn10,6,256,58);ObjPrim_SetVertexUVT(spn10,13,0,74);
	
	i=0;
	
	while(!Obj_IsDeleted(enm)){
		cc+=1;
		if(cc>100){frag=true;}
		ObjRender_SetAngleXYZ(spn7,0,0,cc/1*-1);
		ObjRender_SetAngleXYZ(spn8,0,0,cc/1);
		ObjRender_SetAngleXYZ(spn9,0,0,cc/1*1);
		ObjRender_SetAngleXYZ(spn10,0,0,cc/1*1);
		
		mc-=1.5;
		if(frag==false&&alpha<150){alpha+=5;}
		if(frag==true&&alpha>0){alpha-=15;}
		
		ObjSprite2D_SetSourceRect(spn[0],0+mc,58,600+mc,74);
		ObjSprite2D_SetSourceRect(spn[1],0-mc,58,600-mc,74);
		ObjSprite2D_SetSourceRect(spn[2],0-mc,58,600-mc,74);
		ObjSprite2D_SetSourceRect(spn[3],0+mc,58,600+mc,74);
		ObjSprite2D_SetSourceRect(spn[4],0+mc,58,600+mc,74);
		ObjSprite2D_SetSourceRect(spn[5],0-mc,58,600-mc,74);
		ObjSprite2D_SetSourceRect(spn[6],0-mc,58,600-mc,74);
		ObjSprite2D_SetSourceRect(spn[7],0+mc,58,600+mc,74);
		ObjSprite2D_SetSourceRect(spn[8],0+mc,58,600+mc,74);
		ObjSprite2D_SetSourceRect(spn[9],0-mc,58,600-mc,74);
		ObjSprite2D_SetSourceRect(spn[10],0-mc,58,600-mc,74);
		
		loop(11){
			ObjRender_SetScaleXYZ(spn[i],1+rand(-0.02,0.02),1+rand(-0.02,0.02),1);
			ObjRender_SetColor(spn[i],alpha,alpha+64,alpha+64);
			i++;
		}
		i=0;
		
		ObjRender_SetColor(spn7,alpha,alpha,alpha);
		ObjRender_SetColor(spn8,alpha,alpha,alpha);
		ObjRender_SetColor(spn9,alpha,alpha,alpha);
		ObjRender_SetColor(spn10,alpha,alpha,alpha);
		
	
		if(frag==true&&alpha<=0){
			loop(11){
				Obj_Delete(spn[i]);
				i++;
			}
			i=0;
			
			Obj_Delete(spn7);
			Obj_Delete(spn8);
			Obj_Delete(spn9);
			Obj_Delete(spn10);
			break;
		}
		
		yield;
	}
	i=0;
	Obj_Delete(spn7);
	Obj_Delete(spn8);
	Obj_Delete(spn9);
	Obj_Delete(spn10);
	loop(11){
		Obj_Delete(spn[i]);
		i++;
	}
}

task Timer(type,delay){
	let id			= [ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D)];
	let alpha		= 255;
	let moveA		= 0;
	let move1		= 0;
	let rect1		= [2,18,34,50,66,82,98,114,130,146];
	let rect3		= [18,34,50,66,82,98,114,130,146,162];
	let GetTimer	= ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID(),INFO_TIMER);
	let tf			= GetTimer*60;
	let dc			= 0;
	let rgb			= [255,255,255];
	let i			= 0;
		
	loop(4){
		ObjRender_SetPosition(id[i],CenX+32,MinY+16,0);
		ObjPrim_SetTexture(id[i],front_tex[3]);
		Obj_SetRenderPriorityI(id[i],81);
		ObjRender_SetBlendType(id[i],BLEND_ALPHA);
		ObjRender_SetAngleXYZ(id[i],0,0,0);
		ObjSprite2D_SetSourceRect(id[i],rect1[0],16,rect3[0],34);
		ObjSprite2D_SetDestCenter(id[i]);
		ObjRender_SetAlpha(id[i],alpha);
		i++;
	}
	i=0;
	
	ObjRender_SetScaleXYZ(id[0],1,1,1);
	ObjRender_SetScaleXYZ(id[1],1,1,1);
	ObjRender_SetScaleXYZ(id[2],0.7,0.7,1);
	ObjRender_SetScaleXYZ(id[3],0.7,0.7,1);
	
	while(!Obj_IsDeleted(enm)){
		let GetTimer	= ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID(),INFO_TIMER);
		let GetTimer2	= ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID(),INFO_TIMERF);
		if(ObjRender_GetX(id[0])-50<=GetPlayerX&&ObjRender_GetX(id[0])+50>=GetPlayerX&&
			ObjRender_GetY(id[0])-50<=GetPlayerY&&ObjRender_GetY(id[0])+20>=GetPlayerY){alpha=100;}
		if(IsPlayerSpellActive==true){alpha=0;}
		
		if(alpha<255){alpha+=15;}
		loop(4){
			ObjRender_SetAlpha(id[i],alpha);
			ObjRender_SetColor(id[i],rgb[0],rgb[1],rgb[2]);
			i++;
		}
		i=0;
		
		if(GetTimer<=10){rgb=[255,50,50];}
		
		if(type==0){//掕埵抲屌掕 僗儁僇乣捠忢傊
			if(move1<40){moveA+=2}
			move1=40.0*sin(moveA);
			ObjRender_SetPosition(id[0],CenX+32,MinY+50+16-move1,0);
			ObjRender_SetPosition(id[1],CenX-13+32,MinY+50+16-move1,0);
			ObjRender_SetPosition(id[2],CenX+20+32,MinY+53+16-move1,0);
			ObjRender_SetPosition(id[3],CenX+12+32,MinY+53+16-move1,0);
		}
		if(type==1){//掕埵抲屌掕丂捠忢乣僗儁僇傊
			if(move1<40&&delay<dc){moveA+=2}
			move1=40.0*sin(moveA);
			ObjRender_SetPosition(id[0],CenX+32,MinY+16+move1+10,0);
			ObjRender_SetPosition(id[1],CenX-13+32,MinY+16+move1+10,0);
			ObjRender_SetPosition(id[2],CenX+20+32,MinY+16+move1+13,0);
			ObjRender_SetPosition(id[3],CenX+12+32,MinY+16+move1+13,0);
		}
		if(type==2){//愴摤奐枊帪偺僞僀儅乕
			ObjRender_SetPosition(id[0],CenX+32,MinY+16+move1+10,0);
			ObjRender_SetPosition(id[1],CenX-13+32,MinY+16+move1+10,0);
			ObjRender_SetPosition(id[2],CenX+20+32,MinY+16+move1+13,0);
			ObjRender_SetPosition(id[3],CenX+12+32,MinY+16+move1+13,0);
		}
		
		dc++;
		if(delay>dc){
			ObjSprite2D_SetSourceRect(id[0],rect1[0],16,rect3[0],34);
			ObjSprite2D_SetSourceRect(id[1],rect1[0],16,rect3[0],34);
			ObjSprite2D_SetSourceRect(id[2],rect1[0],16,rect3[0],34);
			ObjSprite2D_SetSourceRect(id[3],rect1[0],16,rect3[0],34);
		}
		if(tf>0&&delay<dc){tf--;}
		
		let timer1  = truncate(GetTimer%10);
		let timer2  = truncate((GetTimer%100)/10);
		let timer3  = truncate(GetTimer2%10);
		let timer4  = truncate((GetTimer2%100)/10);
		if(GetTimer>99){
			timer1=9;
			timer2=9;
			timer3=9;
			timer4=9;
		}
		if(delay<dc){
			ObjSprite2D_SetSourceRect(id[0],rect1[timer1],16,rect3[timer1],34);
			ObjSprite2D_SetSourceRect(id[1],rect1[timer2],16,rect3[timer2],34);
			ObjSprite2D_SetSourceRect(id[2],rect1[timer3],16,rect3[timer3],34);
			ObjSprite2D_SetSourceRect(id[3],rect1[timer4],16,rect3[timer4],34);
		}
		yield;
	}
	i=0;
	loop(4){
		Obj_Delete(id[i]);
		i++;
	}
}

task MagicTimer{
	let spn1		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn2		= ObjPrim_Create(OBJ_SPRITE_2D);
	let pc			= 0;
	let pc2			= 1;
	let i			= 0;
	let i2			= 1;
	let spin		= 0;
	let sca1		= 0;
	let scaA		= 0;
	let sca2		= 0;
	let scaB		= 0;
	let alpha		= 128;
	let delete		= false;
	let delete2		= false;
	let delete3		= false;
	let GetTimer	= ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID(),INFO_TIMER);
	let gtsca		= GetTimer*60/2500;
	let cc			= 0;
	let EnmX		= ObjMove_GetX(enm);
	let EnmY		= ObjMove_GetY(enm);
		
	ObjRender_SetPosition(spn1,EnmX,EnmY,0);
	ObjPrim_SetTexture(spn1,front_tex[0]);
	Obj_SetRenderPriorityI(spn1,31);
	ObjRender_SetBlendType(spn1,BLEND_ADD_RGB);
	ObjRender_SetScaleXYZ(spn1,sca1,sca1,1);
	ObjRender_SetAngleXYZ(spn1,0,0,0);
	ObjRender_SetAlpha(spn1,alpha);
	ObjPrim_SetPrimitiveType(spn1,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn1,722);
	ObjRender_SetColor(spn1,alpha,alpha,alpha);
	ObjRender_SetPosition(spn2,EnmX,EnmY,0);
	ObjPrim_SetTexture(spn2,front_tex[0]);
	Obj_SetRenderPriorityI(spn2,31);
	ObjRender_SetBlendType(spn2,BLEND_ADD_RGB);
	ObjRender_SetScaleXYZ(spn2,sca2,sca2,1);
	ObjRender_SetAngleXYZ(spn2,0,0,0);
	ObjRender_SetAlpha(spn2,alpha);
	ObjPrim_SetPrimitiveType(spn2,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn2,722);//俶妏宍亄侾仏俀傪擖椡
	ObjRender_SetColor(spn2,alpha,alpha,alpha);
	loop(722){
		ObjPrim_SetVertexPosition(spn1,i,115*sin(pc),115*cos(pc),0);
		ObjPrim_SetVertexPosition(spn1,i2,100*sin(pc2),100*cos(pc2),0);
		ObjPrim_SetVertexUVT(spn1,i,0+pc,480);//480
		ObjPrim_SetVertexUVT(spn1,i2,0+pc2,496);//496
		ObjRender_SetAlpha(spn1,alpha);
		ObjPrim_SetVertexPosition(spn2,i,130*sin(pc),130*cos(pc),0);
		ObjPrim_SetVertexPosition(spn2,i2,115*sin(pc2),115*cos(pc2),0);
		ObjPrim_SetVertexUVT(spn2,i,0+pc,465);
		ObjPrim_SetVertexUVT(spn2,i2,0+pc2,480);
		ObjRender_SetAlpha(spn2,alpha);
		pc+=1;
		pc2+=1;
		i+=2;
		i2+=2;
	}
	pc=0;
	pc2=0;
	i=0;
	i2=0;
	
	while(!Obj_IsDeleted(enm)){
		let GetTimer	= ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID(),INFO_TIMER);
		let EnmX		= ObjMove_GetX(enm);
		let EnmY		= ObjMove_GetY(enm);
		
		spin+=6;
		ObjRender_SetAngleXYZ(spn1,0,0,spin*-1);
		ObjRender_SetAngleXYZ(spn2,0,0,spin);
		cc++;
		ObjRender_SetPosition(spn1,EnmX,EnmY,0);
		ObjRender_SetPosition(spn2,EnmX,EnmY,0);
		
		if(delete==false&&sca1<gtsca){scaA+=1;}
		if(delete==false){sca1=(gtsca+0.01)*sin(scaA);}
		if(delete==false&&sca1>=(gtsca-0.1)){delete=true;}
		if(delete==true&&sca1>0){sca1-=1/2500;}
		
		if(delete2==false&&delete3==false){scaB+=1;}
		if(sca2>=3){delete2=true;}
		if(delete2==true&&delete3==false&&sca2>sca1){scaB+=2;}
		if(delete2==true&&sca2<=sca1){delete3=true;}
		if(delete2==true&&delete3==true&&sca2>0){sca2-=1/2500;}
		if(delete3==false){sca2=3.0*sin(scaB);}

		ObjRender_SetScaleXYZ(spn1,0.5+sca1,0.5+sca1,0);
		ObjRender_SetScaleXYZ(spn2,0.5+sca2,0.5+sca2,0);
		
		yield;
	}
	Obj_Delete(spn1);
	Obj_Delete(spn2);
}

task MagicTimer_SUBT{
	let spn1		= ObjPrim_Create(OBJ_SPRITE_2D);
	let spn2		= ObjPrim_Create(OBJ_SPRITE_2D);
	let pc			= 0;
	let pc2			= 1;
	let i			= 0;
	let i2			= 1;
	let spin		= 0;
	let sca1		= 0;
	let scaA		= 0;
	let sca2		= 0;
	let scaB		= 0;
	let alpha		= 32;
	let delete		= false;
	let delete2		= false;
	let delete3		= false;
	let GetTimer	= ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID(),INFO_TIMER);
	let gtsca		= GetTimer*60/2500;
	let cc			= 0;
	let EnmX		= ObjMove_GetX(enm);
	let EnmY		= ObjMove_GetY(enm);
	
	ObjRender_SetPosition(spn1,EnmX,EnmY,0);
	ObjPrim_SetTexture(spn1,front_tex[0]);
	Obj_SetRenderPriorityI(spn1,21);
	ObjRender_SetBlendType(spn1,BLEND_SUBTRACT);
	ObjRender_SetScaleXYZ(spn1,sca1,sca1,1);
	ObjRender_SetAngleXYZ(spn1,0,0,0);
	ObjRender_SetAlpha(spn1,alpha);
	ObjPrim_SetPrimitiveType(spn1,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn1,722);
	ObjRender_SetColor(spn1,alpha,alpha,8);
	ObjRender_SetPosition(spn2,EnmX,EnmY,0);
	ObjPrim_SetTexture(spn2,front_tex[0]);
	Obj_SetRenderPriorityI(spn2,21);
	ObjRender_SetBlendType(spn2,BLEND_SUBTRACT);
	ObjRender_SetScaleXYZ(spn2,sca2,sca2,1);
	ObjRender_SetAngleXYZ(spn2,0,0,0);
	ObjRender_SetAlpha(spn2,alpha);
	ObjPrim_SetPrimitiveType(spn2,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(spn2,722);//俶妏宍亄侾仏俀傪擖椡
	ObjRender_SetColor(spn2,alpha,8,alpha);
	loop(722){
		ObjPrim_SetVertexPosition(spn1,i,256*sin(pc),256*cos(pc),0);
		ObjPrim_SetVertexPosition(spn1,i2,0*sin(pc2),0*cos(pc2),0);
		ObjPrim_SetVertexUVT(spn1,i,0+pc,480);
		ObjPrim_SetVertexUVT(spn1,i2,0+pc2,496);
		ObjRender_SetAlpha(spn1,alpha);
		ObjPrim_SetVertexPosition(spn2,i,256*sin(pc),256*cos(pc),0);
		ObjPrim_SetVertexPosition(spn2,i2,0*sin(pc2),0*cos(pc2),0);
		ObjPrim_SetVertexUVT(spn2,i,0+pc,464);
		ObjPrim_SetVertexUVT(spn2,i2,0+pc2,480);
		ObjRender_SetAlpha(spn2,alpha);
		pc+=1;
		pc2+=1;
		i+=2;
		i2+=2;
	}
	pc=0;
	pc2=0;
	i=0;
	i2=0;

	
	while(!Obj_IsDeleted(enm)){
		let GetTimer	= ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID(),INFO_TIMER);
		let EnmX		= ObjMove_GetX(enm);
		let EnmY		= ObjMove_GetY(enm);
		let gox			= ObjRender_GetX(spn1);
		let goy			= ObjRender_GetY(spn1);
		
		spin+=6;
		ObjRender_SetAngleXYZ(spn1,0,0,spin*-1);
		ObjRender_SetAngleXYZ(spn2,0,0,spin);
		cc++;
		ObjRender_SetPosition(spn1,EnmX,EnmY,0);
		ObjRender_SetPosition(spn2,gox,goy,0);
		
		if(delete==false&&sca1<gtsca){scaA+=1;}
		if(delete==false){sca1=(gtsca+0.01)*sin(scaA);}
		if(delete==false&&sca1>=(gtsca-0.1)){delete=true;}
		if(delete==true&&sca1>0){sca1-=1/2500;}
		
		if(delete2==false&&delete3==false){scaB+=1;}
		if(sca2>=3){delete2=true;}
		if(delete2==true&&delete3==false&&sca2>sca1){scaB+=2;}
		if(delete2==true&&sca2<=sca1){delete3=true;}
		if(delete2==true&&delete3==true&&sca2>0){sca2-=1/2500;}
		if(delete3==false){sca2=3.0*sin(scaB);}

		ObjRender_SetScaleXYZ(spn1,0+sca2,0+sca2,0);
		ObjRender_SetScaleXYZ(spn2,0+sca2,0+sca2,0);
		
		yield;
	}
	Obj_Delete(spn1);
	Obj_Delete(spn2);
}

task History(getspell,playspell){
	let id			= [ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D),
						ObjPrim_Create(OBJ_SPRITE_2D)];
	let i		= 0;
	let alpha	= 0;
	let rect1	= [10,18,26,34,42,50,58,66,74,82];//90,98
	let rect3	= [17,25,33,41,49,57,65,73,81,89];//97,105
	let hs		= playspell;
	let gs		= getspell;
	let hispell	= [truncate(hs%10),
					truncate((hs%100)/10),
					truncate((hs%1000)/100)];
	let gespell	= [truncate(gs%10),
					truncate((gs%100)/10),
					truncate((gs%1000)/100)];

	ObjPrim_SetTexture(id[0],front_tex[0]);
	Obj_SetRenderPriorityI(id[0],82);
	ObjRender_SetBlendType(id[0],BLEND_ALPHA);
	ObjRender_SetScaleXYZ(id[0],1,1,1);
	ObjSprite2D_SetSourceRect(id[0],44,80,78,90);
	ObjSprite2D_SetDestCenter(id[0]);
	ObjRender_SetAlpha(id[0],alpha);

	loop(7){
		ObjPrim_SetTexture(id[1+i],front_tex[0]);
		Obj_SetRenderPriorityI(id[1+i],82);
		ObjRender_SetBlendType(id[1+i],BLEND_ALPHA);
		ObjRender_SetScaleXYZ(id[1+i],1,1,1);
		ObjSprite2D_SetSourceRect(id[1+i],rect1[0],104,rect3[0],114);
		ObjSprite2D_SetDestCenter(id[1+i]);
		ObjRender_SetAlpha(id[1+i],alpha);
		i++;
	}
	i=0;
	
	ObjSprite2D_SetSourceRect(id[4],90,104,98,114);
	ObjSprite2D_SetDestCenter(id[4]);
	
	loop(120){yield;}
	
	while(!Obj_IsDeleted(enm)){
		let EnmX		= ObjMove_GetX(enm);
		let EnmY		= ObjMove_GetY(enm);
		
		if(ObjRender_GetX(id[4])-50<=GetPlayerX&&ObjRender_GetX(id[4])+50>=GetPlayerX&&
		   ObjRender_GetY(id[4])-50<=GetPlayerY&&ObjRender_GetY(id[4])+50>=GetPlayerY){alpha=100;}
		if(ObjRender_GetX(id[4])-50<=EnmX&&ObjRender_GetX(id[4])+50>=EnmX&&
		   ObjRender_GetY(id[4])-50<=EnmY&&ObjRender_GetY(id[4])+50>=EnmY){alpha=100;}
		
		hispell	= [truncate(hs%10),
					truncate((hs%100)/10),
					truncate((hs%1000)/100)];
		gespell	= [truncate(gs%10),
					truncate((gs%100)/10),
					truncate((gs%1000)/100)];
		
		let gx = ObjRender_GetX(id[0]);
		let gy = ObjRender_GetY(id[0]);
		
		ObjRender_SetPosition(id[0],MinX+332,MinY+44,0);
		ObjRender_SetPosition(id[1],gx+22,gy,0);
		ObjRender_SetPosition(id[2],gx+29,gy,0);
		ObjRender_SetPosition(id[3],gx+36,gy,0);
		ObjRender_SetPosition(id[4],gx+43,gy,0);
		ObjRender_SetPosition(id[5],gx+50,gy,0);
		ObjRender_SetPosition(id[6],gx+57,gy,0);
		ObjRender_SetPosition(id[7],gx+64,gy,0);
		
		loop(3){
			ObjSprite2D_SetSourceRect(id[1+i],rect1[gespell[2-i]],104,rect3[gespell[2-i]],114);
			ObjSprite2D_SetSourceRect(id[5+i],rect1[hispell[2-i]],104,rect3[hispell[2-i]],114);
			i++;
		}i=0;
		
		if(alpha<255){alpha+=15;}
		loop(8){
			ObjRender_SetAlpha(id[i],alpha);
			i++;
		}i=0;
		
		yield;
	}
	loop(8){
		Obj_Delete(id[i]);
		i++;
	}i=0;
}

task VSname(type,char_txt){
	//type
	//0:婛弌
	//1:alpha憖嶌墘弌
	//2:堏摦D墘弌
	//3:堏摦R墘弌
	let id2		= [ObjText_Create(),ObjText_Create()];
	let alpha	= 28;
	let alpha1	= 0;
	let alphaA	= 0;
	let i		= 0;
	
	loop(2){
		ObjRender_SetPosition(id2[0],MinX+8,MinY+6,0);
		ObjRender_SetPosition(id2[1],MinX+6,MinY+4,0);
		ObjText_SetText(id2[i],char_txt);
		ObjText_SetFontType(id2[i],"俵俽 僑僔僢僋");
		ObjText_SetFontSize(id2[i],12);
		ObjText_SetHorizontalAlignment(id2[i],ALIGNMENT_LEFT);
		ObjText_SetMaxWidth(id2[i],450);
		ObjText_SetFontBorderWidth(id2[i],1);
		ObjText_SetFontBorderType(id2[i],BORDER_FULL);
		ObjText_SetFontBorderColor(id2[0],0,0,0);
		ObjText_SetFontBorderColor(id2[1],0,64,32);
		ObjText_SetFontColorTop(id2[0],0,0,0);
		ObjText_SetFontColorBottom(id2[0],0,0,0);
		ObjText_SetFontColorTop(id2[1],32,255,128);
		ObjText_SetFontColorBottom(id2[1],32,255,128);
		Obj_SetRenderPriorityI(id2[i],80);
		i++;
	}i=0;
	
	while(!Obj_IsDeleted(enm)){
		if(type==0){
			ObjRender_SetAlpha(id2[0],128);
			ObjRender_SetAlpha(id2[1],150);
		}
		if(type==1){
			if(alpha1<255){alphaA+=5;}
			alpha1 = 255*sin(alphaA);
			ObjRender_SetAlpha(id2[0],alpha1/2);
			ObjRender_SetAlpha(id2[1],alpha1/1.7);
		}
		if(type==2){
			ObjRender_SetAlpha(id2[0],128);
			ObjRender_SetAlpha(id2[1],150);
			if(alpha1<alpha){alphaA+=2;}
			alpha1 = alpha*sin(alphaA);
			ObjRender_SetPosition(id2[0],MinX+8,MinY+6+alpha1,0);
			ObjRender_SetPosition(id2[1],MinX+6,MinY+4+alpha1,0);
		}
		if(type==3){
			ObjRender_SetAlpha(id2[0],128);
			ObjRender_SetAlpha(id2[1],150);
			if(alpha1<alpha){alphaA+=2;}
			alpha1 = alpha*sin(alphaA);
			ObjRender_SetPosition(id2[0],MinX+8,MinY+6+alpha-alpha1,0);
			ObjRender_SetPosition(id2[1],MinX+6,MinY+4+alpha-alpha1,0);
		}
		
		yield;
	}
	Obj_Delete(id2[0]);
	Obj_Delete(id2[1]);
}

task RedMagicCircle(type,delay){
	let def			= ObjPrim_Create(OBJ_SPRITE_2D);
	let delay2		= 0;
	let alpha		= 64;
	let act			= 0;
	let move1		= 0;
	let moveA		= 0;
	let sca1		= 0;
	let scaA		= 0;
	let spin		= 0;
	let scp			= 0;
	let EnmX		= ObjMove_GetX(enm);
	let EnmY		= ObjMove_GetY(enm);
	
	ObjPrim_SetTexture(def,effect_tex[0]);
	Obj_SetRenderPriorityI(def,31);
	ObjRender_SetBlendType(def,BLEND_ADD_RGB);
	ObjRender_SetAngleXYZ(def,0,0,0);
	ObjRender_SetScaleXYZ(def,sca1,sca1,0);
	ObjSprite2D_SetSourceRect(def,2,2,125,125);
	ObjSprite2D_SetDestCenter(def);
	ObjRender_SetColor(def,alpha,alpha,alpha);
	
	loop(delay){
		ObjRender_SetPosition(def,EnmX,EnmY,0);
		yield;
	}
	
	alternative(type)
	case(0){
		act=0;
		PlaySEs(csd~"../../se/power_logo.wav");
	}
	case(1){
		act=1;
		sca1=2;
	}
	
	while(!Obj_IsDeleted(enm)){
		let EnmX		= ObjMove_GetX(enm);
		let EnmY		= ObjMove_GetY(enm);
		let gx			= ObjRender_GetX(def);
		let gy			= ObjRender_GetY(def);
		
		ObjRender_SetPosition(def,EnmX,EnmY,0);
		ObjRender_SetAngleXYZ(def,0,0,180-move1-spin);
		ObjRender_SetScaleXYZ(def,sca1+scp*sin(spin/2),sca1+scp*sin(spin/2),1);
		if(act==0){
			if(move1<180){moveA+=2;}
			move1=180.0*sin(moveA);
			if(sca1<2){scaA+=2;}
			sca1=2*sin(scaA);
			if(moveA==2){PlaySE(0);}
		}
		if(sca1>=1.8&&move1>=180){act=1;}
		if(act==1){
			spin+=6;
			scp=0.3;
		}
		yield;
	}
	Obj_Delete(def);
}

task PlaySEs(se){
	let sid		= ObjSound_Create;
	let SE		= GetAreaCommonData("Option","SE_Volume",100);
	
	ObjSound_Load(sid,se);
	ObjSound_SetVolumeRate(sid,SE);
	ObjSound_SetLoopEnable(sid,false);
	ObjSound_Play(sid);
	SEwait(180,sid);
}

function SEwait(long,ID){
	loop(long){yield;}
	Obj_Delete(ID);
}