Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Random sound chooser

Author
Message
mikahell
18
Years of Service
User Offline
Joined: 6th Nov 2005
Location:
Posted: 14th Nov 2005 16:16
I wanted enemies to play sounds when they get hitted, but I don't want them to always make the same sound. I have a list of sounds, and I want the script to randomly choose one sound of the list, like it does for player when you get hit. (hurt1,hurt2,hurt3)

***By the way, if you add for your player a sound called "hurt4", it won't play it, so I wonder if there would be a way to make more than 3 sounds play for the player getting hurted?***

Anyway, for now I have made a large randomizer, that works like a tree, each intersection of the tree would be a random between two numbers, and the answer redirects to another series of randoms, and so on, until you get at the end of the code. But this supposes you could only have numbers of sounds by multiples of 2. (2x2x2x2x2... because of a random between 2 numbers). If you don't get it, see the image I have linked to this post.

There's the code for it, I hope there's a better way to do this, because it will easilly slow the game:


This is part of a code for enemies that I started to make. It just checks to see if he gets hit, then randomly chooses a sound...

Someone, please help me find a better way to do this!!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-18 18:00:13
Your offset time is: 2024-04-18 18:00:13