Skip to content

Reimplement the code reverted in 35f5f3eb3758dc09d3a0ae3bffccd033245abe51 - #2088

Merged
Coronia merged 13 commits into
Phobos-developers:developfrom
TaranDahl:ApproachTarget_StopMovingWhenInRange
Aug 9, 2026
Merged

Reimplement the code reverted in 35f5f3eb3758dc09d3a0ae3bffccd033245abe51#2088
Coronia merged 13 commits into
Phobos-developers:developfrom
TaranDahl:ApproachTarget_StopMovingWhenInRange

Conversation

@TaranDahl

@TaranDahl TaranDahl commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Stop immediately if the target enters the range during ApproachTarget

  • In vanilla, the ApproachTarget will simply exit and do nothing if the target is in range. This will cause your units to approach the target unnecessarily.
    • Now you can change this behavior by the following flag.
    • The setting can be customized per techno type; if not set on a type, the global setting is used as the fallback.
    • AttackMove.StopWhenTargetAcquired is read as a compatibility alias for ApproachTarget.StopWhenInRange (in both [General] and techno type sections).

In rulesmd.ini:

[General]
ApproachTarget.StopWhenInRange=false  ; boolean

[SOMETECHNO]
ApproachTarget.StopWhenInRange=       ; boolean, default to the same key in [General]

Keep pursuing the target during ApproachTarget

  • Now you can make a unit approach its target with the target itself as the destination, just like ZEP, instead of a point on the arc around the target whose radius is the unit's own weapon range.
    • If ApproachTarget.StopWhenInRange is set to true, the unit will stop as soon as the target enters its range and will not chase it further.
    • AttackMove.PursuitTarget is read as a compatibility alias for ApproachTarget.PursuitTarget.

In rulesmd.ini:

[SOMETECHNO]                   ; TechnoType
ApproachTarget.PursuitTarget=  ; boolean, default to false

@TaranDahl TaranDahl added Interaction Something related to interaction with other extension, program etc. Tested ⚙️T1 T1 maintainer review is sufficient ❓Unhardcoding / Customization Make something more tweakable labels Feb 4, 2026
@github-actions

github-actions Bot commented Feb 4, 2026

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

The AttackMove.StopWhenTargetAcquired has been deprecated because it was implemented in an incorrect way. It should be ApproachTarget instead of AttackMove that needs to be modified. It has now been replaced by ApproachTarget.StopWhenInRange. The prerequisite for it to take full effect is #2084.

The AttackMove.PursuitTarget has been deprecated because it was implemented in an incorrect way. It should be InAttackMoveKeepRange (implemented by #2081) and ApproachTarget (implemented by #1998) that need to be modified.

@Coronia

Coronia commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

given there were quite a lot of controversial for our previous tag renaming (such as new Trajectory and the recent major renaming), I think we should still stick to the principal of no tag name change unless necessary. For this PR I think we don't have to depreciate those AttackMove tag, could just redirect their implementaion to the new one.

@TaranDahl

Copy link
Copy Markdown
Contributor Author

deprecated because it was implemented in an incorrect way

I don't think we should keep something that is incorrect. This is not a simple tag renaming. They are removed because the function itself is incorrect.

@TaranDahl

Copy link
Copy Markdown
Contributor Author

Bounty: 10 CNY for the 1st reviewer who gives valid review
image

@DeathFishAtEase DeathFishAtEase left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Changelog entry position error

Comment thread docs/Whats-New.md Outdated
Comment thread docs/Whats-New.md
@DeathFishAtEase

Copy link
Copy Markdown
Collaborator

I see that it has already added the Tested label and is not a draft, so should this PR already be in a completed state?

I don't think we should keep something that is incorrect. This is not a simple tag renaming. They are removed because the function itself is incorrect.

The documentation for the discarded INI flag and its related content does not seem to have been removed yet, which should also be part of the pending work for this PR, because I see that they have already been removed in the changes to the source code.

core

Update docs/Whats-New.md

Update docs/Whats-New.md

Move the position of document paragraphs

Co-Authored-By: Noble Fish <89088785+DeathFishAtEase@users.noreply.github.com>
@TaranDahl
TaranDahl force-pushed the ApproachTarget_StopMovingWhenInRange branch from 1c3b9f7 to e8826d9 Compare July 15, 2026 12:09
Comment thread src/Utilities/TemplateDef.h Outdated
Comment thread YRpp
Comment thread docs/Fixed-or-Improved-Logics.md Outdated
Comment thread docs/Whats-New.md
@Coronia
Coronia requested a review from NetsuNegi August 5, 2026 14:27
Coronia and others added 2 commits August 5, 2026 22:39
# Conflicts:
#	CREDITS.md
#	docs/Whats-New.md
#	docs/locale/zh_CN/LC_MESSAGES/CREDITS.po
#	docs/locale/zh_CN/LC_MESSAGES/Whats-New.po
#	src/Ext/Rules/Body.cpp
#	src/Ext/Rules/Body.h
#	src/Ext/TechnoType/Body.h
#	src/Utilities/TemplateDef.h
Comment thread src/Ext/Techno/Hooks.Firing.cpp Outdated
DeathFishAtEase and others added 2 commits August 5, 2026 23:27
Supplement migration information and adjust the relative positions of variable declarations
@Coronia

Coronia commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

seems not working as great as before. Sometime the unit won't stop when facing a target in attack move
image

@TaranDahl

Copy link
Copy Markdown
Contributor Author

Can you post a gif?

@TaranDahl TaranDahl changed the title Stop immediately if the target enters the range during ApproachTarget Reimplement the code reverted in 35f5f3eb3758dc09d3a0ae3bffccd033245abe51 Aug 7, 2026
@fagonghaiwo

fagonghaiwo commented Aug 7, 2026

Copy link
Copy Markdown
bandicam 2026-08-07 18-30-06-340

old
[General]
;ApproachTarget.StopWhenInRange=1
AttackMove.StopWhenTargetAcquired=1

bandicam 2026-08-07 18-32-45-089

new
[General]
ApproachTarget.StopWhenInRange=1
;AttackMove.StopWhenTargetAcquired=1

doesnt work

@TaranDahl

Copy link
Copy Markdown
Contributor Author
image

This is not an issue with this feature. It is a problem with task switching. Hover has a similar issue to Jumpjet: their IsMovingNow is handled incorrectly, which causes incorrect evaluation of ReadyToNextMission. Even when AttackMove detects a target and queues an Attack mission, it cannot switch over.

Optional solutions:

  1. Simply revert to the old code. I do not know why, but since it works in practice, it works. However, the old implementation is essentially piling more garbage onto a garbage heap, because the root cause of the failure to stop properly comes from ApproachTarget rather than AttackMove. Other tasks that need to call ApproachTarget will still be problematic.
  2. Exclude Hover in FootClass_ReadyToNextMission_MovingCheck. In fact, I currently believe that the IsMovingNow check is unnecessary for any Locomotor. Side‑effects are unknown, though.
  3. (Recommended) Ignore the Hover shit, push forward the merge of PR2042, and then replace all Hover instances with AdvancedDrive.Hover.

@TaranDahl

Copy link
Copy Markdown
Contributor Author

@Coronia The choice is in your hands.

@Coronia

Coronia commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

First of all, I don't think the problem should be left unresolved even if AdvancedDrive is added. Hover is something that every mod has been used for age so it's not even feasible to replace them in a wide scale. Whatever AdvancedDrive did shouldn't be considered in the current topic

As of the problem itself, I think tweaking FootClass_ReadyToNextMission_MovingCheck might be an acceptable solution since this is the root cause. But if we want to avoid potential side effect, maybe we could just do some special handling to Hover for ApproachTarget's case alone? In worst case we can just reuse the previous codes for Hover alone since it has proven to work

In any case, if we can't find a proper solution then I would still suggest reverting the old implementation for now

@Coronia

Coronia commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

so far seems to be fine in testing, perhaps @Metadorius could take a look before the merge

@Coronia Coronia added Will be merged in 24h This PR will be merged in 24 hours if no one has further instructions. and removed Will be merged in 24h This PR will be merged in 24 hours if no one has further instructions. labels Aug 8, 2026
@Coronia

Coronia commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

there's still one remaining thing to optimize: using locomotion_cast to merely check if it's jumpjet or hover type is a little bit costy. I'll make a variable to cache it for such scenario, but that's not part of this PR anyway. Merge it first so that I can proceed the latter work

@Coronia
Coronia merged commit 99079b7 into Phobos-developers:develop Aug 9, 2026
7 checks passed
DeathFishAtEase added a commit to DeathFishAtEase/Phobos that referenced this pull request Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bounty available Interaction Something related to interaction with other extension, program etc. ⚙️T1 T1 maintainer review is sufficient Tested ❓Unhardcoding / Customization Make something more tweakable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants