Announcement

Collapse
No announcement yet.

Damage Formulas

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Damage Formulas

    Hey there everyone.

    I'm working through an RPGMaker Tutorial. I've come to the section where they talk about skills. Now I am on the Skills tab in the damage area. The tutorial talks about it briefly, but it's not very descriptive. Is there anyone who can give me a detailed description about it?

    Thanks.

    #2
    Re: Damage Formulas

    This might help: http://rmvxace.wikia.com/wiki/Damage...eference_Guide

    Basically whatever is in the "Formula" field box determines how much base damage a skill will do, before modifiers like elemental weaknesses/resistances, critical hits, stat raises and drops, random variance, etc., are applied.

    The "a" in a typical damage formula is used to denote the user of the skill. The "b" means the target of the skill.

    So the standard damage formula for a physical attack "a.atk * 4 - b.def * 2" means that if the user's atk (attack) stat is 50 and the target's def (defense) stat is 25, the skill would deal a base damage of 150 [because (50 * 4) - (25 * 2) = 150] before all the other modifies are applied. But you can put all sorts of other things into the damage formula box instead.

    If you just typed in "50" into the formula box, the base damage before modifiers would be 50. If you put "a.agi * 2" into the box the skill would do 2 times the user's agi (agility) stat as base damage. If you put "b.atk / 2" into the box, the skill would deal base damage equal to the target's attack stat divided by 2, effectively using the target's own attack stat against them.

    Once you're comfortable with the basics, this tutorial introduces some of the more complicated things you can do with the damage formula box: Fomar's "How to make the most of custom formulae"

    Comment


      #3
      Re: Damage Formulas

      In addition to the good tips from Ryu:
      • If you hover your mouse over the word "Formula" it will give you a list of keywords you can use in the Formula Box
      • You can add effects completely unrelated to the formula to the formula box, so long as you've got enough room. For example, you want a skill to do damage to an enemy but also heal the user for a quarter of their max HP if Switch 10 is set to 'ON'. You could type in the formula box: if $game_switches[10] == true; a.hp += (a.mhp * 0.25); end; a.atk * 4 - b.def * 2. As long as the final segment results in a number, that's the formula the skill will use for damage.


      How Badly Do You Want It? (VX Ace) is now available for download! - no outside software necessary.

      "I live and love in God's peculiar light." - Michelangelo

      Comment


        #4
        Re: Damage Formulas

        Hmm... think I get the BASIC gist of it. I suppose it's learning how to use it or what kind of variable I need to use at what instance. Looks like it could be good for creating effects during events.
        Last edited by Omnislash024; 07-04-2014, 12:58 PM.

        Comment


          #5
          Re: Damage Formulas

          What does "end" stand for?

          Comment


            #6
            Re: Damage Formulas

            Has nothing to do with the topic, but holy **** Omni is back. Welcome back person that likely doesn't remember me. Enjoy your visit.
            PSN: KingJamos

            Add me... I'll wait.

            Comment


              #7
              Re: Damage Formulas

              Originally posted by Omnislash024 View Post
              What does "end" stand for?
              You really only need "end" in the damage formula box if you're writing an "if" statement.

              An if statement is a staple of computer programming. It's a way of telling the computer to check if a statement is true, and if so, then do something, or else do something else. The keyword "else" that you might also have seen points the computer to what to do if the if statement is not true. The "end" tells the computer when to stop doing something in either case of the if statement being true or false. It's somewhat like a period at the end of the sentence that tells you that what comes next isn't part of the sentence.

              So if you wrote something like this in the damage formula box:
              Code:
              if a.hp<=100; 200; else; 100; end;
              The way to read this is to say that if a's (the user's) current hp is less than or equal to 100 then return 200 as the base damage. Else (that is, if a's hp is not less than or equal to 100) then return 100 as the base damage. Then "end" ends this set of instructions.

              If you didn't have the "end" there to close this set of instructions that's the same as telling the computer that if the if statement is false then try to carry out without stopping every piece of code that appears after the else statement in RPG Maker VX Ace's code. This will result in an error that will prevent VX Ace from running your game.

              Comment


                #8
                Re: Damage Formulas

                Alright. Pretty much a programming term then. Makes sense. Lots to learn. And yes, it's nice to come back. If I get the hang of this program then I might be here to stay for awhile. I do love making me some RPGs, especially the thought of being able to actually make a complete game without running out of memory!
                Last edited by Omnislash024; 07-04-2014, 10:00 PM.

                Comment


                  #9
                  Re: Damage Formulas

                  I had no idea you could get that elaborate with the formulas. I feel like I've just woken up for the first time.
                  Ryner's Games

                  Simple Man's Quest for the Playground* - Winner: Pavilionite Biography Contest - Click Here!

                  Monster Must Die - Winner: Halloween Horror Contest - Click Here!

                  All you need to play is a computer, no outside program necessary!

                  Comment


                    #10
                    Re: Damage Formulas

                    Originally posted by Ryner View Post
                    I had no idea you could get that elaborate with the formulas. I feel like I've just woken up for the first time.
                    Yeah. Most things that you can do in the script editor, you can do with the formula box - sometimes making the job much, much easier because of its useful shorthand. Using "a" and "b", for example, is a lot easier than figuring out where in the code you can reliably access the skill's user and target based on the scope that was selected for the skill!

                    A few of my favorite skills from How Badly that were implemented without ever accessing the Script Editor are below. The damage formula itself is in orange and other processing I needed to place in the Damage formula box is in green.
                    • (Invigoration) b.tp += 30; ((a.mat * (6 + b.tp * 0.13))/10) + 9 This spell increases the TP (called "Adrenaline" in How Badly) of an ally, then heals that ally based on both the user's Magic power and the amount of TP that the ally has.
                    • (Grenadier) a.add_state(33); a.mat * 14 / (10 + b.mdf) This adds a state to the user which locks the normal Grenadier spell and replaces it with a more powerful version of the skill (which does the same thing with an even more powerful version - its formula reads "a.add_state(34); a.mat * 19 / (10 + b.mdf)" ), allowing you to deal higher damage with each consecutive hit! Note that since the target of the spell is an enemy, I had to use the formula box to add a state to the user.
                    • (Crosswinds) if b.state?(103);if rand(100) < 43;b.add_state(31);end;c = 20;else;c = 10;end;a.mat*c/ (10 + b.mdf) This one barely fit in the formula box! But what it's doing is checking to see whether an enemy is vulnerable to Crosswinds (state 103), and if so, dealing significant extra damage (by increasing the value of an arbitrary variable c in the damage formula) and possibly knocking them down (state 31).
                    • (All In - Charge) v[283] = 0; for r in $game_party.members; v[283] += r.tp; r.tp = 0; end This drains the TP from ALL friendly party members and stores the amount drained in a variable (Variable 283); the self-targeted skill also adds state 104 (which was added through the Effects box) that allows you to use...
                    • (All In) a.remove_state(104); a.mat * (35 + (v[283] * 0.48)) / (10 + b.mdf) ...this skill next turn, which deals big damage to an enemy that grows even bigger based on how much TP you just borrowed from your allies!

                    There are certainly some things that the formula box can't help you with. For example, the "Critical Effects" in Timeblazer, which grant bonus effects contingent upon scoring a Critical Hit, absolutely required me to go into the Script Editor and code them into the "Apply Critical" method, since RPG Maker processes the damage formula before it checks whether to see if a character scored a Critical Hit. (EDIT: I'm wrong! As Ryu points out below, the Formula Box CAN check for criticial hits - it's even more powerful than I realized. There are other things, however, that would be hard or impossible to do in this Box.)

                    But overall, the flexibility of the Formula Box (often in combination with States and Common Events) really lets you create a strategically compelling, worthwhile battle system if you're creative enough to do it - very little coding knowledge necessary.
                    Last edited by Wavelength; 07-21-2014, 04:19 AM.


                    How Badly Do You Want It? (VX Ace) is now available for download! - no outside software necessary.

                    "I live and love in God's peculiar light." - Michelangelo

                    Comment


                      #11
                      Re: Damage Formulas

                      It's also fairly easy to use the script editor to add small methods to the Game_Battler class that you then call in the damage formula box. I want to write a little step-by-step guides showing how to do this.

                      There's a lot of benefits of doing it this way, such as:
                      • No character limit
                      • Ease of reading. Rather than having everything crammed into one line full of semi-colons, ifs, elses, and ends in the damage formula box, you have the luxury of multiple nested lines
                      • Editing all in once place. If you ever want to tweak how the damage formula works, and multiple skills use the same basic damage formula, you only need to edit it once in the script editor rather than repeatedly copy, paste, and edit in each individual damage formula box in the database
                      • The ability to pass values of a (the user) and b (the target) from the damage box into a larger method.
                      • Common events execute after the damage is applied, but calling a method in the damage formula box allows you to apply a complex effect as the damage is applied


                      If none of these benefits matter very much for the effect I'm trying to achieve, then I use only the damage formula box by itself. But I have a bunch of more complicated things currently up and running in my game that would never fit into the damage formula box. These range from skills that remove a long list of block/guard states (different weapons and shields have different rates at which they resist melee, long-range, and magical attacks when guarding, each assigned to a different state) before dealing damage, to a custom status effect engine where skills that inflict certain negative status effects can inflict a more severe stage of that status effect on targets already inflicted with the less severe stage, at a percent chance determined by a custom "Potency" value for the skill plus the user's and target's stats and resistances.

                      Originally posted by Wavelength View Post
                      There are certainly some things that the formula box can't help you with. For example, the "Critical Effects" in Timeblazer, which grant bonus effects contingent upon scoring a Critical Hit, absolutely required me to go into the Script Editor and code them into the "Apply Critical" method, since RPG Maker processes the damage formula before it checks whether to see if a character scored a Critical Hit.
                      Actually I think it is possible to check for critical hits using the damage formula box. See these threads:

                      Comment


                        #12
                        Re: Damage Formulas

                        Originally posted by TheHonorableRyu View Post
                        Actually I think it is possible to check for critical hits using the damage formula box. See these threads:
                        Oh, now that is awesome. It also makes me feel like a bit of a dope for making such a big deal of the "Crit Effects" in my last game when it was apparently such an easy thing for anyone to do... but it's really cool. Being able to check for a Critical Result opens up a lot of possibilities for the Formula Box.

                        Any idea whether it's possible to use the Formula Box to check whether the target was hit, and also whether the target was KO'ed by the attack/skill?


                        How Badly Do You Want It? (VX Ace) is now available for download! - no outside software necessary.

                        "I live and love in God's peculiar light." - Michelangelo

                        Comment


                          #13
                          Re: Damage Formulas

                          Originally posted by Wavelength View Post
                          Any idea whether it's possible to use the Formula Box to check whether the target was hit, and also whether the target was KO'ed by the attack/skill?
                          To check if the skill hit the target, I think you should be able to either use the hit? check or the "success," "missed" and/or "evaded" variables in the formula box in the same way as "critical" as described in the threads linked above.

                          VX Ace doesn't apply K.O state to a battler until after damage has been executed so I don't think it's possible to check for a K.O. flag proper with just the formula box. If your game has extremely simple damage calcs (like no crits, no elemental weakness/resistance, no variance) you could check if a skill will kill the target by evaluating whether the result of the calculation you're using for the damage is greater than the target's current HP. The problem is that if you need to account for normal modifiers like crits, elemental weakness/resistances, variance, etc., I doubt that you'd be able to properly access the regular methods for these functions in the formula box without interrupting how the formula box is evaluated. And if you tried to recreate these modifiers yourself, there's probably no way it would all fit into the formula box. It would be cleaner and easier to achieve the effect through common events or scripting.

                          Comment


                            #14
                            Re: Damage Formulas

                            Originally posted by TheHonorableRyu View Post
                            To check if the skill hit the target, I think you should be able to either use the hit? check or the "success," "missed" and/or "evaded" variables in the formula box in the same way as "critical" as described in the threads linked above.

                            VX Ace doesn't apply K.O state to a battler until after damage has been executed so I don't think it's possible to check for a K.O. flag proper with just the formula box. If your game has extremely simple damage calcs (like no crits, no elemental weakness/resistance, no variance) you could check if a skill will kill the target by evaluating whether the result of the calculation you're using for the damage is greater than the target's current HP. The problem is that if you need to account for normal modifiers like crits, elemental weakness/resistances, variance, etc., I doubt that you'd be able to properly access the regular methods for these functions in the formula box without interrupting how the formula box is evaluated. And if you tried to recreate these modifiers yourself, there's probably no way it would all fit into the formula box. It would be cleaner and easier to achieve the effect through common events or scripting.
                            Thanks for your help in figuring this out! I guess I should check myself to make sure that the Formula Box will evaluate at all in the case of misses or evades, but if it does, this will open lots of cool opportunities for result.missed or result.evaded branches in the Formula Box.

                            I can see it now: a "wild swing" kind of skill with a low hit percentage that deals damage to the user whenever it misses (which would be particularly great combined with states/equip that raise your hit rate). Or a skill that deals damage to an enemy but blinds the user afterwards, and a second skill that restores your own health if it misses. When life gives you lemons...

                            I was thinking the same on the KO checks (but I was also thinking crits/misses/evades worked this way until you corrected me, so it was worth asking!) - some of my favorite skills in both my own games and professional games I've played have involved granting bonuses for KOing a foe.

                            (My personal favorite was Guild Wars' "Assassin's Promise", an Elite hex which restored energy and reset all of your skill cooldowns if the hexed creature dies within X seconds. It opened up all kinds of ridiculously cool combo possibilities but was hard to utilize in PvP where you couldn't reliably ensure an opponent would die. Not a super-hard thing to script right into the "subtract damage from target's HP" method (or even the tactfully-named "die" method) in the code, but having that kind of keyword available in the formula box would have been even cooler for non-scripters who want to open up their skill variety.)


                            How Badly Do You Want It? (VX Ace) is now available for download! - no outside software necessary.

                            "I live and love in God's peculiar light." - Michelangelo

                            Comment

                            Working...
                            X