diff --git a/Source/trigs.cpp b/Source/trigs.cpp index ab53a9574..5a6a5a72f 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -661,7 +661,7 @@ void CheckTrigForce() { trigflag = FALSE; - if (MouseY > PANEL_TOP - 1) { + if (!sgbControllerActive && MouseY > PANEL_TOP - 1) { return; } diff --git a/SourceX/controls/plrctrls.cpp b/SourceX/controls/plrctrls.cpp index fbcd8ead4..eed8eaa42 100644 --- a/SourceX/controls/plrctrls.cpp +++ b/SourceX/controls/plrctrls.cpp @@ -148,7 +148,8 @@ void FindItemOrObject() void CheckTownersNearby() { for (int i = 0; i < 16; i++) { - if (GetDistance(towner[i]._tx, towner[i]._ty, 2) == 0) + int distance = GetDistance(towner[i]._tx, towner[i]._ty, 2); + if (distance == 0 || distance > 2) continue; pcursmonst = i; } @@ -341,6 +342,49 @@ void FindActor() CheckPlayerNearby(); } +int pcursmissile; +int pcurstrig; + +void FindTrigger() +{ + if (pcursitem != -1 || pcursobj != -1) + return; // Prefer showing items/objects over triggers (use of cursm* conflicts) + + for (int i = 0; i < nummissiles; i++) { + int mi = missileactive[i]; + if (missile[mi]._mitype == MIS_TOWN || missile[mi]._mitype == MIS_RPORTAL) { + int distance = GetDistance(missile[mi]._mix, missile[mi]._miy, 2); + if (distance == 0 || distance > 2) + continue; + cursmx = missile[mi]._mix; + cursmy = missile[mi]._miy; + pcursmissile = mi; + } + } + + if (pcursmissile == -1) { + for (int i = 0; i < numtrigs; i++) { + int tx = trigs[i]._tx; + int ty = trigs[i]._ty; + if (trigs[i]._tlvl == 13) + ty -= 1; + int distance = GetDistance(tx, ty, 2); + if (distance == 0 || distance > 2) + continue; + cursmx = tx; + cursmy = ty; + pcurstrig = i; + } + } + + if (pcursmonst != -1 || pcursplr != -1) + return; // Prefer monster/player info text + + CheckTrigForce(); + CheckTown(); + CheckRportal(); +} + void Interact() { if (leveltype == DTYPE_TOWN && pcursmonst != -1) { @@ -767,11 +811,14 @@ void plrctrls_after_check_curs_move() pcursmonst = -1; pcursitem = -1; pcursobj = -1; + pcursmissile = -1; + pcurstrig = -1; if (!invflag) { *infostr = '\0'; ClearPanel(); FindActor(); FindItemOrObject(); + FindTrigger(); } } } @@ -914,6 +961,12 @@ void PerformSecondaryAction() NetSendCmdLocParam1(true, CMD_GOTOAGETITEM, cursmx, cursmy, pcursitem); } else if (pcursobj != -1) { NetSendCmdLocParam1(true, CMD_OPOBJXY, cursmx, cursmy, pcursobj); + } else if (pcursmissile != -1) { + MakePlrPath(myplr, missile[pcursmissile]._mix, missile[pcursmissile]._miy, true); + plr[myplr].destAction = ACTION_WALK; + } else if (pcurstrig != -1) { + MakePlrPath(myplr, trigs[pcurstrig]._tx, trigs[pcurstrig]._ty, true); + plr[myplr].destAction = ACTION_WALK; } } diff --git a/enums.h b/enums.h index c1634a6ec..5deeba2b2 100644 --- a/enums.h +++ b/enums.h @@ -2892,6 +2892,7 @@ typedef enum shrine_type { } shrine_type; typedef enum action_id { + ACTION_WALK = -2, // Automatic walk when using gamepad ACTION_NONE = -1, ACTION_ATTACK = 9, ACTION_RATTACK = 10,