task DeleteShotWave(type,x,y,speed) {
	let r = 0;
	if(type==1){
		loop(120){
			DeleteShotInCircle(TYPE_ALL,TYPE_ITEM,x,y,r);
			r+=speed;
			yield;
		}
	}
	if(type==2){
		loop(120){
			let ShotAll = GetShotIdInCircleA2(GetStgFrameWidth/2,GetStgFrameHeight/2,r,TARGET_ENEMY);
			ascent(i in 0..length(ShotAll)) {
				BulletDeleteEffect(ObjMove_GetX(ShotAll[i]),ObjMove_GetY(ShotAll[i]),ObjShot_GetImageID(ShotAll[i]));
				Obj_Delete(ShotAll[i]);
			}
			r+=speed;
			yield;
		}
	}
	if(type==3){
		loop(120){
			let ShotAll = GetShotIdInCircleA2(GetStgFrameWidth/2,GetStgFrameHeight/2,r,TARGET_ENEMY);
			ascent(i in 0..length(ShotAll)) {
				Break(ObjMove_GetX(ShotAll[i]),ObjMove_GetY(ShotAll[i]),ShotAll[i]);
				Obj_Delete(ShotAll[i]);
			}
			r+=speed;
			yield;
		}
	}
}

task Break(x,y,ID){
	let Path = GetCurrentScriptDirectory ~ "./img/BulletBreak2.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let timer = 1;
	let s = 64;
	let color = [];
	if(ID==ID_INVALID){break;}



	Obj_SetRenderPriorityI(obj, 49);
	ObjPrim_SetTexture(obj, Path);
	color = GetShotDataInfoA1(ObjShot_GetImageID(ID),TARGET_ENEMY,INFO_DELAY_COLOR);
	ObjRender_SetColor(obj,color[0],color[1],color[2]);
	Obj_Delete(ID);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	ObjSprite2D_SetSourceRect(obj, 0, 0, 32, GetTextureHeight(Path));
	ObjSprite2D_SetDestCenter(obj);
	
	ObjRender_SetScaleXYZ(obj, 0.5, 0.5, 0.5);
	ObjRender_SetAngleXYZ(obj,0,0,round(rand(0,315)));
	ObjRender_SetPosition(obj,x,y,125);


	Animate;
	ascent(i in 0..8){
	if(ID==ID_INVALID){break;}
		ObjSprite2D_SetSourceRect(obj, s*i, 0, s*(i+1), GetTextureHeight(Path));
		loop(4){ yield;}

	}
	ascent(i in 0..8){
	if(ID==ID_INVALID){break;}
		ObjSprite2D_SetSourceRect(obj, s*i, 0, s*(i+1), GetTextureHeight(Path));
		loop(4){ yield;}

	}
	ascent(i in 0..8){
	if(ID==ID_INVALID){break;}
		ObjSprite2D_SetSourceRect(obj, s*i, 0, s*(i+1), GetTextureHeight(Path));
		loop(4){ yield;}

	}
	
	task Animate{
	let scale = 1;
	let sw = 0;
	
	while(scale<2){
		scale+=0.05;

		ObjRender_SetScaleXYZ(obj,scale,scale,scale);
		yield;
		}
		while(scale>0){
			scale-=0.05;

			ObjRender_SetScaleXYZ(obj,scale,scale,scale);
			yield;
		}
		ObjRender_SetScaleXYZ(obj,0,0,scale);
		Obj_Delete(obj);
	}

}

task BulletBreak(x,y,color){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let w = 3;
	let count = 0;
	let speed = rand(1.3,2);
	let dir = rand(0,360);
	Obj_SetRenderPriorityI(obj,49);
	ObjRender_SetPosition(obj,x,y,0);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/BulletBreak.png");
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAngleXYZ(obj,0,0,rand(0,360));
	ObjRender_SetColor(obj,color[0],color[1],color[2]);
	
	loop(24) {
		if(count>=w*0) { ObjSprite2D_SetSourceRect(obj,0,0,32,32); }
		if(count>=w*1) { ObjSprite2D_SetSourceRect(obj,32,0,64,32); }
		if(count>=w*2) { ObjSprite2D_SetSourceRect(obj,64,0,96,32); }
		if(count>=w*3) { ObjSprite2D_SetSourceRect(obj,96,0,128,32); }
		if(count>=w*4) { ObjSprite2D_SetSourceRect(obj,128,0,160,32); }
		if(count>=w*5) { ObjSprite2D_SetSourceRect(obj,160,0,192,32); }
		if(count>=w*6) { ObjSprite2D_SetSourceRect(obj,192,0,224,32); }
		if(count>=w*7) { ObjSprite2D_SetSourceRect(obj,224,0,256,32); }
		ObjSprite2D_SetDestCenter(obj);
	
		ObjRender_SetPosition(obj,x,y,0);
		if(speed>0) { speed-=0.10; }
		x+=speed*cos(dir);
		y+=speed*sin(dir);
		count++;
		yield;
	}
	Obj_Delete(obj);
}

function BulletDeleteEffect(xpos,ypos,graphic) {
	let DelayColor = GetShotDataInfoA1(graphic,TARGET_ENEMY,INFO_DELAY_COLOR);
	if(xpos<GetStgFrameWidth+20 && xpos>-20 && ypos<GetStgFrameHeight+20 && ypos>-20) {
		if(graphic>=284 && graphic<=291) {
			loop(3) { BulletBreak(xpos+rand(-10,10),ypos+rand(-8,8),[DelayColor[0],DelayColor[1],DelayColor[2]]); }
		}
		if(graphic>=265 && graphic<=272) {
			loop(3) { BulletBreak(xpos+rand(-10,10),ypos+rand(-8,8),[DelayColor[0],DelayColor[1],DelayColor[2]]); }
		}
		if(graphic>=324 && graphic<=331) {
			loop(3) { BulletBreak(xpos+rand(-10,10),ypos+rand(-8,8),[DelayColor[0],DelayColor[1],DelayColor[2]]); }
		}
		if(graphic>=292 && graphic<=307) {
			loop(8) { BulletBreak(xpos+rand(-20,20),ypos+rand(-23,23),[DelayColor[0],DelayColor[1],DelayColor[2]]); }
		}
		if(graphic>=383 && graphic<=390) {
			loop(5) { BulletBreak(xpos+rand(-20,20),ypos+rand(-18,18),[DelayColor[0],DelayColor[1],DelayColor[2]]); }
		}
		if(graphic>=399 && graphic<=408) {
			loop(5) { BulletBreak(xpos+rand(-20,20),ypos+rand(-18,18),[DelayColor[0],DelayColor[1],DelayColor[2]]); }
		}
		if(graphic>=272 && graphic<287) {
			loop(5) { BulletBreak(xpos+rand(-20,20),ypos+rand(-18,18),[DelayColor[0],DelayColor[1],DelayColor[2]]); }
		}
		if(graphic>=355 && graphic<=370) {
			loop(8) { BulletBreak(xpos+rand(-25,25),ypos+rand(-23,23),[DelayColor[0],DelayColor[1],DelayColor[2]]); }
		}
		else { BulletBreak(xpos,ypos,[DelayColor[0],DelayColor[1],DelayColor[2]]); }
	}
}