Skip to content

Commit

Permalink
Use 2D distance to check whether team members have arrived destination (
Browse files Browse the repository at this point in the history
#1487)

- Now the team members use the 2D distance instead of the 3D distance to
judge whether to reach the mission destination, so as to prevent the
problem that the mission is stuck and cannot continue in some cases
(such as when the jumpjet stops on the building).

---------

Co-authored-by: Kerbiter <[email protected]>
  • Loading branch information
CrimRecya and Metadorius authored Jan 13, 2025
1 parent 32f4cd3 commit 4699bc4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ This page lists all the individual contributions to the project by their author.
- Allow using waypoints, area guard and attack move with aircraft
- Fix `Stop` command not working so well in some cases
- Fix aircraft `MovementZone` and `SpeedType` inconsistencies
- Use 2D distance instead of 3D to check whether in air team members have arrived destination
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
Expand Down
1 change: 1 addition & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Aircraft no longer find airport twice and overlap.
- Aircraft no longer briefly pause in the air before returning.
- Aircraft with `AirportBound=no` continue moving forward.
- Now in air team members will use the 2D distance instead of the 3D distance to judge whether have reached the mission destination, so as to prevent the problem that the mission is stuck and cannot continue in some cases (such as when the jumpjet stops on the building).
- Unit `Speed` setting now accepts floating-point values. Internally parsed values are clamped down to maximum of 100, multiplied by 256 and divided by 100, the result (which at this point is converted to an integer) then clamped down to maximum of 255 giving effective internal speed value range of 0 to 255, e.g leptons traveled per game frame.
- Subterranean movement now benefits from speed multipliers from all sources such as veterancy, AttachEffect etc.
- Aircraft will now behave as expected according to it's `MovementZone` and `SpeedType` when moving onto different surfaces. In particular, this fixes erratic behavior when vanilla aircraft is ordered to move onto water surface and instead the movement order changes to a shore nearby.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ Vanilla fixes:
- Follower vehicle index for preplaced vehicles in maps is now explicitly constrained to `[Units]` list in map files and is no longer thrown off by vehicles that could not be created or created vehicles having other vehicles as initial passengers (by Starkku)
- Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix (by tyuah8)
- Fix `Stop` command not working so well in some cases (by CrimRecya)
- Use 2D distance instead of 3D to check whether in air team members have arrived destination (by CrimRecya)
- Subterranean movement now benefits from speed multipliers from all sources such as veterancy, AttachEffect etc. (by Starkku)
- Aircraft will now behave as expected according to it's `MovementZone` and `SpeedType` when moving onto different surfaces. In particular, this fixes erratic behavior when vanilla aircraft is ordered to move onto water surface and instead the movement order changes to a shore nearby (by CrimRecya)
Expand Down
15 changes: 15 additions & 0 deletions src/Misc/Hooks.BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,21 @@ DEFINE_HOOK(0x4C75DA, EventClass_RespondToEvent_Stop, 0x6)

#pragma endregion

#pragma region TeamCloseRangeFix

int __fastcall Check2DDistanceInsteadOf3D(ObjectClass* pSource, void* _, AbstractClass* pTarget)
{
// At present, it seems that aircraft use their own mapcoords and the team destination's mapcoords to check.
// During the previous test, it was found that if the aircraft uses this and needs to return to the airport
// with the script first, it will interrupt the remaining tasks for unknown reasons - CrimRecya
return (pSource->IsInAir() && pSource->WhatAmI() != AbstractType::Aircraft) // Jumpjets or sth in the air
? (pSource->DistanceFrom(pTarget) * 2) // 2D distance (2x is the bonus to units in the air)
: pSource->DistanceFrom3D(pTarget); // 3D distance (vanilla)
}
DEFINE_JUMP(CALL, 0x6EBCC9, GET_OFFSET(Check2DDistanceInsteadOf3D));

#pragma endregion

// This shouldn't be here
// Author: tyuah8
DEFINE_HOOK_AGAIN(0x4AF94D, EndPiggyback_PowerOn, 0x7) // Drive
Expand Down

0 comments on commit 4699bc4

Please sign in to comment.