RPG [Help]Battle Algorithmes and Formulas (Read 807 times)

  • Avatar of Thera Dratara
  • Group: Member
  • Joined: Apr 23, 2004
  • Posts: 51
I'm currently trying to program a J-RPG in gamemaker, and while most things are working out quite well, I realised there's one thing I have absolutely no experience in:

Battle algorithms and formulas.

Also known as the mathematical magic that run RPGs.

I'm being very simple with having the following stats: Strength, Defence, Magic, Magic Defence and Speed. Next to that there's elemental attributes, weaknesses(depending on monster type) and stat modification.
My battlesystem is just a simple turn based system where the player chooses attacks before each round and the speed dictates when the character's turn is.

So here's my questions:

* What kind of battle algorithms/formulas have you used?
* What algorithms/formulas have you seen that impressed you, or had a creative thing about them?
* What kind of algorithms/formulas would you advice me to use?
- Therahedwig

Thera's deviantart page
  • Avatar of the bloddy ghost
  • ::pulls another Hideo Kojima::
  • PipPipPipPipPipPipPip
  • Group: Premium Member
  • Joined: Mar 25, 2003
  • Posts: 1050
Woah, I was actually just looking for the same thing. I'm gonna PM a guy who wrote a tutorial on it a long time ago, maybe he still has it.
has a girl in his bed. pot in his pipe and family guy on the tube. i like life
  • Avatar of Thera Dratara
  • Group: Member
  • Joined: Apr 23, 2004
  • Posts: 51
Woah, I was actually just looking for the same thing. I'm gonna PM a guy who wrote a tutorial on it a long time ago, maybe he still has it.

:D

Oh, if you do manage to get your hands on that tutorial, could you post it here? I myself am intrested in it, and maybe others would like to see it too.
- Therahedwig

Thera's deviantart page
  • Comrade!
  • PipPip
  • Group: Premium Member
  • Joined: Mar 1, 2003
  • Posts: 222
there was a program around here at one point called algorithmate which basically acted as a spreadsheet and let you adjust the equations if i remember correctly...

I use four basic stats in my current project -- Power, Speed, Magic, Luck. Typically I use one attribute as the primary modifier, and a second as a .. secondary modifier.

example: "Dagger" is primarily Power, secondary speed.

Primary modifiers are 100% of the attribute, secondary are 50%, and I add these together, then multiply by a luck/randomizer modifier.

Then I calculate in a similar way for enemy's defences.

I've got my actual algorithms written down somewhere, I'll post them if I find them.

But basically, my post was trying to say, I think flexibility and symmetry is important, so different classes or weapons stay effective and scale properly.
  • Comrade!
  • PipPip
  • Group: Premium Member
  • Joined: Mar 1, 2003
  • Posts: 222
http://www.rpg-palace.com/utilities.php

Here it is
  • Avatar of Dart00
  • Always needing help....
  • Pip
  • Group: Member
  • Joined: Jun 17, 2005
  • Posts: 179
Also take a look at the help file...Do a search for: "Battle Algorithms"....it should clear a LOT up...im making a CBS...but ill use the same algorithms as rm2k3...makes things easyer.

This info and algorithmate should be just what you need!

But if your to lazy to open the helpfile like I am at times, heres the text:

Quote
·   The attacking character is designated as A, and the defending character (the one being attacked) is designated as B.
·   Success or failure of certain things are determined by a random number.
·   When using an attack with attributes assigned to it, damage fluctuation and effectiveness are separately calculated.

Normal Attack Damage

Damage (HP decrease value) = (Attack power of A / 2) - (Defense power of B / 4)

·   The actual damage fluctuates between 80%-120% of this value.
·   In the event of a "Critical Hit", damage is multiplied by 3.
·   When B defends, the damage taken is reduced to 1/4.

Normal Attack Hit Ratio

Hit ratio (%) = 100 - (100 - hit ratio % of A's equipped weapon) * (1 + (agility of B / agility of A - 1) / 2)


·   When "Ignore Monster Evasion" is checked, the hit rate becomes the basic hit rate of the weapon.
·   Hit ratio can change according to afflicted conditions.
·   When B is afflicted with a condition that prevents action in battle, hit rate is automatically taken to be 100%.

Skill Damage

Damage = Base Damage + (Attack power of A / 20 * Attack influence of skill) + (Defense of B / 40 * Intelligence Influence of skill)


·   For each point of variance, damage fluctuation will be ±5% more, up to a total of ±50%.
·   When [Ignore Defense] is checked, the damage algorithm is as below.

(Defense power of B / 40 * Attack influence of skill) + (Intelligence of B / 80 * Intelligence influence of skill)

·   When B defends, the damage taken is reduced to 1/4.
·   Skills that cancel the death condition will heal a % of HP instead of an absolute value if no other options are checked. (If the value is 100 or more, the character will revive with 100% of their HP.)

Success Rate of Skills

Success Ratio (%) = Success Rate

·   For a skill with multiple effects, each is checked separate to see if it fails or not.
·   When an attack that reduces HP or MP fails, all other effects and conditions of it are ignored.

Escape Success Ratio

Escape success (%) = (1.5 * (Average agility of party / average agility of monster group) * 100

·   For example, if the average agility of the party and monster group is the same, escape success ratio is 50%.
·   Every time an escape fails, 10% is added to the escape success ratio.
·   If a pre-emptive attack is made, escape success ratio will be 100%.
  • Avatar of Thera Dratara
  • Group: Member
  • Joined: Apr 23, 2004
  • Posts: 51
While it's very kind of you to point me at algorithmate and the RPGMAKER 2k/3 helpfile... I'm using GAMEMAKER. As in, the 2d engine people only use for platformers and weird arcade type games because nobody can be bothered to try something more complicate ;).

But thanks none the less for posting that, it's interesting to see how RPGmaker deals with the algorithms.

I've tried to look around, and found some other examples:

Dragon quest for an example, roughly uses:
[Attack/2-(defense/4)] = Base damage, before the randomizer.(it seems that RPGmaker is based off this)

Pokémon on the other hand does the following:
((((2*level+10)*attack*basedamage)/(250*defence))+2)*modifier*same type attack bonus*randomnizer = damage

But keep 'em coming, I'm certain there's more types out there...
- Therahedwig

Thera's deviantart page
  • *untis* *untis* ^
  • PipPip
  • Group: Member
  • Joined: Feb 11, 2008
  • Posts: 247
Earthbound uses (attack level * offense - defense) +/- 25% damage. I used it for my game, it's not very good unless you set up some things.
 Oh, I have a bunch more algorithms from Earthbound, as I found an article:
Escaping: (highest speed among PCs - highest speed among enemies + 10*turn number)%
Stat gain on level = ((growth rate * old level) - ((stat-2) * 10)) * r/50
Dodging = The target has a (2*target speed - attacker speed)/500 chance of dodging the attack. If the enemy dodges, skip the remaining steps.
Last Edit: August 04, 2009, 08:55:53 pm by Immakinganaccountk
How about no!? You are an idiotic version of a baboon.
  • Avatar of Dart00
  • Always needing help....
  • Pip
  • Group: Member
  • Joined: Jun 17, 2005
  • Posts: 179
this is worth taking a look over:

http://www.blade2k.net/writings/0/1/1/writing_102

Its kinda steep thou...I think ill stick to rm2k3s simple but effective algorithms

Or you could forget about algorithms and just have constant damage....

Wood Sword: 12 damage
Metal Sword: 19 damage

Escape Chance: 100% or 0%

Lvl 1 damage: 4
Lvl 2 damage: 6

Slash Kick: 6 damage
Mega Punch: 9 damage

and all you would need is just attack stat + weapon attack stat! hehe.
Last Edit: August 04, 2009, 09:03:11 pm by Dart00
  • *untis* *untis* ^
  • PipPip
  • Group: Member
  • Joined: Feb 11, 2008
  • Posts: 247
The problem with that article, IIRC, is that it uses character level as a modifier. I tried it and a level 99 character has their damage multiplied by 99. Also, you have to limit your def/atk to under 100.
How about no!? You are an idiotic version of a baboon.
  • Avatar of the bloddy ghost
  • ::pulls another Hideo Kojima::
  • PipPipPipPipPipPipPip
  • Group: Premium Member
  • Joined: Mar 25, 2003
  • Posts: 1050
That was the tutorial that I was going to link. You could ignore the level multiplier if you don't want to use it.
has a girl in his bed. pot in his pipe and family guy on the tube. i like life
  • Avatar of Dart00
  • Always needing help....
  • Pip
  • Group: Member
  • Joined: Jun 17, 2005
  • Posts: 179
That was the tutorial that I was going to link.

Kinda figured  :cool:​...
  • *untis* *untis* ^
  • PipPip
  • Group: Member
  • Joined: Feb 11, 2008
  • Posts: 247
That was the tutorial that I was going to link. You could ignore the level multiplier if you don't want to use it.
I wasn't commenting on the usefulness of it, I was just being whiny.  :welp:
How about no!? You are an idiotic version of a baboon.
  • Avatar of datamanc3r
  • The Irrepressible
  • PipPipPipPipPipPip
  • Group: Member
  • Joined: Nov 24, 2004
  • Posts: 938
Wow this thread is a godsend -- just what I was looking for!

For myself, I'ma do away with the level multiplier entirely. My game will feature a job-experience system like Final Fantasy Tactics, in addition to raising core stats: SPD, STR, and INT. I think other stats like 'defense' and 'magic' are related to these three stats, so why bother the gamer with redundant information? Leastwise, that's what I figure.

You know, there needs to be a better way to access information like this for this forum. We used to have so many articles!
Last Edit: August 06, 2009, 05:59:29 am by Juris
"I would be totally embarassed to write this, even as a fakepost. it's not funny except in how you seem to think it's good. look at all the redundancies, for fuck's sake. "insipid semantics, despicable mediocrity" ugh gross gross. I want to take a shower every time I read your prose." -Steel
  • Avatar of Biggles
  • I know your secrets
  • PipPipPipPipPip
  • Group: Premium Member
  • Joined: May 5, 2005
  • Posts: 688
"Mathematical magic" in RPG games is an exceedingly dumb idea in my opinion. It removes any kind of meaningful description and replaces it with an arbitrary number. 1908273 damage! Fucking great.

 If you simply want to copy the feeling of another popular game with some modifications, obsessed fans often produce in-depth descriptions of battle mechanics. Games with multiplayer components are often explored in quite a lot of depth because people start wanting to win at them competitively. I know that this is true of Pokemon, and I assume it's also the case for MMORPGs like Guild Wars and World of Warcraft.

Some examples of these FAQs for RPGs that fans often want to emulate:
FF7: Battle Mechanics Monster/Item List
Chrono Trigger: Mechanics Enemy List
Oblivion: Damage formula, I assume the rest is easy to find from there
I'm getting bored now, but the point is that technical information about 'magic numbers' isn't hard to find for popular commercial games. Oh boy! Magical!

That aside, taking this approach to rpg development is exceedingly weak. If you don't fully understand your own 'magic formulae' and how they came about, then you don't have control over the way your game turns out. Consider your rpg battle mechanics from the ground up, and they will cease to be 'magic numbers' because you will either have done away with equations, or the numbers will make sense because you put thought into how they make your game feel. Descriptive systems are, imo, better from a design perspective because they allow you to work directly with meaningful words as opposed from going from words into numbers into words and hoping everything works out.
  • Avatar of Thera Dratara
  • Group: Member
  • Joined: Apr 23, 2004
  • Posts: 51
Well, what you mentioned is exactly why I wanted to study battle algorithms in the first place.

Any idiot understands what the effect of elemental atribute modifiers or that you add the strength of the weapon to the strength of the main character.
But while I can follow the defence/4 thing of dragon quest, I have no clue why they did the attack devided by two.

My original plan was to do attack-defence, because even in the players mind that would make sense, after all, the defence should be stopping the offence from hurting the character. But the problem with that is that the attack needs to be high enough to do a decent amount of damage, and you don't want to confront your audience with astronomical attack-numbers.

And then there's things like random modifiers which have no real reason besides hiding the algorithm for the player. But I'm not certain if I would that.
Making battles more varied, my ass, I would rather prefer to know what the general damage I do is, and thus gain a bit of feeling that I understand the game rather than that I'm just trying random stuff and the monster will die anyway. (But that's partially also a design problem in monsters and using weaknesses that I'm trying to conquer. (Having each type of monsters being specifically weak to status effect/magic/weapons, and TELLING this to the player.)) Sure, some people would say 'that's making the game too easy for the player' but I myself find it more important to allow the player to PLAY rather then to obscure everything into what's story and basically a fighting minigame that they would rather avoid. And making the player play also means that whatever is supossed to refrain the player from breaking the game should be something that racks his brain, makes him reconsider his tactics rather then a statistics problem or anything else that's basically fake difficulty.

It's the reason some people think pokémon is a good RPG: The battle mechanics are widely known, and they encourage the player to think during a battle, knowing what attacks to choose, not just based on elemental weakness, but also based on tactics(besides spamming the strongest attack repeatedly).

This is the reason I put up a thread, because I had hoped that those experienced in custom systems would voice their opinions. Hence the 'what were algorithms that you found particulary interesting' question. Perhaps people would mention why they liked the algorithm so much, what of it made sense, what they thought was good game design. Because, as you said, finding any algorithm from a proffesional game is easy.

So, yeah, if you've got ideas on how to design an algorithm, please say so. Because I'm interested.
And I apologise if I sound disconnected, I can't seem to make this sound more coherent.

Also, to the other posters, thank you for the tutorial, I'll look through it :)
- Therahedwig

Thera's deviantart page
  • Comrade!
  • PipPipPipPip
  • Group: Member
  • Joined: Sep 1, 2003
  • Posts: 525
FF7: Battle Mechanics Monster/Item List
For the record this Battle Mechanics guide is incomplete, and is missing a ton of algorithms such as critical hit, evasion, ATB algorithm and the time unit definition needed for DoT/HoT spells (mainly Regen, Shield and Dual). I can make these available if people request it.

EDIT: Atleast they were, seems the article got updated in June.
Last Edit: August 06, 2009, 09:46:30 pm by Vanit
"the way you speak about rm2k3, like "modules, arrays, pointers" sounds like
you're some badass c++ programmer stuck in the past and only has rm2k3 to
work with"
-Gutts
  • Avatar of Biggles
  • I know your secrets
  • PipPipPipPipPip
  • Group: Premium Member
  • Joined: May 5, 2005
  • Posts: 688
Well, what you mentioned is exactly why I wanted to study battle algorithms in the first place.
 :words:
So, yeah, if you've got ideas on how to design an algorithm, please say so. Because I'm interested.
Here is one possible method.

How 2 designing roleplaying game combat system, "world's greatest expert" Biggles edition:
Step One: Decide how you want the feeling of your combat system to be. Are the battle to be a long and drawn-out tactical challange? Is there a better option in the having of short and amusing RPG fight with less tactic and more bashing? How great is element of randomness? Etc. Decide, for now is the time at which this decision must be made!
Step Two: Formulate initial set of rules for combat. These will, with greatest probability, be abstract written set of descriptions of combat rules. Example and drawing may be attach to help for understanding.
Step Three: Assess result of step two with respect to result of step one. Does the rules achieve your combat goal? Could the same effect be achieve with simpler set of rule? Probably your rules are shit, so edit and rewrite a few times until you can read your own rules without cringing at lack of quality. Hopefully you (world's brilliant designer) can now play the combat in your head and feel how battle would flow in the ideal implementation. Perhaps a small feeling of pride may result but this will be extinguish soon enough.
Step Four: Implement rules and test. Find massive flaws in battle structure and feeling. Rewrite rules abstract and then re-implement until happy as in step 3. If game is computerised then good programming and software design practise will make this much easier!
Step Five: Now you have design and construct rpg battle system! Hooray!

Careful reader will notice strong similarity to both writing process and software design process! This has no coincidence - many processes is a form like this one. Important focus of this process is aggressively deleting rules that aren't necessary and focus on simplicity and elegance - in theory simple rule is easier to design around and more aesthetically pleasing / comprehensible to player. Focus on "achieving design goal" rather than "making a lot of rules" also important.

As for what specifically should be aimed for in first step, this is a question of art and not really a question of design - follow your heart and your mind, my friends. As for how to implement rules, this is mostly a question of software design and not of game design.
  • Comrade!
  • PipPipPipPip
  • Group: Member
  • Joined: Sep 1, 2003
  • Posts: 525
Why'd you put the quote as mine? O.o
"the way you speak about rm2k3, like "modules, arrays, pointers" sounds like
you're some badass c++ programmer stuck in the past and only has rm2k3 to
work with"
-Gutts
  • Avatar of Biggles
  • I know your secrets
  • PipPipPipPipPip
  • Group: Premium Member
  • Joined: May 5, 2005
  • Posts: 688
I think I accidentally deleted part of my post including the section where I quoted and made a one line reply to you, so the header of your quote got attached to the body of Thera's quote. What I said to you was something along the lines of "heh yeah I didn't actually read the article - I'm not really interested in the specifics of FF7's combat system".