beyond-all-reason / beyond-all-reason/RecoilEngine

StrafeAir Fighters going astray and out of map

Open
#2,379 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
679
Forks
290
Avg merge
3d 2h
Merged PRs (30d)
40

Description

### Context

from discord: https://discord.com/channels/549281623154229250/1382564097509294251

game demo: https://www.beyondallreason.info/replays?gameId=1e4d48689677576a64028661d3de4de7

using this widget to help finding out whats happening: [dbg_debug_unit.lua](https://github.com/saurtron/bar-widgets/blob/main/debug/dbg_debug_unit.lua)

Seems like sometimes fighters leaving quite far off map and staying there for some time.

Reporters say this is a new issue since 1 week or so, so maybe related to recent engine changes, could be smth in BAR too, but didn't see anything specific pointing there.

### Investigation

I have some preliminary conclusions, but may need some discussion about what to do.

I don't see the unit receiving any special orders to go off map, its just in an area and goes to fight some incoming fighters, it seems to be getting an off map `MoveType->goalPos` (~= 7537, 316, 8194) due to internal `StrafeAirMoveType` logic.

the offmap `goalPos` in this case is set here:

https://github.com/beyond-all-reason/RecoilEngine/blob/b29554ca8a91605fa235eafe60ad740783359665/rts/Sim/MoveTypes/StrafeAirMoveType.cpp#L761-L764

Values at the point of getting the wrong new `goalPos`:

- goalPos: 2917.887451, 413.342346, 6891.113770 (this is the right area where the fig is fighting)
- difGoalPos: 4619.898438, -97.109131, 1303.566406 (this gets summed into goalPos and becomes off map destination)

Also for what I can see, the previous goalPos triggering the difference comes from this trace:

click to see trace

```
AAirMoveType.cpp:? AMoveType::SetGoal(float3 const&, float)
...//rts/System/float3.h:142 float3::operator-(float3 const&) const
...//rts/Sim/MoveTypes/StrafeAirMoveType.cpp:490 CStrafeAirMoveType::Update()
...//rts/Sim/MoveTypes/Systems/GeneralMoveSystem.cpp:43 GeneralMoveSystem::Update()
...//rts/lib/entt/src/entt/entity/view.hpp:783 each >
...//rts/Sim/MoveTypes/Systems/GeneralMoveSystem.cpp:33 GeneralMoveSystem::Update()
...//rts/Sim/Units/UnitHandler.cpp:336 CUnitHandler::UpdateUnitMoveTypes()
...//rts/Sim/Units/UnitHandler.cpp:454 CUnitHandler::Update()
```

Don't get why `difGoalPos` is chosen as it is, since a big difference between the old goal pos and the new one is going to be multiplied, also unsure why this doesn't cause more issues.

Seems CHoverAirMoveType sets oldGoalPos when doing SetGoal, while CStrafeAirMoveType doesn't, but not sure atm if doing that is the right solution here.

### More details

While this could be a game bug, I investigated this and doesn't seem to be the case.

In this case, the unit 16121 gets an (internal) attack order on another unit, who immediately dies (becomes a crashing fighter).

The affected unit seems

```lua
[f=0048177] 20, CMD_ATTACK, [31345], 8
[f=0048177] {"maxPitch":0.80000001,"progressState":"done","collide":false,"goalx":2917.88745,"maxAcc":0.20847496,"wantedHeight":248.853012,"useSmoothMesh":true,"aircraftState":"flying","maxWantedSpeed":379.5,"maxElevator":0.01107202,"maxRudder":0.00664545,"maxAileron":0.01502476,"myGravity":0.40000001,"maxSpeed":379.5,"goalz":6891.11377,"turnRadius":64,"goaly":413.342346,"name":"airplane","maxBank":0.80000001}
[f=0048177] Target start crashing, 31345
[f=0048178] {"maxPitch":0.80000001,"progressState":"done","collide":false,"goalx":7537.78613,"maxAcc":0.20847496,"wantedHeight":248.853012,"useSmoothMesh":true,"aircraftState":"flying","maxWantedSpeed":379.5,"maxElevator":0.01107202,"maxRudder":0.00664545,"maxAileron":0.01502476,"myGravity":0.40000001,"maxSpeed":379.5,"goalz":8194.67969,"turnRadius":64,"goaly":316.233215,"name":"airplane","maxBank":0.80000001}
[f=0048294] Lost Target, 31345
```

Contributor guide

Open the contributing guide

Research direction

Replay the linked game demo and inspect the debug_unit widget output for the fighter that receives an off-map goal after its attack target starts crashing. Start in rts/Sim/MoveTypes/StrafeAirMoveType.cpp around lines 490 and 761-764, then follow the provided Update and SetGoal trace. Done means the fighter no longer receives an unintended off-map destination in this scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.