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

Fix hostiles running away. #5436

Merged
merged 1 commit into from
Dec 21, 2022

Conversation

azieba
Copy link
Contributor

@azieba azieba commented Dec 5, 2022

Now this is some funny bug. For some time I thought that the ships spawning in the combat missions were running away from me because I bought this big gun.
The truth is that when a ship gets AI command kill, if it is further then 16 km away it executes first the AICmdFlyTo and this command completes only on specific condition that the ship arrives at a point 15 km in front of target. This condition is almost never fulfilled if the player is actively perusing the hostile ship.
Additionally when the player is closer then 15km to the hostile, it still tries to fly to this point 15 km away from the player. Effectively it looks like it is running, always facing away.
I have attached a save file with a hostile Natrix in front of me. If you load it will be running away, unless you stop and wait for it to fly to this 15km point from you and only then it will return with guns blazing.

At first I tried to refactor the autopilot code not to use this 15km point and just use a distance condition. It was fine, but I noticed some performance issue. The AI ships started to behave somehow differently and the number of them started to increase with time. Maybe they could not land or stopped crashing.. I do not know.

So instead I decided to add this distance condition in the AICmdKill and to terminate the AICmdFlyTo from there.
I also removed numerous target distance calculations. Only one remains.

If you load the save game with the fix, the hostile will immediately turn around and start shooting.

test.gz

@impaktor
Copy link
Member

impaktor commented Dec 6, 2022

Ha, that was interesing! What you describe sounds familiar, and makes sense

@Web-eWorks Web-eWorks merged commit 08cf129 into pioneerspacesim:master Dec 21, 2022
@azieba azieba deleted the fix_running_hostiles branch December 21, 2022 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants