mirror of
				https://github.com/DarkflameUniverse/DarkflameServer.git
				synced 2025-11-04 06:32:00 +00:00 
			
		
		
		
	Fixed BoNS achievements being repeatable
This commit is contained in:
		@@ -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,19 +502,34 @@ 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) {
 | 
				
			||||||
 | 
					                        // 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);
 | 
					                            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) {
 | 
					                    if (state.players.size() == 1) {
 | 
				
			||||||
                            for (const auto& missionID : soloWaveMissions) {
 | 
					                            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);
 | 
					                                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());
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
@@ -532,6 +538,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Might seem odd to send the next wave but the client isn't 0-indexed so it thinks it completed the correct wave
 | 
					        // Might seem odd to send the next wave but the client isn't 0-indexed so it thinks it completed the correct wave
 | 
				
			||||||
        self->SetNetworkVar<uint32_t>(WaveCompleteVariable, { state.waveNumber, (uint32_t) currentTime });
 | 
					        self->SetNetworkVar<uint32_t>(WaveCompleteVariable, { state.waveNumber, (uint32_t) currentTime });
 | 
				
			||||||
@@ -548,14 +555,22 @@ 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>();
 | 
				
			||||||
 | 
					            if (missionComponent == nullptr) return;
 | 
				
			||||||
 | 
					            // 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);
 | 
					                missionComponent->AcceptMission(missionID);
 | 
				
			||||||
 | 
					                missionState = missionComponent->GetMissionState(missionID);
 | 
				
			||||||
            auto* mission = missionComponent->GetMission(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());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BaseWavesServer::ClearSpawners() {
 | 
					void BaseWavesServer::ClearSpawners() {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user