task ExpA1(enemyObj,type,color,length){
	let angle = rand(0,360);
	ObjEnemy_SetLife(enemyObj,1);
	ObjEnemy_SetDamageRate(enemyObj,0,0);
	NotifyEventAll(PLAY_SFX,["se_enep01",IntToString(65)~""]);
	
	if(length == "Short"){
		ScreenShake(45,35);
		DefaultCircle(enemyObj,3,color,255,0,0);
		loop(35){
			ExplodeObject(type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),rand(2,6),angle,"WHITE");
			angle+=360/70;
			ExplodeObject(type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),rand(2,6),angle,color);
			angle+=360/70;
		}
	}
	
	if(length == "Long"){
		ScreenShake(30,30);
		DefaultCircle(enemyObj,3,color,0,0,0);
		ObjMove_SetAngle(enemyObj,rand(0,359));
		ObjMove_SetSpeed(enemyObj,0.4);
		StartSlow(TARGET_ALL,45);
		loop(90/4){
			ExplodeObject(type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),rand(1.5,4),rand(0,360),"WHITE");
			ExplodeObject(type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),rand(1.5,4),rand(0,360),color);
			loop(4){ yield; }
		}
		StopSlow(TARGET_ALL);
		ObjEnemy_SetLife(enemyObj,0);
		Obj_Delete(enemyObj);
		DefaultCircle(enemyObj,3,color,0,0,0);
		ScreenShake(90,65);
		NotifyEventAll(PLAY_SFX,["se_enep01",IntToString(65)~""]);
		loop(40){
			ExplodeObject(type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),rand(2,6),angle,"WHITE");
			angle+=360/80;
			ExplodeObject(type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),rand(2,6),angle,color);
			angle+=360/80;
		}
	}
}

task ExpA2(x,y,type,color,length){
	let angle = rand(0,360);
	let posx = x;
	let posy = y;
	NotifyEventAll(PLAY_SFX,["se_enep01",IntToString(65)~""]);
	
	if(length == "Short"){
		ScreenShake(45,35);
		DefaultCircle2(posx,posy,3,color,255,0,0);
		loop(35){
			ExplodeObject(type,posx,posy,rand(2,6),angle,"WHITE");
			angle+=360/70;
			ExplodeObject(type,posx,posy,rand(2,6),angle,color);
			angle+=360/70;
		}
	}
	
	if(length == "Long"){
		ScreenShake(30,30);
		DefaultCircle2(posx,posy,3,color,0,0,0);
		StartSlow(TARGET_ALL,45);
		loop(90/4){
			ExplodeObject(type,posx,posy,rand(1.5,4),rand(0,360),"WHITE");
			ExplodeObject(type,posx,posy,rand(1.5,4),rand(0,360),color);
			loop(4){ yield; }
		}
		StopSlow(TARGET_ALL);
		DefaultCircle2(posx,posy,3,color,0,0,0);
		ScreenShake(90,65);
		NotifyEventAll(PLAY_SFX,["se_enep01",IntToString(65)~""]);
		loop(40){
			ExplodeObject(type,posx,posy,rand(2,6),angle,"WHITE");
			angle+=360/80;
			ExplodeObject(type,posx,posy,rand(2,6),angle,color);
			angle+=360/80;
		}
	}
}

task DefaultCircle(enemyObj,maxscale,color,x,y,z){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		let path = GetCurrentScriptDirectory ~ "./img/Default_Effect.png";
		ObjPrim_SetTexture(obj,path);
		Obj_SetRenderPriorityI(obj,41);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(path),GetTextureHeight(path));
		ObjSprite2D_SetDestCenter(obj);
	
	let RGB = color;
	
	let alpha = 255;
	let scale = 0;
	let dscale = 0.4;
	
	ObjRender_SetPosition(obj,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),0);
	ObjRender_SetAngleXYZ(obj,x,y,z);
	ascent(i in 0..20){
		scale = maxscale*sin(90*i/20);
		alpha -=255/20;
		ObjRender_SetColor(obj,RGB[0]*(alpha/255),RGB[1]*(alpha/255),RGB[2]*(alpha/255));
		ObjRender_SetScaleXYZ(obj,scale,scale,scale);
		yield;
	}
	Obj_Delete(obj);
}

task DefaultCircle2(x,y,maxscale,color,x,y,z){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		let path = GetCurrentScriptDirectory ~ "./img/Default_Effect.png";
		ObjPrim_SetTexture(obj,path);
		Obj_SetRenderPriorityI(obj,41);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(path),GetTextureHeight(path));
		ObjSprite2D_SetDestCenter(obj);
	
	let RGB = color;
	
	let alpha = 255;
	let scale = 0;
	let dscale = 0.4;
	
	ObjRender_SetPosition(obj,x,y,0);
	ObjRender_SetAngleXYZ(obj,x,y,z);
	ascent(i in 0..20){
		scale = maxscale*sin(90*i/20);
		alpha -=255/20;
		ObjRender_SetColor(obj,RGB[0]*(alpha/255),RGB[1]*(alpha/255),RGB[2]*(alpha/255));
		ObjRender_SetScaleXYZ(obj,scale,scale,scale);
		yield;
	}
	Obj_Delete(obj);
}

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

task ExplodeObject(type,x,y,speed,dir,color){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		let path = GetCurrentScriptDirectory ~ "./img/" ~ type ~ ".png";
		ObjPrim_SetTexture(obj,path);
		Obj_SetRenderPriorityI(obj,41);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(path),GetTextureHeight(path));
		ObjSprite2D_SetDestCenter(obj);
	
	let alpha = 200;
	let spinA = rand(0,180);
	let spinB = rand(0,180);
	let colour = [];
	let scale = 0;
	
	alternative(color)
		case("RED"){
			colour = [255,0,0];
		}
		case("ORANGE"){
			colour = [255,128,0];
		}
		case("YELLOW"){
			colour = [255,255,0];
		}
		case("LGREEN"){
			colour = [128,255,0];
		}
		case("GREEN"){
			colour = [0,255,0];
		}
		case("AQUA"){
			colour = [0,128,255];
		}
		case("BLUE"){
			colour = [0,0,255];
		}
		case("PURPLE"){
			colour = [255,0,128];
		}
		case("PINK"){
			colour = [255,0,255];
		}
		case("WHITE"){
			colour = [255,255,255];
		}
		
	while(!Obj_IsDeleted(obj)){
		ObjRender_SetPosition(obj,x,y,0);
		ObjRender_SetScaleXYZ(obj,scale,scale,scale);
		ObjRender_SetAngleXYZ(obj,spinA,spinB,spinA);
		ObjRender_SetAlpha(obj,alpha);
		ObjRender_SetColor(obj,colour[0]*(alpha/255),colour[1]*(alpha/255),colour[2]*(alpha/255));
		if(scale<0.38 && speed>0){ scale+=0.03; }
		if(speed>1){ speed+=0.03; }
		if(speed<=1 && alpha>0){ alpha-=15; scale-=0.035; }
		if(alpha<=0){ Obj_Delete(obj); }
		spinA+=rand(1,2);
		spinB+=rand(-1,-2);
		x+=speed*cos(dir);
		y+=speed*sin(dir);
		yield;
	}
}