Implementing and Fixing All Racing Achievements (#366)

* Grammatical changes in comments

* Grammatical fixes in comments

Small grammatical fixes found in comments throughout the code.

* Added descriptions to functions

Added descriptions to functions that didn't have them to keep the code well documented

* Created RacingTaskParam.h

Created RacingTaskParam so eliminate magic numbers in the original implementation of completing racing missions.

* Updated magic numbers in Mission.cpp

Updated magic numbers in Mission.cpp to a meaningful name.

* Implemented racing smashable task progression

Previously, races did not progress tasks for smashing Entities.  Now all achievements tracking smashables track them correctly.  This has been implemented in the three Entities that can be smashed in a race (imagination boxes, track specific smashables, Forbidden Valley dragon eggs).

* Updated race imagination task progression

Race imagination now no longer uses a magic number when passed to missionComponent.  Instead we use a number defined in an enum located in RacingTaskParam.h

* Updated Race task checks

Racing tasks for completing races without smashing now no longer auto complete the whole chain of missions.  Tasks that track placing on tracks and races overall now properly complete.  Tasks that count how many missions in a zone are completed now function.  Tasks that track race completions in multiple areas now function.

* Updated RacingControlComponent.cpp

Fixed any tasks that required 3 players to now require 3 or more players in a race to progress.  This restriction is ignored if the world config opted in for solo racing to allow progression in solo worlds.  Updated magic numbers sent into missionComponent->Progress to an enum created in this PR.  Fixed some indentation.

* Fixed a grammatical error in variable name

Fixed a grammatical error in the enum for task params
This commit is contained in:
David Markowitz
2022-02-05 03:28:17 -08:00
committed by GitHub
parent dc2bd76aba
commit c6f220ee31
15 changed files with 109 additions and 67 deletions

View File

@@ -15,6 +15,7 @@
#include "Player.h"
#include "PossessableComponent.h"
#include "PossessorComponent.h"
#include "RacingTaskParam.h"
#include "Spawner.h"
#include "VehiclePhysicsComponent.h"
#include "dServer.h"
@@ -401,18 +402,18 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity *player,
auto *missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent != nullptr) {
missionComponent->Progress(
MissionTaskType::MISSION_TASK_TYPE_RACING, 0, 13); // Enter race
missionComponent->Progress(
MissionTaskType::MISSION_TASK_TYPE_RACING, data->finished,
1); // Finish with rating, one track
missionComponent->Progress(
MissionTaskType::MISSION_TASK_TYPE_RACING, data->finished,
15); // Finish with rating, multiple tracks
missionComponent->Progress(
MissionTaskType::MISSION_TASK_TYPE_RACING, data->smashedTimes,
10); // Safe driver type missions
if (missionComponent == nullptr) return;
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, 0, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_COMPETED_IN_RACE); // Progress task for competing in a race
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, data->smashedTimes, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SAFE_DRIVER); // Finish a race without being smashed.
// If solo racing is enabled OR if there are 3 players in the race, progress placement tasks.
if(m_SoloRacing || m_LoadedPlayers > 2) {
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, data->finished, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_FINISH_WITH_PLACEMENT); // Finish in 1st place on a race
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, data->finished, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_FIRST_PLACE_MULTIPLE_TRACKS); // Finish in 1st place on multiple tracks.
if(m_Finished != 1) return;
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_WIN_RACE_IN_WORLD); // Finished first place in specific world.
}
} else if (id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") {
auto *vehicle = EntityManager::Instance()->GetEntity(data->vehicleID);
@@ -809,9 +810,7 @@ void RacingControlComponent::Update(float deltaTime) {
// Reached the start point, lapped
if (respawnIndex == 0) {
time_t lapTime =
std::time(nullptr) -
(player.lap == 1 ? m_StartTime : player.lapTime);
time_t lapTime = std::time(nullptr) - (player.lap == 1 ? m_StartTime : player.lapTime);
// Cheating check
if (lapTime < 40) {
@@ -833,10 +832,9 @@ void RacingControlComponent::Update(float deltaTime) {
playerEntity->GetComponent<MissionComponent>();
if (missionComponent != nullptr) {
// Lap time
missionComponent->Progress(
MissionTaskType::MISSION_TASK_TYPE_RACING,
(lapTime)*1000, 2);
// Progress lap time tasks
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, (lapTime)*1000, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_LAP_TIME);
if (player.lap == 3) {
m_Finished++;
@@ -852,15 +850,11 @@ void RacingControlComponent::Update(float deltaTime) {
raceTime, raceTime * 1000);
// Entire race time
missionComponent->Progress(
MissionTaskType::MISSION_TASK_TYPE_RACING,
(raceTime)*1000, 3);
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, (raceTime)*1000, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_TOTAL_TRACK_TIME);
auto *characterComponent =
playerEntity->GetComponent<CharacterComponent>();
auto *characterComponent = playerEntity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) {
characterComponent->TrackRaceCompleted(m_Finished ==
1);
characterComponent->TrackRaceCompleted(m_Finished == 1);
}
// TODO: Figure out how to update the GUI leaderboard.

View File

@@ -146,7 +146,7 @@ public:
void HandleMessageBoxResponse(Entity* player, const std::string& id);
/**
* Get the reacing data from a player's LWOOBJID.
* Get the racing data from a player's LWOOBJID.
*/
RacingPlayerInfo* GetPlayerData(LWOOBJID playerID);
@@ -230,7 +230,7 @@ private:
std::vector<LWOOBJID> m_LobbyPlayers;
/**
* The number of players that have fi nished the race
* The number of players that have finished the race
*/
uint32_t m_Finished;