-
Notifications
You must be signed in to change notification settings - Fork 990
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(mechanics): Properly disable triggers for failed missions #10046
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like someone forgot our bracket style
Co-authored-by: TomGoodIdea <108272452+TomGoodIdea@users.noreply.github.com>
Co-authored-by: TomGoodIdea <108272452+TomGoodIdea@users.noreply.github.com>
Co-authored-by: TomGoodIdea <108272452+TomGoodIdea@users.noreply.github.com>
Co-authored-by: TomGoodIdea <108272452+TomGoodIdea@users.noreply.github.com>
Co-authored-by: TomGoodIdea <108272452+TomGoodIdea@users.noreply.github.com>
If you turn the check into an |
Yeah, but that would make it harder to exclude some triggers from that check. I'm still worried that some NPC things could happen after the mission is failed... I should go and check if |
Check |
I think |
|
…-sky into condition-fix
This change restores the previous NPC behaviour. This means NPCs can still fail a mission before showing a popup dialog. The issue with this is that if there are multiple NPCs, none of them are checking the mission state, so you can get the popups even if the mission failed in a previous frame. (This is same as the previous behaviour, btw.) I'm not sure how to fix it. My best idea so far is to only fail a mission at the end of a frame (or only update the value checked in The real issue is that I can't tell if people were relying on the previous, bugged behaviour. If we fix the NPC issue, then you can abort a mission and shoot the NPCs without any record of it being made, which could cause issues if they were carrying some VIPs in a storyline. (Even the same ships showing up could be an issue story-wise.) Test mission:
|
This is what the Unstable releases are for, right? To check if new features/fixes break things. If we get many complaints, we can revert it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place where Mission::Do(Mission::STOPOVER, ...)
(the other "Do" function) is called and I'm pretty sure it means it still can be triggered if failed (probably shouldn't?).
endless-sky/source/PlayerInfo.cpp
Lines 4138 to 4142 in a01426e
// If this is a stopover for the mission, perform the stopover action. | |
mission.Do(Mission::STOPOVER, *this, ui); | |
if(mission.IsFailed(*this)) | |
RemoveMission(Mission::FAIL, mission, ui); |
source/Mission.cpp
Outdated
if((event.Type() & ShipEvent::DISABLE) && event.Target() == player.FlagshipPtr()) | ||
Do(DISABLED, player, ui); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flagship always belongs to the player, so you can move this to the if(event.TargetGovernment()->IsPlayer())
block above. yeah ik it wasn't there before, but since you're changing it anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see the point tbh, we aren't using it anywhere else.
Co-authored-by: TomGoodIdea <108272452+TomGoodIdea@users.noreply.github.com>
I'm actually going to question if this should even be considered a bug. To me, saying this is bugged would imply that the original intention was for actions to not trigger after the mission has already failed. I don't get the impression that this was ever an intention, though, especially as this sounds like how missions have always behaved. The Do function for mission actions didn't check the failed state of the mission, and the Do function for ship events only checked the failed state to prevent displaying irrelevant messages. Given that the behavior for so long has been to trigger the action when it's possible to do so, regardless of whether the mission itself has already failed, I think I'd prefer some method of explicitly flagging actions as being unable to run should the mission have already failed. That way we can pick and choose when we feel that it makes sense for an action to not run if the mission has failed. |
Looking at #8606, where the This probably didn't come up as an issue before because there are no uses of Honestly, I'm having trouble thinking of a scenario where we would want such a trigger to work for a failed mission - in fact, failed missions should try to interact with the player as little as possible. |
In #8606 I thought that if mission triggers shouldn't work for failed missions, it's most likely handled somewhere else already. I probably looked at the waypoint trigger, which also doesn't check for failure. |
Since a failed mission will trigger its on fail action the moment you land, we wouldn't want any other actions that require you to be landed first to trigger. I believe this is already the case. That means that we only need to consider actions which can be triggered in space, which includes the following:
You have already noted how running an action after the mission has already failed can have a use.
Every action should check CanBeDone() before it is run. NPC actions currently don't do this, but #9830 makes it so that they do. Mission actions make this check, including daily, enter, disabled, and waypoint. CanBeDone() has a parameter for the player object and is called in locations that have access to the Mission object. Perhaps we make it so that CanBeDone() checks if the mission has been failed and returns false if this is the case, unless the action has some sort of "can run when failed" flag for the uncommon case where we actually do want the action to run even after the mission has failed. That is, the default would be to not trigger actions on failed missions, but we could have the option to still trigger stuff before the mission has been removed if we'd like. |
The fact it only triggers the failing convo on landing keeps bugging me when I write missions that can fail |
I do think we should eventually have a means on triggering an action the instant a mission fails. |
The string token is a placeholder, and I need to test that it works at all. |
It's a hacky workaround, but it works; the previous behaviour can now be restored by adding I do think creating separate actions for these would be better (something like |
I don't like the length of the token name but other than that it looks ok |
Yeah the token is just a placeholder for now |
I feel like it would bloat things to have duplicate action types for whether they can or can't (or only) trigger after the mission has failed. It would also only allow new functionality in very, very specific use cases. I think a more customizable solution would be to allow multiple action nodes of the same type to exist under a mission. (We might leave some types out, such as
|
That sounds really interesting. It's beyond the scope of this PR, but it would certainly enable more functionality. An alternative could be to allow giving conditions to any |
Bug fix
This PR fixes a bug where mission triggers would activate for failed missions.
Summary
Mission triggers such as
on disabled
were missing checks for the mission state. This PR wraps allMission::Do
actions in a check, making them a no-on when the mission is failed.Testing Done
I tested that the
on disabled
trigger doesn't trigger anymore for failed missions. I'm still testing whether this breaks any existing content; especially the NPC triggers.Performance Impact
N/A