Balancing classes

This is a brief walkthrough of the various parts of the fightcode in the Dystopia 2 codebase, and after reading this, you should be ready to start balancing your classes. The fightcode for Dystopia 1 should be similar enough that you can use this text as a guideline for balancing classes for Dystopia 1 codebases as well.

Dodge and Parry

All players can dodge an attack if they are lucky, and any playing wielding a weapon (or have somehow modified their hands) can parry an attack. The chance of a succesful dodge or parry depends on the players skill with unarmed combat (dodge) or the weapon being used (parry). The chance is then modified by the players class powers and class modifiers. The chance is also modified by the opponents skills and powers. Please notice that certain stances allows a player an extra chance of dodging or parrying. For instance, the Swallow stance allows a player 2 dodge chances for each attach, unless that player is using a stance that negates the enhanced dodging (like Tiger).

check_dodge()
John attacks Jane, and for each attack Jane has a chance to dodge. If the dodge fails, she then has a chance to parry, this is why most attacks gets dodged instead of parried (it never checks parry if dodge succeded).

Jane has a base chance of dodging, which is calculated from Janes skill in unarmed combat. The higher her skill in unarmed combat, the higher her chance of dodging. The chance for John to hit Jane is based on Johns skill in the type of weapon that he is using. Certain stances increase Janes skill at dodging, and certain stances allows John to negate any bonus that Jane gets from stances. If Jane and John where mortal, it would stop here, and the game would roll a dice, and determine if Jane succeded in dodging Johns attack. If John and Jane are avatars, they each have access to their full compliment of class powers, some of which can modify the chance of dodging and hitting. An example would be the Warlocks invocation sphere. If John was a Warlock, then for each point he has in the invocation sphere, he would get 8 points towards hitting Jane. Here is a detailed example - Jane is a giant with 10 points in the Defence Battletrain. John is a Warlock with mastery in Invocation, which allows him 6 levels in the Invocation sphere. Jane has not trained her unarmed very high, and only has 150 points, whereas John has trained his slashing skill all the way to 250 points. John is using a longsword (slashing). Jane is using the Swallow stance, attempting to gain extra dodge, but John is using the Tiger stance, negating the bonus Jane would have gained.

John: Slashing attack (25 points), Invocation 6 (48 points)
Jane: Unarmed skill (75 points), Defence Battletrain (35 points)

Result: (75 + 35) - (25 + 48) = 37

The above calculation means that Jane has a 37% chance of dodging Johns attack. If Jane had trained her unarmed skill higher, she would have increased her dodging potential. Had Janes chance gone above 80%, the game would have capped the chance to 80%, and had the chance gone below 20%, the game would have given Jane 20% chance of dodging.

By increasing and decreasing the modifiers a specific class gains from his or her class powers, it is possible to adjust how often a certain class can hit another in combat. It is basicly a good idea to balance classes at at least two different levels.

check_parry()
If a player fails to dodge an attack, he or she has a chance to parry the attack instead, as long as the player is wielding a weapon. The Fae class can also parry if it has the Blastbeam power turned on.

check_parry() follows the same rules as check_dodge(), with one difference. Janes basic chance is not calculated from her unarmed skill, but from Janes skill with the weapon that John is attacking with.

Had Jane failed to dodge in the above example, she would have had a chance to parry, and this time she would have to use her skills in slashing weapons instead of her skill in unarmed combat.

update_damcap()
If a player does more damage than his or her damcap, the damage is lowered to roughly his or her damcap (the amount is randomized a bit). The function update_damcap() is used to calculate a players damcap, and can be used to tune how much damage a certain class can do - the whole damcap business is a dirty hack to fix a broken damage system. It is encouraged to remove damcap entirely and fix combat afterwards - but that is somewhat outside the scope of this document. Damcap is modified by the skills, stance and powers of both the attacker and the defender.

cap_dam() and up_dam()
These two functions contains all damage modifying class powers. When an attack is dealt, the base damage is calculated from either the power used, or from the weapons damage scale (you will notice that the weapons in Dystopia 2 actually tells how much damage is dealt by the weapon). If we use the example above, where John attacks Jane with his longsword - let us assume that the weapon rolls 500 in damage, and use this as the base for our calculations. First the function up_dam() is called, and then cap_dam(). John is still a warlock, with 6 points in invocation, and Jane is a giant, and has 10 points in battletrained defence. Both players are of Veteran rank (the game scales combat down for lower ranked players to make the fights last longer). Jane is affected by the sanctuary spell.

previous modifiers
------------------
John: Damroll of 400 (adds 400 to the damage)
      Slashing skill of 250 (multiplies with 5)
Jane: No powers

Damage = (500+400) * 5 = 4500

up_dam()
--------
John: Evocation 6 (multiplier 13/7)
Jane: No powers

Damage = 4500 * 13/7 = 8357

cap_dam()
---------
John: No powers
Jane: Leatherskiin (multiplier 0.70)
      Standfirm (multiplier 0.65)
      Sanctuary (multiplier 0.50)
Game: The game randomizes the damage a bit and modifies it by
      the rank of the players (Veteran). Total result is
      roughly a multiplier of 0.49

Damage = 8357 * 0.70 * 0.65 * 0.50 * 0.49 = 931

The major factors are Johns damroll, skill with the weapon that he is using, Johns class powers and Janes class powers and sanctuary spell. The game modifiers are basicly always the same, and is used to tweak combat a bit. You could change this factors, but they seem to work as they are. Damroll can be tweaked simply by increasing or decreasing the damroll bonus that a class gains from his or her class powers, the toughness powers of a class is also helpful to tweak damage.

multi_hit()
The function multi_hit() is called every second for each player, but certain parts of the code is only accessed every third second, using the turn argument. This ensures rapid combat, without causing to much damage to fast. The function takes care of all the players normal weapon attacks and special automatic class attacks. I good guess would be that multi_hit() takes care of half the damage inflicted in a player vs player fight. This function can be tuned by adding or removing attacks.

number_attacks()
Quite simply calculate how many attacks a player gets each time multi_hit() is called, these attacks are the normal kind, slice, slash, pound, etc. and they can all be dodged or parried. A normal amount would be 3-6 for the class powers (speed items, stances, etc also modifies this number, but it can be used to balance).

This is a website bent on world domination - all rights reserved