Looks logical to me, but maybe the variable name or type doesn't match. I have often problems like that, something looks right to me, but one variable is a string instead of an integer, or an object instead of an index.
FAIK something with ref in front, like rCannon, is an object , while CANNON_TYPE_CANNON_LBS12 might be an integer/index or a namestring. so maybe you can't compare them. What does the errorlog say?
But that you have already found that "playSound" command makes things easier. That looks in fact very much like the (hand)gunsound code, so one could copy the SWAK code as you initially suggested.
In cannonscannons_init insert into each cannontype definition a line with a soundfilename as attribute:
rCannon.sound = "filepathfilename.wav";
And in AIBalls change your code like this
ref rCannon = GetCannonByType(sti(aCharacter.Ship.Cannons.Type));
Play3DSound( rCannon.sound , fX, fY, fZ);
Just an untested idea though
FAIK something with ref in front, like rCannon, is an object , while CANNON_TYPE_CANNON_LBS12 might be an integer/index or a namestring. so maybe you can't compare them. What does the errorlog say?
But that you have already found that "playSound" command makes things easier. That looks in fact very much like the (hand)gunsound code, so one could copy the SWAK code as you initially suggested.
In cannonscannons_init insert into each cannontype definition a line with a soundfilename as attribute:
rCannon.sound = "filepathfilename.wav";
And in AIBalls change your code like this
ref rCannon = GetCannonByType(sti(aCharacter.Ship.Cannons.Type));
Play3DSound( rCannon.sound , fX, fY, fZ);
Just an untested idea though