Up to Main Index Up to Journal for June, 2022 JOURNAL FOR SATURDAY 18TH JUNE, 2022 ______________________________________________________________________________ SUBJECT: Some details on combat DATE: Sat 18 Jun 19:57:32 BST 2022 It’s been a while since my previous update. I’ve been hard at work on the combat system, but just haven’t found the time to write about it — even this update has taken all week to put together. Weather is improving, an overgrown garden, Go 1.19 Beta 1 released, new Hertzbleed[1] vulnerability, bill paying work — you know how it goes :( People have been asking about the combat system — how it will work and the progress being made. I thought some details would make an interesting update. I have a combat system now working, based on a “score” calculated from attack and defense values. Attack represents how well an actor can inflict damage on a target. Defense represents how well a target can fend off and/or survive an attack. Very basic stuff. Attack and defense are comprised of a number of components including current health, armour worn, items worn or wielded — in the future skills and other elements will also be included. The armour and damage values can be assigned to any items. If armour or damage is directly assigned to a player or mobile it represents their natural armour and damage. For now I’m using the following for attack and damage: ATTACK = natural damage + (natural random damage/2) + item damage + (item random damage/2) + current health DEFENSE = natural armour + item armour + current health Note: Items must be worn or wielded to be accounted for, Half random damage is rounded to zero Using the attack and defense values, a percentage chance to hit is calculated. First, a score for the actor and target are calculated. Next, the percentage chance to hit is then calculated for the actor (A) and target (T): A.score = (A.attack × A.attack) / (A.attack + T.defense) T.score = (T.attack × T.attack) / (T.attack + A.defense) A.chance = A.score / (A.score + T.score) T.chance = T.score / (T.score + A.score) It should be noted that A.chance + T.chance = 1 (i.e. 100%) and that for a round of combat either the attacker or target will always hit. There are no long drawn out “You miss… They miss… You miss…”, either you hit or they hit. The minimum chance to hit is limited to 0.000001% and the maximum chance to hit is limited to 99.9999% — this allows for a 1,000,000:1 chance to hit, even against the most powerful opponents ;) As an example lets take a standard human using “natural” kicks and punches: Human: armour 10, damage 1+[0-2], health 30 The ‘human’ is the standard model, scaled up/down for other mobiles. For weapons the standard is a dagger/shortsword doing 1+[0-3] points of damage, scaled as needed. The opponent will be a small, winged imp using bites and claws. Compared to the human the imp is smaller reducing its armour value, but it can fly around and so not lowering it too much. The imp’s attacks are scaled down to 1+[0-1], but scaled up again for multiple teeth and claw attacks to 2+[0-3] damage: Imp: armour 5, damage 2+[0-3], health 10 Calculating the values we get: Human, attack: (1+(2/2) damage)+(30 health) = 32 defense: (10 armour)+(30 current health) = 40 score: (32 × 32)/(32 + 15) = 21.787234 hit chance: 21.787234/(21.787234+3.188679) = 0.872330 ≈ 87.2% Imp, attack: (2+(3/2) damage)+(10 current health) = 13 defense: (5 armour)+(10 current health) = 15 score: (13 × 13)/(13 + 40) = 3.188679 hit chance: 3.188679/(3.188679+21.787234) = 0.127670 ≈ 12.8% An interesting point of note is that it gets harder to attack and defend the more health you loose. For the first example, both parties at full health, the percentages are 87.2% and 12.8%, this changes to 91.1% and 8.9% when the imp is at half health. If instead the human is knocked down to half health the chances are 59.1% and 40.9% instead. Then again you can just quaff that health potion — unless both hands are already full… sword and shield maybe? ;) At the moment armour is defined as a single value, fixed and random damage are also single values: Armour: 10 DamageFixed: 2 DamageRandom: 2 The plan is to expand this in the future to handle different types of damage: Armour: 10 FIRE→-5 PIERCING→5 DamageFixed: 2 POISON→2 DamageRandom: 2 FIRE→2 The final calculations may change as I’m still trying to balance them — health can swing the chance to hit wildly, armour and damage have less of an effect. All of the calculations are going into core/combat.go to make it easy to change or replace them. I’m also busy updating all of the mobiles, weapons and armour to have suitable attributes and values. Hopefully I’ll get some changes out soonish for others to play with. However, I still need to build a release for the terminal changes… *sigh* -- Diddymus [1] Hertzbleed vulnerability: https://www.hertzbleed.com/ Up to Main Index Up to Journal for June, 2022