task FadeOutSound(objSound,frames) {
	let volume = ObjSound_GetVolumeRate(objSound);
	let volumelimit = volume-50;
	if(volumelimit<0) { volumelimit = 0; }
	loop(frames) {
		ObjSound_SetVolumeRate(objSound,volume);
		volume-=volumelimit/frames;
		yield;
	}
	Obj_Delete(objSound);
}
task PlayEnemyHitSound(objEnemy, type){
	let damage1 = 11;
	let damage2 = 12;
	let damage3 = 13;
	let bosshp = ObjEnemy_GetInfo(objEnemy, INFO_LIFE);
	let initbosshp = ObjEnemy_GetInfo(objEnemy, INFO_LIFE);
	
	while(!Obj_IsDeleted(objEnemy)){
		if(bosshp != ObjEnemy_GetInfo(objEnemy, INFO_LIFE) && type == 1){
			if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > initbosshp/10){ PlaySoundEffect(damage1,100); }
			if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) < initbosshp/10){ PlaySoundEffect(damage2,100); }
		}
		if(bosshp != ObjEnemy_GetInfo(objEnemy, INFO_LIFE) && type == 2){ PlaySoundEffect(damage1,100); }
		if(bosshp != ObjEnemy_GetInfo(objEnemy, INFO_LIFE) && type == 3){ PlaySoundEffect(damage3,100); }
		
		bosshp = ObjEnemy_GetInfo(objEnemy, INFO_LIFE);
		loop(6) { yield; }
	}
}
function LoadSoftSE(sound) {
	let obj = ObjSound_Create;
	ObjSound_SetSoundDivision(obj,SOUND_SE);
	ObjSound_Load(obj,sound);
	return obj;
}
function PlayLoadedSoftSE(obj,volume) {
	ObjSound_SetVolumeRate(obj,volume);
	ObjSound_Play(obj);
}
function PlaySoftSE(sound,volume) {
	let obj = ObjSound_Create;
	ObjSound_SetSoundDivision(obj,SOUND_SE);
	ObjSound_Load(obj,sound);
	ObjSound_SetVolumeRate(obj,volume);
	ObjSound_Play(obj);
}
function PlaySoundEffect(id,volume) {
	NotifyEventAll(EV_SOUND,[id,volume]);
}
function PlayMusic(id) {
	NotifyEventAll(EV_MUSIC_START,id);
}