Topic category: Help with MCreator software
When creating a mob, you can select their ambient, hurt and death sound, which will play it at a random pitch to create variation. I however want to use multiple hurt sounds to create variation.
The way I planned on doing this was by adding a death sound and ambience sound and leaving the hurt sound empty. Then I'd go to procedures and entered the following in the Mob Is Hurt procedure call:
Set Local randNum to Random[0,1]
repeat 1 times
if Get Local randNum < 0.2
Play at x y z level 1 pitch 1 sound Entity_Hurt1
break out of loop
if Get Local randNum < 0.4
Play at x y z level 1 pitch 1 sound Entity_Hurt2
break out of loop
if Get Local randNum < 0.6
Play at x y z level 1 pitch 1 sound Entity_Hurt3
break out of loop
if Get Local randNum < 0.8
Play at x y z level 1 pitch 1 sound Entity_Hurt4
break out of loop
else
Play at x y z level 1 pitch 1 sound Entity_Hurt5
break out of loop
One problem with this approach however is that Mob Is Hurt is also called when the mobs dies, meaning that I heard both the death and the hurt procedure. (To me it seems counterproductive to have Mob Is Hurt procedure call called on the death blow as there already is "When Mob Dies", which simply could call the same procedure.
So I tried removing the death sound also and calling the sound through the Mob is Hurt procedure:
Set Local randNum to Random[0,1]
if entity health > 0
repeat 1 times... (And the rest you find above)
else
Play at x y z level 1 pitch 1 sound Entity_DYING
But again there is a problem. When this procedure is called, the entity's health has not been set to 0/below yet! This results in the same as the first implementation as the death sound is never played. I tried entity health - attack damage of item > 0, but this didn't work out for me the way I did it.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
So as for my question: How do you create a sound procedure like this that doesn't play both the hurt sound and death sound at the same time?
Additionally in future Mcreator versions, will Mob-is-Hurt no longer trigger when When-Mob-Dies"triggers as When-Mob-Dies makes Mob-is-Hurt in that instance redundant as When Mob Dies can already be used for that?
Do you still have the file for the workspace? Maybe I can help you look at it
I no longer do. Though all it requires is 2 sounds, triggered customarily through procedures. 1 must play on death and the other on mob is hurt but not on hurt if the mob dies to that attack.
Is this for a custom mob of yours? If so, on the very first page of the mob you got ambient, hurt, and death sound. Use those
I know about those options, however, I want to have multiple hurt sounds and multiple death sounds rather than only have it variate in pitch.
Not using the ambient option on page 1 and replacing it with On Tick Update with a counter of about 400 ticks works fine, allowing the ability to use an if statement to randomly pick between the ambient sounds. But the same strategy failed for Hurt and Death as they are in each-other's way.
Ah I see. So like DrZhark's werewolf one where it's multiple hurt sounds as a human? I'll do some testing and see if I can help you out there!
Okay I believe I figured it out. I tested it too. Try this code
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)
Sadly, just like Entity Hurt procedure on the mob, it is called before on Entity death. Thus when selecting a death sound, the procedure of the entity hurt will also play. It doesn't work.
The core issue here is that
1. Entity Hurt is also called on Entity Death.
2. Entity Hurt is called before Entity Death, preventing us from setting an NBT tag in Entity Death that prevents Entity Hurt from playing.
3. Health is subtracted AFTER Entity Hurt procedure. Meaning that when we check Entity Hurt whether HP is 0 or smaller, then this will not work, as health is subtracted after this procedure call.
The problem isn't getting variation in sound. The problem is that the hurt sound and death sound will play both on mob death as a result.
What we need is a way to detect whether the entity has died FROM the entity is hurt procedure, so that we can disrupt it from playing a hurt sound on the Mob Death.
Okay, try duplicating the procedure but replace hurt with death. change the sounds too
I really don't see how that would help xD
Give it a go
I gave it a go before writing this post and obviously it failed.
Both death and hurt sounds will play on the hit the mob is killed as both Mob is Hurt and Mob is killed are called.
You got discord? Maybe you can show me screenshots and I can help better
I don't have Discord, but there's not a lot of information needed:
---------------------What I want: (mob takes 4 hits for this example)---------------------
hit1: random hurt sound.
hit2: random hurt sound.
hit3: random hurt sound.
hit4: death sound
---------------------What I don't want but currently happens:---------------------
hit1: random hurt sound.
hit2: random hurt sound.
hit3: random hurt sound.
hit4: death sound + random hurt sound.
---------------------------------------------------------------------------------------------------------
It looks easier than it is.