Skip to content

Distribution click action mode - #1993

Open
TaranDahl wants to merge 10 commits into
Phobos-developers:developfrom
TaranDahl:分散点击模式

Hidden character warning

The head ref may contain hidden characters: "\u5206\u6563\u70b9\u51fb\u6a21\u5f0f"
Open

Distribution click action mode#1993
TaranDahl wants to merge 10 commits into
Phobos-developers:developfrom
TaranDahl:分散点击模式

Conversation

@TaranDahl

@TaranDahl TaranDahl commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Reopen #1453 again.

[ ] Distribution Mode Spread / Filter / Enable

  • Now you can change the click action by using AllowSwitchNoMoveCommand hotkey. If the behavior to be executed by the current techno is different from the behavior displayed by the mouse, and the behavior to be executed will make the techno move near the target, the behavior will be replaced with area guard. Regardless of whether or not switch hotkey is used, default behavior can be changed through DefaultApplyNoMoveCommand.
  • Now you can also change the click action when hold down the specific hotkey if enabled AllowDistributionCommand. The new behavior is like using the selected objects one by one to click on each target within the spread range.
    • The targets within the spread range will be allocated equally to the selected technos. Only when the behavior to be performed by the current techno is the same as that displayed by the mouse will it be allocated. Otherwise, it will return to the original default behavior of the game (it will not be effective for technos in the air). This will display a range ring.
    • DefaultDistributionSpreadRange controls the initial spread range, which is a number that's corresponding to the amount of cell radius * 512.
  • AllowDistributionCommand.SpreadMode allows you to set spread range by hotkey. There're 4 tiers of range that can be selected by this hotkey which are identical to 0, 4, 8 and 16 cells.
    • When the range is 0, it is the original default behavior of the game.
  • You can also adjust spread range by using the mouse wheel while holding down the specific hotkey if AllowDistributionCommand.SpreadModeScroll set to true. This allows a more precise control of spread range that each step will increase/decrease it by DistributionSpreadScrollStep, with 20 cells as its maximum value.
  • AllowDistributionCommand.FilterMode allows you to set target filter by hotkey, which default to DefaultDistributionFilterMode.
    • When the filter is None, it is the default behavior of the game. If the range is not zero at this time, a green ring will be displayed. You can adjust the filter mode to:
      • Like - only targets with the same armor type (Completely identical Armor) will be selected among the targets allocated in the range. At this time, a blue ring will be displayed.
      • Type - only targets of the same type (like infantries, vehicles or buildings) will be selected among the targets allocated in the range. At this time, a yellow ring will be displayed.
      • Name - only targets of the same name (or with the same GroupAs) will be selected among the targets allocated in the range. At this time, a red ring will be displayed.
  • AllowDistributionCommand.AffectsAllies, AllowDistributionCommand.AffectsEnemies & AllowDistributionCommand.AffectsNeutral allow the distribution command to work on allies (including owner), enemies or neutral target. If picking a target that's not eligible, it'll fallback to vanilla command.
  • It's possible to add a button for distribution mode in the bottom bar by adding DistributionMode in the ButtonList of AdvancedCommandBar and MultiplayerAdvancedCommandBar.
    • The positions of each button are hardcoded, so it'll only decide whether enable this button or not. Distribute Mode button is now always listed after all the vanilla ones.
    • The asset of these buttons should be added in sidec0x.mix files which correspond to different sides, with the name button12.shp.
  • For localization add TXT_SWITCH_NOMOVE, TXT_DISTR_SPREAD, TXT_DISTR_FILTER, TXT_DISTR_HOLDDOWN, TXT_SWITCH_NOMOVE_DESC, TXT_DISTR_SPREAD_DESC, TXT_DISTR_FILTER_DESC, TXT_DISTR_HOLDDOWN_DESC, MSG:DistributionModeOn, MSG:DistributionModeOff, TIP:DistributionMode into your .csf file.

In rulesmd.ini:

[GlobalControls]
AllowSwitchNoMoveCommand=false                      ; boolean
AllowDistributionCommand=false                      ; boolean
AllowDistributionCommand.SpreadMode=true            ; boolean
AllowDistributionCommand.SpreadModeScroll=true      ; boolean
AllowDistributionCommand.FilterMode=true            ; boolean
AllowDistributionCommand.AffectsAllies=true         ; boolean
AllowDistributionCommand.AffectsEnemies=true        ; boolean
AllowDistributionCommand.AffectsNeutral=true        ; boolean

[AudioVisual]
StartDistributionModeSound=                         ; sound entry
EndDistributionModeSound=                           ; sound entry
AddDistributionModeCommandSound=                    ; sound entry

In ra2md.ini:

[Phobos]
DefaultApplyNoMoveCommand=true                      ; boolean
DefaultDistributionSpreadRange=2048                 ; integer between 0 and 5120
DistributionSpreadScrollStep=16                     ; integer between 16 and 512
DefaultDistributionFilterMode=2                     ; integer, 0 - None , 1 - Like , 2 - Type , 3 - Name

In uimd.ini:

[AdvancedCommandBar]
ButtonList=[Button1],DistributionMode,[ButtonX]     ; List of button entry

[MultiplayerAdvancedCommandBar]
ButtonList=[Button1],DistributionMode,[ButtonX]     ; List of button entry

@github-actions

github-actions Bot commented Dec 8, 2025

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@TaranDahl

Copy link
Copy Markdown
Contributor Author

@Metadorius Any issue other than #1949 (review)?

@TaranDahl

TaranDahl commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

TODO:
(Summarized from #1949 (review))

  • Create independent file for AdvancedCommandBarButtonClass.
  • Allow registering new AdvancedCommandBarButtonClass like MakeCommand.
  • Rewrite the spread range code to allow exact range.
  • Press-and-drag mode

@Metadorius Please confirm the above summary, or supplement/correct the incorrect parts.

@Metadorius

Copy link
Copy Markdown
Member

@TaranDahl yeah, correct, there was also a comment about implementing press-and-drag mode (and not sure if the "same type" (infantry/buildings/vehicles/etc) is needed, since we have "same armor" mode). CrimRecya said it's too problematic, however I don't really see why, since we already have drag selection and we could reuse drag selection to calculate the radius.

@TaranDahl

TaranDahl commented Dec 10, 2025

Copy link
Copy Markdown
Contributor Author

there was also a comment about implementing press-and-drag mode (and not sure if the "same type" (infantry/buildings/vehicles/etc) is needed

I think there is not enough labor force to add more features.
I think the existing work is sufficient in terms of completion. We should just perfect the existing features and then merge them.
As for more features, they should be another work, and can be implemented later, by anyone who wants them.
Breaking it into two PR can also help avoid the problem of having an excessive amount of code piled up in one PR, which may lead to no one willing to review it.

@Metadorius

Copy link
Copy Markdown
Member

I think there is not enough labor force to add more features. I think the existing work is sufficient in terms of completion. We should just perfect the existing features and then merge them. As for more features, they should be another work, and can be implemented later, by anyone who wants them. Breaking it into two PR can also help avoid the problem of having an excessive amount of code piled up in one PR, which may lead to no one willing to review it.

This isn't a feature though? It is just a somewhat small improvement that brings it in line with how modern games do it.

  • 0x6D2280 (exists in YRpp) for transforming screen coords into world coords (though Z is 0, maybe would want to account for that)
  • 0x4AC4CC is where the drag-selection band is set and the mouse hold is done
  • 0x4ABCEB is where the drag-selection release is handled
  • 0xD90 in TacticalClass is Rect that contains X, Y, Width, Height

From that you could calculate 2 points, get world coords via function above, use this info to draw a corresponding circle and set the mode to such. I am not sure what is complex here. If needed I can send my decompile for this.

@TaranDahl

Copy link
Copy Markdown
Contributor Author

@Metadorius Is there any difference between ShapeButtonClass and AdvancedCommandBarButtonClass?

@Metadorius

Metadorius commented Dec 24, 2025

Copy link
Copy Markdown
Member

@TaranDahl ShapeButtonClass is a vanilla engine class, AdvancedCommandBarButtonClass is something I propose to invent (perhaps a descendant from ShapeButtonClass) that stores the extra things that are currently stored as static arrays, for example.

@TaranDahl

Copy link
Copy Markdown
Contributor Author

@TaranDahl ShapeButtonClass is a vanilla engine class, AdvancedCommandBarButtonClass is something I propose to invent (perhaps a descendant from ShapeButtonClass) that stores the extra things that are currently stored as static arrays, for example.

Judging from the current code, there seems to be no need for it to inherit from ShapeButtonClass. After all, the game originally stores those attributes in a static array.
image

@Metadorius

Copy link
Copy Markdown
Member

After all, the game originally stores those attributes in a static array.

Which is a bad pattern. You have class fields and methods for that.

@TaranDahl

Copy link
Copy Markdown
Contributor Author

Yeah I will make a new class to arrange the new buttons. But for the vanilla buttons, maybe we should just let them be?

@Metadorius

Copy link
Copy Markdown
Member

Yeah I will make a new class to arrange the new buttons. But for the vanilla buttons, maybe we should just let them be?

Yeah I didn't mean we should be squeezing vanilla static array shitcode into proper classes necessarily, should be good.

@TaranDahl

Copy link
Copy Markdown
Contributor Author

If we want to implement dragging, how should we handle the selection range?
Right now, it's several specific values.

Comment thread src/Commands/DistributionMode.cpp Outdated

@Metadorius Metadorius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partial review

Comment thread src/Commands/DistributionMode.cpp
Comment thread src/Commands/DistributionMode.cpp Outdated
Comment thread src/Commands/DistributionMode.cpp Outdated
@NetsuNegi
NetsuNegi marked this pull request as draft December 29, 2025 09:27
@TaranDahl TaranDahl removed the Tested label Jan 25, 2026
@TaranDahl
TaranDahl force-pushed the 分散点击模式 branch from 22dd6fa to 769c5a2 Compare July 14, 2026 07:19
update

update doc

禁止分配到回收站

update

update

Update src/Commands/DistributionMode.cpp

fix

core

disable force attack for distribution mode

fix double keys breaking distribution command

fix distribution mode crash

add AffectsNeutral for distribution mode

Update Phobos.vcxproj

move things to new files

update doc

Button on bottom

TODO

Fit with FakeOf

Fix include

Separate functions

Fix default value

Remove useless

Refactor

remove unnecessary Grinder process

Code style

...

Low distance first

Fix merge

Message, sound and scroll action

Global toggle

Fix target outside units

Fix target disguised units

Fix target shrouded units

Doc

Add a hold down key to enable

Fix target cloaked units

Fix a typo

Show range ring

Draw at mouse

Core

Co-Authored-By: Kerbiter <crabiter@vivaldi.net>
Co-Authored-By: Coronia <28055583+Coronia@users.noreply.github.com>
Co-Authored-By: 绯红热茶 <169989423+CrimRecya@users.noreply.github.com>
@TaranDahl
TaranDahl force-pushed the 分散点击模式 branch from d4daaa2 to f644c0a Compare July 15, 2026 18:37
@TaranDahl
TaranDahl marked this pull request as ready for review July 15, 2026 18:41
@TaranDahl
TaranDahl requested a review from Metadorius July 15, 2026 18:48
@Coronia

Coronia commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

maybe the default DistributionSpreadScrollStep of 16 is too small. Now it takes long time to scroll it to a desirable value. Maybe make it 256 which is 1 cell per scroll, making it more intuitive and easy to use while keeping the preciseness

also the upper limit of DistributionSpreadScrollStep seems to be not needed, as it was 0-4-8-16 range before which are all greater than 512

as for the drag, I think instead of a choice between it and scroll, it'd better just make a toggle in rulesmd.ini to enable or disable it, like AllowDistributionCommand.SpreadModeScroll did, since these 2 patterns can naturally co-exist without conflict

@TaranDahl

Copy link
Copy Markdown
Contributor Author

maybe the default DistributionSpreadScrollStep of 16 is too small. Now it takes long time to scroll it to a desirable value. Maybe make it 256 which is 1 cell per scroll, making it more intuitive and easy to use while keeping the preciseness

also the upper limit of DistributionSpreadScrollStep seems to be not needed, as it was 0-4-8-16 range before which are all greater than 512

as for the drag, I think instead of a choice between it and scroll, it'd better just make a toggle in rulesmd.ini to enable or disable it, like AllowDistributionCommand.SpreadModeScroll did, since these 2 patterns can naturally co-exist without conflict

Changed.

@Coronia
Coronia requested a review from CrimRecya July 17, 2026 02:57

@Metadorius Metadorius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a doc pass, sorry, haven't got to the rest yet. treat it both as a doc review (if what I asked for is true but docs are not reflecting it yet) and design review (if what I asked about is not true yet)

Comment thread docs/User-Interface.md

### `[ ]` Distribution Mode Spread / Filter / Enable

- Now you can change the click action by using `AllowSwitchNoMoveCommand` hotkey. If the behavior to be executed by the current techno is different from the behavior displayed by the mouse, and the behavior to be executed will make the techno move near the target, the behavior will be replaced with area guard. Regardless of whether or not switch hotkey is used, default behavior can be changed through `DefaultApplyNoMoveCommand`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't think this has to be in Distribution Mode docs
  2. it's not clear what this does, is it a toggle for "fallback" behavior if different from the mouse one and allows disabling it? if so - maybe UnavailableActionFallsBackToMove=action will be more intuitive? or UnavailableActionFallBack=none/action (defaults to move), with customisability per type (not sure what handles actions, MissionType?) maybe useful?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't think this has to be in Distribution Mode docs

wdym? A function without docs?

2. it's not clear what this does, is it a toggle for "fallback" behavior if different from the mouse one and allows disabling it? if so - maybe will be more intuitive? or (defaults to move), with customisability per type (not sure what handles actions, MissionType?) maybe useful?UnavailableActionFallsBackToMove=action``UnavailableActionFallBack=none/action

The current fallback behavior is not simply changing the Action, but a specially customized behavior targeting the AreaGuard unit itself instead of the target.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdym? A function without docs?

no, just a separate section. it's not really relevant to distribution mode and can be used without it, right? it's just a complementary function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current fallback behavior is not simply changing the Action, but a specially customized behavior targeting the AreaGuard unit itself instead of the target.

then the tag name is still not clear IMO

Comment thread docs/User-Interface.md Outdated
Comment thread docs/User-Interface.md Outdated

- Now you can change the click action by using `AllowSwitchNoMoveCommand` hotkey. If the behavior to be executed by the current techno is different from the behavior displayed by the mouse, and the behavior to be executed will make the techno move near the target, the behavior will be replaced with area guard. Regardless of whether or not switch hotkey is used, default behavior can be changed through `DefaultApplyNoMoveCommand`.
- Now you can also change the click action when hold down the specific hotkey if enabled `AllowDistributionCommand`. The new behavior is like using the selected objects one by one to click on each target within the spread range.
- The targets within the spread range will be allocated equally to the selected technos. Only when the behavior to be performed by the current techno is the same as that displayed by the mouse will it be allocated. Otherwise, it will return to the original default behavior of the game (it will not be effective for technos in the air). This will display a range ring.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, it will return to the original default behavior of the game

do you mean the move fallback? if so - you should mention that and/or link it

(it will not be effective for technos in the air)

hmm?

Comment thread docs/User-Interface.md
- Now you can change the click action by using `AllowSwitchNoMoveCommand` hotkey. If the behavior to be executed by the current techno is different from the behavior displayed by the mouse, and the behavior to be executed will make the techno move near the target, the behavior will be replaced with area guard. Regardless of whether or not switch hotkey is used, default behavior can be changed through `DefaultApplyNoMoveCommand`.
- Now you can also change the click action when hold down the specific hotkey if enabled `AllowDistributionCommand`. The new behavior is like using the selected objects one by one to click on each target within the spread range.
- The targets within the spread range will be allocated equally to the selected technos. Only when the behavior to be performed by the current techno is the same as that displayed by the mouse will it be allocated. Otherwise, it will return to the original default behavior of the game (it will not be effective for technos in the air). This will display a range ring.
- `DefaultDistributionSpreadRange` controls the initial spread range, which is a number that's corresponding to the amount of cell radius * 512.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably move the modes description earlier

Suggested change
- `DefaultDistributionSpreadRange` controls the initial spread range, which is a number that's corresponding to the amount of cell radius * 512.
- `DefaultDistributionSpreadRange` controls the initial spread range for the scrollwheel mode, which is a number that's corresponding to the amount of cell radius * 512.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It applies to all modes except PressAndDrag. I don't think it needs special explanation, because it should be intuitive that PressAndDrag does not take this into account.

Comment thread docs/User-Interface.md Outdated
Comment on lines +615 to +617
AllowDistributionCommand.SpreadModeHotKey=true ; boolean
AllowDistributionCommand.SpreadModeScroll=true ; boolean
AllowDistributionCommand.SpreadModeDrag=true ; boolean

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should be controlled from rules.ini. Control schemes are not up to mod author.

The mod author should be able to enable or disable the feature (because it significantly alters the gameplay), but the players must be able to choose their preferred implementation themselves via RA2MD.ini.

Comment thread docs/User-Interface.md Outdated
Comment on lines +625 to +626
StartDistributionModeSound= ; sound entry
EndDistributionModeSound= ; sound entry

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's default this to the same sound as waypoint mode

Comment thread docs/User-Interface.md Outdated
[AudioVisual]
StartDistributionModeSound= ; sound entry
EndDistributionModeSound= ; sound entry
AddDistributionModeCommandSound= ; sound entry

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this about

Comment thread docs/Whats-New.md Outdated
Comment thread docs/User-Interface.md Outdated
- `AllowDistributionCommand.UseClick` controls whether distribution mode is activated by clicking on a target. When set to false, distribution mode only works via press-and-drag, and the range ring will only be shown while dragging.
- You can also adjust spread range by using the mouse wheel while holding down the specific hotkey if `AllowDistributionCommand.SpreadModeScroll` set to true. This allows a more precise control of spread range that each step will increase/decrease it by `DistributionSpreadScrollStep`, with 20 cells as its maximum value.
- `AllowDistributionCommand.SpreadModeDrag` allows you to adjust the spread range by pressing and dragging the mouse while holding down the specific hotkey. The drag distance from the starting point determines the spread range. This can naturally co-exist with `SpreadModeScroll`.
- `AllowDistributionCommand.FilterMode` allows you to set target filter by hotkey, which default to `DefaultDistributionFilterMode`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how this tag works? at least from the documentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set it to false, and it will function exactly as you described earlier. It is fully tailored for you.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is a toggle between togglable and not togglable mode? I am not sure why this needs to be customised at rulesmd.ini level though?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you asking about the UseClick or FilterMode?

Comment thread docs/User-Interface.md
- Deselect 1 or 5 object(s) from current selected objects.
- For localization add `TXT_DESELECT`, `TXT_DESELECT_DESC`, `TXT_DESELECT5` and `TXT_DESELECT5_DESC` into your `.csf` file.

### `[ ]` Distribution Mode Spread / Filter / Enable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could assign it by default to something like C? or maybe (crazy idea) holding X (and making specifically the release of the same hotkey in a short time scattering)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the current architecture does not allow the same key to be used for different functions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waypoint mode somehow works like this, so this should too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waypoint mode somehow works like this, so this should toowaypoint mode somehow works like this, so this should too

I don't quite know what you're referring to.
By default, the hotkey for waypoint mode is Z, and the Z key is exclusively used by waypoint mode.
It is not feasible under the current hotkey architecture for different CommandClass to share the same hotkey and distinguish between short presses and long presses only. Also I don't think it is worthwhile to significantly expand the existing hotkey architecture for this at the moment; it would make more sense to devote that effort to the development of OpenYR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I confused the response thread, nevermind. just ensure it works like waypoint mode hotkey, that's all

TaranDahl and others added 4 commits July 20, 2026 01:01
Co-authored-by: Kerbiter <crabiter@vivaldi.net>
Co-authored-by: Kerbiter <crabiter@vivaldi.net>
# Conflicts:
#	CREDITS.md
#	docs/User-Interface.md
#	src/Ext/TechnoType/Body.h
#	src/Phobos.INI.cpp
#	src/Phobos.h
@TaranDahl

Copy link
Copy Markdown
Contributor Author

@Metadorius How about the rest of your review?

@Metadorius

Copy link
Copy Markdown
Member

How about the rest of your review?

Have you addressed the design changes I requested? without that it would be a moot point to get deeper into code

@TaranDahl

Copy link
Copy Markdown
Contributor Author

How about the rest of your review?

Have you addressed the design changes I requested? without that it would be a moot point to get deeper into code

So there are no further issues with the design, right?

@Metadorius

Copy link
Copy Markdown
Member

So there are no further issues with the design, right?

you left some of my comments/suggestion unaddressed though, either by changes or replies, that's what I was pointing at

@TaranDahl

Copy link
Copy Markdown
Contributor Author

So there are no further issues with the design, right?

you left some of my comments/suggestion unaddressed though, either by changes or replies, that's what I was pointing at

Yeah I know it. I was looking forward to some other reviews, to deal with them together.

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

Labels

Needs testing ❓New feature ⚙️T2 T2 maintainer review is sufficient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants