A few bug fixes. Part of major refactor.

This commit is contained in:
Storm Dragon
2026-01-21 18:14:26 -05:00
parent 129cd4a656
commit af9a402e80
18 changed files with 660 additions and 433 deletions
+97 -44
View File
@@ -8,7 +8,7 @@ void apply_falling_damage(int fall_height) {
p.play_stationary("sounds/actions/hit_ground.ogg", false);
if (fall_height <= SAFE_FALL_HEIGHT) {
screen_reader_speak("Landed safely.", true);
speak_with_history("Landed safely.", true);
return;
}
@@ -23,7 +23,7 @@ void apply_falling_damage(int fall_height) {
if (player_health < 0) player_health = 0;
// Feedback
screen_reader_speak("Fell " + fall_height + " feet! Took " + damage + " damage. " + player_health + " health remaining.", true);
speak_with_history("Fell " + fall_height + " feet! Took " + damage + " damage. " + player_health + " health remaining.", true);
}
// Tree Object
class Tree {
@@ -439,7 +439,7 @@ void damage_tree(int target_x, int damage) {
}
p.play_stationary("sounds/items/stick.ogg", false);
screen_reader_speak(drop_message, true);
speak_with_history(drop_message, true);
}
}
}
@@ -474,24 +474,24 @@ void perform_search(int current_x)
if (s != null) {
if (s.has_catch) {
if (inv_small_game >= get_personal_stack_limit()) {
screen_reader_speak("You can't carry any more small game.", true);
speak_with_history("You can't carry any more small game.", true);
return;
}
if (inv_snares >= get_personal_stack_limit()) {
screen_reader_speak("You can't carry any more snares.", true);
speak_with_history("You can't carry any more snares.", true);
return;
}
inv_small_game++;
inv_small_game_types.insert_last(s.catch_type);
inv_snares++; // Recover snare
screen_reader_speak("Collected " + s.catch_type + " and snare.", true);
speak_with_history("Collected " + s.catch_type + " and snare.", true);
} else {
if (inv_snares >= get_personal_stack_limit()) {
screen_reader_speak("You can't carry any more snares.", true);
speak_with_history("You can't carry any more snares.", true);
return;
}
inv_snares++; // Recover snare
screen_reader_speak("Collected snare.", true);
speak_with_history("Collected snare.", true);
}
p.play_stationary("sounds/items/miscellaneous.ogg", false);
remove_snare_at(check_x);
@@ -500,7 +500,7 @@ void perform_search(int current_x)
}
if (random(1, 100) <= 10) {
screen_reader_speak("Found nothing.", true);
speak_with_history("Found nothing.", true);
return;
}
@@ -525,14 +525,14 @@ void perform_search(int current_x)
if (inv_reeds < get_personal_stack_limit()) {
inv_reeds++;
p.play_stationary("sounds/items/stick.ogg", false);
screen_reader_speak("Found a reed.", true);
speak_with_history("Found a reed.", true);
return;
}
} else {
if (inv_clay < get_personal_stack_limit()) {
inv_clay++;
p.play_stationary("sounds/items/clay.ogg", false);
screen_reader_speak("Found clay.", true);
speak_with_history("Found clay.", true);
return;
}
}
@@ -540,15 +540,15 @@ void perform_search(int current_x)
if (!found_reed && inv_reeds < get_personal_stack_limit()) {
inv_reeds++;
p.play_stationary("sounds/items/stick.ogg", false);
screen_reader_speak("Found a reed.", true);
speak_with_history("Found a reed.", true);
} else if (found_reed && inv_clay < get_personal_stack_limit()) {
inv_clay++;
p.play_stationary("sounds/items/clay.ogg", false);
screen_reader_speak("Found clay.", true);
speak_with_history("Found clay.", true);
} else if (found_reed) {
screen_reader_speak("You can't carry any more reeds.", true);
speak_with_history("You can't carry any more reeds.", true);
} else {
screen_reader_speak("You can't carry any more clay.", true);
speak_with_history("You can't carry any more clay.", true);
}
return;
}
@@ -573,12 +573,12 @@ void perform_search(int current_x)
if(@nearest != null)
{
if(nearest.is_chopped) {
screen_reader_speak("This tree has been cut down.", true);
speak_with_history("This tree has been cut down.", true);
return;
}
if (nearest.depleted) {
screen_reader_speak("This tree is empty.", true);
speak_with_history("This tree is empty.", true);
return;
}
@@ -592,13 +592,13 @@ void perform_search(int current_x)
nearest.sticks--;
inv_sticks++;
p.play_stationary("sounds/items/stick.ogg", false);
screen_reader_speak("Found a stick.", true);
speak_with_history("Found a stick.", true);
took_item = true;
} else if (nearest.vines > 0 && inv_vines < get_personal_stack_limit()) {
nearest.vines--;
inv_vines++;
p.play_stationary("sounds/items/vine.ogg", false);
screen_reader_speak("Found a vine.", true);
speak_with_history("Found a vine.", true);
took_item = true;
}
} else {
@@ -606,24 +606,24 @@ void perform_search(int current_x)
nearest.vines--;
inv_vines++;
p.play_stationary("sounds/items/vine.ogg", false);
screen_reader_speak("Found a vine.", true);
speak_with_history("Found a vine.", true);
took_item = true;
} else if (nearest.sticks > 0 && inv_sticks < get_personal_stack_limit()) {
nearest.sticks--;
inv_sticks++;
p.play_stationary("sounds/items/stick.ogg", false);
screen_reader_speak("Found a stick.", true);
speak_with_history("Found a stick.", true);
took_item = true;
}
}
if (!took_item) {
if (nearest.sticks > 0 && nearest.vines > 0) {
screen_reader_speak("You can't carry any more sticks or vines.", true);
speak_with_history("You can't carry any more sticks or vines.", true);
} else if (nearest.sticks > 0) {
screen_reader_speak("You can't carry any more sticks.", true);
speak_with_history("You can't carry any more sticks.", true);
} else {
screen_reader_speak("You can't carry any more vines.", true);
speak_with_history("You can't carry any more vines.", true);
}
return;
}
@@ -636,27 +636,58 @@ void perform_search(int current_x)
}
else
{
screen_reader_speak("This area has nothing left.", true);
speak_with_history("This area has nothing left.", true);
}
return;
}
// Gravel Area - Stones (20-34)
if (current_x >= 20 && current_x <= 34)
// Stone terrain - check for stones
bool is_stone_terrain = false;
// Check base gravel area (20-34)
if (current_x >= GRAVEL_START && current_x <= GRAVEL_END) {
is_stone_terrain = true;
}
// Check expanded areas
else if (expanded_area_start != -1 && current_x >= expanded_area_start && current_x <= expanded_area_end) {
// Check for mountain terrain first
MountainRange@ mountain = get_mountain_at(current_x);
if (mountain !is null) {
string terrain = mountain.get_terrain_at(current_x);
if (terrain == "stone" || terrain == "hard_stone") {
is_stone_terrain = true;
}
} else {
// Regular expanded area - check terrain type
int index = current_x - expanded_area_start;
if (index >= 0 && index < int(expanded_terrain_types.length())) {
string terrain = expanded_terrain_types[index];
// Handle "mountain:terrain" format from older saves
if (terrain.find("mountain:") == 0) {
terrain = terrain.substr(9);
}
if (terrain == "stone" || terrain == "hard_stone") {
is_stone_terrain = true;
}
}
}
}
if (is_stone_terrain)
{
if (inv_stones < get_personal_stack_limit())
{
inv_stones++;
p.play_stationary("sounds/items/stone.ogg", false);
screen_reader_speak("Found a stone.", true);
speak_with_history("Found a stone.", true);
}
else
{
screen_reader_speak("You can't carry any more stones.", true);
speak_with_history("You can't carry any more stones.", true);
}
return;
}
screen_reader_speak("Found nothing.", true);
speak_with_history("Found nothing.", true);
}
// Climbing functions
@@ -669,7 +700,7 @@ void start_climbing_tree(int target_x) {
climbing = true;
climb_target_y = tree.height;
climb_timer.restart();
screen_reader_speak("Started climbing tree. Height is " + tree.height + " feet.", true);
speak_with_history("Started climbing tree. Height is " + tree.height + " feet.", true);
}
void update_climbing() {
@@ -686,7 +717,7 @@ void update_climbing() {
if (y >= climb_target_y) {
climbing = false;
screen_reader_speak("Reached the top at " + y + " feet.", true);
speak_with_history("Reached the top at " + y + " feet.", true);
}
}
// Climbing down
@@ -697,7 +728,7 @@ void update_climbing() {
if (y <= 0) {
climbing = false;
y = 0;
screen_reader_speak("Safely reached the ground.", true);
speak_with_history("Safely reached the ground.", true);
}
}
}
@@ -709,7 +740,7 @@ void climb_down_tree() {
climbing = true;
climb_target_y = 0;
climb_timer.restart();
screen_reader_speak("Climbing down.", true);
speak_with_history("Climbing down.", true);
}
void start_falling() {
@@ -793,16 +824,16 @@ bool can_move_mountain(int from_x, int to_x) {
if (mountain.is_steep_section(from_x, to_x)) {
// Need rope
if (inv_ropes < 1) {
screen_reader_speak("You'll need a rope to climb there.", true);
speak_with_history("You'll need a rope to climb there.", true);
return false;
}
// Prompt for rope climb
int elevation_change = mountain.get_elevation_change(from_x, to_x);
if (elevation_change > 0) {
screen_reader_speak("Press up to climb up.", true);
speak_with_history("Press up to climb up.", true);
} else {
screen_reader_speak("Press down to climb down.", true);
speak_with_history("Press down to climb down.", true);
}
// Store pending rope climb info
@@ -817,22 +848,40 @@ bool can_move_mountain(int from_x, int to_x) {
// Rope climbing functions
void start_rope_climb(bool climbing_up, int target_x, int target_elevation) {
rope_climbing = true;
rope_climb_up = climbing_up;
rope_climb_target_x = target_x;
rope_climb_target_y = target_elevation;
rope_climb_start_y = y;
rope_climb_timer.restart();
int distance = rope_climb_target_y - y;
// Determine actual climbing direction based on elevation difference
int elevation_diff = target_elevation - y;
if (elevation_diff > 0) {
rope_climb_up = true;
} else if (elevation_diff < 0) {
rope_climb_up = false;
} else {
// Already at target elevation, no climbing needed
rope_climbing = false;
return;
}
// Calculate distance to climb (use actual distance from current position)
int distance = elevation_diff;
if (distance < 0) distance = -distance;
string direction = climbing_up ? "up" : "down";
screen_reader_speak("Climbing " + direction + ". " + distance + " feet.", true);
string direction = rope_climb_up ? "up" : "down";
speak_with_history("Climbing " + direction + ". " + distance + " feet.", true);
}
void update_rope_climbing() {
if (!rope_climbing) return;
// Check if we're already at the target (shouldn't happen, but safety check)
if (y == rope_climb_target_y) {
complete_rope_climb();
return;
}
// Climb at ROPE_CLIMB_SPEED ms per foot
if (rope_climb_timer.elapsed > ROPE_CLIMB_SPEED) {
rope_climb_timer.restart();
@@ -841,20 +890,24 @@ void update_rope_climbing() {
// Climbing up
if (y < rope_climb_target_y) {
y++;
p.play_stationary("sounds/actions/climb_rope.ogg", false);
// Check if we've reached the target BEFORE playing the sound
if (y >= rope_climb_target_y) {
complete_rope_climb();
} else {
p.play_stationary("sounds/actions/climb_rope.ogg", false);
}
}
} else {
// Climbing down
if (y > rope_climb_target_y) {
y--;
p.play_stationary("sounds/actions/climb_rope.ogg", false);
// Check if we've reached the target BEFORE playing the sound
if (y <= rope_climb_target_y) {
complete_rope_climb();
} else {
p.play_stationary("sounds/actions/climb_rope.ogg", false);
}
}
}
@@ -869,7 +922,7 @@ void complete_rope_climb() {
// Play footstep for new terrain
play_footstep(x, BASE_END, GRASS_END);
screen_reader_speak("Reached elevation " + y + ".", true);
speak_with_history("Reached elevation " + y + ".", true);
}
void check_rope_climb_fall() {