Doing a turn based rpg battle system

Started by
3 comments, last by BaneTrapper 11 years, 1 month ago

Hello.

Am doing a rpg turn based battle system, and currently i am battling the values calculation after i added buffs to the game.

Question:

Is there any code you could share that shows how its already done, or a tutorial on concept how it should be done.

What i would like is the concept, i would build it my self, but what i cant think off is a efficient way to structure this all,

yet so many games achieved this already.

What kind of battle system i am talking about, well think off. One example would be Heroes of might and magic.

They have items, passive bonuses that add values to units. Units have primary hp but gain from specific items and passive bonuses extra hp. This is what trouble me how many variables i need and in what order to calculate hp

Story:

What i have is what i call a Squad that consists of 1 to 6 units. Units have inventory(items add stats) stats(Hit points. Round time(Time until this unit acts), Physical armor, Magical armor, Attack power, Spell power, Spell limit(Spells able to cast per battle)).
When the game starts player gets 2 units and can setup their names,stats,look. Then they are put on a Map where they move on a world map(I am looking intro making a static world that will have stuff happen as you move but this is planed for later later on) in this world map you move square by square. When entering 1 square proximity of a (town, enemy unit ...) you get moved intro a corresponding event(if enemy unit, you are moved intro battle with the "collided" enemy. Or if town you can chose to "shop" or "quests")

If event is battle they are moving intro a battle loop. Where units Round time fills up until its it time to act, units actions consist of (Actions(attack, rest), Buffs(defend, heal), Spells(fire ball, double strike)) Buffs and spells can be acquired by using a spell/buff scroll, or learning at town in exchange for stat point.

And that would be the short intro

when the calculations from stats/item stats are turned intro values for battle and then the problem starts i need to add buff values intro that in mid battle.

Advertisement

Didn't really understand how a battle starts, this seems a bit of Ogre Battle (The March of the Black Queen), but the world is not divided on squares and the battle occours in a separated stage.

Anyway, for the buffs management, you shoud create two values for each stat in you characters, for instance:

float spellPower, currentSpellPower;

Then you should create a buff structure/class with at least the following values:

duration, roundsSinceUsed;

You should probably add some kind of ID to know which stat the buff improves (you can also create one list for each stat) and the improvement amount. The duration variable should hold the amount of rounds the buff last, and roundsSinceUsed is set to 0 and increased at the end of each round.

Save the buffs on a list for each character.

At the end of each turn you should check each character in the game and increase the roundsSinceUsed of each buff by 1.

At the beginning of each round you should check if duration is equals to the roundsSinceUsed, if it is you remove the buff.

The buffs should change the current version of the stat, after removing a buff you can either remove the improved stat value (if all the buffs can stack) or just recalculate the current value.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

*system

-Aeramor

CTO at Conjecture, Inc.

In warcraft 3, most of the buffs actually "did" nothing. They just triggered animation effects on the target they were attached to. In general, the buff would have all sorts of properties to change the look of the character they were affecting, but had no gameplay effect at all.

The actual damage dealing / stunning / whatever was controlled by scripts that would fire periodically and look for that buff. If that buff was present, they would influence the character in some way or another.

There were some exceptions to this norm, but, in general, it was the abilities and the scripts that did all the hard work. Buffs were just for show.

As for items, I'm not sure how other games did it, but bastion(by supergiant games) stores all it's data in an XML file (you can see it too), including enemies, items and upgrades. anyway, the item and upgrade tags usually look something like this:

<item name = "damageBuff" target = "DAMAGE" type = "ADD" value = "15 /> <- adds 15 damage

or

<item name = "damagMultiplier" target = "DAMAGE" type = "MULTIPLY" value = "1.8 /> <- multiplies current damage by 1.8

or

<item name= "healthUpgrade target = "HP" type = "ADD" value = "50" /> <- adds 50 bonus

the awesome thing is, if you can just add and multiply variables, you can subtract and divide them too! this system is crazy flexible and I'm using something similar to it.

Hope this helps!

a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)

Didn't really understand how a battle starts, this seems a bit of Ogre Battle (The March of the Black Queen), but the world is not divided on squares and the battle occours in a separated stage.

Anyway, for the buffs management, you shoud create two values for each stat in you characters, for instance:

float spellPower, currentSpellPower;

Then you should create a buff structure/class with at least the following values:

duration, roundsSinceUsed;

You should probably add some kind of ID to know which stat the buff improves (you can also create one list for each stat) and the improvement amount. The duration variable should hold the amount of rounds the buff last, and roundsSinceUsed is set to 0 and increased at the end of each round.

Save the buffs on a list for each character.

At the end of each turn you should check each character in the game and increase the roundsSinceUsed of each buff by 1.

At the beginning of each round you should check if duration is equals to the roundsSinceUsed, if it is you remove the buff.

The buffs should change the current version of the stat, after removing a buff you can either remove the improved stat value (if all the buffs can stack) or just recalculate the current value.

Hopefully this will give you a vision how to engage battles.

(EDIT::: Units move 1 squad i meant 1 square at keypress)

http://postimage.org/image/mvvdmbgmn/

Also i am thinking if making it a round base system or timed (Round based i mean until all units acted once, by that all spells that last like 5 turn buff(Defend) will never be the same length and it will highly depend on units in battle. Therefore i am going to make it timed.

I like the idea, buff has duration and id. when buff is used its push_back() intro units std::vector<Buff> and for each buff, check its type, and call corresponding function.

*system

Thanks on noting that, If you take a closer look you would notice i did not make the same typo in code...

In
warcraft 3, most of the buffs actually "did" nothing. They just
triggered animation effects on the target they were attached to. In
general, the buff would have all sorts of properties to change the look of the character they were affecting, but had no gameplay effect at all.

The
actual damage dealing / stunning / whatever was controlled by scripts
that would fire periodically and look for that buff. If that buff was
present, they would influence the character in some way or another.

There
were some exceptions to this norm, but, in general, it was the
abilities and the scripts that did all the hard work. Buffs were just
for show.

As for items, I'm not sure how other games
did it, but bastion(by supergiant games) stores all it's data in an XML
file (you can see it too), including enemies, items and upgrades.
anyway, the item and upgrade tags usually look something like this:

<item name = "damageBuff" target = "DAMAGE" type = "ADD" value = "15 /> <- adds 15 damage

or

<item name = "damagMultiplier" target = "DAMAGE" type = "MULTIPLY" value = "1.8 /> <- multiplies current damage by 1.8

or

<item name= "healthUpgrade target = "HP" type = "ADD" value = "50" /> <- adds 50 bonus

the
awesome thing is, if you can just add and multiply variables, you can
subtract and divide them too! this system is crazy flexible and I'm
using something similar to it.

Hope this helps!

For bastion system.

Its probably required to store multiple instances of stats(hp...) because in case of

<item name = "damagMultiplier" target = "DAMAGE" type = "MULTIPLY" value = "1.8 /> <- multiplies current damage by 1.8

But what would you do if you got another buff that modifies your DAMAGE, then this buff ends. The buff would have to hold witch attribute to modify and value as well as duration and maybe type.

Regarding the warcraft3 buff system.

That's what i am currently aiming for, tho art effects are still not implemented.

Also i am thinking not working with % values for this project for sake of finishing it, because there are much things need to be done.

Thanks on tips, i got some vision on what i should be aiming for now.

This topic is closed to new replies.

Advertisement