Game Development Reference
In-Depth Information
Dissecting the mp_damage_text Method
The second of the three action result display methods is mp_damage_text . You can see the relevant method code at the
end of this page. The first thing to notice is that, with the sole difference of the specific parameters being passed, we
have the same text issues that we had in the previous method. For example, the if statement will display the following
text, we'll use Eric, a Slime, and the number value of 50 for this.
When ActorDrain: Eric was drained of MP 50
When EnemyDrain: Drained Slime of 50 from MP.
Finding patterns in code will help you understand how things in rMVxa work. For everything else, rMVxa has a
robust ruby reference in the help file.
Tip
#--------------------------------------------------------------------------
# * Get Text for MP Damage
#--------------------------------------------------------------------------
def mp_damage_text
if @mp_drain > 0
fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
sprintf(fmt, @battler.name, Vocab::mp, @mp_drain)
elsif @mp_damage > 0
fmt = @battler.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
sprintf(fmt, @battler.name, Vocab::mp, @mp_damage)
elsif @mp_damage < 0
fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
sprintf(fmt, @battler.name, Vocab::mp, -@mp_damage)
else
""
end
end
The only real difference between this method and the previous one, besides the changes in parameter names
and the use of the ActorLoss and EnemyLoss vocabs, is the fact that the else statement has a pair of quotation marks
instead of actual content. The reasoning behind this is actually very simple: hp_damage_text already covers the text
displayed when a skill or item does no damage. Writing it out a second time in this method would be redundant.
Tweaking the mp_damage_text Method
Take a stab at tweaking this method, given what we have discussed up to now. Whenever you're ready, check the
following code to see the tweaked version.
#--------------------------------------------------------------------------
# * Get Text for MP Damage
#--------------------------------------------------------------------------
def mp_damage_text
if @mp_drain > 0
fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
if fmt = Vocab::ActorDrain
sprintf(fmt, @battler.name, @mp_drain, Vocab::mp)
 
 
Search WWH ::




Custom Search