2021-12-05 17:54:36 +00:00
|
|
|
#include "BaseConsoleTeleportServer.h"
|
|
|
|
#include "GameMessages.h"
|
2024-01-11 12:33:53 +00:00
|
|
|
#include "CharacterComponent.h"
|
2023-03-20 13:10:52 +00:00
|
|
|
#include "RenderComponent.h"
|
|
|
|
#include "EntityManager.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eTerminateType.h"
|
|
|
|
#include "eStateChangeType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void BaseConsoleTeleportServer::BaseOnUse(Entity* self, Entity* user) {
|
|
|
|
auto* player = user;
|
|
|
|
|
|
|
|
const auto& teleportLocString = self->GetVar<std::u16string>(u"teleportString");
|
|
|
|
|
|
|
|
GameMessages::SendDisplayMessageBox(player->GetObjectID(), true, self->GetObjectID(), u"TransferBox", 0, teleportLocString, u"", player->GetSystemAddress());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseConsoleTeleportServer::BaseOnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
|
|
|
|
auto* player = sender;
|
|
|
|
|
|
|
|
if (button == 1) {
|
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
GameMessages::SendSetStunned(
|
|
|
|
player->GetObjectID(), eStateChangeType::PUSH, player->GetSystemAddress(), player->GetObjectID(),
|
2021-12-05 17:54:36 +00:00
|
|
|
true, true, true, true, true, true, true
|
|
|
|
);
|
|
|
|
|
|
|
|
const auto teleportFXID = self->GetVar<int32_t>(u"teleportEffectID");
|
|
|
|
|
|
|
|
if (teleportFXID != 0) {
|
|
|
|
const auto& teleportFXs = self->GetVar<std::vector<std::u16string>>(u"teleportEffectTypes");
|
|
|
|
|
|
|
|
for (const auto& type : teleportFXs) {
|
|
|
|
GameMessages::SendPlayFXEffect(player->GetObjectID(), teleportFXID, type, "FX" + GeneralUtils::UTF16ToWTF8(type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto& teleIntroAnim = self->GetVar<std::u16string>(u"teleportAnim");
|
2023-03-20 13:10:52 +00:00
|
|
|
auto animTime = 3.32999992370605f;
|
2021-12-05 17:54:36 +00:00
|
|
|
if (!teleIntroAnim.empty()) {
|
2023-03-20 13:10:52 +00:00
|
|
|
animTime = RenderComponent::PlayAnimation(player, teleIntroAnim);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdatePlayerTable(self, player, true);
|
|
|
|
|
|
|
|
const auto playerID = player->GetObjectID();
|
|
|
|
|
|
|
|
self->AddCallbackTimer(animTime, [playerID, self]() {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* player = Game::entityManager->GetEntity(playerID);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (player == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GameMessages::SendDisplayZoneSummary(playerID, player->GetSystemAddress(), false, false, self->GetObjectID());
|
|
|
|
});
|
|
|
|
} else if (button == -1 || button == 0) {
|
2023-05-02 22:39:21 +00:00
|
|
|
GameMessages::SendTerminateInteraction(player->GetObjectID(), eTerminateType::FROM_INTERACTION, player->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseConsoleTeleportServer::UpdatePlayerTable(Entity* self, Entity* player, bool bAdd) {
|
|
|
|
const auto iter = std::find(m_Players.begin(), m_Players.end(), player->GetObjectID());
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (iter == m_Players.end() && bAdd) {
|
|
|
|
m_Players.push_back(player->GetObjectID());
|
|
|
|
} else if (iter != m_Players.end() && !bAdd) {
|
|
|
|
m_Players.erase(iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BaseConsoleTeleportServer::CheckPlayerTable(Entity* self, Entity* player) {
|
|
|
|
const auto iter = std::find(m_Players.begin(), m_Players.end(), player->GetObjectID());
|
|
|
|
|
|
|
|
return iter != m_Players.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseConsoleTeleportServer::BaseOnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
|
|
|
|
if (args == "summaryComplete") {
|
|
|
|
TransferPlayer(self, sender, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseConsoleTeleportServer::TransferPlayer(Entity* self, Entity* player, int32_t altMapID) {
|
|
|
|
if (player == nullptr || !CheckPlayerTable(self, player)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
GameMessages::SendSetStunned(
|
|
|
|
player->GetObjectID(), eStateChangeType::POP, player->GetSystemAddress(), player->GetObjectID(),
|
2021-12-05 17:54:36 +00:00
|
|
|
true, true, true, true, true, true, true
|
2023-01-07 05:59:19 +00:00
|
|
|
);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
GameMessages::SendTerminateInteraction(player->GetObjectID(), eTerminateType::FROM_INTERACTION, player->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
const auto& teleportZone = self->GetVar<std::u16string>(u"transferZoneID");
|
|
|
|
|
2024-01-11 12:33:53 +00:00
|
|
|
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
|
|
|
|
|
|
|
if (characterComponent) characterComponent->SendToZone(std::stoi(GeneralUtils::UTF16ToWTF8(teleportZone)));
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
UpdatePlayerTable(self, player, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseConsoleTeleportServer::BaseOnTimerDone(Entity* self, const std::string& timerName) {
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|