870 lines
35 KiB
Plaintext
870 lines
35 KiB
Plaintext
// Inventory and base menus
|
|
void check_inventory_keys(int x) {
|
|
if (key_pressed(KEY_P)) {
|
|
show_character_info();
|
|
return;
|
|
}
|
|
if (key_pressed(KEY_I)) {
|
|
bool in_base = x <= BASE_END;
|
|
if (in_base && world_storages.length() > 0) {
|
|
run_inventory_root_menu();
|
|
} else {
|
|
if (in_base && world_storages.length() == 0) {
|
|
screen_reader_speak("No storage built.", true);
|
|
}
|
|
run_inventory_menu(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
void check_action_menu(int x) {
|
|
if (key_pressed(KEY_A)) {
|
|
run_action_menu(x);
|
|
}
|
|
}
|
|
|
|
void menu_background_tick() {
|
|
update_time();
|
|
update_environment();
|
|
update_snares();
|
|
update_fires();
|
|
update_zombies();
|
|
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();
|
|
screen_reader_speak("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();
|
|
screen_reader_speak(player_health + " health.", true);
|
|
}
|
|
}
|
|
|
|
// Death check
|
|
if (player_health <= 0) {
|
|
screen_reader_speak("You have died.", true);
|
|
wait(2000);
|
|
exit();
|
|
}
|
|
}
|
|
|
|
int get_storage_total_items() {
|
|
int total = 0;
|
|
total += storage_stones;
|
|
total += storage_sticks;
|
|
total += storage_vines;
|
|
total += storage_reeds;
|
|
total += storage_logs;
|
|
total += storage_clay;
|
|
total += storage_small_game;
|
|
total += storage_meat;
|
|
total += storage_skins;
|
|
total += storage_spears;
|
|
total += storage_slings;
|
|
total += storage_axes;
|
|
total += storage_snares;
|
|
total += storage_knives;
|
|
total += storage_fishing_poles;
|
|
total += storage_ropes;
|
|
total += storage_reed_baskets;
|
|
total += storage_clay_pots;
|
|
total += storage_skin_hats;
|
|
total += storage_skin_gloves;
|
|
total += storage_skin_pants;
|
|
total += storage_skin_tunics;
|
|
total += storage_moccasins;
|
|
total += storage_skin_pouches;
|
|
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";
|
|
}
|
|
|
|
void run_base_info_menu() {
|
|
if (x > BASE_END) {
|
|
screen_reader_speak("You are not in the base.", true);
|
|
return;
|
|
}
|
|
|
|
screen_reader_speak("Base info.", true);
|
|
|
|
int selection = 0;
|
|
string[] options;
|
|
options.insert_last("Barricade health " + barricade_health + " of " + BARRICADE_MAX_HEALTH);
|
|
options.insert_last("Residents " + residents_count);
|
|
|
|
if (world_storages.length() > 0) {
|
|
options.insert_last("Storage built. Total items " + get_storage_total_items());
|
|
int daily_food = get_daily_food_requirement();
|
|
options.insert_last("Food in storage " + storage_meat + " meat. Daily use " + daily_food);
|
|
} else {
|
|
options.insert_last("Storage not built");
|
|
}
|
|
|
|
options.insert_last(get_base_fire_status());
|
|
|
|
if (world_altars.length() > 0) options.insert_last("Altar built");
|
|
else options.insert_last("Altar not built");
|
|
|
|
if (get_herb_garden_at_base() != null) options.insert_last("Herb garden built");
|
|
else options.insert_last("Herb garden not built");
|
|
|
|
if (world_pastures.length() > 0) options.insert_last("Pasture built");
|
|
else options.insert_last("Pasture not built");
|
|
|
|
if (world_stables.length() > 0) options.insert_last("Stable built");
|
|
else options.insert_last("Stable not built");
|
|
|
|
while(true) {
|
|
wait(5);
|
|
menu_background_tick();
|
|
if (key_pressed(KEY_ESCAPE)) {
|
|
screen_reader_speak("Closed.", true);
|
|
break;
|
|
}
|
|
|
|
if (key_pressed(KEY_DOWN)) {
|
|
selection++;
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_UP)) {
|
|
selection--;
|
|
if (selection < 0) selection = options.length() - 1;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
void show_character_info() {
|
|
string[] equipped_clothing;
|
|
string[] missing_slots;
|
|
|
|
if (equipped_head == EQUIP_HAT) equipped_clothing.insert_last("Skin Hat");
|
|
else missing_slots.insert_last("head");
|
|
if (equipped_torso == EQUIP_TUNIC) equipped_clothing.insert_last("Skin Tunic");
|
|
else missing_slots.insert_last("torso");
|
|
if (equipped_arms == EQUIP_POUCH) equipped_clothing.insert_last("Skin Pouch");
|
|
else missing_slots.insert_last("arms");
|
|
if (equipped_hands == EQUIP_GLOVES) equipped_clothing.insert_last("Skin Gloves");
|
|
else missing_slots.insert_last("hands");
|
|
if (equipped_legs == EQUIP_PANTS) equipped_clothing.insert_last("Skin Pants");
|
|
else missing_slots.insert_last("legs");
|
|
if (equipped_feet == EQUIP_MOCCASINS) equipped_clothing.insert_last("Moccasins");
|
|
else missing_slots.insert_last("feet");
|
|
|
|
string info = "Character info. ";
|
|
info += "Health " + player_health + " of " + max_health + ". ";
|
|
info += "Weapon " + get_equipped_weapon_name() + ". ";
|
|
if (equipped_clothing.length() > 0) {
|
|
info += "Clothing equipped: " + join_string_list(equipped_clothing) + ". ";
|
|
} else {
|
|
info += "No clothing equipped. ";
|
|
}
|
|
if (missing_slots.length() > 0) {
|
|
info += "Missing " + join_string_list(missing_slots) + ". ";
|
|
}
|
|
info += "Favor " + format_favor(favor) + ". ";
|
|
info += "Speed " + get_speed_status() + ".";
|
|
screen_reader_speak(info, true);
|
|
}
|
|
|
|
int prompt_transfer_amount(const string prompt, int max_amount) {
|
|
string input = ui_input_box("Inventory", prompt + " (max " + max_amount + ")", "");
|
|
int amount = parse_int(input);
|
|
if (amount <= 0) return 0;
|
|
if (amount > max_amount) amount = max_amount;
|
|
return amount;
|
|
}
|
|
|
|
void move_small_game_to_storage(int amount) {
|
|
for (int i = 0; i < amount; i++) {
|
|
string game_type = "small game";
|
|
if (inv_small_game_types.length() > 0) {
|
|
game_type = inv_small_game_types[0];
|
|
inv_small_game_types.remove_at(0);
|
|
}
|
|
storage_small_game_types.insert_last(game_type);
|
|
}
|
|
}
|
|
|
|
void move_small_game_to_personal(int amount) {
|
|
for (int i = 0; i < amount; i++) {
|
|
string game_type = "small game";
|
|
if (storage_small_game_types.length() > 0) {
|
|
game_type = storage_small_game_types[0];
|
|
storage_small_game_types.remove_at(0);
|
|
}
|
|
inv_small_game_types.insert_last(game_type);
|
|
}
|
|
}
|
|
|
|
void deposit_item(int item_type) {
|
|
int available = get_personal_count(item_type);
|
|
if (available <= 0) {
|
|
screen_reader_speak("Nothing to deposit.", true);
|
|
return;
|
|
}
|
|
int capacity = BASE_STORAGE_MAX - get_storage_count(item_type);
|
|
if (capacity <= 0) {
|
|
screen_reader_speak("Storage for that item is full.", true);
|
|
return;
|
|
}
|
|
int max_transfer = (available < capacity) ? available : capacity;
|
|
int amount = prompt_transfer_amount("Deposit how many?", max_transfer);
|
|
if (amount <= 0) return;
|
|
|
|
if (item_type == ITEM_STICKS) { inv_sticks -= amount; storage_sticks += amount; }
|
|
else if (item_type == ITEM_VINES) { inv_vines -= amount; storage_vines += amount; }
|
|
else if (item_type == ITEM_REEDS) { inv_reeds -= amount; storage_reeds += amount; }
|
|
else if (item_type == ITEM_STONES) { inv_stones -= amount; storage_stones += amount; }
|
|
else if (item_type == ITEM_LOGS) { inv_logs -= amount; storage_logs += amount; }
|
|
else if (item_type == ITEM_CLAY) { inv_clay -= amount; storage_clay += amount; }
|
|
else if (item_type == ITEM_SMALL_GAME) { inv_small_game -= amount; storage_small_game += amount; move_small_game_to_storage(amount); }
|
|
else if (item_type == ITEM_MEAT) { inv_meat -= amount; storage_meat += amount; }
|
|
else if (item_type == ITEM_SKINS) { inv_skins -= amount; storage_skins += amount; }
|
|
else if (item_type == ITEM_FEATHERS) { inv_feathers -= amount; storage_feathers += amount; }
|
|
else if (item_type == ITEM_DOWN) { inv_down -= amount; storage_down += amount; }
|
|
else if (item_type == ITEM_INCENSE) { inv_incense -= amount; storage_incense += amount; }
|
|
else if (item_type == ITEM_SPEARS) { inv_spears -= amount; storage_spears += amount; }
|
|
else if (item_type == ITEM_SLINGS) { inv_slings -= amount; storage_slings += amount; }
|
|
else if (item_type == ITEM_AXES) { inv_axes -= amount; storage_axes += amount; }
|
|
else if (item_type == ITEM_SNARES) { inv_snares -= amount; storage_snares += amount; }
|
|
else if (item_type == ITEM_KNIVES) { inv_knives -= amount; storage_knives += amount; }
|
|
else if (item_type == ITEM_FISHING_POLES) { inv_fishing_poles -= amount; storage_fishing_poles += amount; }
|
|
else if (item_type == ITEM_ROPES) { inv_ropes -= amount; storage_ropes += amount; }
|
|
else if (item_type == ITEM_REED_BASKETS) { inv_reed_baskets -= amount; storage_reed_baskets += amount; }
|
|
else if (item_type == ITEM_CLAY_POTS) { inv_clay_pots -= amount; storage_clay_pots += amount; }
|
|
else if (item_type == ITEM_SKIN_HATS) { inv_skin_hats -= amount; storage_skin_hats += amount; }
|
|
else if (item_type == ITEM_SKIN_GLOVES) { inv_skin_gloves -= amount; storage_skin_gloves += amount; }
|
|
else if (item_type == ITEM_SKIN_PANTS) { inv_skin_pants -= amount; storage_skin_pants += amount; }
|
|
else if (item_type == ITEM_SKIN_TUNICS) { inv_skin_tunics -= amount; storage_skin_tunics += amount; }
|
|
else if (item_type == ITEM_MOCCASINS) { inv_moccasins -= amount; storage_moccasins += amount; }
|
|
else if (item_type == ITEM_SKIN_POUCHES) { inv_skin_pouches -= amount; storage_skin_pouches += amount; }
|
|
|
|
cleanup_equipment_after_inventory_change();
|
|
screen_reader_speak("Deposited " + amount + " " + get_item_label(item_type) + ".", true);
|
|
}
|
|
|
|
void withdraw_item(int item_type) {
|
|
int available = get_storage_count(item_type);
|
|
if (available <= 0) {
|
|
screen_reader_speak("Nothing to withdraw.", true);
|
|
return;
|
|
}
|
|
int capacity = get_personal_stack_limit() - get_personal_count(item_type);
|
|
if (capacity <= 0) {
|
|
screen_reader_speak("You can't carry any more " + get_item_label(item_type) + ".", true);
|
|
return;
|
|
}
|
|
int max_transfer = (available < capacity) ? available : capacity;
|
|
int amount = prompt_transfer_amount("Withdraw how many?", max_transfer);
|
|
if (amount <= 0) return;
|
|
|
|
if (item_type == ITEM_STICKS) { storage_sticks -= amount; inv_sticks += amount; }
|
|
else if (item_type == ITEM_VINES) { storage_vines -= amount; inv_vines += amount; }
|
|
else if (item_type == ITEM_REEDS) { storage_reeds -= amount; inv_reeds += amount; }
|
|
else if (item_type == ITEM_STONES) { storage_stones -= amount; inv_stones += amount; }
|
|
else if (item_type == ITEM_LOGS) { storage_logs -= amount; inv_logs += amount; }
|
|
else if (item_type == ITEM_CLAY) { storage_clay -= amount; inv_clay += amount; }
|
|
else if (item_type == ITEM_SMALL_GAME) { storage_small_game -= amount; inv_small_game += amount; move_small_game_to_personal(amount); }
|
|
else if (item_type == ITEM_MEAT) { storage_meat -= amount; inv_meat += amount; }
|
|
else if (item_type == ITEM_SKINS) { storage_skins -= amount; inv_skins += amount; }
|
|
else if (item_type == ITEM_FEATHERS) { storage_feathers -= amount; inv_feathers += amount; }
|
|
else if (item_type == ITEM_DOWN) { storage_down -= amount; inv_down += amount; }
|
|
else if (item_type == ITEM_INCENSE) { storage_incense -= amount; inv_incense += amount; }
|
|
else if (item_type == ITEM_SPEARS) { storage_spears -= amount; inv_spears += amount; }
|
|
else if (item_type == ITEM_SLINGS) { storage_slings -= amount; inv_slings += amount; }
|
|
else if (item_type == ITEM_AXES) { storage_axes -= amount; inv_axes += amount; }
|
|
else if (item_type == ITEM_SNARES) { storage_snares -= amount; inv_snares += amount; }
|
|
else if (item_type == ITEM_KNIVES) { storage_knives -= amount; inv_knives += amount; }
|
|
else if (item_type == ITEM_FISHING_POLES) { storage_fishing_poles -= amount; inv_fishing_poles += amount; }
|
|
else if (item_type == ITEM_ROPES) { storage_ropes -= amount; inv_ropes += amount; }
|
|
else if (item_type == ITEM_REED_BASKETS) { storage_reed_baskets -= amount; inv_reed_baskets += amount; }
|
|
else if (item_type == ITEM_CLAY_POTS) { storage_clay_pots -= amount; inv_clay_pots += amount; }
|
|
else if (item_type == ITEM_SKIN_HATS) { storage_skin_hats -= amount; inv_skin_hats += amount; }
|
|
else if (item_type == ITEM_SKIN_GLOVES) { storage_skin_gloves -= amount; inv_skin_gloves += amount; }
|
|
else if (item_type == ITEM_SKIN_PANTS) { storage_skin_pants -= amount; inv_skin_pants += amount; }
|
|
else if (item_type == ITEM_SKIN_TUNICS) { storage_skin_tunics -= amount; inv_skin_tunics += amount; }
|
|
else if (item_type == ITEM_MOCCASINS) { storage_moccasins -= amount; inv_moccasins += amount; }
|
|
else if (item_type == ITEM_SKIN_POUCHES) { storage_skin_pouches -= amount; inv_skin_pouches += amount; }
|
|
|
|
screen_reader_speak("Withdrew " + amount + " " + get_item_label(item_type) + ".", true);
|
|
}
|
|
|
|
void sacrifice_item(int item_type) {
|
|
int available = get_personal_count(item_type);
|
|
if (available <= 0) {
|
|
screen_reader_speak("Nothing to sacrifice.", true);
|
|
return;
|
|
}
|
|
|
|
if (item_type == ITEM_STICKS) inv_sticks--;
|
|
else if (item_type == ITEM_VINES) inv_vines--;
|
|
else if (item_type == ITEM_REEDS) inv_reeds--;
|
|
else if (item_type == ITEM_STONES) inv_stones--;
|
|
else if (item_type == ITEM_LOGS) inv_logs--;
|
|
else if (item_type == ITEM_CLAY) inv_clay--;
|
|
else if (item_type == ITEM_SMALL_GAME) {
|
|
inv_small_game--;
|
|
if (inv_small_game_types.length() > 0) {
|
|
inv_small_game_types.remove_at(0);
|
|
}
|
|
}
|
|
else if (item_type == ITEM_MEAT) inv_meat--;
|
|
else if (item_type == ITEM_SKINS) inv_skins--;
|
|
else if (item_type == ITEM_FEATHERS) inv_feathers--;
|
|
else if (item_type == ITEM_DOWN) inv_down--;
|
|
else if (item_type == ITEM_INCENSE) inv_incense--;
|
|
else if (item_type == ITEM_SPEARS) inv_spears--;
|
|
else if (item_type == ITEM_SLINGS) inv_slings--;
|
|
else if (item_type == ITEM_AXES) inv_axes--;
|
|
else if (item_type == ITEM_SNARES) inv_snares--;
|
|
else if (item_type == ITEM_KNIVES) inv_knives--;
|
|
else if (item_type == ITEM_FISHING_POLES) inv_fishing_poles--;
|
|
else if (item_type == ITEM_ROPES) inv_ropes--;
|
|
else if (item_type == ITEM_REED_BASKETS) inv_reed_baskets--;
|
|
else if (item_type == ITEM_CLAY_POTS) inv_clay_pots--;
|
|
else if (item_type == ITEM_SKIN_HATS) inv_skin_hats--;
|
|
else if (item_type == ITEM_SKIN_GLOVES) inv_skin_gloves--;
|
|
else if (item_type == ITEM_SKIN_PANTS) inv_skin_pants--;
|
|
else if (item_type == ITEM_SKIN_TUNICS) inv_skin_tunics--;
|
|
else if (item_type == ITEM_MOCCASINS) inv_moccasins--;
|
|
else if (item_type == ITEM_SKIN_POUCHES) inv_skin_pouches--;
|
|
|
|
cleanup_equipment_after_inventory_change();
|
|
double favor_gain = get_item_favor_value(item_type);
|
|
favor += favor_gain;
|
|
screen_reader_speak("Sacrificed 1 " + get_item_label_singular(item_type) + ". Favor +" + format_favor(favor_gain) + ". Total " + format_favor(favor) + ".", true);
|
|
}
|
|
|
|
void build_personal_inventory_options(string[]@ options, int[]@ item_types) {
|
|
options.resize(0);
|
|
item_types.resize(0);
|
|
options.insert_last("Sticks: " + inv_sticks); item_types.insert_last(ITEM_STICKS);
|
|
options.insert_last("Vines: " + inv_vines); item_types.insert_last(ITEM_VINES);
|
|
options.insert_last("Reeds: " + inv_reeds); item_types.insert_last(ITEM_REEDS);
|
|
options.insert_last("Stones: " + inv_stones); item_types.insert_last(ITEM_STONES);
|
|
options.insert_last("Logs: " + inv_logs); item_types.insert_last(ITEM_LOGS);
|
|
options.insert_last("Clay: " + inv_clay); item_types.insert_last(ITEM_CLAY);
|
|
options.insert_last("Small Game: " + inv_small_game); item_types.insert_last(ITEM_SMALL_GAME);
|
|
options.insert_last("Meat: " + inv_meat); item_types.insert_last(ITEM_MEAT);
|
|
options.insert_last("Skins: " + inv_skins); item_types.insert_last(ITEM_SKINS);
|
|
options.insert_last("Feathers: " + inv_feathers); item_types.insert_last(ITEM_FEATHERS);
|
|
options.insert_last("Down: " + inv_down); item_types.insert_last(ITEM_DOWN);
|
|
options.insert_last("Incense: " + inv_incense); item_types.insert_last(ITEM_INCENSE);
|
|
options.insert_last("Spears: " + inv_spears); item_types.insert_last(ITEM_SPEARS);
|
|
options.insert_last("Slings: " + inv_slings); item_types.insert_last(ITEM_SLINGS);
|
|
options.insert_last("Axes: " + inv_axes); item_types.insert_last(ITEM_AXES);
|
|
options.insert_last("Snares: " + inv_snares); item_types.insert_last(ITEM_SNARES);
|
|
options.insert_last("Knives: " + inv_knives); item_types.insert_last(ITEM_KNIVES);
|
|
options.insert_last("Fishing Poles: " + inv_fishing_poles); item_types.insert_last(ITEM_FISHING_POLES);
|
|
options.insert_last("Ropes: " + inv_ropes); item_types.insert_last(ITEM_ROPES);
|
|
options.insert_last("Reed Baskets: " + inv_reed_baskets); item_types.insert_last(ITEM_REED_BASKETS);
|
|
options.insert_last("Clay Pots: " + inv_clay_pots); item_types.insert_last(ITEM_CLAY_POTS);
|
|
options.insert_last("Skin Hats: " + inv_skin_hats); item_types.insert_last(ITEM_SKIN_HATS);
|
|
options.insert_last("Skin Gloves: " + inv_skin_gloves); item_types.insert_last(ITEM_SKIN_GLOVES);
|
|
options.insert_last("Skin Pants: " + inv_skin_pants); item_types.insert_last(ITEM_SKIN_PANTS);
|
|
options.insert_last("Skin Tunics: " + inv_skin_tunics); item_types.insert_last(ITEM_SKIN_TUNICS);
|
|
options.insert_last("Moccasins: " + inv_moccasins); item_types.insert_last(ITEM_MOCCASINS);
|
|
options.insert_last("Skin Pouches: " + inv_skin_pouches); item_types.insert_last(ITEM_SKIN_POUCHES);
|
|
}
|
|
|
|
void build_storage_inventory_options(string[]@ options, int[]@ item_types) {
|
|
options.resize(0);
|
|
item_types.resize(0);
|
|
options.insert_last("Sticks: " + storage_sticks); item_types.insert_last(ITEM_STICKS);
|
|
options.insert_last("Vines: " + storage_vines); item_types.insert_last(ITEM_VINES);
|
|
options.insert_last("Reeds: " + storage_reeds); item_types.insert_last(ITEM_REEDS);
|
|
options.insert_last("Stones: " + storage_stones); item_types.insert_last(ITEM_STONES);
|
|
options.insert_last("Logs: " + storage_logs); item_types.insert_last(ITEM_LOGS);
|
|
options.insert_last("Clay: " + storage_clay); item_types.insert_last(ITEM_CLAY);
|
|
options.insert_last("Small Game: " + storage_small_game); item_types.insert_last(ITEM_SMALL_GAME);
|
|
options.insert_last("Meat: " + storage_meat); item_types.insert_last(ITEM_MEAT);
|
|
options.insert_last("Skins: " + storage_skins); item_types.insert_last(ITEM_SKINS);
|
|
options.insert_last("Feathers: " + storage_feathers); item_types.insert_last(ITEM_FEATHERS);
|
|
options.insert_last("Down: " + storage_down); item_types.insert_last(ITEM_DOWN);
|
|
options.insert_last("Incense: " + storage_incense); item_types.insert_last(ITEM_INCENSE);
|
|
options.insert_last("Spears: " + storage_spears); item_types.insert_last(ITEM_SPEARS);
|
|
options.insert_last("Slings: " + storage_slings); item_types.insert_last(ITEM_SLINGS);
|
|
options.insert_last("Axes: " + storage_axes); item_types.insert_last(ITEM_AXES);
|
|
options.insert_last("Snares: " + storage_snares); item_types.insert_last(ITEM_SNARES);
|
|
options.insert_last("Knives: " + storage_knives); item_types.insert_last(ITEM_KNIVES);
|
|
options.insert_last("Fishing Poles: " + storage_fishing_poles); item_types.insert_last(ITEM_FISHING_POLES);
|
|
options.insert_last("Ropes: " + storage_ropes); item_types.insert_last(ITEM_ROPES);
|
|
options.insert_last("Reed Baskets: " + storage_reed_baskets); item_types.insert_last(ITEM_REED_BASKETS);
|
|
options.insert_last("Clay Pots: " + storage_clay_pots); item_types.insert_last(ITEM_CLAY_POTS);
|
|
options.insert_last("Skin Hats: " + storage_skin_hats); item_types.insert_last(ITEM_SKIN_HATS);
|
|
options.insert_last("Skin Gloves: " + storage_skin_gloves); item_types.insert_last(ITEM_SKIN_GLOVES);
|
|
options.insert_last("Skin Pants: " + storage_skin_pants); item_types.insert_last(ITEM_SKIN_PANTS);
|
|
options.insert_last("Skin Tunics: " + storage_skin_tunics); item_types.insert_last(ITEM_SKIN_TUNICS);
|
|
options.insert_last("Moccasins: " + storage_moccasins); item_types.insert_last(ITEM_MOCCASINS);
|
|
options.insert_last("Skin Pouches: " + storage_skin_pouches); item_types.insert_last(ITEM_SKIN_POUCHES);
|
|
}
|
|
|
|
void show_inventory() {
|
|
string info = "Inventory: ";
|
|
info += inv_sticks + " sticks, ";
|
|
info += inv_vines + " vines, ";
|
|
info += inv_reeds + " reeds, ";
|
|
info += inv_stones + " stones, ";
|
|
info += inv_logs + " logs, ";
|
|
info += inv_clay + " clay, ";
|
|
info += inv_small_game + " small game, ";
|
|
info += inv_meat + " meat, ";
|
|
info += inv_skins + " skins, ";
|
|
info += inv_feathers + " feathers, ";
|
|
info += inv_down + " down, ";
|
|
info += inv_incense + " incense. ";
|
|
info += "Tools: " + inv_spears + " spears, " + inv_slings + " slings, " + inv_axes + " axes, " + inv_snares + " snares, " + inv_knives + " knives, " + inv_fishing_poles + " fishing poles, " + inv_ropes + " ropes, " + inv_reed_baskets + " reed baskets, " + inv_clay_pots + " clay pots. ";
|
|
info += "Clothing: " + inv_skin_hats + " hats, " + inv_skin_gloves + " gloves, " + inv_skin_pants + " pants, " + inv_skin_tunics + " tunics, " + inv_moccasins + " moccasins, " + inv_skin_pouches + " skin pouches.";
|
|
screen_reader_speak(info, true);
|
|
}
|
|
|
|
void run_inventory_root_menu() {
|
|
screen_reader_speak("Inventory menu.", true);
|
|
|
|
int selection = 0;
|
|
string[] options = {"Personal inventory", "Base storage"};
|
|
|
|
while(true) {
|
|
wait(5);
|
|
menu_background_tick();
|
|
if (key_pressed(KEY_ESCAPE)) {
|
|
screen_reader_speak("Closed.", true);
|
|
break;
|
|
}
|
|
|
|
if (key_pressed(KEY_DOWN)) {
|
|
selection++;
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_UP)) {
|
|
selection--;
|
|
if (selection < 0) selection = options.length() - 1;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_RETURN)) {
|
|
if (selection == 0) run_inventory_menu(true);
|
|
else run_storage_menu();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void run_inventory_menu(bool allow_deposit) {
|
|
screen_reader_speak("Inventory menu.", true);
|
|
|
|
int selection = 0;
|
|
string[] options;
|
|
int[] item_types;
|
|
build_personal_inventory_options(options, item_types);
|
|
|
|
while(true) {
|
|
wait(5);
|
|
menu_background_tick();
|
|
if (key_pressed(KEY_ESCAPE)) {
|
|
screen_reader_speak("Closed.", true);
|
|
break;
|
|
}
|
|
|
|
if (key_pressed(KEY_DOWN)) {
|
|
selection++;
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_UP)) {
|
|
selection--;
|
|
if (selection < 0) selection = options.length() - 1;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (allow_deposit && key_pressed(KEY_RETURN)) {
|
|
deposit_item(item_types[selection]);
|
|
build_personal_inventory_options(options, item_types);
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
}
|
|
}
|
|
|
|
void run_storage_menu() {
|
|
if (world_storages.length() == 0) {
|
|
screen_reader_speak("No storage built.", true);
|
|
return;
|
|
}
|
|
|
|
screen_reader_speak("Base storage.", true);
|
|
|
|
int selection = 0;
|
|
string[] options;
|
|
int[] item_types;
|
|
build_storage_inventory_options(options, item_types);
|
|
|
|
while(true) {
|
|
wait(5);
|
|
menu_background_tick();
|
|
if (key_pressed(KEY_ESCAPE)) {
|
|
screen_reader_speak("Closed.", true);
|
|
break;
|
|
}
|
|
|
|
if (key_pressed(KEY_DOWN)) {
|
|
selection++;
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_UP)) {
|
|
selection--;
|
|
if (selection < 0) selection = options.length() - 1;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_RETURN)) {
|
|
withdraw_item(item_types[selection]);
|
|
build_storage_inventory_options(options, item_types);
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
}
|
|
}
|
|
|
|
void check_altar_menu(int player_x) {
|
|
if (!key_pressed(KEY_S)) return;
|
|
|
|
// Must be in base
|
|
if (player_x > BASE_END) {
|
|
screen_reader_speak("Must be in base to use altar.", true);
|
|
return;
|
|
}
|
|
|
|
// Must have altar
|
|
if (world_altars.length() == 0) {
|
|
screen_reader_speak("No altar built.", true);
|
|
return;
|
|
}
|
|
|
|
run_altar_menu();
|
|
}
|
|
|
|
void run_altar_menu() {
|
|
screen_reader_speak("Altar. Favor " + format_favor(favor) + ".", true);
|
|
|
|
int selection = 0;
|
|
string[] options;
|
|
int[] item_types;
|
|
build_personal_inventory_options(options, item_types);
|
|
|
|
while(true) {
|
|
wait(5);
|
|
menu_background_tick();
|
|
if (key_pressed(KEY_ESCAPE)) {
|
|
screen_reader_speak("Closed.", true);
|
|
break;
|
|
}
|
|
|
|
if (key_pressed(KEY_DOWN)) {
|
|
selection++;
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_UP)) {
|
|
selection--;
|
|
if (selection < 0) selection = options.length() - 1;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_RETURN)) {
|
|
sacrifice_item(item_types[selection]);
|
|
build_personal_inventory_options(options, item_types);
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
}
|
|
}
|
|
|
|
void try_place_snare(int x) {
|
|
if (inv_snares > 0) {
|
|
// Prevent placing if one already exists here
|
|
if (get_snare_at(x) != null) {
|
|
screen_reader_speak("There is already a snare here.", true);
|
|
return;
|
|
}
|
|
|
|
inv_snares--;
|
|
add_world_snare(x);
|
|
screen_reader_speak("Snare set.", true);
|
|
} else {
|
|
screen_reader_speak("No snares to place.", true);
|
|
}
|
|
}
|
|
|
|
void try_feed_fire_stick(WorldFire@ fire) {
|
|
if (inv_sticks > 0 && fire != null) {
|
|
inv_sticks--;
|
|
fire.add_fuel(300000); // 5 minutes
|
|
screen_reader_speak("You dump an arm load of sticks into the fire.", true);
|
|
p.play_stationary("sounds/actions/feed_fire.ogg", false);
|
|
}
|
|
}
|
|
|
|
void try_feed_fire_vine(WorldFire@ fire) {
|
|
if (inv_vines > 0 && fire != null) {
|
|
inv_vines--;
|
|
fire.add_fuel(60000); // 1 minute
|
|
screen_reader_speak("You toss a fiew vines and leaves into the fire.", true);
|
|
p.play_stationary("sounds/actions/feed_fire.ogg", false);
|
|
}
|
|
}
|
|
|
|
void try_feed_fire_log(WorldFire@ fire) {
|
|
if (inv_logs > 0 && fire != null) {
|
|
inv_logs--;
|
|
fire.add_fuel(720000); // 12 minutes
|
|
screen_reader_speak("You heave a log into the fire.", true);
|
|
p.play_stationary("sounds/actions/feed_fire.ogg", false);
|
|
}
|
|
}
|
|
|
|
void try_burn_incense() {
|
|
if (world_altars.length() == 0) {
|
|
screen_reader_speak("No altar built.", true);
|
|
return;
|
|
}
|
|
if (inv_clay_pots <= 0) {
|
|
screen_reader_speak("You need a clay pot to burn incense.", true);
|
|
return;
|
|
}
|
|
if (inv_incense <= 0) {
|
|
screen_reader_speak("No incense to burn.", true);
|
|
return;
|
|
}
|
|
|
|
inv_incense--;
|
|
incense_hours_remaining += INCENSE_HOURS_PER_STICK;
|
|
incense_burning = true;
|
|
screen_reader_speak("Incense burning. " + incense_hours_remaining + " hours remaining.", true);
|
|
}
|
|
|
|
void check_equipment_menu() {
|
|
if (key_pressed(KEY_E)) {
|
|
// Check if player has any equipment
|
|
if (inv_spears == 0 && inv_axes == 0 && inv_slings == 0 &&
|
|
inv_skin_hats == 0 && inv_skin_gloves == 0 && inv_skin_pants == 0 &&
|
|
inv_skin_tunics == 0 && inv_moccasins == 0 && inv_skin_pouches == 0) {
|
|
screen_reader_speak("Nothing to equip.", true);
|
|
} else {
|
|
run_equipment_menu();
|
|
}
|
|
}
|
|
}
|
|
|
|
void run_action_menu(int x) {
|
|
screen_reader_speak("Action menu.", true);
|
|
|
|
int selection = 0;
|
|
string[] options;
|
|
int[] action_types; // Track what action each option corresponds to
|
|
|
|
// Check if fire is nearby
|
|
WorldFire@ nearby_fire = get_fire_near(x);
|
|
bool can_feed_fire = nearby_fire != null;
|
|
|
|
// Build menu options dynamically
|
|
options.insert_last("Place Snare");
|
|
action_types.insert_last(0);
|
|
|
|
if (can_feed_fire) {
|
|
if (inv_sticks > 0) {
|
|
options.insert_last("Feed fire with stick");
|
|
action_types.insert_last(1);
|
|
}
|
|
if (inv_vines > 0) {
|
|
options.insert_last("Feed fire with vine");
|
|
action_types.insert_last(2);
|
|
}
|
|
if (inv_logs > 0) {
|
|
options.insert_last("Feed fire with log");
|
|
action_types.insert_last(3);
|
|
}
|
|
}
|
|
|
|
if (x <= BASE_END && world_altars.length() > 0 && inv_incense > 0) {
|
|
options.insert_last("Burn incense");
|
|
action_types.insert_last(4);
|
|
}
|
|
|
|
while(true) {
|
|
wait(5);
|
|
menu_background_tick();
|
|
if (key_pressed(KEY_ESCAPE)) {
|
|
screen_reader_speak("Closed.", true);
|
|
break;
|
|
}
|
|
|
|
if (key_pressed(KEY_DOWN)) {
|
|
selection++;
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_UP)) {
|
|
selection--;
|
|
if (selection < 0) selection = options.length() - 1;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_RETURN)) {
|
|
int action = action_types[selection];
|
|
if (action == 0) {
|
|
try_place_snare(x);
|
|
} else if (action == 1) {
|
|
try_feed_fire_stick(nearby_fire);
|
|
} else if (action == 2) {
|
|
try_feed_fire_vine(nearby_fire);
|
|
} else if (action == 3) {
|
|
try_feed_fire_log(nearby_fire);
|
|
} else if (action == 4) {
|
|
try_burn_incense();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void run_equipment_menu() {
|
|
screen_reader_speak("Equipment menu.", true);
|
|
|
|
int selection = 0;
|
|
string[] options;
|
|
int[] equipment_types;
|
|
|
|
// Build menu dynamically based on what player has
|
|
if (inv_spears > 0) {
|
|
string status = equipment_is_equipped(EQUIP_SPEAR) ? " (equipped)" : "";
|
|
options.insert_last("Spear" + status);
|
|
equipment_types.insert_last(EQUIP_SPEAR);
|
|
}
|
|
if (inv_slings > 0) {
|
|
string status = equipment_is_equipped(EQUIP_SLING) ? " (equipped)" : "";
|
|
options.insert_last("Sling" + status);
|
|
equipment_types.insert_last(EQUIP_SLING);
|
|
}
|
|
if (inv_axes > 0) {
|
|
string status = equipment_is_equipped(EQUIP_AXE) ? " (equipped)" : "";
|
|
options.insert_last("Stone Axe" + status);
|
|
equipment_types.insert_last(EQUIP_AXE);
|
|
}
|
|
if (inv_skin_hats > 0) {
|
|
string status = equipment_is_equipped(EQUIP_HAT) ? " (equipped)" : "";
|
|
options.insert_last("Skin Hat" + status);
|
|
equipment_types.insert_last(EQUIP_HAT);
|
|
}
|
|
if (inv_skin_gloves > 0) {
|
|
string status = equipment_is_equipped(EQUIP_GLOVES) ? " (equipped)" : "";
|
|
options.insert_last("Skin Gloves" + status);
|
|
equipment_types.insert_last(EQUIP_GLOVES);
|
|
}
|
|
if (inv_skin_pants > 0) {
|
|
string status = equipment_is_equipped(EQUIP_PANTS) ? " (equipped)" : "";
|
|
options.insert_last("Skin Pants" + status);
|
|
equipment_types.insert_last(EQUIP_PANTS);
|
|
}
|
|
if (inv_skin_tunics > 0) {
|
|
string status = equipment_is_equipped(EQUIP_TUNIC) ? " (equipped)" : "";
|
|
options.insert_last("Skin Tunic" + status);
|
|
equipment_types.insert_last(EQUIP_TUNIC);
|
|
}
|
|
if (inv_moccasins > 0) {
|
|
string status = equipment_is_equipped(EQUIP_MOCCASINS) ? " (equipped)" : "";
|
|
options.insert_last("Moccasins" + status);
|
|
equipment_types.insert_last(EQUIP_MOCCASINS);
|
|
}
|
|
if (inv_skin_pouches > 0) {
|
|
string status = equipment_is_equipped(EQUIP_POUCH) ? " (equipped)" : "";
|
|
options.insert_last("Skin Pouch" + status);
|
|
equipment_types.insert_last(EQUIP_POUCH);
|
|
}
|
|
|
|
while(true) {
|
|
wait(5);
|
|
menu_background_tick();
|
|
if (key_pressed(KEY_ESCAPE)) {
|
|
screen_reader_speak("Closed.", true);
|
|
break;
|
|
}
|
|
|
|
if (key_pressed(KEY_DOWN)) {
|
|
selection++;
|
|
if (selection >= options.length()) selection = 0;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
if (key_pressed(KEY_UP)) {
|
|
selection--;
|
|
if (selection < 0) selection = options.length() - 1;
|
|
screen_reader_speak(options[selection], true);
|
|
}
|
|
|
|
int slot_index = get_quick_slot_key();
|
|
if (slot_index != -1) {
|
|
int equip_type = equipment_types[selection];
|
|
quick_slots[slot_index] = equip_type;
|
|
screen_reader_speak(get_equipment_name(equip_type) + " set to slot " + slot_index + ".", true);
|
|
}
|
|
|
|
if (key_pressed(KEY_RETURN)) {
|
|
int equip_type = equipment_types[selection];
|
|
if (equipment_is_equipped(equip_type)) {
|
|
unequip_equipment_type(equip_type);
|
|
screen_reader_speak(get_equipment_name(equip_type) + " unequipped.", true);
|
|
} else {
|
|
equip_equipment_type(equip_type);
|
|
screen_reader_speak(get_equipment_name(equip_type) + " equipped.", true);
|
|
}
|
|
update_max_health_from_equipment();
|
|
break;
|
|
}
|
|
}
|
|
}
|