Skip to content

Commit

Permalink
Fix the division by 0 in Chest Mimic tile if the experience gain is zero
Browse files Browse the repository at this point in the history
If the experience gain is equal to 0 (for instance, by equipping a tiny consolation ribbon without having Testidunal Teachings permed), the Chest Mimic tile still tries to divide the experience needed for the next egg by the experience gain, generating a division by 0 error and crashing the script.
Fixed so that if the experience gain is 0 or less, the tile says you cannot get the XP.
  • Loading branch information
Semenar committed Aug 18, 2024
1 parent f17e9c3 commit aba3284
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ void IOTMChestMimicGenerateResource(ChecklistEntry [int] resource_entries)
int famExperienceGain = numeric_modifier("familiar experience") + 1;
int chestExperience = ($familiar[chest mimic].experience);
int famExpNeededForNextEgg = (50 - (chestExperience % 50));
string fightsForNextEgg = pluralise(ceil(to_float(famExpNeededForNextEgg) / famExperienceGain), "fight", "fights");
string fightsForNextEgg;
if (famExperienceGain > 0) {
fightsForNextEgg = pluralise(ceil(to_float(famExpNeededForNextEgg) / famExperienceGain), "fight", "fights");
}
else {
fightsForNextEgg = "cannot get";
}
int mimicEggsLeft = clampi(11 - get_property_int("_mimicEggsObtained"), 0, 11);

string [int] description;
Expand Down

0 comments on commit aba3284

Please sign in to comment.