2021-12-05 17:54:36 +00:00
|
|
|
#include "InstanceExitTransferPlayerToLastNonInstance.h"
|
|
|
|
#include "GameMessages.h"
|
2024-01-11 12:33:53 +00:00
|
|
|
#include "CharacterComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "Character.h"
|
|
|
|
#include "dServer.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eTerminateType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void InstanceExitTransferPlayerToLastNonInstance::OnUse(Entity* self, Entity* user) {
|
|
|
|
auto transferText = self->GetVar<std::u16string>(u"transferText");
|
|
|
|
if (transferText.empty())
|
|
|
|
transferText = u"DRAGON_EXIT_QUESTION";
|
|
|
|
|
|
|
|
GameMessages::SendDisplayMessageBox(
|
|
|
|
user->GetObjectID(),
|
|
|
|
true,
|
|
|
|
self->GetObjectID(),
|
|
|
|
u"Instance_Exit",
|
|
|
|
1,
|
|
|
|
transferText,
|
|
|
|
u"",
|
|
|
|
user->GetSystemAddress()
|
|
|
|
);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void InstanceExitTransferPlayerToLastNonInstance::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
|
2024-01-11 12:33:53 +00:00
|
|
|
if (!sender->IsPlayer()) return;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* character = sender->GetCharacter();
|
|
|
|
if (character != nullptr) {
|
|
|
|
if (identifier == u"Instance_Exit" && button == 1) {
|
|
|
|
auto lastInstance = character->GetLastNonInstanceZoneID();
|
|
|
|
|
|
|
|
// Sanity check
|
|
|
|
if (lastInstance == 0) {
|
|
|
|
switch (Game::server->GetZoneID()) {
|
|
|
|
case 2001:
|
|
|
|
lastInstance = 2000;
|
|
|
|
break;
|
|
|
|
case 1402:
|
|
|
|
lastInstance = 1400;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
lastInstance = 1100;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-11 12:33:53 +00:00
|
|
|
auto* characterComponent = sender->GetComponent<CharacterComponent>();
|
|
|
|
if (characterComponent) characterComponent->SendToZone(lastInstance);
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GameMessages::SendTerminateInteraction(sender->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|