Action Sequence Nested IF

SergeofBIBEK

Villager
Member
Joined
May 8, 2017
Messages
6
Reaction score
36
First Language
English
Primarily Uses
RMMV
Action Sequence Nested IF 1.00
SergeofBIBEK

Hey everyone! I made a plugin that I think would be useful to hardcore action sequence makers!

**Introduction**

This is a really simple plugin. It allows you to nest IF statements in action sequences.

**How to Set Up**

Place this plugin below YEP_BattleEngineCore.

**How to use IF in Action Sequences**

To start an IF, use the following command:
Code:
     IF condition
The condition is whatever you would put in a normal JS IF statement.

Then end the IF with the following command:
Code:
     END
Here is an example:
Code:
     <Target Action>
     if user.mp > 100
     animation 5: target
     wait for animation
     action effect
     mp -100: user, show
     wait: 10
     end
     </Target Action>
You can also still use else and else if like this:
Code:
     ELSE
     ELSE IF condition
The condition follows all the same rules as the IF conditions
Code:
     <Target Action>
     if user.mp > 100
     animation 5: target
     wait for animation
     action effect
     mp -100: user, show
     wait: 10
     else
     animation 3: user
     wait for animation
     mp +50: user, show
     end
     </Target Action>
But Wait! There's more!
Now you can nest your if statements!
Code:
     <Target Action>
     
     if user.mp > 100
     animation 5: target
     wait for animation
     action effect
     mp -100: user, show
     wait: 10
     
     if user.hp > 100
     animation 3: user
     wait for animation
     action effect
     hp -100: user, show
     end
     
     end
     </Target Action>
In this example the user will do damage if their mp is OVER 100,
then do damage again if their hp is OVER 100. If their mp is
is UNDER 100 then nothing will happen. EVEN if their HP is 101+.

Since that if is inside the other if, it won't happen unless the
first IF's conditions are met. Nest IFs, just like JS!

**Script**

*You can get the latest version here:*
[Action Sequence Nested IF](https://www.dropbox.com/s/z4tvqmc2u9mmtn8/SergeofBIBEKActionSequenceNestedIf.js?dl=0)

**Credit and Thanks**

SergeofBIBEK (me!)

Yanfly: You couldn't even nest IFs in Action Sequences without Yanfly's amazing Action Sequences plugins!!

**License:**

Free for any use, do whatever you want. Don't even have to credit me anywhere!
 

Neo Soul Gamer

Veteran
Veteran
Joined
Aug 10, 2012
Messages
628
Reaction score
344
First Language
English
Primarily Uses
N/A
I'm not a big Action Sequence user, so excuse my ignorance... But isn't this already a feature in Yanfly's plugin? What's the difference between the included feature and your addon?

From the help file:


Code:
=============================================================================
IF ... ELSE STATEMENTS
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
For those familiar with programming, you can use if...else statements to
perform different actions based on different conditions. Use 'if' to
specify a block of code to be executed, if a specified condition is true.
Use 'else'  to specify a block of code to be executed, if the same
condition is false. Use 'else if' to specify a new condition to test, if
the first condition is false. Use 'end' to specify where the conditions
are to end.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Usage Example:
    if $gameSwitches.value(1)
        action effect
    else if $gameSwitches.value(2)
        action effect
        action effect
    else
        action effect
        action effect
        action effect
    end

*Note: You do not have to indent the code in between to work. It just
looks better that way in your action sequences.
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
585
Reaction score
329
First Language
English
Primarily Uses
RMMV
You couldn't nest if statements in the action sequences before using this plugin. The plugin was designed such that the first 'end' that it reads would close all if statements, instead of the current one.
Code:
if (something)
 stuff
 if (something else)
  optional stuff
 end
 more stuff
end
That above sequence would originally only do stuff, and possibly optional stuff, but never more stuff... If that makes sense.
 

Neo Soul Gamer

Veteran
Veteran
Joined
Aug 10, 2012
Messages
628
Reaction score
344
First Language
English
Primarily Uses
N/A
@ramza

Makes perfect sense. Like I said, I'm not a big Action Sequence user, so I've never attempted to nest IF statements with them. I had to ask to make sure. Thanks!
 

AdamSakuru

[Null_Value]
Veteran
Joined
Mar 14, 2014
Messages
314
Reaction score
170
First Language
English
Primarily Uses
N/A
Just a note for anyone using SRD's Timed Attack Core plugin (and any of the add-ons for it), you have to place this plugin above those otherwise it seems to make them not function at all.

Edit:
No intention of Necro-posting. This is a very handy plugin!
 

Magusalfador

Veteran
Veteran
Joined
Jun 15, 2014
Messages
209
Reaction score
36
First Language
English Spanish
Primarily Uses
OMG, I lost two days of my life and a great deal of hair not knowing Yanfly Action Sequences does not support nesting. I F*** love you for this plug in.
 

Person1

Angra
Member
Joined
Jan 23, 2019
Messages
5
Reaction score
1
First Language
Portugues
Primarily Uses
RMMV
So from what I understand, you can set conditions on your action sequences. So can I make so if the character is going to land a critical hit, it does a different animation? For example, the way it works on Chrono Trigger and Persona 4 where the MC does a normal slash but on critical hit, the MC jumps into the enemy and does multiple slashes. Can this plug in do that?
 

Magusalfador

Veteran
Veteran
Joined
Jun 15, 2014
Messages
209
Reaction score
36
First Language
English Spanish
Primarily Uses
Hmm I dont know how to check if the hit will be critical so it does another animation. what you can do is your own critical system in your attack skill and then in that case is possible. Like:

random numer between 1 and 100
if its 4 or less
do critical animation
else
do normal attack anmation
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

40 card deck size, the plugin seems more sluggish.
Village theme I composed for a commission!
Stream will be live shortly with some Haunting Ground! Feel free to drop by!
welp, the stock market went down by 7% because of corona today. Time to buy stocks?

Forum statistics

Threads
94,563
Messages
921,921
Members
124,429
Latest member
sheepman
Top