From cdbde9cdcb37c118e6b8bbe52f6c9f25ea7bb225 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 13 Dec 2019 23:58:35 +0100 Subject: [PATCH] [controller] Target quest entrances --- SourceX/controls/plrctrls.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/SourceX/controls/plrctrls.cpp b/SourceX/controls/plrctrls.cpp index bd3dd4110..203288c72 100644 --- a/SourceX/controls/plrctrls.cpp +++ b/SourceX/controls/plrctrls.cpp @@ -349,6 +349,7 @@ void FindActor() int pcursmissile; int pcurstrig; +int pcursquest; void FindTrigger() { @@ -391,6 +392,19 @@ void FindTrigger() cursmy = ty; pcurstrig = i; } + + if (pcurstrig == -1) { + for (int i = 0; i < MAXQUESTS; i++) { + if (i == QTYPE_VB || currlevel != quests[i]._qlevel || quests[i]._qslvl == 0) + continue; + const int newDdistance = GetDistance(quests[i]._qtx, quests[i]._qty, 2); + if (newDdistance == 0) + continue; + cursmx = quests[i]._qtx; + cursmy = quests[i]._qty; + pcursquest = i; + } + } } if (pcursmonst != -1 || pcursplr != -1 || cursmx == -1 || cursmy == -1) @@ -829,6 +843,7 @@ void plrctrls_after_check_curs_move() pcursobj = -1; pcursmissile = -1; pcurstrig = -1; + pcursquest = -1; cursmx = -1; cursmy = -1; if (!invflag) { @@ -985,6 +1000,9 @@ void PerformSecondaryAction() } else if (pcurstrig != -1) { MakePlrPath(myplr, trigs[pcurstrig]._tx, trigs[pcurstrig]._ty, true); plr[myplr].destAction = ACTION_WALK; + } else if (pcursquest != -1) { + MakePlrPath(myplr, quests[pcursquest]._qtx, quests[pcursquest]._qty, true); + plr[myplr].destAction = ACTION_WALK; } }