dealt_damage_instance Creature::deal_damage(Creature *source, body_part bp, const damage_instance &dam) { if( is_dead_state() ) { return dealt_damage_instance(); } int total_damage = 0; int total_pain = 0; damage_instance d = dam; // copy, since we will mutate in absorb_hit dealt_damage_instance dealt_dams; absorb_hit(bp, d); // Add up all the damage units dealt for( const auto &it : d.damage_units ) { int cur_damage = 0; deal_damage_handle_type( it, bp, cur_damage, total_pain ); if( cur_damage > 0 ) { dealt_dams.dealt_dams[ it.type ] += cur_damage; total_damage += cur_damage; } } mod_pain(total_pain); apply_damage( source, bp, total_damage ); return dealt_dams; }
dealt_damage_instance Creature::deal_damage(Creature *source, body_part bp, const damage_instance &dam) { if( is_dead_state() ) { return dealt_damage_instance(); } int total_damage = 0; int total_pain = 0; damage_instance d = dam; // copy, since we will mutate in absorb_hit std::vector<int> dealt_dams(NUM_DT, 0); absorb_hit(bp, d); // add up all the damage units dealt int cur_damage; for (std::vector<damage_unit>::const_iterator it = d.damage_units.begin(); it != d.damage_units.end(); ++it) { cur_damage = 0; deal_damage_handle_type(*it, bp, cur_damage, total_pain); if (cur_damage > 0) { dealt_dams[it->type] += cur_damage; total_damage += cur_damage; } } mod_pain(total_pain); if( dam.effects.count("NOGIB") ) { total_damage = std::min( total_damage, get_hp() + 1 ); } apply_damage(source, bp, total_damage); return dealt_damage_instance(dealt_dams); }
void monster::apply_damage(Creature* source, body_part /*bp*/, int dam) { if( is_dead_state() ) { return; } hp -= dam; if( hp < 1 ) { set_killer( source ); } else if( dam > 0 ) { process_trigger( MTRIG_HURT, 1 + int( dam / 3 ) ); } }
void Creature::process_turn() { if(is_dead_state()) { return; } process_effects(); // Call this in case any effects have changed our stats reset_stats(); // add an appropriate number of moves moves += get_speed(); }
void monster::apply_damage(Creature* source, body_part bp, int side, int amount) { if (is_dead_state()) return; // don't do any more damage if we're already dead hurt(bp, side, amount); if (is_dead_state()) die(source); }
void Creature::check_dead_state() { if( is_dead_state() ) { die( nullptr ); } }
bool monster::is_dead() const { return dead || is_dead_state(); }