Combat System - Part I

Published April 22, 2015
Advertisement
I'm going to talk here about how you fight in Pantless Hero. We wanted to implement a combat system where it is not enough to mash the attack button to win over an enemy. Firstly, because we think challenging games are more fun and secondly, because it is more interesting to implement (code wise).

The hero is using a war axe, so it's heavy to manipulate, we imagine it as using a lot of energy to hit a target. In the game every attack and movement (sprint and dodge) uses stamina to be executed, so managing your stamina bar is a very important part of the gameplay.

Here is the complete offensive and defensive move set:
(The animations presented here are not the final outputs, it still needs improvements)
moveset.gif
In order, dodge (left/right), parry, attack crouch, attack jump, 3 attacks combo and throwing dagger (+ heavy attack which is not yet done).

OFFENSIVE

Each attack uses a different amount of stamina, makes different damage, they also have different timing. The attack that causes the most damages is the 3 attacks combo, it's a chain of 3 attacks that needs the right timing to be executed. The interesting thing about this combo is that the first attack (the regular attack) uses more stamina than the 2 other attacks of the combo while the damages of the attacks increase gradually. So it's more efficient to use the combo rather than just the regular attack.

To execute a combo you need the right timing. The way it works is that after pressing the attack button you need to wait for your attack to reach a certain percent of completion before to hit the attack button again else it will break the combo. After the first attack you have to wait 50% and above (in this case the axe is almost horizontal), after the second attack you have to wait 65% and above to perform the last attack.

Another useful thing about this combo, specially against slower enemies, is that the second attack breaks the current attack of the opponent. For instance after you dodge the attack of a troll it gives you time to do the first attack then while the troll ready his attack you continue your combo and break him with your second attack. The third attack of the combo charges against the enemy and push him back (even big monsters like trolls) making more damage and give you the time to recover.

Another way to deal damage is to use your daggers. The dwarf has a limited number of dagger with him (you can find them when you explore the world) but when you throw them you can get them back on the floor (so be careful where you throw them). You can throw the daggers in 4 directions (left/right and up/down) and they can reach up to 15 tiles in distance. While they don't deal much damage they can be useful to pull or finish enemy from far or kill smaller opponents like bats. But a better use for them is to set an ambush to your enemy taking advantage of the environment. With a dagger you can trigger explosive barrels or cut the rope of a lantern for it to fall and set the floor in fire, some enemies are very strong so it is a good thing to weaken them before they reach you.

The number of dagger is indicated on the top left of the HUD:
hud.png

Demonstration against a training dummy:
fight-dummy.gif


DEFENSIVE

Health points are sparse in Pantless Hero, when you get hit the only way to refill your health bar is by eating mushroom that you gather yourself. It's then essential to know how to avoid hits.

The basic way to protect yourself is to use the parry. When you parry and you get hit by an enemy it uses your stamina bar instead of your health points. The formula goes like this:stamina -= (damage * (1 - bonusParry)) * 0.75fhealth -= damage * (1 - parryAbsorption / 100f)//the dwarf absorbs 100% of the damage on parry but some enemies don't
If you don't have enough stamina to absorb it it will use your health points and your parry will be broken. Knowing that the stamina regenerates very slowly when you are in a parry position it's better to use it just before the attack.

When you fight against enemies dealing big damage your stamina will quickly run out if you parry, to avoid that there is the "perfect parry", from the moment you reach the parry position if the attack hits you within 320ms the attack is completely absorbed without using stamina. It requires to know the timing of the opponent's attack and can be risky because if your parry is too late you will get hit.

Another way is to dodge completely the attacks, it is very efficient against fast enemies, but uses a lot of stamina. One advantage of the dodge is that you can do it even if you are currently attacking. Some enemies do attacks that can be avoided if you crouch (like the horizontal attack of the troll).

BEHIND THE SCENE
This is how the combat system works in the code:
moveset-debug.gif
The green rectangle is the AABB (classic) the red line and rectangle represent the weapon, when either of the two (it depends of the type of weapon) intersects the AABB it hits the owner of the AABB.

This is the weapon class (a shortened version):
Source code:
http://pastebin.com/pqE9erMZ
The class is flexible enough to do a lot of different type of attack (need to add diagonal attack though).

It still needs some optimization and adjustment, but all the techniques combined give a rich gameplay, the different possibilities make it fun to play. One of the things we wanted, regarding the fights, is that it is not the character that gets stronger, so fighting gets easier, but because the player himself improves.

You can also enhance your character with mushrooms and runes, but I will talk about it in another entry.
Previous Entry Gobelin Vendors
Next Entry Graphic Update
4 likes 4 comments

Comments

lede

I like this idea of how to change how the attack works. Mixing it up and making it more challenging adds to the effective game play.

Just wondering, why didn't you just create an interface definition for the WeaponAttack class? As I see it you can add in different settings for the WepaonAttack which allows you to create combos that can fire at different stages of the attack. Either way this is still creative code to solve your combat problem.

April 23, 2015 02:01 PM
Hanksha

I thought of that at first, making an interface and then write classes implementing it for the different attacks. But I realize I could describe the kind of attacks we need in the game we just horizontal (or diagonal) and vertical (for attacks with weapons only) and that it fits all in one class. Each living entity (entity with AI or controlled by the player) as a weapon object and it can add any number of weapon attack in it at its class definition.

April 23, 2015 03:57 PM
lede

And there is the answer simplicity. Thanks for the explanation!

April 23, 2015 06:49 PM
Hanksha

You're welcome, it's always a pleasure to discuss programming.

April 24, 2015 03:45 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Music Themes

1425 views

New trolls

1598 views

Forge and Hub

1586 views

Updates

1470 views

UI & Menus

1523 views

Graphic Update

1461 views

Gobelin Vendors

1854 views
Advertisement