Browse Source

[controller] Automatically apply heal-other, resurect and disarm

pull/496/head
Anders Jenbo 6 years ago
parent
commit
0c75636db3
  1. 19
      Source/missiles.cpp
  2. 2
      Source/scrollrt.cpp
  3. 62
      SourceX/controls/plrctrls.cpp

19
Source/missiles.cpp

@ -2049,8 +2049,11 @@ void AddHealOther(int mi, int sx, int sy, int dx, int dy, int midir, char mienem
{
missile[mi]._miDelFlag = TRUE;
UseMana(id, SPL_HEALOTHER);
if (id == myplr)
if (id == myplr) {
SetCursor_(CURSOR_HEALOTHER);
if (sgbControllerActive)
TryIconCurs();
}
}
void AddElement(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam)
@ -2206,8 +2209,15 @@ void AddDisarm(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy,
{
missile[mi]._miDelFlag = TRUE;
UseMana(id, SPL_DISARM);
if (id == myplr)
if (id == myplr) {
SetCursor_(CURSOR_DISARM);
if (sgbControllerActive) {
if (pcursobj != -1)
NetSendCmdLocParam1(true, CMD_DISARMXY, cursmx, cursmy, pcursobj);
else
SetCursor_(CURSOR_HAND);
}
}
}
void AddApoca(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam)
@ -2336,8 +2346,11 @@ void AddHbolt(int mi, int sx, int sy, int dx, int dy, int midir, char micaster,
void AddResurrect(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam)
{
UseMana(id, SPL_RESURRECT);
if (id == myplr)
if (id == myplr) {
SetCursor_(CURSOR_RESURRECT);
if (sgbControllerActive)
TryIconCurs();
}
missile[mi]._miDelFlag = TRUE;
}

2
Source/scrollrt.cpp

@ -106,7 +106,7 @@ static void scrollrt_draw_cursor_item()
return;
}
if (sgbControllerActive && !invflag && (!chrflag || plr[myplr]._pStatPts <= 0)) {
if (sgbControllerActive && pcurs != CURSOR_TELEPORT && !invflag && (!chrflag || plr[myplr]._pStatPts <= 0)) {
return;
}

62
SourceX/controls/plrctrls.cpp

@ -184,13 +184,56 @@ void CheckMonstersNearby()
}
}
void CheckPlayerNearby()
{
int newRotations, newDdistance;
int distance = 2 * (MAXDUNX + MAXDUNY);
int rotations = 5;
if (pcursmonst != -1)
return;
int spl = plr[myplr]._pRSpell;
if (FriendlyMode && spl != SPL_RESURRECT && spl != SPL_HEALOTHER)
return;
for (int i = 0; i < MAX_PLRS; i++) {
if (i == myplr)
continue;
const int mx = plr[i].WorldX;
const int my = plr[i].WorldY;
if (dPlayer[mx][my] == 0
|| !(dFlags[mx][my] & BFLAG_LIT)
|| (plr[i]._pHitPoints == 0 && spl != SPL_RESURRECT))
continue;
if (plr[myplr]._pwtype == WT_RANGED || HasRangedSpell() || spl == SPL_HEALOTHER)
newDdistance = GetDistanceRanged(mx, my);
else
newDdistance = GetDistance(mx, my);
if (newDdistance == 0 || distance < newDdistance) {
continue;
}
if (distance == newDdistance) {
newRotations = GetRoteryDistance(mx, my);
if (rotations < newRotations)
continue;
}
distance = newDdistance;
rotations = newRotations;
pcursplr = i;
}
}
void FindActor()
{
if (leveltype != DTYPE_TOWN)
CheckMonstersNearby();
else
CheckTownersNearby();
// TODO target players if !FriendlyMode
CheckPlayerNearby();
}
void Interact()
@ -730,6 +773,21 @@ void PerformSpellAction()
if (TryIconCurs())
return;
int spl = plr[myplr]._pRSpell;
if ((pcursplr == -1 && (spl == SPL_RESURRECT || spl == SPL_HEALOTHER))
|| (pcursobj == -1 && spl == SPL_DISARM)) {
if (plr[myplr]._pClass == PC_WARRIOR) {
PlaySFX(PS_WARR27);
#ifndef SPAWN
} else if (plr[myplr]._pClass == PC_ROGUE) {
PlaySFX(PS_ROGUE27);
} else if (plr[myplr]._pClass == PC_SORCERER) {
PlaySFX(PS_MAGE27);
#endif
}
return;
}
UpdateSpellTarget();
CheckPlrSpell();
}
@ -745,7 +803,7 @@ void PerformSecondaryAction()
if (pcursitem != -1 && pcurs == CURSOR_HAND) {
NetSendCmdLocParam1(true, CMD_GOTOAGETITEM, cursmx, cursmy, pcursitem);
} else if (pcursobj != -1) {
NetSendCmdLocParam1(true, pcurs == CURSOR_DISARM ? CMD_DISARMXY : CMD_OPOBJXY, cursmx, cursmy, pcursobj);
NetSendCmdLocParam1(true, CMD_OPOBJXY, cursmx, cursmy, pcursobj);
}
}

Loading…
Cancel
Save