Browse Source

Unify code, and fix bugs related to golems

- OOBs
- Not getting XP from monsters hit by golems
- Sneaks fleeing in the wrong direction of golem
- Monsters going in active when fighting golems offscreen
pull/986/head
Anders Jenbo 5 years ago
parent
commit
973d95b9d4
  1. 34
      Source/monster.cpp

34
Source/monster.cpp

@ -1763,8 +1763,8 @@ void M2MStartHit(int mid, int i, int dam)
assurance((DWORD)mid < MAXMONSTERS, mid);
assurance(monster[mid].MType != NULL, mid);
if (i >= 0)
monster[i].mWhoHit |= 1 << i;
if (i >= 0 && i <= MAX_PLRS)
monster[mid].mWhoHit |= 1 << i;
delta_monster_hp(mid, monster[mid]._mhitpoints, currlevel);
NetSendCmdMonDmg(FALSE, mid, dam);
@ -1857,9 +1857,10 @@ void M2MStartKill(int i, int mid)
delta_kill_monster(mid, monster[mid]._mx, monster[mid]._my, currlevel);
NetSendCmdLocParam1(FALSE, CMD_MONSTDEATH, monster[mid]._mx, monster[mid]._my, mid);
monster[mid].mWhoHit |= 1 << i;
if (i < MAX_PLRS)
if (i < MAX_PLRS) {
monster[mid].mWhoHit |= 1 << i;
AddPlrMonstExper(monster[mid].mLevel, monster[mid].mExp, monster[mid].mWhoHit);
}
monstkills[monster[mid].MType->mtype]++;
monster[mid]._mhitpoints = 0;
@ -1892,9 +1893,8 @@ void M2MStartKill(int i, int mid)
if (monster[mid].MType->mtype >= MT_NACID && monster[mid].MType->mtype <= MT_XACID)
AddMissile(monster[mid]._mx, monster[mid]._my, 0, 0, 0, MIS_ACIDPUD, TARGET_PLAYERS, mid, monster[mid]._mint + 1, 0);
#ifdef HELLFIRE
M_StartStand(i, monster[i]._mdir);
#endif
if (gbIsHellfire)
M_StartStand(i, monster[i]._mdir);
}
void M_StartKill(int i, int pnum)
@ -2323,9 +2323,8 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
}
if (plr[pnum]._pHitPoints >> 6 <= 0) {
SyncPlrKill(pnum, 0);
#ifdef HELLFIRE
M_StartStand(i, monster[i]._mdir);
#endif
if (gbIsHellfire)
M_StartStand(i, monster[i]._mdir);
return;
}
StartPlrHit(pnum, dam, FALSE);
@ -3414,16 +3413,11 @@ void MAI_Sneak(int i)
Monst->_mgoalvar1 = 0;
}
}
#ifdef HELLFIRE
if (Monst->_mgoal == MGOAL_RETREAT && !(Monst->_mFlags & MFLAG_NO_ENEMY)) {
if (Monst->_mFlags & MFLAG_TARGETS_MONSTER)
md = GetDirection(Monst->_mx, Monst->_my, monster[Monst->_menemy]._mx, monster[Monst->_menemy]._my);
else
#else
if (Monst->_mgoal == MGOAL_RETREAT) {
if (Monst->_mFlags & MFLAG_TARGETS_MONSTER)
#endif
md = GetDirection(Monst->_mx, Monst->_my, plr[Monst->_menemy]._pownerx, plr[Monst->_menemy]._pownery);
if (Monst->_mFlags & MFLAG_TARGETS_MONSTER)
md = GetDirection(Monst->_mx, Monst->_my, monster[Monst->_menemy]._mx, monster[Monst->_menemy]._my);
else
md = GetDirection(Monst->_mx, Monst->_my, plr[Monst->_menemy]._pownerx, plr[Monst->_menemy]._pownery);
md = opposite[md];
if (Monst->MType->mtype == MT_UNSEEN) {
if (random_(112, 2) != 0)
@ -4124,7 +4118,7 @@ void MAI_Golum(int i)
for (k = 0; k < 5; k++) {
_menemy = dMonster[monster[i]._mx + k - 2][monster[i]._my + j - 2];
if (_menemy > 0)
monster[_menemy]._msquelch = UCHAR_MAX; // BUGFIX: should be `monster[_menemy-1]`, not monster[_menemy].
monster[_menemy - 1]._msquelch = UCHAR_MAX; // BUGFIX: should be `monster[_menemy-1]`, not monster[_menemy]. (fixed)
}
}
}

Loading…
Cancel
Save