MCPcopy Create free account
hub / github.com/diasurgical/devilution / MissToMonst

Function MissToMonst

Source/monster.cpp:5114–5190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5112}
5113
5114void MissToMonst(int i, int x, int y)
5115{
5116 int oldx, oldy;
5117 int newx, newy;
5118 int m, pnum;
5119 MissileStruct *Miss;
5120 MonsterStruct *Monst;
5121
5122 if ((DWORD)i >= MAXMISSILES)
5123 app_fatal("MissToMonst: Invalid missile %d", i);
5124
5125 Miss = &missile[i];
5126 m = Miss->_misource;
5127
5128 if ((DWORD)m >= MAXMONSTERS)
5129 app_fatal("MissToMonst: Invalid monster %d", m);
5130
5131 Monst = &monster[m];
5132 oldx = Miss->_mix;
5133 oldy = Miss->_miy;
5134 dMonster[x][y] = m + 1;
5135 Monst->_mdir = Miss->_mimfnum;
5136 Monst->_mx = x;
5137 Monst->_my = y;
5138 M_StartStand(m, Monst->_mdir);
5139 if (Monst->MType->mtype < MT_INCIN || Monst->MType->mtype > MT_HELLBURN) {
5140 if (!(Monst->_mFlags & MFLAG_TARGETS_MONSTER))
5141 M_StartHit(m, -1, 0);
5142 else
5143 M2MStartHit(m, -1, 0);
5144 } else {
5145 M_StartFadein(m, Monst->_mdir, FALSE);
5146 }
5147
5148 if (!(Monst->_mFlags & MFLAG_TARGETS_MONSTER)) {
5149 pnum = dPlayer[oldx][oldy] - 1;
5150 if (dPlayer[oldx][oldy] > 0) {
5151 if (Monst->MType->mtype != MT_GLOOM && (Monst->MType->mtype < MT_INCIN || Monst->MType->mtype > MT_HELLBURN)) {
5152 M_TryH2HHit(m, dPlayer[oldx][oldy] - 1, 500, Monst->mMinDamage2, Monst->mMaxDamage2);
5153 if (pnum == dPlayer[oldx][oldy] - 1 && (Monst->MType->mtype < MT_NSNAKE || Monst->MType->mtype > MT_GSNAKE)) {
5154 if (plr[pnum]._pmode != 7 && plr[pnum]._pmode != 8)
5155 StartPlrHit(pnum, 0, TRUE);
5156 newx = oldx + offset_x[Monst->_mdir];
5157 newy = oldy + offset_y[Monst->_mdir];
5158 if (PosOkPlayer(pnum, newx, newy)) {
5159 plr[pnum].WorldX = newx;
5160 plr[pnum].WorldY = newy;
5161 FixPlayerLocation(pnum, plr[pnum]._pdir);
5162 FixPlrWalkTags(pnum);
5163 dPlayer[newx][newy] = pnum + 1;
5164 SetPlayerOld(pnum);
5165 }
5166 }
5167 }
5168 }
5169 } else {
5170 if (dMonster[oldx][oldy] > 0) {
5171 if (Monst->MType->mtype != MT_GLOOM && (Monst->MType->mtype < MT_INCIN || Monst->MType->mtype > MT_HELLBURN)) {

Callers 2

MI_RhinoFunction · 0.85
mi_null_32Function · 0.85

Calls 13

app_fatalFunction · 0.85
M_StartStandFunction · 0.85
M_StartHitFunction · 0.85
M2MStartHitFunction · 0.85
M_StartFadeinFunction · 0.85
M_TryH2HHitFunction · 0.85
StartPlrHitFunction · 0.85
PosOkPlayerFunction · 0.85
FixPlayerLocationFunction · 0.85
FixPlrWalkTagsFunction · 0.85
SetPlayerOldFunction · 0.85
M_TryM2MHitFunction · 0.85

Tested by

no test coverage detected