Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Poll

What would you like to see in the next update the most?

More maneuvers
- 0 (0%)
Better/more AI  
- 1 (33.3%)
Multiple battles/Campaign mode
- 0 (0%)
More wounds/status effects
- 1 (33.3%)
Items and Equipment
- 0 (0%)
Two player hotseat
- 1 (33.3%)

Total Members Voted: 3


Pages: [1] 2

Author Topic: Text Based Fighting Game (Using DF-like combat)  (Read 5283 times)

bahihs

  • Bay Watcher
    • View Profile
Text Based Fighting Game (Using DF-like combat)
« on: December 17, 2015, 08:40:13 pm »

I don't really know where else to put this.

Basically I'd like to make a combat simulator which is similar to the one I so admire in Dwarf Fortress. The end goal is to create a multiplayer text-based/ASCII fighting game (like street fighter or soul caliber but..text). This isn't for any commercial purpose, just as a learning project.

What I'm primarily interested in is the way the body systems/parts are implemented in DF. As well as combat physics (which I assume determine things like accuracy and "damage"). I'm obviously not asking for any actual code (I don't even know C++ that well; I'll be using python) but just ideas for how to implement these things (even just speculation on how they are implemented in DF would help).

For some more details on the game:

Spoiler: Game Details (click to show/hide)

Here's what I know so far:

1. Body Systems

It looks like all the major body systems are simulated except for excretory and digestive (which makes sense for the purposes of combat). The latter is partly implemented since you can get nauseous with blows to the stomach and even vomit if the nausea is great enough.

The nervous system determines "life" and "death" (i.e damage to the brain), but also controls motor movement and sensory perception (sight, smell, hearing and touch, though the latter seems cosmetic). There seem to be "nerves" to each body part, which, if damaged, render that body part useless. I don't actually know how they work though, whether each body part is localized with its own set of nerves or if the nerves are actually part of the whole nervous system, or both. The nerves, I would also assume control pain, but usually the pain comes from the breaking of bones. Perhaps the sensory nerves are supposed to control this? Along with pain there is also the "stunned" status which seems to lower speed. I am unsure if that has to do with nervous system though.

The skeletal system provides support for the body. Breaking a leg usually results in the opponent falling down and unable to stand. Similarly breaking an arm or a hand or even a finger, will result in the opponent dropping his weapon. Also there is the well known intense pain associated with bone breaking leading to unconsciousness, though I am unsure whether this is intentional or just a bug. It seems like all the major bones are simulated but none are done so by name (e.g femur, ulna, etc. its for the best probably). This leads me to believe the bodies in game are made up of parts rather than being a cohesive whole (i.e the same parts which show up in the target selection menu) and that each part has bones, nerves, muscles, etc. Again, I'm not sure.

The respiratory/circulatory system consists of the heart and lungs and of veins and arteries. Like the skeletal system the blood vessels are not named. Damage to the blood vessels result in bleeding. Excessive bleeding I assume leads to shock/fainting, then death (which itself is caused by lack of oxygen via blood to the brain) though I'm not sure how this is implemented in the game. I don't know how time really works either (discussed below), but usually a severed limb results in "heavy bleeding" but does not often lead quickly to death. Damage to the heart or lungs is a "mortal wound" which does lead to death, albeit not an immediate one.

The muscular system doesn't really seem to do anything except act as a kind of armor to the more deeper and important tissue (nervous, skeletal and circulatory). I think it may also control stamina, though I'm not sure. As far as I know, repeatedly damaging muscle tissue doesn't really do much of anything. However if you damage it enough I do know you can pulp that particular body part. I could be wrong though, there might be other effects.

2. Combat Physics

In order to begin considering this we have to first look how time is implemented.

a. Time

Time seems to be divided into discrete units. I think these units are constant. I don't actually know how they are determined however. I do know the "," key moves time forward 1 tick and the "." moves it forward more than 1 (10?) tick.

All creatures have a speed. I don't actually know how this speed is calculated, but it seems to be a ratio. A speed of 1.0 therefore represents the "standard" and everything else is just a proportion to this standard. I suspect the standards may be different species to species and even character to character (high agility might influence this). There also seems to be a different speed for combat actions which I believe is more heavily influenced by the agility stat (and maybe the kinesthetic sense stat). I have no idea how this is calculated. But it is a certainty that there are several variables involved and that different characters have different combat speed. The speed, I think determines how much you can do in a time unit. I suspect actions are described in terms of a number of time units, though I can only speculate as to how the actions are executed (e.g are simultaneous blows possible?)

b. Physics

Now Toady is a mathematician by profession so I assume the physics system is quite complex. However I think for the purposes of combat, Newtonian mechanics are what is used. If that's true we can boil the combat down to two things: force and area. I wonder if the different "types" of damage (blunt, cutting etc.) are implemented specifically or if they are just the consequence of the calculations the game makes (e.g whether cutting damage is just force in a narrow band or piercing damage just force at a small point etc.) I suspect the former, but I'm not sure.

According to the wiki, weapon forces are influenced by a number of factors, including the size of the weapon, the material and the shape as well as the strength of the user. I don't know the specific formulas used, but I assume something close to reality is used as much as possible.

c. Damage

I'm curious to know how force translates to damage to the body systems. I assume there are some threshold values, if the force is greater than those thresholds than some effect happens. However, if we consider armor, enemies can sometimes penetrate the armor, therefore there is also some element of randomness.

Any help in clearing some of this up would be appreciated. Thanks.



« Last Edit: December 25, 2015, 12:34:51 am by bahihs »
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Dwarf Fortress Combat Mechanics (Programming Perspective)
« Reply #1 on: December 20, 2015, 12:13:35 pm »

Look at what Toribash does?

The only game I tried and found harder to get the hang of than DF, never did get any good at it, but I did once kick the training dummy hard enough to knock an arm off, do a weird little breakdance twirl, handspring and kick their head off then in mid-air pulled my own head off, as I recall.

https://www.youtube.com/watch?v=a0l9NVcPlDY
Logged

bahihs

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Combat Mechanics (Programming Perspective)
« Reply #2 on: December 20, 2015, 12:32:03 pm »

Look at what Toribash does?

The only game I tried and found harder to get the hang of than DF, never did get any good at it, but I did once kick the training dummy hard enough to knock an arm off, do a weird little breakdance twirl, handspring and kick their head off then in mid-air pulled my own head off, as I recall.

https://www.youtube.com/watch?v=a0l9NVcPlDY

Toribash is cool, but not really what I'm looking for.  Toribash is more of a physics sim, whereas mine is purely a combat sim. 

Actually as I've begun fleshing this out I'm beginning to see the physics become abstracted and simplified. At this point I just have a "Force" value which is calculated from the combination of several different variables, then this force goes through several different transformations ("type" of force determined by the area - cutting, bashing etc., then the penetration of the force determined by type, finally the type of tissue damage depending on penetration) which finally leads to "wounds".

In the end I decided to go with something similar to the combat in "The Riddle of Steel" rpg. But with a more complex wounds system.

If any one is interested here's what I have so far:

Spoiler: Current Combat System (click to show/hide)

I can put the full docs I'm writing if anyone is interested. Though I don't know if it would be appropriate in this sub-forum (maybe creative projects?).
Logged

Thorgrim Grudgebearer

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Combat Mechanics (Programming Perspective)
« Reply #3 on: December 23, 2015, 06:35:51 am »

Good luck to you man sounds like a awesome idea would like to see this actually made. Definitely gonna follow this one.
Logged

bahihs

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Combat Mechanics (Programming Perspective)
« Reply #4 on: December 23, 2015, 11:21:18 am »

Here are the current docs/plan for the game (partly stolen from a different thread of mine):

Spoiler: Docs (click to show/hide)

The "minimal viable product" has essentially been coded. The question now is do I attempt to make some sort of map, or keep it strictly text. I am leaning heavily toward the latter, since it would avoid using any libraries or other fancy stuff. Also since the purpose of the game is purely combat, a map isn't really necessary (consider street fighter, the background hardly makes a difference to the actual fight). However, since interaction with the environment is something I want to include, the best I could come up with is a paragraph of randomly generated text which serves as the "setting" or "map". This paragraph includes some "keywords", these keywords represent "features" in the setting which can interacted with. For example, in the minimal viable product, the setting is a desert (completely flat and devoid of features and therefore easy to code :) ). The only feature it has is "sand" and the only interaction with sand is to throw it in some one's eyes to blind them (haven't implemented what blinding actually does though).

If anyone is interested I can post the code and an .exe so you can test out the game. Right now its very bare bones. There's no AI, so you play both sides (or you can play hotseat). There's only one type of character (Swordsman, either high Agility or high Constitution). Easiest way to win right now, is just cause the other person to bleed (dropping their agility) then spam attacks to the head, hoping to cut it off.

I'm hoping to have something decent by the end of this winter break (~mid Feb). I can keep this post updated, but I'm wondering if I would have to move it to "Creative Projects" (since its becoming less and less about DF)? (How would I actually move it btw?)
Logged

FallacyofUrist

  • Bay Watcher
  • Blatant furry. Also a hypnotist.
    • View Profile
Re: Dwarf Fortress Combat Mechanics (Programming Perspective)
« Reply #5 on: December 23, 2015, 08:52:46 pm »

I think there's a "move thread" think at the bottom of the page.
good luck to you.
Logged
FoU has some twisted role ideas. Screw second-guessing this mechanical garbage spaghetti, I'm basing everything on reads and visible daytime behaviour.

Would you like to play a game of Mafia? The subforum is always open to new players.

bahihs

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Combat Mechanics (Programming Perspective)
« Reply #6 on: December 23, 2015, 08:53:22 pm »

I think there's a "move thread" think at the bottom of the page.
good luck to you.

Indeed there is. Thank you.
Logged

bahihs

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Combat Mechanics (Programming Perspective)
« Reply #7 on: December 24, 2015, 02:01:16 am »

Finished building a crude AI. I think I'll upload the .exe of the game tomorrow (I want to add some more user functionality, like choosing your own name).
Logged

bahihs

  • Bay Watcher
    • View Profile
Re: Dwarf Fortress Combat Mechanics (Programming Perspective)
« Reply #8 on: December 24, 2015, 02:20:31 pm »

First version can be downloaded here, just extract the zip and run the exe.

I would really appreciate any feedback. Of course, the game is, again, very bare bones right now. One thing I want to experiment with is text menus. Does anyone know any modules/libraries for python which allow for text UI's?

EDIT: There were a few small bugs in the program which I fixed (player could not choose to defend for example). The file should be updated so you can use the same link to download. Sorry about that.
« Last Edit: December 24, 2015, 07:02:31 pm by bahihs »
Logged

kytuzian

  • Bay Watcher
    • View Profile
    • Kytuzian - Youtube
Re: Text Based Fighting Game (Using DF-like combat)
« Reply #9 on: December 28, 2015, 08:32:31 am »

I don't suppose a mac version is likely?

bahihs

  • Bay Watcher
    • View Profile
Re: Text Based Fighting Game (Using DF-like combat)
« Reply #10 on: December 28, 2015, 10:40:45 am »

I don't suppose a mac version is likely?

Actually it should work already. Pyinstaller (module used to make the exe) should make the program mac and linux-compatible as well. If you tried it and got an error, let me know and I'll see what I can do.
Logged

bahihs

  • Bay Watcher
    • View Profile
Re: Text Based Fighting Game (Using DF-like combat)
« Reply #11 on: January 02, 2016, 06:59:38 pm »

New version is up.

You can get it here (same place as before). Again any feedback would be greatly appreciated.

I've added:

- A basic main menu (work in progress)
- Ability to create your own characters (work in progress), at least with regards to stats
- Better body part system with wounds and injuries instead of simple HP (work in-well you get the point)
« Last Edit: January 02, 2016, 08:32:37 pm by bahihs »
Logged

kytuzian

  • Bay Watcher
    • View Profile
    • Kytuzian - Youtube
Re: Text Based Fighting Game (Using DF-like combat)
« Reply #12 on: January 02, 2016, 07:05:52 pm »

I don't suppose a mac version is likely?

Actually it should work already. Pyinstaller (module used to make the exe) should make the program mac and linux-compatible as well. If you tried it and got an error, let me know and I'll see what I can do.

I don't see the base .py files in there, only the .exe

bahihs

  • Bay Watcher
    • View Profile
Re: Text Based Fighting Game (Using DF-like combat)
« Reply #13 on: January 02, 2016, 08:31:58 pm »

I don't suppose a mac version is likely?

Actually it should work already. Pyinstaller (module used to make the exe) should make the program mac and linux-compatible as well. If you tried it and got an error, let me know and I'll see what I can do.

I don't see the base .py files in there, only the .exe

EDIT: Also, if any kind soul wants to use pyinstaller to compile it his/herself on linux and/or mac and post it for others, that would be cool. This program will never be commercial, so you can do whatever you like with it. 

Oops, it seems I was mistaken earlier. I have to compile the program in each of the three different platforms (Win, Mac and Linux) that will then generate 3 different versions, each one compatible with its respective platform.

This will take some work, as I'll have to mess around with Virtual Machines to emulate each of the platforms. For now I've updated the file to include a folder with all the base .py files so that it can be run on any environment so long as python (2.7) is installed (I didn't use any third-party libraries, so it should be good to go).

Sorry about that, but I should hopefully have the linux and mac compatible versions in the future.

You can still use the link in the previous post as I've updated the file.
« Last Edit: January 02, 2016, 08:39:04 pm by bahihs »
Logged

kytuzian

  • Bay Watcher
    • View Profile
    • Kytuzian - Youtube
Re: Text Based Fighting Game (Using DF-like combat)
« Reply #14 on: January 02, 2016, 11:56:24 pm »

Oops, it seems I was mistaken earlier. I have to compile the program in each of the three different platforms (Win, Mac and Linux) that will then generate 3 different versions, each one compatible with its respective platform.

This will take some work, as I'll have to mess around with Virtual Machines to emulate each of the platforms. For now I've updated the file to include a folder with all the base .py files so that it can be run on any environment so long as python (2.7) is installed (I didn't use any third-party libraries, so it should be good to go).

Sorry about that, but I should hopefully have the linux and mac compatible versions in the future.

You can still use the link in the previous post as I've updated the file.

Alright, well on Mac and most Linux distributions (I think), Python 2.7 comes preinstalled, so its not a problem, the problem is people being able to find it and run it from the terminal, but I think most people can handle that.

Also it took me a couple more steps to get it to work, because I don't have PIL on my computer. Instead, I converted the background image to a .gif then used Tkinter's PhotoImage class to load it. I'd suggest that approach because it's more cross-platform.

Also I realize its a work in progress, but I think it'd be good to have sliders as well as a text field for entering in your character's stats, because I personally have no idea what sorts of numbers are reasonable. I didn't play around with it too much other than making a character though.
Pages: [1] 2