mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +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:
14
dScripts/02_server/Map/FV/CMakeLists.txt
Normal file
14
dScripts/02_server/Map/FV/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_MAP_FV
|
||||
"EnemyRoninSpawner.cpp"
|
||||
"FvCandle.cpp"
|
||||
"FvFong.cpp"
|
||||
"FvHorsemenTrigger.cpp"
|
||||
"ImgBrickConsoleQB.cpp")
|
||||
|
||||
add_subdirectory(Racing)
|
||||
|
||||
foreach(file ${DSCRIPTS_SOURCES_02_SERVER_MAP_FV_RACING})
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_MAP_FV ${DSCRIPTS_SOURCES_02_SERVER_MAP_FV} "Racing/${file}")
|
||||
endforeach()
|
||||
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_MAP_FV ${DSCRIPTS_SOURCES_02_SERVER_MAP_FV} PARENT_SCOPE)
|
68
dScripts/02_server/Map/FV/EnemyRoninSpawner.cpp
Normal file
68
dScripts/02_server/Map/FV/EnemyRoninSpawner.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "EnemyRoninSpawner.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
void EnemyRoninSpawner::OnStartup(Entity* self) {
|
||||
self->SetProximityRadius(15, "ronin");
|
||||
}
|
||||
|
||||
void EnemyRoninSpawner::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "hatchTime") {
|
||||
auto* renderComponent = self->GetComponent<RenderComponent>();
|
||||
|
||||
if (renderComponent != nullptr) {
|
||||
renderComponent->PlayEffect(644, u"create", "BurstFX1");
|
||||
}
|
||||
|
||||
EntityInfo info{};
|
||||
info.lot = 7815;
|
||||
info.pos = self->GetPosition();
|
||||
info.rot = self->GetRotation();
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
auto* spawnedEntity = EntityManager::Instance()->CreateEntity(info);
|
||||
|
||||
if (spawnedEntity == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(spawnedEntity);
|
||||
|
||||
spawnedEntity->AddCallbackTimer(60, [spawnedEntity]() {
|
||||
spawnedEntity->Smash(spawnedEntity->GetObjectID());
|
||||
});
|
||||
|
||||
self->Smash(self->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
void EnemyRoninSpawner::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
||||
if (entering->IsPlayer() && name == "ronin" && status == "ENTER" && !self->GetVar<bool>(u"hatching")) {
|
||||
StartHatching(self);
|
||||
|
||||
auto* skillComponent = self->GetComponent<SkillComponent>();
|
||||
|
||||
if (skillComponent != nullptr) {
|
||||
skillComponent->CalculateBehavior(305, 3568, LWOOBJID_EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnemyRoninSpawner::OnHit(Entity* self, Entity* attacker) {
|
||||
if (!self->GetVar<bool>(u"hatching")) {
|
||||
StartHatching(self);
|
||||
}
|
||||
}
|
||||
|
||||
void EnemyRoninSpawner::StartHatching(Entity* self) {
|
||||
self->SetVar(u"hatching", true);
|
||||
|
||||
auto* renderComponent = self->GetComponent<RenderComponent>();
|
||||
|
||||
if (renderComponent != nullptr) {
|
||||
renderComponent->PlayEffect(2260, u"rebuild_medium", "WakeUpFX1");
|
||||
}
|
||||
|
||||
self->AddTimer("hatchTime", 2);
|
||||
}
|
12
dScripts/02_server/Map/FV/EnemyRoninSpawner.h
Normal file
12
dScripts/02_server/Map/FV/EnemyRoninSpawner.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class EnemyRoninSpawner final : public CppScripts::Script {
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
|
||||
void OnHit(Entity* self, Entity* attacker) override;
|
||||
void StartHatching(Entity* self);
|
||||
};
|
||||
|
55
dScripts/02_server/Map/FV/FvCandle.cpp
Normal file
55
dScripts/02_server/Map/FV/FvCandle.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "FvCandle.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "RenderComponent.h"
|
||||
|
||||
std::vector<int32_t> FvCandle::m_Missions = { 850, 1431, 1529, 1566, 1603 };
|
||||
|
||||
void FvCandle::OnStartup(Entity* self) {
|
||||
auto* render = static_cast<RenderComponent*>(self->GetComponent(COMPONENT_TYPE_RENDER));
|
||||
if (render == nullptr)
|
||||
return;
|
||||
|
||||
render->PlayEffect(2108, u"create", "candle_light", LWOOBJID_EMPTY, 1.0f, 1.0f, true);
|
||||
self->SetI32(u"Smoke", static_cast<int32_t>(5));
|
||||
self->SetBoolean(u"AmHit", false);
|
||||
}
|
||||
|
||||
void FvCandle::OnHit(Entity* self, Entity* attacker) {
|
||||
BlowOutCandle(self, attacker);
|
||||
}
|
||||
|
||||
void FvCandle::BlowOutCandle(Entity* self, Entity* blower) {
|
||||
if (self->GetBoolean(u"AmHit"))
|
||||
return;
|
||||
|
||||
auto* render = static_cast<RenderComponent*>(self->GetComponent(COMPONENT_TYPE_RENDER));
|
||||
if (render == nullptr)
|
||||
return;
|
||||
|
||||
auto* missionComponent = blower->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponent != nullptr) {
|
||||
for (const auto mission : m_Missions) {
|
||||
missionComponent->ForceProgressTaskType(mission, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//Update mission tasks here
|
||||
self->SetBoolean(u"AmHit", true);
|
||||
|
||||
render->StopEffect("candle_light", false);
|
||||
render->PlayEffect(2109, u"create", "candle_smoke", LWOOBJID_EMPTY, 1.0f, 1.0f, true);
|
||||
|
||||
self->AddTimer("SmokeTime", self->GetI32(u"Smoke"));
|
||||
}
|
||||
|
||||
void FvCandle::OnTimerDone(Entity* self, std::string timerName) {
|
||||
self->SetBoolean(u"AmHit", false);
|
||||
|
||||
auto* render = static_cast<RenderComponent*>(self->GetComponent(COMPONENT_TYPE_RENDER));
|
||||
if (render == nullptr)
|
||||
return;
|
||||
|
||||
render->StopEffect("candle_smoke", false);
|
||||
render->PlayEffect(2108, u"create", "candle_light", LWOOBJID_EMPTY, 1.0f, 1.0f, true);
|
||||
}
|
14
dScripts/02_server/Map/FV/FvCandle.h
Normal file
14
dScripts/02_server/Map/FV/FvCandle.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class FvCandle : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self);
|
||||
void OnHit(Entity* self, Entity* attacker);
|
||||
void OnTimerDone(Entity* self, std::string timerName);
|
||||
private:
|
||||
void BlowOutCandle(Entity* self, Entity* blower);
|
||||
|
||||
static std::vector<int32_t> m_Missions;
|
||||
};
|
10
dScripts/02_server/Map/FV/FvFong.cpp
Normal file
10
dScripts/02_server/Map/FV/FvFong.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "FvFong.h"
|
||||
#include "Darkitect.h"
|
||||
#include "MissionState.h"
|
||||
|
||||
void FvFong::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) {
|
||||
if (missionID == 734 && missionState == MissionState::MISSION_STATE_READY_TO_COMPLETE) {
|
||||
Darkitect Baron;
|
||||
Baron.Reveal(self, target);
|
||||
}
|
||||
}
|
8
dScripts/02_server/Map/FV/FvFong.h
Normal file
8
dScripts/02_server/Map/FV/FvFong.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class FvFong : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) override;
|
||||
};
|
53
dScripts/02_server/Map/FV/FvHorsemenTrigger.cpp
Normal file
53
dScripts/02_server/Map/FV/FvHorsemenTrigger.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "FvHorsemenTrigger.h"
|
||||
#include "EntityManager.h"
|
||||
#include "MissionComponent.h"
|
||||
|
||||
void FvHorsemenTrigger::OnStartup(Entity* self) {
|
||||
self->SetProximityRadius(40, "horsemenTrigger");
|
||||
|
||||
self->SetVar<std::vector<LWOOBJID>>(u"players", {});
|
||||
}
|
||||
|
||||
void FvHorsemenTrigger::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
||||
if (name != "horsemenTrigger" || !entering->IsPlayer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto players = self->GetVar<std::vector<LWOOBJID>>(u"players");
|
||||
|
||||
const auto& iter = std::find(players.begin(), players.end(), entering->GetObjectID());
|
||||
|
||||
if (status == "ENTER" && iter == players.end()) {
|
||||
players.push_back(entering->GetObjectID());
|
||||
} else if (status == "LEAVE" && iter != players.end()) {
|
||||
players.erase(iter);
|
||||
}
|
||||
|
||||
self->SetVar<std::vector<LWOOBJID>>(u"players", players);
|
||||
}
|
||||
|
||||
void
|
||||
FvHorsemenTrigger::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3) {
|
||||
auto players = self->GetVar<std::vector<LWOOBJID>>(u"players");
|
||||
|
||||
if (args == "HorsemenDeath") {
|
||||
for (const auto& playerId : self->GetVar<std::vector<LWOOBJID>>(u"players")) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerId);
|
||||
|
||||
if (player == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponent == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const auto missionId : m_Missions) {
|
||||
missionComponent->ForceProgressTaskType(missionId, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
dScripts/02_server/Map/FV/FvHorsemenTrigger.h
Normal file
15
dScripts/02_server/Map/FV/FvHorsemenTrigger.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
#include "RenderComponent.h"
|
||||
|
||||
class FvHorsemenTrigger : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
|
||||
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3) override;
|
||||
|
||||
private:
|
||||
std::vector<int32_t> m_Missions = { 854, 738, 1432, 1530, 1567, 1604 };
|
||||
};
|
240
dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp
Normal file
240
dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
#include "ImgBrickConsoleQB.h"
|
||||
#include "RebuildComponent.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "EntityManager.h"
|
||||
#include "GameMessages.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
|
||||
int32_t ImgBrickConsoleQB::ResetBricks = 30;
|
||||
int32_t ImgBrickConsoleQB::ResetConsole = 60;
|
||||
int32_t ImgBrickConsoleQB::ResetInteract = 45;
|
||||
|
||||
void ImgBrickConsoleQB::OnStartup(Entity* self) {
|
||||
self->SetNetworkVar(u"used", false);
|
||||
|
||||
self->AddTimer("reset", ResetBricks);
|
||||
}
|
||||
|
||||
void ImgBrickConsoleQB::OnUse(Entity* self, Entity* user) {
|
||||
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
|
||||
|
||||
if (rebuildComponent->GetState() == REBUILD_COMPLETED) {
|
||||
if (!self->GetNetworkVar<bool>(u"used")) {
|
||||
const auto consoles = EntityManager::Instance()->GetEntitiesInGroup("Console");
|
||||
|
||||
auto bothBuilt = false;
|
||||
|
||||
for (auto* console : consoles) {
|
||||
auto* consoleRebuildComponent = console->GetComponent<RebuildComponent>();
|
||||
|
||||
if (consoleRebuildComponent->GetState() != REBUILD_COMPLETED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
console->CancelAllTimers();
|
||||
|
||||
if (console->GetNetworkVar<bool>(u"used")) {
|
||||
bothBuilt = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bothBuilt) {
|
||||
SmashCanister(self);
|
||||
} else {
|
||||
SpawnBrick(self);
|
||||
}
|
||||
|
||||
self->AddTimer("Die", ResetInteract);
|
||||
|
||||
auto onFX = 0;
|
||||
|
||||
const auto location = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"console"));
|
||||
|
||||
if (location == "Left") {
|
||||
onFX = 2776;
|
||||
} else {
|
||||
onFX = 2779;
|
||||
}
|
||||
|
||||
const auto& facility = EntityManager::Instance()->GetEntitiesInGroup("FacilityPipes");
|
||||
|
||||
if (!facility.empty()) {
|
||||
GameMessages::SendStopFXEffect(facility[0], true, location + "PipeEnergy");
|
||||
GameMessages::SendPlayFXEffect(facility[0]->GetObjectID(), onFX, u"create", location + "PipeOn");
|
||||
}
|
||||
}
|
||||
|
||||
auto* player = user;
|
||||
|
||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||
|
||||
if (missionComponent != nullptr && inventoryComponent != nullptr) {
|
||||
if (missionComponent->GetMissionState(1302) == MissionState::MISSION_STATE_ACTIVE) {
|
||||
inventoryComponent->RemoveItem(13074, 1);
|
||||
|
||||
missionComponent->ForceProgressTaskType(1302, 1, 1);
|
||||
}
|
||||
|
||||
if (missionComponent->GetMissionState(1926) == MissionState::MISSION_STATE_ACTIVE) {
|
||||
inventoryComponent->RemoveItem(14472, 1);
|
||||
|
||||
missionComponent->ForceProgressTaskType(1926, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
self->SetNetworkVar(u"used", true);
|
||||
|
||||
GameMessages::SendTerminateInteraction(player->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
void ImgBrickConsoleQB::SpawnBrick(Entity* self) {
|
||||
const auto netDevil = dZoneManager::Instance()->GetSpawnersByName("MaelstromBug");
|
||||
if (!netDevil.empty()) {
|
||||
netDevil[0]->Reset();
|
||||
netDevil[0]->Deactivate();
|
||||
}
|
||||
|
||||
const auto brick = dZoneManager::Instance()->GetSpawnersByName("Imagination");
|
||||
if (!brick.empty()) {
|
||||
brick[0]->Activate();
|
||||
}
|
||||
}
|
||||
|
||||
void ImgBrickConsoleQB::SmashCanister(Entity* self) {
|
||||
const auto brick = EntityManager::Instance()->GetEntitiesInGroup("Imagination");
|
||||
if (!brick.empty()) {
|
||||
GameMessages::SendPlayFXEffect(brick[0]->GetObjectID(), 122, u"create", "bluebrick");
|
||||
GameMessages::SendPlayFXEffect(brick[0]->GetObjectID(), 1034, u"cast", "imaginationexplosion");
|
||||
}
|
||||
|
||||
const auto canisters = EntityManager::Instance()->GetEntitiesInGroup("Canister");
|
||||
for (auto* canister : canisters) {
|
||||
canister->Smash(canister->GetObjectID(), VIOLENT);
|
||||
}
|
||||
|
||||
const auto canister = dZoneManager::Instance()->GetSpawnersByName("BrickCanister");
|
||||
if (!canister.empty()) {
|
||||
canister[0]->Reset();
|
||||
canister[0]->Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
void ImgBrickConsoleQB::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
auto energyFX = 0;
|
||||
|
||||
const auto location = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"console"));
|
||||
|
||||
if (location == "Left") {
|
||||
energyFX = 2775;
|
||||
} else {
|
||||
energyFX = 2778;
|
||||
}
|
||||
|
||||
const auto& facility = EntityManager::Instance()->GetEntitiesInGroup("FacilityPipes");
|
||||
|
||||
if (!facility.empty()) {
|
||||
GameMessages::SendStopFXEffect(facility[0], true, location + "PipeOff");
|
||||
GameMessages::SendPlayFXEffect(facility[0]->GetObjectID(), energyFX, u"create", location + "PipeEnergy");
|
||||
}
|
||||
|
||||
const auto consoles = EntityManager::Instance()->GetEntitiesInGroup("Console");
|
||||
|
||||
for (auto* console : consoles) {
|
||||
auto* consoleRebuildComponent = console->GetComponent<RebuildComponent>();
|
||||
|
||||
if (consoleRebuildComponent->GetState() != REBUILD_COMPLETED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
console->CancelAllTimers();
|
||||
}
|
||||
|
||||
self->AddTimer("Die", ResetConsole);
|
||||
}
|
||||
|
||||
void ImgBrickConsoleQB::OnDie(Entity* self, Entity* killer) {
|
||||
if (self->GetVar<bool>(u"Died")) {
|
||||
return;
|
||||
}
|
||||
|
||||
self->CancelAllTimers();
|
||||
|
||||
self->SetVar(u"Died", true);
|
||||
|
||||
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
|
||||
|
||||
if (rebuildComponent->GetState() == REBUILD_COMPLETED) {
|
||||
auto offFX = 0;
|
||||
|
||||
const auto location = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"console"));
|
||||
|
||||
if (location == "Left") {
|
||||
offFX = 2774;
|
||||
} else {
|
||||
offFX = 2777;
|
||||
}
|
||||
|
||||
const auto& facility = EntityManager::Instance()->GetEntitiesInGroup("FacilityPipes");
|
||||
|
||||
if (!facility.empty()) {
|
||||
GameMessages::SendStopFXEffect(facility[0], true, location + "PipeEnergy");
|
||||
GameMessages::SendStopFXEffect(facility[0], true, location + "PipeOn");
|
||||
GameMessages::SendPlayFXEffect(facility[0]->GetObjectID(), offFX, u"create", location + "PipeOff");
|
||||
GameMessages::SendPlayFXEffect(facility[0]->GetObjectID(), 2750, u"create", location + "imagination_canister");
|
||||
}
|
||||
}
|
||||
|
||||
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
|
||||
|
||||
const auto pipeGroup = myGroup.substr(0, 10);
|
||||
|
||||
const auto firstPipe = pipeGroup + "1";
|
||||
|
||||
const auto samePipeSpawner = dZoneManager::Instance()->GetSpawnersByName(myGroup);
|
||||
if (!samePipeSpawner.empty()) {
|
||||
samePipeSpawner[0]->Reset();
|
||||
samePipeSpawner[0]->Deactivate();
|
||||
}
|
||||
|
||||
const auto firstPipeSpawner = dZoneManager::Instance()->GetSpawnersByName(firstPipe);
|
||||
if (!firstPipeSpawner.empty()) {
|
||||
firstPipeSpawner[0]->Activate();
|
||||
}
|
||||
|
||||
const auto netdevil = dZoneManager::Instance()->GetSpawnersByName("Imagination");
|
||||
if (!netdevil.empty()) {
|
||||
netdevil[0]->Reset();
|
||||
netdevil[0]->Deactivate();
|
||||
}
|
||||
|
||||
const auto brick = dZoneManager::Instance()->GetSpawnersByName("MaelstromBug");
|
||||
if (!brick.empty()) {
|
||||
brick[0]->Activate();
|
||||
}
|
||||
|
||||
const auto canister = dZoneManager::Instance()->GetSpawnersByName("BrickCanister");
|
||||
if (!canister.empty()) {
|
||||
canister[0]->Activate();
|
||||
}
|
||||
|
||||
self->SetNetworkVar(u"used", false);
|
||||
}
|
||||
|
||||
void ImgBrickConsoleQB::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "reset") {
|
||||
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
|
||||
|
||||
if (rebuildComponent->GetState() == REBUILD_OPEN) {
|
||||
self->Smash(self->GetObjectID(), SILENT);
|
||||
}
|
||||
} else if (timerName == "Die") {
|
||||
const auto consoles = EntityManager::Instance()->GetEntitiesInGroup("Console");
|
||||
|
||||
for (auto* console : consoles) {
|
||||
console->Smash(console->GetObjectID(), VIOLENT);
|
||||
}
|
||||
}
|
||||
}
|
19
dScripts/02_server/Map/FV/ImgBrickConsoleQB.h
Normal file
19
dScripts/02_server/Map/FV/ImgBrickConsoleQB.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class ImgBrickConsoleQB : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnUse(Entity* self, Entity* user) override;
|
||||
void SpawnBrick(Entity* self);
|
||||
void SmashCanister(Entity* self);
|
||||
void OnRebuildComplete(Entity* self, Entity* target) override;
|
||||
void OnDie(Entity* self, Entity* killer) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
|
||||
public:
|
||||
static int32_t ResetBricks;
|
||||
static int32_t ResetConsole;
|
||||
static int32_t ResetInteract;
|
||||
};
|
3
dScripts/02_server/Map/FV/Racing/CMakeLists.txt
Normal file
3
dScripts/02_server/Map/FV/Racing/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_MAP_FV_RACING
|
||||
"RaceMaelstromGeiser.cpp"
|
||||
PARENT_SCOPE)
|
85
dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp
Normal file
85
dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#include "RaceMaelstromGeiser.h"
|
||||
#include "GameMessages.h"
|
||||
#include "PossessableComponent.h"
|
||||
#include "PossessorComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "RacingControlComponent.h"
|
||||
#include "dZoneManager.h"
|
||||
|
||||
void RaceMaelstromGeiser::OnStartup(Entity* self) {
|
||||
self->SetVar(u"AmFiring", false);
|
||||
|
||||
self->AddTimer("downTime", self->GetVar<int32_t>(u"startTime"));
|
||||
|
||||
self->SetProximityRadius(15, "deathZone");
|
||||
}
|
||||
|
||||
void RaceMaelstromGeiser::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
||||
if (!entering->IsPlayer() || name != "deathZone" || status != "ENTER") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self->GetVar<bool>(u"AmFiring")) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* possessableComponent = entering->GetComponent<PossessableComponent>();
|
||||
|
||||
Entity* vehicle;
|
||||
Entity* player;
|
||||
|
||||
if (possessableComponent != nullptr) {
|
||||
player = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
|
||||
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
vehicle = entering;
|
||||
} else if (entering->IsPlayer()) {
|
||||
auto* possessorComponent = entering->GetComponent<PossessorComponent>();
|
||||
|
||||
if (possessorComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
vehicle = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||
|
||||
if (vehicle == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
player = entering;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, VIOLENT, u"", 0, 0, 0, true, false, 0);
|
||||
|
||||
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();
|
||||
|
||||
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
|
||||
|
||||
if (racingControlComponent != nullptr) {
|
||||
racingControlComponent->OnRequestDie(player);
|
||||
}
|
||||
}
|
||||
|
||||
void RaceMaelstromGeiser::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "downTime") {
|
||||
GameMessages::SendPlayFXEffect(self->GetObjectID(), 4048, u"rebuild_medium", "geiser", LWOOBJID_EMPTY, 1, 1, true);
|
||||
|
||||
self->AddTimer("buildUpTime", 1);
|
||||
} else if (timerName == "buildUpTime") {
|
||||
self->SetVar(u"AmFiring", true);
|
||||
|
||||
self->AddTimer("killTime", 1.5f);
|
||||
} else if (timerName == "killTime") {
|
||||
GameMessages::SendStopFXEffect(self, true, "geiser");
|
||||
|
||||
self->SetVar(u"AmFiring", false);
|
||||
|
||||
self->AddTimer("downTime", 3.0);
|
||||
}
|
||||
}
|
10
dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.h
Normal file
10
dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class RaceMaelstromGeiser : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
|
||||
};
|
Reference in New Issue
Block a user