# How to make the most of custom formulae. Part #1

#### Fomar0153

##### Arkz
Try:

Code:
``if rand(100)<85;b.add_debuff(0, 5);end;10+4*a.atk-2*b.def``
The 0 is for the stat

0 - Max HP

1- Max MP

2 - ATK

and so on

The 5 is for number of turns.

Last edited by a moderator:

#### Ronove

##### ♫꒰･‿･๑꒱
Yay! Works like a charm. Now is there a way to make it do 2 different debuffs or would this be limited to just doing one?

#### Fomar0153

##### Arkz
Hmm:

Code:
``if rand(100)<85;b.add_debuff(0, 5);b.add_debuff(1, 5);end;10+4*a.atk-2*b.def``
Might run out of room.

I'll try and finish my tutorial on bypassing the length and using more scripting features soon.

#### Ronove

##### ♫꒰･‿･๑꒱
Didn't run out of room! Thanks a bunch, I totally appreciate it. :lol:

#### Warpmind

##### Twisted Genius
Try:

Code:
``if rand(100)<85;b.add_debuff(0, 5);end;10+4*a.atk-2*b.def``
The 0 is for the stat

0 - Max HP

1- Max MP

2 - ATK

and so on

The 5 is for number of turns.
*Bow* *Scrape* *Repeat*

I, too, make a note of this for later reference. Every little bit of code I can analyze helps.

#### lohenien

##### Veteran
Oh, I stand corrected. I'm used to using states as my debuffs instead of the actual Ace debuff options that's why I thought you could set percents. That is an option though, use states for your debuffs.

#### Knightmare

##### Knight of the Night
I'm thinking of using a script that allows formulas for each individual weapon. If I wanted a weapon to do damage in a range of say 8-16 how would I do that?

#### Fomar0153

##### Arkz
I'm thinking of using a script that allows formulas for each individual weapon. If I wanted a weapon to do damage in a range of say 8-16 how would I do that?
Set variance to 0. And then it would be: min + rand(range)

So in the 8-16 example:

8+rand(9)

#### Knightmare

##### Knight of the Night
Thanks Foam I appreciate that!

#### dionisiovega

##### Villager
Really looking forward to the tutorial about bypassing the formula textbox length, that is starting to give me some problems.

#### lohenien

##### Veteran
Really looking forward to the tutorial about bypassing the formula textbox length, that is starting to give me some problems.
I believe you can already do this simply by calling a function instead of typing it all out in the damage window.

#### dionisiovega

##### Villager
I had created a separate script to handle several different attack formulas I was using, but all of them were never run completely as they errored out for some reason.

Thankfully Fomar added a tutorial for what I asked on his website, and it solved my problem. Never realized I needed class Game_Battler < Game_BattlerBase.

#### Guy

##### Villager
How would you get the formula to add a status ailment only if the spell crits?

#### Fomar0153

##### Arkz
Sorry critical hits are determined after the custom formula is ran.

#### Guy

##### Villager
Darn, well I got another silly question. ><

I am trying to make my healing spell do x 2 healing when the caster has a heal boosting buff... otherwise the spell works like normal. I can't get it to work.

> In formula box in Database:

Code:
``a.heal_spell_formula``
Script Editor:

Code:
``````class Game_Battler < Game_BattlerBase

def heal_spell_formula
if a.state?(44); ( a.mat * 1 ) ; else; ( a.mat * 2 ) ; end
end

end``````
Sorry for so many questions. ><

#### Yato

##### (aka Racheal)
Few things I noticed, Guy. Once you are working with a function in a class, 'a' and 'b' no longer apply. So it would simply be

Code:
``if state?(44); ( mat * 1 ) ; else; ( mat * 2 ) ; end``
but I think you have it backwards to what you intended. Right now it will use double the magic stat when the state is not inflicted.

and nitpicky things that don't matter per se

-mat * 1 is more than is needed. You can just use mat.-You can shorten the code to

Code:
``state?(44) ? mat*2 : mat``

Last edited by a moderator:

#### Guy

##### Villager
Thank you!

:

I was so busy trying to make it just like you would right it out in the script box in the database. :wacko:

#### Fafnir

##### And yet, these hands will never finish anything.
How would you get the formula to add a status ailment only if the spell crits?
The only way I can think of is the one Fomar himself pointed out a few posts above:
Try:

Code:
``if a.mp>=100;@result.critical=true;(a.atk*4-b.def*2)*3;else;(a.atk*4-b.def*2);end;``
Make sure the skill has no crit chance and turn the formula into this:

Code:
``if rand<=cri;@result.critical=true;FORMULA*3;b.add_state(STATEID);else;FORMULA;end;``
Where FORMULA is your base damaging formula, STATEID is the id of the state you want to inflict and I am assuming crit is still triple damage, otherwise you'd need to change that as well.

e.g

Spiffy.

### Latest Profile Posts

Quite the versatile cast so far

Degica Games Turn Komodo | RPG Maker News #77

Well, rats. Was really looking forward to trying out FPS Creator, but trying to install and set it up was pretty much impossible for my tiny brain to comprehend. So much for that, then.
Ah, home once more! I think I can safely work on my games now.
Let's hope power remains on for the day