Oops, no more zombies in the day.
This commit is contained in:
@@ -354,6 +354,18 @@ int get_random_invasion_hour(int min_hour) {
|
|||||||
return random(min_hour, 11);
|
return random(min_hour, 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_night_hour(int hour) {
|
||||||
|
return hour < 6 || hour >= 19;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_random_zombie_swarm_hour(int min_hour) {
|
||||||
|
if (!is_night_hour(min_hour)) return -1;
|
||||||
|
if (min_hour >= 19) {
|
||||||
|
return random(min_hour, 23);
|
||||||
|
}
|
||||||
|
return random(min_hour, 5);
|
||||||
|
}
|
||||||
|
|
||||||
void schedule_invasion() {
|
void schedule_invasion() {
|
||||||
if (invasion_scheduled_hour != -1) return;
|
if (invasion_scheduled_hour != -1) return;
|
||||||
int hour = get_random_invasion_hour(current_hour);
|
int hour = get_random_invasion_hour(current_hour);
|
||||||
@@ -432,6 +444,10 @@ void end_zombie_swarm() {
|
|||||||
|
|
||||||
void check_zombie_swarm_status() {
|
void check_zombie_swarm_status() {
|
||||||
if (!zombie_swarm_active) return;
|
if (!zombie_swarm_active) return;
|
||||||
|
if (!is_night_hour(current_hour)) {
|
||||||
|
end_zombie_swarm();
|
||||||
|
return;
|
||||||
|
}
|
||||||
int hours_elapsed = current_hour - zombie_swarm_start_hour;
|
int hours_elapsed = current_hour - zombie_swarm_start_hour;
|
||||||
if (hours_elapsed < 0) {
|
if (hours_elapsed < 0) {
|
||||||
hours_elapsed += 24;
|
hours_elapsed += 24;
|
||||||
@@ -443,7 +459,7 @@ void check_zombie_swarm_status() {
|
|||||||
|
|
||||||
void schedule_zombie_swarm() {
|
void schedule_zombie_swarm() {
|
||||||
if (zombie_swarm_scheduled_hour != -1) return;
|
if (zombie_swarm_scheduled_hour != -1) return;
|
||||||
int hour = get_random_invasion_hour(current_hour);
|
int hour = get_random_zombie_swarm_hour(current_hour);
|
||||||
if (hour == -1) return;
|
if (hour == -1) return;
|
||||||
zombie_swarm_scheduled_hour = hour;
|
zombie_swarm_scheduled_hour = hour;
|
||||||
}
|
}
|
||||||
@@ -451,12 +467,14 @@ void schedule_zombie_swarm() {
|
|||||||
void check_scheduled_zombie_swarm() {
|
void check_scheduled_zombie_swarm() {
|
||||||
if (zombie_swarm_active) return;
|
if (zombie_swarm_active) return;
|
||||||
if (zombie_swarm_scheduled_hour != -1) {
|
if (zombie_swarm_scheduled_hour != -1) {
|
||||||
|
if (!is_night_hour(zombie_swarm_scheduled_hour) || !is_night_hour(current_hour)) {
|
||||||
|
zombie_swarm_scheduled_hour = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (current_hour == zombie_swarm_scheduled_hour) {
|
if (current_hour == zombie_swarm_scheduled_hour) {
|
||||||
zombie_swarm_scheduled_hour = -1;
|
zombie_swarm_scheduled_hour = -1;
|
||||||
zombie_swarm_triggered_today = true;
|
zombie_swarm_triggered_today = true;
|
||||||
start_zombie_swarm();
|
start_zombie_swarm();
|
||||||
} else if (current_hour > 11) {
|
|
||||||
zombie_swarm_scheduled_hour = -1;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -466,7 +484,7 @@ void check_scheduled_zombie_swarm() {
|
|||||||
void attempt_daily_zombie_swarm() {
|
void attempt_daily_zombie_swarm() {
|
||||||
if (!can_roll_zombie_swarm_today()) return;
|
if (!can_roll_zombie_swarm_today()) return;
|
||||||
if (zombie_swarm_roll_done_today || zombie_swarm_triggered_today || zombie_swarm_active) return;
|
if (zombie_swarm_roll_done_today || zombie_swarm_triggered_today || zombie_swarm_active) return;
|
||||||
if (current_hour < 6) return;
|
if (!is_night_hour(current_hour)) return;
|
||||||
|
|
||||||
zombie_swarm_roll_done_today = true;
|
zombie_swarm_roll_done_today = true;
|
||||||
int chance = get_zombie_swarm_chance_for_day();
|
int chance = get_zombie_swarm_chance_for_day();
|
||||||
|
|||||||
Reference in New Issue
Block a user