Game Development Reference
In-Depth Information
Overview
For this exercise, you'll need the following:
A new test map (the tileset and the size do not matter). Then, copy-paste the Gemini event
from the first dungeon to our test map.
An Autorun event that is only active when a switch is flipped. This event will use a scripted
conditional branch to determine whether Noah is in the active party. If he is, we process the
battle against Gemini. If he isn't, we have Noah say some words and use the Open Menu
command to allow the player to change his/her active lineup.
The Autorun will keep running until Noah is in the active party.
This is a rather easy event. The only thing that should even give you a second of pause by now is the single line
that we have to use as a conditional branch. To find it, we must figure out how RMVXA handles party members
internally.
Finding Out How RMVXA Handles Party Members
A good place to start figuring that out is the conveniently named Game_Party . We needn't go far, as we already see
some promising code by line 70. Look at the following to see lines 63 to 74 of the Game_Party class.
#--------------------------------------------------------------------------
# * Get Battle Members
#--------------------------------------------------------------------------
def battle_members
all_members[0, max_battle_members].select {|actor| actor.exist? }
end
#--------------------------------------------------------------------------
# * Get Maximum Number of Battle Members
#--------------------------------------------------------------------------
def max_battle_members
return 4
end
In fact, the method we need happens to be battle_members . In essence, what the single line of code within that
method does is find every available party member and then take the first one to four of them and place them into an
array. This array is $game_party.battle_members .
We use battle_members , as only the active party members can participate in battle. We want to see if noah is
part of that array or not.
Note
Now, the next question is: How do we use that array? Click Help in RMVXA's Main Menu toolbar and run a search
for Array. The first search result will be thus named. This is one of RMVXA's many Ruby reference pages. The array
method we want to use is called include? (the question mark is not a typo). Figure 15-1 is a screenshot of what the
reference file has to say about this particular method.
 
 
Search WWH ::




Custom Search