#include"./../System/LIB/Event_Const.dnh"

function ExplosionA1(objEnemy,starcolor,circlecolor) {
	NotifyEventAll(EV_EXPLODE,[[1],[objEnemy],starcolor,circlecolor]);
}
function ExplosionA2(objEnemy,starcolor,circlecolor) {
	NotifyEventAll(EV_EXPLODE,[[2],[objEnemy],starcolor,circlecolor]);
}
function ExplosionB1(objEnemy,circlecolor,starcolor) {
	NotifyEventAll(EV_EXPLODE,[[3],[objEnemy],starcolor,circlecolor]);
}
function ExplosionB2(objEnemy,circlecolor,starcolor) {
	NotifyEventAll(EV_EXPLODE,[[4],[objEnemy],starcolor,circlecolor]);
}
function ExplosionB3(objEnemy,circlecolor,starcolor) {
	NotifyEventAll(EV_EXPLODE,[[5],[objEnemy],starcolor,circlecolor]);
}
function ExplosionB4(objEnemy,circlecolor,starcolor) {
	NotifyEventAll(EV_EXPLODE,[[6],[objEnemy],starcolor,circlecolor]);
}
function ExplosionRainbow(objEnemy) {
	NotifyEventAll(EV_EXPLODE,[[7],[objEnemy]]);
}
function ExplosionPPC(objEnemy,color) {
	NotifyEventAll(EV_EXPLODE,[[8],[objEnemy],color]);
}
function ExplosionPPCRainbow(objEnemy) {
	NotifyEventAll(EV_EXPLODE,[[9],[objEnemy]]);
}
task ConcentrationA1(objEnemy,duration,speed,radius,color) {
	NotifyEventAll(EV_CONCENTRATION,[[1],[objEnemy],[duration],[speed],[radius],color]);
}
task ConcentrationA2(objEnemy,duration,speed,radius,color) {
	NotifyEventAll(EV_CONCENTRATION,[[2],[objEnemy],[duration],[speed],[radius],color]);
}
task ConcentrationA3(objEnemy,speed,radius,color) {
	NotifyEventAll(EV_CONCENTRATION,[[3],[objEnemy],[speed],[radius],color]);
}
task ConcentrationA4(objEnemy,duration,speed,radius,color) {
	NotifyEventAll(EV_CONCENTRATION,[[4],[objEnemy],[duration],[speed],[radius],color]);
}
task ConcentrationBinaryA1(objEnemy,duration,speed,radius,color) {
}
task ConcentrationBinaryA2(objEnemy,duration,speed,radius,color) {
}
task ConcentrationRainbowA1(objEnemy,duration,speed,radius) {
	NotifyEventAll(EV_CONCENTRATION,[[5],[objEnemy],[duration],[speed],[radius]]);
}
task ConcentrationB1(objEnemy,duration,speed,layer,color) {
	NotifyEventAll(EV_CONCENTRATION,[[6],[objEnemy],[duration],[speed],[layer],color]);
}
task ConcentrationB2(objEnemy,duration,speed,layer,color) {
	NotifyEventAll(EV_CONCENTRATION,[[7],[objEnemy],[duration],[speed],[layer],color]);
}

task SpellBurst(x,y,maxscale,R,G,B) {
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	
	ObjPrim_SetTexture(obj, PSD ~ "IMG/Effect/ConcentrationCircle.png");
	ObjSprite2D_SetSourceRect(obj,0,0,256,256);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriorityI(obj, 50);
	
	
	let alpha = 1.8;
	let scale = 0;
	let dscale = 0.15*maxscale;
	loop(30){
		scale += dscale;
		if(dscale>0){ dscale = dscale^1.05; }
		if(alpha>0) { alpha -= 1/15; }
		else { alpha = 0; }
		ObjRender_SetColor(obj, R*alpha, G*alpha, B*alpha);
		ObjRender_SetPosition(obj, x, y, 0);
		ObjRender_SetScaleXYZ(obj, scale, scale, 1);
		yield;
	}
	Obj_Delete(obj);
}
task ConcCircle(x,y,speed,r,color) {
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	
	let RGB = color;
	
	let alpha = 0;
	let scale = 2.5*(r/200);
	
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriorityI(obj,41);
	ObjPrim_SetTexture(obj, PSD ~ "IMG/Effect/ConcentrationCircle.png");
	ObjSprite2D_SetSourceRect(obj, 0, 0, 256, 256);
	ObjSprite2D_SetDestCenter(obj);
	
	while(!Obj_IsDeleted(obj)) {
		ObjRender_SetPosition(obj, x, y, 0);
		ObjRender_SetScaleXYZ(obj, scale, scale, scale);
		ObjRender_SetColor(obj, RGB[0]*(alpha/255), RGB[1]*(alpha/255), RGB[2]*(alpha/255));
		if(alpha<255) { alpha+=255/(r-90)*speed; }
		scale-=speed/100;
		if(scale<=0) { Obj_Delete(obj); }
		yield;
	}
}

task ScreenShake(duration,range) {
let shake = range;
	loop(duration) {
		Set2DCameraFocusX(Get2DCameraX + rand(-shake, shake));
		Set2DCameraFocusY(Get2DCameraY + rand(-shake, shake));
		shake-=range/duration;
		yield;
		Reset2DCamera;
	}
}