feat(skills): end a dead caster's skill when a client reports it (CasterDead)

When a client gets EchoStartSkill (or SyncSkill) from a caster it sees
as dead, aimed at another object, it logs "msgEchoStartSkill
msgCasterDead" and sends CasterDead (120: optional i64Caster, optional
uiSkillHandle) through that target
(LWOSkillComponent::msgEchoStartSkill 0x00d5dc90). 303 live packets, the
target nearly always the attacked player, the caster a spawned enemy;
the next messages were mostly Die and SetStunned for the player. DLU
dropped it.

The server now ends that skill on the caster: its behaviors with that
handle are dropped (end entries run, pending timers and syncs discarded,
its projectiles removed), so a hit an enemy scheduled before dying does
not land later. It only does so when the server also sees the caster as
dead, so a client can't cancel a living enemy's attack. What live did
with the message is inferred from the name and when it was sent.

Check in game: kill an enemy in the middle of a slow or charged attack
(e.g. a Maelstrom horseman or a spider queen add): its attack does not
hit after it has died, and other enemies' attacks still hit normally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-29 03:13:56 -05:00
parent 8d4422fa5c
commit dd116b9794
6 changed files with 104 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
#include "dServer.h"
#include "eMissionTaskType.h"
#include "Entity.h"
#include "EntityManager.h"
#include "Game.h"
#include "InventoryComponent.h"
#include "MissionComponent.h"
@@ -57,6 +58,27 @@ namespace GameMessages {
return true;
}
void CasterDead::Serialize(RakNet::BitStream& bitStream) const {
BitStreamUtils::WriteOptional(bitStream, i64Caster, LWOOBJID_EMPTY);
BitStreamUtils::WriteOptional(bitStream, uiSkillHandle, 0u);
}
bool CasterDead::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(BitStreamUtils::ReadOptional(bitStream, i64Caster, LWOOBJID_EMPTY));
VALIDATE_READ(BitStreamUtils::ReadOptional(bitStream, uiSkillHandle, 0u));
return true;
}
void CasterDead::Handle(Entity& entity, const SystemAddress& sysAddr) {
// Only for a caster the server also sees as dead: a client can't cancel a living enemy's attack
auto* const caster = Game::entityManager->GetEntity(i64Caster);
if (!caster) return;
const auto* const destroyable = caster->GetComponent<DestroyableComponent>();
if (!destroyable || !destroyable->GetIsDead()) return;
auto* const skillComponent = caster->GetComponent<SkillComponent>();
if (skillComponent) skillComponent->EndSkill(uiSkillHandle);
}
void SelectSkill::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(bFromSkillSet);
bitStream.Write(skillID);