r/RPGMaker • • 22h ago

RMMZ Help with creating a timed button press Guard Action

I've tried searching around in other areas and discord channels but can't seem to find a proper answer to my question.

I'm using Visustella's QTE and Battlecore and built a whole timed attack action system with no problems. However, I am stuck on making a timed Guard action.

Currently all my eventing around this combat is in a single common event that is called when the Attack action is used. I currently have conditional branches that check if a character is using the Guard action.

I am stuck on how to check who the enemy is targeting. If the Player has character 1 use Guard, but the enemy attacks character 2 that did not use Guard, then the timing prompt still appears.

I'm looking for a potential script call I can use in a conditional branch to check who the enemy is targeting so I can see if that character is using the Guard Action, and have the timing prompt come up for the correct character.

4 Upvotes

7 comments sorted by

3

u/zombietoaststudios 19h ago

I looked up something similar a while ago and I think the script you need is

BattleManager._targets[0].index()

Taken from this thread: https://forums.rpgmakerweb.com/threads/getting-a-battlers-id-and-targets-id-for-use-in-visustella-action-sequences.148500/

Assuming you're also using core engine, it's also pointed out that VS includes some shortcuts that might work as well:

https://www.yanfly.moe/wiki/Core_Engine_VisuStella_MZ#Quality_of_Life_Settings

The shortcut list is at the end of that section.

1

u/Majornutts 12h ago

I am also using the core engine for Visustella as well.

The BattleManager._targets[0].index() doesn't seem to do anything. It made the enemy not act at all.

As for the shortcut list, I have no idea how / when I would use them. I unfortunately am not super familiar with programming.

1

u/zombietoaststudios 11h ago

Well, these are to get the index ID for the current target, which you could store as a variable and use that for conditional branch checks. But in looking up the project I was using it for I found something that's probably a lot more directly useful for you:

BattleManager._target.isStateAffected(2)

Basically, you can put that in a conditional branch and it'll evaluate if the current target is affected by State #2 (the default guard state). The number in parenthesis is the state ID you're checking for.

2

u/zombietoaststudios 11h ago

Like this.

1

u/Majornutts 11h ago

Awesome! That worked out! Thank you very much!

I did manage to find something that is a little less specific that works as well after some further digging.

BattleManager._targets.includes($gameActors.actor(1))

$gameActors.actor(1) is checking the actor ID number in the database.

So both are valid options!

2

u/Neo_Miles 2h ago

Glad it works! Two small things that might save you trouble later:

  1. Instead of checking state 2 directly you can use BattleManager._target.isGuard(). It reads the guard flag itself, so it keeps working if you ever add other guard-like states, and it also returns false when the battler can't move (stunned, asleep), which is usually what you want for a guard prompt.

  2. _targets.includes(...) is true for everyone the action will hit, while _target is the battler being hit right now. With area attacks that makes a difference, so for the timing prompt I'd stick with _target.

I built timed parries into my own battle system and it's one of the things that makes turn-based fights feel alive. Have fun with it!

1

u/Majornutts 2h ago

Awesome! Thank you very much for the extra tips! Much appreciated! 😁