Play specific unit selection sound?

Lutefisk Mafia

Inscrutable Enforcer
Joined
Jun 15, 2007
Messages
544
Location
Minnesota
Is there an easy way to call a specific unit selection sound via python?

I know that many units have a list of sounds from which a random one is chosen when you click on that unit.

Can I get a specific one of those? I am looking for a way to do this in python because it is for a scenario and I cant change or add to the audio def XML files.

Thanks!
 
Looking at the Python API for "sound", I see

CyInterface().playGeneralSound(string szSound)​

All of the sounds are in a big XML file: XML/Audio/AudioDefines.xml. There's also

CyInterface().playGeneralSoundByID(int iScriptId)​

which might take the integer returned from

gc.getInfoTypeForString(string xmlKey)​

But probably not since it wants a script ID. I don't know where scripts enter into the picture.
 
I don't know where scripts enter into the picture.

It looks like iScriptId works the same as Id's used with other things (like units). The first script listed in AudioDefines.xml has an id of 0, the second has an id of 1, third has an id of 2......

For example: CyInterface().playGeneralSoundByID(5) would play the 6th sound script in the file.

This isn't a very good way to do things. Unforunately, as you mentioned getInfoTypeForString doesn't work with iScriptId, and I don't know of any other way to get the id. Maybe someone else will have a better idea.
 
For example in the FfH2 mod, the AudioDefines.XML has an entry like this:

Code:
		<SoundData>
			<SoundID>SND_DWARF_SELECT</SoundID>
			<Filename>Sounds/Units/DwarfSelect</Filename>
			<LoadType>DYNAMIC_RES</LoadType>
			<bIsCompressed>1</bIsCompressed>
			<bInGeneric>1</bInGeneric>
		</SoundData>

if you go to the folder where the sound files are (sounds/units), you find wav files listed from:

DwarfSelect-000
to
DwarfSelect-007

The Civ engine randomly selects one of these each time the SND_DWARF_SELECT is called.

But I am trying to figure out how to call the DwarfSelect-004 wav file on demand.

If I understand what was said above, I can use those API functions to call a specific script, by name or ID, but that still just calls a random wav within the XML definition, right?
 
Back
Top Bottom