Refactor complete. Time for bug huntin'
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
// Equipment menu system
|
||||
// Functions for managing equipment (weapons and clothing)
|
||||
|
||||
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) {
|
||||
speak_with_history("Nothing to equip.", true);
|
||||
} else {
|
||||
run_equipment_menu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void run_equipment_menu() {
|
||||
speak_with_history("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)) {
|
||||
speak_with_history("Closed.", true);
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int slot_index = get_quick_slot_key();
|
||||
if (slot_index != -1) {
|
||||
int equip_type = equipment_types[selection];
|
||||
quick_slots[slot_index] = equip_type;
|
||||
speak_with_history(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);
|
||||
speak_with_history(get_equipment_name(equip_type) + " unequipped.", true);
|
||||
} else {
|
||||
equip_equipment_type(equip_type);
|
||||
speak_with_history(get_equipment_name(equip_type) + " equipped.", true);
|
||||
}
|
||||
update_max_health_from_equipment();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user