let auraimg=GetCurrentScriptDirectory~"lib\eff01.png";
LoadGraphic(auraimg);

task aurastart(r, g, b)
{
	loop(200)
	{
	yield;
	aura(r, g, b);
	}
}
task aura(r,g,b)
{
	yield;
	loop
	{
	auralift(rand_int(20,40),rand(3.5, 4.5),rand_int(90,120),r,g,b);
	auraparticle(rand(1.2,1.7),rand_int(0,360),rand(0.015,0.05),r,g,b);
	loop(200){yield;}
	}
}

task auralift(width,liftspeed,lifttime,r,g,b) {
	let obj=Obj_Create(OBJ_EFFECT);
	let lift=0;
	let alpha=255;
	Obj_SetPosition(obj,GetEnemyX,GetEnemyY);
	ObjEffect_SetTexture(obj,auraimg);
	ObjEffect_SetLayer(obj,1);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexUV(obj, 1, 50, 0);
	ObjEffect_SetVertexUV(obj, 2, 0, 46);
	ObjEffect_SetVertexUV(obj, 3, 50, 46);
	while(Obj_BeDeleted(obj)==false)
	{
		ObjEffect_SetVertexXY(obj, 0, -width, -lift);
		ObjEffect_SetVertexXY(obj, 1, width, -lift);
		ObjEffect_SetVertexXY(obj, 2, -width, 0);
		ObjEffect_SetVertexXY(obj, 3, width, 0);
		ascent(i in 0..4){ObjEffect_SetVertexColor(obj,i,alpha,r,g,b);}
		Obj_SetPosition(obj,GetEnemyX,GetEnemyY);
		lift+=liftspeed;
		alpha-=5;
		if(lift>lifttime){Obj_Delete(obj);}
		yield;
	}
}

task auraparticle(scale,rot,scalespeed,r,g,b){
	let obj = Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj,GetEnemyX, GetEnemyY);
	ObjEffect_SetTexture(obj,auraimg);
	ObjEffect_SetLayer(obj,1);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexUV(obj, 0, 52, 0);
	ObjEffect_SetVertexUV(obj, 1, 94, 0);
	ObjEffect_SetVertexUV(obj, 2, 52, 44);
	ObjEffect_SetVertexUV(obj, 3, 94, 44);
	ObjEffect_SetVertexXY(obj, 0, -21, -21);
	ObjEffect_SetVertexXY(obj, 1, 21, -21);
	ObjEffect_SetVertexXY(obj, 2, -21, 21);
	ObjEffect_SetVertexXY(obj, 3, 21, 21);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetScale(obj,scale,scale);
	ObjEffect_SetAngle(obj,0,0,rot);
	while(Obj_BeDeleted(obj)==false)
	{
	ascent(i in 0..4){ObjEffect_SetVertexColor(obj,i,128,r,g,b);}
	Obj_SetPosition(obj,GetEnemyX, GetEnemyY);	
	ObjEffect_SetScale(obj,scale,scale);
	if(scale<0.25){Obj_Delete(obj);}
	scale-=scalespeed;
	yield;
	}
}