Documentation sort of updated, food consumption also updated for residents.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Base automation helpers
|
||||
int get_daily_food_requirement() {
|
||||
if (residents_count <= 0) return 0;
|
||||
return (residents_count + 1) / 2;
|
||||
return residents_count * 2;
|
||||
}
|
||||
|
||||
void consume_food_for_residents() {
|
||||
|
||||
@@ -5,6 +5,7 @@ void run_materials_menu() {
|
||||
int selection = 0;
|
||||
string[] options = {
|
||||
"Butcher Game [Requires Game, Knife, Fire nearby]",
|
||||
"Arrows (2 Sticks, 4 Feathers, 2 Stones) [Requires Quiver]",
|
||||
"Incense (6 Sticks, 2 Vines, 1 Reed) [Requires Altar]"
|
||||
};
|
||||
|
||||
@@ -30,18 +31,91 @@ void run_materials_menu() {
|
||||
|
||||
if (key_pressed(KEY_RETURN)) {
|
||||
if (selection == 0) butcher_small_game();
|
||||
else if (selection == 1) craft_incense();
|
||||
else if (selection == 1) craft_arrows();
|
||||
else if (selection == 2) craft_incense();
|
||||
break;
|
||||
}
|
||||
|
||||
if (key_pressed(KEY_TAB)) {
|
||||
if (selection == 0) butcher_small_game_max();
|
||||
else if (selection == 1) craft_incense_max();
|
||||
else if (selection == 1) craft_arrows_max();
|
||||
else if (selection == 2) craft_incense_max();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void craft_arrows() {
|
||||
if (get_personal_count(ITEM_QUIVERS) <= 0) {
|
||||
speak_with_history("You need a quiver to craft arrows.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
int currentArrows = get_personal_count(ITEM_ARROWS);
|
||||
int capacity = get_arrow_limit() - currentArrows;
|
||||
if (capacity < ARROWS_PER_CRAFT) {
|
||||
speak_with_history("Not enough quiver capacity for arrows.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
string missing = "";
|
||||
if (get_personal_count(ITEM_STICKS) < 2) missing += "2 sticks ";
|
||||
if (get_personal_count(ITEM_FEATHERS) < 4) missing += "4 feathers ";
|
||||
if (get_personal_count(ITEM_STONES) < 2) missing += "2 stones ";
|
||||
|
||||
if (missing == "") {
|
||||
simulate_crafting(8);
|
||||
add_personal_count(ITEM_STICKS, -2);
|
||||
add_personal_count(ITEM_FEATHERS, -4);
|
||||
add_personal_count(ITEM_STONES, -2);
|
||||
add_personal_count(ITEM_ARROWS, ARROWS_PER_CRAFT);
|
||||
speak_with_history("Crafted " + ARROWS_PER_CRAFT + " arrows.", true);
|
||||
} else {
|
||||
speak_with_history("Missing: " + missing, true);
|
||||
}
|
||||
}
|
||||
|
||||
void craft_arrows_max() {
|
||||
if (get_personal_count(ITEM_QUIVERS) <= 0) {
|
||||
speak_with_history("You need a quiver to craft arrows.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
int currentArrows = get_personal_count(ITEM_ARROWS);
|
||||
int capacity = get_arrow_limit() - currentArrows;
|
||||
int maxByCapacity = capacity / ARROWS_PER_CRAFT;
|
||||
if (maxByCapacity <= 0) {
|
||||
speak_with_history("Not enough quiver capacity for arrows.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
int maxBySticks = get_personal_count(ITEM_STICKS) / 2;
|
||||
int maxByFeathers = get_personal_count(ITEM_FEATHERS) / 4;
|
||||
int maxByStones = get_personal_count(ITEM_STONES) / 2;
|
||||
int maxCraft = maxBySticks;
|
||||
if (maxByFeathers < maxCraft) maxCraft = maxByFeathers;
|
||||
if (maxByStones < maxCraft) maxCraft = maxByStones;
|
||||
if (maxByCapacity < maxCraft) maxCraft = maxByCapacity;
|
||||
|
||||
if (maxCraft <= 0) {
|
||||
string missing = "";
|
||||
if (get_personal_count(ITEM_STICKS) < 2) missing += "2 sticks ";
|
||||
if (get_personal_count(ITEM_FEATHERS) < 4) missing += "4 feathers ";
|
||||
if (get_personal_count(ITEM_STONES) < 2) missing += "2 stones ";
|
||||
speak_with_history("Missing: " + missing, true);
|
||||
return;
|
||||
}
|
||||
|
||||
int totalCost = maxCraft * 8; // 2 sticks + 4 feathers + 2 stones per bundle
|
||||
int craftTime = (totalCost < maxCraft * 4) ? maxCraft * 4 : totalCost;
|
||||
simulate_crafting(craftTime);
|
||||
add_personal_count(ITEM_STICKS, -(maxCraft * 2));
|
||||
add_personal_count(ITEM_FEATHERS, -(maxCraft * 4));
|
||||
add_personal_count(ITEM_STONES, -(maxCraft * 2));
|
||||
add_personal_count(ITEM_ARROWS, ARROWS_PER_CRAFT * maxCraft);
|
||||
speak_with_history("Crafted " + (ARROWS_PER_CRAFT * maxCraft) + " arrows.", true);
|
||||
}
|
||||
|
||||
void craft_incense() {
|
||||
if (world_altars.length() == 0) {
|
||||
speak_with_history("You need an altar to craft incense.", true);
|
||||
|
||||
@@ -9,6 +9,7 @@ void run_tools_menu() {
|
||||
"Stone Axe (1 Stick, 1 Vine, 2 Stones) [Requires Knife]",
|
||||
"Fishing Pole (1 Stick, 2 Vines)",
|
||||
"Rope (3 Vines)",
|
||||
"Quiver (2 Skins, 2 Vines)",
|
||||
"Reed Basket (3 Reeds)",
|
||||
"Clay Pot (3 Clay)"
|
||||
};
|
||||
@@ -39,8 +40,9 @@ void run_tools_menu() {
|
||||
else if (selection == 2) craft_axe();
|
||||
else if (selection == 3) craft_fishing_pole();
|
||||
else if (selection == 4) craft_rope();
|
||||
else if (selection == 5) craft_reed_basket();
|
||||
else if (selection == 6) craft_clay_pot();
|
||||
else if (selection == 5) craft_quiver();
|
||||
else if (selection == 6) craft_reed_basket();
|
||||
else if (selection == 7) craft_clay_pot();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -50,8 +52,9 @@ void run_tools_menu() {
|
||||
else if (selection == 2) craft_axe_max();
|
||||
else if (selection == 3) craft_fishing_pole_max();
|
||||
else if (selection == 4) craft_rope_max();
|
||||
else if (selection == 5) craft_reed_basket_max();
|
||||
else if (selection == 6) craft_clay_pot_max();
|
||||
else if (selection == 5) craft_quiver_max();
|
||||
else if (selection == 6) craft_reed_basket_max();
|
||||
else if (selection == 7) craft_clay_pot_max();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -242,6 +245,57 @@ void craft_rope_max() {
|
||||
speak_with_history("Crafted " + max_craft + " Rope.", true);
|
||||
}
|
||||
|
||||
void craft_quiver() {
|
||||
string missing = "";
|
||||
if (get_personal_count(ITEM_SKINS) < 2) missing += "2 skins ";
|
||||
if (get_personal_count(ITEM_VINES) < 2) missing += "2 vines ";
|
||||
|
||||
if (missing == "") {
|
||||
if (get_personal_count(ITEM_QUIVERS) >= get_personal_stack_limit()) {
|
||||
speak_with_history("You can't carry any more quivers.", true);
|
||||
return;
|
||||
}
|
||||
simulate_crafting(4);
|
||||
add_personal_count(ITEM_SKINS, -2);
|
||||
add_personal_count(ITEM_VINES, -2);
|
||||
add_personal_count(ITEM_QUIVERS, 1);
|
||||
speak_with_history("Crafted a Quiver.", true);
|
||||
} else {
|
||||
speak_with_history("Missing: " + missing, true);
|
||||
}
|
||||
}
|
||||
|
||||
void craft_quiver_max() {
|
||||
if (get_personal_count(ITEM_QUIVERS) >= get_personal_stack_limit()) {
|
||||
speak_with_history("You can't carry any more quivers.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
int maxBySkins = get_personal_count(ITEM_SKINS) / 2;
|
||||
int maxByVines = get_personal_count(ITEM_VINES) / 2;
|
||||
int maxCraft = maxBySkins;
|
||||
if (maxByVines < maxCraft) maxCraft = maxByVines;
|
||||
|
||||
int space = get_personal_stack_limit() - get_personal_count(ITEM_QUIVERS);
|
||||
if (maxCraft > space) maxCraft = space;
|
||||
|
||||
if (maxCraft <= 0) {
|
||||
string missing = "";
|
||||
if (get_personal_count(ITEM_SKINS) < 2) missing += "2 skins ";
|
||||
if (get_personal_count(ITEM_VINES) < 2) missing += "2 vines ";
|
||||
speak_with_history("Missing: " + missing, true);
|
||||
return;
|
||||
}
|
||||
|
||||
int totalCost = maxCraft * 4; // 2 skins + 2 vines per quiver
|
||||
int craftTime = (totalCost < maxCraft * 4) ? maxCraft * 4 : totalCost;
|
||||
simulate_crafting(craftTime);
|
||||
add_personal_count(ITEM_SKINS, -(maxCraft * 2));
|
||||
add_personal_count(ITEM_VINES, -(maxCraft * 2));
|
||||
add_personal_count(ITEM_QUIVERS, maxCraft);
|
||||
speak_with_history("Crafted " + maxCraft + " Quivers.", true);
|
||||
}
|
||||
|
||||
void craft_reed_basket() {
|
||||
string missing = "";
|
||||
if (get_personal_count(ITEM_REEDS) < 3) missing += "3 reeds ";
|
||||
|
||||
@@ -63,6 +63,19 @@ int get_arrow_limit() {
|
||||
return quivers * ARROW_CAPACITY_PER_QUIVER;
|
||||
}
|
||||
|
||||
void clamp_arrows_to_quiver_limit() {
|
||||
int maxArrows = get_arrow_limit();
|
||||
int currentArrows = get_personal_count(ITEM_ARROWS);
|
||||
if (currentArrows <= maxArrows) return;
|
||||
|
||||
set_personal_count(ITEM_ARROWS, maxArrows);
|
||||
if (maxArrows == 0) {
|
||||
speak_with_history("You need a quiver to carry arrows.", true);
|
||||
} else {
|
||||
speak_with_history("You can only carry " + maxArrows + " arrows with your current quivers.", true);
|
||||
}
|
||||
}
|
||||
|
||||
string get_equipment_name(int equip_type) {
|
||||
if (equip_type == EQUIP_SPEAR) return "Spear";
|
||||
if (equip_type == EQUIP_AXE) return "Stone Axe";
|
||||
@@ -274,5 +287,6 @@ void cleanup_equipment_after_inventory_change() {
|
||||
if (get_personal_count(ITEM_MOCCASINS) <= 0) equipped_feet = EQUIP_NONE;
|
||||
if (get_personal_count(ITEM_SKIN_POUCHES) <= 0 && equipped_arms == EQUIP_POUCH) equipped_arms = EQUIP_NONE;
|
||||
if (get_personal_count(ITEM_BACKPACKS) <= 0 && equipped_arms == EQUIP_BACKPACK) equipped_arms = EQUIP_NONE;
|
||||
clamp_arrows_to_quiver_limit();
|
||||
update_max_health_from_equipment();
|
||||
}
|
||||
|
||||
@@ -30,38 +30,15 @@ void sacrifice_item(int item_type) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item_type == ITEM_STICKS) add_personal_count(ITEM_STICKS, -1);
|
||||
else if (item_type == ITEM_VINES) add_personal_count(ITEM_VINES, -1);
|
||||
else if (item_type == ITEM_REEDS) add_personal_count(ITEM_REEDS, -1);
|
||||
else if (item_type == ITEM_STONES) add_personal_count(ITEM_STONES, -1);
|
||||
else if (item_type == ITEM_LOGS) add_personal_count(ITEM_LOGS, -1);
|
||||
else if (item_type == ITEM_CLAY) add_personal_count(ITEM_CLAY, -1);
|
||||
else if (item_type == ITEM_SMALL_GAME) {
|
||||
if (item_type == ITEM_SMALL_GAME) {
|
||||
add_personal_count(ITEM_SMALL_GAME, -1);
|
||||
if (personal_small_game_types.length() > 0) {
|
||||
personal_small_game_types.remove_at(0);
|
||||
}
|
||||
}
|
||||
else if (item_type == ITEM_MEAT) add_personal_count(ITEM_MEAT, -1);
|
||||
else if (item_type == ITEM_SKINS) add_personal_count(ITEM_SKINS, -1);
|
||||
else if (item_type == ITEM_FEATHERS) add_personal_count(ITEM_FEATHERS, -1);
|
||||
else if (item_type == ITEM_DOWN) add_personal_count(ITEM_DOWN, -1);
|
||||
else if (item_type == ITEM_INCENSE) add_personal_count(ITEM_INCENSE, -1);
|
||||
else if (item_type == ITEM_SPEARS) add_personal_count(ITEM_SPEARS, -1);
|
||||
else if (item_type == ITEM_SLINGS) add_personal_count(ITEM_SLINGS, -1);
|
||||
else if (item_type == ITEM_AXES) add_personal_count(ITEM_AXES, -1);
|
||||
else if (item_type == ITEM_SNARES) add_personal_count(ITEM_SNARES, -1);
|
||||
else if (item_type == ITEM_KNIVES) add_personal_count(ITEM_KNIVES, -1);
|
||||
else if (item_type == ITEM_FISHING_POLES) add_personal_count(ITEM_FISHING_POLES, -1);
|
||||
else if (item_type == ITEM_ROPES) add_personal_count(ITEM_ROPES, -1);
|
||||
else if (item_type == ITEM_REED_BASKETS) add_personal_count(ITEM_REED_BASKETS, -1);
|
||||
else if (item_type == ITEM_CLAY_POTS) add_personal_count(ITEM_CLAY_POTS, -1);
|
||||
else if (item_type == ITEM_SKIN_HATS) add_personal_count(ITEM_SKIN_HATS, -1);
|
||||
else if (item_type == ITEM_SKIN_GLOVES) add_personal_count(ITEM_SKIN_GLOVES, -1);
|
||||
else if (item_type == ITEM_SKIN_PANTS) add_personal_count(ITEM_SKIN_PANTS, -1);
|
||||
else if (item_type == ITEM_SKIN_TUNICS) add_personal_count(ITEM_SKIN_TUNICS, -1);
|
||||
else if (item_type == ITEM_MOCCASINS) add_personal_count(ITEM_MOCCASINS, -1);
|
||||
else if (item_type == ITEM_SKIN_POUCHES) add_personal_count(ITEM_SKIN_POUCHES, -1);
|
||||
else {
|
||||
add_personal_count(item_type, -1);
|
||||
}
|
||||
|
||||
cleanup_equipment_after_inventory_change();
|
||||
double favor_gain = get_item_favor_value(item_type);
|
||||
@@ -82,36 +59,13 @@ void sacrifice_item_max(int item_type) {
|
||||
|
||||
double favor_per_item = get_item_favor_value(item_type);
|
||||
|
||||
if (item_type == ITEM_STICKS) { set_personal_count(ITEM_STICKS, 0); }
|
||||
else if (item_type == ITEM_VINES) { set_personal_count(ITEM_VINES, 0); }
|
||||
else if (item_type == ITEM_REEDS) { set_personal_count(ITEM_REEDS, 0); }
|
||||
else if (item_type == ITEM_STONES) { set_personal_count(ITEM_STONES, 0); }
|
||||
else if (item_type == ITEM_LOGS) { set_personal_count(ITEM_LOGS, 0); }
|
||||
else if (item_type == ITEM_CLAY) { set_personal_count(ITEM_CLAY, 0); }
|
||||
else if (item_type == ITEM_SMALL_GAME) {
|
||||
if (item_type == ITEM_SMALL_GAME) {
|
||||
set_personal_count(ITEM_SMALL_GAME, 0);
|
||||
personal_small_game_types.resize(0);
|
||||
}
|
||||
else if (item_type == ITEM_MEAT) { set_personal_count(ITEM_MEAT, 0); }
|
||||
else if (item_type == ITEM_SKINS) { set_personal_count(ITEM_SKINS, 0); }
|
||||
else if (item_type == ITEM_FEATHERS) { set_personal_count(ITEM_FEATHERS, 0); }
|
||||
else if (item_type == ITEM_DOWN) { set_personal_count(ITEM_DOWN, 0); }
|
||||
else if (item_type == ITEM_INCENSE) { set_personal_count(ITEM_INCENSE, 0); }
|
||||
else if (item_type == ITEM_SPEARS) { set_personal_count(ITEM_SPEARS, 0); }
|
||||
else if (item_type == ITEM_SLINGS) { set_personal_count(ITEM_SLINGS, 0); }
|
||||
else if (item_type == ITEM_AXES) { set_personal_count(ITEM_AXES, 0); }
|
||||
else if (item_type == ITEM_SNARES) { set_personal_count(ITEM_SNARES, 0); }
|
||||
else if (item_type == ITEM_KNIVES) { set_personal_count(ITEM_KNIVES, 0); }
|
||||
else if (item_type == ITEM_FISHING_POLES) { set_personal_count(ITEM_FISHING_POLES, 0); }
|
||||
else if (item_type == ITEM_ROPES) { set_personal_count(ITEM_ROPES, 0); }
|
||||
else if (item_type == ITEM_REED_BASKETS) { set_personal_count(ITEM_REED_BASKETS, 0); }
|
||||
else if (item_type == ITEM_CLAY_POTS) { set_personal_count(ITEM_CLAY_POTS, 0); }
|
||||
else if (item_type == ITEM_SKIN_HATS) { set_personal_count(ITEM_SKIN_HATS, 0); }
|
||||
else if (item_type == ITEM_SKIN_GLOVES) { set_personal_count(ITEM_SKIN_GLOVES, 0); }
|
||||
else if (item_type == ITEM_SKIN_PANTS) { set_personal_count(ITEM_SKIN_PANTS, 0); }
|
||||
else if (item_type == ITEM_SKIN_TUNICS) { set_personal_count(ITEM_SKIN_TUNICS, 0); }
|
||||
else if (item_type == ITEM_MOCCASINS) { set_personal_count(ITEM_MOCCASINS, 0); }
|
||||
else if (item_type == ITEM_SKIN_POUCHES) { set_personal_count(ITEM_SKIN_POUCHES, 0); }
|
||||
else {
|
||||
set_personal_count(item_type, 0);
|
||||
}
|
||||
|
||||
cleanup_equipment_after_inventory_change();
|
||||
double total_favor = favor_per_item * available;
|
||||
|
||||
@@ -166,7 +166,16 @@ void withdraw_item(int item_type) {
|
||||
speak_with_history("Nothing to withdraw.", true);
|
||||
return;
|
||||
}
|
||||
int capacity = get_personal_stack_limit() - get_personal_count(item_type);
|
||||
int capacity = 0;
|
||||
if (item_type == ITEM_ARROWS) {
|
||||
capacity = get_arrow_limit() - get_personal_count(ITEM_ARROWS);
|
||||
if (capacity <= 0) {
|
||||
speak_with_history("You can't carry any more arrows.", true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
capacity = get_personal_stack_limit() - get_personal_count(item_type);
|
||||
}
|
||||
if (capacity <= 0) {
|
||||
speak_with_history("You can't carry any more " + get_item_label(item_type) + ".", true);
|
||||
return;
|
||||
@@ -212,9 +221,20 @@ void withdraw_item_max(int item_type) {
|
||||
return;
|
||||
}
|
||||
|
||||
int personal_limit = get_personal_stack_limit();
|
||||
int current_personal = get_personal_count(item_type);
|
||||
int space = personal_limit - current_personal;
|
||||
int personalLimit = 0;
|
||||
int currentPersonal = 0;
|
||||
if (item_type == ITEM_ARROWS) {
|
||||
personalLimit = get_arrow_limit();
|
||||
currentPersonal = get_personal_count(ITEM_ARROWS);
|
||||
if (personalLimit <= 0) {
|
||||
speak_with_history("You need a quiver to carry arrows.", true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
personalLimit = get_personal_stack_limit();
|
||||
currentPersonal = get_personal_count(item_type);
|
||||
}
|
||||
int space = personalLimit - currentPersonal;
|
||||
|
||||
if (space <= 0) {
|
||||
speak_with_history("Can't carry any more.", true);
|
||||
|
||||
@@ -406,6 +406,8 @@ void update_time() {
|
||||
attempt_resident_collection();
|
||||
}
|
||||
|
||||
ensure_ambience_running();
|
||||
|
||||
// Proactive resident defense with slings
|
||||
attempt_resident_sling_defense();
|
||||
|
||||
@@ -533,6 +535,9 @@ void complete_crossfade() {
|
||||
}
|
||||
if (night_sound_handle != -1) p.update_sound_start_values(night_sound_handle, 0.0, 0.0, 1.0);
|
||||
is_daytime = false;
|
||||
if (night_sound_handle == -1 || !p.sound_is_active(night_sound_handle)) {
|
||||
update_ambience(false);
|
||||
}
|
||||
} else {
|
||||
// Destroy night sound, ensure day is at full volume
|
||||
if (night_sound_handle != -1) {
|
||||
@@ -541,6 +546,23 @@ void complete_crossfade() {
|
||||
}
|
||||
if (day_sound_handle != -1) p.update_sound_start_values(day_sound_handle, 0.0, 0.0, 1.0);
|
||||
is_daytime = true;
|
||||
if (day_sound_handle == -1 || !p.sound_is_active(day_sound_handle)) {
|
||||
update_ambience(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ensure_ambience_running() {
|
||||
if (crossfade_active) return;
|
||||
|
||||
if (is_daytime) {
|
||||
if (day_sound_handle == -1 || !p.sound_is_active(day_sound_handle)) {
|
||||
update_ambience(false);
|
||||
}
|
||||
} else {
|
||||
if (night_sound_handle == -1 || !p.sound_is_active(night_sound_handle)) {
|
||||
update_ambience(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user