DarkflameServer/dScripts/NsLegoClubDoor.cpp

153 lines
5.2 KiB
C++
Raw Permalink Normal View History

#include "NsLegoClubDoor.h"
#include "dZoneManager.h"
#include "GameMessages.h"
#include "AMFFormat.h"
2022-07-28 13:39:57 +00:00
void NsLegoClubDoor::OnStartup(Entity* self) {
self->SetVar(u"currentZone", (int32_t)dZoneManager::Instance()->GetZoneID().GetMapID());
self->SetVar(u"choiceZone", m_ChoiceZoneID);
self->SetVar(u"teleportAnim", m_TeleportAnim);
self->SetVar(u"teleportString", m_TeleportString);
self->SetVar(u"spawnPoint", m_SpawnPoint);
2022-07-28 13:39:57 +00:00
args = {};
2022-07-28 13:39:57 +00:00
AMFStringValue* callbackClient = new AMFStringValue();
callbackClient->SetStringValue(std::to_string(self->GetObjectID()));
args.InsertValue("callbackClient", callbackClient);
2022-07-28 13:39:57 +00:00
AMFStringValue* strIdentifier = new AMFStringValue();
strIdentifier->SetStringValue("choiceDoor");
args.InsertValue("strIdentifier", strIdentifier);
2022-07-28 13:39:57 +00:00
AMFStringValue* title = new AMFStringValue();
title->SetStringValue("%[UI_CHOICE_DESTINATION]");
args.InsertValue("title", title);
2022-07-28 13:39:57 +00:00
AMFArrayValue* choiceOptions = new AMFArrayValue();
2022-07-28 13:39:57 +00:00
{
AMFArrayValue* nsArgs = new AMFArrayValue();
2022-07-28 13:39:57 +00:00
AMFStringValue* image = new AMFStringValue();
image->SetStringValue("textures/ui/zone_thumnails/Nimbus_Station.dds");
nsArgs->InsertValue("image", image);
2022-07-28 13:39:57 +00:00
AMFStringValue* caption = new AMFStringValue();
caption->SetStringValue("%[UI_CHOICE_NS]");
nsArgs->InsertValue("caption", caption);
2022-07-28 13:39:57 +00:00
AMFStringValue* identifier = new AMFStringValue();
identifier->SetStringValue("zoneID_1200");
nsArgs->InsertValue("identifier", identifier);
2022-07-28 13:39:57 +00:00
AMFStringValue* tooltipText = new AMFStringValue();
tooltipText->SetStringValue("%[UI_CHOICE_NS_HOVER]");
nsArgs->InsertValue("tooltipText", tooltipText);
2022-07-28 13:39:57 +00:00
choiceOptions->PushBackValue(nsArgs);
}
2022-07-28 13:39:57 +00:00
{
AMFArrayValue* ntArgs = new AMFArrayValue();
2022-07-28 13:39:57 +00:00
AMFStringValue* image = new AMFStringValue();
image->SetStringValue("textures/ui/zone_thumnails/Nexus_Tower.dds");
ntArgs->InsertValue("image", image);
2022-07-28 13:39:57 +00:00
AMFStringValue* caption = new AMFStringValue();
caption->SetStringValue("%[UI_CHOICE_NT]");
ntArgs->InsertValue("caption", caption);
2022-07-28 13:39:57 +00:00
AMFStringValue* identifier = new AMFStringValue();
identifier->SetStringValue("zoneID_1900");
ntArgs->InsertValue("identifier", identifier);
2022-07-28 13:39:57 +00:00
AMFStringValue* tooltipText = new AMFStringValue();
tooltipText->SetStringValue("%[UI_CHOICE_NT_HOVER]");
ntArgs->InsertValue("tooltipText", tooltipText);
2022-07-28 13:39:57 +00:00
choiceOptions->PushBackValue(ntArgs);
}
2022-07-28 13:39:57 +00:00
options = choiceOptions;
2022-07-28 13:39:57 +00:00
args.InsertValue("options", choiceOptions);
}
2022-07-28 13:39:57 +00:00
void NsLegoClubDoor::OnUse(Entity* self, Entity* user) {
auto* player = user;
2022-07-28 13:39:57 +00:00
if (CheckChoice(self, player)) {
AMFArrayValue* multiArgs = new AMFArrayValue();
2022-07-28 13:39:57 +00:00
AMFStringValue* callbackClient = new AMFStringValue();
callbackClient->SetStringValue(std::to_string(self->GetObjectID()));
multiArgs->InsertValue("callbackClient", callbackClient);
2022-07-28 13:39:57 +00:00
AMFStringValue* strIdentifier = new AMFStringValue();
strIdentifier->SetStringValue("choiceDoor");
multiArgs->InsertValue("strIdentifier", strIdentifier);
2022-07-28 13:39:57 +00:00
AMFStringValue* title = new AMFStringValue();
title->SetStringValue("%[UI_CHOICE_DESTINATION]");
multiArgs->InsertValue("title", title);
2022-07-28 13:39:57 +00:00
multiArgs->InsertValue("options", options);
2022-07-28 13:39:57 +00:00
GameMessages::SendUIMessageServerToSingleClient(player, player->GetSystemAddress(), "QueueChoiceBox", multiArgs);
} else if (self->GetVar<int32_t>(u"currentZone") != m_ChoiceZoneID) {
AMFArrayValue* multiArgs = new AMFArrayValue();
2022-07-28 13:39:57 +00:00
AMFStringValue* state = new AMFStringValue();
state->SetStringValue("Lobby");
multiArgs->InsertValue("state", state);
2022-07-28 13:39:57 +00:00
AMFArrayValue* context = new AMFArrayValue();
2022-07-28 13:39:57 +00:00
AMFStringValue* user = new AMFStringValue();
user->SetStringValue(std::to_string(player->GetObjectID()));
context->InsertValue("user", user);
2022-07-28 13:39:57 +00:00
AMFStringValue* callbackObj = new AMFStringValue();
callbackObj->SetStringValue(std::to_string(self->GetObjectID()));
context->InsertValue("callbackObj", callbackObj);
2022-07-28 13:39:57 +00:00
AMFStringValue* helpVisible = new AMFStringValue();
helpVisible->SetStringValue("show");
context->InsertValue("HelpVisible", helpVisible);
2022-07-28 13:39:57 +00:00
AMFStringValue* type = new AMFStringValue();
type->SetStringValue("Lego_Club_Valid");
context->InsertValue("type", type);
2022-07-28 13:39:57 +00:00
multiArgs->InsertValue("context", context);
GameMessages::SendUIMessageServerToSingleClient(player, player->GetSystemAddress(), "pushGameState", multiArgs);
} else {
BaseOnUse(self, player);
}
}
2022-07-28 13:39:57 +00:00
void NsLegoClubDoor::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
std::u16string strIdentifier = identifier;
2022-07-28 13:39:57 +00:00
if (strIdentifier == u"PlayButton" || strIdentifier == u"CloseButton") {
strIdentifier = u"TransferBox";
}
2022-07-28 13:39:57 +00:00
BaseOnMessageBoxResponse(self, sender, button, strIdentifier, userData);
}
2022-07-28 13:39:57 +00:00
void NsLegoClubDoor::OnChoiceBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier) {
BaseChoiceBoxRespond(self, sender, button, buttonIdentifier, identifier);
}
2022-07-28 13:39:57 +00:00
void NsLegoClubDoor::OnTimerDone(Entity* self, std::string timerName) {
BaseOnTimerDone(self, timerName);
}
2022-07-28 13:39:57 +00:00
void NsLegoClubDoor::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
BaseOnFireEventServerSide(self, sender, args, param1, param2, param3);
}