+PunchDamageResult getPunchDamage(
+ const ItemGroupList &armor_groups,
+ const ToolCapabilities *toolcap,
+ const ItemStack *punchitem,
+ float time_from_last_punch
+){
+ bool do_hit = true;
+ {
+ if(do_hit && punchitem){
+ if(itemgroup_get(armor_groups, "punch_operable") &&
+ (toolcap == NULL || punchitem->name == ""))
+ do_hit = false;
+ }
+ if(do_hit){
+ if(itemgroup_get(armor_groups, "immortal"))
+ do_hit = false;
+ }
+ }
+
+ PunchDamageResult result;
+ if(do_hit)
+ {
+ HitParams hitparams = getHitParams(armor_groups, toolcap,
+ time_from_last_punch);
+ result.did_punch = true;
+ result.wear = hitparams.wear;
+ result.damage = hitparams.hp;
+ }
+
+ return result;
+}
+
+