Summon State and Common Events help!

Hello, I followed a video on how to add summons to the game using common events which works great, but my 1 issue I'm having is switching the actor back to a empty slot once the counter expires, I'm going to explain everything with pictures of my state etc.

This is a lot of info and I apologize I just want to be thorough as possible with my question!!!

The plugin I am using to make this possible so far is YEP PartySystem

ACTOR 10

1679583855098.png

This is my actor 10! I set his class to the appropriate class with move set and the moves work fine in battle!

Here's where it starts to get tricky:

I figured out that adding and removing the actors will screw up in battle meaning if you have more then 4 actors and summon a 5th, into battle, it will just add the 5th actor in your party to the fight in most cases. So my solution is to add 3 empty actors in the beginning of the game, lock actor 5 and remove actor 3 and 4!

1679584082318.png


Here is the starting event in my game

1679584107882.png


(Actor 2 is not important nor is the hard mode in this scenario)


So now we have Beginning sequence 1 and 2 that are invisible, that instantly leave after the event plays, and Actor 30, Summon Slot is now added to the party, like so:

1679584205899.png


Now I add in 3 other party members, since summoning won't be available before then, note how the 5th slot is empty which is what I want so far!

This is where it gets more confusing but it is my lack of knowledge on how the syntax of the code goes I suppose:

This is the Summon State with the counter of how long the summon exists:

1679584550518.png

The full code in the note tag is this:
Code:
<Custom Remove Effect>
$gameVariables.setValue(348, $gameParty.allMembers());
If 348 = 7
$gameParty.swapOrder(4, 6)
$gameParty.removeActor(10);
$gameParty.removeActor(11);
else
If 348 = 8
$gameParty.swapOrder(4, 7)
$gameParty.removeActor(10);
$gameParty.removeActor(11);
</Custom Remove Effect>

The note tag WITHOUT the If then statements WORKS but my game works as there will up to 9 potential swapping party members, so I need the event to check if there is 7 8 9 or 10 party members once the summon is included.

This parallel works for removing the actor if the summoned actor didn't expire or die, just be sure to switch on a switch at the beginning of the game:

1679584893681.png

So my main question is How do I write the state notetag "if then" syntax correctly?
x
not sure if "if 348 === 8" with work without curly brackets "( )"
as most if statement is "if (348 === 8) do stuff".

but this might work:
JavaScript:
<Custom Remove Effect>
let gv = $gameVariables.setValue(348, $gameParty.allMembers());
If (gv === 7) {
$gameParty.swapOrder(4, 6)
$gameParty.removeActor(10);
$gameParty.removeActor(11);
} else if (gv === 8) {
$gameParty.swapOrder(4, 7)
$gameParty.removeActor(10);
$gameParty.removeActor(11);
} else {
    //whatever else if NOT battle members 7,8,9,10 etc
    // which is maybe empty to do nothing?
}
</Custom Remove Effect>

cannot guarantee this will work thoug, bu you can test it.
It would be helpful if you linked to the video that you followed. That helps us make sure there's no error in the logic of what you copied over.

Have you tried using a plugin that offers this functionality? The SRD_Summon works well and works with the Yanfly Party plugin and doesn't require to jump through all this rigamarole.

The full code in the note tag is this:
Code:
<Custom Remove Effect>
$gameVariables.setValue(348, $gameParty.allMembers());
If 348 = 7
$gameParty.swapOrder(4, 6)
$gameParty.removeActor(10);
$gameParty.removeActor(11);
else
If 348 = 8
$gameParty.swapOrder(4, 7)
$gameParty.removeActor(10);
$gameParty.removeActor(11);
</Custom Remove Effect>
A significant portion of this is incorrect JavaScript syntax.
Code:
$gameVariables.setValue(348, $gameParty.allMembers());
You're setting variable 348 to an array of actors, then later you're checking for it to be a specific value. That doesn't make sense. Are you trying to set it to be the number of actors in the party? That's
Code:
$gameVariables.setValue(348, $gameParty.allMembers().length);

Then...
Code:
If 348 = 7
$gameParty.swapOrder(4, 6)
There's a lot wrong here.
- "if" is not capitalized
- if statements require the conditions to be in parentheses
- if statements only apply to the next single code statement unless you create a code block with braces
- = is an assignment operator, you're setting the number 348 equal to the number 7, which produces an error. To check for equality you use ==
- Just 348 doesn't mean anything, you're looking for the value of game variable 348.
Code:
if ($gameVariables.value(348) == 7)
{
    $gameParty.swapOrder(4, 6)
    $gameParty.removeActor(10);
    $gameParty.removeActor(11);
}

Then...
Code:
else
If 348 = 8
There's no line break between "else if".

So my main question is How do I write the state notetag "if then" syntax correctly?
If you Google the question, you'll find free JavaScript tutorials to help you.


let gv = $gameVariables.setValue(348, $gameParty.allMembers());
That doesn't work - setValue() does not return a value.

And the rest is still following what ZCSully did with storing an array then trying to compare it to a single value.
not sure if "if 348 === 8" with work without curly brackets "( )"
as most if statement is "if (348 === 8) do stuff".

but this might work:
JavaScript:
<Custom Remove Effect>
let gv = $gameVariables.setValue(348, $gameParty.allMembers());
If (gv === 7) {
$gameParty.swapOrder(4, 6)
$gameParty.removeActor(10);
$gameParty.removeActor(11);
} else if (gv === 8) {
$gameParty.swapOrder(4, 7)
$gameParty.removeActor(10);
$gameParty.removeActor(11);
} else {
    //whatever else if NOT battle members 7,8,9,10 etc
    // which is maybe empty to do nothing?
}
</Custom Remove Effect>

cannot guarantee this will work thoug, bu you can test it.

I did something along the lines of this just writing the variables differently and it worked! The bracket stuff just confused me around the else if's etc..

It's just my common event that checks the party # when summoned now is broken if I put conditionals in there, I am going to just play around until it fixes!


@ATT_Turan
"It would be helpful if you linked to the video that you followed. That helps us make sure there's no error in the logic of what you copied over.

Have you tried using a plugin that offers this functionality? The SRD_Summon works well and works with the Yanfly Party plugin and doesn't require to jump through all this rigamarole."

(I don't know how to quote I tried the quote command but couldn't figure it out)

I can link you the video right here!
It's a very old video



I tried to use SRD Summon, it's actually in my load order, the problems I had with it:

The exit animation was incompatible with something about YEP SV animated enemies, so I changed the exit animation to just change the actor opacity to 0 and that worked! But then I got a pop up damage error the second my summoned actor damaged the enemy which was weird.

Regarding the rest of the corrections, thank you so much, I should always refer to that link I just forget about it sometimes, I ended up kind of going through the


Link for RPG Maker MV script calls, and just wrote out code based on a If else if statement that I found inside one of the examples!
(I don't know how to quote I tried the quote command but couldn't figure it out)
If you use the +Quote button, an "Insert Quotes" button appears at the bottom of the post you're writing. You click it.

Or you can just click Reply.

I tried to use SRD Summon, it's actually in my load order, the problems I had with it:
You'd have to post a thread with the precise issues, all I can tell you is that I use SRD Summon with Yanfly's Party System and Animated SV Enemies and it works no problem.

Link for RPG Maker MV script calls, and just wrote out code based on a If else if statement that I found inside one of the examples!
If you can please find where in that document you saw conditionals typed out with that kind of syntax, it would be good to get it corrected.
If you use the +Quote button, an "Insert Quotes" button appears at the bottom of the post you're writing. You click it.

Or you can just click Reply.


You'd have to post a thread with the precise issues, all I can tell you is that I use SRD Summon with Yanfly's Party System and Animated SV Enemies and it works no problem.


If you can please find where in that document you saw conditionals typed out with that kind of syntax, it would be good to get it corrected.
Thank you!


I can post a new thread with the issues if you want I just have to recreate them with screenshots which will take a few minutes!

No, I meant after I posted this I went and looked at the syntax which was correct, instead of searching on the javascript page that you sent, because I started searching for answers before any responses haha. The page is correct!
I don't think it needs to be a new thread as it pertains to this issue. But yes, screenshots of any errors (hit F8 and go to the Console tab) and a description of what's happening.
I don't think it needs to be a new thread as it pertains to this issue. But yes, screenshots of any errors (hit F8 and go to the Console tab) and a description of what's happening.
Ooooh okay I will report my new thread to be taken down as I post it here:

This happens when the summon runs out of turns or I'm assuming dies!:
1679591040440.png

1679591048079.png

This is another issue I'm having:

When some summons attack the this pops up right before the hit splat:

1679591063559.png

1679591069038.png
I appreciate you providing information, but you don't need to do so much 🤣

The Yanfly error log and the Console tab show the exact same thing, so just one of those is sufficient.

And the Elements tab is useless.

Have you tried simply rearranging the plugin order in your plugin manager? Everything works for me with the Summon Core beneath all the Yanfly stuff.

Aside from that, I guess a screenshot of your summon skill.
I appreciate you providing information, but you don't need to do so much 🤣

The Yanfly error log and the Console tab show the exact same thing, so just one of those is sufficient.

And the Elements tab is useless.

Have you tried simply rearranging the plugin order in your plugin manager? Everything works for me with the Summon Core beneath all the Yanfly stuff.

Aside from that, I guess a screenshot of your summon skill.
😅.. I did not know that haha! I guess that does make sense.

I will show you the bottom of my plugin list, unless there is a way to provide my entire plugin list in one picture or text:

1679591580530.png


This is as much of it as I can get, the only cutoff part is <Cooldown: 5>
1679591637221.png
Have you made sure the rest of your Yanfly plugins are in the correct order?

If they're not in the order listed on the Yanfly Engine Library page, it can cause weird glitches.

I'm using all of the plugins listed in your error trace, plus the Summon Core, and I don't have any issues.

If you check that the entire order is correct, I suggest some basic, logical troubleshooting.

- turn off all plugins except the summon, see if it works
- if yes, turn back on half of your plugin list, see if it works
- if yes, turn those off and turn on the other half. If no, turn off half of those.
- Continue until you isolate the specific combination of plugins that produces an error.
Have you made sure the rest of your Yanfly plugins are in the correct order?

If they're not in the order listed on the Yanfly Engine Library page, it can cause weird glitches.

I'm using all of the plugins listed in your error trace, plus the Summon Core, and I don't have any issues.

If you check that the entire order is correct, I suggest some basic, logical troubleshooting.

- turn off all plugins except the summon, see if it works
- if yes, turn back on half of your plugin list, see if it works
- if yes, turn those off and turn on the other half. If no, turn off half of those.
- Continue until you isolate the specific combination of plugins that produces an error.
How badly will this screw up my game by turning them off? will the parameters save?

I will try this in a bit when I get back to my computer thank you so much!!

I hope to answer back here to you or at least edit this comment within the next few hours 🙂
use the plugin in my spoiler (ALOE_YEP_PluginOrderChecker) to see which one
are correct and incorrect.

I forgot the rest of the code when I post a solution which ATT_Turan mentioned
on the length (that I forgot) but specially overlook the "setValue" for value and
the capitalize "If" that is always lowercase "if", which I should corrected.

ATT_Turan is good in lunatic code and can help you set it up right.
but start with setting all YEP plugin in the correct order as they crash or
dont work correctly when placed incorrectly.
How badly will this screw up my game by turning them off? will the parameters save?
It doesn't screw up your game, or I wouldn't have recommended it as a standard troubleshooting measure.

Plugin parameters are saved in your project until you delete the plugin from your plugin manager. Turning it off and on does nothing permanent.
Moderator note: Closed at OP's request

Original thread: https://forums.rpgmakerweb.com/threads/summon-state-and-common-events-help.156072/