mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-26 23:43:34 +00:00
implement some missing scripts
This commit is contained in:
parent
e92cdc4f14
commit
b4acf329b4
@ -274,6 +274,10 @@
|
||||
#include "AgSurvivalMech.h"
|
||||
#include "AgSurvivalSpiderling.h"
|
||||
|
||||
// Frostburgh Scripts
|
||||
#include "RockHydrantBroken.h"
|
||||
#include "WhFans.h"
|
||||
|
||||
//Big bad global bc this is a namespace and not a class:
|
||||
InvalidScript* invalidToReturn = new InvalidScript();
|
||||
std::map<std::string, CppScripts::Script*> m_Scripts;
|
||||
@ -795,6 +799,12 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
||||
else if (scriptName == "scripts\\EquipmentScripts\\BuccaneerValiantShip.lua")
|
||||
script = new BuccaneerValiantShip();
|
||||
|
||||
// FB
|
||||
else if (scriptName = "scripts\\ai\\NS\\WH\\L_ROCKHYDRANT_BROKEN.lua")
|
||||
script = new RockHydrantBroken();
|
||||
else if (scriptName = "L_NS_WH_FANS.lua")
|
||||
script = new WhFans();
|
||||
|
||||
//Ignore these scripts:
|
||||
else if (scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua")
|
||||
script = invalidToReturn;
|
||||
|
46
dScripts/RockHydrantBroken.cpp
Normal file
46
dScripts/RockHydrantBroken.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#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);
|
||||
|
||||
Game::logger->Log("RockHydrantBroken", "Broken Hydrant spawned (%s)\n", hydrant.c_str());
|
||||
|
||||
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", 25);
|
||||
}
|
||||
|
||||
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(), 384, u"water", "water", LWOOBJID_EMPTY, 1, 1, true);
|
||||
}
|
||||
}
|
10
dScripts/RockHydrantBroken.h
Normal file
10
dScripts/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;
|
||||
};
|
||||
|
72
dScripts/WhFans.cpp
Normal file
72
dScripts/WhFans.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include "AgFans.h"
|
||||
|
||||
#include "RenderComponent.h"
|
||||
|
||||
void AgFans::OnStartup(Entity* self) {
|
||||
self->SetVar<bool>(u"alive", true);
|
||||
self->SetVar<bool>(u"on", false);
|
||||
|
||||
ToggleFX(self, false);
|
||||
|
||||
auto* renderComponent = static_cast<RenderComponent*>(self->GetComponent(COMPONENT_TYPE_RENDER));
|
||||
|
||||
if (renderComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
renderComponent->PlayEffect(495, u"fanOn", "fanOn");
|
||||
}
|
||||
|
||||
void AgFans::ToggleFX(Entity* self, bool hit) {
|
||||
std::string fanGroup = self->GetGroups()[0];
|
||||
std::vector<Entity*> fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup);
|
||||
|
||||
auto* renderComponent = static_cast<RenderComponent*>(self->GetComponent(COMPONENT_TYPE_RENDER));
|
||||
|
||||
if (renderComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fanVolumes.size() == 0 || !self->GetVar<bool>(u"alive")) return;
|
||||
|
||||
if (self->GetVar<bool>(u"on")) {
|
||||
GameMessages::SendPlayAnimation(self, u"fan-off");
|
||||
|
||||
renderComponent->StopEffect("fanOn");
|
||||
self->SetVar<bool>(u"on", false);
|
||||
|
||||
for (Entity* volume : fanVolumes) {
|
||||
PhantomPhysicsComponent* volumePhys = static_cast<PhantomPhysicsComponent*>(volume->GetComponent(COMPONENT_TYPE_PHANTOM_PHYSICS));
|
||||
if (!volumePhys) continue;
|
||||
volumePhys->SetPhysicsEffectActive(false);
|
||||
EntityManager::Instance()->SerializeEntity(volume);
|
||||
}
|
||||
}
|
||||
else if (!self->GetVar<bool>(u"on") && self->GetVar<bool>(u"alive")) {
|
||||
GameMessages::SendPlayAnimation(self, u"fan-on");
|
||||
|
||||
self->SetVar<bool>(u"on", true);
|
||||
|
||||
for (Entity* volume : fanVolumes) {
|
||||
PhantomPhysicsComponent* volumePhys = static_cast<PhantomPhysicsComponent*>(volume->GetComponent(COMPONENT_TYPE_PHANTOM_PHYSICS));
|
||||
if (!volumePhys) continue;
|
||||
volumePhys->SetPhysicsEffectActive(true);
|
||||
EntityManager::Instance()->SerializeEntity(volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AgFans::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3) {
|
||||
if (args.length() == 0 || !self->GetVar<bool>(u"alive")) return;
|
||||
|
||||
if ((args == "turnOn" && self->GetVar<bool>(u"on")) || (args == "turnOff" && !self->GetVar<bool>(u"on"))) return;
|
||||
ToggleFX(self, false);
|
||||
}
|
||||
|
||||
void AgFans::OnDie(Entity* self, Entity* killer) {
|
||||
if (self->GetVar<bool>(u"on")) {
|
||||
ToggleFX(self, true);
|
||||
}
|
||||
self->SetVar<bool>(u"alive", false);
|
||||
}
|
17
dScripts/WhFans.h
Normal file
17
dScripts/WhFans.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
#include "GameMessages.h"
|
||||
#include "EntityManager.h"
|
||||
#include "PhantomPhysicsComponent.h"
|
||||
|
||||
class WhFans : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self);
|
||||
void OnDie(Entity* self, Entity* killer);
|
||||
void OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3);
|
||||
private:
|
||||
void ToggleFX(Entity* self, bool hit);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user