Allow towns to not die no matter how many monsters are killed

This commit is contained in:
2015-09-20 14:16:18 -04:00
parent eba7a0c4e6
commit b8ac49f9ce
5 changed files with 12 additions and 6 deletions

View File

@@ -54,7 +54,7 @@ void create_wand_monst() {
place_outd_wand_monst(univ.out->wandering_locs[r2], univ.out->wandering[r1],0);
}
} else if(!univ.town->wandering[r1].isNull() && univ.town.countMonsters() <= 50
&& univ.party.m_killed[univ.town.num] < univ.town->max_num_monst) {
&& !univ.town->is_cleaned_out(univ.party.m_killed[univ.town.num])) {
// won't place wandering if more than 50 monsters
r2 = get_ran(1,0,univ.town->wandering.size() - 1);
while(point_onscreen(univ.town->wandering_locs[r2],univ.town.p_loc) &&

View File

@@ -221,7 +221,7 @@ void start_town_mode(short which_town, short entry_dir) {
// TODO: Should these two cases be separated?
if(univ.town->town_chop_time > 0 && day_reached(univ.town->town_chop_time,univ.town->town_chop_key))
univ.town.monst[i].active += 10;
else if(univ.party.m_killed[univ.town.num] > univ.town->max_num_monst)
else if(univ.town->is_cleaned_out(univ.party.m_killed[univ.town.num]))
univ.town.monst[i].active += 10;
else univ.town.monst[i].active = 0;
if(univ.town.monst[i].active >= 10)
@@ -291,7 +291,7 @@ void start_town_mode(short which_town, short entry_dir) {
// TODO: Should these two cases be separated?
if(univ.town->town_chop_time > 0 && day_reached(univ.town->town_chop_time,univ.town->town_chop_key))
univ.town.monst[i].active += 10;
else if(univ.party.m_killed[univ.town.num] > univ.town->max_num_monst)
else if(univ.town->is_cleaned_out(univ.party.m_killed[univ.town.num]))
univ.town.monst[i].active += 10;
else univ.town.monst[i].active = 0;
break;
@@ -320,7 +320,7 @@ void start_town_mode(short which_town, short entry_dir) {
// Thrash town?
if(univ.party.m_killed[univ.town.num] > univ.town->max_num_monst) {
if(univ.town->is_cleaned_out(univ.party.m_killed[univ.town.num])) {
town_toast = true;
add_string_to_buf("Area has been cleaned out.");
}

View File

@@ -110,7 +110,7 @@ public:
std::vector<cTimer> party_event_timers;
std::set<int> spec_items;
std::set<int> help_received;
short m_killed[200]; // monsters killed per town, I think
long m_killed[200]; // monsters killed per town
long long total_m_killed, total_dam_done, total_xp_gained, total_dam_taken;
std::string scen_name;
private:

View File

@@ -179,6 +179,11 @@ bool cTown::cWandering::isNull(){
return true;
}
bool cTown::is_cleaned_out(long m_killed) {
if(max_num_monst < 0) return false;
return m_killed >= max_num_monst;
}
void cTown::set_up_lights() {
using namespace std::placeholders;
short rad;

View File

@@ -76,7 +76,7 @@ public:
rectangle in_town_rect;
std::vector<cItem> preset_items;
std::vector<cTownperson> creatures;
short max_num_monst;
long max_num_monst;
std::vector<cField> preset_fields;
short spec_on_entry,spec_on_entry_if_dead;
short spec_on_hostile;
@@ -104,6 +104,7 @@ public:
void init_start();
void set_up_lights();
short light_obscurity(short x,short y); // Obscurity function used for calculating lighting
bool is_cleaned_out(long m_killed);
explicit cTown(cScenario& scenario);
void append(legacy::town_record_type& old);