Initial implementation of fishing system. A couple bugs fixed, e.g. zombies that are killed by residents actually die.
This commit is contained in:
@@ -173,6 +173,24 @@ void reset_game_state() {
|
||||
rope_climb_sound_handle = -1;
|
||||
pending_rope_climb_x = -1;
|
||||
pending_rope_climb_elevation = 0;
|
||||
is_casting = false;
|
||||
line_in_water = false;
|
||||
fish_on_line = false;
|
||||
is_reeling = false;
|
||||
cast_position = -1;
|
||||
reel_position = -1;
|
||||
cast_origin_x = -1;
|
||||
cast_direction = 0;
|
||||
reel_direction = 0;
|
||||
reel_start_direction = 0;
|
||||
target_stream_start = -1;
|
||||
target_stream_end = -1;
|
||||
catch_chance = 0;
|
||||
hooked_fish_type = "";
|
||||
if (cast_sound_handle != -1) {
|
||||
p.destroy_sound(cast_sound_handle);
|
||||
cast_sound_handle = -1;
|
||||
}
|
||||
|
||||
player_health = 10;
|
||||
base_max_health = 10;
|
||||
@@ -190,6 +208,7 @@ void reset_game_state() {
|
||||
axe_equipped = false;
|
||||
sling_equipped = false;
|
||||
bow_equipped = false;
|
||||
fishing_pole_equipped = false;
|
||||
equipped_head = EQUIP_NONE;
|
||||
equipped_torso = EQUIP_NONE;
|
||||
equipped_arms = EQUIP_NONE;
|
||||
@@ -257,7 +276,7 @@ string serialize_tree(Tree@ tree) {
|
||||
}
|
||||
|
||||
string serialize_snare(WorldSnare@ snare) {
|
||||
return snare.position + "|" + serialize_bool(snare.has_catch) + "|" + snare.catch_type + "|" + snare.catch_chance + "|" + snare.escape_chance + "|" + serialize_bool(snare.active);
|
||||
return snare.position + "|" + serialize_bool(snare.has_catch) + "|" + snare.catch_type + "|" + snare.catch_chance + "|" + snare.escape_chance + "|" + serialize_bool(snare.active) + "|" + snare.hours_with_catch;
|
||||
}
|
||||
|
||||
string serialize_fire(WorldFire@ fire) {
|
||||
@@ -370,11 +389,22 @@ bool save_game_state() {
|
||||
saveData.set("storage_inventory", serialize_inventory_array(storage_inventory));
|
||||
saveData.set("personal_small_game_types", join_string_array(personal_small_game_types));
|
||||
saveData.set("storage_small_game_types", join_string_array(storage_small_game_types));
|
||||
string[] personalFishWeightsData;
|
||||
for (uint i = 0; i < personal_fish_weights.length(); i++) {
|
||||
personalFishWeightsData.insert_last("" + personal_fish_weights[i]);
|
||||
}
|
||||
saveData.set("personal_fish_weights", join_string_array(personalFishWeightsData));
|
||||
string[] storageFishWeightsData;
|
||||
for (uint i = 0; i < storage_fish_weights.length(); i++) {
|
||||
storageFishWeightsData.insert_last("" + storage_fish_weights[i]);
|
||||
}
|
||||
saveData.set("storage_fish_weights", join_string_array(storageFishWeightsData));
|
||||
|
||||
saveData.set("equipment_spear_equipped", spear_equipped);
|
||||
saveData.set("equipment_axe_equipped", axe_equipped);
|
||||
saveData.set("equipment_sling_equipped", sling_equipped);
|
||||
saveData.set("equipment_bow_equipped", bow_equipped);
|
||||
saveData.set("equipment_fishing_pole_equipped", fishing_pole_equipped);
|
||||
saveData.set("equipment_head", equipped_head);
|
||||
saveData.set("equipment_torso", equipped_torso);
|
||||
saveData.set("equipment_arms", equipped_arms);
|
||||
@@ -649,10 +679,41 @@ bool load_game_state() {
|
||||
set_storage_count(ITEM_SMALL_GAME, int(storage_small_game_types.length()));
|
||||
}
|
||||
|
||||
string[] loadedPersonalFishWeights = get_string_list_or_split(saveData, "personal_fish_weights");
|
||||
personal_fish_weights.resize(0);
|
||||
for (uint i = 0; i < loadedPersonalFishWeights.length(); i++) {
|
||||
personal_fish_weights.insert_last(parse_int(loadedPersonalFishWeights[i]));
|
||||
}
|
||||
int personal_fish_count = get_personal_count(ITEM_FISH);
|
||||
if (personal_fish_weights.length() < personal_fish_count) {
|
||||
int missing = personal_fish_count - int(personal_fish_weights.length());
|
||||
for (int i = 0; i < missing; i++) {
|
||||
personal_fish_weights.insert_last(get_default_fish_weight());
|
||||
}
|
||||
} else if (personal_fish_weights.length() > personal_fish_count) {
|
||||
personal_fish_weights.resize(personal_fish_count);
|
||||
}
|
||||
|
||||
string[] loadedStorageFishWeights = get_string_list_or_split(saveData, "storage_fish_weights");
|
||||
storage_fish_weights.resize(0);
|
||||
for (uint i = 0; i < loadedStorageFishWeights.length(); i++) {
|
||||
storage_fish_weights.insert_last(parse_int(loadedStorageFishWeights[i]));
|
||||
}
|
||||
int storage_fish_count = get_storage_count(ITEM_FISH);
|
||||
if (storage_fish_weights.length() < storage_fish_count) {
|
||||
int missing = storage_fish_count - int(storage_fish_weights.length());
|
||||
for (int i = 0; i < missing; i++) {
|
||||
storage_fish_weights.insert_last(get_default_fish_weight());
|
||||
}
|
||||
} else if (storage_fish_weights.length() > storage_fish_count) {
|
||||
storage_fish_weights.resize(storage_fish_count);
|
||||
}
|
||||
|
||||
spear_equipped = get_bool(saveData, "equipment_spear_equipped", false);
|
||||
axe_equipped = get_bool(saveData, "equipment_axe_equipped", false);
|
||||
sling_equipped = get_bool(saveData, "equipment_sling_equipped", false);
|
||||
bow_equipped = get_bool(saveData, "equipment_bow_equipped", false);
|
||||
fishing_pole_equipped = get_bool(saveData, "equipment_fishing_pole_equipped", false);
|
||||
equipped_head = int(get_number(saveData, "equipment_head", EQUIP_NONE));
|
||||
equipped_torso = int(get_number(saveData, "equipment_torso", EQUIP_NONE));
|
||||
equipped_arms = int(get_number(saveData, "equipment_arms", EQUIP_NONE));
|
||||
@@ -666,7 +727,7 @@ bool load_game_state() {
|
||||
if (slot_count > quick_slots.length()) slot_count = quick_slots.length();
|
||||
for (uint i = 0; i < slot_count; i++) {
|
||||
int slot_value = parse_int(loadedQuickSlots[i]);
|
||||
if (slot_value >= EQUIP_NONE && slot_value <= EQUIP_BACKPACK) {
|
||||
if (slot_value >= EQUIP_NONE && slot_value <= EQUIP_FISHING_POLE) {
|
||||
quick_slots[i] = slot_value;
|
||||
}
|
||||
}
|
||||
@@ -795,7 +856,11 @@ bool load_game_state() {
|
||||
snare.catch_chance = parse_int(parts[3]);
|
||||
snare.escape_chance = parse_int(parts[4]);
|
||||
snare.active = (parse_int(parts[5]) == 1);
|
||||
snare.minute_timer.restart();
|
||||
// Load hours_with_catch if available (for backwards compatibility with old saves)
|
||||
if (parts.length() >= 7) {
|
||||
snare.hours_with_catch = parse_int(parts[6]);
|
||||
}
|
||||
snare.hour_timer.restart();
|
||||
world_snares.insert_last(snare);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user