#include "utility.h"
#include "itemdef.h" // For itemgroup_get()
#include "log.h"
+#include "inventory.h"
void ToolCapabilities::serialize(std::ostream &os) const
{
//infostream<<"getDigParams"<<std::endl;
/* Check group dig_immediate */
switch(itemgroup_get(groups, "dig_immediate")){
- case 1:
- //infostream<<"dig_immediate=1"<<std::endl;
- return DigParams(true, 0.0, 0);
case 2:
//infostream<<"dig_immediate=2"<<std::endl;
- return DigParams(true, 1.0, 0);
+ return DigParams(true, 0.5, 0);
+ case 3:
+ //infostream<<"dig_immediate=3"<<std::endl;
+ return DigParams(true, 0.0, 0);
default:
break;
}
return getHitParams(groups, tp, 1000000);
}
+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;
+}
+
+