Game Development Reference
In-Depth Information
as you'll find out later in the topic when I delve ever deeper into scripting, I'm not the biggest fan of adding
things to preexistent rmvXa code. It is preferable to create a new script page (by right-clicking under the materials sec-
tion of the script editor and clicking Insert) and write up your new code on it. the preceding code assumes that you'll be
using a new script page.
Note
The preceding method is a simple one-liner. The bool inside the parentheses is a method parameter (recall our
use of these back in Chapter 3 with the custom damage formulas). Because @can_escape is meant to be either true or
false (an assertion that you can verify by seeing how it is used within BattleManager ), those are the values you should
use for the method parameter. How do you use that new method? The easiest way is to have a troop event that triggers
on Turn 0 and uses a script call for the new method. So, if you want to make it so that the player cannot escape from
Slimes (for whatever reason), all you have to do is structure the troop event as follows:
Condition: Turn 0
Span: Battle
@>Script: BattleManager.set_can_escape(false)
Once the battle begins, you'll notice that it is impossible to escape, whether via the Escape command or the use
of Smoke Bombs. In this way, it is possible to make troops that prevent the player from escaping when encountered.
Additional Exercises
Before we end this chapter, I'll leave some more exercises for you to tackle concerning common events.
1.
Create a note that someone would write before embarking on a long journey. Leave it
on a table for the player to find and add to his/her inventory.
You can have the note display its text when the player grabs it. Then, you make it a key
item that cannot be consumed and have the common event, if the player ever wants to
read its text again.
2.
Make a troop with three enemies, in which one enemy gives a random anti-elemental
barrier to its allies.
You can cover random with a variable similar to the seed we used for the treasure chest
minigame. Just have the variable roll from 1 to 3.
Create one skill for each type of anti-elemental barrier.
The common event would have conditional branches for the three possible results. When
the enemy with the skill uses it, the common event will trigger. The type of barrier will
depend on the value of the variable and will be applied by means of Force Action. (Make
sure you're applying Force Action to the skill user; it will be best if you only have one
enemy that can use this skill.) Following is some sample code:
@>Control Variables: [0018:BarrierUp] = Random No. (1...3)
@>Conditional Branch: Variable [0018:BarrierUp] == 1
@>Force Action: [1. ], [Anti-Earth Barrier], Last Target
@>
: Branch End
@>Conditional Branch: Variable [0018:BarrierUp] == 2
@>Force Action: [1. ], [Anti-Thunder Barrier], Last Target
 
 
Search WWH ::




Custom Search