Game Development Reference
In-Depth Information
Escape effect (you'll want to give the item itself a scope of User), the player will be able to retreat from any battle. To
counter that, we need a way to make sure that the player is allowed to escape the battle. Make your way to the Script
Editor and take a look at the BattleManager module. Near the top of the page, you'll see a particular variable named
@can_escape . That variable shows up within the can_escape? method in BattleManager and determines whether or
not the player can escape from a particular battle. By default, the player can escape from every randomly generated
battle and all event-created ( Battle Processing ) battles that have the Can Escape check box toggled. Conversely,
escape from an event battle with Can Escape untoggled is impossible. Now, let's create the common event that will
handle the Smoke Bomb logic. Of particular note is the fact that you can use script code within conditional branches to
the same effect as the more standard uses I have covered up to now. To call a method using a script, you use the format
Module.method . That's why we have BattleManager.can_escape? in the following code.
@>Conditional Branch: Script: BattleManager.can_escape? == true
@>Comment: Escape = TRUE
@>Change Items: [Smoke Bomb], -1
@>Text: -, -, Normal, Bottom
: : You distract the enemy with the Smoke Bomb and
: : escape!
@>Abort Battle
@>
: Else
@>Comment: Escape = FALSE
@>Text: -, -, Normal, Bottom
: : You can't escape from this fight!
@>
: Branch End
@>
When the player uses a Smoke Bomb, we check to see if he/she can escape the fight in question. If the
@can_escape variable returns true, the player can escape. In that case, we consume one Smoke Bomb, display a
message, and abort the battle. If the player cannot, he/she will receive an error message saying as much, and the item
will not be consumed. I'll leave the creation of the item up to you. Now, there are two more things to discuss before
the end of this chapter. Thing the first . . .
Making Specific Random Battles Inescapable
We have created an item that can be used to escape from a battle with no fail rate, so long as the player is allowed to
escape it normally. Now, that brings up an interesting question: What happens if we want to make certain random
battles inescapable? It's as easy as creating a new method within the BattleManager module.
module BattleManager
def self.set_can_escape(bool)
@can_escape = bool
end
end
 
Search WWH ::




Custom Search