Files
draugnorak/src/menus/menu_utils.nvgt

82 lines
2.3 KiB
Plaintext

// Menu utility functions
// Helper functions used across multiple menu systems
void menu_background_tick() {
// Keep this list in sync with the main game loop to avoid pausing ambience/weather/time.
update_time();
update_crossfade();
update_weather();
update_environment();
update_snares();
update_streams();
update_fires();
update_zombies();
update_bandits();
update_boars();
update_flying_creatures();
update_world_drops();
update_blessings();
update_notifications();
// Fire damage check (only if not jumping)
WorldFire@ fire_on_tile = get_fire_at(x);
if (fire_on_tile != null && !jumping && fire_damage_timer.elapsed > 1000) {
player_health--;
fire_damage_timer.restart();
speak_with_history("Burning! " + player_health + " health remaining.", true);
}
// Healing in base area
if (x <= BASE_END && player_health < max_health) {
WorldHerbGarden@ herb_garden = get_herb_garden_at_base();
int heal_interval = (herb_garden != null) ? 30000 : 150000; // 30 seconds with garden, 2.5 minutes without
if (healing_timer.elapsed > heal_interval) {
player_health++;
healing_timer.restart();
speak_with_history(player_health + " health.", true);
}
}
// Death check
if (player_health <= 0) {
if (!try_consume_heal_scroll()) {
speak_with_history("You have died.", true);
wait(2000);
exit();
}
}
}
string join_string_list(const string[]@ items) {
if (@items == null || items.length() == 0) return "";
string result = items[0];
for (uint i = 1; i < items.length(); i++) {
result += ", " + items[i];
}
return result;
}
int get_storage_total_items() {
int total = 0;
for (int i = 0; i < ITEM_COUNT; i++) {
total += get_storage_count(i);
}
return total;
}
string get_base_fire_status() {
int total = 0;
int burning = 0;
for (uint i = 0; i < world_fires.length(); i++) {
if (world_fires[i].position <= BASE_END) {
total++;
if (world_fires[i].is_burning()) {
burning++;
}
}
}
if (total == 0) return "No fires in base";
return "Fires in base: " + burning + " burning, " + total + " total";
}