Repository navigation
Conversation
Changing a hatched egg's army creates a new egg whose OnStopBeingBuilt spawns the egg's unit again. Hatched eggs now set `NoTransfer`, which TransferUnitsOwnership skips and the ChangeUnitArmy hook refuses even with noRestrictions. They also become unselectable and uncapturable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Pre-merge checks:
|
Member
|
Can you rename the flag to |
Matches the flag the coop mod already uses and the existing CanBeKilled and CanTakeDamage flags: it defaults to true on the Unit class, and false blocks the transfer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Renamed to |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of the proposed changes
Fixes the "spawning mass" Megalith exploit (https://youtu.be/4TkXWnxNBxE).
Cause. When a Megalith egg (
xrl0002-xrl0005,CConstructionEggUnit) finishes,OnStopBeingBuiltspawns its unit right away, then plays the open and sink animations and destroys the egg. During those animations the egg is still a selectable, fully built unit, so it can be given to an ally.ChangeUnitArmyreplaces it with a new, fully built egg, whoseOnStopBeingBuiltspawns the unit a second time. Each transfer during the animation gives a free unit.Fix.
CanBeGivenfield,trueby default on theUnitclass likeCanBeKilledandCanTakeDamage. The coop mod already uses this name. A hatched egg sets it tofalseinOnStopBeingBuilt, before it spawns the unit.TransferUnitsOwnershipskips units withCanBeGivenset tofalse. Every transfer goes through it: manual gifts, full share on defeat, captures.ChangeUnitArmyhook inSimHooks.luarefuses those units too, even withnoRestrictions. This covers the callers that skipTransferUnitsOwnership:MergeArmyPairinsimInit.lua,ScenarioFramework.GiveUnitToArmyand the Sorian AI.ScenarioFramework.GiveUnitToArmyno longer callsOnGivenwith a nil unit whenChangeUnitArmyrefuses the transfer. This also applied to command units before.Choices made:
OnKilledalready leaves no wreck for an egg that has spawned its unit.TransferUnitsOwnershipalready skipped units under 100% complete, and on defeat they're rebuilt for the receiver byTransferUnfinishedUnitsAfterDeath. They hatch once there.CanBeGivenis a general unit field, so other units can opt out of transfers the same way. The coop mod's ownCanBeGivenhook stays compatible: it sets the same field totrueinOnCreate.Testing done on the proposed changes
Tested on 3e295e3 with the faf-re dev engine. Repro on
develop(69a6628) first.Setup:
openworldsix.v0002with no AI, so army 2 is the civilianARMY_17. The tests make it an ally, so the units don't fight. With the mouse near your ACU, run this. It builds an egg with a Megalith, tries to give it at 50% and after it finishes, then gives an egg on the tick it's created, then callsChangeUnitArmy(egg, 2, true)the way army merges do. It logs T3 Engineer (url0309, what thexrl0002egg hatches) counts per army after each step:developTransferUnitsOwnershipskips units under 100%)selectable= false)GiveUnitsToPlayer, then share another hatching egg withTransferUnitsToHighestBrain(the defeat path). Ondevelopthis gives the ally 2 engineers and then 4, one extra per egg:mine= 0 ally= 1)mine= 0 ally= 2). The egg stays in army 1 and finishes sinking (egg2 dead= true)developdoesn't also logNot tested in a campaign (
ScenarioFramework.GiveUnitToArmy) or withMergeArmyPair: both callChangeUnitArmy, and step 2 covers the hook withnoRestrictions.Checklist
🤖 Generated with Claude Code