Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Text-based Combat

eric__s

ass hater
Developer
Joined
Jun 13, 2011
Messages
2,301
I'm looking for suggestions for a text-based RPG combat system.

The way the combat system currently works is that your character has skills (hundreds of them - too many to keep track of or even fully comprehend (but this is a good thing!)) that determine the choices you're able to make and even certain sentences that are displayed. It's a solid system because it allows you to take advantage of tactical opportunities unique to your character's skill set. For instance, if your character has an advanced understanding of anatomy, you can choose to target certain body parts that would incapacitate your enemy. If your character is mentally ill or has an understanding of psychological combat, you can choose to (or involuntarily) act insane to bewilder your enemies and affect their psyche. In one fight, if your spacial perception and totemic knowledge are high enough, you can smash some ritual object to make a guy flip out, taking the fight in an entirely different direction. It's a really cool system and it presents a lot of context sensitive choices that are based on what your character is good at and how they perceive the world.

The problem is that it is extremely rigid and plays exactly the same as the rest of the game. There is no mechanical difference between how combat works and how the rest of the game works and because combat is a series of quick actions and choices that happen over a short period of time, it makes it very difficult to do. A combat sequence that takes 30 seconds to complete might take 5,000 words to write, 90% of which you won't see. This is time and effort that can be better spent elsewhere! What I would like is a system that maintains the freedom of tactical choice that the current one has while being able to dynamically generate text and situations, but I don't know how feasible this is or if it's even possible.

Are there any examples of text-based games that have good combat? Is there anything I could look at as an example or template? Should I scrap this idea entirely and go for a more traditional RPG combat system? Any other suggestions? Any help at all would be appreciated!

I guess I should add that you only control a single character and that there's no magic (or there's no tangible, visible magic - there are religions, many people believe in magic and there are all sorts of ritualist and folk magic skills, but you don't go around casting fireballs or whatever).
 
Joined
Jan 9, 2011
Messages
2,749
Codex 2012 Codex 2013 Codex 2014 PC RPG Website of the Year, 2015 Codex 2016 - The Age of Grimoire Make the Codex Great Again! Grab the Codex by the pussy Insert Title Here RPG Wokedex Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming! Enjoy the Revolution! Another revolution around the sun that is. Serpent in the Staglands Dead State Divinity: Original Sin Project: Eternity Torment: Tides of Numenera Wasteland 2 Codex USB, 2014 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Bubbles In Memoria A Beautifully Desolate Campaign Pillars of Eternity 2: Deadfire Pathfinder: Kingmaker Steve gets a Kidney but I don't even get a tag. My team has the sexiest and deadliest waifus you can recruit. Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
Well, the way I would do it, would be to use stuff like nCurses to split display into some status segments and an available action segment. One status segment for hero, one for enemies and maybe a detailed status for focused/targeted enemy (if you do have such thing). If you don't have targeting then add it, it will save on retyping name of the enemy each turn.

The available action segment would show what you character can do, based on skill. If you don't want to simplify too much, on first level you should put stuff hinting at which skill will be used and on second level have more exact options. Have shortcuts for those.

Of course all this should still allow the user to type the whole action sequence as he would normally. Think Norton/Midnight Commander - you have panels for doing stuff quickly but you still have command line.

Good idea would be chaining of actions. I.e. allow user to queue several actions on a target. Make the sequence stop if the situation changes sufficiently (enemy dead or some other configurable condition).

Being able to type:
>:a[ttack] e[nemy]1 w[eapon]1 && a e1 w2 && (a e2 w3)10
should be reasonably tolerable even for longer sequences. Proposed syntax is of course an example only, although sticking to stuff similar to bash will make it feel warm and familiar to linux nerds ;)
 

Alex

Arcane
Joined
Jun 14, 2007
Messages
8,805
Location
São Paulo - Brasil
Well, it seems to me the best way of doing this would be through inheritance. Basically, have a "default" combat model. With a few simple, "default" actions. For example, by default, a direct attack (a type of default action) might roll a d20, add the opponent's armor class and compare this to the attacker's THAC0. It might run the following code to display text:

Code:
attacker.getName() + " attacks " defender.getName() + " for " + damage.getTotal() + " damage."

Alternatively, you might leave the phrase displaying method abstract, which means that only actual direct attacks would implement the code above (see below) or even roll randomly on a list of possible phrases that only the actual attacks implement.

Once you have done this, you will have a basic combat system, much like those of your common RPG. I expect this isn't at all what you want, but you can now specialize the basic combat to the specific cases you want to deal with without so much trouble. For example, you might have a "slash" attack, representing a wide slash with a cutting weapon, as inheriting from the direct attack class. However, it has its code changed so the attack is considered slow, but has a higher chance of penetrating the character's armor. Of course, it would probably need its own text description.

Then, you might have certain actions that specialize on the type of enemy. For example, all direct attack against a bat (or maybe, against any creatures that are both small and flying), might have a penalty to hit based on their speed, thanks to the greater mobility afforded to such creatures. Thrust attacks (which inherit from normal attacks) might have a further penalty. But then, if you make a swing attack with a flaming weapon (such as a torch), you might also scare the bat (or any other animal, for that matter).

If you are using a "normal" programming language, one that doesn't allow you to do multiple dispatch (and most don't), you can use the double dispatch pattern, which might look like this:

Code:
public Class Slash extends DirectAttack {
(...)
  public void attackEnemy (Character enemy, Weapon weapon) {
    enemy.beSlashed(this, weapon);
  }
(...)

And then you should implement on character the basic handling of all possible double dispatch method, such as beSlashed, beStabbed, beBurned, etc. Since we might be talking about triple dispatch here, and on multiple levels (most animals handle beSlashed on a way, but small, flying animals might handle it differently, to account for the possibility of them losing a wing), the end result could be pretty complex still. In fact, I think it might be more complex than absolutely necessary. But the only way I can think of doing this in a simpler way would be to make a custom language, or a language extension, which would be even more trouble.
 

Weierstraß

Learned
Joined
Apr 1, 2011
Messages
282
Location
Schwitzerland
Project: Eternity
If your only issue is how to create the amount of text needed a system of rough categories of basic sentence structures (attack with a weapon, use of specific knowledge or ability, using an item etc) together with a number of randomized words for description to avoid repetition and maybe some counters for repeated actions ( i.e. "swings his sword" the first time, "swing his sword again" if using the sword two rounds in a row).
 

shihonage

Subscribe to my OnlyFans
Patron
Joined
Jan 10, 2008
Messages
7,163
Location
location, location
Bubbles In Memoria
cboyardee said:
Are there any examples of text-based games that have good combat? Is there anything I could look at as an example or template? Should I scrap this idea entirely and go for a more traditional RPG combat system? Any other suggestions? Any help at all would be appreciated!

Non-lulzy response: Look at Dwarf Fortress combat system. I think it's the closest to what you want.

Lulzy response.
 

eric__s

ass hater
Developer
Joined
Jun 13, 2011
Messages
2,301
Hey, thanks for the suggestions everyone. Alex, I'm going to look into this. This seems like a pretty clever solution that might do a lot of what I want it to do. I think the main thing is that I want every battle to have lots of exceptions and unique occurrences; things that work in some fights won't work in others and there are many things exclusive to each fight.

Also, I should probably clarify that it's a text-based game in the way King of Dragon Pass is a text-based game. I guess that would make it a choose your own adventure game, I'm not really sure about the nomenclature or whatever. How it works is that there are a few base choices available to everyone and more choices that aren't visible unless you meet the minimum stat requirements. All choices can have multiple outcomes based on your stats and the choices that unlock based on your stats might or might not necessarily be better than the base choices. It's more about the freedom of being able to approach things in different ways or take them in different directions.

I was thinking about a parser but I don't know if it would be worth the effort to implement. I think the biggest difference between a parser and being given choices is that with choices, you can see from a list what you're capable of doing and with a parser you have to guess. With a game that has hundreds of skills, it would be hard to guess which skills you would use in any particular situation, especially since there are many times when you use combinations of skills or skills you wouldn't necessarily associate with combat. Also, there are a LOT of actions you just would never think to do that might not even be associated with skills like vomiting on a guy, eating a guy's heart, hurting yourself, screaming, whatever.

But yeah, thanks for the suggestions everyone. It's all given me at least something to think about. I appreciate it!
 

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
There is this:

http://www.projectaon.org/staff/david/

But i don't think this is the system you're looking for, since it's a "traditional" random roll gamebook combat instead of what you want.

Beware of rigid inheritance hierarchies since some OO languages require workarounds (eg:visitor pattern) when objects need to interact with other objects without classtype checks, and those workarounds will explode your code (besides burying interactions in the classes, which may well be the point, but can turn out more complex that doing it in the main loop).

Your main loop will look very clean though. And quite frankly if you're going for hundreds of interactions, you should bite the bullet and prepare to use visitors extensively, because otherwise your main loop will be fucking huge.

Here is a high level overview of some different visitor strategies:
http://tech.puredanger.com/2007/07/16/visitor/

This is all plumbing though - the real sauce is work, ideas and insight.

Also some alternatives to visitors in other languages:
For navigation visitors: lambda expressions or closures or function pointers given into a piece of code that iterates how you want over the objects are simpler (ex: C#, any functional language, Java 8, function pointers in C/C++).
For "OO" class visitors: multimethods (methods that also dispatch on argument type, ex: python)


You'll eventually need a dataformat. Enemies will need their own properties, will need to store them, you'll want to make items with effects etc.

How about leaving the bare system in code barebones and just have:
Iteration strategies: all of the persons in the map, all of the allies, all of the enemies, enemies in sight, beings of race, combinations etc etc etc.
Effect stacking and limits (general universal rules).

AI (of course): I have no good suggestions, not that smart myself. Maybe this should be scriptable too for variety.

And leave the properties in a file format that would be parsed and run at runtime:
effects cancellation and prerequisites:
ie: improved haste DISPELS haste and haste ISPREVENTED by Improved haste
effects on the npc stats; permanent, while equipped, timer, dispellable etc.
type of targeting (equivalent of the iteration strategy code)
dispel DISPELS everything except DISPEL

.... many things i didn't think of....

IESDP file formats section is a nice place to get ideas of how to do file formats like this:
http://iesdp.gibberlings3.net/file_form ... eff_v2.htm
 

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
Finally a word about AI:

You may not have realized it if you've never tried doing a game (don't know if you did), but at the "lowest level" possible, after the "hard" decision making process, AI outputs actions for your mooks to do.

Actions, both in games and in real life have a time component - however you are in a computer, that by necessity and simplicity runs actions sequentially (yes yes i know, but that turns things into mush).
The "actions" the AI produces must be interruptible and restartable from the point of time. Either by subdividing into smaller actions when the time allotted to them finishes, or by "starting again" from the the same place they left off.

(Actions also sometimes need to be stopped and replaced... the world changes - but that is part of the "hard" decision process).

They need this interruption to give the rest of the game their fair time to go on, otherwise the illusion of simultaneous actions would fall apart (and the game).

There is a technical solution for this programming problem in some languages called continuations. I don't know if you can use it in yours, but it's a nice thing that simplifies this lowest level if you can (it also slightly slows down your AI, but who the fuck cares right?)

Notice that it doesn't fucking matter if the game is turnbased or not. It still needs to interrupt the action to draw the nice glowy swords, move the animations (another thing with state that must be interruptible) etc.
 

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
And this my friends, is why i quit programing.


It sucks balls.
 

shihonage

Subscribe to my OnlyFans
Patron
Joined
Jan 10, 2008
Messages
7,163
Location
location, location
Bubbles In Memoria
Remind me to never tell you how I coded combat AI in Shelter.

There are things, man. Things you have to do to stay sane in there.

Things that can never be undone.
 

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
Yeah well, my code sucks too.


BTW; using continuations in languages without garbage collection is "hard", so my advice is fucking useless :M
I think they're often used in Lua for AI though (but i never used lua).

edited out misinformation :x

Continuations are interesting by themselves though. Here is a simple (inefficient) java library and example:
http://commons.apache.org/sandbox/javaf ... orial.html

Fuck restating whiles is what i say. Bring on the languages with continuations
 

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
Actually, forget that. Don't try to use continuations.

It will slow down things unless you are in a arcane programming language, and you need to known when to stop the action anyway (to stop the execution), so you might as well setup something that short circuits the larger action and restarts it.

Just be aware of the "interruption problem" when you're implementing a action like "AttackObject", "Turn" or "Follow". Restarting as a strategy is simple: before updating your gamestate check if you should interrupt if needed. Next time the action is run it needs to return to that point, so reset every variable except time elapsed. If you're using a while... well, it's harder, but add at least the iteration counter to the "not reset" set.

Bugs bugs bugs.

BTW, it's good to be able to compose actions if you can figure out how (follow is "walk to" and "turn to").
 
Joined
Nov 8, 2007
Messages
6,207
Location
The island of misfit mascots
cboyardee said:
I'm looking for suggestions for a text-based RPG combat system.

The way the combat system currently works is that your character has skills (hundreds of them - too many to keep track of or even fully comprehend (but this is a good thing!)) that determine the choices you're able to make and even certain sentences that are displayed. It's a solid system because it allows you to take advantage of tactical opportunities unique to your character's skill set. For instance, if your character has an advanced understanding of anatomy, you can choose to target certain body parts that would incapacitate your enemy. If your character is mentally ill or has an understanding of psychological combat, you can choose to (or involuntarily) act insane to bewilder your enemies and affect their psyche. In one fight, if your spacial perception and totemic knowledge are high enough, you can smash some ritual object to make a guy flip out, taking the fight in an entirely different direction. It's a really cool system and it presents a lot of context sensitive choices that are based on what your character is good at and how they perceive the world.

The problem is that it is extremely rigid and plays exactly the same as the rest of the game. There is no mechanical difference between how combat works and how the rest of the game works and because combat is a series of quick actions and choices that happen over a short period of time, it makes it very difficult to do. A combat sequence that takes 30 seconds to complete might take 5,000 words to write, 90% of which you won't see. This is time and effort that can be better spent elsewhere! What I would like is a system that maintains the freedom of tactical choice that the current one has while being able to dynamically generate text and situations, but I don't know how feasible this is or if it's even possible.

Are there any examples of text-based games that have good combat? Is there anything I could look at as an example or template? Should I scrap this idea entirely and go for a more traditional RPG combat system? Any other suggestions? Any help at all would be appreciated!

I guess I should add that you only control a single character and that there's no magic (or there's no tangible, visible magic - there are religions, many people believe in magic and there are all sorts of ritualist and folk magic skills, but you don't go around casting fireballs or whatever).

Have you been hanging round the web long enough to remember the days of text-based MUDs (the precursors to MMOs - when MMOs first came out they were called graphical MUDs)? Almost all of those had combat systems, most had open PvP and some had reasonably complex systems. My favourite was one where you had 5 different time periods (which operate in effect like continents in modern MMOrpgs), and the one where you choose to start in determines what combat skills are available to you (stealth/backstab, melee skill tree, magic, medicine, firearms, mechanics, etc - so if you start in the Arabian knights era you can find teachers for magic, stealth and melee, if you start in modern England you can have firearms, mechanics and medicine). All combination of teach and train-by-use, but the major point of the game is that at about the mid-level of the game, you had a chance to pass a reasonably tough quest to get a time-travelling ability, which would enable you (now a tough enough player to wtfpwn most of the local players, but not so tough that they can't call their guildie top guns to zone into their home time zone and kill you - you had a death limit of 5, renewable each level, but by time-travelling stages levels are far apart so perma-death was a serious issue in PvP).

You could also try learning skills from foreign time zones (go back in time to learn druidic magic, or forward to learn guns) but you'd naturally learn them slower than your home ones because of the increase in exp required per level (hence you'd have fewer training points to speed up your learning, making it unlikely that you'd ever catch up to your 'home time-zone' skills).

Now that battle system was actually much simpler than the one that you're describing, but my point was that while there were plenty of clone MUDs, there was also an incredible feast of creativity out there, with MUDs designed for roleplaying, PvE with some PvP, and even pure PvP (the popular Aliens v Predator v Marines MUD comes to mind - three different races with different classes and wildly different combat systems. Aliens would be almost entirely level-dependent in what they could do and had no ranged attacks, but could move fast, fly, pounce, stun everyone in the room, etc; at the other end of the spectrum, a low-level Marine could be pretty powerful if he has some good equipment (powerful guns, armour, or a fucking tank etc, but would still have accuracy and other stats determined by level).

I don't think any of these will give you what you're looking for in a single package, but it is certainly worth checking out as many MUDs as you can (if they are even around these days - I doubt that there are any live servers still around, but there might be repositories storing them for posterity). I can't think of any greater period of competitive creativity in text-based combat engines than the MUD era.
 

eric__s

ass hater
Developer
Joined
Jun 13, 2011
Messages
2,301
Hey everyone, thanks a lot for the advice. I've been digesting and looking into a lot of what you've mentioned and it's been a lot of help. It's hard to explain, but the project is moving fast in some areas and is pretty slowly in others, but I think I'll have something decent to show for it fairly soon. I'm pretty much convinced now that combat needs to be completely dynamic, rather than a series of hypertext choices that are visible or invisible based on your skills, and I think this will probably take the bulk of development.

I ran through a couple of Telnet MUDS to see how they worked. None of the stuff I found was particularly advanced but I liked the idea of actions happening simultaneously or on a timer. I think this could be potentially pretty interesting for the game depending on how we develop it, but I don't know yet since I still have a lot of work on some of the other systems as well. Actually, I messed around with MUDs in high school and got my school's network banned from Telnet for goofing off in some Christian MUD.

But yeah, I really appreciate all the advice so far and I'm going to look further into all of it. Right now the game is sort of a test run for ideas, but hopefully if it works out well it will develop into something bigger. Thanks everyone.
 

Father Walker

Potato Ranger
Joined
Apr 13, 2011
Messages
1,282
I'm not into programming that much, but I suggest that you take a look at this: http://www.driftwoodpublishing.com/support/TheRiddleOfSteel.zip

It's a electronic version of a combat system used in the Riddle of Steel (it's a PnP RPG). The game would be a chore to run, but it has some decent ideas easily usable in PC games. It manages to get pretty realistic results using simple means.

I don't want to intrude into your design, but have you considered reducing amount of skills and modifiers? You know, sometimes it's best to keep things as simple as possible. The more shit you put into a design, the more unexpected corelations you can get, not to mention methods to abuse the system.

Then again, I know shit about PC game design.
 

zeitgeist

Magister
Joined
Aug 12, 2010
Messages
1,444
Could you describe the context of this combat, and the final (post-combat) results it is supposed to produce in more detail please? How often does it occur? What is the overall purpose of combat in this game, and what are the main end states of a combat event? How do these events influence the overall course of the game? Are they supposed to be randomized, is the game designed to be replayed multiple times, etc?

The main reason I'm asking is because there might not be a point in even implementing such a complex system if it ends up playing more or less the same as a regular CYOA.
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom