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

Use 2D distance to check whether team members have arrived destination #1487

Merged
merged 9 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ This page lists all the individual contributions to the project by their author.
- Fix `LimboKill` not working reliably
- Allow using waypoints, area guard and attack move with aircraft
- Fix `Stop` command not working so well in some cases
- Use 2D distance instead of 3D distance to check whether 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 @@ -182,6 +182,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 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).
- 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.

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 distance to check whether team members have arrived destination (by CrimRecya)
- Subterranean movement now benefits from speed multipliers from all sources such as veterancy, AttachEffect etc. (by Starkku)

Phobos fixes:
Expand Down
29 changes: 29 additions & 0 deletions src/Misc/Hooks.BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,35 @@ DEFINE_HOOK(0x4C75DA, EventClass_RespondToEvent_Stop, 0x6)

#pragma endregion

#pragma region TeamCloseRangeFix

int __fastcall Check2DDistanceInsteadOf3D(AbstractClass* pSource, void* _, AbstractClass* pTarget)
{
const auto sourceCoords = pSource->GetCoords();
const auto targetCoords = pTarget->GetCoords();

int distance = Game::F2I(Point2D { sourceCoords.X - targetCoords.X, sourceCoords.Y - targetCoords.Y }.Magnitude());

if (const auto pBuilding = abstract_cast<BuildingClass*>(pTarget)) // Vanilla bonus to building
distance -= ((pBuilding->Type->GetFoundationWidth() + pBuilding->Type->GetFoundationHeight(false)) << 6);
CrimRecya marked this conversation as resolved.
Show resolved Hide resolved

return distance;
}
DEFINE_JUMP(CALL, 0x6EB686, GET_OFFSET(Check2DDistanceInsteadOf3D)); // MoveToObject - TeamSpawnCell
DEFINE_JUMP(CALL, 0x6EB8FF, GET_OFFSET(Check2DDistanceInsteadOf3D)); // TryToGuard - TeamSpawnCell1
DEFINE_JUMP(CALL, 0x6EB9C8, GET_OFFSET(Check2DDistanceInsteadOf3D)); // TryToGuard - TeamSpawnCell2
DEFINE_JUMP(CALL, 0x6EBB8C, GET_OFFSET(Check2DDistanceInsteadOf3D)); // MoveToCell - TeamSpawnCell
DEFINE_JUMP(CALL, 0x6EBCC9, GET_OFFSET(Check2DDistanceInsteadOf3D)); // MoveToCell - TeamFocus
DEFINE_JUMP(CALL, 0x6EBD6E, GET_OFFSET(Check2DDistanceInsteadOf3D)); // MoveToCell - SelfDestination
DEFINE_JUMP(CALL, 0x6EC1BB, GET_OFFSET(Check2DDistanceInsteadOf3D)); // InlineCall - CheckStray
DEFINE_JUMP(CALL, 0x6ED390, GET_OFFSET(Check2DDistanceInsteadOf3D)); // TryToLoad - TeamSpawnCell
DEFINE_JUMP(CALL, 0x6ED562, GET_OFFSET(Check2DDistanceInsteadOf3D)); // TryToDeploy - TeamSpawnCell
DEFINE_JUMP(CALL, 0x6ED873, GET_OFFSET(Check2DDistanceInsteadOf3D)); // NewMission - TeamSpawnCell1
DEFINE_JUMP(CALL, 0x6ED958, GET_OFFSET(Check2DDistanceInsteadOf3D)); // NewMission - TeamSpawnCell2
DEFINE_JUMP(CALL, 0x6EF1AE, GET_OFFSET(Check2DDistanceInsteadOf3D)); // TryToUnload - TeamSpawnCell

#pragma endregion

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