Main Menu

[VX] Any way to check for current # of party members and activate switch?

Started by Aviziel, June 08, 2011, 02:50:55 PM

0 Members and 1 Guest are viewing this topic.

Aviziel

Basically, I'd like to know if there's any way to run a check and see if there are four/certain number of members currently in the party, and then throw a switch/fiddle with a variable.

exhydra

You could either use a nested conditional branch that would look something like this :

Conditional Branch : Ralph is in the party
-Conditional Branch : Ulrika is in the party
--Conditional Branch : Bennett is in the party
---Conditional Branch : Ylva is in the party
----Control Switches : [0001] = On

Or use a script like this :

AcN = $game_actors[1]
A = $game_party.members.include?(AcN)
AcN = $game_actors[2]
B = $game_party.members.include?(AcN)
AcN = $game_actors[3]
C = $game_party.members.include?(AcN)
AcN = $game_actors[4]
D = $game_party.members.include?(AcN)
if A && B && C && D then
$game_switches[1] = true
end

Where the numbers displayed within '$game_actors[1], $game_actors[2], etc' are the index numbers of the actors you want to check for. As in, the number displayed on the Database window under the Actors tab. The script could probably be made better, but that's the basic idea and it should work.


EDIT : Oh, you're only wanting to check for a certain number of members? Oop, I guess your question came across wrong to me. You can try this for determining if you have four people in the party currently :

if $game_party.members.size == 4
(Do Stuff)
end

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

Zylos

It's as Exhydra says. Use a conditional branch and use the script command to check the $game_party.members.size.




Aviziel

I hate to look foolish here, but I've never messed around or learned how to use the scripting in VX or XP, so I've got no idea what I'm doing, really.

When I put

if $game_party.members.size == 4

in the script section of a conditional branch and then try it out, I get a SyntaxError. I'm sure I'm missing something simple, or just doing something wrong?

exhydra

Ah, not a problem. Use the Script button on the third tab of the Event Commands window. Now, if you wanted to turn the 5th Switch in your list on, you would put this into the Script window :

if $game_party.members.size == 4
  $game_switches[5] = true
end

Now if you wanted to set the 5th variable in your list, you would do the same thing but with a slightly different middle section :

if $game_party.members.size == 4
  $game_variables[5] = (Whatever Number or Data You Want)
end

Just change the [5] to whatever index of Switch or Variable that you want.

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

Aviziel


pacdiggity

Alternatively, you could simply make a variable equal to the number of members in the party. It's in no way better, just something I realised. Also that way you could simply check the variable itself rather than the global.
$game_variables[VARIABLE_ID] = $game_party.members.size
Will make variable VARIABLE_ID equal to the number of members in the party.
it's like a metaphor or something i don't know

modern algebra

Zylos was also right in that you could use the script option of Conditional Branch as well. You would need to remove the if though and just put:


$game_members.size == 4


It might be useful in the future so you won't have to get the code for every event command. Pacman's way would be good for that as well.

lauronpegason

This is how I did it, which is kind of what you do when you don't know anything about scripting :V

@>Control Variables: [0001:Party_Members] = Party Members
@>Conditional Branch: Variable [0001:Party_Members] == 4
    @>Control Switches: [0001:Switch] = ON
Current Project: