Skip to content

feat: deprecate team transfer, add sharing hooks#2528

Closed
keithharvey wants to merge 3 commits into
beyond-all-reason:masterfrom
keithharvey:team_transfer
Closed

feat: deprecate team transfer, add sharing hooks#2528
keithharvey wants to merge 3 commits into
beyond-all-reason:masterfrom
keithharvey:team_transfer

Conversation

@keithharvey

Copy link
Copy Markdown
Contributor

The idea is to let LUA take over the team transfer logic, and to deprecate the engine's team transfer logic.

  • followed the breadcrumbs for everything CHANGETEAM_REASON and deprecated all call paths.
  • added new SYNCED_ACTION_FALLBACKS for specific actions (income happens from reclaim, overflow happens)
  • the goal is no breaking changes.

The idea is to let LUA take over the team transfer logic, and to deprecate the engine's team transfer logic.
@keithharvey keithharvey changed the title feat: deprecate team transfer in engine feat: deprecate team transfer, add sharing hooks Aug 14, 2025
@keithharvey keithharvey marked this pull request as draft August 14, 2025 22:34
AllowUnitTransfer should no longer be useful for the LUA implementation, which just expects the engine to do as told.
@sprunk

sprunk commented Aug 15, 2025

Copy link
Copy Markdown
Collaborator

tl;dr I made #2529, #2530, #2531 and #2532 and I think these should allow you to do everything you want.

  • NetResourceTransfer is somewhat redundant with AllowResourceTransfer. The caveat is that there's two places AllowResourceTransfer can be called from, synced Lua and manual sharing, so you can't tell which is which. I think this is better solved by making it not called from synced Lua, since it can still be called manually if needed (but usually synced Lua wouldn't do silly changes it would later block itself?) and that guarantees that all calls come from manual requests. This is achieved by Spring.ShareTeamResource no longer triggers AllowResourceTransfer #2531.
  • similarly NetShareTransfer is mostly redundant with AllowUnitTransfer but you can't tell whether it came from manual individual share, manual "give everything" or /take. I think the best approach here is to extend the "allow take" modrule to "give everything" since they overlap heavily and on some level are the same thing (if people disagree it can also just be a separate bool). See Add system.allowGiveawayResign to block "resign and give everything to X" #2532.
  • PR description says that there's now some way to handle resource overflows but I can't find it in the code. Anyway I think that's best handled by Add 'system.nativeExcessSharing' modrule #2529 and Add gadget:TeamResourceExcess(teamID, metal, energy) -> bool #2530.
  • income from reclaim is already doable in Lua by setting reclaim efficiency to 0 and using Allow{Unit,Feature}BuildStep, or UnitDestroyed with weaponDefID == reclaimed.
  • Spring.ChangeTeamWithReason is already doable entirely in Lua as per refactor: move /take and /give to LUA #2423 (comment), if you're not sure how to translate that e.g. into BAR then I could make a little example PR there too
  • there's some /give change, but that is unrelated to /take so shouldn't be touched.
  • there's also some /capture change. I'm not sure what it is about, if it's about this comment then what I meant by "capture handling" was not a text action but a Lua reimplementation of the mechanics behind the CMD_CAPTURE unit order, including the application and tracking of capture buildpower.
  • there's a bunch of other somewhat chaotic changes, these would ideally be individual PRs if desired.

@keithharvey

Copy link
Copy Markdown
Contributor Author

Spring.ChangeTeamWithReason is already doable entirely in Lua as per #2423 (comment), if you're not sure how to translate that e.g. into BAR then I could make a little example PR there too

Nah sorry I meant to remove that entirely.

there's also some /capture change. I'm not sure what it is about, if it's about #2423 (comment) then what I meant by "capture handling" was not a text action but a Lua reimplementation of the mechanics behind the CMD_CAPTURE unit order, including the application and tracking of capture buildpower.

Yes, I'm working on the re-implementation of the CAPTURE mechanics.

income from reclaim is already doable in Lua by setting reclaim efficiency to 0 and using Allow{Unit,Feature}BuildStep, or UnitDestroyed with weaponDefID == reclaimed.

Cool.

https://github.com/beyond-all-reason/Beyond-All-Reason/pull/5667/files#diff-d445230470af67515fb8e9687ea31988696c94e85a331a22ad66ebcf481f85a8R33

some way to handle resource overflows

Whoops you're right that didn't make it in but that sounds like it might be OK: https://github.com/beyond-all-reason/Beyond-All-Reason/pull/5667/files#diff-d445230470af67515fb8e9687ea31988696c94e85a331a22ad66ebcf481f85a8R33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants