mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
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:
6
dScripts/ai/RACING/OBJECTS/CMakeLists.txt
Normal file
6
dScripts/ai/RACING/OBJECTS/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
set(DSCRIPTS_SOURCES_AI_RACING_OBJECTS
|
||||
"RaceImagineCrateServer.cpp"
|
||||
"RaceImaginePowerup.cpp"
|
||||
"FvRaceSmashEggImagineServer.cpp"
|
||||
"RaceSmashServer.cpp"
|
||||
PARENT_SCOPE)
|
38
dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp
Normal file
38
dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
6
dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.h
Normal file
6
dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class FvRaceSmashEggImagineServer : public CppScripts::Script {
|
||||
void OnDie(Entity* self, Entity* killer) override;
|
||||
};
|
55
dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp
Normal file
55
dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
14
dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.h
Normal file
14
dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.h
Normal 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;
|
||||
};
|
36
dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp
Normal file
36
dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp
Normal 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);
|
||||
}
|
||||
}
|
9
dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.h
Normal file
9
dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.h
Normal 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;
|
||||
};
|
30
dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp
Normal file
30
dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
12
dScripts/ai/RACING/OBJECTS/RaceSmashServer.h
Normal file
12
dScripts/ai/RACING/OBJECTS/RaceSmashServer.h
Normal 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;
|
||||
};
|
Reference in New Issue
Block a user