function Bat(X, Y, Health, Color, tangible){
let obj = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(obj);
ObjEnemy_SetLife(obj, Health);
Render(obj, X, Y, Color);
return(obj);
	task Render(obj, X, Y, Color){
	let x = 64;
	let y = 64;
	let frame = 0;
	let alpha = 0;
	ObjMove_SetPosition(obj,X,Y);
	
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/Ingame/bat.png");
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	Obj_SetRenderPriorityI(obj, 25);
	ObjSprite2D_SetSourceRect(obj,0,0,x,y);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetAlpha(obj,255);
	ObjRender_SetAngleXYZ(obj,0,0,0);
	ObjRender_SetScaleXYZ(obj,1,1,0);
	ObjRender_SetColor(obj, Color[0], Color[1], Color[2]);
	Alpha(alpha);
	
	task Alpha(alpha){
		ascent(i in 0..255/4){
		ObjRender_SetAlpha(obj,alpha+i*5);
		yield;
		}
	}
	while(ObjEnemy_GetInfo(obj, INFO_LIFE) > 10){
		if(tangible==true){
		ObjEnemy_SetIntersectionCircleToShot(obj,ObjMove_GetX(obj),ObjMove_GetY(obj),6);
		ObjEnemy_SetIntersectionCircleToPlayer(obj,ObjMove_GetX(obj),ObjMove_GetY(obj),8);}
		
		if(frame<4){ObjSprite2D_SetSourceRect(obj,0,0,x,y);}
		if(frame>=4 && frame<8){ObjSprite2D_SetSourceRect(obj,x,0,x*2,y);}
		if(frame>=8 && frame<12){ObjSprite2D_SetSourceRect(obj,x*2,0,x*3,y);}
		if(frame>=12 && frame<16){ObjSprite2D_SetSourceRect(obj,x*3,0,x*4,y);}
	frame++;
	if(frame>=16){frame=0;}
	yield;
	}
	if(ObjEnemy_GetInfo(obj, INFO_LIFE) > 2){
	DeathBat(obj, ObjMove_GetX(obj),ObjMove_GetY(obj), Color);}
	yield;
	Obj_Delete(obj);
	
		task DeathBat(obj, Xp,Yp, color){
		let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(obj2,GetCurrentScriptDirectory ~ "./img/Ingame/bat.png");
		ObjRender_SetBlendType(obj2, BLEND_ADD_ARGB);
		Obj_SetRenderPriorityI(obj2, 25);
		ObjSprite2D_SetSourceRect(obj2,0,0,x,y);
		ObjSprite2D_SetDestCenter(obj2);
		ObjRender_SetAlpha(obj2,255);
		ObjRender_SetAngleXYZ(obj2,0,0,0);
		ObjRender_SetScaleXYZ(obj2,1,1,0);
		ObjRender_SetPosition(obj2, Xp,Yp, 1);
		
		ObjRender_SetColor(obj2, Color[0], Color[1], Color[2]);
		
		let count = 0;
		let random = rand(-2, 2);
			loop(255){
			ObjRender_SetScaleXYZ(obj2, 1-(count/122), 1-(count/122), 1);
			ObjRender_SetAlpha(obj2, 255-count*2);
			ObjRender_SetAngleXYZ(obj2,0,0,0+count*0.7*random);
			ObjRender_SetPosition(obj2, ObjRender_GetX(obj2), ObjRender_GetY(obj2)+0.6, 1);
			count++;
			yield;
			}
		Obj_Delete(obj2);
		}
	}
}

task PhantomEye(long){ //Totally not stolen from MPP.
	let id		= ObjPrim_Create(OBJ_SPRITE_2D);
	let id2		= [ObjPrim_Create(OBJ_SPRITE_2D),
					ObjPrim_Create(OBJ_SPRITE_2D)];
	let i		= 0;
	let kill	= 0;
	let sca1	= 0;
	let scaA	= 0;
	
	let CenX = GetStgFrameWidth/2;
	let CenY = GetStgFrameHeight/2;
	
	SetCommonData("Phantom", true);
	PlaySound(GetCurrentScriptDirectory ~ "./se/phantom.wav", 255);
		
	ObjRender_SetPosition(id,CenX,CenY,0);
	ObjPrim_SetTexture(id,GetCurrentScriptDirectory ~ "./img/Ingame/back2.png");
	Obj_SetRenderPriorityI(id,60);
	ObjRender_SetBlendType(id,BLEND_SUBTRACT);
	ObjRender_SetScaleXYZ(id,1.2,1.2,0);
	ObjSprite2D_SetSourceRect(id,0,0,666,666);
	ObjSprite2D_SetDestCenter(id);
	ObjRender_SetColor(id,sca1*32,sca1*255,sca1*255);
	
	loop(2){
		ObjRender_SetPosition(id2[i],CenX,CenY,0);
		ObjPrim_SetTexture(id2[i],GetCurrentScriptDirectory ~ "./img/Ingame/eye.png");
		Obj_SetRenderPriorityI(id2[i],71);
		ObjRender_SetBlendType(id2[0],BLEND_ALPHA);
		ObjRender_SetBlendType(id2[1],BLEND_SUBTRACT);
		ObjRender_SetScaleXYZ(id2[i],1,sca1,0);
		ObjSprite2D_SetSourceRect(id2[i],0,0,256,64);
		ObjSprite2D_SetDestCenter(id2[i]);
		ObjRender_SetAlpha(id2[0],200);
		i++;
	}i=0;
	
	while(kill<long){
		kill++;
		ObjRender_SetPosition(id,CenX+rand(-4,4),CenY+rand(-4,4),0);
		ObjRender_SetColor(id,sca1*32,sca1*255,sca1*255);
		ObjRender_SetAngleZ(id,kill);
		
		if(sca1<1){scaA+=2;}
		sca1=1*sin(scaA);
		ObjRender_SetPosition(id2[0],CenX+rand(-4,4),CenY+rand(-4,4),0);
		ObjRender_SetPosition(id2[1],CenX+rand(-12,12),CenY+rand(-12,12),0);
		ObjRender_SetScaleXYZ(id2[0],7-sca1*4,sca1*3,0);
		ObjRender_SetScaleXYZ(id2[1],7-sca1*4,sca1*3,0);
		yield;
	}
	while(sca1>0){
		kill++;
		ObjRender_SetPosition(id,CenX+rand(-4,4),CenY+rand(-4,4),0);
		ObjRender_SetColor(id,sca1*32,sca1*255,sca1*255);
		ObjRender_SetAngleZ(id,kill);
		
		scaA+=10;
		sca1=1*sin(scaA);
		ObjRender_SetPosition(id2[0],CenX+rand(-4,4),CenY+rand(-4,4),0);
		ObjRender_SetPosition(id2[1],CenX+rand(-8,8),CenY+rand(-8,8),0);
		ObjRender_SetScaleXYZ(id2[0],3,sca1*3,0);
		ObjRender_SetScaleXYZ(id2[1],3,sca1*3,0);
		yield;
	}
	Obj_Delete(id);
	Obj_Delete(id2[0]);
	Obj_Delete(id2[1]);
	SetCommonData("Phantom", false);
}

function ScytheSlash(X, Y, ang, dir){
let obj = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(obj);
ObjMove_SetAngle(obj, ang);
Render(obj, X, Y, ang, dir);
return(obj);
	task Render(obj, X, Y, ang, dir){
	let x = 128;
	let y = 256;
	let frame = 0;
	let alpha = 0;
	ObjMove_SetPosition(obj,X,Y);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/Ingame/slash.png");
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriorityI(obj, 25);
	ObjSprite2D_SetSourceRect(obj,0,0,x,y);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetAlpha(obj,255);
	ObjRender_SetAngleXYZ(obj,0,0,ang);
	ObjRender_SetScaleXYZ(obj,1,1*dir,0);
		loop{
			if(frame<4){ObjSprite2D_SetSourceRect(obj,0,0,x,y);}
			if(frame>=4 && frame<8){ObjSprite2D_SetSourceRect(obj,x,0,x*2,y);}
			if(frame>=8 && frame<12){ObjSprite2D_SetSourceRect(obj,x*2,0,x*3,y);}
			if(frame>=12 && frame<16){ObjSprite2D_SetSourceRect(obj,x*3,0,x*4,y);}
			if(frame>=16 && frame<20){ObjSprite2D_SetSourceRect(obj,0,y,x,y*2);}
			if(frame>=20 && frame<24){ObjSprite2D_SetSourceRect(obj,x,y,x*2,y*2);}
			if(frame>=24 && frame<28){ObjSprite2D_SetSourceRect(obj,x*2,y,x*3,y*2);}
			if(frame>=28 && frame<32){ObjSprite2D_SetSourceRect(obj,x*3,y,x*4,y*2);}
			frame++;
			if(frame>=32){Obj_Delete(obj)}
		yield;
		}
	}
}