#include"./../System/Minoriko_Effect.txt"
#include"./LoadGraphics.txt"
let f = 0;
let attack = 0;
let animFrame = 0;
let animFrame2 = 0;
let animFrame3 = 0;

task animateBossM{
	let dir;
	let speed;
	let hover = 0;
	let w = 5;
	if(GetCommonData("WaveCircle",0) != 0){
		TWaveCircle();}

	ObjPrim_SetTexture(bossObj,animation);
	Obj_SetRenderPriorityI(bossObj,41);
	while(!Obj_IsDeleted(bossObj)){
	ObjSprite2D_SetDestRect(bossObj,-32,-32+20*cos(hover),32,32+20*cos(hover));
	hover+=1;
		dir = ObjMove_GetAngle(bossObj);
		speed = ObjMove_GetSpeed(bossObj);

		if(speed==0){
			ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame < w){ObjSprite2D_SetSourceRect(bossObj,0,128,64,192);f=1;}
			if(animFrame >= w*5){ObjSprite2D_SetSourceRect(bossObj,64,128,128,192);f=2;}
			animFrame2 = 0;}
		else if(cos(dir) > 0){
			ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame2 < w){ObjSprite2D_SetSourceRect(bossObj,0,192,64,256);f=5;}
			if(animFrame2 >= w && animFrame2 < w*2){ObjSprite2D_SetSourceRect(bossObj,64,192,128,256);f=6;}
			if(animFrame2 >= w*2){ObjSprite2D_SetSourceRect(bossObj,128,192,192,256);f=7;}}
		else if(cos(dir) < 0){
			ObjRender_SetAngleXYZ(bossObj,0,180,0);
			if(animFrame2 < w){ObjSprite2D_SetSourceRect(bossObj,0,192,64,256);f=5;}
			if(animFrame2 >= w && animFrame2 < w*2){ObjSprite2D_SetSourceRect(bossObj,64,192,128,256);f=6;}
			if(animFrame2 >= w*2){ObjSprite2D_SetSourceRect(bossObj,128,192,192,256);f=7;}}

		if(attack == 1){
			ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame3 < w){ObjSprite2D_SetSourceRect(bossObj,0,128,64,192);f=5;}
			if(animFrame3 >= w && animFrame3 < w*2){ObjSprite2D_SetSourceRect(bossObj,64,128,128,192);f=6;}
			if(animFrame3 >= w*2){ObjSprite2D_SetSourceRect(bossObj,128,128,192,192);f=7;}
			animFrame3++;}
		if(attack == 0){animFrame3 = 0;}
		animFrame++;
		animFrame2++;
		if(animFrame > w*10){animFrame = 0;}
		yield;}
	return;}

task animateBossS{
	let dir;
	let speed;
	let hover = 0;
	let w = 5;
	TWaveCircle();

	ObjPrim_SetTexture(bossObj,animation);
	Obj_SetRenderPriorityI(bossObj,41);
	while(!Obj_IsDeleted(bossObj)){
	ObjSprite2D_SetDestRect(bossObj,-32,-32+20*cos(hover),32,32+20*cos(hover));
	hover+=2;
		dir = ObjMove_GetAngle(bossObj);
		speed = ObjMove_GetSpeed(bossObj);

		if(speed==0){
			ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame < w){ObjSprite2D_SetSourceRect(bossObj,0,0,64,64);f=1;}
			if(animFrame >= w && animFrame < w*3){ObjSprite2D_SetSourceRect(bossObj,64,0,128,64);f=2;}
			if(animFrame >= w*3 && animFrame < w*5){ObjSprite2D_SetSourceRect(bossObj,128,0,192,64);f=3;}
			if(animFrame >= w*5 && animFrame < w*7){ObjSprite2D_SetSourceRect(bossObj,192,0,256,64);f=4;}
			if(animFrame >= w*7 && animFrame < w*9){ObjSprite2D_SetSourceRect(bossObj,128,0,192,64);f=3;}
			if(animFrame >= w*9){ObjSprite2D_SetSourceRect(bossObj,64,0,128,64);f=2;}
			animFrame2 = 0;}
		else if(cos(dir) > 0){
			ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame2 < w){ObjSprite2D_SetSourceRect(bossObj,0,64,64,128);f=5;}
			if(animFrame2 >= w && animFrame2 < w*2){ObjSprite2D_SetSourceRect(bossObj,64,64,128,128);f=6;}
			if(animFrame2 >= w*2 && animFrame2 < w*3){ObjSprite2D_SetSourceRect(bossObj,128,64,192,128);f=7;}
			if(animFrame2 >= w*3){ObjSprite2D_SetSourceRect(bossObj,192,64,256,128);f=8;}}
		else if(cos(dir) < 0){
			ObjRender_SetAngleXYZ(bossObj,0,180,0);
			if(animFrame2 < w){ObjSprite2D_SetSourceRect(bossObj,0,64,64,128);f=9;}
			if(animFrame2 >= w && animFrame2 < w*2){ObjSprite2D_SetSourceRect(bossObj,64,64,128,128);f=10;}
			if(animFrame2 >= w*2 && animFrame2 < w*3){ObjSprite2D_SetSourceRect(bossObj,128,64,192,128);f=11;}
			if(animFrame2 >= w*3){ObjSprite2D_SetSourceRect(bossObj,192,64,256,128);f=12;}}
		animFrame++;
		animFrame2++;
		if(animFrame > w*11){animFrame = 0;}
		yield;}
	return;}

task animateBossSAura{
	let ang = 1;
	let hover = 0;
		while(!Obj_IsDeleted(bossObj)){
			let boss = ObjPrim_Create(OBJ_SPRITE_2D);
			ObjPrim_SetTexture(boss,animation);
			Obj_SetRenderPriorityI(boss,40);
			ObjRender_SetBlendType(boss,BLEND_ADD_ARGB);
			ObjSprite2D_SetDestRect(boss,-32,-32+20*cos(hover),32,32+20*cos(hover));
			ObjRender_SetPosition(boss,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
			if(f==1){ObjSprite2D_SetSourceRect(boss,0,0,64,64);ang=1;}
			if(f==2){ObjSprite2D_SetSourceRect(boss,64,0,128,64);ang=1;}
			if(f==3){ObjSprite2D_SetSourceRect(boss,128,0,192,64);ang=1;}
			if(f==4){ObjSprite2D_SetSourceRect(boss,192,0,256,64);ang=1;}
			if(f==5){ObjSprite2D_SetSourceRect(boss,0,64,64,128);ang=1;}
			if(f==6){ObjSprite2D_SetSourceRect(boss,64,64,128,128);ang=1;}
			if(f==7){ObjSprite2D_SetSourceRect(boss,128,64,192,128);ang=1;}
			if(f==8){ObjSprite2D_SetSourceRect(boss,192,64,256,128);ang=1;}

			if(f==9){ObjSprite2D_SetSourceRect(boss,0,64,64,128);ang=2;}
			if(f==10){ObjSprite2D_SetSourceRect(boss,64,64,128,128);ang=2;}
			if(f==11){ObjSprite2D_SetSourceRect(boss,128,64,192,128);ang=2;}
			if(f==12){ObjSprite2D_SetSourceRect(boss,192,64,256,128);ang=2;}
		if(ang==1){ObjRender_SetAngleXYZ(boss,0,0,0);}
		if(ang==2){ObjRender_SetAngleXYZ(boss,0,180,0);}
		disappear(boss);
		hover+=2;wait(1);}
	task disappear(object){
	let alpha = 255;loop(30){ObjRender_SetAlpha(object,alpha);alpha-=255/30;yield;}Obj_Delete(object);}
	return;}

task Circle(path, RealmaxRadius, radset, angturn){
	let countVertex = 64;
	let listRadius = [];
	loop(countVertex){
		listRadius = listRadius ~ [0];}

	let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(obj, countVertex);
	Obj_SetRenderPriorityI(obj, 29);
	ObjPrim_SetTexture(obj, path);
	ObjRender_SetAlpha(obj,200);
	ascent(iVert in 0..countVertex / 2){
		let left = iVert * 24;
		let indexVert = iVert * 2;
		ObjPrim_SetVertexUVT(obj, indexVert + 0, left, 0);
		ObjPrim_SetVertexUVT(obj, indexVert + 1, left, 16);}

	let cx = ObjMove_GetX(bossObj);
	let cy = ObjMove_GetY(bossObj);
	let alpha = 255;
	let frame = 0;
	let angleRender = 0;
	let maxRadius = radset;

	while(!Obj_IsDeleted(bossObj)){
				let by = ObjMove_GetY(bossObj);
				let bx = ObjMove_GetX(bossObj);
				let my = ObjRender_GetY(obj);
				let mx = ObjRender_GetX(obj);				
				if(cx > bx+3 || cy > by+3 || cx < bx-3 || cy < by-3){ 
					cx = cx+(GetObjectDistance(obj, bossObj)/16)*cos(atan2(by-my, bx-mx));
					cy = cy+(GetObjectDistance(obj, bossObj)/16)*sin(atan2(by-my, bx-mx));}

			if(frame>45){
				if(maxRadius>RealmaxRadius){maxRadius-=16;}
				if(maxRadius<RealmaxRadius){maxRadius+=4;}}
			alpha += 1/120;
			alpha = min(alpha, 1);
			angleRender += (360 / countVertex / angturn);
			let rRate = 1+(angturn/200);

			ascent(iVert in 0..countVertex / 2){
				let indexVert = iVert * 2;
				let left = iVert * truncate(8+maxRadius/8); //частота
				let angle = (360 / (countVertex / 2 - 1) * iVert);

				let vx1 = listRadius[indexVert] * cos(angle);
				let vy1 = listRadius[indexVert] * sin(angle);
				ObjPrim_SetVertexPosition(obj, indexVert + 0, vx1, vy1, 0);

				let vx2 = listRadius[indexVert+1] * cos(angle);
				let vy2 = listRadius[indexVert+1] * sin(angle);
				ObjPrim_SetVertexPosition(obj, indexVert + 1, vx2, vy2, 0);

				if(frame >= 0){
					let dr = (maxRadius * rRate - listRadius[indexVert]) / 5;
					listRadius[indexVert] = listRadius[indexVert] + dr;}
				if(frame > 1){
					let rRateIn = rRate - 0.1;
					if(rRateIn < 1.5){rRateIn = 1.5;}
					let dr= (maxRadius * rRateIn - bossObj - listRadius[indexVert + 1]) / 5;
					listRadius[indexVert + 1] = listRadius[indexVert + 1] + dr;}
				ObjPrim_SetVertexUVT(obj, indexVert + 0, left, 0);
				ObjPrim_SetVertexUVT(obj, indexVert + 1, left, 16);}

			UpdateVertex;
			frame++;
		yield;}

	Obj_Delete(obj);
	
	task UpdateVertex{
		ObjRender_SetPosition(obj, cx, cy, 0);
		ObjRender_SetAngleZ(obj, angleRender);}}

task LoadShotData{
	let current = GetCurrentScriptDirectory();
	let path = current ~ "./../Functions/AllStarShot.txt";
	LoadEnemyShotData(path);}

task TEtama{
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,circle);
	Obj_SetRenderPriorityI(obj,29);
	ObjSprite2D_SetSourceRect(obj,0,0,256,256);
	ObjSprite2D_SetDestCenter(obj);
	let ro = 0;
	let zah = 4;
	let fern = 0;
	let scale = 0;
	loop(45){
		ObjRender_SetScaleXYZ(obj,scale,scale,0);
		ObjRender_SetPosition(obj,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
		ObjRender_SetAngleZ(obj,ro);
		ro+=8; scale+=1/45; yield;}
	loop(60){
		ObjRender_SetPosition(obj,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
		ObjRender_SetAngleZ(obj,ro);
		ro+=zah; zah-=7/60; yield;}
		let num = ObjRender_GetScaleX(obj);
		while(!Obj_IsDeleted(obj)){
			ObjRender_SetScaleXYZ(obj,num-fern*cos(scale),num-fern*cos(scale),0);
			ObjRender_SetPosition(obj,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
			ObjRender_SetAngleZ(obj,ro);
				if(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 0){break;}
				if(fern >= 0.1){fern=0.1;}
			ro+=zah; scale+=1;fern+=0.001; yield;}
		Obj_Delete(obj);}

task TSpellBG{
	let move = 0;
	let objbg = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg,card1);
	Obj_SetRenderPriorityI(objbg,23);
	ObjSprite2D_SetSourceRect(objbg,0,0,384,448);
	ObjSprite2D_SetDestRect(objbg,0,0,384,448);

	let objbg2 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg2,card2);
	Obj_SetRenderPriorityI(objbg2,22);
	ObjSprite2D_SetSourceRect(objbg2,0,-20000,384,448);
		while(!Obj_IsDeleted(bossObj)){
		ObjSprite2D_SetDestRect(objbg2,0,-20000+move,384,448+move);
				move+=1; yield;}
		Obj_Delete(objbg);
		Obj_Delete(objbg2);
	return;}

task THarvesterWreath(size,time,turn){ let count = 0;
	let move = 0; let sc = 3; let alpha = 0;
	let objbg = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg,wreath);
	Obj_SetRenderPriorityI(objbg,31);
	ObjSprite2D_SetSourceRect(objbg,0,0,256,256);
	ObjSprite2D_SetDestCenter(objbg);
	ObjRender_SetBlendType(objbg,BLEND_ALPHA);
		while(!Obj_IsDeleted(bossObj)){
			ObjRender_SetPosition(objbg,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
			if(count < 60){
				ObjRender_SetAngleZ(objbg,move);
				ObjRender_SetScaleXYZ(objbg,sc,sc,0);
				ObjRender_SetAlpha(objbg,alpha);
				alpha+=255/60;sc-=size/60;move+=5*turn;}
			if(count >= time){
				move = ObjRender_GetAngleZ(objbg);
				ObjRender_SetAngleZ(objbg,move+1*turn);}
			count++;yield;}
		Obj_Delete(objbg);
	return;}

task THarvesterWreathC(size,turn){
	let move = 0;
	let objbg = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg,wreath);
	Obj_SetRenderPriorityI(objbg,31);
	ObjSprite2D_SetSourceRect(objbg,0,0,256,256);
	ObjSprite2D_SetDestCenter(objbg);
	ObjRender_SetBlendType(objbg,BLEND_ALPHA);
	ObjRender_SetScaleXYZ(objbg,size,size,0);
		while(!Obj_IsDeleted(bossObj)){
			ObjRender_SetPosition(objbg,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
				ObjRender_SetAngleZ(objbg,move);
				move+=1*turn;
			yield;}
		Obj_Delete(objbg);
	return;}

task TLightAura{
	let red = 255;
	let green = 255;
	let blue = 255;
	let color = 10;
	while(!Obj_IsDeleted(bossObj)){
		if(color >= 80){color = 20;}
		if(color >= 10 && color < 20){
			CreateLight(red,green,blue);
			green-=30;blue-=30;}
		if(color >= 20 && color < 30){
			CreateLight(red,green,blue);
			green+=30;}
		if(color >= 30 && color < 40){
			CreateLight(red,green,blue);
			red-=30;}
		if(color >= 40 && color < 50){
			CreateLight(red,green,blue);
			blue+=30;}
		if(color >= 50 && color < 60){
			CreateLight(red,green,blue);
			green-=30;}
		if(color >= 60 && color < 70){
			CreateLight(red,green,blue);
			red+=30;}
		if(color >= 70 && color < 80){
			CreateLight(red,green,blue);
			blue-=30;}
		
		wait(22);
		color+=2;}
	
	task CreateLight(r,g,b){
		let m = 0; let z = 0;let alpha = 0; let sc = 1;
		let objbg2 = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(objbg2,light);
		Obj_SetRenderPriorityI(objbg2,30);
		ObjSprite2D_SetSourceRect(objbg2,0,0,382,382);
		ObjSprite2D_SetDestCenter(objbg2);
		ObjRender_SetColor(objbg2,r,g,b);
		loop(120){
			if(Obj_IsDeleted(bossObj)){break;}
			ObjRender_SetPosition(objbg2,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
			ObjRender_SetScaleXYZ(objbg2,sc,sc,0);
			ObjRender_SetAlpha(objbg2,alpha);
			ObjRender_SetAngleZ(objbg2,z);
			alpha+=10*sin(m);m+=3;z+=0.5;sc+=0.004;yield;}
		Obj_Delete(objbg2);}}

task TWaveCircle(){
	let renderTexture = GetReservedRenderTargetName(0);

	let frame = 0;
	let baseEffectRadius = 128;
	let outerFluct = 16;
	let effectRadius = 0;
	let priEffectMin = 20;
	let priEffectMax = 28;

	SetInvalidRenderPriorityA1(priEffectMin, priEffectMax);

	let frameWidth = GetStgFrameWidth();
	let frameHeight = GetStgFrameHeight();
	let frameLeft = GetStgFrameLeft();
	let frameRight = frameLeft + frameWidth;
	let frameTop = GetStgFrameTop();
	let frameBottom = frameTop + frameHeight;

	let objWave = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objWave, 25);
	ObjPrim_SetTexture(objWave, renderTexture);
	ObjSprite2D_SetSourceRect(objWave, frameLeft, frameTop, frameRight, frameBottom);
	ObjSprite2D_SetDestRect(objWave, 0, 0, frameWidth, frameHeight);
	Obj_SetRenderPriorityI(objWave, priEffectMax + 1);

	let pathShader = GetCurrentScriptDirectory ~ "./SamplePS03_HLSL.txt";
	ObjShader_SetShaderF(objWave, pathShader);
	ObjShader_SetTechnique(objWave, "TecWave");

	let objEnemy = GetEnemyBossObjectID[0];
	while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0){
		effectRadius = baseEffectRadius + outerFluct * sin(frame*4);

		let enemyX = ObjMove_GetX(objEnemy);
		let enemyY = ObjMove_GetY(objEnemy);

		RenderToTextureA1(renderTexture, priEffectMin, priEffectMax, true);

		ObjShader_SetFloat(objWave, "frame_", frame);
		ObjShader_SetFloat(objWave, "enemyX_", enemyX + frameLeft);
		ObjShader_SetFloat(objWave, "enemyY_", enemyY + frameTop);
		ObjShader_SetFloat(objWave, "waveRadius_", effectRadius);
		frame++;
		yield;}
	Obj_Delete(objWave);
	ClearInvalidRenderPriority();}

task TEnd{
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){yield;}
	let GetX = ObjMove_GetX(bossObj);
	let GetY = ObjMove_GetY(bossObj);
	SetCommonData("End",1);
	Obj_Delete(bossObj);
	DisappearAll();
	loop(35){yield;}
	DeleteShotAll(TYPE_ALL,TYPE_ITEM);
	CloseScript(GetOwnScriptID());}

task TLastEnd{
	let end = GetCurrentScriptDirectory ~ "./../Sounds/se_enep01.wav";
	LoadSound(end);
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){yield;}
	SetCommonData("EndMusic",1);
	let GetX = ObjMove_GetX(bossObj);
	let GetY = ObjMove_GetY(bossObj);
	StartSlow(TARGET_ALL,30);
	ScreenShake2(100,1);
	loop(10){
		DeleteShotInCircle(TYPE_ALL,TYPE_FADE,GetPlayerX,GetPlayerY,60);
		TExplosionA(GetX+rand(-30,30), GetY+rand(-30,30), rand(-60,60), 5, 0.2, 0.6);
		wait(10);}
	PlaySE(end);
	ScreenShake2(150,5);
	SetCommonData("End",1);
	DisappearAll();
	DeleteShotAll(TYPE_ALL,TYPE_ITEM);
	WhiteAll;
	loop(30){
		TExplosionA(GetX+rand(-30,30), GetY+rand(-30,30), rand(-60,60), 2, 0.2, 0.6);
		wait(5);}
	StopSlow(TARGET_ALL);
	Obj_Delete(bossObj);
	loop(35){yield;}
	CloseScript(GetOwnScriptID());}

task WhiteAll{
	let object = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(object,"");
	Obj_SetRenderPriorityI(object, 100);
	ObjSprite2D_SetSourceRect(object, 0, 0, 640, 480);
	ObjSprite2D_SetDestRect(object, 0, 0, 640, 480);
	let alpha = 0;
	loop(85){
	ObjRender_SetAlpha(object,alpha);
		alpha+=3.1; yield;}
	loop(180){yield;}
	Obj_Delete(object);}

task ScreenShake2(time,n){
	let shakeamount = n;
	let delay = 1;
	
	loop(time){
	Set2DCameraFocusX(GetStgFrameWidth/2+shakeamount);
	Set2DCameraFocusY(GetStgFrameHeight/2+shakeamount);
	loop(delay){yield;}
	Set2DCameraFocusX(GetStgFrameWidth/2-shakeamount);
	Set2DCameraFocusY(GetStgFrameHeight/2-shakeamount);
	loop(delay){yield;}
	Set2DCameraFocusX(GetStgFrameWidth/2+shakeamount);
	Set2DCameraFocusY(GetStgFrameHeight/2-shakeamount);
	loop(delay){yield;}
	Set2DCameraFocusX(GetStgFrameWidth/2-shakeamount);
	Set2DCameraFocusY(GetStgFrameHeight/2+shakeamount);
	loop(delay){yield;}}
	
	Set2DCameraFocusX(GetStgFrameWidth/2);
	Set2DCameraFocusY(GetStgFrameHeight/2);}

task DisappearAll(){
	let shotarray = [];
	let radius = 0;
	loop{
		radius+=25;
		shotarray = GetShotIdInCircleA2( GetPlayerX,GetPlayerY, radius, TARGET_ENEMY);
		ascent( i in 0..length(shotarray) ){DisappearBullet(ObjMove_GetX(shotarray[i]),ObjMove_GetY(shotarray[i]),shotarray[i]);}
		if(radius>=max(GetStgFrameWidth, GetStgFrameHeight)*1.25){break;}
	yield;}}

task DisappearBullet(x,y,ID){
	let sc = 1; let angleZ = round(rand(0,180)); let alpha = 255;
	let objde = ObjPrim_Create(OBJ_SPRITE_2D);
	let dc = GetShotDataInfoA1(ObjShot_GetImageID(ID),TARGET_ENEMY,INFO_DELAY_COLOR);
	Obj_SetRenderPriorityI(objde, 25);
	ObjPrim_SetTexture(objde, expl2);
	ObjRender_SetColor(objde,dc[0],dc[1],dc[2]);
	ObjSprite2D_SetSourceRect(objde, 96, 224, 128, 256);
	ObjSprite2D_SetDestCenter(objde);
	ObjRender_SetPosition(objde,x,y,0);
		while(!Obj_IsDeleted(objde)){
			loop(15){
				ObjRender_SetAngleZ(objde,angleZ);
				ObjRender_SetScaleXYZ(objde,sc,sc,0);
				ObjRender_SetAlpha(objde,alpha);
				angleZ+=5;sc-=0.1;alpha-=20;
				loop(2){yield;}
		Obj_Delete(ID);}
	Obj_Delete(objde);}}

task DisappearBulletEffect(x,y,ID,r,g,b){
	let sc = 2; let angleZ = round(rand(0,180)); let alpha = 255;
	let objde = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objde, 25);
	ObjPrim_SetTexture(objde, expl2);
	ObjRender_SetColor(objde,r,g,b);
	ObjSprite2D_SetSourceRect(objde, 96, 224, 128, 256);
	ObjSprite2D_SetDestCenter(objde);
	ObjRender_SetBlendType(objde,BLEND_ADD_ARGB);
	ObjRender_SetPosition(objde,x,y,0);
		while(!Obj_IsDeleted(objde)){
			loop(15){
				ObjRender_SetAngleZ(objde,angleZ);
				ObjRender_SetScaleXYZ(objde,sc,sc,0);
				ObjRender_SetAlpha(objde,alpha);
				angleZ+=2;sc-=0.2; alpha-=20;
				loop(2){yield;}
		Obj_Delete(ID);}
	Obj_Delete(objde);}}

function wait(w){loop(w){yield;}}
function CenterX{return GetStgFrameWidth/2;}
function CenterY{return GetStgFrameHeight/2;}
function rand_int(min,max){return round(rand(min,max));}