//Nuclear Suns
task NuclearShot(type,x,y,nangle,speed,maxscale,distance,minscale,color,kill,bomb){
	/*Usage :Credit:From TLC
	type 1:Normal 2:Orbit 3:Dissoloved
	xy  lanching coordinate or polar coordinatw
	nangl angle(for type 2:intial direction)
	speed speed(type2:rotation-speed.if -1then inversed.Slow down if use decimal point)
	mxsc Maximun Size
	dista Distance from enemy when rotation(type2only,other should use 0)
	misc Minimum Size(type3only,other should use 0)
	color Self Explanatory
	kill  hitbox
	bomb  bomb-resist.
	*/
	let nuff2 = ObjPrim_Create(OBJ_SPRITE_2D);
	let nuff  = ObjPrim_Create(OBJ_SPRITE_2D);
	let shff  = ObjShot_Create(OBJ_SHOT);
ObjShot_Regist(shff);
	let img   = GetCurrentScriptDirectory~"Nuclear.png";
	let uv1   = [0,256,512,768,0,256,512,768];
	let uv2   = [0,0,0,0,256,256,256,256];
	let uv3   = [256,512,768,1024,256,512,768,1024];
	let uv4   = [256,256,256,256,512,512,512,512];
	let colorC;
	let MinX=0;
let MinY=0;
let MaxX=GetStgFrameWidth;
let MaxY=GetStgFrameHeight;
	let r=255;
	let g=255;
	let b=255;
	let scale = 0;
	let scp   = 0;
	let killC = 0;
	let distanceC = 0;
	let grazeF = false;
	
	//LoadGraphic(img);
	
	alternative(color)
	case("RED"){colorC=0}
	case("ORANGE"){colorC=1}
	case("YELLOW"){colorC=2}
	case("GREEN"){colorC=3}
	case("AQUA"){colorC=4}
	case("BLUE"){colorC=5}
	case("PURPLE"){colorC=6}
	case("WHITE"){colorC=7}
	
	ObjRender_SetPosition(nuff,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
	ObjPrim_SetTexture(nuff,img);
	ObjRender_SetBlendType(nuff,BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(nuff,PRIMITIVE_TRIANGLESTRIP);
	ObjRender_SetScaleXYZ(nuff,scale,scale,scale);
	ObjMove_SetSpeed(nuff,0);
	ObjMove_SetAngle(nuff,nangle);
	ObjRender_SetAngleXYZ(nuff,0,0,nangle);
	Obj_SetRenderPriorityI(nuff,50);
	ObjPrim_SetVertexCount(nuff,4);
	ObjPrim_SetVertexPosition(nuff,0,-128,-128,0);
	ObjPrim_SetVertexPosition(nuff,1,-128,128,0);
	ObjPrim_SetVertexPosition(nuff,2,128,-128,0);
	ObjPrim_SetVertexPosition(nuff,3,128,128,0);
ascent(i in 0..4){
	  ObjPrim_SetVertexColor(nuff,i,r,g,b);
	  ObjPrim_SetVertexAlpha(nuff,i,128);	
	  }
	//ObjEffect_SetVertexColor(nuff,0,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff,1,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff,2,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff,3,125,r,g,b);

	ObjPrim_SetVertexUVT(nuff,0,uv1[colorC],uv2[colorC]);
	ObjPrim_SetVertexUVT(nuff,1,uv1[colorC],uv4[colorC]);
	ObjPrim_SetVertexUVT(nuff,2,uv3[colorC],uv2[colorC]);
	ObjPrim_SetVertexUVT(nuff,3,uv3[colorC],uv4[colorC]);
	
	ObjRender_SetPosition(nuff2,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
	ObjPrim_SetTexture(nuff2,img);
	ObjRender_SetBlendType(nuff2,BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(nuff2,PRIMITIVE_TRIANGLESTRIP);
	ObjRender_SetScaleXYZ(nuff2,scale,scale,scale);
	ObjMove_SetSpeed(nuff2,0);
	ObjMove_SetAngle(nuff2,nangle);
	ObjRender_SetAngleXYZ(nuff2,0,0,nangle);
	Obj_SetRenderPriorityI(nuff2,40);
	ObjPrim_SetVertexCount(nuff2,4);
	ObjPrim_SetVertexPosition(nuff2,0,-128,-128,0);
	ObjPrim_SetVertexPosition(nuff2,1,-128,128,0);
	ObjPrim_SetVertexPosition(nuff2,2,128,-128,0);
	ObjPrim_SetVertexPosition(nuff2,3,128,128,0);
ascent(i in 0..4){
	  ObjPrim_SetVertexColor(nuff2,i,r,g,b);
	  ObjPrim_SetVertexAlpha(nuff2,i,128);	
	  }
	//ObjEffect_SetVertexColor(nuff2,0,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff2,1,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff2,2,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff2,3,125,r,g,b);
	ObjPrim_SetVertexUVT(nuff2,0,uv1[colorC],uv2[colorC]);
	ObjPrim_SetVertexUVT(nuff2,1,uv1[colorC],uv4[colorC]);
	ObjPrim_SetVertexUVT(nuff2,2,uv3[colorC],uv2[colorC]);
	ObjPrim_SetVertexUVT(nuff2,3,uv3[colorC],uv4[colorC]);
	
	ObjMove_SetPosition(shff,x,y);
	ObjMove_SetSpeed(shff,speed);
	ObjMove_SetAngle(shff,nangle);
	ObjRender_SetAlpha(shff,0);
	ObjShot_SetIntersectionEnable(shff,false);
	ObjShot_SetAutoDelete(shff,false);
	ObjShot_SetSpellResist(shff,bomb);
	ObjShot_SetGraphic(shff,1);
	
	loop(15){
		ObjRender_SetPosition(nuff,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
		ObjRender_SetPosition(nuff2,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
		if(type!=2){
			scale+=(maxscale/15);
			ObjRender_SetScaleXYZ(nuff,scale,scale,scale);
			ObjRender_SetScaleXYZ(nuff2,scale,scale,scale);
		}
		if(type==3){
			ObjMove_SetSpeed(shff,speed);
		}
		yield;
	}
	
	loop{
		let gnx = ObjMove_GetX(nuff);
		let gny = ObjMove_GetY(nuff);
		let gsx = ObjMove_GetX(shff);
		let gsy = ObjMove_GetY(shff);
		
		if(ObjEnemy_GetInfo(Enemy, INFO_LIFE)<=1){
			Obj_Delete(shff);
			Obj_Delete(nuff);
			Obj_Delete(nuff2);
			break;
		}else{
			//SetCollisionB(gsx,gsy,scale*120);
ObjShot_SetIntersectionCircleA1(shff,scale*120);
		}
		
		ObjRender_SetPosition(nuff,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
		ObjRender_SetPosition(nuff2,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
		
		if(type==2&&maxscale>scale){
			scale+=(maxscale/500);
			ObjRender_SetScaleXYZ(nuff,scale,scale,scale);
			ObjRender_SetScaleXYZ(nuff2,scale,scale,scale);
		}
		//SetCollisionB(gsx,gsy,scale*120);
		ObjEnemy_SetIntersectionCircleToPlayer(shff,gsx,gsy,scale*120);
		scp++;
		ObjRender_SetScaleXYZ(nuff,scale+0.03*sin(scp*10),scale+0.03*sin(scp*10),scale);
		
		alternative(type)
		case(1){
			ObjMove_SetSpeed(shff,speed);
			ObjMove_SetPosition(nuff2,gnx,gny);
		}
		case(2){
			if(distance>distanceC){distanceC++}
			ObjMove_SetPosition(shff,EnemyX+distanceC*sin(nangle+(scp/2*speed)),EnemyY+distanceC*cos(nangle+(scp/2*speed)));
			ObjMove_SetPosition(nuff,gsx,gsy);
			ObjMove_SetPosition(nuff2,gsx,gsy);
		}
		case(3){
			ObjMove_SetSpeed(shff,speed);
			ObjMove_SetPosition(nuff,gsx,gsy);
			ObjMove_SetPosition(nuff2,gsx,gsy);
			if(minscale<scale){scale-=0.005;}
			ObjRender_SetScaleXYZ(nuff,scale,scale,scale);
			ObjRender_SetScaleXYZ(nuff2,scale,scale,scale);
		}
		
		killC++;
		if(killC>kill&&kill>=0){
			Obj_Delete(nuff);
			Obj_Delete(nuff2);
			Obj_Delete(shff);
			break;
		}
		
		if(scale<=0){
			Obj_Delete(nuff);
			Obj_Delete(nuff2);
			Obj_Delete(shff);
			break;
		}
		
		//if(OnBomb==true&&bomb==false){
		//	Obj_Delete(nuff);
		//	Obj_Delete(nuff2);
		//	Obj_Delete(shff);
		//	break;
		//}
		if(type!=2){
			if(gny>=MaxY+250||gny<=MinY-250||gnx>=MaxX+250||gny<=MinY-250){
				Obj_Delete(nuff);
				Obj_Delete(nuff2);
				Obj_Delete(shff);
				break;
			}
		}
		if(Obj_IsDeleted(nuff)==true){break;}
		if(Obj_IsDeleted(shff)==true){
			Obj_Delete(nuff2);
			Obj_Delete(nuff);
			break;
		}
		yield;
	}
}
//Neg.Nuclear Suns
task NuclearShot_Negative(type,x,y,nangle,speed,maxscale,distance,minscale,color,kill,bomb){
	/*Usage :Credit:From TLC
	type 1:Normal 2:Orbit 3:Dissoloved
	xy  lanching coordinate or polar coordinatw
	nangl angle(for type 2:intial direction)
	speed speed(type2:rotation-speed.if -1then inversed.Slow down if use decimal point)
	mxsc Maximun Size
	dista Distance from enemy when rotation(type2only,other should use 0)
	misc Minimum Size(type3only,other should use 0)
	color Self Explanatory
	kill  hitbox
	bomb  bomb-resist.
	*/
	let nuff2 = ObjPrim_Create(OBJ_SPRITE_2D);
	let nuff  = ObjPrim_Create(OBJ_SPRITE_2D);
	let shff  = ObjShot_Create(OBJ_SHOT);
ObjShot_Regist(shff);
	let img   = GetCurrentScriptDirectory~"Nuclear.png";
	let uv1   = [0,256,512,768,0,256,512,768];
	let uv2   = [0,0,0,0,256,256,256,256];
	let uv3   = [256,512,768,1024,256,512,768,1024];
	let uv4   = [256,256,256,256,512,512,512,512];
	let colorC;
	let MinX=0;
let MinY=0;
let MaxX=GetStgFrameWidth;
let MaxY=GetStgFrameHeight;
	let r=255;
	let g=255;
	let b=255;
	let scale = 0;
	let scp   = 0;
	let killC = 0;
	let distanceC = 0;
	let grazeF = false;
	
	//LoadGraphic(img);
	
	alternative(color)
	case("RED"){colorC=0}
	case("ORANGE"){colorC=1}
	case("YELLOW"){colorC=2}
	case("GREEN"){colorC=3}
	case("AQUA"){colorC=4}
	case("BLUE"){colorC=5}
	case("PURPLE"){colorC=6}
	case("WHITE"){colorC=7}
	
	ObjRender_SetPosition(nuff,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
	ObjPrim_SetTexture(nuff,img);
	ObjRender_SetBlendType(nuff,BLEND_SUBTRACT);
	ObjPrim_SetPrimitiveType(nuff,PRIMITIVE_TRIANGLESTRIP);
	ObjRender_SetScaleXYZ(nuff,scale,scale,scale);
	ObjMove_SetSpeed(nuff,0);
	ObjMove_SetAngle(nuff,nangle);
	ObjRender_SetAngleXYZ(nuff,0,0,nangle);
	Obj_SetRenderPriorityI(nuff,50);
	ObjPrim_SetVertexCount(nuff,4);
	ObjPrim_SetVertexPosition(nuff,0,-128,-128,0);
	ObjPrim_SetVertexPosition(nuff,1,-128,128,0);
	ObjPrim_SetVertexPosition(nuff,2,128,-128,0);
	ObjPrim_SetVertexPosition(nuff,3,128,128,0);
ascent(i in 0..4){
	  ObjPrim_SetVertexColor(nuff,i,r,g,b);
	  ObjPrim_SetVertexAlpha(nuff,i,128);	
	  }
	//ObjEffect_SetVertexColor(nuff,0,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff,1,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff,2,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff,3,125,r,g,b);

	ObjPrim_SetVertexUVT(nuff,0,uv1[colorC],uv2[colorC]);
	ObjPrim_SetVertexUVT(nuff,1,uv1[colorC],uv4[colorC]);
	ObjPrim_SetVertexUVT(nuff,2,uv3[colorC],uv2[colorC]);
	ObjPrim_SetVertexUVT(nuff,3,uv3[colorC],uv4[colorC]);
	
	ObjRender_SetPosition(nuff2,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
	ObjPrim_SetTexture(nuff2,img);
	ObjRender_SetBlendType(nuff2,BLEND_SUBTRACT);
	ObjPrim_SetPrimitiveType(nuff2,PRIMITIVE_TRIANGLESTRIP);
	ObjRender_SetScaleXYZ(nuff2,scale,scale,scale);
	ObjMove_SetSpeed(nuff2,0);
	ObjMove_SetAngle(nuff2,nangle);
	ObjRender_SetAngleXYZ(nuff2,0,0,nangle);
	Obj_SetRenderPriorityI(nuff2,40);
	ObjPrim_SetVertexCount(nuff2,4);
	ObjPrim_SetVertexPosition(nuff2,0,-128,-128,0);
	ObjPrim_SetVertexPosition(nuff2,1,-128,128,0);
	ObjPrim_SetVertexPosition(nuff2,2,128,-128,0);
	ObjPrim_SetVertexPosition(nuff2,3,128,128,0);
ascent(i in 0..4){
	  ObjPrim_SetVertexColor(nuff2,i,r,g,b);
	  ObjPrim_SetVertexAlpha(nuff2,i,128);	
	  }
	//ObjEffect_SetVertexColor(nuff2,0,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff2,1,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff2,2,125,r,g,b);
	//ObjEffect_SetVertexColor(nuff2,3,125,r,g,b);
	ObjPrim_SetVertexUVT(nuff2,0,uv1[colorC],uv2[colorC]);
	ObjPrim_SetVertexUVT(nuff2,1,uv1[colorC],uv4[colorC]);
	ObjPrim_SetVertexUVT(nuff2,2,uv3[colorC],uv2[colorC]);
	ObjPrim_SetVertexUVT(nuff2,3,uv3[colorC],uv4[colorC]);
	
	ObjMove_SetPosition(shff,x,y);
	ObjMove_SetSpeed(shff,speed);
	ObjMove_SetAngle(shff,nangle);
	ObjRender_SetAlpha(shff,0);
	ObjShot_SetIntersectionEnable(shff,false);
	ObjShot_SetAutoDelete(shff,false);
	ObjShot_SetSpellResist(shff,bomb);
	ObjShot_SetGraphic(shff,1);
	
	loop(15){
		ObjRender_SetPosition(nuff,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
		ObjRender_SetPosition(nuff2,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
		if(type!=2){
			scale+=(maxscale/15);
			ObjRender_SetScaleXYZ(nuff,scale,scale,scale);
			ObjRender_SetScaleXYZ(nuff2,scale,scale,scale);
		}
		if(type==3){
			ObjMove_SetSpeed(shff,speed);
		}
		yield;
	}
	
	loop{
		let gnx = ObjMove_GetX(nuff);
		let gny = ObjMove_GetY(nuff);
		let gsx = ObjMove_GetX(shff);
		let gsy = ObjMove_GetY(shff);
		
		if(ObjEnemy_GetInfo(Enemy, INFO_LIFE)<=1){
			Obj_Delete(shff);
			Obj_Delete(nuff);
			Obj_Delete(nuff2);
			break;
		}else{
			//SetCollisionB(gsx,gsy,scale*120);
ObjShot_SetIntersectionCircleA1(shff,scale*120);
		}
		
		ObjRender_SetPosition(nuff,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
		ObjRender_SetPosition(nuff2,ObjMove_GetX(shff),ObjMove_GetY(shff),0);
		
		if(type==2&&maxscale>scale){
			scale+=(maxscale/500);
			ObjRender_SetScaleXYZ(nuff,scale,scale,scale);
			ObjRender_SetScaleXYZ(nuff2,scale,scale,scale);
		}
		//SetCollisionB(gsx,gsy,scale*120);
		ObjEnemy_SetIntersectionCircleToPlayer(shff,gsx,gsy,scale*120);
		scp++;
		ObjRender_SetScaleXYZ(nuff,scale+0.03*sin(scp*10),scale+0.03*sin(scp*10),scale);
		
		alternative(type)
		case(1){
			ObjMove_SetSpeed(shff,speed);
			ObjMove_SetPosition(nuff2,gnx,gny);
		}
		case(2){
			if(distance>distanceC){distanceC++}
			ObjMove_SetPosition(shff,EnemyX+distanceC*sin(nangle+(scp/2*speed)),EnemyY+distanceC*cos(nangle+(scp/2*speed)));
			ObjMove_SetPosition(nuff,gsx,gsy);
			ObjMove_SetPosition(nuff2,gsx,gsy);
		}
		case(3){
			ObjMove_SetSpeed(shff,speed);
			ObjMove_SetPosition(nuff,gsx,gsy);
			ObjMove_SetPosition(nuff2,gsx,gsy);
			if(minscale<scale){scale-=0.005;}
			ObjRender_SetScaleXYZ(nuff,scale,scale,scale);
			ObjRender_SetScaleXYZ(nuff2,scale,scale,scale);
		}
		
		killC++;
		if(killC>kill&&kill>=0){
			Obj_Delete(nuff);
			Obj_Delete(nuff2);
			Obj_Delete(shff);
			break;
		}
		
		if(scale<=0){
			Obj_Delete(nuff);
			Obj_Delete(nuff2);
			Obj_Delete(shff);
			break;
		}
		
		//if(OnBomb==true&&bomb==false){
		//	Obj_Delete(nuff);
		//	Obj_Delete(nuff2);
		//	Obj_Delete(shff);
		//	break;
		//}
		if(type!=2){
			if(gny>=MaxY+250||gny<=MinY-250||gnx>=MaxX+250||gny<=MinY-250){
				Obj_Delete(nuff);
				Obj_Delete(nuff2);
				Obj_Delete(shff);
				break;
			}
		}
		if(Obj_IsDeleted(nuff)==true){break;}
		if(Obj_IsDeleted(shff)==true){
			Obj_Delete(nuff2);
			Obj_Delete(nuff);
			break;
		}
		yield;
	}
}
//Aura
let imgaura1 = GetCurrentScriptDirectory~"img/Aura01.png";
let imgaura2 = GetCurrentScriptDirectory~"img/Aura02.png";

function Aura1(enemy,time,R,G,B) {

	Aura1_1_Auto(enemy,time,R,G,B);
	Aura1_2_Auto(enemy,3   ,R,G,B);

}

task Aura1_1_Auto(enemy,time,R,G,B) {

	while(!Obj_IsDeleted(enemy)) {
		Aura1_1(enemy,30,R,G,B);
		loop(time) { yield; }
	}
}

task Aura1_2_Auto(enemy,time,R,G,B) {

	while(!Obj_IsDeleted(enemy)) {
		Aura1_2(enemy,30,R,G,B);
		loop(time) { yield; }
	}
}

task Aura1_1(enemy,time,R,G,B) {

	let aura	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let mY		= 0;
	let pX		= rand(-4,4);
	let angle	= pX*2;
	let alpha1	= 0;
	let alpha2	= 0;
	let scalex1	= 0;
	let scalex2	= 0;
	let scalex3	= rand(1.0,1.4);
	let scaley1	= 0;
	let scaley2	= 0;
	let scaley3	= rand(1.4,1.6);

        let enemy_x = ObjMove_GetX(enemy);
        let enemy_y = ObjMove_GetY(enemy);

	LoadTexture(imgaura1);

	ObjRender_SetPosition(aura,enemy_x+pX,enemy_y-mY,0);
	ObjPrim_SetTexture(aura,imgaura1);
	ObjRender_SetBlendType(aura,BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(aura,PRIMITIVE_TRIANGLESTRIP);
	ObjRender_SetScaleXYZ(aura,scalex1,scaley1,1);
	ObjRender_SetAngleXYZ(aura,0,0,angle);
	Obj_SetRenderPriorityI(aura,25);
	ObjPrim_SetVertexCount(aura,4);
	ObjPrim_SetVertexPosition(aura,0,-24,-24,0);
	ObjPrim_SetVertexPosition(aura,1,-24, 24,0);
	ObjPrim_SetVertexPosition(aura,2, 24,-24,0);
	ObjPrim_SetVertexPosition(aura,3, 24, 24,0);
	ObjPrim_SetVertexUVT(aura,0,  0,  0);
	ObjPrim_SetVertexUVT(aura,1,  0, 48);
	ObjPrim_SetVertexUVT(aura,2, 48,  0);
	ObjPrim_SetVertexUVT(aura,3, 48, 48);

	loop(time) {

		mY      += 56/time;
		alpha2  += 180/time;
		alpha1   = 255*sin(alpha2);
		scalex2 += 135/time;
		scaley2 += 90 /time;
		scalex1  = scalex3*sin(scalex2);
		scaley1  = scaley3*sin(scaley2);

                enemy_x = ObjMove_GetX(enemy);
                enemy_y = ObjMove_GetY(enemy);

	        ObjRender_SetPosition(aura,enemy_x+pX,enemy_y-mY,0);
		ObjRender_SetScaleXYZ(aura,scalex1,scaley1,1);
		ObjPrim_SetVertexColor(aura,0,R*alpha1/255,G*alpha1/255,B*alpha1/255);
		ObjPrim_SetVertexColor(aura,1,R*alpha1/255,G*alpha1/255,B*alpha1/255);
		ObjPrim_SetVertexColor(aura,2,R*alpha1/255,G*alpha1/255,B*alpha1/255);
		ObjPrim_SetVertexColor(aura,3,R*alpha1/255,G*alpha1/255,B*alpha1/255);
		ObjPrim_SetVertexAlpha(aura,0,alpha1);
		ObjPrim_SetVertexAlpha(aura,1,alpha1);
		ObjPrim_SetVertexAlpha(aura,2,alpha1);
		ObjPrim_SetVertexAlpha(aura,3,alpha1);
                if(Obj_IsDeleted(enemy)){break;}
		yield;
	}
	Obj_Delete(aura);
}

task Aura1_2(enemy,time,R,G,B) {

	let aura	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let alpha	= 0;
	let scale	= 3.0;

        let enemy_x = ObjMove_GetX(enemy);
        let enemy_y = ObjMove_GetY(enemy);

	LoadTexture(imgaura1);

	ObjRender_SetPosition(aura,enemy_x,enemy_y,0);
	ObjPrim_SetTexture(aura,imgaura1);
	ObjRender_SetBlendType(aura,BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(aura,PRIMITIVE_TRIANGLESTRIP);
	ObjRender_SetScaleXYZ(aura,scale,scale,1);
	ObjRender_SetAngleXYZ(aura,0,0,rand(0,360));
	Obj_SetRenderPriorityI(aura,25);
	ObjPrim_SetVertexCount(aura,4);
	ObjPrim_SetVertexPosition(aura,0,-24,-24,0);
	ObjPrim_SetVertexPosition(aura,1,-24, 24,0);
	ObjPrim_SetVertexPosition(aura,2, 24,-24,0);
	ObjPrim_SetVertexPosition(aura,3, 24, 24,0);
	ObjPrim_SetVertexUVT(aura,0, 48,  0);
	ObjPrim_SetVertexUVT(aura,1, 48, 48);
	ObjPrim_SetVertexUVT(aura,2, 96,  0);
	ObjPrim_SetVertexUVT(aura,3, 96, 48);

	loop(time) {
		scale -= 2.0/time;
		alpha += 224/time;

                enemy_x = ObjMove_GetX(enemy);
                enemy_y = ObjMove_GetY(enemy);

	        ObjRender_SetPosition(aura,enemy_x,enemy_y,0);
		ObjRender_SetScaleXYZ(aura,scale,scale,1);
		ObjPrim_SetVertexColor(aura,0,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexColor(aura,1,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexColor(aura,2,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexColor(aura,3,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexAlpha(aura,0,alpha);
		ObjPrim_SetVertexAlpha(aura,1,alpha);
		ObjPrim_SetVertexAlpha(aura,2,alpha);
		ObjPrim_SetVertexAlpha(aura,3,alpha);
                if(Obj_IsDeleted(enemy)){break;}
		yield;
	}
	Obj_Delete(aura);
}

//Explosion Effect
let imgeff1 = GetCurrentScriptDirectory~"img/ChargeEffect_01.png";
let imgeff2 = GetCurrentScriptDirectory~"img/ChargeEffect_02.png";
task Diffusion01(x,y,nam,R,G,B) {

	loop(nam/10) {
		loop(10) { Diffusion(x,y,2,R,G,B); }
		loop(2) { yield; }
	}
}


task Diffusion02(x,y,nam,R,G,B) {

	loop(nam/10) {
		loop(10) { Diffusion(x,y,3,R,G,B); }
		loop(2) { yield; }
	}
}


task Diffusion03(x,y,nam,R,G,B) {

	loop(nam/10) {
		loop(10) { Diffusion(x,y,5,R,G,B); }
		loop(2) { yield; }
	}
}


task Diffusion04(x,y,nam,R,G,B) {

	loop(nam/10) {
		loop(10) { Diffusion(x,y,1,R,G,B) }
		loop(2) { yield; }
	}
}

task Diffusion05(x,y,nam,R,G,B) {

	loop(nam/10) {
		loop(10) { Diffusion(x,y,4,R,G,B) }
		loop(2) { yield; }
	}
}
let CHARGE_maxscale	= [2.50, 2.50, 3.75, 3.00, 2.00, 3.25, 3.25];
let CHARGE_efftime	= [  36,   30,   36,   30,   33,   30,   30];
let CHARGE_rectU	= [ 128,  192,   64,    0,  192,  128,  192];
let CHARGE_rectV	= [  64,   64,    0,   64,  128,    0,    0];
task Diffusion(x,y,type,R,G,B) {

	let eff		= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let scale	= CHARGE_maxscale[type]-0.50;
	let angle00	= rand(-180,180);
	let angle01	= rand(-180,180);
	let angle02	= rand(-180,180);
	let radius01	= 0;
	let radius02	= 0;
	let radius03	= rand(160,380);
	let alpha	= 0;
	let i1		= 1;
	let i2		= rand(-8,8);

	if(type==0) { i1 = 1.25; i2 = 0; }

	LoadTexture(imgeff1);

//	Obj_SetSpeed(eff,0);
//	Obj_SetAngle(eff,0);
	ObjPrim_SetTexture(eff,imgeff1);
	ObjRender_SetBlendType(eff,BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(eff,PRIMITIVE_TRIANGLESTRIP);
	ObjRender_SetScaleXYZ(eff,scale*i1,scale,1);
	Obj_SetRenderPriorityI(eff,30);
	ObjPrim_SetVertexCount(eff,4);
	ObjPrim_SetVertexPosition(eff,0,-32,-32,0);
	ObjPrim_SetVertexPosition(eff,1,-32, 32,0);
	ObjPrim_SetVertexPosition(eff,2, 32,-32,0);
	ObjPrim_SetVertexPosition(eff,3, 32, 32,0);
	ObjPrim_SetVertexUVT(eff,0,CHARGE_rectU[type]   ,CHARGE_rectV[type]);
	ObjPrim_SetVertexUVT(eff,1,CHARGE_rectU[type]   ,CHARGE_rectV[type]+64);
	ObjPrim_SetVertexUVT(eff,2,CHARGE_rectU[type]+64,CHARGE_rectV[type]);
	ObjPrim_SetVertexUVT(eff,3,CHARGE_rectU[type]+64,CHARGE_rectV[type]+64);

	while(alpha<255 ) {
		alpha    += 255.0/15;
		angle01  += i2;
		angle02  += 180.0/60;
		radius01 -= 90.00/60;
		radius02  = radius03*sin(radius01);

		ObjRender_SetPosition(eff,x+16+radius02*cos(angle00),y+16+radius02*sin(angle00),0);
		ObjRender_SetScaleXYZ(eff,scale*i1,scale,1);
		ObjRender_SetAngleXYZ(eff,angle02,angle02,angle01);
		ObjPrim_SetVertexColor(eff,0,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexColor(eff,1,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexColor(eff,2,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexColor(eff,3,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexAlpha(eff,0,alpha);
		ObjPrim_SetVertexAlpha(eff,1,alpha);
		ObjPrim_SetVertexAlpha(eff,2,alpha);
		ObjPrim_SetVertexAlpha(eff,3,alpha);
		yield;
	}
	while(alpha>0 ) {
		alpha    -= 255.0/45;
		angle01  += i2;
		angle02  += 180.0/60;
		radius01 -= 90.00/60;
		radius02  = radius03*sin(radius01);

		ObjRender_SetPosition(eff,x+16+radius02*cos(angle00),y+16+radius02*sin(angle00),0);
		ObjRender_SetScaleXYZ(eff,scale*i1,scale,1);
		ObjRender_SetAngleXYZ(eff,angle02,angle02,angle01);
		ObjPrim_SetVertexColor(eff,0,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexColor(eff,1,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexColor(eff,2,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexColor(eff,3,R*alpha/255,G*alpha/255,B*alpha/255);
		ObjPrim_SetVertexAlpha(eff,0,alpha);
		ObjPrim_SetVertexAlpha(eff,1,alpha);
		ObjPrim_SetVertexAlpha(eff,2,alpha);
		ObjPrim_SetVertexAlpha(eff,3,alpha);
		yield;
	}
	Obj_Delete(eff);
}

//Circle Life Bar
let imgbar1 = GetCurrentScriptDirectory~"img/Lifebar01.png";
let imgbar2 = GetCurrentScriptDirectory~"img/Lifebar02.png";
task LifeCircleBar_Marker(enemy,movelong) {

	let marker	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let m_angle	= -90+360*movelong;
	let m_scale	= 1.0;
	let type	= 0;

	LoadTexture(imgbar2);

	ObjPrim_SetTexture(marker,imgbar2);
	ObjRender_SetAngleXYZ(marker,0,0,m_angle-90);
	ObjRender_SetBlendType(marker,BLEND_ALPHA);
	ObjPrim_SetPrimitiveType(marker,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(marker,4);
	ObjRender_SetScaleXYZ(marker,m_scale*0.83,m_scale,1);
	Obj_SetRenderPriorityI(marker,70);
	ObjPrim_SetVertexPosition(marker,0,-4,-4,0);
	ObjPrim_SetVertexPosition(marker,1,-4, 4,0);
	ObjPrim_SetVertexPosition(marker,2, 4,-4,0);
	ObjPrim_SetVertexPosition(marker,3, 4, 4,0);
	ObjPrim_SetVertexUVT(marker,0,0+8*type, 4);
	ObjPrim_SetVertexUVT(marker,1,0+8*type,12);
	ObjPrim_SetVertexUVT(marker,2,8+8*type, 4);
	ObjPrim_SetVertexUVT(marker,3,8+8*type,12);
	ObjPrim_SetVertexColor(marker,0,255,255,255);
	ObjPrim_SetVertexColor(marker,1,255,255,255);
	ObjPrim_SetVertexColor(marker,2,255,255,255);
	ObjPrim_SetVertexColor(marker,3,255,255,255);
        ObjPrim_SetVertexAlpha(marker,0,255);
	ObjPrim_SetVertexAlpha(marker,1,255);
	ObjPrim_SetVertexAlpha(marker,2,255);
	ObjPrim_SetVertexAlpha(marker,3,255);

	while(!Obj_IsDeleted(enemy)) {
		ObjRender_SetPosition(marker,ObjMove_GetX(enemy)+cos(m_angle)*64,ObjMove_GetY(enemy)+sin(m_angle)*64,0);
		yield;
	}
        Obj_Delete(marker);
}


//task LifeCircleBar_MarkerEx(enemy,movelong,delete){}
task LifeCircleBar_MarkerEx(enemy,movelong,delete) {

	let marker	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let m_angle	= -90+360*movelong;
	let m_scale	= 1.0;
	let m_alpha	= 255;
	let type	= 0;
        let maxlife	= ObjEnemy_GetInfo(enemy,INFO_LIFE);

	LoadTexture(imgbar2);

	ObjPrim_SetTexture(marker,imgbar2);
	ObjRender_SetAngleXYZ(marker,0,0,m_angle+90);
	ObjRender_SetBlendType(marker,BLEND_ALPHA);
	ObjPrim_SetPrimitiveType(marker,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(marker,4);
	ObjRender_SetScaleXYZ(marker,m_scale*0.83,m_scale,1);
	Obj_SetRenderPriorityI(marker,70);
	ObjPrim_SetVertexPosition(marker,0,-4,-4,0);
	ObjPrim_SetVertexPosition(marker,1,-4, 4,0);
	ObjPrim_SetVertexPosition(marker,2, 4,-4,0);
	ObjPrim_SetVertexPosition(marker,3, 4, 4,0);
	ObjPrim_SetVertexUVT(marker,0,0+8*type, 4);
	ObjPrim_SetVertexUVT(marker,1,0+8*type,12);
	ObjPrim_SetVertexUVT(marker,2,8+8*type, 4);
	ObjPrim_SetVertexUVT(marker,3,8+8*type,12);
	ObjPrim_SetVertexColor(marker,0,255,255,255);
	ObjPrim_SetVertexColor(marker,1,255,255,255);
	ObjPrim_SetVertexColor(marker,2,255,255,255);
	ObjPrim_SetVertexColor(marker,3,255,255,255);
        ObjPrim_SetVertexAlpha(marker,0,255);
	ObjPrim_SetVertexAlpha(marker,1,255);
	ObjPrim_SetVertexAlpha(marker,2,255);
	ObjPrim_SetVertexAlpha(marker,3,255);

	while(delete < ObjEnemy_GetInfo(enemy,INFO_LIFE)/maxlife) {
		ObjRender_SetPosition(marker,ObjMove_GetX(enemy)+cos(m_angle)*64,ObjMove_GetY(enemy)+sin(m_angle)*64,0);
		yield;
	}
	loop(30) {
		ObjRender_SetPosition(marker,ObjMove_GetX(enemy)+cos(m_angle)*64,ObjMove_GetY(enemy)+sin(m_angle)*64,0);
                ObjPrim_SetVertexAlpha(marker,0,m_alpha);
        	ObjPrim_SetVertexAlpha(marker,1,m_alpha);
        	ObjPrim_SetVertexAlpha(marker,2,m_alpha);
        	ObjPrim_SetVertexAlpha(marker,3,m_alpha);
		m_alpha -= 255/30;
		yield;
	}
	Obj_Delete(marker);
}


//task LifeCircleBar_A(enemy,long,slide,direct){}
task LifeCircleBar_A(enemy,long,slide,direct) {

	let bar1	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let bar2	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let maxlife	= ObjEnemy_GetInfo(enemy,INFO_LIFE);
	let vertex	= 722.0;
	let type	= 0;
	let i1		= 0;
	let i2		= -180.0;
	let i3		= 0;
	let i4		= 0;

	LoadTexture(imgbar2);

	ObjRender_SetPosition(bar1,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
	ObjPrim_SetTexture(bar1,imgbar2);
        ObjRender_SetBlendType(bar1,BLEND_ALPHA);
	ObjPrim_SetPrimitiveType(bar1,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(bar1,vertex);
        ObjRender_SetScaleXYZ(bar1,1.0,1.0,1);
        ObjRender_SetAngleXYZ(bar1,0,0,0);
	Obj_SetRenderPriorityI(bar1,70);

	ObjRender_SetPosition(bar2,ObjMove_GetX(enemy)+GetStgFrameLeft,ObjMove_GetY(enemy)+GetStgFrameTop,0);
	ObjPrim_SetTexture(bar2,imgbar2);
        ObjRender_SetBlendType(bar2,BLEND_ALPHA);
	ObjPrim_SetPrimitiveType(bar2,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(bar2,vertex);
        ObjRender_SetScaleXYZ(bar2,1.0,1.0,1);
        ObjRender_SetAngleXYZ(bar2,0,0,0);
	Obj_SetRenderPriorityI(bar2,70);

	loop(vertex) {
		ObjPrim_SetVertexPosition(bar1,i1  ,sin(i2)*68,cos(i2)*68,0);
		ObjPrim_SetVertexPosition(bar1,i1+1,sin(i2)*60,cos(i2)*60,0);
		ObjPrim_SetVertexUVT(bar1,i1  , 1+8*type,15);
		ObjPrim_SetVertexUVT(bar1,i1+1, 6+8*type,32);
		ObjPrim_SetVertexColor(bar1,i3,255,255,255);
		ObjPrim_SetVertexAlpha(bar1,i3,255);

		ObjPrim_SetVertexPosition(bar2,i1  ,sin(i2)*67,cos(i2)*67,0);
		ObjPrim_SetVertexPosition(bar2,i1+1,sin(i2)*61,cos(i2)*61,0);
		ObjPrim_SetVertexUVT(bar2,i1  , 1+8*type,39);
		ObjPrim_SetVertexUVT(bar2,i1+1, 6+8*type,56);
		ObjPrim_SetVertexColor(bar2,i3,255,255,255);
		ObjPrim_SetVertexAlpha(bar2,i3,0);

		i1 += 2;
		i2 += vertex/720.0;
		i3++;
	}	

	if(!direct) { loop(vertex) { ObjPrim_SetVertexColor(bar2,i4,255,255,255); ObjPrim_SetVertexAlpha(bar2,i4,255); i4++; }}

	loop(60) {
		if(direct){ yield; }
		ObjRender_SetPosition(bar1,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetPosition(bar2,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
//ObjEffect_ResizeVertexCount(bar2,vertex);
		loop(vertex/60) { ObjPrim_SetVertexColor(bar2,i4,255,255,255); ObjPrim_SetVertexAlpha(bar2,i4,255); i4++; }
	}

	i1 = 0;
	i2 = ((vertex/2.0)*slide)-180.0;
	i3 = 0;

	loop(720) {
		ObjPrim_SetVertexPosition(bar1,i1  ,sin(i2)*68,cos(i2)*68,0);
		ObjPrim_SetVertexPosition(bar1,i1+1,sin(i2)*60,cos(i2)*60,0);
		ObjPrim_SetVertexUVT(bar1,i1  ,1+8*type,16);
		ObjPrim_SetVertexUVT(bar1,i1+1,6+8*type,31);
		ObjPrim_SetVertexColor(bar1,i3,255,255,255);
                ObjPrim_SetVertexAlpha(bar1,i3,255);

		ObjPrim_SetVertexPosition(bar2,i1  ,sin(i2)*67,cos(i2)*67,0);
		ObjPrim_SetVertexPosition(bar2,i1+1,sin(i2)*61,cos(i2)*61,0);
		ObjPrim_SetVertexUVT(bar2,i1  , 1+8*type,40);
		ObjPrim_SetVertexUVT(bar2,i1+1, 6+8*type,55);
		ObjPrim_SetVertexColor(bar2,i3,255,255,255);
                ObjPrim_SetVertexAlpha(bar2,i3,255);

		i1 += 2;
		i2 += vertex/(720.0);
		i3++;
	}

	while(!Obj_IsDeleted(enemy)) {
	        i1 = 0;
	        i2 = ((vertex/2.0)*slide)-180.0;
	        i3 = 0;
                let resize = (ObjEnemy_GetInfo(enemy,INFO_LIFE)/maxlife)*vertex*long;
		ObjRender_SetPosition(bar1,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetPosition(bar2,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
//ObjEffect_ResizeVertexCount(bar2,(GetLife/maxlife)*vertex*long);
                ObjPrim_SetVertexCount(bar2,resize );
                loop(resize){
                       ObjPrim_SetVertexPosition(bar2,i1  ,sin(i2)*67,cos(i2)*67,0);
		       ObjPrim_SetVertexPosition(bar2,i1+1,sin(i2)*61,cos(i2)*61,0);
		       ObjPrim_SetVertexUVT(bar2,i1  , 1+8*type,40);
		       ObjPrim_SetVertexUVT(bar2,i1+1, 6+8*type,55);
		       ObjPrim_SetVertexColor(bar2,i3,255,255,255);
                       ObjPrim_SetVertexAlpha(bar2,i3,255);
		       i1 += 2;
		       i2 += vertex/720.0;
	               i3++;
                }
		yield;
	}
        Obj_Delete(bar1);
        Obj_Delete(bar2);
}


//task LifeCircleBar_B(enemy,long,slide,direct){}
task LifeCircleBar_B(enemy,long,slide,direct) {

	let bar		= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let maxlife	= ObjEnemy_GetInfo(enemy,INFO_LIFE);
	let vertex	= 730.0;
	let type	= 0;
	let i1		= 0;
	let i2		= ((vertex/2.0)*slide)-180;
	let i3		= 0;

	LoadTexture(imgbar2);

	ObjRender_SetPosition(bar,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
	ObjPrim_SetTexture(bar,imgbar2);
        ObjRender_SetBlendType(bar,BLEND_ALPHA);
	ObjPrim_SetPrimitiveType(bar,PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(bar,vertex*long);
        ObjRender_SetScaleXYZ(bar,1.0,1.0,1);
        ObjRender_SetAngleXYZ(bar,0,0,0);
	Obj_SetRenderPriorityI(bar,70);

	loop(vertex) {
		ObjPrim_SetVertexPosition(bar,i1  ,sin(i2)*67,cos(i2)*67,0);
		ObjPrim_SetVertexPosition(bar,i1+1,sin(i2)*61,cos(i2)*61,0);
		ObjPrim_SetVertexUVT(bar,i1  , 1+8*type,40);
		ObjPrim_SetVertexUVT(bar,i1+1, 6+8*type,55);
		ObjPrim_SetVertexColor(bar,i3,255,255,255);
                ObjPrim_SetVertexAlpha(bar,i3,0);

		i1 += 2;
		i2 += vertex/720.0;
		i3++;
	}	

	i3 = 0;
	if(direct) { loop(60) { yield; } }
	loop(vertex) { ObjPrim_SetVertexColor(bar,i3,255,255,255); ObjPrim_SetVertexAlpha(bar,i3,255); i3++; }

	while(!Obj_IsDeleted(enemy)) {
		ObjRender_SetPosition(bar,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
//ObjEffect_ResizeVertexCount(bar,vertex*long);
		yield;
	}
        Obj_Delete(bar);
}
//Magic Circle
let imgmagic1 = GetCurrentScriptDirectory~"img/magic01.png";
let imgmagic2 = GetCurrentScriptDirectory~"img/magic02.png";

task MagicCircleEx(enemy,direct) {

	CreateCommonDataArea("circle");

	let magic	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let alpha	= 200;
	let R		= 240*alpha/255;
	let G		= 240*alpha/255;
	let B		= 240*alpha/255;
	let anglez	= 0;
	let scale1	= 0;
	let scale2	= 0;
	let scale3	= 0;

	LoadTexture(imgmagic1);

	ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
	ObjPrim_SetTexture(magic,imgmagic1);
	ObjRender_SetBlendType(magic,BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(magic,PRIMITIVE_TRIANGLESTRIP);
	Obj_SetRenderPriorityI(magic,25);
	ObjRender_SetScaleXYZ(magic,scale1,scale1,1);
	ObjPrim_SetVertexCount(magic,4);
	ObjPrim_SetVertexPosition(magic,0,-128,-128,0);
	ObjPrim_SetVertexPosition(magic,1,-128, 128,0);
	ObjPrim_SetVertexPosition(magic,2, 128,-128,0);
	ObjPrim_SetVertexPosition(magic,3, 128, 128,0);
	ObjPrim_SetVertexUVT(magic,0,  0,  0);
	ObjPrim_SetVertexUVT(magic,1,  0,256);
	ObjPrim_SetVertexUVT(magic,2,256,  0);
	ObjPrim_SetVertexUVT(magic,3,256,256);
	ObjPrim_SetVertexColor(magic,0,R,G,B);
	ObjPrim_SetVertexColor(magic,1,R,G,B);
	ObjPrim_SetVertexColor(magic,2,R,G,B);
	ObjPrim_SetVertexColor(magic,3,R,G,B);

	loop(60) {
		scale2 += 90/60;
		scale3  = 0.90*sin(scale2);
		scale1  = 0.10*sin(scale2);
		anglez  = 360*sin(-scale2);

		ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetScaleXYZ(magic,scale3+scale1,scale3+scale1,1);
		ObjRender_SetAngleXYZ(magic,0,0,anglez);
		if(direct) { yield; }
	}
	if(!direct) { anglez = GetAreaCommonData("circle","circleanglez",0); scale2 = GetAreaCommonData("circle","circlescale",0); }
	while(!Obj_IsDeleted(enemy)) {
		anglez -= 360/60;
		scale2 += 360/120;
		scale1  = 0.10*sin(scale2);

		ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetScaleXYZ(magic,scale3+scale1,scale3+scale1,1);
		ObjRender_SetAngleXYZ(magic,0,0,anglez);
		SetAreaCommonData("circle","circleanglez",anglez);
		SetAreaCommonData("circle","circlescale",scale2);
		yield;
	}
        Obj_Delete(magic);
}


task MagicCircleEx2(enemy,direct) {

	CreateCommonDataArea("circle");

	let magic	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let alpha	= 144;
	let R		= 240*alpha/255;
	let G		= 240*alpha/255;
	let B		= 240*alpha/255;
	let lean	= 28;
	let anglex	= 0;
	let angley	= 0;
	let anglez	= 0;
	let scale1	= 0;
	let scale2	= 0;
	let scale3	= 0;

	LoadTexture(imgmagic2);

	ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
	ObjPrim_SetTexture(magic,imgmagic2);
	ObjRender_SetBlendType(magic,BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(magic,PRIMITIVE_TRIANGLESTRIP);
	Obj_SetRenderPriorityI(magic,25);
	ObjRender_SetScaleXYZ(magic,scale1,scale1,1);
	ObjPrim_SetVertexCount(magic,4);
	ObjPrim_SetVertexPosition(magic,0,-128,-128,0);
	ObjPrim_SetVertexPosition(magic,1,-128, 128,0);
	ObjPrim_SetVertexPosition(magic,2, 128,-128,0);
	ObjPrim_SetVertexPosition(magic,3, 128, 128,0);
	ObjPrim_SetVertexUVT(magic,0,  0,  0);
	ObjPrim_SetVertexUVT(magic,1,  0,256);
	ObjPrim_SetVertexUVT(magic,2,256,  0);
	ObjPrim_SetVertexUVT(magic,3,256,256);
	ObjPrim_SetVertexColor(magic,0,R,G,B);
	ObjPrim_SetVertexColor(magic,1,R,G,B);
	ObjPrim_SetVertexColor(magic,2,R,G,B);
	ObjPrim_SetVertexColor(magic,3,R,G,B);

	loop(60) {
		scale2 += 90/60;
		scale3  = 0.90*sin(scale2);
		scale1  = 0.10*sin(scale2);
		anglez  = 360*sin(-scale2);
		anglex  = lean-lean*cos(anglez);
		angley  = lean-lean*sin(anglez);

		ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetScaleXYZ(magic,scale3+scale1,scale3+scale1,1);
		ObjRender_SetAngleXYZ(magic,anglex,angley,anglez);
		if(direct) { yield; }
	}
	if(!direct) { anglez = GetAreaCommonData("circle","circleanglez",0); scale2 = GetAreaCommonData("circle","circlescale",0); }
	while(!Obj_IsDeleted(enemy)) {
		anglez -= 90/135;
		anglex  = lean-lean*cos(anglez);
		angley  = lean-lean*sin(anglez);

		ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetScaleXYZ(magic,scale3+scale1,scale3+scale1,1);
		ObjRender_SetAngleXYZ(magic,anglex,angley,anglez);
		SetAreaCommonData("circle","circleanglez",anglez);
		yield;
	}
        Obj_Delete(magic);
}
//Timer
let imgtimer = GetCurrentScriptDirectory()~ "./img/Namber01_HD.png";
let TIME_RECT_01= [  0, 32, 64, 96,128,160,192,224,256,288,320];
	let TIME_RECT_02= [ 31, 63, 95,127,159,191,223,255,287,319,351];
	let TIME_RECT_03= 0;
	let TIME_RECT_04= 64;
let TIME_SCALE	= 1.0;
task DrawTimer03(type) {

	CreateCommonDataArea("time");

	let Enemy	= GetEnemyBossObjectID[0];
	let id		= [ObjPrim_Create(OBJ_PRIMITIVE_2D), ObjPrim_Create(OBJ_PRIMITIVE_2D), ObjPrim_Create(OBJ_PRIMITIVE_2D), ObjPrim_Create(OBJ_PRIMITIVE_2D), ObjPrim_Create(OBJ_PRIMITIVE_2D)];
	let rgb		= [255,255,255];
	let ms		= ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER)*60*(100/60)+(100/60);
	let py		= 0;
	let i		= 0;
	let timer1	= 9;
	let timer2	= 9;
	let timer3	= 9;
	let timer4	= 9;
	let scale1	= 1;
	let scale2	= 0;
	let scale3	= 0.25;
	let count1	= 0;
	let count2	= 0;
	let count3	= 0;
	let t_count	= 0;
	let t_alpha	= 255;
	let CenX	= GetStgFrameWidth/2.0+32;
	let MinY	= GetStgFrameTop();

	LoadTexture(imgtimer);
	
	loop(5) {
		ObjPrim_SetTexture(id[i],imgtimer);
		Obj_SetRenderPriorityI(id[i],85);
		ObjPrim_SetPrimitiveType(id[i],PRIMITIVE_TRIANGLESTRIP);
		ObjPrim_SetVertexCount(id[i],4);
		ObjPrim_SetVertexPosition(id[i],0,-8.0,-16.0,0);
		ObjPrim_SetVertexPosition(id[i],1,-8.0, 16.0,0);
		ObjPrim_SetVertexPosition(id[i],2, 8.0,-16.0,0);
		ObjPrim_SetVertexPosition(id[i],3, 8.0, 16.0,0);
		i++;
	}
	ObjRender_SetScaleXYZ(id[2],0.6*TIME_SCALE,0.7*TIME_SCALE,1.00);
	ObjRender_SetScaleXYZ(id[3],0.6*TIME_SCALE,0.7*TIME_SCALE,1.00);
	ObjRender_SetScaleXYZ(id[4],1.0*TIME_SCALE,1.0*TIME_SCALE,1.00);
	ObjPrim_SetVertexUVT(id[4],0,TIME_RECT_01[10],TIME_RECT_03);
	ObjPrim_SetVertexUVT(id[4],1,TIME_RECT_01[10],TIME_RECT_04);
	ObjPrim_SetVertexUVT(id[4],2,TIME_RECT_02[10],TIME_RECT_03);
	ObjPrim_SetVertexUVT(id[4],3,TIME_RECT_02[10],TIME_RECT_04);

	if(type==2) { t_alpha = 0; }

	while(t_count<90&&!Obj_IsDeleted(Enemy)) {
		i = 0;
		ms -= 100/60;
		t_count += 90/60;
		timer1 = truncate(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER)%10);
		timer2 = truncate((ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER)%100)/10);
		timer3 = truncate(ms%10);
		timer4 = truncate((ms%100)/10);

		if(t_alpha <255) { t_alpha += 255/30; }
		if(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER)> 99) { timer1 = 9; timer2 = 9; timer3 = 9; timer4 = 9; }
		if(ms <  100/60) { timer1 = 0; timer2 = 0; timer3 = 0; timer4 = 0; }

		if(timer2<1) { rgb =  [255,128,128];
			if(timer1<5) { rgb =  [255, 64, 64]; scale3 = 0.5; }
		}
		else { rgb =  [255,255,255]; }

		count1++;
		if(count3>=10) { scale3 = 0; }
		if(count1>=60) { count2 = 1; count1 = 0; }
		if(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER)<=9&&count2==1) {
			scale2 += 180/6;
			if(scale2==180) { count2 = 0; scale2 = 0; count3++; }
		}
		scale1 = 1+scale3*sin(scale2);

		alternative(type)
		case(0) { py = -32*sin(t_count)+32; }
		case(1) { py =  32*sin(t_count); }
		case(2) { py =  16; }
		case(3) { py = -16*sin(t_count)+16; }
		case(4) { py =  16*sin(t_count); }
		case(5) { py =  32; }
		case(6) { py =  0;  }
		case(7) { py =  32; }

		SetAreaCommonData("time","time1",timer1);
		SetAreaCommonData("time","time2",timer2);
		SetAreaCommonData("time","time3",timer3);
		SetAreaCommonData("time","time4",timer4);

		ObjRender_SetPosition(id[0],CenX   ,MinY+10+py,0);
		ObjRender_SetPosition(id[1],CenX-12,MinY+10+py,0);
		ObjRender_SetPosition(id[2],CenX+22,MinY+13+py,0);
		ObjRender_SetPosition(id[3],CenX+15,MinY+13+py,0);
		ObjRender_SetPosition(id[4],CenX+8 ,MinY+10+py,0);
		ObjRender_SetScaleXYZ(id[0],scale1*TIME_SCALE,scale1*TIME_SCALE,1.00);
		ObjRender_SetScaleXYZ(id[1],scale1*TIME_SCALE,scale1*TIME_SCALE,1.00);
		ObjPrim_SetVertexUVT(id[0],0,TIME_RECT_01[timer1],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[0],1,TIME_RECT_01[timer1],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[0],2,TIME_RECT_02[timer1],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[0],3,TIME_RECT_02[timer1],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[1],0,TIME_RECT_01[timer2],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[1],1,TIME_RECT_01[timer2],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[1],2,TIME_RECT_02[timer2],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[1],3,TIME_RECT_02[timer2],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[2],0,TIME_RECT_01[timer3],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[2],1,TIME_RECT_01[timer3],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[2],2,TIME_RECT_02[timer3],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[2],3,TIME_RECT_02[timer3],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[3],0,TIME_RECT_01[timer4],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[3],1,TIME_RECT_01[timer4],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[3],2,TIME_RECT_02[timer4],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[3],3,TIME_RECT_02[timer4],TIME_RECT_04);
		loop(5) {
			ObjPrim_SetVertexAlpha(id[i],0,t_alpha);
			ObjPrim_SetVertexAlpha(id[i],1,t_alpha);
			ObjPrim_SetVertexAlpha(id[i],2,t_alpha);
			ObjPrim_SetVertexAlpha(id[i],3,t_alpha);
			ObjPrim_SetVertexColor(id[i],0,rgb[0],rgb[1],rgb[2]);
			ObjPrim_SetVertexColor(id[i],1,rgb[0],rgb[1],rgb[2]);
			ObjPrim_SetVertexColor(id[i],2,rgb[0],rgb[1],rgb[2]);
			ObjPrim_SetVertexColor(id[i],3,rgb[0],rgb[1],rgb[2]);
			i++;
		}
		yield;
	}
	while(!Obj_IsDeleted(Enemy)) {
		i = 0;
		ms -= 100/60;
		timer1 = truncate(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER)%10);
		timer2 = truncate((ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER)%100)/10);
		timer3 = truncate(ms%10);
		timer4 = truncate((ms%100)/10);

		if(t_alpha <255) { t_alpha += 255/30; }
		if(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER)> 99) { timer1 = 9; timer2 = 9; timer3 = 9; timer4 = 9; }
		if(ms <  100/60) { timer1 = 0; timer2 = 0; timer3 = 0; timer4 = 0; }

		if(timer2<1) { rgb =  [255,128,128];
			if(timer1<5) { rgb =  [255, 64, 64]; scale3 = 0.5; }
		}
		else { rgb =  [255,255,255]; }

		count1++;
		if(count3>=10) { scale3 = 0; }
		if(count1>=60) { count2 = 1; count1 = 0; }
		if(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_TIMER)<=9&&count2==1) {
			scale2 += 180/6;
			if(scale2==180) { count2 = 0; scale2 = 0; count3++; }
		}
		scale1 = 1+scale3*sin(scale2);

		SetAreaCommonData("time","time1",timer1);
		SetAreaCommonData("time","time2",timer2);
		SetAreaCommonData("time","time3",timer3);
		SetAreaCommonData("time","time4",timer4);

		ObjRender_SetPosition(id[0],CenX   ,MinY+10+py,0);
		ObjRender_SetPosition(id[1],CenX-12,MinY+10+py,0);
		ObjRender_SetPosition(id[2],CenX+22,MinY+13+py,0);
		ObjRender_SetPosition(id[3],CenX+15,MinY+13+py,0);
		ObjRender_SetPosition(id[4],CenX+8 ,MinY+10+py,0);
		ObjRender_SetScaleXYZ(id[0],scale1*TIME_SCALE,scale1*TIME_SCALE,1.00);
		ObjRender_SetScaleXYZ(id[1],scale1*TIME_SCALE,scale1*TIME_SCALE,1.00);
		ObjPrim_SetVertexUVT(id[0],0,TIME_RECT_01[timer1],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[0],1,TIME_RECT_01[timer1],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[0],2,TIME_RECT_02[timer1],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[0],3,TIME_RECT_02[timer1],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[1],0,TIME_RECT_01[timer2],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[1],1,TIME_RECT_01[timer2],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[1],2,TIME_RECT_02[timer2],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[1],3,TIME_RECT_02[timer2],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[2],0,TIME_RECT_01[timer3],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[2],1,TIME_RECT_01[timer3],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[2],2,TIME_RECT_02[timer3],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[2],3,TIME_RECT_02[timer3],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[3],0,TIME_RECT_01[timer4],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[3],1,TIME_RECT_01[timer4],TIME_RECT_04);
		ObjPrim_SetVertexUVT(id[3],2,TIME_RECT_02[timer4],TIME_RECT_03);
		ObjPrim_SetVertexUVT(id[3],3,TIME_RECT_02[timer4],TIME_RECT_04);
		loop(5) {
			ObjPrim_SetVertexAlpha(id[i],0,t_alpha);
			ObjPrim_SetVertexAlpha(id[i],1,t_alpha);
			ObjPrim_SetVertexAlpha(id[i],2,t_alpha);
			ObjPrim_SetVertexAlpha(id[i],3,t_alpha);
			ObjPrim_SetVertexColor(id[i],0,rgb[0],rgb[1],rgb[2]);
			ObjPrim_SetVertexColor(id[i],1,rgb[0],rgb[1],rgb[2]);
			ObjPrim_SetVertexColor(id[i],2,rgb[0],rgb[1],rgb[2]);
			ObjPrim_SetVertexColor(id[i],3,rgb[0],rgb[1],rgb[2]);
			i++;
		}
		yield;
	}
	i=0;
	loop(5) {
		Obj_Delete(id[i]);
		i++;
	}
}