bool Weapon::useFist(Player* player, Creature* target)
{
const Position& playerPos = player->getPosition();
const Position& targetPos = target->getPosition();
if(!Position::areInRange<1,1>(playerPos, targetPos))
return false;
float attackFactor = player->getAttackFactor();
int32_t attackSkill = player->getSkill(SKILL_FIST, SKILL_LEVEL);
int32_t attackValue = 7;
double maxDamage = Weapons::getMaxWeaponDamage(player->getLevel(), attackSkill, attackValue, attackFactor);
if(random_range(1, 100) <= g_config.getNumber(ConfigManager::CRITICAL_HIT_CHANCE))
{
maxDamage = std::pow(maxDamage, g_config.getDouble(ConfigManager::CRITICAL_HIT_MUL));
player->sendCritical();
}
Vocation* vocation = player->getVocation();
if(vocation && vocation->getMultiplier(MULTIPLIER_MELEE) != 1.0)
maxDamage *= vocation->getMultiplier(MULTIPLIER_MELEE);
maxDamage = std::floor(maxDamage);
int32_t damage = -random_range(0, (int32_t)maxDamage, DISTRO_NORMAL);
CombatParams fist;
fist.blockedByArmor = true;
fist.blockedByShield = true;
fist.combatType = COMBAT_PHYSICALDAMAGE;
Combat::doCombatHealth(player, target, damage, damage, fist);
if(!player->hasFlag(PlayerFlag_NotGainSkill) && player->getAddAttackSkill())
player->addSkillAdvance(SKILL_FIST, 1);
return true;
}