Game Development Reference
In-Depth Information
You may be wondering the purpose of writing your formula somewhere else and calling it via code, instead of
just typing it into the formula box. Well, as I have noted already, the damage box has limited space. Take a look at the
formula that I used at one point in a game I was making using RMVXA.
a.atk>b.def ? a.atk*0.5*(1.0+(1.0-(b.def*1.0/a.atk*1.0))) : a.atk*0.5*(a.atk*1.0/b.def*1.0)
And that's after I applied some basic Ruby to shorten the expression. The above formula is written as a ternary
expression. In simpler terms, it's another way to write out an if conditional branch. It reads out as such.
If a.atk > b.def
then a.atk*0.5*(1.0+(1.0-(b.def*1.0/a.atk*1.0))
else (if a.atk < b.def) a.atk*0.5*(a.atk*1.0/b.def*1.0)
The damage formula may seem alien, but the net effect that it achieves is that a character can never deal more
damage than its total Attack stat (which is the sum of a character's Attack and the Attack that it receives from its
equipment). This formula favors lower stats a lot better than the default formula does. A similar formula is used for
games in the Dragon Quest series (where the HP cap is 999 instead of 9999, as in Final Fantasy , and thus damage/
healing has to be lower across the board).
Of course, as cool as the formula is, writing it out completely within the damage box takes up very nearly every
inch of space there is. So, I read up a bit and decided to create a module within the Script Editor instead. How do we
do that?
From the main map screen, press F11 or click Tools and find the Script Editor option.
Enter the Script Editor and then scroll all the way down to Materials. You will see a single
option titled “(Insert Here).” Click it and read what it entails.
Afterward, do as the help note recommends and insert a new page under the Materials section
of the Script Editor by right-clicking Insert Here. Here's what the filled out page looks like for me:
module Winter
module_function
def phys(p, a, b, v = $game_variables)
if a.atk > b.def
return (a.atk*p*(1.00+(1.00-(b.def*1.00/a.atk*1.00))))
else
return (a.atk*p*(a.atk*1.00/b.def*1.00))
end
end
#Express in the form Winter.phys(p, a, b)
#p is the power multiplier for the ATK stat of the caster.
def sitva(bd, p, a, b, v = $game_variables)
return ((bd + a.mat*p)*(a.mat*1.00/b.mdf*1.00))
end
#Express in the form Winter.sitva(bd, p, a, b)
#bd is the base damage of the Sitva
#p is the power multiplier for the MAT stat of the caster.
end
 
Search WWH ::




Custom Search