summaryrefslogtreecommitdiff
path: root/src/tool.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-05 01:30:55 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-10 11:28:13 +0200
commit501b8fe743c56ad07c5fd8bdd4bfffa13fcb3c4d (patch)
tree77400d94bc48a74cb34d6934e4f3d09ef1a49881 /src/tool.cpp
parente9cdb938fe44282e09fb88628a6e86e5e7279c69 (diff)
downloadminetest-501b8fe743c56ad07c5fd8bdd4bfffa13fcb3c4d.tar.gz
minetest-501b8fe743c56ad07c5fd8bdd4bfffa13fcb3c4d.tar.bz2
minetest-501b8fe743c56ad07c5fd8bdd4bfffa13fcb3c4d.zip
Damage groups WIP
Diffstat (limited to 'src/tool.cpp')
-rw-r--r--src/tool.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tool.cpp b/src/tool.cpp
index da7ee73dc..d6f994307 100644
--- a/src/tool.cpp
+++ b/src/tool.cpp
@@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "utility.h"
#include "itemdef.h" // For itemgroup_get()
#include "log.h"
+#include "inventory.h"
void ToolCapabilities::serialize(std::ostream &os) const
{
@@ -153,3 +154,36 @@ HitParams getHitParams(const ItemGroupList &groups,
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;
+}
+
+