task BurstA1(enemyObj,type,colour,sound){

	if(sound == "Short"){
		NotifyEventAll(PLAY_SFX,["se_enep02",IntToString(65)~""]);
	}
	if(sound == "Long"){
		NotifyEventAll(PLAY_SFX,["se_don00",IntToString(65)~""]);
	}
	
	let angle = rand(0,360);
	
		alternative(colour)
			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];
			}
		
	loop(30){
		BurstObject(enemyObj,type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),angle,[255,255,255]);
		angle+=360/60;
		BurstObject(enemyObj,type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),angle,colour);
		angle+=360/60;
	}
	BurstCircle(enemyObj,2.5*(240/200),colour);
}

task BurstA1_Rainbow(enemyObj,type,sound){

	if(sound == "Short"){
		NotifyEventAll(PLAY_SFX,["se_enep02",IntToString(65)~""]);
	}
	if(sound == "Long"){
		NotifyEventAll(PLAY_SFX,["se_don00",IntToString(65)~""]);
	}
	
	let angle = rand(0,360);
	let colourchoice;
	let colour = [128,128,128];
	let pick = 0;
	
	loop(30){
		checkrainbow;
		BurstObject(enemyObj,type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),angle,[255,255,255]);
		angle+=360/40;
		BurstObject(enemyObj,type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),angle,colourchoice);
		angle+=360/40;
		BurstObject(enemyObj,type,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),angle,colourchoice);
		angle+=360/40;
	}
	BurstCircle(enemyObj,2.5*(240/200),colour);
	
	function checkrainbow{
	
		pick+=1;
		
		if(pick >= 10){
			pick = 1;
		}
		
		if(pick <= 0){
			pick = 1;
		}
		
		alternative(pick)
		case(1){
			colourchoice = [255,0,0];
		}
		case(2){
			colourchoice = [255,128,0];
		}
		case(3){
			colourchoice = [255,255,0];
		}
		case(4){
			colourchoice = [128,255,0];
		}
		case(5){
			colourchoice = [0,255,0];
		}
		case(6){
			colourchoice = [0,128,255];
		}
		case(7){
			colourchoice = [0,0,255];
		}
		case(8){
			colourchoice = [128,0,255];
		}
		case(9){
			colourchoice = [255,0,255];
		}	
		return colourchoice;
	}
}

task BurstCircle(enemyObj,maxscale,colour){
	
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		let path = GetCurrentScriptDirectory ~ "./img/ConcentrationCircle.png";
		ObjPrim_SetTexture(obj,path);
		Obj_SetRenderPriorityI(obj,40);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(path),GetTextureHeight(path));
		ObjSprite2D_SetDestCenter(obj);
	
	let alpha = 255;
	let scale = 0;
	
	ObjRender_SetColor(obj,colour[0],colour[1],colour[2]);
	
	ascent(i in 0..30){
		if(ObjEnemy_GetInfo(enemyObj,INFO_LIFE)>0){
			scale = maxscale*sin(90*i/30);
			alpha -=255/30;
			ObjRender_SetAlpha(obj,alpha);
			ObjRender_SetPosition(obj,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),0);
			ObjRender_SetScaleXYZ(obj,scale,scale,scale);
			yield;
		}
	}
	Obj_Delete(obj);
}

task BurstObject(enemyObj,type,x,y,dir,color){
	let alpha = 255;
	let speed = rand(2,8);
	let spinA = rand(0,180);
	let spinB = rand(0,180);
	let Red = color[0];
	let Green = color[1];
	let Blue = color[2];
	let scale = 0;
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		let path = GetCurrentScriptDirectory ~ "./img/" ~ type ~ ".png";
		ObjPrim_SetTexture(obj,path);
		Obj_SetRenderPriorityI(obj,40);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(path),GetTextureHeight(path));
		ObjSprite2D_SetDestCenter(obj);
	
	while(!Obj_IsDeleted(obj) && ObjEnemy_GetInfo(enemyObj,INFO_LIFE)>0){
		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,Red*(alpha/255),Green*(alpha/255),Blue*(alpha/255));
		if(scale<0.38 && speed>0){ scale+=0.03; }
		if(speed>1){ speed+=0.09; }
		if(speed>=2 && alpha>0){ alpha-=3; scale-=0.0035; }
		if(alpha<=0){ break; }
		spinA+=rand(1,2);
		spinB+=rand(-1,-2);
		x+=speed*cos(dir);
		y+=speed*sin(dir);
		yield;
	}
	Obj_Delete(obj);
}