Organize dScripts (#814)

* Organize dScripts

whitespace

Remove parent scope

Remove parent scope from initial setter

Remove debug

Remove helper programs

* Fix NtImagimeterVisibility script

Co-authored-by: aronwk-aaron <aronwk.aaron@gmail.com>
This commit is contained in:
David Markowitz
2022-11-03 10:57:54 -07:00
committed by GitHub
parent b974eed8f5
commit 8d37d9b681
567 changed files with 886 additions and 252 deletions

View File

@@ -0,0 +1,6 @@
set(DSCRIPTS_SOURCES_AI_RACING_OBJECTS
"RaceImagineCrateServer.cpp"
"RaceImaginePowerup.cpp"
"FvRaceSmashEggImagineServer.cpp"
"RaceSmashServer.cpp"
PARENT_SCOPE)

View File

@@ -0,0 +1,38 @@
#include "FvRaceSmashEggImagineServer.h"
#include "CharacterComponent.h"
#include "DestroyableComponent.h"
#include "EntityManager.h"
#include "PossessableComponent.h"
#include "RacingTaskParam.h"
#include "MissionComponent.h"
void FvRaceSmashEggImagineServer::OnDie(Entity* self, Entity* killer) {
if (killer != nullptr) {
auto* destroyableComponent = killer->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) {
destroyableComponent->SetImagination(destroyableComponent->GetImagination() + 10);
EntityManager::Instance()->SerializeEntity(killer);
}
// get possessor to progress statistics and tasks.
auto* possessableComponent = killer->GetComponent<PossessableComponent>();
if (possessableComponent != nullptr) {
auto* possessor = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
if (possessor != nullptr) {
auto* missionComponent = possessor->GetComponent<MissionComponent>();
auto* characterComponent = possessor->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) {
characterComponent->UpdatePlayerStatistic(ImaginationPowerUpsCollected);
characterComponent->UpdatePlayerStatistic(RacingSmashablesSmashed);
}
if (missionComponent == nullptr) return;
// Dragon eggs have their own smash server so we handle mission progression for them here.
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, 0, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASHABLES);
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, self->GetLOT(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASH_SPECIFIC_SMASHABLE);
}
}
}
}

View File

@@ -0,0 +1,6 @@
#pragma once
#include "CppScripts.h"
class FvRaceSmashEggImagineServer : public CppScripts::Script {
void OnDie(Entity* self, Entity* killer) override;
};

View File

@@ -0,0 +1,55 @@
#include "CharacterComponent.h"
#include "DestroyableComponent.h"
#include "EntityManager.h"
#include "PossessableComponent.h"
#include "RaceImagineCrateServer.h"
#include "RacingTaskParam.h"
#include "MissionComponent.h"
#include "SkillComponent.h"
void RaceImagineCrateServer::OnDie(Entity* self, Entity* killer) {
if (self->GetVar<bool>(u"bIsDead")) {
return;
}
self->SetVar<bool>(u"bIsDead", true);
if (killer == nullptr) {
return;
}
auto* skillComponent = killer->GetComponent<SkillComponent>();
if (skillComponent == nullptr) {
return;
}
auto* destroyableComponent = killer->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) {
destroyableComponent->SetImagination(60);
EntityManager::Instance()->SerializeEntity(killer);
}
// Find possessor of race car to progress missions and update stats.
auto* possessableComponent = killer->GetComponent<PossessableComponent>();
if (possessableComponent != nullptr) {
auto* possessor = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
if (possessor != nullptr) {
auto* missionComponent = possessor->GetComponent<MissionComponent>();
auto* characterComponent = possessor->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) {
characterComponent->UpdatePlayerStatistic(RacingImaginationCratesSmashed);
characterComponent->UpdatePlayerStatistic(RacingSmashablesSmashed);
}
// Progress racing smashable missions
if (missionComponent == nullptr) return;
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, 0, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASHABLES);
}
}
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "CppScripts.h"
class RaceImagineCrateServer : public CppScripts::Script
{
public:
/**
* @brief When a boost smashable has been smashed, this function is called
*
* @param self The Entity that called this function.
* @param killer The Entity that killed this Entity.
*/
void OnDie(Entity* self, Entity* killer) override;
};

View File

@@ -0,0 +1,36 @@
#include "DestroyableComponent.h"
#include "EntityManager.h"
#include "PossessorComponent.h"
#include "RaceImaginePowerup.h"
#include "RacingTaskParam.h"
#include "MissionComponent.h"
void RaceImaginePowerup::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1,
int32_t param2, int32_t param3) {
if (sender->IsPlayer() && args == "powerup") {
auto* possessorComponent = sender->GetComponent<PossessorComponent>();
if (possessorComponent == nullptr) {
return;
}
auto* vehicle = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
if (vehicle == nullptr) {
return;
}
auto* destroyableComponent = vehicle->GetComponent<DestroyableComponent>();
if (destroyableComponent == nullptr) {
return;
}
destroyableComponent->Imagine(10);
auto* missionComponent = sender->GetComponent<MissionComponent>();
if (missionComponent == nullptr) return;
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, self->GetLOT(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_COLLECT_IMAGINATION);
}
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include "CppScripts.h"
class RaceImaginePowerup : public CppScripts::Script
{
public:
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) override;
};

View File

@@ -0,0 +1,30 @@
#include "CharacterComponent.h"
#include "EntityManager.h"
#include "PossessableComponent.h"
#include "RaceSmashServer.h"
#include "RacingTaskParam.h"
#include "MissionComponent.h"
void RaceSmashServer::OnDie(Entity* self, Entity* killer) {
// Crate is smashed by the car
auto* possessableComponent = killer->GetComponent<PossessableComponent>();
if (possessableComponent != nullptr) {
auto* possessor = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
if (possessor != nullptr) {
auto* missionComponent = possessor->GetComponent<MissionComponent>();
auto* characterComponent = possessor->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) {
characterComponent->UpdatePlayerStatistic(RacingSmashablesSmashed);
}
// Progress racing smashable missions
if (missionComponent == nullptr) return;
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, 0, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASHABLES);
// Progress missions that ask us to smash a specific smashable.
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, self->GetLOT(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASH_SPECIFIC_SMASHABLE);
}
}
}

View File

@@ -0,0 +1,12 @@
#pragma once
#include "CppScripts.h"
class RaceSmashServer : public CppScripts::Script {
/**
* @brief When a smashable has been destroyed, this function is called.
*
* @param self The Entity that called this function.
* @param killer The Entity that killed this Entity.
*/
void OnDie(Entity* self, Entity* killer) override;
};