MV How to make a Critical Hit Sound Effect across my game? (Yanfly's Buffs/States + Autopassive States help)

I was trying to figure out how to make it to where, if there's a critical hit at any point in my game, it will play a special sound effect.

I found this article, and gave it a shot:

I notice the special damage sound effects does play like I want it to, but unfortunately problem is that it is so delayed...
Like, the normal damage sound effect plays, then about a second later, that's when the special damage sound plays.

I want to make it to where it basically just "replaces" the regular damage sound effect with that special sound effect when a critical hit occurs. Without that delay as well...


How can I make this happen?
For context, all I did was follow what the article I linked above does. So all my actors have a passive state with that custom establish effect, and the common event has nothing else but the special sound effect.

========================
I'll list below here what I'm doing for more clarification:

Using Yanfly's Buffs and States core together with the AutoPassiveStates and the lunatic code:
Code:
Comment: Inside of my database, this is in my note tag of State 50.

<Custom Establish Effect>

if (target.result().hpDamage > 0 && target.result().critical) {

$gameTemp.reserveCommonEvent(23);

</Custom Establish Effect>


}

Screen Shot 2023-05-03 at 11.16.14 PM.png


In my Common Even #23, I am just playing a sound effect using the normal Play SE option in the Events Pages.

And all of my actors have the <Passive State: 50> in their notetag databases as well.
The problem with the thread you linked to is that it uses a common event. That's really lagged because reserving a common event doesn't execute it instantaneously, it puts it in the queue for the next window the engine looks for a common event.

If you just use the script call equivalent for playing a sound effect (found in the script call list), it should play instantly.

You could also incorporate it into the damage steps using Yanfly's Damage Control instead of giving each of your actors a passive state, but I don't know how much practical difference there is.
The problem with the thread you linked to is that it uses a common event. That's really lagged because reserving a common event doesn't execute it instantaneously, it puts it in the queue for the next window the engine looks for a common event.

If you just use the script call equivalent for playing a sound effect (found in the script call list), it should play instantly.

You could also incorporate it into the damage steps using Yanfly's Damage Control instead of giving each of your actors a passive state, but I don't know how much practical difference there is.


Oooh I see, I had no idea the common event was like a delayed thing. Thank you for the tip!

I found the script call from the list you mentioned. So I got rid of the common event script thing, and replaced it with that sound effect call.
It works nicely!

I guess my only nit pick would be that the original Normal Damage sound effect still "plays" even if it does get drowned out by the critical hit sound.

Would you happen to know of any ways "around" that nit pick? One thing I can think of is just not having a sound effect at all for taking damage in the System Database, and doing something else for damage sounds through other approaches? I don't have many skills in my game yet, so I don't mind doing individual damage sounds through events/notetags if needed.
Correct. You'd just delete the damage sound in the database and put an if/else in the notetag.

Code:
if (this.isPhysical() && target.result().hpDamage > 0)
{
    if (target.result().critical) 
        play critical sound
    else
        play normal sound
}
Correct. You'd just delete the damage sound in the database and put an if/else in the notetag.

Code:
if (this.isPhysical() && target.result().hpDamage > 0)
{
    if (target.result().critical)
        play critical sound
    else
        play normal sound
}

Ahh, thank you!

I guess my only question now is...
It works when my actors deal the critical hit to enemies.

But what about when the enemies attack my actors, and get critical hits?

It didn't seem to work then.
...did you put the passive state on the enemies?

Alternately, you could use the corresponding Buffs & States notetags for receiving the hit and copy the code over, leaving it on just the actors. But that would be the obvious reason, I presume.
Moved to: Plugin Support
...did you put the passive state on the enemies?

Alternately, you could use the corresponding Buffs & States notetags for receiving the hit and copy the code over, leaving it on just the actors. But that would be the obvious reason, I presume.

Ahhh I did NOT do that lol. I forget it's the enemies as well, and not just actors.

So for the code, would this be the right way to format it in my enemy notetags?
(Pardon me asking but coding/scripts is not my strong suit):

Code:
if (target.result().hpDamage > 0)

{

    if (target.result().critical)

        play critical sound

    else

        play enemy sound

}
I don't see why any of the code would be different for enemies vs. actors. You're asking as if you're making a different passive state to put on the enemies, but I don't get why you would.

The portion you removed with the check for isPhysical() does exactly what it says - makes this only happen when it's a skill that has Physical Hit.

You can keep that or remove it, but I should think you'd want it the same on everyone.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-critical-hit-sound-effect-across-my-game-yanflys-buffs-states-autopassive-states-help.157205/