make damage type -> boom type DRY

This commit is contained in:
2024-11-26 13:11:52 -06:00
committed by Celtic Minstrel
parent 3068e97868
commit 3a9c5ea208
3 changed files with 14 additions and 15 deletions

View File

@@ -2377,13 +2377,7 @@ short damage_pc(cPlayer& which_pc,short how_much,eDamageType damage_type,eRace t
if(how_much < 0)
how_much = 0;
which_pc.marked_damage += how_much;
short boom_type = 2;
if(damage_type == eDamageType::FIRE)
boom_type = 0;
else if(damage_type == eDamageType::UNBLOCKABLE)
boom_type = 4;
else if(damage_type == eDamageType::COLD)
boom_type = 5;
short boom_type = get_boom_type(damage_type);
if(is_town())
add_explosion(univ.party.town_loc,how_much,0,boom_type,0,0);
else add_explosion(which_pc.combat_pos,how_much,0,boom_type,0,0);

View File

@@ -1433,6 +1433,17 @@ void set_sound_type(eDamageType dam_type, short& sound_type) {
}
}
short get_boom_type(eDamageType dam_type){
short boom_type = 2;
if(dam_type == eDamageType::FIRE)
boom_type = 0;
else if(dam_type == eDamageType::UNBLOCKABLE)
boom_type = 4;
else if(dam_type == eDamageType::COLD)
boom_type = 5;
return boom_type;
}
// Damaging and killing monsters needs to be here because several have specials attached to them.
short damage_monst(cCreature& victim, short who_hit, short how_much, eDamageType dam_type, short sound_type, bool do_print) {
short r1,which_spot;
@@ -1492,15 +1503,8 @@ short damage_monst(cCreature& victim, short who_hit, short how_much, eDamageType
if(boom_anim_active) {
if(how_much < 0)
how_much = 0;
short boom_type = 2;
if(dam_type == eDamageType::FIRE)
boom_type = 0;
else if(dam_type == eDamageType::UNBLOCKABLE)
boom_type = 4;
else if(dam_type == eDamageType::COLD)
boom_type = 5;
victim.marked_damage += how_much;
add_explosion(victim.cur_loc,how_much,0,boom_type,14 * (victim.x_width - 1),18 * (victim.y_width - 1));
add_explosion(victim.cur_loc,how_much,0,get_boom_type(dam_type),14 * (victim.x_width - 1),18 * (victim.y_width - 1));
// Note: Windows version printed an "undamaged" message here if applicable, but I don't think that's right.
if(how_much == 0)
return false;

View File

@@ -9,6 +9,7 @@ void use_item(short pc,short item);
bool use_space(location where);
bool adj_town_look(location where);
void set_sound_type(eDamageType dam_type, short& sound_type);
short get_boom_type(eDamageType dam_type);
short damage_monst(cCreature& which_m, short who_hit, short how_much, eDamageType dam_type, short sound_type = -1, bool do_print = true);
void petrify_monst(cCreature& which_m,int strength);
void kill_monst(cCreature& which_m,short who_killed,eMainStatus type = eMainStatus::DEAD);