/** ** Set the range of a given sound. ** ** @param l Lua state. */ static int CclSetSoundRange(lua_State *l) { LuaCheckArgs(l, 2); int tmp = LuaToNumber(l, 2); clamp(&tmp, 0, 255); const unsigned char theRange = static_cast<unsigned char>(tmp); lua_pushvalue(l, 1); CSound *id = CclGetSound(l); SetSoundRange(id, theRange); return 1; }
global void MapUnitSounds(void) { int i; int nb; SoundId HumanHelp,HumanCityHelp,OrcHelp,OrcCityHelp; SoundId HumanDead,OrcDead,BuildingDestroyed,ShipSinking; if( SoundFildes!=-1 ) { SetSoundRange(SoundIdForName("tree chopping"),32); nb=sizeof(UnitTypes)/sizeof(*UnitTypes); // help sounds HumanHelp=SoundIdForName("basic human voices help 1"); HumanCityHelp=SoundIdForName("basic human voices help 2"); OrcHelp=SoundIdForName("basic orc voices help 1"); OrcCityHelp=SoundIdForName("basic orc voices help 2"); // Ranges for help sounds SetSoundRange(HumanHelp,INFINITE_SOUND_RANGE); SetSoundRange(HumanCityHelp,INFINITE_SOUND_RANGE); SetSoundRange(OrcHelp,INFINITE_SOUND_RANGE); SetSoundRange(OrcCityHelp,INFINITE_SOUND_RANGE); // death sounds HumanDead=SoundIdForName("basic human voices dead"); OrcDead=SoundIdForName("basic orc voices dead"); BuildingDestroyed=SoundIdForName("building destroyed"); ShipSinking=SoundIdForName("ship sinking"); for(i=0;i<nb;i++) { UnitTypes[i].Sound.Selected.Sound= SoundIdForName(UnitTypes[i].Sound.Selected.Name); UnitTypes[i].Sound.Acknowledgement.Sound= SoundIdForName(UnitTypes[i].Sound.Acknowledgement.Name); // Acknowledge sounds have infinite range SetSoundRange(UnitTypes[i].Sound.Acknowledgement.Sound, INFINITE_SOUND_RANGE); UnitTypes[i].Sound.Ready.Sound= SoundIdForName(UnitTypes[i].Sound.Ready.Name); //FIXME: will be modified UnitTypes[i].Weapon.Attack.Sound= SoundIdForName(UnitTypes[i].Weapon.Attack.Name); //FIXME: very dirty trick based on the fact that unit types // alternate between human and orc, starting with human. // should be at least defined as remaps //FIXME: (Fabrice) I don't think it's 100% correct for death //sounds. if (i%2) { //orc if (UnitTypes[i].Building) { UnitTypes[i].Sound.Help.Sound=OrcCityHelp; UnitTypes[i].Sound.Dead.Sound=BuildingDestroyed; } else { UnitTypes[i].Sound.Help.Sound=OrcHelp; if (UnitTypes[i].SeaUnit) { UnitTypes[i].Sound.Dead.Sound=ShipSinking; } else { UnitTypes[i].Sound.Dead.Sound=OrcDead; } } } else { //human if (UnitTypes[i].Building) { UnitTypes[i].Sound.Help.Sound=HumanCityHelp; UnitTypes[i].Sound.Dead.Sound=BuildingDestroyed; } else { UnitTypes[i].Sound.Help.Sound=HumanHelp; if (UnitTypes[i].SeaUnit) { UnitTypes[i].Sound.Dead.Sound=ShipSinking; } else { UnitTypes[i].Sound.Dead.Sound=HumanDead; } } } } } }