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:
:shotdamage=1:activate=100
:activated=100,random=2:activate=101
:activated=100:activate=102
:activated=101,random=2:activate=103
:activated=101:activate=104
:activated=102,random=2:activate=105
:activated=102:activate=106
:activated=103,random=2:sound=audiobank\voices\male\hurt1.wav,activate=4
:activated=103:sound=audiobank\voices\male\hurt2.wav,activate=4
:activated=104,random=2:sound=audiobank\voices\male\hurt3.wav,activate=4
:activated=104:sound=audiobank\voices\male\hurt4.wav,activate=4
:activated=105,random=2:sound=audiobank\voices\male\hurt5.wav,activate=4
:activated=105:sound=audiobank\voices\male\hurt6.wav,activate=4
:activated=106,random=2:sound=audiobank\voices\male\hurt7.wav,activate=4
:activated=106:sound=audiobank\voices\male\hurt8.wav,activate=4
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!!