Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: My first C++ game (combat demo)  (Read 4297 times)

Gordon108

  • Bay Watcher
    • View Profile
My first C++ game (combat demo)
« on: September 19, 2009, 08:29:55 am »

Screenshot at the bottom.

I've just started to learn programming and had done very little in the way of actual programming until I decided to create a simplistic text based with combat elements. This is my first somewhat complex program and would like to know what you guys think.

The combat system was inspired by dwarf fortresses. Im tired of health point based systems and although this does have health points, blood loss is generally the deciding factor in fights.

If you try it you'll also notice the setting is inspired by dwarf fortress (Hint: Its a dwarven fortress and your name is Urist Doomhammer, despite your lack of a hammer.)

At this point, just go back and forth from the entrance to the 'next room' until you enter combat. The other rooms have not been implemented yet, but I do have a fairly good writer working on it.

Heres the description of the nusery...

At one time, you estimate that this was the place where many a mother dwarf and her children spent their days. Toys are visible across the floor, and four torches cast a gentle, though vibrant light across the room. The walls are hung with fantastic and joyful drapery. Near the door, the stone is gray, but farther into the room, the color gradually changes to a deep crimson, accentuated by splotches of darker red here and there. At the far end, you see the mangled and tortured corpses of adult dwarf women strewn across the floor in pieces. Behind them, the gore is piled high, and you can make out infantile limbs sticking out at painfully wrong angles. Bits of furniture protrude from the piles of gore with an almost artistic flair.


FEATURES:
-Gore
-Blood loss. If blood gets to 0, you (or the monster) dies.
-Blocking. High chance of blocking entirely, if you fail, you lower the damage done to you.
-Severed arterys. Rare, but a death sentence.
-Various body parts can be hit. Cut arterys correspond to the part that was hit.
-Physical damage separate from blood loss.
-Very rare critical strikes that cause massive blood loss and damage.

TIPS:
-Try to bleed the orcs to death rather than kill them with brute force.
-If your artery is severed, you better win quickly.
-The amount of blood you have resets at the end of the battle and you stop bleeding.
That means blocking attacks after the orc is bleeding a lot, even if you're bleeding a bit, is
better than attacking, as you are more likely to lose hit points.
-Health points and blood are not shown. Under status you have 3 lines, line one allows you
judge how much hp you have, line two judges how much blood you have, and line 3 lets you judge how much you are bleeding. Same goes for the monster status.

KNOWN BUGS:
-If you are fighting and input anything other than the options given, your turn will be skipped.
-Orc stabbing you even after youve sliced clean through his head.
-When the player does 10 damage, the message for attacking is not shown.
-If you type a word during battle your turn will be skipped until you are dead. If you do this out of battle the program will exit.

FUTURE PLANS:
-Armor that can deflect attacks. Helmets can deflect head blows, etc etc.
-Random (and dangerous) events, such as accidentally igniting the booze storage.
-Inventory system
-Thirty seven different rooms with various interactions and surprises (Rooms nearly complete, surprises aren't).
-Weapons
-Possible additions to combat: Broken bones, severed muscles, individual limb damage that effects combat.
-A large dynamic end game battle between orcs and the surviving dwarves



Heres the link to the download.
http://www.fileden.com/files/2009/9/19/2579237/The%20Fortress%20COMBAT%20TESTv.3.zip
« Last Edit: September 21, 2009, 01:06:49 am by Gordon108 »
Logged

de5me7

  • Bay Watcher
  • urban spaceman
    • View Profile
Re: My first C++ game (combat demo)
« Reply #1 on: September 19, 2009, 08:47:08 am »

i like it, the writting generates atmosphere. Feels like a choose your own adventure. It would be nice to have some more combat tactical options. The current strategy seems to be attack until hes bleeding more than u then block until he bleeds to death.

With a full story/dungeon to explore and lots of choices, and a few more combat options this could be a good game.
Logged
I haven't been able to get any vomit this release. Not any I can pick up, at any rate.
Swans, too. Swans are complete bastards.

Gordon108

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #2 on: September 19, 2009, 08:51:33 am »

I have ideas on implementing armor that has a chance to deflect attacks based on what the armor is and where the attack is (example: Head stabs might get deflected if you have a helm).

Knockdowns were another idea I had, maybe you could do alot of damage if you push the orc down, but actually pushing the orc over would be difficult.

Running away is another thing I want to implement, mostly as a way to avoid death if you have an artery severed, however, it would be based on a random chance whether you actually got away or not.

As for items and choices, that's a hard one, as im not an experienced programmer and havent got a clue as to how I might implement it. I can try though.
Logged

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: My first C++ game (combat demo)
« Reply #3 on: September 20, 2009, 12:56:48 pm »

One thing you could also consider is localised damage, meaning you can directly attack the opponents sword arm (if it's a being that holds a sword) or go for his head.

A second thing would then be to use stances: Blocking left side of the body with shield, blocking the right side, leaing forward, leaning backward, crouched, lying in his back, lying on his side, being flung up in the air....
Logged

Kusgnos

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #4 on: September 20, 2009, 07:01:01 pm »

Pretty nice. It'll be cool if you can develop this further. A minor typo: "your mody is mangled"--I assume that'd be body, correct?
Logged

Gordon108

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #5 on: September 21, 2009, 12:56:12 am »

Indeed it would. Fixed.

Adding 'Future plans' to the original post.
« Last Edit: September 21, 2009, 01:07:06 am by Gordon108 »
Logged

kulik

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #6 on: September 21, 2009, 03:04:41 pm »

It looks really nice.

I have my own combat system for a game, but im not a programer.

Its aimed to give more control to the player, short version of my combat system looks like this:

Stances (switching is an action):
Defensive- bonus to defense penalty to attack
Balanced- no bonuses
Attacking- small bonus to attack and small penalty to defense
Berserk- big bonus to attack big penalty to defense

Combat maneuvers:
Attack- (-1 balance)
Defense- (-1 balance)
Double slash- 2x attack in one round (-3 balance)
shield bash- attack delivering blunt damage with no penalty in defensive stance to this attack (-2 balance)
Spinning slash/bash -bonus to attack if performed after successful parry (-3 balance, -5 balance if parried)
indicated attack - will not attack and will give penalty to defense in this round but adds attack bonus to next attack move (-2 balance)
defense move- bonus to defense in this round penalty if next move is attack move (-2 balance)
deflect attack move- penalised defensive move but if successful will drain opponents 8  balance points
disarm move- penalised defensive move but if successful could disarm opponent (-3 balance)
regain balance move -read lower (+6 balance)
...

Body balance:
Make a value representing your balance lets say "10".
Now various things can happen:
standard attack -1 balance
berserk attack -3 balance
parry berserk attack -4 balance
...
You would regain balance (+4) if standing still (+6) with the regain balance move.
If you have 3 or lower balance points you could fall, if 0 you will fall.

Distance:
Distance between opponents from 1-10
10- archery only
9- archery only
8- archery only
7- archery only
6- archery and throwing weapons
5-archery and throwing weapons
4- close combat "far" (pike hallenberg)
3-close combat "medium" (Long swords, Two handed axes)
2- close combat "close" (swords, axes, maces...)
1-wrestle and knives

Player can close distance by one per round, or two (defense penalty).
Player can raise distance by one per round, or two (-2 to balance).
Moving forward or backward is not an action so player can still attack if moved in that round, but will lower his balance (-1 balance) and add defense penalty.

Note.
This system can be adjusted from semi-real combat to "cinamatic" combat.
It can be combined with RPG aspect of the game. While attack and defense would be based on your stats, you combat skill would determine which combat moves you can perform.

I have some thoughts how to expand this (need to preplan your move one round ahead with severe penalties if changed, aiming on bodyparts, stamina, multiple oponents...)
 It would need lots of playtesting to balance this.

Feel free to take some inspiration.
« Last Edit: September 21, 2009, 03:06:56 pm by kulik »
Logged

lumin

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #7 on: September 21, 2009, 04:00:02 pm »

Looks pretty cool, nice work Gordon.

This actually makes me wonder how a rogue-like would play that is completely text-based like a MUD.  It would be a lot of fun to explore random tunnels and find random loot and monsters, with nothing but text descriptions.
Logged

Gordon108

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #8 on: September 21, 2009, 07:34:24 pm »

@Kulik
Very interesting. I hadn't thought of a balance system. Stances as well would make an interesting addition. Especially if balance was decreased with blood loss and being hit.

Balance would definitely make the player interact more than "Make it bleed, then block all attacks", especially if failed blocks removed quite a bit of balance. Do you regain your balance or try to block in the hopes that the enemy will bleed to death before he knocks you over and cuts your throat.

Distance system would be nice if I could see any easy way to implement it. At the moment, I cant, but it will definitely be on a to do list just to see.


Logged

Azrathud

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #9 on: September 22, 2009, 04:43:30 pm »

Can I see the source code? I'm currently learning C++ and It would be awesome to see how it works.
« Last Edit: September 22, 2009, 04:56:15 pm by Azrathud »
Logged

Gordon108

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #10 on: September 22, 2009, 06:47:52 pm »

http://www.fileden.com/files/2009/9/19/2579237/The%20Fortress%20v.4%20Source%20code.zip

Thats the source for the combat (I think).

I didn't really know how to make an object global, so the player class isnt in the code, but its going to be, that way I can add items and such to the player. Also, due to that, many of the things that should be part of the objects (like blood) aren't.

Also.. good luck deciphering it, as I have a tendency to not put comments (Which is horrible and I should change, as I often have to take a few minutes to figure out what a bit of code even does).

Logged

Azrathud

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #11 on: September 22, 2009, 08:12:59 pm »

Your code is fine, thanks! The best way for me to learn, it seems, is to look at examples like this.
Logged

Grendus

  • Bay Watcher
    • View Profile
Re: My first C++ game (combat demo)
« Reply #12 on: September 22, 2009, 08:41:41 pm »

http://www.fileden.com/files/2009/9/19/2579237/The%20Fortress%20v.4%20Source%20code.zip

Thats the source for the combat (I think).

I didn't really know how to make an object global, so the player class isnt in the code, but its going to be, that way I can add items and such to the player. Also, due to that, many of the things that should be part of the objects (like blood) aren't.

Also.. good luck deciphering it, as I have a tendency to not put comments (Which is horrible and I should change, as I often have to take a few minutes to figure out what a bit of code even does).



Yea, I learned about that the hard way. Took me two months (MONTHS!) to find a timing bug in a blackjack program I wrote. Partly this was because a cute girl across the room needed help with her own program, but mostly it was because I couldn't get anything done for having to decipher my code every day.

Comments are a pita, but they're worth it in the end I suppose.
Logged
A quick guide to surviving your first few days in CataclysmDDA:
http://www.bay12forums.com/smf/index.php?topic=121194.msg4796325;topicseen#msg4796325

chaoticag

  • Bay Watcher
  • All Natural Pengbean
    • View Profile
Re: My first C++ game (combat demo)
« Reply #13 on: September 24, 2009, 02:35:42 am »

I won't say that it is a good game, but I will say that it came be made into a great game with some work.
Logged