Topic category: User side tutorials
Event trigger-triggered by external call or when (global trigger): Entity attacked
If is current entity (sub)type of [entity]
do
if random[o,1) < 0.9
do Play at x: x y: y z: z level: 1 pitch: 1 sound: (chosen sound)
else if random[o,1) > 0.9
do Play at x: x y: y z: z level: 1 pitch: 1 sound: (chosen sound)
This is the code for when it is attacked. If you want it to be death sounds, replace Entity attacked with Entity dies. For instance, I want the Golem to sound like a villager when it's hit. Okay, so, Here's how the code will be set up:
Event trigger-triggered by external call or when (global trigger): Entity attacked
If is current entity (sub)type of EntityIronGolem
do
if random[o,1) < 0.9
do Play at x: x y: y z: z level: 1 pitch: 1 sound: entity.irongolem.hurt
else if random[o,1) > 0.9
do Play at x: x y: y z: z level: 1 pitch: 1 sound: entity.villager.hurt
The 0.9 is an example. It can be any number. But if you want to make the sounds evenly used or something, make both numbers the same for both like mine. Hope this helps you!
What if Random[0,1] produces 0.9? (:
Then it is what it is XD
That is not how you would use random on something like this.
Well it works fine for me.
This straight up doesnt work.
Why else if random[o,1) > 0.9?
You can just use else