Damage calculation / API - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html) +--- Forum: Development (https://forum.cuberite.org/forum-13.html) +--- Thread: Damage calculation / API (/thread-625.html) Pages:
1
2
|
Damage calculation / API - xoft - 11-16-2012 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) RE: Damage calculation / API - FakeTruth - 11-16-2012 How about also adding the knockback and effects to the TDI, that way plugins can change the knockback amount and we dont need a magic -1 value for damage. I would like players to be able to get healed instead of damaged through TakeDamage by providing negative damage values. RE: Damage calculation / API - xoft - 11-16-2012 A magical sword of healing? Or an enchantment of life-stealing? Sounds reasonable. (for some reason, I was reminded of this: ) RE: Damage calculation / API - FakeTruth - 11-16-2012 Yes ^^ RE: Damage calculation / API - xoft - 11-17-2012 Editted to include the TDI changes RE: Damage calculation / API - xoft - 12-18-2012 I think I'm in the right mood to do this RE: Damage calculation / API - Luksor - 12-19-2012 (12-18-2012, 09:54 PM)xoft Wrote: I think I'm in the right mood to do this Yay! PvP servers incoming! RE: Damage calculation / API - keyboard - 12-19-2012 (12-18-2012, 09:54 PM)xoft Wrote: I think I'm in the right mood to do this Let me know if you need any help with this. RE: Damage calculation / API - xoft - 12-21-2012 Rev 1087 has the first version of the refactoring. I think it should work, but I'm unable to test neither armor nor PvP. I need people to test this. Best would be if someone added an OnTakeDamage hook to the Debuggers plugin that would log the amount of damages that the server sends in TakeDamageInfo, so that people can verify correct values are being given. Also, armor is currently not depleted by absorbing hits. And of course, we don't have enchantments yet (but the code is ready for them Debuggers plugin logs the dealt damage, as of rev 1089. So now I need testers. Here's the referential mc-wiki page: http://www.minecraftwiki.net/wiki/Damage#Dealing_damage RE: Damage calculation / API - NiLSPACE - 12-21-2012 it works fine for me i tested it and it worked i also get the good amount of damage. (3.5 damage with diamond sword etc). EDIT: btw i if someone is wearing armor, other players don't see that. |