Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Source/controls/plrctrls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <SDL3/SDL_gamepad.h>
#include <SDL3/SDL_timer.h>
#else
#include <SDL.h>

Check warning on line 13 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:13:1 [misc-include-cleaner]

included header SDL.h is not used directly

#ifdef USE_SDL1
#include "utils/sdl2_to_1_2_backports.h"
Expand Down Expand Up @@ -62,7 +62,7 @@

int pcurstrig = -1;
Missile *pcursmissile = nullptr;
quest_id pcursquest = Q_INVALID;

Check warning on line 65 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:65:23 [misc-include-cleaner]

no header providing "devilution::Q_INVALID" is directly included

Check warning on line 65 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:65:1 [misc-include-cleaner]

no header providing "devilution::quest_id" is directly included

/**
* Native game menu, controlled by simulating a keyboard.
Expand All @@ -75,8 +75,8 @@
|| ChatFlag
|| qtextflag
|| gmenu_is_active()
|| PauseMode == 2

Check warning on line 78 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:78:9 [misc-include-cleaner]

no header providing "devilution::PauseMode" is directly included
|| (MyPlayer != nullptr && MyPlayer->_pInvincible && MyPlayer->hasNoLife());

Check warning on line 79 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:79:10 [misc-include-cleaner]

no header providing "devilution::MyPlayer" is directly included
}

namespace {
Expand All @@ -86,7 +86,7 @@
int PreviousInventoryColumn = -1;
bool BeltReturnsToStash = false;

const Direction FaceDir[3][3] = {

Check warning on line 89 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:89:7 [misc-include-cleaner]

no header providing "devilution::Direction" is directly included
// NONE UP DOWN
{ Direction::South, Direction::North, Direction::South }, // NONE
{ Direction::West, Direction::NorthWest, Direction::SouthWest }, // LEFT
Expand Down Expand Up @@ -136,9 +136,9 @@
return 0;
}

int8_t walkpath[MaxPathLengthPlayer];

Check warning on line 139 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:139:18 [misc-include-cleaner]

no header providing "devilution::MaxPathLengthPlayer" is directly included
Player &myPlayer = *MyPlayer;
const int steps = FindPath(CanStep, [&myPlayer](Point position) { return PosOkPlayer(myPlayer, position); }, myPlayer.position.future, destination, walkpath, std::min<size_t>(maxDistance, MaxPathLengthPlayer));

Check warning on line 141 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:141:169 [misc-include-cleaner]

no header providing "size_t" is directly included

Check warning on line 141 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:141:75 [misc-include-cleaner]

no header providing "devilution::PosOkPlayer" is directly included

Check warning on line 141 in Source/controls/plrctrls.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/controls/plrctrls.cpp:141:20 [misc-include-cleaner]

no header providing "devilution::FindPath" is directly included
if (steps > maxDistance)
return 0;

Expand Down Expand Up @@ -524,9 +524,13 @@
position = Monsters[pcursmonst].position.tile;
}

NetSendCmdLoc(MyPlayerId, true, myPlayer.UsesRangedWeapon() ? CMD_RATTACKXY : CMD_SATTACKXY, position);
LastPlayerAction = PlayerActionType::Attack;
return;
bool bNear = myPlayer.position.tile.WalkingDistance(position) < 2;

if (!(bNear && (pcursmonst != -1 || PlayerUnderCursor != nullptr))) {
NetSendCmdLoc(MyPlayerId, true, myPlayer.UsesRangedWeapon() ? CMD_RATTACKXY : CMD_SATTACKXY, position);
LastPlayerAction = PlayerActionType::Attack;
return;
}
}

if (pcursmonst != -1) {
Expand Down
29 changes: 11 additions & 18 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ bool ProcessInput()

void LeftMouseCmd(bool bShift)
{
bool bNear;

assert(!GetMainPanel().contains(MousePosition));

if (leveltype == DTYPE_TOWN) {
Expand All @@ -264,17 +262,14 @@ void LeftMouseCmd(bool bShift)
}

const Player &myPlayer = *MyPlayer;
bNear = myPlayer.position.tile.WalkingDistance(cursPosition) < 2;
bool bNear = myPlayer.position.tile.WalkingDistance(cursPosition) < 2;
if (pcursitem != -1 && pcurs == CURSOR_HAND && !bShift) {
NetSendCmdLocParam1(true, invflag ? CMD_GOTOGETITEM : CMD_GOTOAGETITEM, cursPosition, pcursitem);
} else if (ObjectUnderCursor != nullptr && !ObjectUnderCursor->IsDisabled() && (!bShift || (bNear && ObjectUnderCursor->_oBreak == 1))) {
LastPlayerAction = PlayerActionType::OperateObject;
NetSendCmdLoc(MyPlayerId, true, pcurs == CURSOR_DISARM ? CMD_DISARMXY : CMD_OPOBJXY, cursPosition);
} else if (myPlayer.UsesRangedWeapon()) {
if (bShift) {
LastPlayerAction = PlayerActionType::Attack;
NetSendCmdLoc(MyPlayerId, true, CMD_RATTACKXY, cursPosition);
} else if (pcursmonst != -1) {
if (pcursmonst != -1) {
if (CanTalkToMonst(Monsters[pcursmonst])) {
NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst);
} else {
Expand All @@ -284,20 +279,18 @@ void LeftMouseCmd(bool bShift)
} else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) {
LastPlayerAction = PlayerActionType::AttackPlayerTarget;
NetSendCmdParam1(true, CMD_RATTACKPID, PlayerUnderCursor->getId());
} else if (bShift) {
LastPlayerAction = PlayerActionType::Attack;
NetSendCmdLoc(MyPlayerId, true, CMD_RATTACKXY, cursPosition);
}
} else {
if (bShift) {
if (pcursmonst != -1) {
if (CanTalkToMonst(Monsters[pcursmonst])) {
NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst);
} else {
LastPlayerAction = PlayerActionType::Attack;
NetSendCmdLoc(MyPlayerId, true, CMD_SATTACKXY, cursPosition);
}
} else {
LastPlayerAction = PlayerActionType::Attack;
NetSendCmdLoc(MyPlayerId, true, CMD_SATTACKXY, cursPosition);
if (bShift && !(bNear && (pcursmonst != -1 || PlayerUnderCursor != nullptr))) {
if (pcursmonst != -1 && CanTalkToMonst(Monsters[pcursmonst])) {
NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst);
return;
}
LastPlayerAction = PlayerActionType::Attack;
NetSendCmdLoc(MyPlayerId, true, CMD_SATTACKXY, cursPosition);
} else if (pcursmonst != -1) {
LastPlayerAction = PlayerActionType::AttackMonsterTarget;
NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst);
Expand Down
6 changes: 6 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Features

#### Gameplay

- Stand ground attacks nearby targets instead of nearby tiles to improve accuracy

## DevilutionX 1.5.2

### Bug Fixes
Expand Down
Loading