MZ Checking if the skill hits the target or misses, run common event if hits

Hello people,
I need help with something as the title says.
i need to check a skill hits the target, the skill plays the common event but it needs to check first if the skill hit the player or missed it. This have to happen right before damage. Because the common event would contain skill picture, animations or movies. After the movies for example, the damage would be done.

I am using visustella MZ battle core plugin. I know this is possible using yanfly in MV but for MZ, I have no idea how to do this.
Hmmm don't think there's an easy way to run a common event between hit and damage. You can make calculations in the action sequence before the attack to determine hit/miss or emulate a dummy skill in the action sequence and check the hit/miss switch. Then use those results in the JS accuracy notetag (I guess using AS commands to increase/[edit: or decrease] hit rate greatly would also work) or whatever for the actual skill. Same things can be used to check critical hits if needed.
Easiest (but not the best solution) I can think of, is to handle the entire skill as a branching action sequence.

The skill itself would be setup as "Certain Hit", which triggers the action sequence common event.

Then, in the middle of the sequence when attacking, simulate your hit/miss by assigning a randomly generated number (e.g. 0~100) which you store in a variable.

At that point, make a conditional branch for that variable, e.g.:
- if the random number is 20 or lower, perform "miss" action sequence with no damage applied etc.
- if it is higher, call your special "common event" (like playing a movie), then perform the normal hitting sequence afterwards




If you don't know how to make your own action sequence, you could simplify it further.

Just make your skill certain hit that does nothing but call a common event. That event generates random number 0~100 to simulate hit or miss and save that random number in a variable. Then make a conditional branch...

- "hit" number (calls your cinematic event, then force action like simple attack, or any skill you make that player can't normally use/learn, only through this process)

- "miss" number (displays a message "Damn, I missed!" or force action a dummy skill you make that has 0% hit rate etc.)

The latter should in theory work even with vanilla MZ...

This is how I would handle it, but there is probably a better or more elegant solution tbh.

EDIT: I just realized I have suggested basically the same thing as rpgLord69 ... <insert a facepalm meme here>
Easiest (but not the best solution) I can think of, is to handle the entire skill as a branching action sequence.

The skill itself would be setup as "Certain Hit", which triggers the action sequence common event.

Then, in the middle of the sequence when attacking, simulate your hit/miss by assigning a randomly generated number (e.g. 0~100) which you store in a variable.

At that point, make a conditional branch for that variable, e.g.:
- if the random number is 20 or lower, perform "miss" action sequence with no damage applied etc.
- if it is higher, call your special "common event" (like playing a movie), then perform the normal hitting sequence afterwards




If you don't know how to make your own action sequence, you could simplify it further.

Just make your skill certain hit that does nothing but call a common event. That event generates random number 0~100 to simulate hit or miss and save that random number in a variable. Then make a conditional branch...

- "hit" number (calls your cinematic event, then force action like simple attack, or any skill you make that player can't normally use/learn, only through this process)

- "miss" number (displays a message "Damn, I missed!" or force action a dummy skill you make that has 0% hit rate etc.)

The latter should in theory work even with vanilla MZ...

This is how I would handle it, but there is probably a better or more elegant solution tbh.

EDIT: I just realized I have suggested basically the same thing as rpgLord69 ... <insert a facepalm meme here>
Thanks for your help. I am hoping in future someone does a plugin on this or vistella does consider this.
I took this opportunity to test a plugin that I had been eyeing for a while.


It's a set of plugins, one needs to be placed at the top of the list and the other at the bottom. I did a quick test in an action sequence, right after the usual ACSET, as follows:

◆If:Script:BattleManager.isReservedSuccess()
◆Script:console.log(BattleManager.isReservedSuccess())
◆Plugin Command:TextPicture, Set Text Picture
:Plugin Command:Text=Gonna Hit
◆Show Picture:#1, None, Upper Left (200,200), (500%,500%), 255, Normal
◆Move Picture:#1, Linear, Upper Left (300,300), (200%,200%), 0, Normal, 60 frames
◆
:Else
◆Script:console.log(BattleManager.isReservedSuccess())
◆Plugin Command:TextPicture, Set Text Picture
:Plugin Command:Text=Gonna Miss
◆Show Picture:#1, None, Upper Left (200,200), (500%,500%), 255, Normal
◆Move Picture:#1, Linear, Upper Left (300,300), (200%,200%), 0, Normal, 60 frames
◆
:End

The result is that when hit the console will display "true" and on screen it will look like:
1758083618560.png

If it's a miss the console will display "false" and on screen it will look like:
1758083690179.png
1758083730930.png

So I think this works. Just use BattleManager.isReservedSuccess() in a conditional branch after installing the plugins. Haven't tested it with multi-target skills. The plugin description says something about the ability to feed a target number as an argument in the function, but am not sure how it'll work.

Original thread: https://forums.rpgmakerweb.com/threads/checking-if-the-skill-hits-the-target-or-misses-run-common-event-if-hits.180075/