diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-03-09 20:46:56 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-03-10 11:28:13 +0200 |
commit | 8db89b8136686a5721080d18e8a14f03404aa095 (patch) | |
tree | a6a87bc6a50b9ab2030930faae35ed22814c7669 /src/content_cao.cpp | |
parent | 8c01ad8a9da86fc76bc9a180ccab10ede726625a (diff) | |
download | minetest-8db89b8136686a5721080d18e8a14f03404aa095.tar.gz minetest-8db89b8136686a5721080d18e8a14f03404aa095.tar.bz2 minetest-8db89b8136686a5721080d18e8a14f03404aa095.zip |
LuaEntity armor groups
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r-- | src/content_cao.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 836f719a3..33079fd11 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -240,6 +240,7 @@ private: int m_anim_num_frames; float m_anim_framelength; float m_anim_timer; + ItemGroupList m_armor_groups; public: LuaEntityCAO(IGameDef *gamedef, ClientEnvironment *env): @@ -594,14 +595,21 @@ public: m_hp = result_hp; // TODO: Execute defined fast response } + else if(cmd == LUAENTITY_CMD_UPDATE_ARMOR_GROUPS) + { + m_armor_groups.clear(); + int armor_groups_size = readU16(is); + for(int i=0; i<armor_groups_size; i++){ + std::string name = deSerializeString(is); + int rating = readS16(is); + m_armor_groups[name] = rating; + } + } } 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()); @@ -613,7 +621,6 @@ public: if(result.did_punch) { - // TODO: Decrease hp by if(result.damage < m_hp) m_hp -= result.damage; else @@ -623,6 +630,19 @@ public: return false; } + + std::string debugInfoText() + { + std::ostringstream os(std::ios::binary); + os<<"LuaEntityCAO \n"; + os<<"armor={"; + for(ItemGroupList::const_iterator i = m_armor_groups.begin(); + i != m_armor_groups.end(); i++){ + os<<i->first<<"="<<i->second<<", "; + } + os<<"}"; + return os.str(); + } }; // Prototype |