From 72174930fb22cd1ac3024b0aae310449694574c2 Mon Sep 17 00:00:00 2001 From: Eric Robinson <68359262+kphoenix137@users.noreply.github.com> Date: Tue, 30 Dec 2025 18:41:27 -0500 Subject: [PATCH] Prevent targeting dead players (#8393) --- Source/controls/plrctrls.cpp | 2 +- Source/diablo.cpp | 6 +++--- Source/player.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 4ab25c8ea..7a54aba31 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -539,7 +539,7 @@ void Interact() return; } - if (leveltype != DTYPE_TOWN && PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) { + if (leveltype != DTYPE_TOWN && PlayerUnderCursor != nullptr && !PlayerUnderCursor->hasNoLife() && !myPlayer.friendlyMode) { NetSendCmdParam1(true, myPlayer.UsesRangedWeapon() ? CMD_RATTACKPID : CMD_ATTACKPID, PlayerUnderCursor->getId()); LastPlayerAction = PlayerActionType::AttackPlayerTarget; return; diff --git a/Source/diablo.cpp b/Source/diablo.cpp index cd095aa90..7fcd30399 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -281,7 +281,7 @@ void LeftMouseCmd(bool bShift) LastPlayerAction = PlayerActionType::AttackMonsterTarget; NetSendCmdParam1(true, CMD_RATTACKID, pcursmonst); } - } else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) { + } else if (PlayerUnderCursor != nullptr && !PlayerUnderCursor->hasNoLife() && !myPlayer.friendlyMode) { LastPlayerAction = PlayerActionType::AttackPlayerTarget; NetSendCmdParam1(true, CMD_RATTACKPID, PlayerUnderCursor->getId()); } @@ -301,7 +301,7 @@ void LeftMouseCmd(bool bShift) } else if (pcursmonst != -1) { LastPlayerAction = PlayerActionType::AttackMonsterTarget; NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst); - } else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) { + } else if (PlayerUnderCursor != nullptr && !PlayerUnderCursor->hasNoLife() && !myPlayer.friendlyMode) { LastPlayerAction = PlayerActionType::AttackPlayerTarget; NetSendCmdParam1(true, CMD_ATTACKPID, PlayerUnderCursor->getId()); } @@ -2853,7 +2853,7 @@ bool TryIconCurs() NetSendCmdLocParam4(true, CMD_SPELLXYD, cursPosition, static_cast(spellID), static_cast(spellType), static_cast(sd), spellFrom); } else if (pcursmonst != -1 && leveltype != DTYPE_TOWN) { NetSendCmdParam4(true, CMD_SPELLID, pcursmonst, static_cast(spellID), static_cast(spellType), spellFrom); - } else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) { + } else if (PlayerUnderCursor != nullptr && !PlayerUnderCursor->hasNoLife() && !myPlayer.friendlyMode) { NetSendCmdParam4(true, CMD_SPELLPID, PlayerUnderCursor->getId(), static_cast(spellID), static_cast(spellType), spellFrom); } else { NetSendCmdLocParam3(true, CMD_SPELLXY, cursPosition, static_cast(spellID), static_cast(spellType), spellFrom); diff --git a/Source/player.cpp b/Source/player.cpp index 894b8335d..a9b9a3aa6 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3206,7 +3206,7 @@ void CheckPlrSpell(bool isShiftHeld, SpellID spellID, SpellType spellType) } else if (pcursmonst != -1 && !isShiftHeld) { LastPlayerAction = PlayerActionType::SpellMonsterTarget; NetSendCmdParam4(true, CMD_SPELLID, pcursmonst, static_cast(spellID), static_cast(spellType), spellFrom); - } else if (PlayerUnderCursor != nullptr && !isShiftHeld && !myPlayer.friendlyMode) { + } else if (PlayerUnderCursor != nullptr && !PlayerUnderCursor->hasNoLife() && !isShiftHeld && !myPlayer.friendlyMode) { LastPlayerAction = PlayerActionType::SpellPlayerTarget; NetSendCmdParam4(true, CMD_SPELLPID, PlayerUnderCursor->getId(), static_cast(spellID), static_cast(spellType), spellFrom); } else {