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:
4
dScripts/ai/NS/WH/CMakeLists.txt
Normal file
4
dScripts/ai/NS/WH/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
set(DSCRIPTS_SOURCES_AI_NS_WH
|
||||
"RockHydrantSmashable.cpp"
|
||||
"RockHydrantBroken.cpp"
|
||||
PARENT_SCOPE)
|
38
dScripts/ai/NS/WH/RockHydrantBroken.cpp
Normal file
38
dScripts/ai/NS/WH/RockHydrantBroken.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "RockHydrantBroken.h"
|
||||
#include "EntityManager.h"
|
||||
#include "GameMessages.h"
|
||||
|
||||
void RockHydrantBroken::OnStartup(Entity* self) {
|
||||
self->AddTimer("playEffect", 1);
|
||||
|
||||
const auto hydrant = "hydrant" + self->GetVar<std::string>(u"hydrant");
|
||||
|
||||
const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant);
|
||||
|
||||
for (auto* bouncer : bouncers) {
|
||||
self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID());
|
||||
|
||||
|
||||
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
self->AddTimer("KillBroken", 10);
|
||||
}
|
||||
|
||||
void RockHydrantBroken::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "KillBroken") {
|
||||
auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"bouncer"));
|
||||
|
||||
if (bouncer != nullptr) {
|
||||
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision", UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
self->Kill();
|
||||
} else if (timerName == "playEffect") {
|
||||
GameMessages::SendPlayFXEffect(self->GetObjectID(), 4737, u"water", "water", LWOOBJID_EMPTY, 1, 1, true);
|
||||
}
|
||||
}
|
10
dScripts/ai/NS/WH/RockHydrantBroken.h
Normal file
10
dScripts/ai/NS/WH/RockHydrantBroken.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class RockHydrantBroken : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
};
|
||||
|
20
dScripts/ai/NS/WH/RockHydrantSmashable.cpp
Normal file
20
dScripts/ai/NS/WH/RockHydrantSmashable.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "RockHydrantSmashable.h"
|
||||
#include "EntityManager.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
void RockHydrantSmashable::OnDie(Entity* self, Entity* killer) {
|
||||
const auto hydrantName = self->GetVar<std::u16string>(u"hydrant");
|
||||
|
||||
LDFBaseData* data = new LDFData<std::string>(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName));
|
||||
|
||||
EntityInfo info{};
|
||||
info.lot = ROCK_HYDRANT_BROKEN;
|
||||
info.pos = self->GetPosition();
|
||||
info.rot = self->GetRotation();
|
||||
info.settings = { data };
|
||||
info.spawnerID = self->GetSpawnerID();
|
||||
|
||||
auto* hydrant = EntityManager::Instance()->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(hydrant);
|
||||
}
|
11
dScripts/ai/NS/WH/RockHydrantSmashable.h
Normal file
11
dScripts/ai/NS/WH/RockHydrantSmashable.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class RockHydrantSmashable : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnDie(Entity* self, Entity* killer);
|
||||
private:
|
||||
LOT ROCK_HYDRANT_BROKEN = 12293;
|
||||
};
|
||||
|
Reference in New Issue
Block a user