Night Soil
a simple combat system


Author: Dan
Version: 1.5 (2001-Apr-05)
Version: 1.4 (2000-Jun-06)

This is a stripped down role-playing-game combat system called "Night Soil", demonstrated in a little roguelike game called "The Quest for the Golden Stool".


First recall the principles of a good combat system (translated from the original cuneiform engravings found on the "Slab of Mud"):

  1. Simplicity. If you want the real thing, put on your sandals, take up your sword, and seek your fortune. Otherwise, try to keep the system simple or it will grow into tangled spaghetti, leaving the players unsure of where they stand. Complexity should arise from circumstances in the game, not from the rules of the game.
  2. Diversity. Trade-offs are what make stats interesting. If there is only one way to become powerful, players will have little use for each other. But when one kind of power tends to create a corresponding weakness, players must strategize and form alliances.
  3. Risk. Advancement should involve calculated risk. The slightest hole in the system, providing risk-free rewards, destroys the value of advancement. This often takes the form of some mindless repetitive process that generates a guaranteed profit. Think of it as the difference between playing the stock market and working on an assembly line.
  4. Infinity. There should be no end to potential growth and no end to the challenge of achieving it. This goal is impossible, but that is what makes the designer's task interesting!

The night soil combat system has four basic abilities: damaging, hitting, deflecting or dodging, and reading scrolls. These are represented by the four stats strength, aim, armor, and iq. There are also two mechanical stats, offense and defense, which are modified by the player's equipment. The first multiplies the amount of damage done and the second divides the amount of damage received. Finally, there is the life stat which indicates how much damage can be absorbed before becoming somebody's lunch.

mob stats: life (vital energy) strength (damaging power) iq (mental power) aim (hitting skill) armor (deflecting or dodging skill) offense (damage multiplier) defense (damage divisor) max_life max_strength max_iq max_aim max_armor

The four abilities and the life stat range from 0 to some maximum value. In the case of life, strength, and iq the maximum value can only be obtained in a state of perfect health or full energy. Any exertion of these "energy" stats will cause them to diminish from their "fully charged" state. Eating food (in the form of corpses and other items) can recharge them, depending on the nutritional properties of the food. The aim and armor skills are "fully equipped" by using armor and weaponry. No matter how good the equipment is, a mob's aim and armor are limited by the respective maximums, which indicate the mob's current limitations in using such devices.

Perhaps the most elegant element of the system is the mechanism for advancement. When the energy stats are recharged there is a chance that the mob's maximum value for the stat will increase. The greater the recharge, the greater the chance. What this means is that in order to advance, a player must exert a particular ability and must be successful enough in the encounter to obtain food to restore the lost energy.

The aim and armor skills may increase during combat. The increase to the maximum skill level depends on successfully hitting (or dodging) when the odds were against it.

The ultimate gamble in night soil is to pick adversaries that are challenging enough to exercise one's abilities but not so challenging as to be unbeatable. This simple rule adds a pleasing touch of reality. The amount and type of experience from an encounter depends on the circumstances. If one fights from a distance and never takes a blow, it is possible to develop great aim but learn little about the art of dodging. And one can lift useless weights all day to build strength, but without doing something to restore the lost energy, nothing is gained.

The night soil combat system depends on a few simple formulas rather than enormous numerical tables. When a mob takes a swing at another mob, the chance of hitting depends on a mathematical formula called a sigmoid. It is called a sigmoid because it is shaped like an 's' if you were to pull on the two ends of the 's' a bit to stretch it out. The formula used in night soil is p(X) = 1/(1 + 100**-X). The symbol '**' in DM is the power operator, which raises the left hand value to the power of the right hand value. For example, 100**0 = 1, 100**1 = 100, and 100**2 = 10000.

The formula for X is (A-D)/(A+D) where A is the attacker's aim and D is the defender's armor. Rearranging terms, A/D = (1+X)/(1-X). So if the attacker's aim is equal to the defender's armor, the chance of hitting is p(0) = 0.5 or 50%. If the attacker's aim is half of the defender's armor, the chance is p(-1/3) = 0.18. If the attacker's aim is twice the defender's armor, p(1/3) = 0.82. The following table summarizes the shape of the sigmoid. Beside it is a crude outline of the 's' shape with X on the horizontal and p on the vertical axis.

X A/D p ------------------- 1 Inf 0.99 # # 0.6 4 0.94 # 0.33 2 0.82 # 0 1 0.5 # -0.33 0.5 0.18 # -0.6 0.25 0.06 # -1 0 0.01 # #

For values of X greater than 0, the probability approaches 1, indicating an aim far superior to the defender's ability to avoid the blow. For values of X less than 0, the probability approaches 0, indicating a very small chance of penetrating the defender's defenses.

To obtain the amount of energy put into a hit, p is multiplied by 7% of the attacker's strength, which is then reduced by that same amount. The damage inflicted is then computed by multiplying the hit energy by the attacker's offense multiplier and divided by the defender's defense divisor.

The abilities aim and armor are directly improved by combat. If a hit succeeds, the attacker's maximum aim is increased by the amount (1-p)/10. If the hit is avoided, the defender's maximum armor is increased by the amount p/10. This means that one's aim skill is improved more by successfully hitting when the odds were against it (i.e. p is small). Similarly, one's armor skill improves the most when a blow is successfully deflected and the odds were in favor of a hit (i.e. p is large).

Combat equipment affects aim, armor, offense, and defense. In the case of aim and armor, the equipment can only increase the stat to the mob's maximum skill level. The damage modifiers offense and defense, on the other hand, are simply multiplied by the item and have no such limitation. Equipment therefore has two properties. One is limited by the skill of the user and the other depends only on the quality of the item.

The life, strength, and iq stats must be recharged by eating food. Food items provide varying quantities of nourishment in these three categories but may never recharge above the mob's maximum level. Each time an increase is made in one of these values (life, strength, or iq) there is a chance of the maximum advancing (by 1 point). The probability is equal to the increase divided by the maximum value. So if a mob eats something that increases his life by half it's maximum value, there is a 50% chance of advancement of his maximum level of life.

Magic scrolls are the final component of the combat system. Each spell has an iq cost (scroll.iq) which decreases the caster's iq. The chance of successfully casting a spell depends on a sigmoid with X = (usr.iq - scroll.iq)/(usr.iq + scroll.iq). Unlike weaponry, magic tends to be fairly predictable (when it works). The amount of damage done is often simply equal to the iq cost.

For those wishing to experiment, there are a number of adjustable parameters in night soil. In fact, there are endless possible modifications and additions to the basic system and I will be very curious to see what improvements you may invent.

The mathematical formulas in the basic system are as follows:

x = (aim - defender.armor)/(aim + defender.armor) p(X) = 1/(1 + A ** (B-x)) //probability of hitting e = C * strength * p //hit energy strength -= e //strength discharge d = e * offense/defender.defense //hit damage max_aim += D * (1-p) //reward for hitting max_armor += E * p //reward for dodging g(r) = F * r/max //probability for recharge r of increasing max A = 100 (steepness of the sigmoid) B = 0 (shifts the sigmoid to the left or right) C = 0.07 (rate of strength discharge in a successful hit) D = 0.1 (learning rate of the aim skill) E = 0.1 (learning rate of the armor skill) F = 1 (growth rate of life, strength, and iq)

In brief, the night soil combat system may be summarized as having three energy stats: life, strength, and iq. These are recharged by consuming food and discharged during combat by absorbing blows, striking blows, and casting spells. Advancement of the maximum energy levels may occur during a recharge.

There are also two equipment skills: aim and armor. The maximum value is the mob's level of skill and the actual value is determined by the equipment in use. A skill is fully equipped when the maximum level is reached. Beyond that, additional equipment has no effect. Advancement of the maximum skill levels occurs during combat when a skill is successfully employed. The advance is larger when the chance of success was smaller.

Finally there are two mechanical attributes, the offense and defense levels. The first multiplies the amount of damage a mob does and the second divides the amount of damage a mob receives. These stats are entirely determined by the equipment being used, allowing objects to have a certain amount of functionality even in unskilled hands.

That's about all there is to the basic combat system. There are, of course, other elements that have not been mentioned like mob "moods" which control automated combat behavior, and "stepping modes" which control automated motion of non-players, as well as movement rate and swing speed. For the details on all these extra bits, make an excursion into the night soil code. But don't stray too long on your first journey or you may become entangled by the creatures that live there.

This is just a basic bare-bones system. I welcome any modifications you may devise. There's plenty of room left on the Slab of Mud. Carve your own initials!