#include "halfling.h" #include "../constants.h" fraction halfling::HIT_RATE_MUL = {1, 2}; halfling::halfling(RNG *rng, const feature enabled_features, const position &pos, const int gen_room_num): enemy_base{rng, enabled_features, rhalfling, pos, gen_room_num, "L"} {} const char *halfling::get_race_name() const { return "Halfling"; } long_result halfling::get_hit(character *ch, const int tATK, const fraction &hit_rate) { auto nhit_rate = HIT_RATE_MUL * hit_rate; if (rng->trial(nhit_rate)) { int tmp = calc_dmg(tATK, DEF); tmp = tmp > HP ? HP : tmp; HP -= tmp; if (HP == 0) return {result::hit, "PC deals " + std::to_string(tmp) + " damage to " + abbrev + " (" + std::to_string(HP) + " HP). " + abbrev + " is slain by PC. "}; return {result::hit, "PC deals " + std::to_string(tmp) + " damage to " + abbrev + " (" + std::to_string(HP) + " HP). "}; } return {miss, "PC tried to hit " + abbrev + " but missed. The halfling laughed. "}; }