From fe178bf745b3d4b5c5b83191ae4043f21e16a3be Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sat, 5 Feb 2022 03:54:12 -0800 Subject: [PATCH] Fully Implemented Shooting Gallery Mission and Achievement Fixes (#381) * Fixed tab indent * Fully implemented Achievement tracking for Shooting Gallery - Removed logging in MissionTask.cpp and moved the checks for mission progression to after checking the instance. - Implemented the achievement tracking in SGCannon as well as tracking of the maximum hit streak and progression of enemy smashes in the shooting gallery. --- dGame/dMission/MissionTask.cpp | 11 ++++------- dScripts/SGCannon.cpp | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/dGame/dMission/MissionTask.cpp b/dGame/dMission/MissionTask.cpp index d90f7682..12272008 100644 --- a/dGame/dMission/MissionTask.cpp +++ b/dGame/dMission/MissionTask.cpp @@ -338,9 +338,6 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& case MissionTaskType::MISSION_TASK_TYPE_MINIGAME: { - if (targets != info->targetGroup || info->targetValue > value) - break; - auto* minigameManager = EntityManager::Instance()->GetEntity(associate); if (minigameManager == nullptr) break; @@ -356,10 +353,10 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& break; } - Game::logger->Log("Minigame Task", "Progressing minigame with %s %d > %d (%d)\n", - targets.c_str(), value, info->targetValue, gameID); - SetProgress(info->target); - + if(info->targetGroup == targets && value >= info->targetValue) { + SetProgress(info->target); + break; + } break; } diff --git a/dScripts/SGCannon.cpp b/dScripts/SGCannon.cpp index a691443e..58e1d144 100644 --- a/dScripts/SGCannon.cpp +++ b/dScripts/SGCannon.cpp @@ -579,6 +579,8 @@ void SGCannon::StopGame(Entity *self, bool cancel) { self->GetObjectID(), "performact_score" ); + missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_MINIGAME, self->GetVar(MaxStreakVariable), self->GetObjectID(), "performact_streak"); + missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_ACTIVITY, m_CannonLot, 0, "", self->GetVar(TotalScoreVariable)); } LootGenerator::Instance().GiveActivityLoot(player, self, GetGameID(self), self->GetVar(TotalScoreVariable)); @@ -645,10 +647,6 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time if (!self->GetVar(SuperChargeActiveVariable)) { self->SetVar(u"m_curStreak", self->GetVar(u"m_curStreak") + 1); - - if (self->GetVar(u"m_curStreak") > 12) { - self->SetVar(u"m_curStreak", 12); - } } } else { @@ -693,6 +691,14 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time self->SetNetworkVar(u"updateScore", newScore); self->SetNetworkVar(u"beatHighScore", GeneralUtils::to_u16string(newScore)); + + auto* player = EntityManager::Instance()->GetEntity(self->GetVar(PlayerIDVariable)); + if (player == nullptr) return; + + auto missionComponent = player->GetComponent(); + if (missionComponent == nullptr) return; + + missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_SMASH, spawnInfo.lot, self->GetObjectID()); } void SGCannon::UpdateStreak(Entity* self) @@ -722,6 +728,8 @@ void SGCannon::UpdateStreak(Entity* self) self->SetNetworkVar(u"UnMarkAll", true); } } + auto maxStreak = self->GetVar(MaxStreakVariable); + if (maxStreak < curStreak) self->SetVar(MaxStreakVariable, curStreak); } float_t SGCannon::GetCurrentBonus(Entity* self)