summaryrefslogtreecommitdiff
path: root/src/content_cao.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/content_cao.cpp
parente9cdb938fe44282e09fb88628a6e86e5e7279c69 (diff)
downloadminetest-501b8fe743c56ad07c5fd8bdd4bfffa13fcb3c4d.tar.gz
minetest-501b8fe743c56ad07c5fd8bdd4bfffa13fcb3c4d.tar.bz2
minetest-501b8fe743c56ad07c5fd8bdd4bfffa13fcb3c4d.zip
Damage groups WIP
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r--src/content_cao.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index d6289a1b9..836f719a3 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -31,7 +31,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_object.h"
#include "mesh.h"
#include "utility.h" // For IntervalLimiter
+#include "itemdef.h"
+#include "tool.h"
class Settings;
+struct ToolCapabilities;
core::map<u16, ClientActiveObject::Factory> ClientActiveObject::m_types;
@@ -585,13 +588,41 @@ public:
}
else if(cmd == LUAENTITY_CMD_PUNCHED)
{
- s16 damage = readS16(is);
+ /*s16 damage =*/ readS16(is);
s16 result_hp = readS16(is);
m_hp = result_hp;
// TODO: Execute defined fast response
}
}
+
+ bool directReportPunch(v3f dir, const ItemStack *punchitem=NULL,
+ float time_from_last_punch=1000000)
+ {
+ // TODO: Transfer this from the server
+ ItemGroupList m_armor_groups;
+
+ assert(punchitem);
+ const ToolCapabilities *toolcap =
+ &punchitem->getToolCapabilities(m_gamedef->idef());
+ PunchDamageResult result = getPunchDamage(
+ m_armor_groups,
+ toolcap,
+ punchitem,
+ time_from_last_punch);
+
+ if(result.did_punch)
+ {
+ // TODO: Decrease hp by
+ if(result.damage < m_hp)
+ m_hp -= result.damage;
+ else
+ m_hp = 0;
+ // TODO: Execute defined fast response
+ }
+
+ return false;
+ }
};
// Prototype