-
Notifications
You must be signed in to change notification settings - Fork 68
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
Rclick melee delegate 1138 #1152
Rclick melee delegate 1138 #1152
Conversation
e0cf4fe
to
35cc73c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way this would be a useful functionality to have, so I hope you can address the requested changes so this can be added to CHL.
X2WOTCCommunityHighlander/Src/XComGame/Classes/X2AbilityTrigger_EndOfMove.uc
Outdated
Show resolved
Hide resolved
X2WOTCCommunityHighlander/Src/XComGame/Classes/X2AbilityTrigger_EndOfMove.uc
Outdated
Show resolved
Hide resolved
X2WOTCCommunityHighlander/Src/XComGame/Classes/X2AbilityTrigger_EndOfMove.uc
Outdated
Show resolved
Hide resolved
35cc73c
to
73240bd
Compare
Simplified the process significantly by reducing a lot of the clunkiness and now passes UnitState to the delegate allowing for the end consumer to interact with it and the ruleset cache as much as the desire. Should be much cleaner now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified the process significantly by reducing a lot of the clunkiness and now passes UnitState to the delegate allowing for the end consumer to interact with it and the ruleset cache as much as the desire. Should be much cleaner now.
It seems alright superficially, I haven't gone through it letter by letter or ran any tests yet. I still think the system would benefit from being able to override which ability to use depending on the target.
This would just mean copying the code from the X2AbilityTrigger_EndOfMove
to:
1) XComTacticalInput - here you would have to retrieve the target State Object from History using PathingPawn.LastTargetObject.GetReference().ObjectID
.
2) XComPathingPawn - you get XComGameState_BaseObject TargetObject
right in the function arguments.
The X2AbilityTrigger_EndOfMove
should still call the override though, just without the target state. You can make the target state object an optional argument for the delegate, or just explicitly pass none
there.
This is just so that the override can remain at least somewhat functional in case mod-added code also runs X2AbilityTrigger_EndOfMove::GetAvailableEndOfMoveAbilityForUnit()
.
73240bd
to
a642a8f
Compare
Updated to include the target object now. Still tried to maintain a minimal footprint in the Highlander itself. |
a642a8f
to
d6bdb84
Compare
d6bdb84
to
89f459c
Compare
X2WOTCCommunityHighlander/Src/XComGame/Classes/X2AbilityTrigger_EndOfMove.uc
Outdated
Show resolved
Hide resolved
X2WOTCCommunityHighlander/Src/XComGame/Classes/X2AbilityTrigger_EndOfMove.uc
Outdated
Show resolved
Hide resolved
{ | ||
// Begin Issue #1138 | ||
// Forward the work to the new endpoint to maintain BC | ||
return GetAvailableEndOfMoveAbilityForUnitWithTarget(UnitState, none); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uncomfortable with how this has been handled. GetAvailableEndOfMoveAbilityForUnitWithTarget()
doesn't exist in base game code, but it's not immediately obvious.
I also have BC concerns.
Here's what I request:
- Get rid of
GetAvailableEndOfMoveAbilityForUnitWithTarget()
, keep the original code insideGetAvailableEndOfMoveAbilityForUnit()
. - Add the
CHHelpersObj.TriggerPrioritizeRightClickMelee()
above the original code, just give it anone
target object. - Also call
CHHelpersObj.TriggerPrioritizeRightClickMelee()
from the two places where you calledGetAvailableEndOfMoveAbilityForUnitWithTarget()
from, but this time with the target object.
Let's do it this way, because then we do not have to maintain an additional function and worry about having to protect internal API or maintain BC.
It's not as pretty and results in more lines of code, but I believe it is the better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tweaked the implementation a little by finally realizing there are actually two things at play here. First thing is allowing a mod to fix the "bug" of the right-click priority choosing abilities that are non-intuitive. The second thing was enhancing the selection ability to allow for the target to be provided increasing the flexibility of the choice.
5bf9389
to
4399dc1
Compare
Refactored the PR. Footnotes:
|
/// You can optionally specify callback Priority. The default Priority is 50. | ||
///```unrealscript | ||
///CHHelpersObj.AddPrioritizeRightClickMeleeCallback(PrioritizeRightClickMelee, 45); | ||
///``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discord formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HL-Docs can render UC code in a similar fashion, example: this -> renders like this
77dc047
to
468cdc9
Compare
Moved the override trigger after the default logic so that the override could allow for a more informed decision without directly replicating base game logic. |
This is tested and ready to go, just waiting for @FearTheBunnies to squash the commit with my adjustments and it'll be ready to merge. |
56a5713
to
4a74078
Compare
Uses a delegate based approach to expanding the functionality versus actually forcing a revised sorting algorithm. Will allow other mods to hook into the right-click melee determination logic and provide prioritization dynamically for which melee ability should be used. Closes #1138