How to make the most of custom formulae.

So earlier today in rpgmaker’s irc chat the conversation moved to the scripts someone desired for their game which included:

favorite foods – i can specify each actor’s favorite food and when the item is used on them, they heal extra hp or something

Anyhow I pretty quickly realised a script was not needed to implement this feature. RPG Maker Ace once again proves just how versatile it is because this feature can be implemented in a single input box. In particular this one:

That formula box alone has tremendous potential. I offered two solutions to the problem.

if b.id == 1; 500; else; 100; end;

b.id == 1 ? 500 : 100

Let us first look at exactly what they are doing. They both check a conditional statement, namely:

b.id == 1

For the formula box in general a refers to the attacker or user and b refers to the defender or recipient, who may or may not be the same.

Any way what we are checking is that the recipient’s id is equal to 1. Please note that this example is about an item which should be usable on party members only and therefore b is always going to be an actor (party member in English). So essentially we are checking that the person who the item is being used on is first in the database (Eric by default).

Now let’s look at the rest of those lines.

if b.id == 1; 500; else; 100; end;

If you’ve done any programming before you will recognise this as a standard if statement. If you’re confused about the presence of the semi-colons then let me quickly explain that they are like a way of inserting a new line. Were we not restricted to a single line then we could have written it like this:

if b.id == 1

500

else

100

end

So what this means is when the character id equals 1, heal 500HP otherwise heal 100HP. The other version achieves the same result but might be a little less clear if you are not overly familiar with ruby.

b.id == 1 ? 500 : 100

It still has the conditional, it is still checking if the item is being used on Eric but the rest of the code you could say has been condensed. This effectively boils down to:

condition ? true : false

The last thing two things I want to say before moving on are firstly that for more complicated situations you are probably better going the if statement route and the last thing is that while the formula box is pretty powerful you need to be aware that it is capped at a certain length (let’s be grateful that we use a & b and not attacker & defender) and if there is an error in your formula the skill will just miss repeatedly rather than crash the game.

Right so that concludes the explanation section of this tutorial. I personally find having a lot of examples to work from quite helpful so this next section is going to be a problem and solution section and hopefully one of them will be close enough to what you hope to achieve that you can adapt it.


Scenario: Half your party are demi-humans or robots and require different healing items than the rest of your party.

There are some quite creative solutions to this problem but for the sake of this tutorial I want to keep is simple. So the solution I offer just checks the ids again.

(b.id==1 or b.id==3 or b.id==4) ? 500 : 0

A couple of things I would like to draw your attention to. I have omitted the spaces on both sides of == because when we’re space conscious they are wasted characters. The other feature is the ors they act like you’d expect but be careful when using and because it has a bit more to it.


Scenario: One character’s favourite food is peanut butter sandwiches but another character is allergic to peanuts.

So the way I’m going to implement it is that Eric gets a bonus 100 health when he eat the sandwich but Natalie is afflicted by poison when she eats one.

if b.id==1;200;elsif b.id==2;b.add_state(2);0;else;100;end;

So it was a bit more complicated this time so I went the route of the if statement, elsif is a way of checking another condition if the first one wasn’t met. So let’s just talk it through, if Eric gain 200HP, if Natalie add status number 2 (poison) otherwise restore 100HP.


Scenario: You have a thunder skill which doors more damage when outside, which you control with a switch

This is just a switch example.

$game_switches[x] ? 500 + a.mat * 4 – b.mdf * 2 :  200 + a.mat * 4 – b.mdf * 2

I’ve also included in it an example of how to include the default formula so you can see how to incorporate it.


Scenario: I have a skill whose power I want to control through a variable

Easy enough. Here’s how to do 10 times the value of the variable.

$game_variables[x] * 10


Scenario: I have a gamber and I want him to use dice skills e.g. he rolls two six sided dice, the skill does 100 times the combined number of the faces. It does double if he rolls a double and 10000 if he rolls snake eyes.

This one has a lot in it so we’ll look at it closely. We’ll use the if method and then use the rand(x) method which returns a number from 0 to x-1 meaning we will add 1 to it to simulate dice. We will also need to create some local variables, I will use c & d (DO NOT USE a & b).

c=1+rand(6);d=1+rand(6);if c==1 and d==1;10000;elsif c==d;c*400;else;(c+d)*100;end;

It’s not perfect, I would quite like to know what he rolled rather than just seeing the damage. Don’t worry the solution to this new problem will be shown in the next tutorial.


Scenario: We want a skill like White Wind (a final fantasy move which restores someone’s current health).

An easier one for once, we want the target’s (b) hp

b.hp

Other parameters you can use:

hp,mp,tp,mhp (Maximum Hit Points), mmp *Maximum Magic Points), atk,def,mat (Magic ATtack power),mdf,agi,luk


Scenario: What about demi?

Demi was a move which took a quarter of your current health.

b.hp / 4


Scenario: I want a skill which uses someone else’s stat e.g. my princess is bossing her guard around.

This is easier than you think, as long as it’s a particular character.

$game_actors[1].atk * 4 – b.def * 2

Eric attack!


Scenario: I want a skill to add an effect on the user e.g. exhaustion.

Not too hard.

a.add_state(2); a.atk * 4 – b.def * 2

Could also have it damage the user etc


Scenario: I want a skill which does more damage with a certain weapon equipped.

Little bit more complicated.

a.weapons.include?($data_weapons[1]) ? 1000 : 200

Since when did Hand Axes become so strong?


Scenario: I want a skill to do x

Leave a comment and I will try my best to direct you.

It has been brought to my attention that v[x] achieves the same result as $game_variables[x]

20
  

95 comments

  1. amerk says:

    That’s pretty awesome, and now I know when dealing with the party outside of battle to use b instead of a. Since you are now diving into tutorials, perhaps you can also show more on custom damage formulas? I’ve heard you can add snippets of codes into the scripts and do script calls in the formulas, so some examples of that (if you have any) would be great.

    • Fomar0153 says:

      I intend to follow this tutorial up with one focusing on just that. Until then have a few examples from my game:

      This one is just a convenience thing:
      class Game_BattlerBase
      def sorcery_healing?
      return state?(51) || state?(52) || state?(53)
      end
      end

      Basically I have healing techniques which are weakened when you are under some states. In the formula box I call:
      b.sorcery_healing? ? 100+a.basef(a.mat,0)/2 : 200+a.basef(a.mat,0)

      basef is another example, it stands for base formula:
      class Game_Battler < Game_BattlerBase
      def basef(a,d)
      return ([a / 5, a-d].max * (a ** 0.5)).to_i
      end
      end

      The idea behind it is that should I find my formula doesn’t work well at higher levels then I only have to change it once.

      Anyway I’ll cover this more later. Now back to adding more examples.

  2. This is a great tutorial. I didn’t know you could do so much with the custom formulas. If I think of something (I’m sure I will), I will ask. You provided so many good examples. Now I have some stuff to think about.

  3. Digger says:

    This is really interesting.
    Thanks for the tutorial I never would have known any of this stuff could be done if you had not posted about it.

  4. killer690 says:

    Well, this is pretty interesting, really, I must say.
    Can I take this info, translate it and post it in a spanish talking forum (Credits and Font goes to you, for making the info) I think that everyone must know this.

  5. Here’s an idea.
    What about a skill that does extra damge if the character has a certain piece of equipment equipped?

  6. [...] tutorial on using the Custom Damage Formula  of skills is a must read and check out the Monster Master class for his [...]

  7. Fafnir says:

    This is impressive. I didn’t realize the damage box allowed for quite so much coding.

  8. Fafnir says:

    Correct me if I’m wrong, but this can be used to make skills that (sort of) mimic potions, by working pharmacology into the formula, right?

    For example, “500*a.pha” would essentially be identical to a 500 hp potion in all respects.

  9. Rigor Mortex says:

    Is there a way to make a skill heal the user by an amount equal to 1/4 of the damage inflicted, and to cap the recovery possible at 100?

    If so, is it also possible to make a similar skill that hits multiple targets, but adds up the damage inflicted to all hit targets, and then determines the recovery based on the total amount (ex: recovery equal to 1/4 the total amount inflicted, recovery capped at 100)?

    • Fomar0153 says:

      The first one is possible something like:
      d=2*(a.atk-b.def);a.hp+=[d/4,100].min;d
      Though that won’t account for variance, so you can set variance to 0 and include some random element in the formula.

      • Rigor Mortex says:

        I just tried it and it does work; it shows decimals for HP, though. Can I make it round/fix this, or do I just have to live with it?

        • Rigor Mortex says:

          I forgot to mention that, since I’m working with smaller numbers for my game, I changed the formula to:
          d=(a.atk*0.5-b.def*0.25);a.hp+=[d/4,100].min;d)
          That probably has something to do with it.

  10. Josh says:

    this opens up a lot of possibilities.

    Is it possible to deal extra damage if the target is afflicted with a number of states?

    Like, +500 damage if they’re afflicted with Poison, Blind, Confuse, Sleep and Silence. (100 damage per state).

    That seems kind of challenging, I admit.

  11. Pillanious says:

    Hate to ask you for this, Fomar, but maybe you can solve my dilemma. I’m playing with the following formula:
    ((a.atk+(a.atk/10*2))*(100/(100+b.def))+(a.atk-b.def))

    The engine is, essentially, ignoring all of the bracketed items except the final a.atk-b.def situation.

    Is there a reason why? Is there another way to make this formula work?

  12. Rigor Mortex says:

    Alright, so I’ve come across a problem:

    [(a.atk * 0.75 - b.def * 0.25), 999].min

    Now, this is pretty straight-forward; I made it so the damage for this skill is capped at 999 (every skill in my project has a damage cap). The skill works as intended, UNLESS it scores a critical hit. If it lands a critical hit, the damage is doubled and it can *ignore* the cap I set of 999. Naturally, this is a problem. How do I make criticals not ignore the cap I have set?

    • Rigor Mortex says:

      Additionally, is there a way to make a skill that hits all enemies, but does decreasing damage to each target after the first? Basically, here’s what I’d like to have:

      Enemy 1 takes 100%, or the full/normal, damage of the skill.
      Enemy 2 takes 80% damage.
      Enemy 3 takes 70% damage.
      Enemy 4 takes 60% damage.
      Enemies 5 and beyond take 50% damage.
      ^Is this possible to do with a formula? I imagine I’d have to use your script that allows longer formulas if it is indeed possible.

    • Fomar0153 says:

      Critical calculation takes place after the damage calculation. Without modifying the default scripts this isn’t possible.

      • Rigor Mortex says:

        FFFFFFF- Well, what about the second question?

      • Fomar0153 says:

        I can’t remember if a common event runs before or after the damage calculation. Either way have it set a variable to 100.

        d=((2*a.atk-b.def)*v[x])/100;$game_variables[x]=[v[x]-20,50].max;d;

    • Xypher says:

      class Game_Battler < Game_BattlerBase
      def test2(a,b)
      if @critical
      c=[(a.atk * 0.75 - b.def * 0.25), 1888].min
      else
      c=[(a.atk * 0.75 - b.def * 0.25), 999].min
      end
      c
      end
      end

      formula
      b.test2(a,b)

      • Xypher says:

        Pasted wrong script

        class Game_Battler < Game_BattlerBase
        def test2(a,b)
        if @result.critical
        c=[(a.atk * 0.75 - b.def * 0.25), 629.3334.to_f].min
        else
        c=[(a.atk * 0.75 - b.def * 0.25), 999].min
        end
        c
        end
        end

        formula remains the same though

        • Fomar0153 says:

          Whoops, double checked and critical is determined before the damage but the damage is applied afterward, try what Xypher suggests.

  13. adalwulf says:

    Quick question, how would I go about grabbing the stats of active battlers possessing a specific state?

  14. HamPants says:

    What would you say to a skill that exploits a state? Such as one that ignores defense if the target is nauseated?

  15. HamPants says:

    Sorry to bother you, I have another one, I think I have the hang of this though.

    Say you want to do a spell called “Shatter”, which deals major defense-ignoring damage to someone with reflect, AND removes reflect, but does nothing otherwise. Would the formula be like this:

    if b.state == (n);4 * a.mat; remove_state(n);else;0;end

    I think I have it?

    Also, would the spell penetrate the reflect? Or would the system, as it is, just reflect the spell?

    • Fomar0153 says:

      I think it would get reflected but the formula would be:
      if b.state?(n);b.remove_state(n);4 * a.mat;else;0;end

    • adalwulf says:

      Skill needs to have Certain Hit to avoid being reflected back.

    • HamPants says:

      Thanks guys! Both of you!

      I think I’m getting the hang of this now. It’s always so hard to learn a new code language format. I appreciate everything!

  16. Morlockhater says:

    Ok, kinda complex skill, I need a ‘Redirect lightning’ skill, I’m making an Avatar: The Last Airbender fan game and need a skill that, when character a is targeted with a specific skill, in this case, a lightning strike, the player has a percentage chance of reflecting it back at the enemy, or being hurt themselves. How could this be implemented?

    • Fomar0153 says:

      Probably not possible with a damage formula. You could try using the magic reflect state but that doesn’t discriminate between types of magic.

  17. Amelanduil says:

    Hello,
    I had an idea about a skill that would have a chance to inflict certain state if the target’s hp is below half. Is it possible?

    • Fomar0153 says:

      It would have to be based on their HP before the attack.

      • Amelanduil says:

        uh-oh… I’m not really good at this… would it be something like: if b.hp <= /2 then b.add_state(1) ?

        • DeiLin says:

          if b.hp <= b.mhp/2||c=rand(2)||b.add_state(?) if c = 1||end||(damage formula)

          Not sure if this script will fit in box. or else, you can do this

          if b.hp <= b.mhp/2||$game_variable[x]=1||end||(damage formula)

          have it trigger a common event, have the event chack for
          $game_variable[x]=1 then write a chance for adding state.
          However, with this one, the sklll only applies to one character ONLY unless you store b.id into a variable and link the variable to a charcater or enemy slot.

          both are untested in formula, though.

        • DeiLin says:

          Another thought

          c=rand(2)||b.add_state(?) if b.hp<=b.mhp/2 and c=1||(damage formula)

  18. DeiLin says:

    one formula I’ve used is TP as a variable in an equation that cost MP, and vise versa, of course I use MP and TP different then many games since I’ve rewritten how both regenerate and under what conditions.

    MMP = 10 * level
    MTP = 10

    Start of Battle:
    0MP
    0TP

    Action (skill) succeeds:
    TP +1

    You are hit with an action:
    TP +1

    End of Turn:
    TP +1
    MP +2

  19. zorger100 says:

    Hey Formar0153, can you make a new tutorial about damage formulae? you could explain the meaning of “.max”, “.min”,”Methods to do square roots”…
    sorry for my bad english and thanks for this wonderful tutorial ^^

    • Fomar0153 says:

      If I have an array [1,2,3,4] and use min on it it will get the lowest value in the array, 1 and similarly max will get the highest value, 4.

      To do a square root: e.g. 16 ** 0.5 would give 4.0
      Usually you don’t want floats in the formula so I would do:
      (100 ** 0.5).to_i which would give 10.

  20. Zetsu says:

    This is a really basic and cliched question but how do you set a skill to heal unless the target has a certain state?

    • Fomar0153 says:

      Make sure the skill type is set to HP recovery.
      b.state?(id) ? 0 : 500
      where id is the id of the state.

  21. estriole says:

    i tries making a skill which will kill the target at 100% but will reduce user maxhp by 100 points then store to variable how many times the user use this skill and make his maxhp reduced (so there’s a way to revert that back). and if the user use it and his max hp below 100 it will bring him game over. i try this formula:
    b.add_state(1);v[7]+=1;v[8]=a.id;a.atk*4-b.def*2
    a.atk*4 – b.def* 2 is for showing some damage and not null (i’m using ace battle engine that if the damage is 0 it will show null. its a bit strange if death and null shown at the same time but the enemy still die)
    then have that skill call common event. since the common event executed before the variable 7 +1. i use this event sequences:

    if the variable 7 is 0 (first time using it)
    reduce max hp by 100 using change parameter and using variable 8 as the id of actor
    show the message that your soul have been shattered too.
    else
    if actor(variable 8) hp < 100
    game over
    show message your soul has been devoured
    end
    end

    it works fine but sometimes there is 103 error.(often actually).
    can anyone give better formula that not trigger the error (maybe my logic is calling process to rapidly?)

    • estriole says:

      if the variable 7 is 0 (first time using it)
      reduce max hp by 100 using change parameter and using variable 8 as the id of actor
      show the message that your soul have been shattered too.
      else
      if actor(variable 8) hp < 100
      game over
      show message your soul has been devoured
      else
      reduce max hp by 100 using change parameter and using variable 8 as the id of actor
      show the message that your soul have been shattered too.
      end
      end

      sorry this is the right one i use

    • Fomar0153 says:

      This might be easier to implement using a common event.

      • estriole says:

        sorry if i mislead you. the:

        if the variable 7 is 0 (first time using it)
        reduce max hp by 100 using change parameter and using variable 8 as the id of actor
        show the message that your soul have been shattered too.
        else
        if actor(variable 8) hp < 100
        game over
        show message your soul has been devoured
        else
        reduce max hp by 100 using change parameter and using variable 8 as the id of actor
        show the message that your soul have been shattered too.
        end
        end

        is my common event

        the damage formula i use is

        b.add_state(1);v[7]+=1;v[8]=a.id;a.atk*4-b.def*2
        then the skill call common event. it supposed to add death state then add variable 7 by 1. then change variable 8 to user id. then some damage then it call common event above. but it seems that it crash often.
        thx.

  22. Grim Tuesday says:

    Thanks for amazing tutorial, I really learned a lot, both from the tutorial itself and from replies under it, but I have a problem.

    I’ve two states: flammable (id 9) and burning (id 8), and two damage elements: melee and firearms. If a character is flammable (by being hit with vodka bottle, for example), he bursts into flames if hit with a bullet from firearms (I’m using ABS which assigns a skill to every weapon and item). I understand I need to make a formula for all firearms skills, i.e. pistol, SMG, and so on. I tried

    if b.state == (9);a.atk – b.def; b.add_state(8);else;a.atk-b.def;end

    but it leaves me with guns dealing no damage. I’d appreciate your help. Thanks.

    • Fomar0153 says:

      if b.state == (9);b.add_state(8);a.atk – b.def;else;a.atk-b.def;end

      • Grim Tuesday says:

        Interestingly enough, a skill with the formula you proposed still deals 0 damage, regardless of the target’s flammability, plus doesn’t set the target on fire even if it’s flammable. Out of curiosity, I eliminated damage dealing from condition “if state applied”, leaving only “add state”, but it still neither damages the target, nor does apply the state. That’s strange, because even I can see that the formula should be working. Other formulas from your tutorial work just fine, so I’m guessing my ABS shouldn’t be the problem here. Do you happen to have any other idea what to do?

    • Xypher says:

      try
      if b.state?(9);b.add_state(8);a.atk – b.def;else;a.atk-b.def;end

      • Grim Tuesday says:

        Thank you so very much, that’s more like it! But it’s still imperfect – when an enemy is not flammable, it receives normal damage as he’s supposed to, but when he becomes flammable, any attack that makes him burst into flames deals 0 damage. In other words, a flammable enemy receives 0 damage from the first gunshot, the very gunshot that converts flammabiity into burning, and when burning is already applied he receives normal damage as he should. So the problem is that damage from the triggering attack is effectively nullified. Any idea of solving that?

        Anyway, thanks again for help.

  23. ViewtifulStyle says:

    Someone gave me a formula which is supposed to decrease the user’s HP by 25% on use, but it just gives me an error that says something along the lines of unexpected tIdentifier, expecting $end.

    Here’s the formula
    4 * a.atk – 2 * b.def; c=a.hp/4; a.hp -= c

  24. Inspirit says:

    Hi Fomar, thx for the amazing tutorial that made me realize full potential of this formula box.
    Idk whether someone has asked this or not, but I have an idea of making skill that not allows user to knockout enemies in one hit, which means if enemy’s HP is full, than this skill will at least leave 1 HP. Much like one of Pokemon move.
    Maybe you can help me, I’d appreciate your help. Thanks :D

    • Dekita-RPG says:

      moves like fissure (total oneshot)
      b.mhp < this will hit for the targets total MaxHP value.

      b.hp < this will hit for the targets current HP value.

      moves that leave a little hp
      b.mhp / 1 – 1
      ^ deal damage equal to targets max HP – 1 (basically leaving 1 hp)

      b.hp / 1 – 1
      ^ deal damage equal to targets current HP value – 1 (also leaves 1 hp)

      • Fomar0153 says:

        I don’t get the divide by 1.

        • Dekita-RPG says:

          yea the divide by 1 isn’t really necessary i guess its just how i used to do it when i first got into RPG maker b.hp – 1 has the exact same effect ^_^ i forgot to mention to set the variance to 0 and critical hits off :D

    • Fomar0153 says:

      Hmm assuming it’s a regular damage skill do something like: (set the variance to 0)
      c=4*a.atk-2*b.def;d=(4*c)/5+rand(c/5);d=[d,b.mhp-1].min

      • Inspirit says:

        I don’t actually understand the formula… can u explain?

        • Fomar0153 says:

          c is the standard attack formula
          d is then c with some varience
          and at the end I stop it doing more than the target’s hp -1.

  25. Xypher says:

    Fomar your formula only takes into account for negative variance.
    And i believe he wants it to take current hp into account instead of max hp.
    c=4*a.atk-2*b.def;d=(4*c)/5+rand(2*c/5);d=[d,b.hp-1].min
    should work.

  26. Jacob says:

    how do i make a formula thats like a dice roll like base damage + random number?

  27. Xypher says:

    a.atk + rand(6) + 1

  28. Hi Formar! I have an idea.
    How about “Adrenaline Skill” or “Ultima Weapon” in Final Fantasy series? Damage would multiply or divide the attack power by certain percentage of HP.

    For example:
    1) Ultima Weapon would deal double damage if HP reach at max and half damage if HP below 50%.
    2) Adrenaline Skill is invert of Ultima Weapon. Damage would double if HP reach of ZERO. But not effect of HP reach max capacity.

    Sorry for my English. I use translator :)

    • Fomar0153 says:

      set c to your base formula and then e.g.
      Ultima
      c=a.atk;[c*2*a.hp_rate,c/2].max

      Adrenaline
      c=a.atk;c*2*(1-a.hp_rate)

      • Works perfectly! Thank you!

        How about opposite of Adrenaline? It couldn’t same be same as Ultima Weapon, is it?

        And, are those formulas work with MP or TP? e.g.
        Ultima / Atma Weapon
        c=a.atk;[c*2*a.mp_rate,c/2].max

        Adrenaline
        c=a.atk;c*2*(1-a.mp_rate)

        And… what does “max” mean?

  29. DrSecret says:

    I really want to experiment with this formula, but I’m not entirely sure what is possible.

    Would it be possible for an attack to deal damage based on number of times total that character has evaded attacks?

    Final Fantasy IX uses a similar skill, but that’s based on times stolen. Is there actually a way to do that too? ex: power-up skill based on times another skill was used.

    Is there also a way to drain HP and use it to heal MP and vice versa?

    • Xypher says:

      There’s nothing that stores that information in vxace so no.
      as for your drain hp heal mp question
      set the damage type to mp recover then use a formula like
      a.hp-=100;100
      that will reduce the user’s hp by 100 and heal their mp by 100.
      vice versa is just a heal spell?

  30. Vee Ladu says:

    i am using a script that allows custom formula’s for poison + regen states but I havnt done this before but and am finding it really confusing :S how would i make a state for poison as an example that would do 5hp damage a turn? I want to make more powerful versions but no matter what i do the enemy goes from 100% full hp to just 5hp

  31. Cain says:

    Hey! I’ve been trying to create a formula which uses percentages, rather than whole numbers. However, I can’t for the life of me figure out how to write percentages in Ruby. The % symbol simply creates an error whenever I use the item.

    I would like to make it so a specific actor loses 10$ of their mp, whilst all others gain 10%.

    If you could shed some light on this, it would be great! Thanks in advance.

  32. Esper says:

    This is great stuff! Thanks!

    I also just wanna point out that when implementing variables into the damage formula, it can just be v[x] (x is variable’s id).

    • Esper says:

      And wow I’m sorry I didn’t notice the end there. Go ahead and get rid of this comment. I do apologize. Thanks again though.

  33. shagans says:

    ok I always see these things, think I understand them, then fail to implement properly either due to syntax or some other error.

    I’m trying to create a complex damage formula as a base formula. Basically I want the base formula to evaluate enemy mhp to give an enemy level, then use the level difference between player and enemy as a significant damage bonus.

    My formula in math terms with ruby syntax is as follows:

    (((a.atk /5) + a.atk – b.def) + a ** 0.5) + ((a.lvl – (b.mhp/100) +1) + ((a.lvl ** 2)/2) – (((b.mhp/100) ** 2)/2))

    I tried to put variables in this formula with a.atk = a, a.lvl = b, b.mhp = c, and b.def = d; but all attacks miss when I do that.

    My code:

    Class Game_Battler << Game_BattlerBase
    def basef (a,b,c,d)
    return ((((a/5)+a-d)+a ** 0.5) + ((b-(c/100))+1) + (((b ** 2)/2) – (((c/100)** 2)/2))).to_i

    Formula box has:

    basef(a.atk, a.lvl, b.mhp, b.def)

    any ideas why nothing is happening?

    • shagans says:

      I do have proper end statements in the code, and my formula box has a.basef to clarify… I just didn’t include those on my comment.

  34. Xypher says:

    he told you not to use a &/or b for variables.

    • shagans says:

      ok so this is still just simply not working. I’ve simplified it down to the following two functions:

      class Game_Battler < Game_BattlerBase
      def basef(c)
      return (c)
      end
      def based(a)
      return (a)
      end
      end

      regardless of whether i use basef or based, I cannot get damage to occur in battle. In my formula bar I put: a.basef(a.atk) or a.based(a.atk) and neither produces damage. This simply is not working even in the conceptual phase unless I'm missing something ridiculous.

  35. Phantominoid says:

    Hey Fomar, i was wondering if you still help out with formulas, i have a few i’d like to ask you about if you have time.
    thanks in advance

  36. Xypher says:

    class Game_Battler < Game_BattlerBase

    def basef(c)
    return (c)
    end

    end

    a.basef(a.atk)

    works fine

    • shagans says:

      ok you’re right, that does work. So somehow taking out the extra function makes it work properly… however, I can’t pass in multiple parameters.

      As soon as it changes to

      def basef(c,d)
      return (c)
      end

      end

      a.basef(a.atk,b.def)
      it doesn’t work.

      On Fomar’s example, there is only one parameter being passed in(m.atk), but two variables (a,d). I didn’t think there would be a difference between (m.atk,0) and (a.atk,b.def) I figured it would just assign a.atk to c, and b.def to d, but instead including two parameters just breaks it. There has to be a way to do this and I don’t understand why these limitations exist.