Files
draugnorak/src/bosses/adventure_system.nvgt

91 lines
2.6 KiB
Plaintext

// Adventure System
// Handles triggering and managing terrain-specific adventures
#include "src/bosses/adventure_combat.nvgt"
#include "src/bosses/unicorn/unicorn_boss.nvgt"
#include "src/bosses/bandit_hideout.nvgt"
void check_adventure_menu(int player_x) {
if (key_pressed(KEY_TAB)) {
run_adventure_menu(player_x);
}
}
void run_adventure_menu(int player_x) {
if (player_x <= BASE_END) {
speak_with_history("No adventures available in the base.", true);
return;
}
if (last_adventure_day == current_day) {
speak_with_history("You have already attempted an adventure today.", true);
return;
}
string terrain = get_terrain_at_position(player_x);
MountainRange@ mountain = get_mountain_at(player_x);
// Check available adventures based on terrain
string[] options;
int[] adventure_ids; // 1 = Unicorn, 2 = Bandit's Hideout
if (mountain !is null) {
// Mountain terrain
options.insert_last("Unicorn Hunt (Mountain Boss)");
adventure_ids.insert_last(1);
}
if (mountain is null && (terrain == "forest" || terrain == "deep_forest")) {
options.insert_last("Bandit's Hideout");
adventure_ids.insert_last(ADVENTURE_BANDIT_HIDEOUT);
}
if (options.length() == 0) {
speak_with_history("No adventures found in this area.", true);
return;
}
// Show Menu
speak_with_history("Adventure Menu.", true);
int selection = 0;
speak_with_history(options[selection], true);
while (true) {
wait(5);
if (key_pressed(KEY_ESCAPE)) {
speak_with_history("Closed.", true);
return;
}
if (key_pressed(KEY_DOWN)) {
selection++;
if (selection >= options.length()) selection = 0;
speak_with_history(options[selection], true);
}
if (key_pressed(KEY_UP)) {
selection--;
if (selection < 0) selection = options.length() - 1;
speak_with_history(options[selection], true);
}
if (key_pressed(KEY_RETURN)) {
start_adventure(adventure_ids[selection]);
// Adventure has finished (it blocks until done)
// Resume main game ambience
update_ambience(true);
return;
}
}
}
void start_adventure(int adventure_id) {
last_adventure_day = current_day;
if (adventure_id == 1) {
run_unicorn_adventure();
} else if (adventure_id == ADVENTURE_BANDIT_HIDEOUT) {
run_bandit_hideout_adventure();
}
}