mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-10 02:08:20 +00:00
43707952d2
* feat: move all ldf config to be in xml cleanup dev-tribute.xml add comments to atm.xml remove custom script tag in favor of ldfconfig for it * replace sto* calls with tryParse's * remove unesessary .has_value() calls and check for null_lot * remove member variable naming that on on-member vars * move max's vendor inventory to be configurable via vanity * Consolidate triplecated vendor code * don't write name if one is not given * Updates to vanity xml's and demo for later docs * rename vars
46 lines
1.9 KiB
C++
46 lines
1.9 KiB
C++
#include "DLUVanityTeleportingObject.h"
|
|
#include "GameMessages.h"
|
|
#include "dServer.h"
|
|
#include "VanityUtilities.h"
|
|
#include "RenderComponent.h"
|
|
|
|
void DLUVanityTeleportingObject::OnStartup(Entity* self) {
|
|
if (!self->HasVar(u"npcName")) return;
|
|
|
|
m_Object = VanityUtilities::GetObject(self->GetVarAsString(u"npcName"));
|
|
if (!m_Object) return;
|
|
if (self->HasVar(u"teleportInterval")) m_TeleportInterval = self->GetVar<float>(u"teleportInterval");
|
|
|
|
self->AddTimer("setupTeleport", m_TeleportInterval);
|
|
}
|
|
|
|
void DLUVanityTeleportingObject::OnTimerDone(Entity* self, std::string timerName) {
|
|
if (timerName == "setupTeleport") {
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam");
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings");
|
|
|
|
self->AddTimer("teleport", 2.0f);
|
|
self->AddTimer("stopFX", 2.0f);
|
|
} else if (timerName == "stopFX") {
|
|
GameMessages::SendStopFXEffect(self, true, "teleportBeam");
|
|
GameMessages::SendStopFXEffect(self, true, "teleportRings");
|
|
} else if (timerName == "teleport") {
|
|
std::vector<VanityObjectLocation>& locations = m_Object->m_Locations[Game::server->GetZoneID()];
|
|
|
|
selectLocation:
|
|
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) {
|
|
VanityObjectLocation& newLocation = locations[GeneralUtils::GenerateRandomNumber<size_t>(0, locations.size() - 1)];
|
|
}
|
|
|
|
self->SetPosition(newLocation.m_Position);
|
|
self->SetRotation(newLocation.m_Rotation);
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam");
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings");
|
|
self->AddTimer("stopFX", 2.0f);
|
|
self->AddTimer("setupTeleport", m_TeleportInterval);
|
|
}
|
|
}
|