mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
Converts the pet taming minigame, naming, command and bouncer messages to
NetGameMsgs in PetMessages.{h,cpp}: NotifyPetTamingMinigame,
NotifyTamingModelLoadedOnServer, NotifyPetTamingPuzzleSelected,
PetTamingTryBuildResult, PetResponse, AddPetToPlayer, RegisterPetID,
RegisterPetDBID, ShowPetActionButton, BouncerActiveStatus, SetPetName,
SetPetNameModerated and PetNameChanged (sent), and PetTamingTryBuild,
NotifyTamingBuildSuccess, RequestSetPetName, StartServerPetMinigameTimer,
ClientExitTamingMinigame, CommandPet and DespawnPet (received, registered
in GameMessageHandler's map; each Handle hands the message to the
player's taming or active PetComponent exactly as the old handler did).
PetComponent, BouncerComponent and the hydrant/catapult scripts build
the structs; the old Send*/Handle* functions and switch cases are gone.
The never-called SendClientExitTamingMinigame is folded into the
ClientExitTamingMinigame struct. MarkInventoryItemAsActive stays with
the inventory messages.
No wire change and no change in recipients. 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 with every truncated payload rejected, hand
computed golden bytes, round trips, and a mutation check. Layouts
confirmed against the 1.10.64 client's Serialize/Deserialize in Ghidra.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.5 KiB
C++
71 lines
2.5 KiB
C++
#include "CatapultBaseServer.h"
|
|
#include "PetMessages.h"
|
|
#include "GameMessages.h"
|
|
#include "EntityManager.h"
|
|
#include "Entity.h"
|
|
#include "RenderComponent.h"
|
|
|
|
void CatapultBaseServer::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
|
|
if (name == "BouncerBuilt") {
|
|
// start a timer for the arm to player the with bouncer animation
|
|
self->AddTimer("PlatAnim", .75);
|
|
|
|
// set the bouncer so we can use it later
|
|
self->SetVar(u"Bouncer", sender->GetObjectID());
|
|
|
|
GameMessages::BouncerActiveStatus msg;
|
|
msg.target = sender->GetObjectID();
|
|
msg.bActive = true;
|
|
msg.Send(UNASSIGNED_SYSTEM_ADDRESS);
|
|
}
|
|
}
|
|
|
|
void CatapultBaseServer::OnTimerDone(Entity* self, std::string timerName) {
|
|
if (timerName == "PlatAnim") {
|
|
// get the arm asset
|
|
const auto arm = Game::entityManager->GetEntitiesInGroup(self->GetVarAsString(u"ArmGroup"));
|
|
|
|
// tell the arm to the play the platform animation, which is just the arm laying there but with bouncer
|
|
for (auto* obj : arm) {
|
|
RenderComponent::PlayAnimation(obj, u"idle-platform");
|
|
GameMessages::SendPlayNDAudioEmitter(obj, UNASSIGNED_SYSTEM_ADDRESS, "{8cccf912-69e3-4041-a20b-63e4afafc993}");
|
|
// set the art so we can use it again
|
|
self->SetVar(u"Arm", obj->GetObjectID());
|
|
break;
|
|
}
|
|
|
|
// start a timer till the bouncer actually bounces
|
|
self->AddTimer("bounce", 3);
|
|
} else if (timerName == "launchAnim") {
|
|
// get the arm asset
|
|
auto* arm = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Arm"));
|
|
if (arm == nullptr) return;
|
|
|
|
// tell the arm to player the launcher animation
|
|
auto animTime = 1;
|
|
self->AddTimer("resetArm", animTime);
|
|
RenderComponent::PlayAnimation(arm, u"launch");
|
|
} else if (timerName == "bounce") {
|
|
auto* bouncer = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Bouncer"));
|
|
if (bouncer == nullptr) return;
|
|
|
|
// bounce all players
|
|
bouncer->NotifyObject(bouncer, "bounceAllInProximity"); // Likely to trigger server side bounce, bodging this
|
|
// add a delay to play the animation
|
|
self->AddTimer("launchAnim", .3);
|
|
} else if (timerName == "resetArm") {
|
|
auto* arm = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Arm"));
|
|
if (arm == nullptr) return;
|
|
|
|
// set the arm back to natural state
|
|
RenderComponent::PlayAnimation(arm, u"idle");
|
|
|
|
auto* bouncer = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Bouncer"));
|
|
if (bouncer == nullptr) return;
|
|
|
|
// kill the bouncer
|
|
GameMessages::SendNotifyClientObject(bouncer->GetObjectID(), u"TimeToDie");
|
|
bouncer->Smash(self->GetObjectID(), eKillType::VIOLENT);
|
|
}
|
|
}
|