//This is my sound effect library derived from Ultima and perfected with Arby's help. Thank you guys!!

#include "./Const_IDs.dnh"

let CSD = GetCurrentScriptDirectory;
let SEObject = [];
let SEPath = [
CSD ~ "../SFX/se_bonus.wav",
CSD ~ "../SFX/se_bonus2.wav",
CSD ~ "../SFX/se_boon00.wav",
CSD ~ "../SFX/se_boon01.wav",
CSD ~ "../SFX/se_cancel00.wav",
CSD ~ "../SFX/se_cardget.wav",
CSD ~ "../SFX/se_cat00.wav",
CSD ~ "../SFX/se_cat01.wav",
CSD ~ "../SFX/se_ch00.wav",
CSD ~ "../SFX/se_ch01.wav",
CSD ~ "../SFX/se_ch02.wav",
CSD ~ "../SFX/se_damage00.wav",
CSD ~ "../SFX/se_damage01.wav",
CSD ~ "../SFX/se_don00.wav",
CSD ~ "../SFX/se_enep00.wav",
CSD ~ "../SFX/se_enep01.wav",
CSD ~ "../SFX/se_enep02.wav",
CSD ~ "../SFX/se_etbreak.wav",
CSD ~ "../SFX/se_extend.wav",
CSD ~ "../SFX/se_fault.wav",
CSD ~ "../SFX/se_graze.wav",
CSD ~ "../SFX/se_gun00.wav",
CSD ~ "../SFX/se_heal.wav",
CSD ~ "../SFX/se_hint00.wav",
CSD ~ "../SFX/se_invalid.wav",
CSD ~ "../SFX/se_item00.wav",
CSD ~ "../SFX/se_kira00.wav",
CSD ~ "../SFX/se_kira01.wav",
CSD ~ "../SFX/se_kira02.wav",
CSD ~ "../SFX/se_lazer00.wav",
CSD ~ "../SFX/se_lazer01.wav",
CSD ~ "../SFX/se_lazer02.wav",
CSD ~ "../SFX/se_lgods1.wav",
CSD ~ "../SFX/se_lgods2.wav",
CSD ~ "../SFX/se_lgods3.wav",
CSD ~ "../SFX/se_lgods4.wav",
CSD ~ "../SFX/se_lgodsget.wav",
CSD ~ "../SFX/se_msl.wav",
CSD ~ "../SFX/se_msl2.wav",
CSD ~ "../SFX/se_msl3.wav",
CSD ~ "../SFX/se_nep00.wav",
CSD ~ "../SFX/se_nodamage.wav",
CSD ~ "../SFX/se_noise.wav",
CSD ~ "../SFX/se_ok00.wav",
CSD ~ "../SFX/se_option.wav",
CSD ~ "../SFX/se_pause.wav",
CSD ~ "../SFX/se_pin00.wav",
CSD ~ "../SFX/se_pin01.wav",
CSD ~ "../SFX/se_pldead00.wav",
CSD ~ "../SFX/se_pldead01.wav",
CSD ~ "../SFX/se_plst00.wav",
CSD ~ "../SFX/se_power0.wav",
CSD ~ "../SFX/se_power1.wav",
CSD ~ "../SFX/se_powerup.wav",
CSD ~ "../SFX/se_select00.wav",
CSD ~ "../SFX/se_slash.wav",
CSD ~ "../SFX/se_tan00.wav",
CSD ~ "../SFX/se_tan01.wav",
CSD ~ "../SFX/se_tan02.wav",
CSD ~ "../SFX/se_tan03.wav",
CSD ~ "../SFX/se_timeout.wav",
CSD ~ "../SFX/se_timeout2.wav",
CSD ~ "../SFX/se_warp.wav",
CSD ~ "../SFX/se_water.wav",
CSD ~ "../SFX/se_nice.wav",
CSD ~ "../SFX/se_warpl.wav",
CSD ~ "../SFX/se_warpr.wav",
CSD ~ "../SFX/se_shield.wav",
CSD ~ "../SFX/se_border.wav"
];

function SoundEvent(){
    alternative(GetEventType)
        case(PLAY_SFX){
            PlaySFX(GetEventArgument(0)[0],atoi(GetEventArgument(0)[1]));
        }
}

task SE_Load{
	ascent(i in 0..length(SEPath)){
		SEObject = SEObject ~ [ObjSound_Create];
	}
	
	ascent(i in 0..length(SEPath)){
		ObjSound_SetSoundDivision(SEObject[i],SOUND_SE);
	}
}

task PlaySFX(sound,volume){
	let se_pl = 0;
	alternative(sound)
	case("se_bonus"){
		se_pl = 0;
	}
	case("se_bonus2"){
		se_pl = 1;
	}
	case("se_boon00"){
		se_pl = 2;
	}
	case("se_boon01"){
		se_pl = 3;
	}
	case("se_cancel00"){
		se_pl = 4;
	}
	case("se_cardget"){
		se_pl = 5;
	}
	case("se_cat00"){
		se_pl = 6;
	}
	case("se_cat01"){
		se_pl = 7;
	}
	case("se_ch00"){
		se_pl = 8;
	}
	case("se_ch01"){
		se_pl = 9;
	}
	case("se_ch02"){
		se_pl = 10;
	}
	case("se_damage00"){
		se_pl = 11;
	}
	case("se_damage01"){
		se_pl = 12;
	}
	case("se_don00"){
		se_pl = 13;
	}
	case("se_enep00"){
		se_pl = 14;
	}
	case("se_enep01"){
		se_pl = 15;
	}
	case("se_enep02"){
		se_pl = 16;
	}
	case("se_etbreak"){
		se_pl = 17;
	}
	case("se_extend"){
		se_pl = 18;
	}
	case("se_fault"){
		se_pl = 19;
	}
	case("se_graze"){
		se_pl = 20;
	}
	case("se_gun00"){
		se_pl = 21;
	}
	case("se_heal"){
		se_pl = 22;
	}
	case("se_hint"){
		se_pl = 23;
	}
	case("se_invalid"){
		se_pl = 24;
	}
	case("se_item00"){
		se_pl = 25;
	}
	case("se_kira00"){
		se_pl = 26;
	}
	case("se_kira01"){
		se_pl = 27;
	}
	case("se_kira02"){
		se_pl = 28;
	}
	case("se_lazer00"){
		se_pl = 29;
	}
	case("se_lazer01"){
		se_pl = 30;
	}
	case("se_lazer02"){
		se_pl = 31;
	}
	case("se_lgods1"){
		se_pl = 32;
	}
	case("se_lgods2"){
		se_pl = 33;
	}
	case("se_lgods3"){
		se_pl = 34;
	}
	case("se_lgods4"){
		se_pl = 35;
	}
	case("se_lgodsget"){
		se_pl = 36;
	}
	case("se_msl"){
		se_pl = 37;
	}
	case("se_msl2"){
		se_pl = 38;
	}
	case("se_msl3"){
		se_pl = 39;
	}
	case("se_nep00"){
		se_pl = 40;
	}
	case("se_nodamage"){
		se_pl = 41;
	}
	case("se_noise"){
		se_pl = 42;
	}
	case("se_ok00"){
		se_pl = 43;
	}
	case("se_option"){
		se_pl = 44;
	}
	case("se_pause"){
		se_pl = 45;
	}
	case("se_pin00"){
		se_pl = 46;
	}
	case("se_pin01"){
		se_pl = 47;
	}
	case("se_pldead00"){
		se_pl = 48;
	}
	case("se_pldead01"){
		se_pl = 49;
	}
	case("se_plst00"){
		se_pl = 50;
	}
	case("se_power0"){
		se_pl = 51;
	}
	case("se_power1"){
		se_pl = 52;
	}
	case("se_powerup"){
		se_pl = 53;
	}
	case("se_select00"){
		se_pl = 54;
	}
	case("se_slash"){
		se_pl = 55;
	}
	case("se_tan00"){
		se_pl = 56;
	}
	case("se_tan01"){
		se_pl = 57;
	}
	case("se_tan02"){
		se_pl = 58;
	}
	case("se_tan03"){
		se_pl = 59;
	}
	case("se_timeout"){
		se_pl = 60;
	}
	case("se_timeout2"){
		se_pl = 61;
	}
	case("se_warp"){
		se_pl = 62;
	}
	case("se_water"){
		se_pl = 63;
	}
	case("se_nice"){
		se_pl = 64;
	}
	case("se_warpl"){
		se_pl = 65;
	}
	case("se_warpr"){
		se_pl = 66;
	}
	case("se_shield"){
		se_pl = 67;
	}
	case("se_border"){
		se_pl = 68;
	}
	ObjSound_Load(SEObject[se_pl],SEPath[se_pl]);
	ObjSound_SetVolumeRate(SEObject[se_pl],volume);
	yield;
	ObjSound_Play(SEObject[se_pl]);
}