Custom SOUND variations using procedures. The problem with proccedurecall "When Mob is Hurt"

Started by StellaeLux on

Topic category: Help with MCreator software

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Custom SOUND variations using procedures. The problem with proccedurecall "When Mob is Hurt"
Thu, 08/29/2019 - 12:25 (edited)

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?

Edited by StellaeLux on Thu, 08/29/2019 - 12:25
Last seen on 15:12, 21. Oct 2019
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay I see. So, I don't know…
Wed, 10/09/2019 - 21:36

Okay I see. So, I don't know how to explain this but hit 4 isnt always going to result in a death sound. It actually depends how many hits it takes to kill a mob. And I doubt the sounds will happen in order which is why they are random. Which I would use 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)

 

This is for only 2 random sounds when the entity is hit. If you want to make it 3, do this

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)

    if random[o,1) < 0.9
    do Play at x: x y: y z: z level: 1 pitch: 1 sound: (chosen sound)

    if random[o,1) < 0.9
    do Play at x: x y: y z: z level: 1 pitch: 1 sound: (chosen sound)

 

Perhaps try this out?

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I am not going to try that…
Thu, 10/10/2019 - 05:58

I am not going to try that out xD but thanks for trying to help (:

Last seen on 21:40, 21. Dec 2019
Joined Dec 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Could you do a, "All you…
Sat, 12/21/2019 - 21:14

Could you do a, "All you need to know" on Tick Rate?