The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => Topic started by: Aviziel on June 08, 2011, 02:50:55 PM

Title: [VX] Any way to check for current # of party members and activate switch?
Post by: Aviziel on June 08, 2011, 02:50:55 PM
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.
Title: Re: [VX] Any way to check for current # of party members and activate switch?
Post by: exhydra on June 08, 2011, 06:41:51 PM
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
Title: Re: [VX] Any way to check for current # of party members and activate switch?
Post by: Zylos on June 08, 2011, 06:49:22 PM
It's as Exhydra says. Use a conditional branch and use the script command to check the $game_party.members.size.
Title: Re: [VX] Any way to check for current # of party members and activate switch?
Post by: Aviziel on June 09, 2011, 03:03:16 AM
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?
Title: Re: [VX] Any way to check for current # of party members and activate switch?
Post by: exhydra on June 09, 2011, 06:13:39 AM
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.
Title: Re: [VX] Any way to check for current # of party members and activate switch?
Post by: Aviziel on June 09, 2011, 07:42:24 AM
Thanks so much, Exhydra. Exactly what I needed. :D
Title: Re: [VX] Any way to check for current # of party members and activate switch?
Post by: pacdiggity on June 09, 2011, 07:56:26 AM
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.
Title: Re: [VX] Any way to check for current # of party members and activate switch?
Post by: modern algebra on June 09, 2011, 11:48:26 AM
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.
Title: Re: [VX] Any way to check for current # of party members and activate switch?
Post by: lauronpegason on June 20, 2011, 12:13:00 PM
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