Browse Source

Prevent targeting dead players (#8393)

pull/8285/head
Eric Robinson 3 months ago committed by GitHub
parent
commit
72174930fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      Source/controls/plrctrls.cpp
  2. 6
      Source/diablo.cpp
  3. 2
      Source/player.cpp

2
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;

6
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<int8_t>(spellID), static_cast<uint8_t>(spellType), static_cast<uint16_t>(sd), spellFrom);
} else if (pcursmonst != -1 && leveltype != DTYPE_TOWN) {
NetSendCmdParam4(true, CMD_SPELLID, pcursmonst, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);
} else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) {
} else if (PlayerUnderCursor != nullptr && !PlayerUnderCursor->hasNoLife() && !myPlayer.friendlyMode) {
NetSendCmdParam4(true, CMD_SPELLPID, PlayerUnderCursor->getId(), static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);
} else {
NetSendCmdLocParam3(true, CMD_SPELLXY, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);

2
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<int8_t>(spellID), static_cast<uint8_t>(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<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);
} else {

Loading…
Cancel
Save