mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
feat(scripts): L_ZONE_FIRE_TEMPLE_SERVER
Each player gets the activity close button; it asks to confirm leaving, and yes takes the button away and sends the player to their last zone that is not an instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,8 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL
|
||||
"TouchMissionUpdateServer.cpp"
|
||||
"VisToggleNotifierServer.cpp"
|
||||
"NTNaomiDirtServer.cpp"
|
||||
"WishingWellServer.cpp")
|
||||
"WishingWellServer.cpp"
|
||||
"ZoneFireTempleServer.cpp")
|
||||
|
||||
add_subdirectory(Ninjago)
|
||||
|
||||
|
||||
50
dScripts/02_server/Map/General/ZoneFireTempleServer.cpp
Normal file
50
dScripts/02_server/Map/General/ZoneFireTempleServer.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "ZoneFireTempleServer.h"
|
||||
#include "GameMessages.h"
|
||||
#include "EffectsMessages.h"
|
||||
#include "Entity.h"
|
||||
#include "Character.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "Amf3.h"
|
||||
|
||||
void ZoneFireTempleServer::OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) {
|
||||
self->SetVar<int32_t>(u"initialPlayerCount", info.maxPlayers);
|
||||
}
|
||||
|
||||
void ZoneFireTempleServer::ToggleActivityCloseButton(Entity* player, const bool show) {
|
||||
AMFArrayValue args;
|
||||
args.Insert("bShow", show);
|
||||
GameMessages::UIMessageServerToSingleClient uiMessage;
|
||||
uiMessage.target = player->GetObjectID();
|
||||
uiMessage.strMessageName = "ToggleActivityCloseButton";
|
||||
uiMessage.args = std::move(args);
|
||||
uiMessage.SendToClient(player->GetSystemAddress());
|
||||
}
|
||||
|
||||
// (The Lua also keeps a list of the players in the zone, which nothing reads.)
|
||||
void ZoneFireTempleServer::OnPlayerLoaded(Entity* self, Entity* player) {
|
||||
ToggleActivityCloseButton(player, true);
|
||||
}
|
||||
|
||||
void ZoneFireTempleServer::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
|
||||
if (!sender) return;
|
||||
const auto asked = u"|" + GeneralUtils::ASCIIToUTF16(std::to_string(sender->GetObjectID()));
|
||||
if (identifier == u"ActivityButton" && !self->GetVar<bool>(asked)) {
|
||||
self->SetVar<bool>(asked, true);
|
||||
GameMessages::DisplayMessageBox messageBox;
|
||||
messageBox.target = sender->GetObjectID();
|
||||
messageBox.bShow = true;
|
||||
messageBox.imageID = 1;
|
||||
messageBox.callbackClient = self->GetObjectID();
|
||||
messageBox.text = u"UI_EULA_CONFIRM_EXIT_LINE2";
|
||||
messageBox.identifier = u"Exit";
|
||||
messageBox.SendToClient(sender->GetSystemAddress());
|
||||
} else if (identifier == u"Exit") {
|
||||
self->SetVar<bool>(asked, false);
|
||||
if (button == 1) {
|
||||
ToggleActivityCloseButton(sender, false);
|
||||
auto* const character = sender->GetCharacter();
|
||||
auto* const characterComponent = sender->GetComponent<CharacterComponent>();
|
||||
if (character && characterComponent) characterComponent->SendToZone(character->GetLastNonInstanceZoneID());
|
||||
}
|
||||
}
|
||||
}
|
||||
13
dScripts/02_server/Map/General/ZoneFireTempleServer.h
Normal file
13
dScripts/02_server/Map/General/ZoneFireTempleServer.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
// L_ZONE_FIRE_TEMPLE_SERVER.lua: the Fire Temple instance's zone script. Each player gets the activity close button;
|
||||
// using it asks to confirm leaving (UI_EULA_CONFIRM_EXIT_LINE2), and yes takes the button away and sends the player
|
||||
// to the last zone that is not an instance.
|
||||
class ZoneFireTempleServer : public CppScripts::Script {
|
||||
public:
|
||||
void OnZoneLoadedInfo(Entity* self, const GameMessages::ZoneLoadedInfo& info) override;
|
||||
void OnPlayerLoaded(Entity* self, Entity* player) override;
|
||||
void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) override;
|
||||
static void ToggleActivityCloseButton(Entity* player, bool show);
|
||||
};
|
||||
@@ -280,6 +280,7 @@
|
||||
#include "SpinnersVol.h"
|
||||
#include "DoorIndicatorServer.h"
|
||||
#include "ElementalChestsServer.h"
|
||||
#include "ZoneFireTempleServer.h"
|
||||
#include "SimpleOnceOnlyMoverSpinnerEvent.h"
|
||||
#include "ImaginationShrineServer.h"
|
||||
#include "Lieutenant.h"
|
||||
@@ -699,6 +700,7 @@ namespace {
|
||||
{"scripts\\02_server\\Map\\firetemple\\L_DSPINNERS_VOL.lua", []() {return new DSpinnersVol();}},
|
||||
{"scripts\\02_server\\Map\\firetemple\\L_DOOR_INDICATOR_SERVER.lua", []() {return new DoorIndicatorServer();}},
|
||||
{"scripts\\02_server\\Map\\firetemple\\L_ELEMENTAL_CHESTS_SERVER.lua", []() {return new ElementalChestsServer();}},
|
||||
{"scripts\\02_server\\Map\\firetemple\\L_ZONE_FIRE_TEMPLE_SERVER.lua", []() {return new ZoneFireTempleServer();}},
|
||||
{"scripts\\02_server\\Map\\General\\L_KILL_COUNTER_UTIL.lua", []() {return new KillCounterUtil();}},
|
||||
{"scripts\\02_server\\Enemy\\General\\L_ENEMY_NJ_BUFF_STUN_IMMUNITY.lua", []() {return new EnemyNjBuff();}},
|
||||
{"scripts\\02_server\\Map\\njhub\\L_IMAGINATION_SHRINE_SERVER.lua", []() {return new ImaginationShrineServer();}},
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "02_server/Map/General/DoorIndicatorServer.h"
|
||||
#include "02_server/Map/General/ElementalChestsServer.h"
|
||||
#include "CDClientDatabase.h"
|
||||
#include "02_server/Map/General/ZoneFireTempleServer.h"
|
||||
#include "EffectsMessages.h"
|
||||
|
||||
namespace {
|
||||
// A kill counter extension that records its limit events
|
||||
@@ -106,3 +108,21 @@ TEST_F(FireTempleScriptsTest, ElementalChestFlagIsItsPreconditionsTarget) {
|
||||
EXPECT_EQ(ElementalChestsServer::PreconditionFlag("322"), std::nullopt);
|
||||
EXPECT_EQ(ElementalChestsServer::PreconditionFlag(""), std::nullopt);
|
||||
}
|
||||
|
||||
// L_ZONE_FIRE_TEMPLE_SERVER: the close button asks once to confirm; no keeps the player here, and the box can be asked
|
||||
// for again
|
||||
TEST_F(FireTempleScriptsTest, FireTempleExitAsksToConfirm) {
|
||||
Entity zone(288300744895900204, info);
|
||||
Entity player(288300744895900205, info);
|
||||
ZoneFireTempleServer script;
|
||||
auto* const mock = static_cast<dServerMock*>(Game::server);
|
||||
mock->ClearSentPackets();
|
||||
script.OnMessageBoxResponse(&zone, &player, 1, u"ActivityButton", u"");
|
||||
EXPECT_EQ(mock->GetSentPackets().size(), 1u);
|
||||
// Asked again before answering: nothing more
|
||||
script.OnMessageBoxResponse(&zone, &player, 1, u"ActivityButton", u"");
|
||||
EXPECT_EQ(mock->GetSentPackets().size(), 1u);
|
||||
script.OnMessageBoxResponse(&zone, &player, 0, u"Exit", u"");
|
||||
script.OnMessageBoxResponse(&zone, &player, 1, u"ActivityButton", u"");
|
||||
EXPECT_EQ(mock->GetSentPackets().size(), 2u);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user