Lots of changes, forgot to add the heal scroll sound. Sounds for when enemies come in and go out of range. Menu filtering added.

This commit is contained in:
Storm Dragon
2026-01-25 21:10:38 -05:00
parent 815ac97a64
commit 43b24b6d11
30 changed files with 731 additions and 119 deletions

View File

@@ -29,6 +29,12 @@ int invasion_chance = 25;
bool invasion_triggered_today = false;
bool invasion_roll_done_today = false;
int invasion_scheduled_hour = -1;
string invasion_enemy_type = "bandit";
// Invasion mapping: "terrain=enemy" (defaults to bandits when no match)
// Terrain keys: "mountain" for mountain ranges, or regular types like "grass", "snow", "forest", "deep_forest", "stone".
string default_invasion_enemy_type = "bandit";
string[] invasion_terrain_enemy_map = {"mountain=goblin"};
void init_time() {
current_hour = 8;
@@ -46,10 +52,37 @@ void init_time() {
invasion_triggered_today = false;
invasion_roll_done_today = false;
invasion_scheduled_hour = -1;
invasion_enemy_type = "bandit";
update_ambience(true); // Force start
}
void expand_area() {
string get_invasion_enemy_type_for_terrain(const string&in terrain_type) {
for (uint i = 0; i < invasion_terrain_enemy_map.length(); i++) {
string entry = invasion_terrain_enemy_map[i];
int eq_pos = entry.find("=");
if (eq_pos <= 0) {
continue;
}
string key = entry.substr(0, eq_pos);
string value = entry.substr(eq_pos + 1);
if (key == terrain_type && value != "") {
return value;
}
}
return default_invasion_enemy_type;
}
string get_invasion_enemy_label(const string&in enemy_type) {
if (enemy_type != "") return enemy_type;
return default_invasion_enemy_type;
}
string get_invasion_enemy_plural(const string&in enemy_type) {
return get_invasion_enemy_label(enemy_type) + "s";
}
string expand_area() {
// Play invasion sound
p.play_stationary("sounds/enemies/invasion.ogg", false);
@@ -57,12 +90,13 @@ void expand_area() {
int type_roll = random(0, 3);
if (type_roll == 0) {
expand_mountain();
} else {
expand_regular_area();
return "mountain";
}
return expand_regular_area();
}
void expand_regular_area() {
string expand_regular_area() {
// Calculate new area
int new_start = MAP_SIZE;
int new_end = MAP_SIZE + EXPANSION_SIZE - 1;
@@ -120,6 +154,7 @@ void expand_regular_area() {
area_expanded_today = true;
notify("The area has expanded! New territory discovered to the east.");
return terrain_type;
}
void expand_mountain() {
@@ -147,10 +182,13 @@ void expand_mountain() {
}
void start_invasion() {
expand_area();
string expansion_terrain = expand_area();
invasion_active = true;
invasion_start_hour = current_hour;
notify("Bandits are invading from the new area!");
invasion_enemy_type = get_invasion_enemy_type_for_terrain(expansion_terrain);
string source = (expansion_terrain == "mountain") ? "the mountains" : "the new area";
string enemy_plural = get_invasion_enemy_plural(invasion_enemy_type);
notify(enemy_plural + " are invading from " + source + "!");
}
void update_invasion_chance_for_new_day() {
@@ -268,7 +306,7 @@ void end_invasion() {
invasion_active = false;
invasion_start_hour = -1;
transition_bandits_to_wandering();
notify("The bandit invasion has ended.");
notify("The " + get_invasion_enemy_label(invasion_enemy_type) + " invasion has ended.");
attempt_resident_recruitment();
}
@@ -302,10 +340,10 @@ void manage_bandits_during_invasion() {
return;
}
// During daytime: if invasion is active, maintain bandit count
// During daytime: if invasion is active, maintain invader count
if (invasion_active && expanded_area_start != -1) {
while (bandits.length() < BANDIT_MAX_COUNT) {
spawn_bandit(expanded_area_start, expanded_area_end);
spawn_bandit(expanded_area_start, expanded_area_end, invasion_enemy_type);
}
}
// If invasion not active, wandering bandits persist during daytime
@@ -448,7 +486,7 @@ void update_time() {
// Proactive resident defense with slings
attempt_resident_sling_defense();
// Manage bandits during active invasion
// Manage invasion enemies during active invasion
manage_bandits_during_invasion();
}