#include "./selibrary.txt"

function wait(w) { loop(w) { yield; } } 

function BossShotSound(tar,vol,cap){
	while(!Obj_IsDeleted(tar)) {
	if(ObjEnemy_GetInfo(tar,INFO_SHOT_HIT_COUNT)>0&&ObjEnemy_GetInfo(tar,INFO_LIFE)>cap){
	SE_Play(GetCurrentScriptDirectory ~ "sfx/damage1.wav", vol);
	yield;
	}
	if(ObjEnemy_GetInfo(tar,INFO_SHOT_HIT_COUNT)>0&&ObjEnemy_GetInfo(tar,INFO_LIFE)<cap){
	SE_Play(GetCurrentScriptDirectory ~ "sfx/damage2.wav", vol);
	yield;
	}
	yield;
	}
}

function TimerCountdown(obj){
	loop{
	if(ObjEnemyBossScene_GetInfo(obj, INFO_TIMER)<11){SE_Play(GetCurrentScriptDirectory ~ "sfx/timeout.wav", 150);}
	if(ObjEnemyBossScene_GetInfo(obj, INFO_TIMER)<6){SE_Play(GetCurrentScriptDirectory ~ "sfx/timeout2.wav", 150);}
	wait(60);
	}
}

let blurswitch = false;

task MotionBlur //totally not stolen from sample
{
	let renderTexture = [GetReservedRenderTargetName(0), GetReservedRenderTargetName(1)];
	
	SetInvalidRenderPriorityA1(20, 79);


	let objCurentFrame = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objCurentFrame, 80);
	ObjRender_SetPermitCamera(objCurentFrame, false);

	let objOldFrame = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objOldFrame, 0);
	ObjRender_SetPermitCamera(objOldFrame, false);
	ObjRender_SetAlpha(objOldFrame, 200);
	Obj_SetVisible(objOldFrame, true);

	let frame = 0;
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0)
	{
		let currentFrameTexture = renderTexture[frame % 2];

		RenderToTextureA1(currentFrameTexture, 20, 79, true);

		if(frame >= 1) 
		{
			let oldFrameTexture = renderTexture[(frame - 1) % 2];
			ObjPrim_SetTexture(objOldFrame, oldFrameTexture);
			ObjSprite2D_SetSourceRect(objOldFrame, 32, 16, 416, 464);
			ObjSprite2D_SetDestRect(objOldFrame, 32, 16, 416, 464);
			RenderToTextureB1(currentFrameTexture, objOldFrame, false);
		}
		if(blurswitch==true){break;}
		ObjPrim_SetTexture(objCurentFrame, currentFrameTexture);
		ObjSprite2D_SetSourceRect(objCurentFrame, 32, 16, 416, 464);
		ObjSprite2D_SetDestRect(objCurentFrame, 32, 16, 416, 464);

		frame++;
		yield;
	}
	Obj_Delete(objCurentFrame);
	Obj_Delete(objOldFrame);
	ClearInvalidRenderPriority();
}