when checking if outdoor enemies are alive, count types

This commit is contained in:
2025-01-19 19:30:10 -06:00
committed by Celtic Minstrel
parent 17a4c25d3c
commit 94b63dee49
2 changed files with 20 additions and 7 deletions

View File

@@ -4661,7 +4661,10 @@ bool hit_end_c_button() {
bool end_ok = true;
if(which_combat_type == 0) {
end_ok = out_monst_all_dead();
auto out_monst_remaining = out_monst_alive();
if(!out_monst_remaining.empty()){
end_ok = false;
}
}
for(cPlayer& pc : univ.party) {
if(pc.status[eStatus::FORCECAGE] > 0) {
@@ -4675,14 +4678,23 @@ bool hit_end_c_button() {
return end_ok;
}
bool out_monst_all_dead() {
for(short i = 0; i < univ.town.monst.size(); i++)
if(univ.town.monst[i].is_alive() && !univ.town.monst[i].is_friendly()) {
std::map<std::string,short> out_monst_alive() {
std::map<std::string,short> monst_alive;
for(short i = 0; i < univ.town.monst.size(); i++){
cCreature& m = univ.town.monst[i];
if(m.is_alive() && !m.is_friendly()) {
if(monst_alive.find(m.m_name) != monst_alive.end()){
// Would += work in this context?
monst_alive[m.m_name] = monst_alive[m.m_name] + 1;
}else{
monst_alive[m.m_name] = 1;
}
//print_nums(5555,i,univ.town.monst[i].number);
//print_nums(5555,univ.town.monst[i].m_loc.x,univ.town.monst[i].m_loc.y);
return false;
}
return true;
}
return monst_alive;
}
void end_combat() {

View File

@@ -2,6 +2,7 @@
#ifndef BOE_GAME_COMBAT_H
#define BOE_GAME_COMBAT_H
#include <map>
#include "location.hpp"
#include "scenario/monster.hpp"
#include "scenario/outdoors.hpp"
@@ -49,7 +50,7 @@ void do_poison();
void handle_disease();
void handle_acid();
bool hit_end_c_button();
bool out_monst_all_dead();
std::map<std::string,short> out_monst_alive();
void end_combat();
bool combat_cast_mage_spell();
bool combat_cast_priest_spell();