refactor: death, stun, buff and knockback game messages as structs

Converts the combat messages to NetGameMsgs in CombatMessages.{h,cpp}:
Die, Resurrect, SetResurrectRestoreValues, SetPlayerAllowedRespawn
(SendToClient, as before), Knockback, SetStunned, SetStunImmunity,
SetStatusImmunity, AddBuff, RemoveBuff, AddRunSpeedModifier,
RemoveRunSpeedModifier and DeactivateBubbleBuffFromServer, and the
received RequestDie, RequestSmashPlayer, RequestResurrect, Resurrect,
ActivateBubbleBuff and DeactivateBubbleBuff. Smash and UnSmash move
here from GameMessages.h (Smash's ghostCapacity is ghostOpacity, the
client's name) and gain a Deserialize.

The callers (DestroyableComponent, BuffComponent,
ControllablePhysicsComponent, QuickBuildComponent, RacingControl,
RailActivator and the scripts) build the structs. SendResurrect's
respawn timer moves to DestroyableComponent::Resurrect. The received
messages are registered in GameMessageHandler's map and their switch
cases are deleted, along with the unused HandleRequestDie overload and
the Send* functions nothing called (SendSmash, SendUnSmash, the run
speed modifiers, SendActivateBubbleBuffFromServer). Handler logic is
unchanged.

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
(every optional field, bool patterns, empty and long strings), received
messages compared with the old handlers' read sequences and truncated
payloads rejected, hand computed golden bytes, round trips, and a
deliberate width mutation made the tests fail.

Known difference from the client, not changed here: DLU writes
SetStatusImmunity's nine flags in its own order; the client reads them
alphabetically (GameMessage::SetStatusImmunity::Serialize @ 00d8f140).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-27 00:01:18 -05:00
parent 27de0cf268
commit f7f5d304d0
38 changed files with 2002 additions and 808 deletions

View File

@@ -1,6 +1,7 @@
#include "AmSkullkinDrill.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "MovingPlatformComponent.h"
#include "DestroyableComponent.h"
#include "ProximityMonitorComponent.h"
@@ -165,9 +166,15 @@ void AmSkullkinDrill::FreezePlayer(Entity* self, Entity* player, bool bFreeze) {
}
}
GameMessages::SendSetStunned(player->GetObjectID(), StateChangeType, player->GetSystemAddress(), self->GetObjectID(),
true, false, true, false, true, false, true
);
GameMessages::SetStunned stun;
stun.target = player->GetObjectID();
stun.StateChangeType = StateChangeType;
stun.Originator = self->GetObjectID();
stun.bCantAttack = true;
stun.bCantInteract = true;
stun.bCantMove = true;
stun.bCantUseItem = true;
stun.Send(player->GetSystemAddress());
}
void AmSkullkinDrill::OnArrived(Entity* self, uint32_t waypointIndex) {

View File

@@ -1,6 +1,7 @@
#include "AmSkullkinDrillStand.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "dpEntity.h"
#include "Entity.h"
#include "RenderComponent.h"
@@ -30,7 +31,12 @@ void AmSkullkinDrillStand::OnProximityUpdate(Entity* self, Entity* entering, std
NiPoint3 newVec = { (objPos.x - myPos.x) * 4.5f, 15, (objPos.z - myPos.z) * 4.5f };
GameMessages::SendKnockback(entering->GetObjectID(), self->GetObjectID(), self->GetObjectID(), 0, newVec);
GameMessages::Knockback knockback;
knockback.target = entering->GetObjectID();
knockback.Caster = self->GetObjectID();
knockback.Originator = self->GetObjectID();
knockback.vector = newVec;
knockback.Send(UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::PlayFXEffect(entering->GetObjectID(), 1378, u"create", "pushBack").Send(UNASSIGNED_SYSTEM_ADDRESS);

View File

@@ -1,6 +1,7 @@
#include "RaceMaelstromGeiser.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "PossessableComponent.h"
#include "PossessorComponent.h"
#include "EntityManager.h"
@@ -56,7 +57,12 @@ void RaceMaelstromGeiser::OnProximityUpdate(Entity* self, Entity* entering, std:
}
GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false, 0);
GameMessages::Die die;
die.target = vehicle->GetObjectID();
die.bClientDeath = true;
die.bSpawnLoot = false;
die.killerID = self->GetObjectID();
die.Send(UNASSIGNED_SYSTEM_ADDRESS);
auto* zoneController = Game::zoneManager->GetZoneControlObject();

View File

@@ -1,6 +1,7 @@
#include "GfCaptainsCannon.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "EntityManager.h"
#include "MissionComponent.h"
#include "RenderComponent.h"
@@ -17,9 +18,18 @@ void GfCaptainsCannon::OnUse(Entity* self, Entity* user) {
self->SetVar<bool>(u"bIsInUse", true);
self->SetNetworkVar<bool>(u"bIsInUse", true);
GameMessages::SendSetStunned(user->GetObjectID(), eStateChangeType::PUSH, user->GetSystemAddress(),
LWOOBJID_EMPTY, true, true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = user->GetObjectID();
stun.StateChangeType = eStateChangeType::PUSH;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.bDontTerminateInteract = true;
stun.Send(user->GetSystemAddress());
auto position = self->GetPosition();
auto forward = QuatUtils::Forward(self->GetRotation());
@@ -73,9 +83,18 @@ void GfCaptainsCannon::OnTimerDone(Entity* self, std::string timerName) {
ambientSound.audioGUID = "{7457d85c-4537-4317-ac9d-2f549219ea87}";
ambientSound.SendToClient(player->GetSystemAddress());
} else if (timerName == "cinematicTimer") {
GameMessages::SendSetStunned(playerId, eStateChangeType::POP, player->GetSystemAddress(),
LWOOBJID_EMPTY, true, true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = playerId;
stun.StateChangeType = eStateChangeType::POP;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.bDontTerminateInteract = true;
stun.Send(player->GetSystemAddress());
self->SetVar<bool>(u"bIsInUse", false);
self->SetNetworkVar<bool>(u"bIsInUse", false);

View File

@@ -2,6 +2,7 @@
#include "EntityManager.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "Preconditions.h"
#include "eEndBehavior.h"
#include "DestroyableComponent.h"
@@ -21,9 +22,17 @@ void MastTeleport::OnQuickBuildComplete(Entity* self, Entity* target) {
if (Preconditions::Check(target, 154) && Preconditions::Check(target, 44)) {
self->SetVar<LWOOBJID>(u"userID", target->GetObjectID());
GameMessages::SendSetStunned(target->GetObjectID(), eStateChangeType::PUSH, target->GetSystemAddress(),
LWOOBJID_EMPTY, true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = target->GetObjectID();
stun.StateChangeType = eStateChangeType::PUSH;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.Send(target->GetSystemAddress());
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
if (destroyableComponent) destroyableComponent->SetStatusImmunity(eStateChangeType::PUSH, true, true, true, true, true, false, false, true, true);
@@ -92,9 +101,17 @@ void MastTeleport::OnTimerDone(Entity* self, std::string timerName) {
GameMessages::SendTeleport(playerId, position, QuatUtils::IDENTITY, player->GetSystemAddress());
GameMessages::SendSetStunned(playerId, eStateChangeType::POP, player->GetSystemAddress(),
LWOOBJID_EMPTY, true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = playerId;
stun.StateChangeType = eStateChangeType::POP;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.Send(player->GetSystemAddress());
auto* destroyableComponent = player->GetComponent<DestroyableComponent>();
if (destroyableComponent) destroyableComponent->SetStatusImmunity(eStateChangeType::POP, true, true, true, true, true, false, false, true, true);
Game::entityManager->SerializeEntity(player);

View File

@@ -1,6 +1,7 @@
#include "NtAssemblyTubeServer.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "EntityManager.h"
#include "MissionComponent.h"
#include "eMissionTaskType.h"
@@ -42,9 +43,17 @@ void NtAssemblyTubeServer::RunAssemblyTube(Entity* self, Entity* player) {
if (player->IsPlayer() && !bPlayerBeingTeleported) {
auto teleCinematic = self->GetVar<std::u16string>(u"Cinematic");
GameMessages::SendSetStunned(playerID, eStateChangeType::PUSH, player->GetSystemAddress(), LWOOBJID_EMPTY,
true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = playerID;
stun.StateChangeType = eStateChangeType::PUSH;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.Send(player->GetSystemAddress());
if (!teleCinematic.empty()) {
const auto teleCinematicUname = teleCinematic;
@@ -124,7 +133,15 @@ void NtAssemblyTubeServer::UnlockPlayer(Entity* self, Entity* player) {
m_TeleportingPlayerTable[playerID] = false;
GameMessages::SendSetStunned(playerID, eStateChangeType::POP, player->GetSystemAddress(), LWOOBJID_EMPTY,
true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = playerID;
stun.StateChangeType = eStateChangeType::POP;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.Send(player->GetSystemAddress());
}

View File

@@ -1,6 +1,7 @@
#include "NtParadoxPanelServer.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "MissionComponent.h"
#include "EntityManager.h"
#include "Character.h"
@@ -40,11 +41,23 @@ void NtParadoxPanelServer::OnUse(Entity* self, Entity* user) {
RenderComponent::PlayAnimation(player, u"rebuild-celebrate");
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SparkStop", 0, 0, player->GetObjectID(), "", player->GetSystemAddress());
GameMessages::SendSetStunned(player->GetObjectID(), eStateChangeType::POP, player->GetSystemAddress(), LWOOBJID_EMPTY, false, false, true, false, true, true, false, false, true);
GameMessages::SetStunned stun;
stun.target = player->GetObjectID();
stun.StateChangeType = eStateChangeType::POP;
stun.bCantInteract = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.Send(player->GetSystemAddress());
self->SetVar(u"bActive", false);
});
RenderComponent::PlayAnimation(user, u"nexus-powerpanel", 6.0f);
GameMessages::SendSetStunned(user->GetObjectID(), eStateChangeType::PUSH, user->GetSystemAddress(), LWOOBJID_EMPTY, false, false, true, false, true, true, false, false, true);
GameMessages::SetStunned stun;
stun.target = user->GetObjectID();
stun.StateChangeType = eStateChangeType::PUSH;
stun.bCantInteract = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.Send(user->GetSystemAddress());
return;
}
@@ -52,7 +65,12 @@ void NtParadoxPanelServer::OnUse(Entity* self, Entity* user) {
const auto dir = QuatUtils::Right(self->GetRotation());
GameMessages::SendKnockback(user->GetObjectID(), self->GetObjectID(), self->GetObjectID(), 0, { dir.x * 15, 5, dir.z * 15 });
GameMessages::Knockback knockback;
knockback.target = user->GetObjectID();
knockback.Caster = self->GetObjectID();
knockback.Originator = self->GetObjectID();
knockback.vector = NiPoint3{ dir.x * 15, 5, dir.z * 15 };
knockback.Send(UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::PlayFXEffect(self->GetObjectID(), 6432, u"create", "console_sparks").Send(UNASSIGNED_SYSTEM_ADDRESS);

View File

@@ -1,6 +1,7 @@
#include "NtParadoxTeleServer.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "EntityManager.h"
#include "MissionComponent.h"
#include "eMissionTaskType.h"
@@ -26,9 +27,17 @@ void NtParadoxTeleServer::OnProximityUpdate(Entity* self, Entity* entering, std:
const auto bPlayerBeingTeleported = m_TeleportingPlayerTable[playerID];
if (player->IsPlayer() && !bPlayerBeingTeleported) {
GameMessages::SendSetStunned(playerID, eStateChangeType::PUSH, player->GetSystemAddress(), LWOOBJID_EMPTY,
true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = playerID;
stun.StateChangeType = eStateChangeType::PUSH;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.Send(player->GetSystemAddress());
auto animTime = RenderComponent::PlayAnimation(player, u"teledeath", 4.0f);
if (animTime == 0.0f) animTime = 2.0f;
@@ -106,9 +115,17 @@ void NtParadoxTeleServer::UnlockPlayer(Entity* self, Entity* player) {
m_TeleportingPlayerTable[playerID] = false;
GameMessages::SendSetStunned(playerID, eStateChangeType::POP, player->GetSystemAddress(), LWOOBJID_EMPTY,
true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = playerID;
stun.StateChangeType = eStateChangeType::POP;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.Send(player->GetSystemAddress());
auto teleCinematic = self->GetVar<std::u16string>(u"Cinematic");

View File

@@ -1,6 +1,7 @@
#include "NtVentureCannonServer.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "CombatMessages.h"
#include "EntityManager.h"
#include "Entity.h"
#include "GeneralUtils.h"
@@ -21,9 +22,17 @@ void NtVentureCannonServer::OnUse(Entity* self, Entity* user) {
self->SetNetworkVar(u"bIsInUse", true);
GameMessages::SendSetStunned(playerID, eStateChangeType::PUSH, player->GetSystemAddress(), LWOOBJID_EMPTY,
true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = playerID;
stun.StateChangeType = eStateChangeType::PUSH;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.Send(player->GetSystemAddress());
auto destPosition = self->GetPosition();
@@ -117,9 +126,17 @@ void NtVentureCannonServer::ExitCannonEnded(Entity* self, Entity* player) {
}
void NtVentureCannonServer::UnlockCannonPlayer(Entity* self, Entity* player) {
GameMessages::SendSetStunned(player->GetObjectID(), eStateChangeType::POP, player->GetSystemAddress(), LWOOBJID_EMPTY,
true, true, true, true, true, true, true
);
GameMessages::SetStunned stun;
stun.target = player->GetObjectID();
stun.StateChangeType = eStateChangeType::POP;
stun.bCantAttack = true;
stun.bCantEquip = true;
stun.bCantInteract = true;
stun.bCantJump = true;
stun.bCantMove = true;
stun.bCantTurn = true;
stun.bCantUseItem = true;
stun.Send(player->GetSystemAddress());
self->SetNetworkVar(u"bIsInUse", false);

View File

@@ -1,6 +1,7 @@
#include "FlameJetServer.h"
#include "SkillComponent.h"
#include "GameMessages.h"
#include "CombatMessages.h"
void FlameJetServer::OnStartup(Entity* self) {
if (self->GetVar<bool>(u"NotActive")) {
@@ -33,7 +34,13 @@ void FlameJetServer::OnCollisionPhantom(Entity* self, Entity* target) {
dir.x = -dir.x * 15;
dir.z = -dir.z * 15;
GameMessages::SendKnockback(target->GetObjectID(), self->GetObjectID(), self->GetObjectID(), 1000, dir);
GameMessages::Knockback knockback;
knockback.target = target->GetObjectID();
knockback.Caster = self->GetObjectID();
knockback.Originator = self->GetObjectID();
knockback.iKnockBackTimeMS = 1000;
knockback.vector = dir;
knockback.Send(UNASSIGNED_SYSTEM_ADDRESS);
}
void FlameJetServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {