Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 1.96 KB

docs_onhit_and_damage.md

File metadata and controls

48 lines (39 loc) · 1.96 KB

Damage calculation and hit handling

When a local hit event occurs, client sends an OnHit packet to server.

It contains the following fields:

uint32_t aggressor = 0; // originating actor
bool isBashAttack = false;
bool isHitBlocked = false;
bool isPowerAttack = false;
bool isSneakAttack = false;
uint32_t projectile = 0;
uint32_t source = 0; // formId of weapon (or of bare hands)
uint32_t target = 0; // target actor

Damage formula

There is an interface IDamageFormula, which allows calculating damage based on aggressor and target actors, as well as hit data.

By default, vanilla Skyrim damage formula is used (althrough it's not fully implemented yet, see below): TES5DamageFormula. But abstract formula will allow custom server implementations to easily redefine formula by something else.

Implemented formula components

At the moment, TES5DamageFormula is not complete enough and only takes basic values into account. If you notice something missing, consider creating an issue if it's not present yet. If you have C++ knowledge, we would be glad to see your contributions!

Incoming damage:

incomingDamage = isUnarmed ? raceUnarmedDamage : baseWeaponDamage;

Armor damage reduction:

armorRating = armorRating1 + armorRating2 + armorRating3 + ... + armorRatingN + magicArmorRating;
//fMaxArmorRating is [GMST:00037DEB], fArmorScalingFactor is [GMST:00021A72];
//fMaxArmorRating = 80 by default, fArmorScalingFactor = 0.12 by default
//magicArmorRating is sum of magnitudes of armors' enchantments with magic effect of damage resist
receivedDamage = incomingDamage * 0.01 * (100 - std::min(armorRating * fArmorScalingFactor, fMaxArmorRating));