Close Combat system in top down 2d rpg style game.

Hi guys,

I’ve got to the stage in my game development that I am starting to think about fighting!

things I think I need to take into consideration are:

Viewport locked to player character (he’s always dead centre, except when at the edge of the world).
Only 1 playable character but the player can ask friends (certain NPCs) to do things (like walk to location x/y). this is done by clicking on the friend in question then clicking somewhere on the map.
Interaction is context-based by right-clicks (i.e. click on an empty space and the player will walk there, click on an item and the player should pick it up, click an enemy and some sort of combat should happen).
The player will have 2 modes of attack - melee and ranged - and 3 sub modes - “rough up”, “incapacitate” and “kill” (for different intended levels of damage, no guarantee that you won’t kill with a rough-up attack).
Majority of combat will be 1-on-1, but lots-on-1 must be possible as a deterrent for the player to go to certain areas and for specific plot points.

The world is a medieval/fantasy style (yawn, isn’t everything these days??) and as such weapons available are going to basically be Stave, Dagger, Sword, Axe, Hammer, Bow and Crossbow.

I was thinking of a system based on skills with weapons (that get better with use) and balancing them against skills of opponents to work out hits, followed by a strength attribute which would modify a base damage provided by the weapon and finally, giving the player a toughness attribute (that could be increased with “armour”) would modify the amount of damage taken.

A quick code example:

double attackOpponent(Entity me, Entity him) {

  double myHit = Math.random()*100 + me.getHitRating();
  double hisDefence = Math.random()*100 + him.getHitRating();

  double damageBeforeMod, damageAfterMod;

  if (myHit > hisDefence) {

    damageBeforeMod = me.getWeapon().getDamageRating() * me.getStrengthMod();

    damageAfterMod = damageBeforeMod * (1 + 1/him.getToughnessRating());

  }

  return damageAfterMod;

}

BUT is this all a bit over the top for a simple top-down 2d game?

What would your suggestions be for this kind of thing? I did some searching online but it doesn’t seem to be a hotly discussed topic.

(p.s. it’s amazing how writing a post like this suddenly makes the code look really easy!).

There’s no such thing as over the top. If your system works and you’re satisfied with it, then use it.

So I thought I’d resurrect this thread instead of starting a new one. Combat is coming along nicely, just one part I could do with a bit of input in - hit boxes for entities.

I have 2 hatboxes currently - a groundCollision box to stop entities walking into each other, and a combatCollision box that entities use to fight with.

The way I did my combat in the end felt quite simple really… I take the combatCollision box and shift it in the direction the entity is facing and see if it collides with anything.

The thing I’m a bit stuck on, is whether I’m drawing the boxes correctly from a players point of view. The groundCollision boxes are easy to work out how to walk around something, but the combat ones feel a bit clunky.

Examples of what I mean (combatCollision box is the red box).
In this one, it’s fairly obvious. these 2 entities are standing next to each other so they should be able to fight:

This one though, not so straight forward. Should the player at the bottom be able to hit the entity above it from here?

Or how about in reverse?

This one looks better, but will it be intuitive enough for people not to get caught out by it?

But this is the major issue I think I’m encountering. What should happen in these situations? Should the player (half-naked man) be able to hit the target dummy in these cases?

The first one with the player above-left, might lead you to think you could chop the target’s head off somehow…
the other two with the player below-left and below-right, might you think the player could reach out and score a hit?

The blue box in the last few images is the groundCollision box, I’m thinking now perhaps the attacker uses his combatCollision box and we could test against the target’s groundCollision box?

Basically I’m looking for insider info from the awesome people who hang around here and know about this kind of thing :slight_smile:

Perhaps I’m doing it wrong and it would be much easier if I had a different way of looking at the problem?

Thanks for reading my tripe and dribble!

What you should do, regardless if they combatants are close or far away, is to keep the distances consistent. So if you take a swing with a sword, it should look like you attacked from approzimately the same distance away everytime. Although I do think it would be cool if your character had to overlap a little (similar to the 4th image) when attacking.

Hi Danisaur, thanks for your input.

At the moment everything is consistent surrounding those red boxes. the standard “range” of a melee attack is fixed as the same from every angle.

I was really concerned that experienced players would understand a certain range from each entity’s feet whereas a newbie player maybe wouldn’t get it :confused:

But I guess, like you say, consistency is the trick and if it’s difficult to start with the more they do it the easier it will become.

Well ask yourself this. Do you know how to play everygame immediately when you start playing? I bet the answer is no, but you jump in, play with the controls to see what everything does and go from there, consistency is super important here for basic rules (you can bend them later after the player “knows” the game better).

The next thing to consider in your case is the learning curve, that’s a hard one cause you, probably, play the game all the time, so you might need fresh people to play.

Anyway cool art, hope you post more screens here as you go.