High Or Low Skill

Hello! So, there was a concept for a skill I wanted to implement that I felt was complicated enough that I wasn't even going to bother asking if this would be possible without a plugin.

Basically, the skill in question is inspired by the skill "Double Up" from Lufia: The Legend Returns.

The way the ability works is that you spend all of your LP and are then presented with a card. You're then prompted to guess whether the next card will have a higher or lower value from the previous one. If you guess correctly, the damage of the attack is doubled, and the process is repeated again, but if it's incorrect, the attack ends and deals zero damage. At any point, you can choose to end the attack, causing it to deal damage based on how many times you guessed correctly.

The important aspects I feel would be needed for such a plugin would be having the skill pull a random number after each "attempt", a way to display the number (it doesn't necessarily have to be a graphic of a card, and even putting it in a text box would work), allowing the player to either guess high or low, or choose to end the attack, and having the attack deal damage accordingly.

This does sound like it might be a lot of work, but is it hypothetically possible?
This would be possible using Yanfly's Action Sequences and a common event:
  • The action sequence would run the common event, then process the "action effect" (i.e. damage).

  • The common event would handle the randomisation (Control Variables > Random), display (e.g. Show Text or Show Picture), input (e.g. Show Choices), and output a damage multiplier (Control Variables again); it can loop as many times as needed, either with Label/Jump To Label or Loop/Break Loop.

  • The skill's damage formula could then incorporate the damage multiplier variable's value, e.g. 50 times value of variable 1:
    JavaScript:
    50 * v[1]
Links to plugins required for this approach:
I've implemented something similar before, albeit a bit more complex (Steam Workshop - Skills with Event Input); based on that I think you could use this action sequence:
Spoiler: Action sequence suggestion
Code:
<target action>
</target action>
<whole action>
wait for movement
common event: 1
action effect: targets
death break
wait: 30
</whole action>
You'll need to change the common event: 1 action to reflect the ID of your common event. Also, if it's single-target, you may need to swap the <target action> and <whole action> tags (so <whole action> is empty and the actions are all in <target action>).

Your common event might look something like this:
Spoiler: Event suggestion
Code:
◆Comment:Variables:
:       :  21: damage multiplier
:       :  22: current number
:       :  23: next number
◆Comment:--------------------------------------------------
◆Comment:Initialise
◆Control Variables:#0021 Damage Multiplier = 1
◆Control Variables:#0023 Next Number = Random 1..10
◆Comment:Get guessing!
◆Loop
  ◆Comment:Move next number into current number slot
  ◆Control Variables:#0022 Current Number = Next Number
  ◆Comment:Generate next number
  ◆Control Variables:#0023 Next Number = Random 1..10
  ◆Comment:Present current number, ask for input
  ◆Text:None, Window, Bottom
  :    :Your current multiplier is \v[21].
  :    :The current value is \v[22].
  :    :Will the next value be higher or lower?
  ◆Show Choices:Higher, Lower, End (Window, Middle, #1, #3)
  :When Higher 
    ◆If:Next Number > Current Number
      ◆Comment:Success!
      ◆Text:None, Window, Bottom
      :    :\v[22] < \v[23]
      :    :\.Correct! Damage increases!
      ◆Control Variables:#0021 Damage Multiplier *= 2
      ◆
    :Else
      ◆Comment:Fail.
      ◆Text:None, Window, Bottom
      :    :\v[22] < \v[23]
      :    :\.No, that's not right. Zero damage!
      ◆Control Variables:#0021 Damage Multiplier = 0
      ◆Break Loop
      ◆
    :End
    ◆
  :When Lower 
    ◆If:Next Number < Current Number
      ◆Comment:Success!
      ◆Text:None, Window, Bottom
      :    :\v[22] > \v[23]
      :    :\.Correct! Damage increases!
      ◆Control Variables:#0021 Damage Multiplier *= 2
      ◆
    :Else
      ◆Comment:Fail.
      ◆Text:None, Window, Bottom
      :    :\v[22] > \v[23]
      :    :\.No, that's not right. Zero damage!
      ◆Control Variables:#0021 Damage Multiplier = 0
      ◆Break Loop
      ◆
    :End
    ◆
  :When End 
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above
◆Text:None, Window, Bottom
:    :Damage multiplier: x\v[21]
This would be possible using Yanfly's Action Sequences and a common event:
  • The action sequence would run the common event, then process the "action effect" (i.e. damage).

  • The common event would handle the randomisation (Control Variables > Random), display (e.g. Show Text or Show Picture), input (e.g. Show Choices), and output a damage multiplier (Control Variables again); it can loop as many times as needed, either with Label/Jump To Label or Loop/Break Loop.

  • The skill's damage formula could then incorporate the damage multiplier variable's value, e.g. 50 times value of variable 1:
    JavaScript:
    50 * v[1]
Links to plugins required for this approach:
I've implemented something similar before, albeit a bit more complex (Steam Workshop - Skills with Event Input); based on that I think you could use this action sequence:
Spoiler: Action sequence suggestion
Code:
<target action>
</target action>
<whole action>
wait for movement
common event: 1
action effect: targets
death break
wait: 30
</whole action>
You'll need to change the common event: 1 action to reflect the ID of your common event. Also, if it's single-target, you may need to swap the <target action> and <whole action> tags (so <whole action> is empty and the actions are all in <target action>).

Your common event might look something like this:
Spoiler: Event suggestion
Code:
◆Comment:Variables:
:       :  21: damage multiplier
:       :  22: current number
:       :  23: next number
◆Comment:--------------------------------------------------
◆Comment:Initialise
◆Control Variables:#0021 Damage Multiplier = 1
◆Control Variables:#0023 Next Number = Random 1..10
◆Comment:Get guessing!
◆Loop
  ◆Comment:Move next number into current number slot
  ◆Control Variables:#0022 Current Number = Next Number
  ◆Comment:Generate next number
  ◆Control Variables:#0023 Next Number = Random 1..10
  ◆Comment:Present current number, ask for input
  ◆Text:None, Window, Bottom
  :    :Your current multiplier is \v[21].
  :    :The current value is \v[22].
  :    :Will the next value be higher or lower?
  ◆Show Choices:Higher, Lower, End (Window, Middle, #1, #3)
  :When Higher
    ◆If:Next Number > Current Number
      ◆Comment:Success!
      ◆Text:None, Window, Bottom
      :    :\v[22] < \v[23]
      :    :\.Correct! Damage increases!
      ◆Control Variables:#0021 Damage Multiplier *= 2
      ◆
    :Else
      ◆Comment:Fail.
      ◆Text:None, Window, Bottom
      :    :\v[22] < \v[23]
      :    :\.No, that's not right. Zero damage!
      ◆Control Variables:#0021 Damage Multiplier = 0
      ◆Break Loop
      ◆
    :End
    ◆
  :When Lower
    ◆If:Next Number < Current Number
      ◆Comment:Success!
      ◆Text:None, Window, Bottom
      :    :\v[22] > \v[23]
      :    :\.Correct! Damage increases!
      ◆Control Variables:#0021 Damage Multiplier *= 2
      ◆
    :Else
      ◆Comment:Fail.
      ◆Text:None, Window, Bottom
      :    :\v[22] > \v[23]
      :    :\.No, that's not right. Zero damage!
      ◆Control Variables:#0021 Damage Multiplier = 0
      ◆Break Loop
      ◆
    :End
    ◆
  :When End
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above
◆Text:None, Window, Bottom
:    :Damage multiplier: x\v[21]
That ended up working perfectly! Furthermore, it taught me a lot about what kind of things I can do with common events in battles, and it's just so much fun to mess with! Thank you very much for giving such a thorough answer and helping me figure out how to do this.

Original thread: https://forums.rpgmakerweb.com/threads/high-or-low-skill.118785/