Scripting a random sound selector (SOLVED)

Started by timlump, Thu 04/05/2006 23:07:46

Previous topic - Next topic

timlump

I,m making a one room real time rpg action game called SuRvIvAl and I plan to include allied a.i characters that assist you but i want them to say random catch phrases etc during the game, I'm currently in the process of recording 300 or so sound bites but need a script to put in the repeatedly execute system that generates a number between say 1 and 400 then plays the corresponding sound file e.g sound1 or sound2.

Ashen

Random(int) and PlaySound(int), e.g.

Code: ags

PlaySound(Random(399)+1);

Or am I missing something?

You'll probably also want to include a Timer or something, so they start at intervals rather than trying to start too many sounds at once. Or have you got that bit covered some other way? Why are you using sound files, rather than Character.Say (other than the sound files probably being quicker to script)?

(BTW, unless there's something major I'm missing, I think this is more a Beginners Tech question.)
I know what you're thinking ... Don't think that.

timlump

thanks and yes i do have the timing issue somewhat covered.
Also I didnt think it was a beginners question since i was expecting a lot more elaborate code (since I've never used the random number generator)

SMF spam blocked by CleanTalk