How do i make it so that every time i want my character to attack he has to answer a question?

I was wondering on how to make it so that to attack the player has to answer a question if they get it right they get to attack otherwise they takes damage.
Thanks.
It depends exactly what order of operations you want, e.g.
  1. Question per turn -> if incorrect, the party misses a turn.
  2. Select actions -> question per action -> action succeeds iff answer is correct.
Option 1 can be done with some creative use of troop events, like I mention here:
Basically, ask a question on Turn 0 / Turn End, and stun the party (or the troop) based on whether or not the answer is correct. The discussion and concept demo are for MV, but the same approach ought to work in MZ.

I think option 2 would need either:
  • The Force Action command, e.g. original skill asks the question, then forces intended skill if answer is correct. That would require duplicates for all relevant skills, and is awkward because Force Action doesn't accept variable input (could use a script call to work around that).

  • A plugin, e.g. something that can run a common event during a skill's execution, rather than after it. VisuStella MZ Battle Core can do that with action sequences. There are probably alternatives.
Thank you so much.
I was just wondering then how can I made a random number generator for a maths question let’s say and then how would I display that random number and have the answer calculated/ready to check if it’s correct?
Thanks
It depends exactly what order of operations you want, e.g.
  1. Question per turn -> if incorrect, the party misses a turn.
  2. Select actions -> question per action -> action succeeds iff answer is correct.
Option 1 can be done with some creative use of troop events, like I mention here:
Basically, ask a question on Turn 0 / Turn End, and stun the party (or the troop) based on whether or not the answer is correct. The discussion and concept demo are for MV, but the same approach ought to work in MZ.

I think option 2 would need either:
  • The Force Action command, e.g. original skill asks the question, then forces intended skill if answer is correct. That would require duplicates for all relevant skills, and is awkward because Force Action doesn't accept variable input (could use a script call to work around that).

  • A plugin, e.g. something that can run a common event during a skill's execution, rather than after it. VisuStella MZ Battle Core can do that with action sequences. There are probably alternatives.
You can use Control Variables -> Set -> Random to store a random integer in a variable.

You can calculate simple arithmetic solutions using the Add, Sub, Mul, Div, and/or Mod operators of Control Variables, e.g.

◆Control Variables:#0001 Number A = Random 1..100 ◆Control Variables:#0002 Number B = Random 1..100 ◆Control Variables:#0003 Correct Answer = Number A ◆Control Variables:#0003 Correct Answer += Number B ◆Text:None, None, Window, Bottom : :What is \v[1] + \v[2]? ◆Input Number:Player Answer, 3 digits ◆If:Correct Answer = Player Answer ◆Text:None, None, Window, Bottom : :Correct! ◆ :Else ◆Text:None, None, Window, Bottom : :Incorrect. ◆ :End
You can use Control Variables -> Set -> Random to store a random integer in a variable.

You can calculate simple arithmetic solutions using the Add, Sub, Mul, Div, and/or Mod operators of Control Variables, e.g.

◆Control Variables:#0001 Number A = Random 1..100 ◆Control Variables:#0002 Number B = Random 1..100 ◆Control Variables:#0003 Correct Answer = Number A ◆Control Variables:#0003 Correct Answer += Number B ◆Text:None, None, Window, Bottom : :What is \v[1] + \v[2]? ◆Input Number:Player Answer, 3 digits ◆If:Correct Answer = Player Answer ◆Text:None, None, Window, Bottom : :Correct! ◆ :Else ◆Text:None, None, Window, Bottom : :Incorrect. ◆ :End

thank you so much

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-it-so-that-every-time-i-want-my-character-to-attack-he-has-to-answer-a-question.165182/