mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Merge remote-tracking branch 'upstream/main' into PetFixes
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
set(DSCRIPTS_SOURCES_02_SERVER_DLU
|
||||
"DLUVanityNPC.cpp"
|
||||
"DLUVanityTeleportingObject.cpp"
|
||||
PARENT_SCOPE)
|
||||
|
@@ -1,22 +1,22 @@
|
||||
#include "DLUVanityNPC.h"
|
||||
#include "DLUVanityTeleportingObject.h"
|
||||
#include "GameMessages.h"
|
||||
#include "dServer.h"
|
||||
#include "VanityUtilities.h"
|
||||
#include "RenderComponent.h"
|
||||
|
||||
void DLUVanityNPC::OnStartup(Entity* self) {
|
||||
m_NPC = VanityUtilities::GetNPC("averysumner - Destroyer of Worlds");
|
||||
void DLUVanityTeleportingObject::OnStartup(Entity* self) {
|
||||
if (!self->HasVar(u"npcName") || !self->HasVar(u"teleport")) return;
|
||||
m_Object = VanityUtilities::GetObject(self->GetVarAsString(u"npcName"));
|
||||
|
||||
if (m_NPC == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (!m_Object) return;
|
||||
if (self->HasVar(u"teleportInterval")) m_TeleportInterval = self->GetVar<float>(u"teleportInterval");
|
||||
|
||||
if (self->GetVar<bool>(u"teleport")) {
|
||||
self->AddTimer("setupTeleport", 15.0f);
|
||||
self->AddTimer("setupTeleport", m_TeleportInterval);
|
||||
}
|
||||
}
|
||||
|
||||
void DLUVanityNPC::OnTimerDone(Entity* self, std::string timerName) {
|
||||
void DLUVanityTeleportingObject::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "setupTeleport") {
|
||||
RenderComponent::PlayAnimation(self, u"interact");
|
||||
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam");
|
||||
@@ -28,20 +28,22 @@ void DLUVanityNPC::OnTimerDone(Entity* self, std::string timerName) {
|
||||
GameMessages::SendStopFXEffect(self, true, "teleportBeam");
|
||||
GameMessages::SendStopFXEffect(self, true, "teleportRings");
|
||||
} else if (timerName == "teleport") {
|
||||
std::vector<VanityNPCLocation>& locations = m_NPC->m_Locations[Game::server->GetZoneID()];
|
||||
std::vector<VanityObjectLocation>& locations = m_Object->m_Locations[Game::server->GetZoneID()];
|
||||
|
||||
selectLocation:
|
||||
VanityNPCLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber<size_t>(0, locations.size() - 1)];
|
||||
VanityObjectLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber<size_t>(0, locations.size() - 1)];
|
||||
|
||||
// try to get not the same position, but if we get the same one twice, it's fine
|
||||
if (self->GetPosition() == newLocation.m_Position) {
|
||||
goto selectLocation; // cry about it
|
||||
VanityObjectLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber<size_t>(0, locations.size() - 1)];
|
||||
}
|
||||
|
||||
self->SetPosition(newLocation.m_Position);
|
||||
self->SetRotation(newLocation.m_Rotation);
|
||||
self->SetScale(newLocation.m_Scale);
|
||||
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam");
|
||||
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings");
|
||||
self->AddTimer("stopFX", 2.0f);
|
||||
self->AddTimer("setupTeleport", 15.0f);
|
||||
self->AddTimer("setupTeleport", m_TeleportInterval);
|
||||
}
|
||||
}
|
@@ -1,13 +1,14 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class VanityNPC;
|
||||
class DLUVanityNPC : public CppScripts::Script
|
||||
class VanityObject;
|
||||
class DLUVanityTeleportingObject : public CppScripts::Script
|
||||
{
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
|
||||
private:
|
||||
VanityNPC* m_NPC;
|
||||
VanityObject* m_Object;
|
||||
float m_TeleportInterval = 15.0f;
|
||||
};
|
@@ -216,7 +216,7 @@
|
||||
#include "NtNaomiBreadcrumbServer.h"
|
||||
|
||||
// DLU Scripts
|
||||
#include "DLUVanityNPC.h"
|
||||
#include "DLUVanityTeleportingObject.h"
|
||||
|
||||
// AM Scripts
|
||||
#include "AmConsoleTeleportServer.h"
|
||||
@@ -834,8 +834,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
||||
script = new NjNyaMissionitems();
|
||||
|
||||
//DLU:
|
||||
else if (scriptName == "scripts\\02_server\\DLU\\DLUVanityNPC.lua")
|
||||
script = new DLUVanityNPC();
|
||||
else if (scriptName == "scripts\\02_server\\DLU\\DLUVanityTeleportingObject.lua")
|
||||
script = new DLUVanityTeleportingObject();
|
||||
|
||||
// Survival minigame
|
||||
else if (scriptName == "scripts\\02_server\\Enemy\\Survival\\L_AG_SURVIVAL_STROMBIE.lua")
|
||||
|
@@ -17,11 +17,11 @@ ScriptComponent::~ScriptComponent() {
|
||||
|
||||
}
|
||||
|
||||
void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
|
||||
void ScriptComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
if (bIsInitialUpdate) {
|
||||
const auto& networkSettings = m_Parent->GetNetworkSettings();
|
||||
auto hasNetworkSettings = !networkSettings.empty();
|
||||
outBitStream->Write(hasNetworkSettings);
|
||||
outBitStream.Write(hasNetworkSettings);
|
||||
|
||||
if (hasNetworkSettings) {
|
||||
|
||||
@@ -31,12 +31,12 @@ void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitial
|
||||
ldfData.Write<uint32_t>(networkSettings.size());
|
||||
|
||||
for (auto* networkSetting : networkSettings) {
|
||||
networkSetting->WriteToPacket(&ldfData);
|
||||
networkSetting->WriteToPacket(ldfData);
|
||||
}
|
||||
|
||||
// Finally write everything to the stream
|
||||
outBitStream->Write<uint32_t>(ldfData.GetNumberOfBytesUsed());
|
||||
outBitStream->Write(ldfData);
|
||||
outBitStream.Write<uint32_t>(ldfData.GetNumberOfBytesUsed());
|
||||
outBitStream.Write(ldfData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public:
|
||||
ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client = false);
|
||||
~ScriptComponent() override;
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
/**
|
||||
* Returns the script that's attached to this entity
|
||||
|
Reference in New Issue
Block a user