First I suggest you check out Fomar's tutorial on getting the most out of Custom Formula. This will help you understand how these work and modify them. http://www.rpgmakerv...ormulae-part-1/ For many of the novice and intermediate game developers here, they may not know where to find the script snippets we can call to use in Custom Formula. (They're in Game_BattlerBase) Even if they did know, some would not know how to interpret them and use them to their full extent. Some may also not realize the use or see some uses for these snippets. I want to remedy that and provide a list, with the help of any contributors, of skill ideas we can do with the custom formula. Please contribute freely! First, I'd like to drop off this list. This list is all the .stat values we can use in custom formula. While the tooltip shows atk and def, it does not show pharmacology and evasion. This shows you them:
def mhp; param(0); end # MHP Maximum Hit Points
def mmp; param(1); end # MMP Maximum Magic Points
def atk; param(2); end # ATK ATtacK power
def def; param(3); end # DEF DEFense power
def mat; param(4); end # MAT Magic ATtack power
def mdf; param(5); end # MDF Magic DeFense power
def agi; param(6); end # AGI AGIlity
def luk; param(7); end # LUK LUcK
def hit; xparam(0); end # HIT HIT rate
def eva; xparam(1); end # EVA EVAsion rate
def cri; xparam(2); end # CRI CRItical rate
def cev; xparam(3); end # CEV Critical EVasion rate
def mev; xparam(4); end # MEV Magic EVasion rate
def mrf; xparam(5); end # MRF Magic ReFlection rate
def cnt; xparam(6); end # CNT CouNTer attack rate
def hrg; xparam(7); end # HRG Hp ReGeneration rate
def mrg; xparam(8); end # MRG Mp ReGeneration rate
def trg; xparam(9); end # TRG Tp ReGeneration rate
def tgr; sparam(0); end # TGR TarGet Rate
def grd; sparam(1); end # GRD GuaRD effect rate
def rec; sparam(2); end # REC RECovery effect rate
def pha; sparam(3); end # PHA PHArmacology
def mcr; sparam(4); end # MCR Mp Cost Rate
def tcr; sparam(5); end # TCR Tp Charge Rate
def pdr; sparam(6); end # PDR Physical Damage Rate
def mdr; sparam(7); end # MDR Magical Damage Rate
def fdr; sparam(8); end # FDR Floor Damage Rate
def exr; sparam(9); end # EXR EXperience Rate
Now we can use a ton of stats for our formulas! 1. How do we change the users stats when we're targeting someone else? a.stat -= \ += \ %= \ *= \ /= n Any time we put a = after a math symbol, we're telling the game to set that number to the value we get after doing that math. What can we do with this? So many things. You can cause backlash or reward for using skills. Specifically I created a skill that deals damage back to the user based on HP. r = a.hp*0.3;a.hp -= (a.hp*0.1).round;r - b.def/2 2. How do we check for a state on a target? .state?(n) Where n is the number of the state we're checking for. What can we do with this? We can do a lot. Boost damage if a state is applied, do increased healing if a state is applied, the list goes on and can be coupled with anything in the list of things we can do. Specifically I created a backstab that deals extra damage if the enemy is Surprised. b.state?(50) ? r = a.atk * 12 : r = a.atk * 4 ; r - b.def * 2 3. How do we check if we're removing a state on a target? .erase_state(n) This saves us a little work. Basically, it both removes the state and checks if there was a state to remove. What can we do with this? We can do anything extra if the state is successfully removed. For example we can do extra healing if we remove poison, or deal extra damage if the target is stunned but remove stun. Specifically I made a skill that heals HP and cures poison, but takes 3 extra mana if it removes poison. if b.erase_state(2) ; a.mp -= 3 ; end ; 50 4. How do we use elemental defense for calculations? .element_rate(n) This is returned as a decimal value. 1 = 100%, 3 = 300%, 0.5 = 50%. What can we do with this? Some really interesting and fun stuff. You can make it so you heal more if you're weaker to fire, or recover more HP if you're strong to ice. You can check if your resistance is below a certain amount and then do something. Specifically I created a fire spell that deals more damage the weaker you are to fire. (a.mat * 2 - b.mdf * 2)*a.element_rate(3) 4a. What about states? .state_rate(n)
5. Can we apply debuffs and buffs?
.add_debuff(param, turn)
.add_buff(param, turn)
Turn is the turn number for the buff to last and param is the parameter number we're debuffing.
What can we do with this?
We can set a debuff to happen by a random chance when attacking, or buff the user.
Here I've put a 50% chance to buff your defense for 2 turns when you attack, and deal 150 damage.
rand(100) <= 50 ? a.add_buff(3, 2):0;150
6. Can we stop an enemy from acting without using a stun status?
.remove_current_action
This can allow you to make a disruption skill that will stop an enemy from taking an action, great for fast characters. You may want a random chance on this though. What can we do with this?
I've made a simple one round "stun" with a 35% chance of happening and deals a flat 50 damage.
if rand(100) <= 35;b.remove_current_action;end;50 7. Can we hide an ally in battle or make an ally appear?
.hide
.appear
These two will make an enemy or ally hidden from battle or make them reappear. There are certainly some uses for skills like this or even just events in battle. When an enemy is hidden, it doesn't give EXP. When a character is hidden, you do not receive a game over when the battle ends.
What can we do with this?
We can have summons that hide characters or enemies. We can even create individual escape mechanisms, like a % chance for just the user to escape by hiding them. There's a lot of possibilities for this skill. I'll help you by going through some not-so-obvious set-ups.
Make all enemies on the battlefield appear:
$game_troop.members.each {|enemy| enemy.appear}
Make a specific enemy appear:
$game_troop.members[n].appear
Make a specific ally in your party appear (if hidden):
$game_party.members[n].appear
Make all allies in your party appear (if hidden):
$game_party.members.each {|ally| ally.appear}
8. Can we get the base value of a stat?
. param_base(param_id)
Unfortunately I can't tell you all the parameter IDs, but I'm sure once you figure them out this may be of use.
We can also check the added or debuffed amount from a parameter.
.param_plus(param_id)
.param_min(param_id)
9. Can we force an ally or enemy to use a skill (even if they haven't learned it)? Yes! .force_action(n, n) The first n is the skill id. If you randomize or array it, you can probably do some interesting stuff. The second n is the target index, where -2 is the last target selected and -1 is a random target. What can we do with this? Fun stuff! Things like make them heal or use a specific attack. Specifically I used mine to force an ally to use a random spell in the list on a random target. b.force_action(3+rand(15), -1);0 This one unfortunately has some limitations, please keep these in mind when using Force Action. Problems: If used on the user, the user repeats the spell. You must make sure a.id != b.id.
If the enemy or actor has used their turn already, they will not act. You must make sure the skill with force action will always go first. I'm not sure how the target indexing works, and cannot guide you to use it.
Appendix A: List of Conditions we can check:
#--------------------------------------------------------------------------
# * Determine if States Are Addable
#--------------------------------------------------------------------------
def state_addable?
#--------------------------------------------------------------------------
# * Determine Buff Status
#--------------------------------------------------------------------------
def buff?(param_id)
#--------------------------------------------------------------------------
# * Determine Debuff Status
#--------------------------------------------------------------------------
def debuff?(param_id)
#--------------------------------------------------------------------------
# * Determine if Buff Is at Maximum Level
#--------------------------------------------------------------------------
def buff_max?(param_id)
#--------------------------------------------------------------------------
# * Determine if Debuff Is at Maximum Level
#--------------------------------------------------------------------------
def debuff_max?(param_id)
#--------------------------------------------------------------------------
# * Determine if Skill/Item Has Any Valid Effects
#--------------------------------------------------------------------------
def item_has_any_valid_effects?(user, item)
#--------------------------------------------------------------------------
# * Determine Usability of Normal Attack
#--------------------------------------------------------------------------
def attack_usable?
#--------------------------------------------------------------------------
# * Determine Usability of Guard
#--------------------------------------------------------------------------
def guard_usable?
#--------------------------------------------------------------------------
# * Determine if Enemy
#--------------------------------------------------------------------------
def enemy?
#--------------------------------------------------------------------------
# * Determine if Actor or Not
#--------------------------------------------------------------------------
def actor?
return false
end
#--------------------------------------------------------------------------
# * Determine if Action is Possible
#--------------------------------------------------------------------------
def movable?
exist? && restriction < 4
end
#--------------------------------------------------------------------------
# * Determine if Character is Confused
#--------------------------------------------------------------------------
def confusion?
exist? && restriction >= 1 && restriction <= 3
end
#--------------------------------------------------------------------------
# * Determine if Guard
#--------------------------------------------------------------------------
def guard?
special_flag(FLAG_ID_GUARD) && movable?
end
#--------------------------------------------------------------------------
# * Determine if Substitute
#--------------------------------------------------------------------------
def substitute?
special_flag(FLAG_ID_SUBSTITUTE) && movable?
end
#--------------------------------------------------------------------------
# * Determine if Preserve TP
#--------------------------------------------------------------------------
def preserve_tp?
#--------------------------------------------------------------------------
# * Determine if State Is Resisted
#--------------------------------------------------------------------------
def state_resist?(state_id)
#--------------------------------------------------------------------------
# * Check K.O. State
#--------------------------------------------------------------------------
def death_state?
#--------------------------------------------------------------------------
# * Check State
#--------------------------------------------------------------------------
def state?(state_id)
@states.include?(state_id)
end