mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
Converts PlayAnimation, PlayNDAudioEmitter, PlayEmbeddedEffectOnAllClientsNearObject,
PlayFXEffect, StopFXEffect, BroadcastTextToChatbox, Play2DAmbientSound,
Stop2DAmbientSound, UIMessageServerToSingleClient, UIMessageServerToAllClients,
StartCelebrationEffect, DisplayMessageBox, DisplayChatBubble, ChangeIdleFlags,
SetNameBillboardState, ShowBillboardInteractIcon, PlayCinematic, EndCinematic,
SlashCommandTextFeedback, PlayEmote and SetEmoteLockState (21 old Send
functions, 23 with overloads) and the received MessageBoxRespond,
ChoiceBoxRespond, CinematicUpdate and PlayEmote to NetGameMsgs in
EffectsMessages.{h,cpp}. The high traffic messages get a constructor for their
required fields. UI messages own their AMF arguments. Every caller is switched,
the received messages are registered in GameMessageHandler's map, and the old
functions and switch cases are deleted. Handlers are copied verbatim.
No wire change and no change in recipients: functions that always broadcast
whatever address they were given are sent with Send(UNASSIGNED_SYSTEM_ADDRESS),
functions that only did SEND_PACKET use SendToClient. Quirks are kept and
documented on the structs (PlayAnimation's UTF-8 sized name, the always written
null terminator in BroadcastTextToChatbox, StartCelebrationEffect always
writing celebrationID, SetNameBillboardState having no payload).
Verified byte for byte against a frozen verbatim copy of the old functions over
an input grid, to one client and broadcast; received messages compared with the
old handlers' read sequences and every truncated payload rejected; hand
computed golden bytes; round trips; a deliberate width mutation made the tests
fail. The byte-equality helper gains a Broadcast mode for functions that
ignored their address.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
1.7 KiB
C++
62 lines
1.7 KiB
C++
#include "AgPropguards.h"
|
|
#include "Character.h"
|
|
#include "GameMessages.h"
|
|
#include "EffectsMessages.h"
|
|
#include "EntityManager.h"
|
|
#include "dZoneManager.h"
|
|
#include "eMissionState.h"
|
|
|
|
void AgPropguards::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
|
|
auto* character = target->GetCharacter();
|
|
if (character == nullptr)
|
|
return;
|
|
|
|
const auto flag = GetFlagForMission(missionID);
|
|
if (flag == 0)
|
|
return;
|
|
|
|
if ((missionState == eMissionState::AVAILABLE || missionState == eMissionState::ACTIVE)
|
|
&& !character->GetPlayerFlag(flag)) {
|
|
// If the player just started the mission, play a cinematic highlighting the target
|
|
GameMessages::PlayCinematic cinematic;
|
|
cinematic.target = target->GetObjectID();
|
|
cinematic.pathName = u"MissionCam";
|
|
cinematic.Send(target->GetSystemAddress());
|
|
} else if (missionState == eMissionState::READY_TO_COMPLETE) {
|
|
// Makes the guard disappear once the mission has been completed
|
|
const auto zoneControlID = Game::entityManager->GetZoneControlEntity()->GetObjectID();
|
|
GameMessages::SendNotifyClientObject(zoneControlID, u"GuardChat", 0, 0, self->GetObjectID(),
|
|
"", UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
self->AddCallbackTimer(5.0f, [self]() {
|
|
auto spawnerName = self->GetVar<std::string>(u"spawner_name");
|
|
if (spawnerName.empty())
|
|
spawnerName = "Guard";
|
|
|
|
auto spawners = Game::zoneManager->GetSpawnersByName(spawnerName);
|
|
for (auto* spawner : spawners) {
|
|
spawner->Deactivate();
|
|
}
|
|
|
|
self->Smash();
|
|
});
|
|
}
|
|
}
|
|
|
|
int32_t AgPropguards::GetFlagForMission(uint32_t missionID) {
|
|
switch (missionID) {
|
|
case 872:
|
|
return 97;
|
|
case 873:
|
|
return 98;
|
|
case 874:
|
|
return 99;
|
|
case 1293:
|
|
return 118;
|
|
case 1322:
|
|
return 122;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|