1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Damage groups WIP

This commit is contained in:
Perttu Ahola 2012-03-05 01:30:55 +02:00
parent e9cdb938fe
commit 501b8fe743
6 changed files with 136 additions and 29 deletions

View file

@ -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;
}