print remaining enemies when can't end combat

This commit is contained in:
2025-01-19 19:50:33 -06:00
committed by Celtic Minstrel
parent 94b63dee49
commit 3a5a02202b
3 changed files with 51 additions and 15 deletions

View File

@@ -45,6 +45,7 @@ extern short fast_bang;
extern short store_current_pc;
extern short combat_posing_monster , current_working_monster ; // 0-5 PC 100 + x - monster x
extern short missile_firer,current_monst_tactic;
extern cOutdoors::cWandering store_wandering_special;
eSpell spell_being_cast;
bool spell_freebie;
short missile_inv_slot, ammo_inv_slot;
@@ -4663,6 +4664,10 @@ bool hit_end_c_button() {
if(which_combat_type == 0) {
auto out_monst_remaining = out_monst_alive();
if(!out_monst_remaining.empty()){
// Print remaining monsters.
add_string_to_buf("Enemies are still alive!");
print_encounter_monsters(store_wandering_special, nullptr, out_monst_remaining);
end_ok = false;
}
}

View File

@@ -838,25 +838,54 @@ cVehicle* out_horse_there(location where) {
return &univ.party.horses[i];
return nullptr;
}
void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) {
std::string msg;
add_string_to_buf("COMBAT!");
for(short i = 0; i < 6; i++)
if(encounter.monst[i] != 0) {
msg = get_m_name(encounter.monst[i]);
std::ostringstream sout;
sout << " " << nums[i] << " x " << msg;
msg = sout.str();
add_string_to_buf(msg);
void print_monster_count(std::string m_name, short num){
if(num > 0){
std::ostringstream sout;
sout << " ";
if(num > 1){
sout << num << " x ";
}
if(encounter.monst[6] != 0) {
msg = " " + get_m_name(encounter.monst[6]);
add_string_to_buf(msg);
sout << m_name;
add_string_to_buf(sout.str());
}
}
void print_encounter_monsters(cOutdoors::cWandering encounter, short* nums, std::map<std::string,short> alive) {
std::string m_name;
bool remaining_specified = !alive.empty();
// Still follow the predefined ordering when giving an updated total, and leave summons to the end.
for(short i = 0; i < 7; i++)
if(encounter.monst[i] != 0) {
m_name = get_m_name(encounter.monst[i]);
short num = 0;
// Combat is just starting, so print the predefined amount
if(!remaining_specified){
num = nums[i];
}
// Combat has started, so need to check how many are still alive
else{
auto iter = alive.find(m_name);
if(iter != alive.end()){
num = iter->second;
alive.erase(iter);
}
}
print_monster_count(m_name, num);
}
// Monsters still in the alive map must have been summoned
if(!alive.empty()){
for (auto iter = alive.begin(); iter != alive.end(); ++iter){
print_monster_count(iter->first, iter->second);
}
}
}
void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) {
add_string_to_buf("COMBAT!");
print_encounter_monsters(encounter, nums);
}
std::string get_m_name(mon_num_t num) {
if(num >= 10000) return univ.party.summons[num - 10000].m_name;
return univ.scenario.scen_monsters[num].m_name;

View File

@@ -19,6 +19,8 @@ cVehicle* town_boat_there(location where);
cVehicle* out_boat_there(location where);
cVehicle* town_horse_there(location where);
cVehicle* out_horse_there(location where);
// Specify the alive map when combat is in progress so casualties and summons are reflected
void print_encounter_monsters(cOutdoors::cWandering encounter, short* nums, std::map<std::string,short> alive = {});
void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) ;
std::string get_m_name(mon_num_t num);
std::string get_ter_name(ter_num_t num);