T2 Constructor Sharing Mode#4447
Conversation
|
@WatchTheFort cleaned this up and it's now ready for you to review |
|
Thank you @badosu for all of your help! |
|
Overall LGTM, some small things to address, up to the author but in general looks solid! |
a678d95 to
f964adc
Compare
0824d92 to
8520a4d
Compare
|
Moving into widgets necessitated a common set of helper functions, which is all good.
This is hard. Like why won't it redraw? I tried to make it dynamic then I tried to separate commands, neither redrew on selection. Not sure whatsup with that but Imma give up and work on something else.
@thehobojoe feel free to integrate this into another PR or merge this one. I think maybe we change the PR target of this and metal_send_threshold and emp to a new branch you create tonight (combined_mod_options?) that we can then rebase on top of with some of this other chobby/organizational work. I rebased this one too and I think both are ready to roll. |
8520a4d to
97826bc
Compare
Redraw already happens on every selection change. You can see how to accomplish this here |
Interestingly I was already doing that, let me test this again. edit: On testing, the branch linked also always shows the transfer button I was attempting to fix. I thought we were talking about this button in advanced player list: |
49a7f32 to
f60bdfc
Compare
f60bdfc to
0824d92
Compare
0824d92 to
ef91c34
Compare
|
This commit was lost to time and very valuable: f60bdfc#diff-40c052408aba0b8d61ccb4d5dbd6743bc00d82a1dc532342290f5c0587c7f8c8 Putting this here so I don't have to rummage again, accidentally force pushed this branch to an old as hell version at some point, and am probably going to just put this feature on top of metal_send_threshold, since they are all up in |
ad27b79 to
2d2a2f6
Compare
|
This branch is now at the exact same place as player send threshold, since they share a lot of common code and I think these go together if they go. I can close this one or keep it open for the description. |
- Add modoption `player_metal_send_threshold` to defer metal tax until a sender’s cumulative sent metal exceeds the threshold; energy unchanged (taxed only by `tax_resource_sharing_amount`). - Track cumulative sent metal per sender and expose via team rules params: `metal_share_cumulative_sent`, `metal_share_threshold`, `resource_share_tax_rate`. - UI (AdvPlayersList): while dragging the share slider - Energy shows received/sent preview. - Metal shows amount_to_send/max_allowance and caps the slider by min(my metal, receiver free, remaining allowance). - Right-justified label with auto-sized grey background to fit two-number display. - Echo on send uses i18n: “Sent Xm[/Ym allowed by the player send threshold]” (optional bracket when threshold > 0). - Refactor: add `common/luaUtilities/resource_share_tax.lua` and use it from both gadget and UI to keep the math in one place. - Safety: clamps against receiver max share, handles 100% tax case, guards against negatives. Default threshold is 0 (immediate tax if base rate > 0). No changes to unit-sharing logic. - i18n: add `ui.playersList.chat.sentMetal` and `ui.playersList.chat.sentMetalThreshold` (en). translation keys try to match the policy keys.
Refactor unit sharing mode into the policy cache/policyResult format and simplify gui_advplayerslist.
44d4a16 to
8dd6520
Compare
|
Closing this in favor of player_send_threshold or possibly some different PR. Really both of these PRs together are the "split mod option" approach to team sharing and should be a unified PR. I'm tired of maintaining it in isolation/it's REALLY hard to keep these two branches separated in gui_advplayerlist, though I did try at the commit level. |



Closes #4416
LLM Usage
A bit on this one. Gemini iirc. This was one of my first times using LLMs for coding and it ended up being mostly by hand because it honestly wasn't super helpful.
Refactor: T2 Constructor Sharing and Fix Take Command
This PR refactors unit sharing logic, introduces the requested "T2 Constructor Sharing Only" mode, and fixes related bugs with the
/takecommand and Unit Market interactions.Problem Description & Motivation
t2consSharing Mode: Provide the community-requested middle ground sharing option (Disabled Unit Sharing Except T2 #4416) between fully enabled and fully disabled, reflecting the common meta of sharing T2 constructors in team games./takeCommand Bug: Resolve the issue where restricted sharing modes (disabledort2cons) incorrectly blocked the/takecommand, preventing players from taking control of inactive allied teams.Implementation Approach & Changes
Unit Sharing Mode (
luarules/gadgets/game_unit_sharing_mode.lua):* Renamed
game_disable_unit_sharing.luatogame_unit_sharing_mode.luafor clarity and naming convention.* Converted the "Disable Unit Sharing" checkbox into a
unit_sharing_modedropdown option with keys:enabled(default),t2cons,combat,combat_t2cons,disabled. (Renamedt2cons_onlytot2consfor brevity).* Refactored
AllowUnitTransferto correctly check the selected mode for standard player-to-player transfers.* Unit Market Decoupling: Implemented a flag (
marketTransferInProgress).game_unit_market.luasets this flag before transfer;game_unit_sharing_mode.luachecks and clears it, bypassing sharing rules for market transactions.*
/takeCommand Fix: Added a workaround function (CheckTakeCondition) that bypasses sharing rules if the sender is allied and has no active human players, mirroring the engine's apparent condition for/take. This was necessary as/takedoesn't setcapture=trueor provide another detectable flag. (Includes a TODO and suggestion for a future engine flag improvement).* Preserved the
capture=truecheck to allow engine-managed transfers.Testing Results
unit_sharing_modeoptions:enabled: Allows all standard transfers.t2cons: Allows standard transfer of T2 constructors (e.g.,armack), blocks T1 constructors, factories, combat units.disabled: Blocks all standard transfers.disabledort2cons):/take <TeamID>command successfully transfers all units from inactive allied teams.capture=true) succeed.Release Notes
disable_unit_sharingcheckbox mod option has been replaced by theunit_sharing_modedropdown list option.!bset modoption disable_unit_sharing 1is now!bset modoption unit_sharing_mode disabled.!bset modoption disable_unit_sharing 0is now!bset modoption unit_sharing_mode enabled.!bset modoption unit_sharing_mode t2cons.Before
After
(ignore the overlap in the screenshot I fixed that at some point)