Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disconnection share and ACU recall options #5971

Open
wants to merge 63 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
9752976
Reorganize SimUtils.lua
lL1l1 Mar 13, 2024
5117faa
Move army death functions from aibrain to simutils
lL1l1 Mar 13, 2024
eba2944
Use newer version of DisableAI from OnDefeat
lL1l1 Mar 13, 2024
bb99f92
upvalue functions
lL1l1 Mar 13, 2024
18b76dd
Add text for on-disconnect lobby options
lL1l1 Mar 11, 2024
312d39d
Implement disconnect lobby options
lL1l1 Mar 13, 2024
f0105f0
Track ACUs last taking damage for disconnect rules
lL1l1 Mar 17, 2024
f89d89c
Add ACU Sharing
lL1l1 Mar 26, 2024
1c804bb
Improve annotations
lL1l1 Apr 1, 2024
a6e015c
Implement sending a reason for units being shared
lL1l1 Apr 1, 2024
a86a62b
Add outside 8-way positioning methods
lL1l1 May 28, 2024
a0aec7c
Refactor announcement.lua using layouter
lL1l1 May 30, 2024
d41189f
Get rid of goalControl == textGroup case
lL1l1 May 30, 2024
1aca972
Optimize imports of LazyVar in UI classes
lL1l1 Jun 5, 2024
39877cd
Implement ItemList:SetAlphaOfColors
lL1l1 Jun 4, 2024
77a026b
Implement `TextArea:FitToText()` and its helpers
lL1l1 Jun 4, 2024
9adf16d
Implement `AlignText` function
lL1l1 Jun 5, 2024
2ab77c7
Implement `ItemList:GetAllItems`
lL1l1 Jun 5, 2024
49f79a8
Implement TextArea SetTextAlignment
lL1l1 Jun 5, 2024
05a99e3
Make color.lua enum support case insensitive
lL1l1 Jun 5, 2024
d7fafc9
Make new color functions enum support case insensitive
lL1l1 Jun 5, 2024
d9c2eee
Implement using TextArea for announcements
lL1l1 Jun 5, 2024
d24c4f1
Refactor "text" variable to "title" in announcement
lL1l1 Jun 5, 2024
0ec268b
Use share reasons in the share announcement
lL1l1 Jun 5, 2024
35da54e
Fix typo in a uiutil comment
lL1l1 Jun 5, 2024
e08721b
Add guards for share option announcement text
lL1l1 Jun 5, 2024
13e4fd3
Use a variable for 2 the minute acu safety timer
lL1l1 Jun 9, 2024
f5923de
Guard against abandoning without an ACU
lL1l1 Jun 9, 2024
e546af9
Update a comment
lL1l1 Jun 9, 2024
29c0b40
Guard against disconnect abuse in ACU sharing
lL1l1 Jun 9, 2024
4216039
Don't delayed recall ACUs in danger
lL1l1 Jun 9, 2024
9d97d46
Final iteration of lobby options text
lL1l1 Jun 5, 2024
1b91d1b
First draft of changelog snippet
lL1l1 Jun 9, 2024
7ddb3df
Fix unknown variable error
lL1l1 Jun 9, 2024
7e6a3ba
Fix sharing ACU in partial share
lL1l1 Jun 9, 2024
021358d
Fix concating nil when transferring 0 units
lL1l1 Jun 9, 2024
ae92573
Simplify TransferUnitsToKiller
lL1l1 Jun 9, 2024
68dc86b
Allow `noRestrictions` to transfer to defeated brains
lL1l1 Jun 11, 2024
002ec24
Delete announcementNew.lua
lL1l1 Jun 11, 2024
6838b66
Fix typo in annotation comment
lL1l1 Jun 12, 2024
62396c9
Init LastTickDamaged to 0 instead of checking for nil
lL1l1 Jun 12, 2024
4725ad4
Fix KillArmyOnDelayedRecall damage check logic
lL1l1 Jun 12, 2024
71f0695
Kill ACUs when needed to prevent sharing
lL1l1 Jun 12, 2024
d705d9a
Handle recalling ACUs
lL1l1 Jun 12, 2024
3bb863c
Specify invalid share condition
lL1l1 Dec 25, 2024
dba06c3
Improve `TransferUnitsToHighestBrain`
lL1l1 Dec 25, 2024
d5a3edc
Annotate `CMauiItemList:SetNewColors`
lL1l1 Dec 25, 2024
bea1ba0
Fix AutoLobbyConnectionMatrixDot
lL1l1 Dec 25, 2024
0e5cacf
Update LaunchFAInstances.ps1
lL1l1 Dec 25, 2024
d1442ea
Fix in SimUtils TransferUnitsToHighestBrain usage
lL1l1 Dec 25, 2024
72475a4
Remove brain.index
lL1l1 Dec 25, 2024
778ea84
Merge branch 'develop' into feature/recall-on-disconnect
lL1l1 Dec 25, 2024
3d9036b
Merge branch 'develop' into feature/recall-on-disconnect
lL1l1 Dec 26, 2024
fa1a3fb
Fix aibrain RecallArmyOnDefeat
lL1l1 Dec 26, 2024
642903e
Fix intellisense warning
lL1l1 Dec 26, 2024
028e2e9
Fix the return type of CreateBorder
lL1l1 Dec 26, 2024
59c3ae2
Fix runtime errors/intellisense warnings
lL1l1 Dec 26, 2024
4c84ede
Update ChangeUnitArmy annotation
lL1l1 Dec 26, 2024
b9b0b02
Fix the enhancement disabling script
lL1l1 Dec 26, 2024
1ee4618
Fix recall conditional
lL1l1 Dec 26, 2024
c56f771
Revert "Fix recall conditional"
lL1l1 Dec 26, 2024
b5c2b9d
Reuse GetGameTick call
lL1l1 Dec 26, 2024
3af9ca2
Fix commander safe time logic at the start of game
lL1l1 Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions changelog/snippets/features.5971.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- (#5971) Add two new lobby options that determine how to share units of players who disconnect (DC) from the game: DC Share Conditions and DC ACU Share Conditions
This gives players of all types a way to lessen the impact of a disconnect in their games to a varying degree.
- DC Share Conditions: Similar to the standard Share Conditions option, this determines how units are shared when a player disconnects.
- The default is to copy the standard share condition, but it can be set independently.
- To prevent abuse, the DC Share Conditions are not applied in Assassination games if the ACU takes damage or dies in 2 minutes (depending on the DC ACU Share Conditions).
- DC ACU Share Conditions: Determines how ACUs are treated when a player disconnects. They can be split into two categories:
- Instant conditions: These are applied instantly, so to prevent abuse, the DC Share Conditions are only applied if the ACU has not taken damage within the last 2 minutes.
- Explode (Default): The current behavior of ACUs, where they explode when their player leaves.
- Recall: Instead of exploding, the ACU peacefully recalls, keeping everything around intact. This can only happen if they weren't damaged in the last 2 minutes to prevent abuse.
- ACU Sharing conditions: These share the disconnecting ACU. To prevent abuse, the DC Share Conditions are only applied if the ACU doesn't die within 2 minutes of being shared. After those 2 minutes, the DC Share Conditions apply when the ACU recalls or dies.
- Delayed Recall: ACUs are very powerful, but also necessary early on, so this option shares the ACU for 2 minutes or until 5 minutes pass in the game (displayed as a countdown on the ACU). Afterwards, it recalls (except if it was damaged in 2 min, then it explodes). This gives players an opportunity to stabilize the new situation without getting a large long term advantage by controlling two ACUs.
- Permanent: For those who don't mind it, or when the ACU is too precious to lose after a timer, the ACU can be shared permanently.

Some examples:
- Share until death players can use "Same as Share" and "Permanent" to keep players who disconnect snipeable, but not lose their entire base.
- Survival/modded players can use "FullShare" and "Permanent" to keep everything.
- Competitive players can use "FullShare" and "Delayed Recall" to not have to restart the lobby or draw because of an early disconnect, but without having an OP double ACU strategy.
- Think getting bases or reclaim from disconnects is unfair? Make them recall and desert as civilians!
14 changes: 9 additions & 5 deletions engine/Sim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
---@alias ReclaimObject moho.prop_methods | moho.unit_methods
---@alias TargetObject moho.prop_methods | moho.unit_methods | moho.projectile_methods

---@type table<Army, AIBrain>
ArmyBrains = {}

--- restricts the army from building the unit category
---@param army Army
---@param category EntityCategory
Expand Down Expand Up @@ -84,13 +87,14 @@ end
function AttachBeamToEntity(emitter, entity, bone, army)
end

-- engine patched to allow commanders to be able to be shared

--- changes the army of a unit, returning the new unit and destroying the old one
--- Changes the army of a unit, returning the new unit and destroying the old one
--- Modified by an engine patch to allow commanders to be given.
--- `COMMAND` units are filtered out in SimHooks.lua for legacy compatibility.
---@param unit Unit
---@param army Army
---@return Unit
function ChangeUnitArmy(unit, army)
---@param allowCommanders? boolean
---@return Unit|nil
function ChangeUnitArmy(unit, army, allowCommanders)
end

--- returns true if cheats are enabled and logs the cheat attempt no matter what
Expand Down
11 changes: 10 additions & 1 deletion engine/User/CMauiItemList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,21 @@ end
function CMauiItemList:ScrollToTop()
end

--- Sets the alpha of a given item list's background, if children is true, also set children's alpha
---@param alpha number
---@param children? boolean
---@see itemlist.lua:SetAlphaOfColors Lua implementation that can set the alpha of the text in an item list.
function CMauiItemList:SetAlpha(alpha, children)
end

---
---@param foreground Color
---@param background Color
---@param selectedForeground Color
---@param selectedBackground Color
function CMauiItemList:SetNewColors(foreground, background, selectedForeground, selectedBackground)
---@param mouseoverForeground Color
---@param mouseoverBackground Color
function CMauiItemList:SetNewColors(foreground, background, selectedForeground, selectedBackground, mouseoverForeground, mouseoverBackground)
end

--- Sets the font to use in this ItemList control
Expand Down
42 changes: 34 additions & 8 deletions loc/US/strings_db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6748,10 +6748,17 @@ urs0304_name="Plan B"
urs0305_desc="Sonar Platform"
urs0305_help="Sonar Platform"
urs0305_name="Flood XR"

usersync_0001="%s wins!"
usersync_0002="%s has been defeated!"
usersync_0003="%s receives a draw."
usersync_0004="Game Over."
usersync_0005="Disconnect Temporary Share"
usersync_0006="Disconnect Share"
usersync_0007="%s\'s units and ACU transferred to you until ACU dies/recalls"
usersync_0008="%s\'s units and ACU transferred to you until ACU dies"
usersync_0009="\nShare Condition after: %s"

uvd_0000="Build Cost (Rate)"
uvd_0002="Yield"
uvd_0003="Description"
Expand Down Expand Up @@ -7735,6 +7742,7 @@ lobui_0781="Teams will be balanced with up to 5%% tolerance of best setup to mak
lobui_0782="Optimal balance (Mirrored)"
lobui_0783="Teams will be optimally balanced, mirrored start locations"

-- Share Options
lobui_0790="Manual Unit Sharing"
lobui_0791="Are players allowed to manually give units?"
lobui_0792="Manual unit sharing are allowed"
Expand All @@ -7744,6 +7752,31 @@ lobui_0795="No manual sharing of units"
lobui_0796="Partial Share"
lobui_0797="Your buildings and engineers will be transferred to your highest rated ally when you die. Your other units will be destroyed when you die, except those captured by the enemy."

lobui_0798="DC Share Conditions"
lobui_0799="Set what happens to a player's units when they disconnect. In Assassination, only applies if an ACU has not been damaged in the last 2 minutes."
lobui_0800="Same as Share Condition"
lobui_0801="Treat disconnecting players the same as defeated players."

-- unranked lobby option
lobui_0802="Unrate"
lobui_0803="Provides a toggle to unrate a game. Note that if this is set to no the game can still be unrated due to other lobby options, unrated sim mods and / or the map being unrated."
lobui_0804="No"
lobui_0805="This game will be rated if all the criteria for a rated game are met."
lobui_0806="Yes"
lobui_0807="This game will not be rated."

-- More share options
lobui_0808="DC ACU Share Conditions"
lobui_0809="Set what happens to a player's ACU when they disconnect. In Assassination, the DC share condition is *not* applied if the ACU was damaged 2 minutes ago or dies within 2 minutes."
lobui_0810="Explode"
lobui_0811="ACUs explode when their player disconnects."
lobui_0812="Recall"
lobui_0813="ACUs not damaged in the last 2 minutes are recalled when their player disconnects."
lobui_0814="Delayed Recall"
lobui_0815="Disconnected ACUs are shared to allies for 2 minutes or until 5 minutes into the match before it recalls."
lobui_0816="Permanent"
lobui_0817="Disconnected ACUs are permanently shared to allies."

aisettings_0001="AIx Cheat Multiplier"
aisettings_0002="Set the cheat multiplier for the cheating AIs."
aisettings_0003="Cheat multiplier of %s"
Expand Down Expand Up @@ -8194,15 +8227,8 @@ aireplace_0004="A disconnected player will cause the destruction of their units
chat_send_type_title="Default recipient: allies"
chat_send_type_description="When enabled, enter sends messages to allies and holding shift + enter sends to all. When not enabled, the behavior is reversed."

-- unranked lobby option
lobui_0802="Unrate"
lobui_0803="Provides a toggle to unrate a game. Note that if this is set to no the game can still be unrated due to other lobby options, unrated sim mods and / or the map being unrated."
lobui_0804="No"
lobui_0805="This game will be rated if all the criteria for a rated game are met."
lobui_0806="Yes"
lobui_0807="This game will not be rated."

replay_id="Replay id"
map_version="Map version"
fullshare_announcement="%s\'s units have been transferred to you"

ChangelogDescriptionIdentifier="description"
Loading
Loading