A few minor bug fixes with area expansion.

This commit is contained in:
Storm Dragon
2026-01-17 23:44:10 -05:00
parent ff9aa00590
commit 764eab45e4
7 changed files with 109 additions and 166 deletions
+69 -70
View File
@@ -251,6 +251,75 @@ void perform_search(int current_x)
}
}
// Trees (Sticks/Vines) - Check for nearby tree anywhere
Tree@ nearest = null;
int nearest_distance = 999;
for(uint i=0; i<trees.length(); i++)
{
int distance = trees[i].position - current_x;
if (distance < 0) distance = -distance;
if(distance <= 1 && distance < nearest_distance)
{
nearest_distance = distance;
@nearest = @trees[i];
if (nearest_distance == 0) {
break;
}
}
}
if(@nearest != null)
{
if(nearest.is_chopped) {
screen_reader_speak("This tree has been cut down.", true);
return;
}
if (nearest.depleted) {
screen_reader_speak("This tree is empty.", true);
return;
}
if(nearest.sticks > 0 || nearest.vines > 0)
{
bool find_stick = (nearest.vines <= 0) || (nearest.sticks > 0 && random(0, 1) == 0);
if(find_stick)
{
if (inv_sticks >= MAX_ITEM_STACK) {
screen_reader_speak("You can't carry any more sticks.", true);
return;
}
nearest.sticks--;
inv_sticks++;
p.play_stationary("sounds/items/stick.ogg", false);
screen_reader_speak("Found a stick.", true);
}
else
{
if (inv_vines >= MAX_ITEM_STACK) {
screen_reader_speak("You can't carry any more vines.", true);
return;
}
nearest.vines--;
inv_vines++;
p.play_stationary("sounds/items/vine.ogg", false);
screen_reader_speak("Found a vine.", true);
}
if(nearest.sticks == 0 && nearest.vines == 0) {
nearest.depleted = true;
nearest.regen_timer.restart();
nearest.minutes_since_depletion = 0;
}
}
else
{
screen_reader_speak("This area has nothing left.", true);
}
return;
}
// Gravel Area - Stones (20-34)
if (current_x >= 20 && current_x <= 34)
{
@@ -266,76 +335,6 @@ void perform_search(int current_x)
}
return;
}
// Grass Area - Trees (Sticks/Vines) (5-19)
if (current_x >= 5 && current_x <= 19)
{
Tree@ nearest = null;
for(uint i=0; i<trees.length(); i++)
{
if(trees[i].position >= current_x - 1 && trees[i].position <= current_x + 1)
{
@nearest = @trees[i];
break;
}
}
if(@nearest != null)
{
if(nearest.is_chopped) {
screen_reader_speak("This tree has been cut down.", true);
return;
}
if (nearest.depleted) {
screen_reader_speak("This tree is empty.", true);
return;
}
if(nearest.sticks > 0 || nearest.vines > 0)
{
bool find_stick = (nearest.vines <= 0) || (nearest.sticks > 0 && random(0, 1) == 0);
if(find_stick)
{
if (inv_sticks >= MAX_ITEM_STACK) {
screen_reader_speak("You can't carry any more sticks.", true);
return;
}
nearest.sticks--;
inv_sticks++;
p.play_stationary("sounds/items/stick.ogg", false);
screen_reader_speak("Found a stick.", true);
}
else
{
if (inv_vines >= MAX_ITEM_STACK) {
screen_reader_speak("You can't carry any more vines.", true);
return;
}
nearest.vines--;
inv_vines++;
p.play_stationary("sounds/items/vine.ogg", false);
screen_reader_speak("Found a vine.", true);
}
if(nearest.sticks == 0 && nearest.vines == 0) {
nearest.depleted = true;
nearest.regen_timer.restart();
nearest.minutes_since_depletion = 0;
}
}
else
{
screen_reader_speak("This area has nothing left.", true);
}
}
else
{
screen_reader_speak("Found nothing.", true);
}
return;
}
screen_reader_speak("Found nothing.", true);
}