Player Resource Send Threshold#4804
Conversation
682bb95 to
5c98db0
Compare
37f45be to
d9e4064
Compare
|
Rebased |
|
Rejected by the GDT: This is counter to our desired game design, we want to address co-op issues via balance rather than arbitrary restrictions. |
|
Reopened after the new decision by the GDT. Awaiting code review. |
d9e4064 to
92b8326
Compare
|
Rebased |
|
blocked until @thehobojoe does a review |
thehobojoe
left a comment
There was a problem hiding this comment.
This PR is fine, but it needs a way to communicate to the player what is happening with their metal, and when taxes are going to kick in and how much it will cost them.
This could be as simple as an echo to the team, but I would prefer some indication during sharing that communicates the threshold and the taxes before they send resources.
309652d to
907e333
Compare
|
Great suggestions. Updated the description with the requested changes. Was able to get this one completely right. Squashed it. |
127a099 to
0eb420c
Compare
427f162 to
74e0d85
Compare
74e0d85 to
c8cb063
Compare
- 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. ded line units
Ported out of taxes to make it explicit.
all credit to hobo on this one I just tied in my unit_sharing_mode Co-authored-by: thehobojoe <the.hobo.joe@gmail.com>
I needed some way to turn sharing off completely and tax=1 didn't seem intuitive (or desirable since semantically following the logic of tax = 1 the sender would lose everything and the receiver would get nothing).
It is a bit kludgey but it is isolated and works surprisingly well until we get engine hooks. Co-authored-by: Fx-Doo <hedibertille93@gmail.com>
64a93b0 to
e01c720
Compare
Had to add an api_extensions because gui_advplayerlist (especially draw) is hitting its local variable limit. Split it off into its own file in teamtransfer since it's api_extensions for that thing
e01c720 to
6e82a6d
Compare
This reverts commit 8d6917d.
231b7af to
a5953b8
Compare
|
Closed this because I am consolidating further into #5704 which presents a complete UX and functional solution. |
Player Resource Send Threshold
Introduces a new configurable threshold for resource sharing tax, for both energy and metal.
AllowResourceTransferhook inprevent_excessive_share.game_tax_resource_sharingis now the only handler and it just transfers within bounds defined by the policy, if that is possible.Note: This is a complete rewrite of the tax system mostly to accommodate the new requirements without exploding gui_advplayerslist, but a side effect of this is that it simplifies the UI considerably.
Demo Video
How does it work?
Right away and then every N frames:
game_tax_resource_sharing.luawill build and cache a tax policy for each team pair <-> resource type (energy and metal). It uses a single function for both resource type calculations and follows that pattern of functional reuse between synced and unsynced to ensure all resource transfer follows the same rules and is driven by the same contract: the policy result.This policy result is then serialized and thrown into a cache:
This gives you a serialized policy result that the UI can quickly grab if it needs to know the bounds of a particular transfer. This also gives you a shared type to use across synced and unsynced functions.
Testing Results
tax_resource_sharing_amount.LLM usage disclosure
None. I tried LLM for this, it was hard. Ended up validating it with unit tests and then backporting this raw implementation by hand.