From 501b8fe743c56ad07c5fd8bdd4bfffa13fcb3c4d Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 5 Mar 2012 01:30:55 +0200 Subject: Damage groups WIP --- src/content_sao.cpp | 56 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'src/content_sao.cpp') diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 5c03c9053..0c105bb0f 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -531,33 +531,47 @@ int LuaEntitySAO::punch(v3f dir, m_removed = true; return 0; } - lua_State *L = m_env->getLua(); - scriptapi_luaentity_punch(L, m_id, puncher, - time_from_last_punch, toolcap, dir); + + ItemStack *punchitem = NULL; + ItemStack punchitem_static; + if(puncher){ + punchitem_static = puncher->getWieldedItem(); + punchitem = &punchitem_static; + } - HitParams hitparams = getHitParams(m_armor_groups, toolcap, + PunchDamageResult result = getPunchDamage( + m_armor_groups, + toolcap, + punchitem, time_from_last_punch); - actionstream<getDescription()<<", damage "<getDescription()<<", damage "<getLua(); + scriptapi_luaentity_punch(L, m_id, puncher, + time_from_last_punch, toolcap, dir); + + return result.wear; } void LuaEntitySAO::rightClick(ServerActiveObject *clicker) -- cgit v1.2.3