Merge pull request #387 from EmosewaMC/BonsRepeatMissionTriggers

Fixed Battle of Nimbus Station achievements being repeatable
This commit is contained in:
Gie "Max" Vanommeslaeghe 2022-01-19 21:08:25 +01:00 committed by GitHub
commit 3bb1491f09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -368,16 +368,7 @@ void BaseWavesServer::GameOver(Entity *self, bool won) {
// Update all mission progression // Update all mission progression
auto* missionComponent = player->GetComponent<MissionComponent>(); auto* missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_MINIGAME, time, self->GetObjectID(), missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_MINIGAME, time, self->GetObjectID(), self->GetVar<std::string>(MissionTypeVariable));
self->GetVar<std::string>(MissionTypeVariable));
auto* mission = missionComponent->GetMission(479);
if (mission->GetMissionState() > MissionState::MISSION_STATE_AVAILABLE
&& mission->GetMissionState() < MissionState::MISSION_STATE_READY_TO_COMPLETE
&& time >= 60) {
mission->Progress(MissionTaskType::MISSION_TASK_TYPE_SCRIPT, self->GetObjectID());
}
} }
StopActivity(self, playerID, wave, time, score); StopActivity(self, playerID, wave, time, score);
@ -511,24 +502,40 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3
auto* missionComponent = player->GetComponent<MissionComponent>(); auto* missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
for (const auto& missionID : waveMission) { for (const auto& missionID : waveMission) {
missionComponent->AcceptMission(missionID); // Get the mission state
auto* mission = missionComponent->GetMission(missionID); auto missionState = missionComponent->GetMissionState(missionID);
// For some reason these achievements are not accepted by default, so we accept them here if they arent already.
if (mission != nullptr) { if (missionState != MissionState::MISSION_STATE_COMPLETE && missionState != MissionState::MISSION_STATE_UNKNOWN) {
mission->Progress(MissionTaskType::MISSION_TASK_TYPE_SCRIPT, self->GetLOT());
}
}
if (state.players.size() == 1) {
for (const auto& missionID : soloWaveMissions) {
missionComponent->AcceptMission(missionID); missionComponent->AcceptMission(missionID);
auto* mission = missionComponent->GetMission(missionID); missionState = missionComponent->GetMissionState(missionID);
}
if (missionState != MissionState::MISSION_STATE_COMPLETE) {
auto mission = missionComponent->GetMission(missionID);
if (mission != nullptr) { if (mission != nullptr) {
mission->Progress(MissionTaskType::MISSION_TASK_TYPE_SCRIPT, self->GetLOT()); mission->Progress(MissionTaskType::MISSION_TASK_TYPE_SCRIPT, self->GetLOT());
} }
} }
} }
// Progress solo missions
if (state.players.size() == 1) {
for (const auto& missionID : soloWaveMissions) {
// Get the mission state
auto missionState = missionComponent->GetMissionState(missionID);
// For some reason these achievements are not accepted by default, so we accept them here if they arent already.
if (missionState != MissionState::MISSION_STATE_COMPLETE && missionState != MissionState::MISSION_STATE_UNKNOWN) {
missionComponent->AcceptMission(missionID);
missionState = missionComponent->GetMissionState(missionID);
}
if (missionState != MissionState::MISSION_STATE_COMPLETE) {
auto mission = missionComponent->GetMission(missionID);
if (mission != nullptr) {
mission->Progress(MissionTaskType::MISSION_TASK_TYPE_SCRIPT, self->GetLOT());
}
}
}
}
} }
} }
} }
@ -548,11 +555,19 @@ void BaseWavesServer::UpdateMissionForAllPlayers(Entity* self, uint32_t missionI
auto* player = EntityManager::Instance()->GetEntity(playerID); auto* player = EntityManager::Instance()->GetEntity(playerID);
if (player != nullptr) { if (player != nullptr) {
auto* missionComponent = player->GetComponent<MissionComponent>(); auto* missionComponent = player->GetComponent<MissionComponent>();
missionComponent->AcceptMission(missionID); if (missionComponent == nullptr) return;
// Get the mission state
auto* mission = missionComponent->GetMission(missionID); auto missionState = missionComponent->GetMissionState(missionID);
if (mission != nullptr) { // For some reason these achievements are not accepted by default, so we accept them here if they arent already.
mission->Progress(MissionTaskType::MISSION_TASK_TYPE_SCRIPT, self->GetLOT()); if (missionState != MissionState::MISSION_STATE_COMPLETE && missionState != MissionState::MISSION_STATE_UNKNOWN) {
missionComponent->AcceptMission(missionID);
missionState = missionComponent->GetMissionState(missionID);
}
if (missionState != MissionState::MISSION_STATE_COMPLETE) {
auto mission = missionComponent->GetMission(missionID);
if (mission != nullptr) {
mission->Progress(MissionTaskType::MISSION_TASK_TYPE_SCRIPT, self->GetLOT());
}
} }
} }
} }