task ConEffect(x, y, angl, num, spd, scale, type, rad, ang, loops, frames, color){
	ascent(i in 0..loops){
	Concentrate(x, y, angl, num, spd, scale, type, rad, ang, color);
	loop(frames){yield;}
	}
}

task Concentrate(x, y, angl, num, spd, scale, type, rad, ang, color){
	ascent(i in 0..num){
	Effect(x, y, angl+i*360/num, spd, scale, type, rad, ang, color);
	}
}

task Effect(x, y, num, spd, scale, type, rad, ang, color){
let obj = ObjPrim_Create(OBJ_SPRITE_2D);

let ghost = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(ghost);


let tex = GetCurrentScriptDirectory ~ "img/" ~ type ~ ".png";
let random = rand(-2, 2);


	ObjPrim_SetTexture(obj, tex);
	Obj_SetRenderPriorityI(obj, 50);
	ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(tex),GetTextureHeight(tex));
	ObjSprite2D_SetDestCenter(obj);	
	ObjRender_SetScaleXYZ(obj,scale,scale,0);
	ObjRender_SetAngleXYZ(obj,0,0,rand(0,360));
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	ObjRender_SetColor(obj, color[0], color[1], color[2]);
	ObjRender_SetAlpha(obj, 0);
	ObjRender_SetPosition(obj, x+rad*cos(num), y+rad*sin(num), 0);
	ObjMove_SetPosition(ghost, x,y);
	
	AlphaController(obj, spd);
	MoveEffect(obj, x,y, ghost,  num, spd, rad, random, scale, ang);
}

task AlphaController(obj, spd){
let alpha = 0;
	ascent(i in 0..10*spd){
	ObjRender_SetAlpha(obj, alpha);
	alpha+=i*10;
	yield;
	}
}

task MoveEffect(obj,x,y, tar, num, spd, rad, random, scale, ang){
let angle = ObjRender_GetAngleZ(obj);
let rotate = 0;
	while(!Obj_IsDeleted(obj)){
	let dist = GetObjectDistance(obj, tar);
	ObjRender_SetPosition(obj, x+rad*cos(num), y+rad*sin(num), 0);
	ObjRender_SetAngleZ(obj, angle+rotate);
	ObjRender_SetScaleXYZ(obj, scale, scale, 1);
	scale-=0.005*spd;
	rotate+=random;
	num+=ang;
	rad-=spd;
	if(dist <= 1){Obj_Delete(obj);}
	yield;
	}
}