Rework xeno guaranteed slots logic and Fix thunderdome evolution slot bug #4206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About the pull request
This PR reworks the logic regarding guaranteed xeno slots. Before, the issue was that there was a discrepancy between gibbing/deletion and regular death (meaning not getting gibbed wouldn't free up a free slot). Now that logic is unified via using hive.remove_xeno and the used_free_slots now is just a count of slots used for a caste rather than trying to keep the calculation always correct. This avoids the messiness of handing the free slot usage to say the other burrower when there are two rather than one then freeing a slot.
Additionally, I encountered a bug during testing where evolution in the thunderdome would alter a hive's slots (and the effect would only show in hive_status after a xeno count update on add/removal), but that is also resolved.
See Testing section below to confirm logic, see reproduction for the t-dome fix, and then retesting.
Explain why it's good for the game
Should fix #398
Testing Photographs and Procedure
Steps 1-9:
1: Initial hive spawned in:
2: Evo a drone to burrower (free slot used):
3: Evo another drone to burrower (tier 2 slot used):
4: First burrower is killed:
5: Second burrower is gibbed:
6: Evo another drone to burrower (free slot used - I also tried deleting the burrower corpse afterwards to see if it affected anything):
7: Evo a drone to hivelord (free slot used):
8: Spawned a carrier and drone in t-dome, and evolved that drone to carrier (no effect on hive slots):
9: Killed and gibbed the t-dome carriers (no effect on hive slots):
Steps 10-14 Before thunderdome fix:
10: !! De-evolve a drone to larva (t2 slots went down - unintended): !!
11: !! Evolve larva to runner (no effect on hive slots - unintended or should have restored to slot counts in previous step): !!
12: Evolve runner to lurker and correctly failed attempt to evolve to ravager (t2 slot used):
13: Evolve another drone to burrower (last tier 2 slot used):
14: Correctly failed attempt to evolve to hivelord, but successful evolution from drone to carrier (last guaranteed slot used):
Steps 10-15 After thunderdome fix:
Steps 1-9 are identical.
10: De-evolve a drone to larva (correctly didn't change slot values because of tdome evolution):
11: Evolve larva to runner (no effect on slots):
12: Evolve runner to lurker and correctly failed attempt to evolve to ravager (t2 slot used):
13: Evolve another drone to burrower (tier 2 slot used):
14: Evolve another drone to burrower (last tier 2 slot used):
15: Correctly failed attempt to evolve to hivelord, but successful evolution from drone to carrier (last guaranteed slot used):
Changelog
🆑 Drathek
fix: Fix/Rework logic regarding xeno guaranteed slots
fix: Fix evolution in thunder dome affecting hive slots
/:cl: