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

Escorts can focus fire on newly captured ships #4129

Open
Amazinite opened this issue Jan 17, 2019 · 7 comments
Open

Escorts can focus fire on newly captured ships #4129

Amazinite opened this issue Jan 17, 2019 · 7 comments
Labels
bug Something in the game is not behaving as intended
Milestone

Comments

@Amazinite
Copy link
Collaborator

Amazinite commented Jan 17, 2019

Describe the bug
Escorts can focus fire on newly captured ships if the order to focus fire was given before the ship was captured.

To Reproduce

  1. Find a ship to capture and position yourself to capture it.
  2. Hit your focus fire button on the ship, then quickly hit your board button as to board the ship before your escorts start attacking it.
  3. Capture the ship.
  4. Watch as your escorts now fire on your newly captured ship.

Expected behavior
Escorts should ignore the focus fire command now that the target has become an escort itself, as escorts are typically unable to fire upon one another.

System:

  • OS: Windows 10 Home, Version 10.0.17134 Build 17134
  • Game Source: Self-compiled
  • Version: Most up to date as of this issue (b30f509)
@Amazinite Amazinite added the bug Something in the game is not behaving as intended label Jan 17, 2019
@tehhowch
Copy link
Collaborator

tehhowch commented Jan 18, 2019

A cursory look suggests this can be addressed by checking the current AI::orders during the AI::UpdateEvents method.


It's a bit more complicated than that (of course): the CAPTURE event is currently only emitted by the BoardingPanel, which currently doesn't have a way to send any events to the Engine class. (Only events that Engine knows about are run through AI::UpdateEvents, #2622, and only the AI class can manipulate the ships' Orders ).

One could probably include a short-term solution that adds to the existing order invalidation code:

endless-sky/source/AI.cpp

Lines 354 to 368 in 6e7043e

// Get rid of any invalid orders. Carried ships will retain orders in case they are deployed.
for(auto it = orders.begin(); it != orders.end(); )
{
if(it->second.type & Orders::REQUIRES_TARGET)
{
shared_ptr<Ship> ship = it->second.target.lock();
if(!ship || !ship->IsTargetable() || (it->first->GetSystem() && ship->GetSystem() != it->first->GetSystem())
|| (ship->IsDisabled() && it->second.type == Orders::ATTACK))
{
it = orders.erase(it);
continue;
}
}
++it;
}

e.g.

if(!ship || !ship->IsTargetable() || (it->first->GetSystem() && ship->GetSystem() != it->first->GetSystem())
		|| (ship->IsDisabled() && it->second.type == Orders::ATTACK))
{

becomes

if(!ship || !ship->IsTargetable() || (it->first->GetSystem() && ship->GetSystem() != it->first->GetSystem())
		|| (it->second.type == Orders::ATTACK && ship->IsDisabled())
		|| (it->second.type == Orders::FINISH_OFF && !ship->IsDisabled()))
{

Patching the behavior here could also incorporate a hostility check instead of a repair check--current behavior is that ordering a finish-off is equivalent to "attack it, even if disabled" and the above would make it "attack it, only if disabled"

The proper solution is going to be getting BoardingPanel connected with the Engine class, so that it can report appropriately to Engine, and Engine can ensure that the game AI is aware of the events as well.

@22144418
Copy link

I think the same effect happens with bribes yeah? when the projectiles hit despite having allied to them just before.

@Amazinite
Copy link
Collaborator Author

Ref: #2277
That's an entirely different scenario, as those are projectiles already in flight, but ships properly follow commands after bribes. In this situation, it's just ships that continue to follow the same command even though that command should now be invalid.

@tehhowch tehhowch added this to the 0.9.x milestone Apr 10, 2019
@tehhowch tehhowch modified the milestones: 0.9.x, 0.9.10 May 28, 2019
@tehhowch
Copy link
Collaborator

tehhowch commented Jul 7, 2019

If someone wouldn't mind trying, it would be good to know if this was ever not an issue. If it isn't an issue in v0.9.8, we don't need to block releasing v0.9.10 until this is fixed. The test is unfortunately not the simplest due to the randomness & setup involved, so I haven't spent the time to trace its origin.

@ChamEV
Copy link
Contributor

ChamEV commented Jul 7, 2019

I just used steams 0.9.8 version and confirmed that your escorts will target and kill your new boarded ship escort.

This happens in both cases F then B, B then F. Each time capturing the ship before escorts arrive in range and kill your new escort.

@tehhowch tehhowch modified the milestones: 0.9.10, 0.9.x Jul 7, 2019
@IsocratesGrey
Copy link

This seems to have been fixed in 0.10.0 as I cannot reproduce it.

@ziproot
Copy link
Contributor

ziproot commented Mar 11, 2023

I just reproduced it in latest continuous. Start boarding a ship, and when you are about to board, press focus fire, then capture the ship, and the fleet will kill the escort.
EDIT: Here is a video detailing the bug in latest continuous
EDIT 2: I accidentally messed up the video. Fixed.
EDIT 3: Apparently the video still won't show. IDK why. If you right click and click "save audio as," then you can watch the video.

traitors.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something in the game is not behaving as intended
Projects
None yet
Development

No branches or pull requests

6 participants