Game Development Reference
In-Depth Information
The method has a one-line expression that checks to see if the battler is afflicted with the Death state, as defined
in the death_state_id method (the one right below death_state? , actually; it returns a value of 1). Trying to reinvent
the wheel here is something you should only try when you gain greater expertise in Ruby. For now, tweaking that
expression will suffice. The easiest way to do that is by using || or or to add new state? expressions.
Note
either operator will work in this case.
So, suppose you wanted to make it so that Paralysis (state #7 in the default state list in RMVXA) counts as an
incapacitating state. First, go to the States tab and change it, so that it can only be removed at the end of battle. Then,
return to the death_state? method and tweak it like so:
def death_state?
state?(death_state_id) || state?(7)
To test whether the change is working or not, you can give one of the existing enemies a Paralysis-inducing skill
(or give their normal attacks a 100% Paralysis State Rate) and then run a Battle Test. If you get a Game Over screen
after being afflicted by Paralysis, you'll know that it is working correctly. Speaking of game overs, I have one last
exercise to work through.
Adding a Menu to the Game Over Screen
This last exercise is going to involve some copy-pasting. Mainly, we're going to copy the RMVXA code that handles the
Title screen's menu and integrate that into the class that governs the Game Over screen. The first order of business is
finding the two classes. As it so happens, both the Title screen and the Game Over screen are governed by classes with
the Scene prefix. Copy Scene_Title and Scene_Gameover to the Materials section of the Script Editor. Next, take a look
at Scene_Gameover and analyze what is going on.
Scene_Gameover starts with a method (called start ) that calls to its parent in Scene_Base by
use of super . Next, it executes three methods of its own.
As a whole, the methods create the background that says “game over,” handle the fade-out
after the party is defeated and the subsequent fade-in to the Game Over screen, and play the
appropriate music.
There are several other methods that handle graphics processing within the class, but what
we're interested in is the transition to Title screen method ( goto_title ).
As we want the game to cause a menu to pop up at the Game Over screen, instead of just cutting to the Title, we
might as well go ahead and excise what we won't be using. Delete the goto_title method and then erase goto_title
if Input.trigger?(:C) from the update method near the top of the class. With that done, we move over to Scene_
Title . Our objective at the Scene_Title class is to figure out what methods are used to call up the Title screen's menu.
If we take a look at the start method for Scene_Title , we see that six methods are called up. Our method of interest is
create_command_window . A closer look at it (it starts on line 91) shows the following code:
def create_command_window
@command_window = Window_TitleCommand.new
@command_window.set_handler(:new_game, method(:command_new_game))
@command_window.set_handler(:continue, method(:command_continue))
@command_window.set_handler(:shutdown, method(:command_shutdown))
end
 
 
Search WWH ::




Custom Search