Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix text appearing out of alignment with adjusted booms #643

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 26 additions & 28 deletions src/game/boe.combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ void char_stand_ready() {
univ.current_pc().ap = 0;
}

// Melee attack a monster
void pc_attack(short who_att,iLiving* target) {
short r1,r2;
short hit_adj, dam_adj;
Expand Down Expand Up @@ -586,11 +587,7 @@ void pc_attack(short who_att,iLiving* target) {
type = eDamageType::UNDEAD;
else if(attacker.race == eRace::DEMON)
type = eDamageType::DEMON;
// TODO: Change to damage_target()
if(cCreature* m_target = dynamic_cast<cCreature*>(target))
damage_monst(*m_target, who_att, r2, type,4);
else if(cPlayer* pc_target = dynamic_cast<cPlayer*>(target))
damage_pc(*pc_target, r2, type, attacker.race, 4);
damage_target(*target, r2, type, 4, true, who_att, attacker.race);
}
else {
draw_terrain(2);
Expand Down Expand Up @@ -810,25 +807,19 @@ void pc_attack_weapon(short who_att,iLiving& target,short hit_adj,short dam_adj,
short inflicted_weapon_damage = 0;
short inflicted_special_damage = 0;
short inflicted_bonus_damage = 0;
// TODO: Change these to damage_target()
if(cCreature* monst = dynamic_cast<cCreature*>(&target)) {
if(dmg_snd != no_dmg)
inflicted_weapon_damage = damage_monst(*monst, who_att, r2, eDamageType::WEAPON, dmg_snd, false);
if(spec_dam)
inflicted_special_damage = damage_monst(*monst, who_att, spec_dam, eDamageType::SPECIAL, 5, false);
if(bonus_dam)
inflicted_bonus_damage = damage_monst(*monst, who_att, bonus_dam, dmg_tp, 0, false);
if(inflicted_weapon_damage || inflicted_special_damage || inflicted_bonus_damage)

eRace race = attacker.race;
if(dmg_snd != no_dmg)
inflicted_weapon_damage = damage_target(target, r2, eDamageType::WEAPON, dmg_snd, false, who_att, race);
if(spec_dam)
inflicted_special_damage = damage_target(target, spec_dam, eDamageType::SPECIAL, 5, false, who_att, race);
if(bonus_dam)
inflicted_bonus_damage = damage_target(target, bonus_dam, dmg_tp, 0, false, who_att, race);

if(inflicted_weapon_damage || inflicted_special_damage || inflicted_bonus_damage){
if(cCreature* monst = dynamic_cast<cCreature*>(&target)) {
monst->damaged_msg(inflicted_weapon_damage, inflicted_special_damage + inflicted_bonus_damage);
} else if(cPlayer* who = dynamic_cast<cPlayer*>(&target)) {
eRace race = attacker.race;
if(dmg_snd != no_dmg)
inflicted_weapon_damage = damage_pc(*who, r2, eDamageType::WEAPON, race, dmg_snd, false);
if(spec_dam)
inflicted_special_damage = damage_pc(*who, spec_dam, eDamageType::SPECIAL, race, dmg_snd, false);
if(bonus_dam)
inflicted_bonus_damage = damage_pc(*who, bonus_dam, dmg_tp, race, dmg_snd, false);
if(inflicted_weapon_damage || inflicted_special_damage || inflicted_bonus_damage) {
} else if(cPlayer* who = dynamic_cast<cPlayer*>(&target)) {
std::string msg = " " + who->name + " takes " + std::to_string(inflicted_weapon_damage);
if(inflicted_special_damage + inflicted_bonus_damage)
msg += '+' + std::to_string(inflicted_special_damage + inflicted_bonus_damage);
Expand Down Expand Up @@ -4030,13 +4021,20 @@ bool monst_cast_priest(cCreature *caster,short targ) {
return acted;
}

void damage_target(short target,short dam,eDamageType type,short sound_type) {
if(target == 6) return;
if(target < 6)
damage_pc(univ.party[target],dam,type,eRace::UNKNOWN,sound_type);
else damage_monst(univ.town.monst[target - 100], 7, dam, type,sound_type);
short damage_target(short target,short dam,eDamageType type,short sound_type, bool do_print, short who_hit, eRace race) {
if(target >= 6 && target < 100) return 0;
if(target < 6){
return damage_pc(univ.party[target], dam, type, race, sound_type, do_print);
}else{
int monst_idx = target - 100;
if(monst_idx >= univ.town.monst.size()) return 0;
return damage_monst(univ.town.monst[monst_idx], who_hit, dam, type, sound_type, do_print);
}
}

short damage_target(iLiving& target,short dam,eDamageType type,short sound_type, bool do_print, short who_hit, eRace race) {
return damage_target(univ.get_target_i(target), dam, type, sound_type, do_print, who_hit, race);
}

// target = find_fireball_loc(caster->m_loc,1,(caster->attitude == 1) ? 0 : 1,&target_levels);

Expand Down
3 changes: 2 additions & 1 deletion src/game/boe.combat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void monst_basic_abil(short m_num, std::pair<eMonstAbil,uAbility> abil, iLiving*
bool monst_breathe(cCreature *caster,location targ_space,uAbility dam_type);
bool monst_cast_mage(cCreature *caster,short targ);
bool monst_cast_priest(cCreature *caster,short targ);
void damage_target(short target,short dam,eDamageType type,short sound_type = 0);
short damage_target(short target,short dam,eDamageType type,short sound_type = 0, bool do_print = true, short who_hit = 7, eRace race = eRace::UNKNOWN);
short damage_target(iLiving& target,short dam,eDamageType type,short sound_type = 0, bool do_print = true, short who_hit = 7, eRace race = eRace::UNKNOWN);
location find_fireball_loc(location where,short radius,short mode,short *m);
location closest_pc_loc(location where);
short count_levels(location where,short radius);
Expand Down
1 change: 0 additions & 1 deletion src/game/boe.graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,6 @@ void boom_space(location where,short mode,short type,short damage,short sound) {
text_rect = dest_rect;
text_rect.top += 13;
text_rect.height() = 10;
text_rect.offset(x_adj,y_adj);
std::string dam_str = std::to_string(damage);
style.colour = sf::Color::White;
text_rect.offset(-1,-1);
Expand Down
Loading