Pets a lot nicer now, hopefully most of the bugs fixed.
This commit is contained in:
@@ -806,6 +806,8 @@ bool save_game_state() {
|
||||
saveData.set("pet_type", petType);
|
||||
saveData.set("pet_gender", petGender);
|
||||
saveData.set("pet_loyalty", petLoyalty);
|
||||
saveData.set("pet_health", petHealth);
|
||||
saveData.set("pet_ko_hours_remaining", petKnockoutHoursRemaining);
|
||||
|
||||
// Save inventory arrays using new compact format
|
||||
saveData.set("personal_inventory", serialize_inventory_array(personal_inventory));
|
||||
@@ -1129,11 +1131,15 @@ bool load_game_state_from_file(const string&in filename) {
|
||||
petGender = loadedPetGender;
|
||||
}
|
||||
petLoyalty = int(get_number(saveData, "pet_loyalty", 0));
|
||||
petHealth = int(get_number(saveData, "pet_health", PET_HEALTH_MAX));
|
||||
petKnockoutHoursRemaining = int(get_number(saveData, "pet_ko_hours_remaining", 0));
|
||||
if (!petActive) {
|
||||
petSoundPath = "";
|
||||
petType = "";
|
||||
petGender = "";
|
||||
petLoyalty = 0;
|
||||
petHealth = 0;
|
||||
petKnockoutHoursRemaining = 0;
|
||||
}
|
||||
if (petActive && petSoundPath != "" && !file_exists(petSoundPath)) {
|
||||
petActive = false;
|
||||
@@ -1141,8 +1147,20 @@ bool load_game_state_from_file(const string&in filename) {
|
||||
petType = "";
|
||||
petGender = "";
|
||||
petLoyalty = 0;
|
||||
petHealth = 0;
|
||||
petKnockoutHoursRemaining = 0;
|
||||
}
|
||||
if (petActive) {
|
||||
if (petKnockoutHoursRemaining < 0) petKnockoutHoursRemaining = 0;
|
||||
if (petKnockoutHoursRemaining > PET_KNOCKOUT_COOLDOWN_HOURS) {
|
||||
petKnockoutHoursRemaining = PET_KNOCKOUT_COOLDOWN_HOURS;
|
||||
}
|
||||
if (petKnockoutHoursRemaining > 0) {
|
||||
petHealth = 0;
|
||||
} else {
|
||||
if (petHealth <= 0) petHealth = PET_HEALTH_MAX;
|
||||
if (petHealth > PET_HEALTH_MAX) petHealth = PET_HEALTH_MAX;
|
||||
}
|
||||
petAttackTimer.restart();
|
||||
petRetrieveTimer.restart();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user