Damage calculation / API
#1
For a real survival gameplay, we need to properly calculate damage caused by attacks and apply that damage through armor and to the players. Most damage-related calculations seem to be already documented on the minecraft wiki, so the calculation itself should be rather straight.

How I'd like to have the things work:
For each hit:
- server calculates raw damage (attacker mob type + weapons)
- server calculates received damage (dampened by receiver's armor)
- server packs those two values into TakeDamageInfo (extended) and lets plugins modify it, using HOOK_TAKE_DAMAGE
- server applies the "received damage" to the receiver
- special values for "received damage", recognized by the server: 0 = don't process at all

This way, without any plugins, the server will have realistic damage. If plugins want to do something about the damage, they can. They can modify the damage amount, or disable the damage altogether.

To have an effective API, the server also needs to export a few properties for cPawn:
- GetEquippedWeapon()
- GetEquippedHelmet()
- GetEquippedChestPlate()
- GetEquippedLeggings()
- GetEquippedBoots()
This will enable us to later add mobs with equipped items and plugins will have a unified way of checking for those. By default, these will return an empty item for everything else than a player, for whom they will return the correct inventory item.
EDIT: Edited the function names to be more descriptive.

EDIT: As suggested by FakeTruth, adding more info into TakeDamageInfo.
The TakeDamageInfo will describe not only the damage, but also the kind of processing to perform various other effects of a hit - knockback, poison, weakness etc.
TakeDamageInfo proposed contents:
- DamageType - enum - indicates whether damage is taken as a result of being hit by an entity, or from the enviroment / fire / drowning etc.
- Attacker - cPawn - instead of Instigator; may be NULL for environmental damage
- RawDamage - int - The amount of damage dealt, before subtracting armor
- FinalDamage - int - The amount of damage to be dealt (after armor); plugins may modify to change the outcome.
- Knockback - Vector3d - The amount of knockback that the receiver should get from this hit
- Effect - List of effects - Other effects (to be specified yet)
Reply
Thanks given by: Taugeshtu


Messages In This Thread
Damage calculation / API - by xoft - 11-16-2012, 08:01 PM
RE: Damage calculation / API - by FakeTruth - 11-16-2012, 08:38 PM
RE: Damage calculation / API - by xoft - 11-16-2012, 08:45 PM
RE: Damage calculation / API - by FakeTruth - 11-16-2012, 10:53 PM
RE: Damage calculation / API - by xoft - 11-17-2012, 12:32 AM
RE: Damage calculation / API - by xoft - 12-18-2012, 09:54 PM
RE: Damage calculation / API - by Luksor - 12-19-2012, 04:09 AM
RE: Damage calculation / API - by keyboard - 12-19-2012, 02:39 PM
RE: Damage calculation / API - by xoft - 12-21-2012, 09:08 PM
RE: Damage calculation / API - by NiLSPACE - 12-21-2012, 10:36 PM
RE: Damage calculation / API - by xoft - 12-22-2012, 06:00 PM
RE: Damage calculation / API - by NiLSPACE - 12-29-2012, 10:14 PM



Users browsing this thread: 6 Guest(s)