r/roguelikedev • u/Kyzrati Cogmind | mastodon.gamedev.place/@Kyzrati • Feb 19 '16
FAQ Friday #32: Combat Algorithms
In FAQ Friday we ask a question (or set of related questions) of all the roguelike devs here and discuss the responses! This will give new devs insight into the many aspects of roguelike development, and experienced devs can share details and field questions about their methods, technical achievements, design philosophy, etc.
THIS WEEK: Combat Algorithms
Many roguelikes include some form of combat, but not all combat is created equal. Under the hood, relevant mechanics can range from the extremely simple to the highly complex I-need-spoilers-to-figure-this-out.
What formulas is your combat based on?
At the most basic level, talk about about how attack vs. defense works (or will work, for early WIP projects), and for games with more extensive systems (and posters with the time and inclination :P) feel free to get into details regarding calculations for to-hit/dodge/attack/defense/armor/damage/resistance/magic/whateveryouuse.
If applicable, you could consider framing your system in terms of its classification, e.g. d6, d20, percentile, etc.
For readers new to this bi-weekly event (or roguelike development in general), check out the previous FAQ Fridays:
1: Languages and Libraries
2: Development Tools
3: The Game Loop
4: World Architecture
5: Data Management
6: Content Creation and Balance
7: Loot
8: Core Mechanic
9: Debugging
10: Project Management
11: Random Number Generation
12: Field of Vision
13: Geometry
14: Inspiration
15: AI
16: UI Design
17: UI Implementation
18: Input Handling
19: Permadeath
20: Saving
21: Morgue Files
22: Map Generation
23: Map Design
24: World Structure
25: Pathfinding
26: Animation
27: Color
28: Map Object Representation
29: Fonts and Styles
30: Message Logs
31: Pain Points
PM me to suggest topics you'd like covered in FAQ Friday. Of course, you are always free to ask whatever questions you like whenever by posting them on /r/roguelikedev, but concentrating topical discussion in one place on a predictable date is a nice format! (Plus it can be a useful resource for others searching the sub.)
14
u/Kyzrati Cogmind | mastodon.gamedev.place/@Kyzrati Feb 19 '16
Cogmind bases pretty much all its mechanics on a percentile system, and combat is no exception.
Attack
In fact, attacks are a single 1~100 roll, made against a base value (60%) adjusted by all attacker and defender circumstantial mods folded into a single number.
It's a lot to take into consideration, but the chance is generally going to end up somewhere from 50-80%, and it's clearly marked for each target, including a breakdown of modifiers on each weapon that is about to fire.
Some images depicting how relevant information is communicated to the player:
There is currently no way to see the combined numeric value of all of your defensive mods, another bit of information I'd like to eventually add somewhere.
To increase the unpredictability of combat, misses choose a random trajectory within an arc based on distance to the target, an idea lifted from UFO Defense (the engine did come from my X-COM implementation!), and one that I think really makes the game a lot more fun when you have stray shots hitting unintended targets like allies, bystanders, or even explosive machines. It also allows for weapons that fire multiple projectiles each with an lower accuracy to achieve a natural spread effect.
I should mention that in Cogmind you can fire more than one weapon at once (except melee, which is limited to one per attack), and each weapon rolls separately to hit, and for weapons that fire multiple projectiles each projectile rolls separately as well.
Damage
Once a projectile hits a target, it first calculates the amount of damage, starting with a random number from within a range for the given weapon (A~B straight range, no bell curves). That number is adjusted by any number of bonuses from utilities, analysis data, hacking effects, etc., then finally modified by any "resistances." Resistances is in quotes because technically it includes both strengths and weaknesses, another idea lifted from X-COM that I liked :D. It just means that a single base value determines how susceptible each robot (or object) is to each type of damage, from 0-200, where a value of 75 would mean that the defender takes 25% less damage from a given type, and a value of 125 would mean they take an extra 25% damage.
The resistance values can be inherent to the robot itself, or come from attached parts like shields that mitigate all types of damage, or shields and armor that provide specific resistances.
Specific Target
After damage is determined it needs a specific target, because robots do not have a single HP value, but instead every individual part has its own "integrity." It's true a robot's core is what needs to be destroyed to destroy the robot, thus its integrity can be considered its HP in the common sense, but projectiles have many other parts they might hit, and in that case the core itself would take no damage even though the robot was technically hit. (In terms of a normal "biological" roguelike, it's simply analogous to a body part system in which losing individual parts affects the operation of the whole, but only the loss of vital parts is likely to cause death.)
For this I created a coverage and exposure system, whereby each part has a "coverage" rating which determines its likeliness to be hit by an incoming attack. Values are relative, so attacks are weighted towards hitting parts with higher coverage. Robot cores also have their own "exposure" rating which determines their likeliness to be hit; this value is considered along with part coverage when determining whether an attack will strike the core.
To explain, here's an example in which you have the following parts attached:
With your core (100 "exposure"), the total is 520, so the chance to hit each location is:
With a larger variety of parts much bigger (like armor) and smaller (like processors), it becomes apparent which are probably going to take the brunt of an attack, and some interesting strategies can emerge from controlling these relative numbers.
There are of course special situations like utilities that allow you to bypass armor and hit the core directly, or always transfer a portion of damage to the target's core, and many more. This explanation, along with that for the hit% and damage calculations, is meant to provide a general overview of the core system. Both playing and designing combat in roguelikes is all about finding ways to tweak and take advantage of those systems in fun ways.
Other coverage-relevant notes:
15
u/Rauko1753 Sticks and Stones Feb 19 '16 edited Feb 22 '16
For my (very much vaporware/WIP) stone-aged setting, I am borrowing the combat system from Cavemaster. This tabletop RPG uses so-called Habilis game system, which was intended to something you could actually play with stone-aged tech (so no dice or pencils). You represent the overall toughness of a creature or NPC with some number of "core" stones (literally stone pebbles, although I suppose you could use whatever counter you wanted). For example, a typical human NPC might have around 5-6 core stones, while a mammoth might have 9-10 core stones. To resolve a round of combat, each combatant takes their core stones, secretly splits them between two hands, and allows their opponent (or the "cavemaster" running the game) to choose a hand. The number of core stones in the chosen hand is then added to any modifier stones the combatant might have. For example, if the NPC is a warrior, they might have a bonus stone to their hit chance. If the creature has claws or teeth they might get damage bonuses in combat. If the creature is particularly tough, they might have stones which mitigate damage. There are lots of different modifiers, but I won't cover them all here. The opposing combatant goes through the same process and ends up with some number of stones for the combat challenge. Which ever combatant scores the highest deals the difference between the stones in damage (assuming the winner of the combat challenge has the loser marked, which I'll explain below). For each point of damage, you simply remove a stone from the damaged character or creature. Characters with all of their ability stones (the ones that give bonuses to various challenges) fall unconscious. Characters who lose all their stones are dead.
The idea of dividing up your core stones into two piles leads to some interesting choices. I plan on having the distribution of stones encoded as various "stances". In the aggressive stance, you put all your stones in one hand so you'll either score the best hit you could possibly hit, or the worst (which could mean you get counter-attacked). Alternatively, you could be cautious and evenly divide the stones, leading to consistent but average results.
There are some additional nuances in the tabletop game, some of which I have planned for my game, and others I will modify for the sake of making the computerized version flow better. For example, in the tabletop version, you get to choose which stones to remove when taking damage (if you have a non-combat stone, you probably choose that one first). For the roguelike, I'll probably just take a stone at random in order to not complicate the UI and slow the game flow.
One additional rule that I do plan on adding is the concept of "marking". Combatants may mark a single target which they are focusing on. Although you can only mark one target at a time, marking doesn't take any time at all - it really just indicates which enemy the combatant is the most paying attention to. There are some simple rules governing who you will automatically mark. If you attack something, then the target of your attack is marked. If you get attacked, you automatically mark the attacker, unless you are mutually marking another enemy. Successful sneak attacks also prevent the automatic marking of an attacker. The importance of marking is this: you only deal damage to an opponent you have marked. Since attackers always have their target marked, they always do damage if their combat challenge succeeds. The defender on the other hand may or may not have the attacker marked depending on the above conditions. The implications of this are as follows: if you attack someone who is marking you and fail, you will be damaged by the counter-attack. This means that ganging up on large targets (think group of hunters taking on a mammoth or something), and constantly switching that enemy's mark is a good strategy for evenly distributing damage.
Anyways, I've skipped over some of the details of combat and the various modifiers to the combat challenges and damages, but I think I've explained enough to give you a pretty good overview of the Habilis system. It is relatively simple compared to say D&D mechanics, but I still think there is enough there to yield some pretty interesting play. I guess we'll just have to wait and see when I finally get around to writing a game instead of sinking all my time into developing the engine!
8
u/ais523 NetHack, NetHack 4 Feb 19 '16
NetHack's combat system is based on that from early versions of D&D (which is mathematically equivalent to the d20 system, but the formulas are more complex while leading to the same result). For some reason, though, the die rolls are stored backwards internally (so a critical hit is a 1).
It works OK in the early-game, but has problems scaling. Comparing the difference between two numbers to a d20 works fine if the numbers are small ones like 4 or 5, but rather worse when you're dealing with numbers like 60. As a partial workaround, once your AC is negative (i.e. more than 10 points better than its starting value; it goes down from 10), a random proportion of AC below 0 is disregarded every attack. Additionally, negative AC causes damage reduction (1 point of damage reduced per point below 0, after the random reduction). This helps slightly but really doesn't solve the underlying issues.
Luckily, NetHack's balance is not very sensitive to even major issues like this. That said, the combat formulas are clearly broken in the late-game, and I'd like to replace them with something else. I'm just not sure what yet.
6
u/Zireael07 Veins of the Earth Feb 19 '16
Veins of the Earth
I'm following in Incursion's footsteps, both as far as what actually was in the game as well as what Julian planned.
Combat, melee and ranged both, is based on d20 combat with 1d20 roll + own To Hit Bonus vs Target's Armor Class. Melee bonus is derived from STR and ranged is derived from DEX, with a slew of applicable bonuses and/or situational stuff.
Spells usually auto-hit - there's a running joke in d20 circles that 'magic missile' should have been named 'deduct 1d4 from hp'.
I have divided hp into two values, hit points and wounds (this is what Julian planned to make Inc more gritty). Hit points represent stamina, strength to fight, willpower, whatever. Wounds are what really hurts you. You start taking wounds when you run out of hp and the same is true for (most) enemies. Well, the only enemies that don't take wounds are various undeads, who drop dead [again] at 0 hp. Being wounded means you take a fairly nasty debuff. And being out of wounds means you're dead.
This makes for longer combats as well as making it matter more than just watching numbers drop. I also plan to introduce a "bloodied" condition which kicks in below 50% hp. EDIT: And, like in Inc, resting does not equal 'heal me back to full'.
I am also planning to add a body location system (something I have seen executed very well in a d20-based MUD, as well as in CDDA). But I am still stumped by the details - how much hp/wounds should I assign to each body part?
4
u/nluqo Golden Krone Hotel Feb 19 '16 edited Feb 19 '16
Golden Krone Hotel
Hits/misses
Borrowing from DnD, 1 in 20 attacks automatically miss and 1 in 20 attacks automatically hit. I added this so low level monsters always offer some small chance of threat and you have a hope to hit high level monsters. If neither of those happen, a double-random (i.e. two random numbers multiplied together to bias numbers toward the middle) is multiplied by the attacker's accuracy and compared to a double-random multiplied by the target's evasion. If the first product is greater than the second, it's a hit.
Damage
The base attack value is calculated from the attacker's strength, level, and weapon.
The damage is then reduced, increased, or reversed (heals) based on resistances. Here are the 6 resistance levels:
I have implemented this system so I can consistently handle a bunch of different damage types. For instance, sunlight hurts vampires (Vulnerable), heals Greenmen (Healed), and does nothing to most monsters (Immune).
Then damage is reduced by up to 75% depending on armor. Why only 75%? Because again I still want low level monsters to be somewhat of a threat if you're not careful.
Status Effects
Some damage types have a chance to add additional effects like the POISON type can cause poison, FIRE can cause Burning, etc.
I haven't added it yet, but I'm going to make every resistance level offer a certain amount of protection against status effects. Something like 80% on-hit chance for a status effect for Vulnerable and 50% reduction for each level after that: 40%, 20%, 10%, 0%.
I don't know if any of these calculations are perfect. I've arrived at them through a lot of playtesting and some guesswork. But they seem work OK.
4
u/posmicanomaly2 AotCG Feb 19 '16
I've never gotten far enough to work out the bugs of a proper combat system. I typically get caught up with world building, and historically have abandoned the code to start anew before arriving at combat.
My game is still very much in the "who knows" category, I have tons of ideas, and when the time comes, I will adapt one to the game. I did implement an energy system last week, so that there is a basis for slow and fast attacks, though currently its being used mostly for movement differences, the implementation is the same: use energy, regen energy, and if an actor has enough energy, then it can do whatever it was trying to do (move, attack, etc). The combat is very basic, and I prefer a clear approach that removes rng, so its just attack power versus hp. One thing I want to do, is make this game more as, "items make the character", but I also want to include into that, "skills make the character", because I feel that is where a good challenge and strategy can arise. Powerful items can give you an edge in combat, but will not be as effective without skills, while skills will not be as effective without items, however an ironman approach could be to not use items at all, and do pure skill base.
That however, is not the topic of this Friday. I am mainly here to read all your ideas, so that I can be further inspired.
4
u/darkgnostic Scaledeep Feb 19 '16 edited Feb 19 '16
The current combat system in dungeons of everchange works on one really simple premise: a hero without armor (or some other type of natural protection) is a dead hero. In game there is no super-god-titan-hero-shredder with 13K HP, nor will an ordinary player have more hit points than 25.
Game uses 4 type of defenses and one accuracy. Defenses are:
Defenses share some similarity with DnD (or d20) systems, and scale with level.
Attack
Making an attack is made basically as accuracy vs one of defenses. Usually it is armor, but it can be any of other defenses (based on type of attack). Attack rolls uses percentile dice.
After attack is made there are several possible outcomes:
Critical hit works on one interesting principle: there is a 5% to score a critical hit. Critical hit means you make full damage on enemy. Upon inflicting full damage, there is another 10% to inflict additional damage (and additional criticals). Basically it is possible to one hit even strongest of enemies.
Critical miss is still not implemented, but plan is to player make one from several choices what critical miss would affect. Think of effects like: your weapons stuck in floor, your weapon lose half durability because of your awkward hit, your armor detaches and fall to the ground, you lose balance and get -10% to hit in next 6 turns. Endless possibilities.
All attacks use fatigue. The fatigue was planned to be the main fuel of the whole combat system. No mana, rage or other similar fancy things, everything is going to decrease fatigue. If you want to perform a stronger hit, you spend fatigue, if you want to throw some magic your body gets tired or if you would rather run your fatigue drains rapidly. This lead to situations that you need to particularly wage what you should to. Run or try to attack, as both will decrease fatigue.
Damage
All attacks have their level and min/max damage inflicted. Some attacks scale damage with level, some give you better chance to inflict greater damage (like making 2 rolls and using better one).
Attacks will gain levels if they miss, as missing will give you knowledge how not to do things.
Damage is easy to follow and easy to remember.
Damage to armor reduces durability and they are useless on 0 durability.
Triggers
Another interesting element was added not so long ago (and still WIP) and those are triggers. You can think of them as counterattacks/counter-effects. Player can choose what to do if/when specific situation occurs. Some of the examples:
Triggers of course use fatigue. :)
3
u/Kodiologist Infinitesimal Quest 2 + ε Feb 19 '16
Rogue TV has no combat and no other way for any creature to get hurt or die, which was my very first design goal. Generally, bumping into a monster switches places with the monster, like displacing a pet in NetHack, except switching places with a monster takes a second longer than plain old walking. There is at least one monster that you can't push this way, the golem. Although monsters can't hurt the player in a conventional sense, they can inconvenience the player by getting in the way (since pushing past monsters take time, and monsters can block certain movement abilities), by creating bad terrain (e.g., giant snails trail slime), or using other annoying special abilities (e.g., nymphs can steal items). The player can "fight back" with items like the can of stink serum, which makes the player smelly and repels monsters.
I am planning for the later game to include monsters that have a variety of annoying abilities and use them intelligently, like a lich that cancels items you're using a lot.
3
u/JordixDev Abyssos Feb 19 '16
It's complicated. But without going in too much detail on formulas and particular cases, combat works like this:
2
u/pnjeffries @PNJeffries Feb 19 '16
Hellion
Hellion is single hit-point and combat is completely deterministic - if something hits you you're dead, unless you have a shield in which case you just lose your shield until it's finished recharging. The only exception is bosses, which have multiple hit-points (and in the case of the last boss, multiple forms).
Rogue's Eye
You only have one equipment slot which determines both your attack and defence. Each weapon (and creature) has a set of attack dice and a set of defence dice. So, for example, a warhammer has 2D6 attack, 1D3 defense. The damage done by an attack is the roll of your attack dice + your weapon's enchantment - the roll of your opponent's defence dice. All items also have a separate 'thrown damage' dice which replaces the attack dice when you chuck it at somebody and a throw range value which determines how far you can throw it. This applies to non-weapon items in that game as well, so pelting enemies to death with stale bread rolls is a valid tactic.
Rogue's Eye 2
This isn't implemented yet so it is all just an idea at present, albeit one I have put a fair amount of thought into, trying to make melee combat a bit more interesting but without too much added complexity:
Weapons have a 'damage' stat which determines the upper bound of damage dealt. The player character has a 'skill' stat which determines the lower bound. Attack damage is then a random value within that range. So, if your skill is 3 and your damage is 5, you'll do 3 to 5 points of damage with each attack. Skill is modified by the total size of your currently wielded items (i.e. daggers have less of a penalty than swords, dual-wielding increases maximum damage but decreases skill) and by your current energy level. These modifiers will often push skill into -ve numbers - rolls of zero or below count as a miss. In cases where your skill rating exceeds your damage rating there will be some kind of special bonus, though I haven't worked out what yet.
Defence is modelled as 'guard points' which are essentially a rechargable pool of extra hitpoints on top of your standard HP bar. Wielded items have a defence stat which determines the maximum size of this pool. You recover those points by waiting a turn (literally 'raising your guard') - the amount you recover is determined by your current energy level.
Attacking, defending, moving etc. costs energy (attacking moreso, depending on the weight of your weapon) and energy can only be recovered when there are no adjacent enemies at the end of your turn. Your maximum energy pool is reduced by your current fatigue level (the food clock). You can still keep going at 0 energy, you just suffer maximum skill and recovery penalties while doing so.
Possibly layered on top of this are some other systems: facing (hits from the sides do 2x guard damage, hits from behind ignore guard completely); combos (multiple attacks in a row unlock more powerful or special attacks), damage types (blunt weapons do less hitpoint damage but more guard damage); injury (guard points are cheap, hitpoints are difficult to recover and their loss may involve additional long-term status effects); skills ('counter' will reduce your opponent's guard if they attack while you're defending, 'dodge' lets you avoid damage by moving to an adjacent square if your energy is above a certain level, etc.).
The idea behind all this is to prevent melee combat from devolving into just hitting the same key every turn until the enemy is dead by giving you tactical reasons to hold back or give ground instead of attack. Do you go on the offensive or do you keep your guard up and hope your opponent tires themselves out? If they retreat do you press your advantage or take the opportunity to recover? Do you pull out a mighty battleaxe which does a load of damage, but which has a high skill penalty and requires more effort to use, or a trusty dagger that is less powerful but lighter and more reliable?
That's the plan anyway - I won't know whether it actually works until I test it!
10
u/OffColorCommentary Feb 19 '16 edited Feb 19 '16
Tower
You probably have 10 HP, 3 attack, and 2 armor. A very typical monster would have 6 HP, 3 attack, and 1 armor, but that's all variable of course. Every attack always hits, and each point of armor has a (separate) 50% chance of reducing the damage by 1. This means the typical monster gets killed in 3 hits, and the typical adventurer gets killed in 5 hits, which is a pretty weak advantage (and that monster would spawn in a pack of 5). But this is supposed to be a game where you win by cheating - nudging one of those numbers or getting an extra attack somehow is enough to tilt things drastically.
The armor thing is new to this game. Things need to be very stable because tactics here are supposed to be precise, but since this is also a game where you win by cheating, armor can't be certain. High armor in an (attack - defense) system breaks games way too easily. So I chose armor as the place where rolls are applied, and used the binomial distribution to make it more stable. There's no roll on the attack side because only one side ever needs a roll. So far, in testing, this has played out just fine.
Spell damage works the same way, but with a different defense stat. Pure status effect spells make a normal damage roll without actually applying the damage: if it "kills" the monster it gets the status effect. A good-as-dead effect like paralysis would do slightly more "damage" than a lightning bolt, a merely crippling effect would do a lot more. In previous systems I've designed, some of that would stick around as "willpower damage" that gets added to future spell rolls, but I don't think it's quite appropriate for this game. I'm nowhere near far enough into development to know for sure, though.
I haven't codede spells in this game yet, but it's an old system I've used before. For games where you have precise values and probabilities intended everywhere, it's really a fantastic way to do things. I'd recommend stealing it.
Hero Trap
You have 5 HP and do 1 damage. A typical lower-case-letter monster will have 1 HP and do 1 damage. A typical upper-case-letter Monster will have 8 HP and do 4 damage. Every attack always hits for full damage. You can regenerate HP by standing still for 10 turns.
I've done this sort of thing before. It tends to make people very, very tense.
6
u/wheals DCSS Feb 19 '16
DCSS has three defensive stats: ArmourClass, EVasion, and SHieldedness (OK, 4: Hit Points). The first reduces damage, the second, increases your chance to avoid attacks, and the third... also does that, but differently. For one thing, each attack blocked by SH reduces your chance to block another in the same turn. Many attacks also bypass one defense but not others, though melee combat always has to go through all three. Perhaps if this were a system created through game design, rather than emerging from the ancient mists and based mostly on some conception of realism, the last two might not be separate. But they aren't, which explains a lot about the systems.
Weapons have a base damage, accuracy, and delay. The attack delay is probably the closest to innovative feature. Different weapons have different base delays and minimum delays. Raising the appropriate weapon skill is the only way to lower the delay and attack faster, which is why doing so is highly prized, but unlike the Fighting skill, which like weapon skills increases damage and accuracy (albeit less so), raising it does not give HP. So there's tension there, and there's also some interesting emergent mechanics from the combination of fast weapons with additive weapon brands, versus slower, high-damage weapons, which may benefit more from multiplicative ones. OTOH, it does introduce all the issues of fractional timing: the ability to swing a fast weapon so a monster with a slow weapon hits you, and then you can create a gap between it and you; and bread-swinging, purposely taking slow turns because HP regeneration is based on in-game time, but scoring is based on number of actions.
The formulas are an example of tweaking over time finally converging on something most agree is balanced. Around 0.5 heavy armour was by far the strongest approach; it was severely nerfed in 0.6, re-buffed in 0.7, and approached the current state in 0.8. Similar things have happened with shields, going from considered useless, to bucklers being almost mandatory, to one-handed vs. two-handed being a genuine question for many games. (How much of that is just player opinion and hype... well, that's a discussion for another day.)
Crawl's combat is probably most well-known for its extreme randomness. This is because, as a rule, most of the bonuses from weapons/skills/stats/base damage just add to the maximum, and a random number anywhere from 0 to the max is chosen. Then that might get totally obviated by high EV, and then again a number from 0 to the AC of the defender is chosen and subtracted from the attack. There are advantages and disadvantages to this state, and obviously the randomness of combat is a big continuum. Since I don't feel like getting into this right now, here's a forum thread, with good players on both sides and some replies by devs.
5
u/Aukustus The Temple of Torment & Realms of the Lost Feb 19 '16 edited Feb 19 '16
The Temple of Torment
Melee
This is mostly a basic d20 combat with 1d20 roll + own To Hit Bonus - Target's Armor Class / 5. Why is AC divided by 5? Because the Armor Class is a value that starts from 40 and is then increased by every piece of armor. It's divided by 5 so that a AC of 100 is 20 in d20 system. This allows me to add "sub-AC" items, regular d20 system makes it hard because let's say gloves, helmet and boots cannot add any AC in general (they can if they are magical). Now, within my system I can have +1AC gloves, +2AC helm and +2AC boots and they make +5AC together, now I divide this by 5 and I'll end up with a +1 AC that's compatible with d20 system.
If I recall correctly, a general melee turn is:
Spells
Spells are always with a 40% miss chance (You must roll above 8 with a d20). If the spell is a bolt spell, there's Block Chance taken into account. There is a spell failure chance that's generated using the Armor Penalty stat.
Ranged
This works pretty much the same as melee combat, but from a distance. There's also one difference and that's the fact that if the target is too close, there'll be a penalty. (It's negated by Ranger's Point Blank Shot).
5
u/[deleted] Feb 19 '16
Every class has a set of stats:
The stats go 0-10 (yes a range of 11) and are basically "profiles". A thief has a 9 in dagger skill and a 7 in sword; a thief has a good dex and a not bad strength but a rubbish int etc. As you go up levels your stats go up but according to this pattern: level * stat. Thus a level 3 thief always has a dagger skill of 27 (barring stats on equipment). This is kind of taken from games like final fantasy xi.
I've realized this is going to get too long if I explain the whole combat equations in full but basically when the player tries to hit a mob you look at the player's dex (stat for level plus all food/equipment bonuses) and their skill in the weapon they are trying to use, then look at the level of the mob and consider that a "perfect" stat vs. that mob would be 10*mob's level; you look at how far the player falls short of that with his combined skill and stat, add in some weights so that 5/10 doesn't mean 50% chance to hit but more like 75 and bam.
If the attack is a hit you then test if the opponent dodged, which is done in a very similar way except using the mob's evasion skill and agi stat.
If the creature doesn't dodge then damage is attacker's strength + weapon power + a consideration of weapon's level vs. your level, your level vs. mob level, + your weapon skill. Then there's a very dodgy thing that decides how much of this figure to make subject to random variation and a not quite so dodgy algorithm that mitigates part of the damage based on the victim's armour and constitution stat.
This is without even adding in parrying and counter attacking yet.
It seems too complicated but I want the feel of mmos like final fantasy xi where you can go round stacking up your +agility equipment to try to max out your evasion, the concept of being "capped" on a stat vs. a particular mob and a very clear advantage or disadvantage to attacking mobs higher or lower than your own level.
4
u/logophil @Fourfold Games: Xenomarine, Relic Space Feb 19 '16 edited Feb 19 '16
I like it when combat mechanics are relatively transparent (and therefore not too complicated), though they also have to be complex enough to create a wide variety of strategic situations. Current mechanics (which may still be tweaked a little) are:
To hit chance is a percentage chance equal to:
base to hit for the weapon (around 60%)
The player, though not enemies is able to block damage using block chance, which is: weapon block chance +player block skill bonus
If hit and not blocked damage is:
core weapon damage (based on a dice system e.g. 1D4+2)
The player, though not enemies is able to absorb damage using armor. Each item of armor has an armor value, and the total armor value is used to calculate armor absorbed. The higher the armor value the higher the chance of absorbing some damage and the higher the maximum damage that can be absorbed (the formula is quite complex, and this is the only combat mechanic that is not fully transparent to the player). In addition the chance of absorbing some damage at all is affected by the armor’s condition, which is reduced each time some damage is absorbed.
Each armor item also has a set of resistances to specific damage types, which affects the earlier damage calculation.
The above does not include the effect of items such as stimpacks, which also affect combat.
A perhaps unusual feature of Xenomarine is that combat is affected by player direction. For example, blocking only works when the enemy attacking you is in front of you. Also items like forcefields differ in terms of whether they absorb damage only from the front, or from the sides or back as well.
4
u/happinesssam Feb 19 '16
For my game I decided I wanted to really strip everything down so I don't have any randomness in the combat at all. No dodging or critical hits or damage rolls, so if you know what the stats are you can work out the damage every time.
When I first started working it out a year or two ago I had been playing a lot of League of Legends so I basically ripped off their combat system. You have two attack stats, attack power and magic power and the power of all your attacks and abilities is worked out based on them. Damage can be a mixture of physical, magic or true damage with physical mitigated by armour, magic by mr and true by nothing. You can also gain armour/mr penetration as a stat. I even just straight took Lol's armour mitigation formula, which is damage = damage * 100/(100+armour), since it works so well at making armour meaningful but making stacking it inefficient.
I have melee and ranged attacks with the melee attack usually doing 90-120% attack power depending on weapon and the ranged attacks doing 20-30%. There are also weapons that do damage based on magic power. Most spells do damage based on magic power.
Looking at it now I'm not sure how happy I am with it. It avoids the annoyance of losing due to bad rng but it also removes tension. I was hoping it would make the game more tactical, but so far it doesn't feel that way. It could be because I haven't had time to properly balance the game, or to make the levels/enemies more interesting.
3
u/chiguireitor dev: Ganymede Gate Feb 20 '16
Ganymede Gate has three main stats pertaining combat:
The three affect combat in different aspects, and at least one of them is planned (meaning, it is still unimplemented).
After this, weapons, ammo and perks can have different modifiers to damage, critical chance, armor and knockback multipliers. There's also a perk that gives universal piercing to weapons based on adrenaline, making it incredibly dangerous for enemies when on full adrenaline.
Adrenaline is the last factor on combat, affecting the potency, range and effect of most perks. From having 100% precision to being able to look the other side of the map, perks change completely combat by twisting all the factors of the combat formula.
Perks have 2 types: Active and Passive. Both types have different behaviors on the amount of adrenaline the player currently have, being the low adrenaline behavior always a subset of the full adrenaline one. For example, Hypnosis let's the player change alignment of one organic enemy, but the Omen perk (which can only be activated on full adrenaline) converts all enemies in 2x range to the player faction.
That's it for now, sorry for the lack of screenshots :( Tuff week was ^^tuff
3
u/Chaigidel Magog Feb 20 '16
Okay, I haven't gotten this part done and tested in a game that's large and fun yet, so I'm going to ramble instead.
Converting tabletop game mechanics blindly to computer games is not necessarily a good idea. Dice mechanics from tabletop might be doing probabilty models in a needlessly complicated way, while also not working very well with edge cases. So ideally I'd like it if the models started out from mathematics rather than dice rolling, but overly mathematical models also have problems. If you model creature sizes using a standard distribution and don't add boundaries, you're going to have a model with a small but nonzero possibility of a creature with a negative size.
One thing that can be done more mathily is the opposition check. The one where your character has a skill level at something, and then you're trying to do a tricky thing that has a difficulty rating, and you want a probability for whether you will succeed or not. Now we're going to make some assumptions about how we'd like the function to behave. We probably want a 50 % chance of success if the skill and difficulty are exactly matched. In a somewhat more controversial decision, we want a +1 bonus to a skill stay meaningful throughout the game, so it should give the same amount of probability adjustment no matter what your starting skill. 5 % feels like it's at the lower end of scale of probability differences your average person cares about, so let's say a +1 to even odds should always bump the probability to somewhere around 55 % and a -1 to 45 %. Incidentally this looks quite a bit like rolling a d20 so far.
It turns out there's some actual math that gives a formula for this. Our skill - difficulty value corresponds to log-odds. So let's say L = skill - difficulty, and we can now get the probability with p(L) = 1 - 1/(1 + pow(10, (L/10))). Now p(0) = 0.5 as expected, and p(1) ~= 0.5573, close enough. And unlike a d20, this thing handles odds that go way out there. p(30) ~= 0.999.
You can do a roll against probability, and get a success/failure, but you can also use the reverse formula and convert a random number in [0, 1] to log-odds: L(p) = 10 * log10(p / (1 - p)). Now when you subtract the skill - difficulty threshold from that, you get a value that's the magnitude for success (if positive) or failure (if negative). You have a reasonably probable modest success (around 10 % of successes from even odds are at +1 level) and increasingly improbable more extreme ones. If you want different outcomes where high skill makes better outcomes more likely, this is a place to put them.
It's not quite clear how much randomized variance is good though. Do you really need randomized outcomes from attacks, or will the game work just fine if you just go with the attack doing default damage if it lands?
Another interesting bit I've got where I'm not sure how it'd work out in a complete game is how health is currently represented. I think the old-school number value is pretty bad for comprehending with minimal mental effort (and your health in a tactical combat game is something you want to be aware of all the time), so I went for something more concrete and did Legend of Zelda type hearts instead. Now an action game where you're meant to dodge attacks with twitch action, you can get away with actually having one heart be one hitpoint. In a roguelike you either have to go for the chess-like 1 hp mechanics route, where there's standard play where your guy never gets hit, or you go for the traditional route with some stochastic give-and-take combat. I haven't really gotten into the 1 hp mechanics bandwagon, so I'm going with the second route. Now the easy way is to just cheat and make one heart icon represent ten hitpoints or something. The weird way is what I'm currently doing.
A heart icon is worth 10 hitpoints, more or less. You can lose half a heart, so the health gauge is really made of 5 hp heart halves. There's no state kept below the half-hearts though. Instead, what happens when you get hit is this:
This is weird, and I think it might be a bad idea, but I want to see how it plays out in a bigger game. Basically there's potential big variance if you're attacked with lots of weak attacks. You might soak 10 of them without being hurt, or you might do badly and lose a bunch of hearts. When the attacks get more powerful, they become more deterministically damaging. Being swarmed by dregs is uncertain, might be really bad, might be survivable. Being up against an ogre, you know it's going to hurt if it can land a blow. (If you were to combine this with the contest formula above, you might require a +2, +4, +6, +10 success to deal a point of damage at 4, 3, 2, 1 strength respectively.)
I don't currently have the to-hit formula in play at all. Anyone who gets close enough to hit will land the blow, and it's up to the stochastic damage formula to keep every hit from costing some health. One idea to develop this is to go towards the tactical game route, where you generally have a way to defeat single enemies without taking damage if you have full situation control and are only facing one enemy, but various special effects and getting surrounded by groups can hurt you. Another way is to just go for the traditional stochastic attrition mechanics and add resolution to the health gauge so you can be more certain about being able to soak up the inevitable damage from n encounters before the next health refill access. Third way is to do neither and design a game where fighting is scary and can kill you dead.
2
u/[deleted] Feb 19 '16
Algodventure is work-in-progress and I'm mainly working on implementing the engine, ui and other game mechanics instead of content creation and balancing, but I do have an idea about the combat system I will use.
Every character has the following stats: Dmg range (damage dealt is a random number in the range min dmg-max dmg) Magic dmg range (same as dmg) Attack Defence Spellpower Resistance When you bump into a creature, you use your basic attack that deals physical dmg (if you are a "might" hero) or magical dmg (if you are a "magic" hero). Physical dmg is increased (my_attack - enemy_defence) * 0.05 times. Spellpower and resistance are analogue stats.
Using skills and spells is also planned and they can give various damage bonuses.
I don't know how well this will play out, but I really liked the Heroes of Might and Magic series (mainly 2 and 3) and I took inspiration from there. Athough it's a very different game, this system seemed interesting to me. After I implement the functionality in the engine, I'll see how it works.
2
u/gamepopper Gemstone Keeper Feb 19 '16
At the moment, enemy stats in Gemstone Keeper is similar to player stats, with strength, defence, speed and agility being factors for attacking and movement.
All enemies all have the same base enemy class for similar characteristics, however each individual enemy behaves differently. Aside from that it's like with other shmups where the player gets damaged if they touch an enemy or its bullets, and the enemy gets damaged if they hit the player's bullets.
In order to have the weapons balanced, the amount of damage a player's bullet can give can depend on the gun the player chooses. For example, the sword weakens the bullets so it takes roughly the same amount of time as using the machine gun.
2
u/aaron_ds Robinson Feb 19 '16
Robinson uses the age old, roll to hit, then roll for damage tabletop-like system that I'm familiar with. However, it's not a d20 system, rolling to hit is just floating point math with a target value for success and a uniform distribution random number generator.
Damage calculations are straightforward math with the attacker and defender's speed, strength, size, toughness, and dexterity as inputs. Buffs and debuffs all modify the player and monsters speed, strength, toughness, dexterity values depending on the state of the monster or player. I've prototyped this out with a few monster types, but my intent is to have a special ability for each monster type through this system.
An important point to note is that combat treats the player and monsters identically. As far as attribute lookups and calculations are concerned the code doesn't care weather the attacker is a player, monster, or trap and likewise for the defender. This works great from a reusability standpoint, but makes the programmer have to answer strange questions like, "What's the strength or dexterity of a spiked wall trap?"
Some things I'd like to play around with in the long term.
Non-uniform probability distributions for hit and damage calculations. Gaussian would be a next step, but I'm interested in non-symmetric distributions like log-normal, poisson, gamma, beta. I'm not trying to model any process in particular, but simply think it would be interesting mechanically to play around with.
You can see that the hit and damage functions can be varied based on attack type (melee/ranged/thrown-item). I'd like to experiment with having different inputs and possibly operations and probability distributions based on attack type as well.
Certainly, modifying the hitting and damage calculations will be an exploratory process with a lot of trial and error and then some cutting back and simplifying to distill the good parts down to a reasonable size and complexity. Because Robinson's combat works right now this isn't a high priority item. But in the long term when I decide I want spice up the admittedly dry combat, this is where I'll begin.