Multiple characters allowed. Starting base health lowered. Fylgjr system implemented.
This commit is contained in:
@@ -27,6 +27,7 @@ sound_pool p(300);
|
||||
#include "src/quest_system.nvgt"
|
||||
#include "src/environment.nvgt"
|
||||
#include "src/combat.nvgt"
|
||||
#include "src/fylgja_system.nvgt"
|
||||
#include "src/save_system.nvgt"
|
||||
#include "src/base_system.nvgt"
|
||||
#include "src/time_system.nvgt"
|
||||
@@ -43,7 +44,7 @@ int run_main_menu() {
|
||||
speak_with_history("Draugnorak. Main menu.", true);
|
||||
|
||||
int selection = 0;
|
||||
string load_label = has_save_game() ? "Load Game" : "Load Game (no save found)";
|
||||
string load_label = has_save_game() ? "Load Game" : "Load Game (no saves found)";
|
||||
string[] options = {"New Game", load_label, "Exit"};
|
||||
|
||||
speak_with_history(options[selection], true);
|
||||
@@ -75,7 +76,7 @@ int run_main_menu() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
void main()
|
||||
void run_game()
|
||||
{
|
||||
// Configure sound pool for better spatial audio
|
||||
p.volume_step = AUDIO_VOLUME_STEP / float(AUDIO_TILE_SCALE); // Default falloff in audio units
|
||||
@@ -91,28 +92,28 @@ void main()
|
||||
int selection = run_main_menu();
|
||||
|
||||
if (selection == 0) {
|
||||
// Check if save file exists and confirm before overwriting
|
||||
if (has_save_game()) {
|
||||
int confirm = ui_question("", "Save found. Are you sure you want to start a new game?");
|
||||
if (confirm != 1) {
|
||||
continue; // Return to main menu
|
||||
}
|
||||
if (!setup_new_character()) {
|
||||
continue;
|
||||
}
|
||||
start_new_game();
|
||||
speak_with_history("New game started.", true);
|
||||
game_started = true;
|
||||
} else if (selection == 1) {
|
||||
if (load_game_state()) {
|
||||
if (!has_save_game()) {
|
||||
ui_info_box("Draugnorak", "Load Game", "No saves found.");
|
||||
continue;
|
||||
}
|
||||
string selectedFile;
|
||||
if (!select_save_file(selectedFile)) {
|
||||
continue;
|
||||
}
|
||||
if (load_game_state_from_file(selectedFile)) {
|
||||
speak_with_history("Game loaded.", true);
|
||||
game_started = true;
|
||||
} else {
|
||||
if (has_save_game()) {
|
||||
string message = last_save_error;
|
||||
if (message == "") message = "Unable to load save.";
|
||||
ui_info_box("Draugnorak", "Load Game", message);
|
||||
} else {
|
||||
ui_info_box("Draugnorak", "Load Game", "No save found.");
|
||||
}
|
||||
string message = last_save_error;
|
||||
if (message == "") message = "Unable to load save.";
|
||||
ui_info_box("Draugnorak", "Load Game", message);
|
||||
}
|
||||
} else {
|
||||
exit();
|
||||
@@ -198,6 +199,11 @@ void main()
|
||||
}
|
||||
}
|
||||
|
||||
if (fylgjaCharging) {
|
||||
update_fylgja_charge();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Inventory & Actions
|
||||
check_inventory_keys(x);
|
||||
check_action_menu(x);
|
||||
@@ -206,6 +212,7 @@ void main()
|
||||
check_altar_menu(x);
|
||||
check_equipment_menu();
|
||||
check_quest_menu();
|
||||
check_fylgja_menu();
|
||||
check_quick_slot_keys();
|
||||
check_time_input();
|
||||
check_notification_keys();
|
||||
@@ -304,6 +311,9 @@ void main()
|
||||
|
||||
movetime = jumping ? jump_speed : walk_speed;
|
||||
|
||||
bool left_active = key_down(KEY_LEFT);
|
||||
bool right_active = key_down(KEY_RIGHT);
|
||||
|
||||
// Movement Logic
|
||||
if (key_pressed(KEY_LEFT) && facing != 0 && !climbing && !falling && !rope_climbing) {
|
||||
facing = 0;
|
||||
@@ -328,13 +338,13 @@ void main()
|
||||
MountainRange@ current_mountain = get_mountain_at(x);
|
||||
Tree@ current_tree = get_tree_at(x);
|
||||
int ground_elevation = get_mountain_elevation_at(x);
|
||||
if((key_down(KEY_LEFT) || key_down(KEY_RIGHT)) && y > ground_elevation && !jumping && !falling && !rope_climbing && current_mountain is null && current_tree !is null) {
|
||||
if((left_active || right_active) && y > ground_elevation && !jumping && !falling && !rope_climbing && current_mountain is null && current_tree !is null) {
|
||||
// Fall out of tree
|
||||
climbing = false;
|
||||
start_falling();
|
||||
}
|
||||
|
||||
if(key_down(KEY_LEFT) && x > 0 && !climbing && !falling && !rope_climbing)
|
||||
if(left_active && x > 0 && !climbing && !falling && !rope_climbing)
|
||||
{
|
||||
facing = 0;
|
||||
int target_x = x - 1;
|
||||
@@ -353,7 +363,7 @@ void main()
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(key_down(KEY_RIGHT) && x < MAP_SIZE - 1 && !climbing && !falling && !rope_climbing)
|
||||
else if(right_active && x < MAP_SIZE - 1 && !climbing && !falling && !rope_climbing)
|
||||
{
|
||||
facing = 1;
|
||||
int target_x = x + 1;
|
||||
@@ -384,10 +394,7 @@ void main()
|
||||
|
||||
// Searching Logic
|
||||
bool shift_down = (key_down(KEY_LSHIFT) || key_down(KEY_RSHIFT));
|
||||
if (!shift_down) {
|
||||
if (searching) {
|
||||
searching = false;
|
||||
}
|
||||
if (!shift_down && !searching) {
|
||||
search_timer.restart();
|
||||
}
|
||||
// Apply rune gathering bonus to search time
|
||||
@@ -475,3 +482,13 @@ void main()
|
||||
p.update_listener_1d(x);
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
try {
|
||||
run_game();
|
||||
} catch {
|
||||
log_unhandled_exception("main");
|
||||
ui_info_box("Draugnorak", "Unhandled exception", "A crash log was written to crash.log.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user