function TCheckHp(obj){
	if(ObjEnemy_GetInfo(obj,INFO_LIFE)<=0){
		break;
	}
}

task TEnemyHitboxStart(obj,n){
	ObjEnemy_SetDamageRate(obj,0,0);
	loop(n){yield;}
	ObjEnemy_SetDamageRate(obj,100,100);
	while(!Obj_IsDeleted(obj)){
		let objScene=GetEnemyBossSceneObjectID();
		if(IsPlayerSpellActive==true&&ObjEnemyBossScene_GetInfo(objScene,INFO_IS_SPELL)==true){
			ObjEnemy_SetDamageRate(obj,0,0);
		}else{
			ObjEnemy_SetDamageRate(obj,100,100);
		}
	yield;
	}
}

let objPlayer;
objPlayer=GetPlayerObjectID();

function getAtanAngle(obj,obj2){
	let angle=atan2(ObjMove_GetY(obj2)-ObjMove_GetY(obj),ObjMove_GetX(obj2)-ObjMove_GetX(obj));
	return angle;
}

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

function GetClipMinX{
	return 0;
}

function GetClipMinY{
	return 0;
}

function GetClipMaxX{
	return GetStgFrameWidth;
}

function GetClipMaxY{
	return GetStgFrameHeight;
}

function ShootShape(spawnX, spawnY, v, angle, num, bside, graphic, delay) {
	ascent(i in 0..num) {
		let sx = spawnX+cos(angle+i*360/num); let sy = spawnY+sin(angle+i*360/num); let sxN = spawnX+cos(angle+(i+1)*360/num); let syN = spawnY+sin(angle+(i+1)*360/num);
		CreateShotA1(spawnX, spawnY, v*(((sx-spawnX)^2+(sy-spawnY)^2)^0.5), atan2(sy-spawnY,sx-spawnX), graphic, delay);
		ascent(j in 0..bside) {
			let toAngle = atan2(syN-sy,sxN-sx); let toDist = (((sxN-sx)^2+(syN-sy)^2)^0.5); let sx2 = sx+toDist/bside*j*cos(toAngle); let sy2 = sy+toDist/bside*j*sin(toAngle);
			CreateShotA1(spawnX, spawnY, v*(((sx2-spawnX)^2+(sy2-spawnY)^2)^0.5), atan2(sy2-spawnY,sx2-spawnX), graphic, delay);
		}
	}
}

task SetBulletTrailDelay(obj,time,delay,c,c2,shrink){
	let img=GCSD~"img/trail.png";
	loop(delay){ yield; }
	TObj;
	task TObj{
		while(!Obj_IsDeleted(obj)){
			let d=ObjPrim_Create(OBJ_SPRITE_2D);
			ObjRender_SetBlendType(d,BLEND_ADD_RGB);
			ObjPrim_SetTexture(d,img);
			ObjSprite2D_SetSourceRect(d,0,0,32,32);
			ObjSprite2D_SetDestCenter(d);
			ObjRender_SetPosition(d,ObjMove_GetX(obj),ObjMove_GetY(obj),0);
			SetColor(d,c,c2);
			TAction(d);
			yield;
			}
		}
	task TAction(o){
		let scale=1;
		let s=1;
		loop(time){
			if(shrink==true){
			ObjRender_SetScaleXYZ(o,scale,scale,0);
			scale-=(s/time);
				}
			yield;
			}
		Obj_Delete(o);
		}
	}

let sound=[];
function TLoadSounds{
//////////////////////////////0
	let water=ObjSound_Create;
	ObjSound_Load(water,GCSD~"se/se_water.wav");
	ObjSound_SetSoundDivision(water,SOUND_SE);
	sound=sound~[water];

//////////////////////////////1
	let laser=ObjSound_Create;
	ObjSound_Load(laser,GCSD~"se/lazer00.wav");
	ObjSound_SetSoundDivision(laser,SOUND_SE);
	sound=sound~[laser];

//////////////////////////////2
	let laser2=ObjSound_Create;
	ObjSound_Load(laser2,GCSD~"se/lazer01.wav");
	ObjSound_SetSoundDivision(laser2,SOUND_SE);
	sound=sound~[laser2];

//////////////////////////////3
	let s=ObjSound_Create;
	ObjSound_Load(s,GCSD~"se/swing37_a.wav");
	ObjSound_SetSoundDivision(s,SOUND_SE);
	sound=sound~[s];

//////////////////////////////4
	let s2=ObjSound_Create;
	ObjSound_Load(s2,GCSD~"se/swing22.wav");
	ObjSound_SetSoundDivision(s2,SOUND_SE);
	sound=sound~[s2];

//////////////////////////////5
	let s3=ObjSound_Create;
	ObjSound_Load(s3,GCSD~"se/swing02.wav");
	ObjSound_SetSoundDivision(s3,SOUND_SE);
	sound=sound~[s3];

//////////////////////////////6
	let s4=ObjSound_Create;
	ObjSound_Load(s4,GCSD~"se/shoot21.wav");
	ObjSound_SetSoundDivision(s4,SOUND_SE);
	sound=sound~[s4];

//////////////////////////////7
	let s5=ObjSound_Create;
	ObjSound_Load(s5,GCSD~"se/buble01.wav");
	ObjSound_SetSoundDivision(s5,SOUND_SE);
	sound=sound~[s5];

//////////////////////////////8
	let s6=ObjSound_Create;
	ObjSound_Load(s6,GCSD~"se/shoot23_b.wav");
	ObjSound_SetSoundDivision(s6,SOUND_SE);
	sound=sound~[s6];

//////////////////////////////9
	let s7=ObjSound_Create;
	ObjSound_Load(s7,GCSD~"se/byoro07.wav");
	ObjSound_SetSoundDivision(s7,SOUND_SE);
	sound=sound~[s7];

//////////////////////////////10
	let s8=ObjSound_Create;
	ObjSound_Load(s8,GCSD~"se/bell04.wav");
	ObjSound_SetSoundDivision(s8,SOUND_SE);
	sound=sound~[s8];

//////////////////////////////11
	let s9=ObjSound_Create;
	ObjSound_Load(s9,GCSD~"se/shot01.wav");
	ObjSound_SetSoundDivision(s9,SOUND_SE);
	sound=sound~[s9];

//////////////////////////////12
	let s10=ObjSound_Create;
	ObjSound_Load(s10,GCSD~"se/shot02.wav");
	ObjSound_SetSoundDivision(s10,SOUND_SE);
	sound=sound~[s10];

//////////////////////////////13
	let s11=ObjSound_Create;
	ObjSound_Load(s11,GCSD~"se/tan02.wav");
	ObjSound_SetSoundDivision(s11,SOUND_SE);
	sound=sound~[s11];

//////////////////////////////14
	let s12=ObjSound_Create;
	ObjSound_Load(s12,GCSD~"se/chari11.wav");
	ObjSound_SetSoundDivision(s12,SOUND_SE);
	sound=sound~[s12];

//////////////////////////////15
	let s13=ObjSound_Create;
	ObjSound_Load(s13,GCSD~"se/freeze05.wav");
	ObjSound_SetSoundDivision(s13,SOUND_SE);
	sound=sound~[s13];

//////////////////////////////16
	let s14=ObjSound_Create;
	ObjSound_Load(s14,GCSD~"se/don20.wav");
	ObjSound_SetSoundDivision(s14,SOUND_SE);
	sound=sound~[s14];
	
//////////////////////////////17
	let s15=ObjSound_Create;
	ObjSound_Load(s15,GCSD~"se/tm2_scratch000.wav");
	ObjSound_SetSoundDivision(s15,SOUND_SE);
	sound=sound~[s15];

//////////////////////////////18
	let s16=ObjSound_Create;
	ObjSound_Load(s16,GCSD~"se/coin01.wav");
	ObjSound_SetSoundDivision(s16,SOUND_SE);
	sound=sound~[s16];

//////////////////////////////19
	let s17=ObjSound_Create;
	ObjSound_Load(s17,GCSD~"se/noise16.wav");
	ObjSound_SetSoundDivision(s17,SOUND_SE);
	sound=sound~[s17];

//////////////////////////////20
	let s18=ObjSound_Create;
	ObjSound_Load(s18,GCSD~"se/wind01.wav");
	ObjSound_SetSoundDivision(s18,SOUND_SE);
	sound=sound~[s18];

//////////////////////////////21
	let exs=ObjSound_Create;
	ObjSound_Load(exs,GCSD~"se/enep01.wav");
	ObjSound_SetSoundDivision(exs,SOUND_SE);
	sound=sound~[exs];

//////////////////////////////22
	let c=ObjSound_Create;
	ObjSound_Load(c,GCSD~"se/charge00.wav");
	ObjSound_SetSoundDivision(c,SOUND_SE);
	sound=sound~[c];

//////////////////////////////23
	let c2=ObjSound_Create;
	ObjSound_Load(c2,GCSD~"se/cardcall.wav");
	ObjSound_SetSoundDivision(c2,SOUND_SE);
	sound=sound~[c2];
}

task PlaySound(obj,se,volume,w){
	loop(w){ yield; }
	if(ObjEnemy_GetInfo(obj,INFO_LIFE)>0){
		ObjSound_SetVolumeRate(sound[se],volume);
		ObjSound_Play(sound[se]);
	}
}

task PlaySoundNR(se,volume,w){
	loop(w){ yield; }
	ObjSound_SetVolumeRate(sound[se],volume);
	ObjSound_Play(sound[se]);
}