Skip to content

Commit

Permalink
Merge branch 'develop' into develop-TeamStray
Browse files Browse the repository at this point in the history
  • Loading branch information
Metadorius authored Jan 13, 2025
2 parents 9078a19 + 32f4cd3 commit 31e3d16
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
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
- 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
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 @@ -186,6 +186,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- 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.

## Fixes / interactions with other extensions

Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ Vanilla fixes:
- 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)
Phobos fixes:
- Fixed a few errors of calling for superweapon launch by `LaunchSW` or building infiltration (by Trsdy)
Expand Down
21 changes: 19 additions & 2 deletions src/Ext/Aircraft/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,32 @@ DEFINE_HOOK(0x416A0A, AircraftClass_Mission_Move_SmoothMoving, 0x5)
const int distance = Game::F2I(Point2D { pCoords->X, pCoords->Y }.DistanceFrom(Point2D { pThis->Location.X, pThis->Location.Y }));

// When the horizontal distance between the aircraft and its destination is greater than half of its deceleration distance
// or its turning radius, continue to move forward, otherwise return to airbase or execute the next planning path
// or its turning radius, continue to move forward, otherwise return to airbase or execute the next planning waypoint
if (distance > std::max((pType->SlowdownDistance >> 1), (2048 / pType->ROT)))
return (R->Origin() == 0x4168C7 ? ContinueMoving1 : ContinueMoving2);

pThis->EnterIdleMode(false, true);
// Try next planning waypoint first, then return to air base if it does not exist or cannot be taken
if (!pThis->TryNextPlanningTokenNode())
pThis->EnterIdleMode(false, true);

return EnterIdleAndReturn;
}

DEFINE_HOOK(0x4DDD66, FootClass_IsLandZoneClear_ReplaceHardcode, 0x6) // To avoid that the aircraft cannot fly towards the water surface normally
{
enum { SkipGameCode = 0x4DDD8A };

GET(FootClass* const, pThis, EBP);
GET_STACK(CellStruct, cell, STACK_OFFSET(0x20, 0x4));

const auto pType = pThis->GetTechnoType();

// In vanilla, only aircrafts or `foots with fly locomotion` will call this virtual function
// So I don't know why WW use hard-coded `SpeedType::Track` and `MovementZone::Normal` to check this
R->AL(MapClass::Instance->GetCellAt(cell)->IsClearToMove(pType->SpeedType, false, false, -1, pType->MovementZone, -1, true));
return SkipGameCode;
}

// AreaGuard: return when no ammo or first target died
DEFINE_HOOK_AGAIN(0x41A982, AircraftClass_Mission_AreaGuard, 0x6)
DEFINE_HOOK(0x41A96C, AircraftClass_Mission_AreaGuard, 0x6)
Expand Down

0 comments on commit 31e3d16

Please sign in to comment.