RPG Maker MV

RPG Maker MV

Skills with Event Input v4
 This topic has been pinned, so it's probably important
Caethyril  [developer] Feb 2, 2018 @ 2:46pm
How it works
Uses Yanfly's action sequences to run common events mid-skill. The skill formula can depend on one or more variables (v[x] is replaced by the value of variable #x), the value(s) of which can be changed in the event. More details below.

A) Action Sequence
Yanfly's Battle Engine Core[yanfly.moe] plugin introduces action sequences, allowing you to specify exactly what happens when you use a skill. Here's an introductory video:
Among other things, the Action Sequence Pack 1[yanfly.moe] extension plugin adds a couple of useful actions:
  • common event: X
    This plays common event number X and waits for it to finish; essential!
    (The action common event action from the core plugin limits you to one event per skill and would require you to override the finish actions so that the event doesn't play at the end of the skill.)

  • change variable X = Y
    This action (and its variants) lets you change the value of a variable. Very useful for keeping a running total!
Action Sequence Pack 2[yanfly.moe] is optional but gives you the move command to help make your actions look more dynamic, e.g.
move user: target, front base, 20

B) Common Event
This is where things get interesting!

Part 1
The core piece of the event will be the part that accepts the user input. All the examples here are time-dependent, so:
  1. Start by initialising a "counter" variable to keep track of what time you're at.
  2. Then, start a loop that checks for the expected input and responds appropriately.
  3. If there's no relevant input, wait for 1 frame and adjust the counter variable.
The counter variable lets you keep track of when input is received, as well as allowing you to do things like end the loop after a certain number of frames.

To check whether a button is pressed down, use a Conditional Branch command (a.k.a. "if statement"). However, you may want to check for a "press & release" instead, i.e. down, then up. A switch can be used to keep track of whether the button was down the last time it was checked, i.e.
If Button [OK] is pressed down If Switch ButtonDown is OFF Comment: OK button has just been pressed down. End Branch Else If Switch ButtonDown is ON Comment: OK button has just been released. End Branch End Branch
You can then toggle the switch as well as doing whatever else should be done when the button is pressed/released.

Part 2
Once you've got it recognising the input, it's time to let the player know what is expected of them! In this project, I've used pictures (and skill descriptions) to indicate which buttons to press and when to press them. These are all handled simply using the Show Picture and Move Picture commands.

Telling the user what to do is important, but it's nice to give the player some extra information, too! In this example, I've used star rating pictures to indicate how well the player's input matched up, as well as a few flash- and shake-screen effects to indicate you're low on time (Lock-On skill).

Scripting
While scripting is not necessary to use the above method, it can help to make things slightly easier. Here are a few ways I've used scripting in this example:
  • if user.attackMotion() !== 'missile' ... end
    (Found in action sequences.) This basically just checks whether the skill user has a ranged weapon equipped. If not, then the actions listed in the branch will run. Used to make melee attackers move to their target.

    This can be avoided by using a plugin such as Kadokawa's WeaponSkill (included by default in new projects) to assign separate melee and ranged attack skills.

  • if target.isActor() ... else ...they're an Enemy end
    (Found in action sequences.) This checks whether the skill target is a member of the player's party. Can replace target with user if appropriate. Used to avoid running the player input event when it's the enemy who is supposed to provide the "input".

    This can be avoided by having enemies and actors use their own versions of skills.

  • 10 * Math.round(10 - 10 * Math.exp(-$gameVariables.value(4) / (1.0 * $gameVariables.value(3))))
    (Found in the Button Mash events.) Don't worry too much about this, it's totally optional. All it does is make each button press count for less and less. In doing so it also converts "number of presses" into a number between 0 and 100 (in multiples of 10).


If you have any other questions about it then ask away! ^_^
Last edited by Caethyril; Apr 28, 2018 @ 3:29pm