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

Function M_DoAttack

Source/monster.cpp:2171–2205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2169}
2170
2171BOOL M_DoAttack(int i)
2172{
2173 MonsterStruct *Monst;
2174
2175 if ((DWORD)i >= MAXMONSTERS)
2176 app_fatal("M_DoAttack: Invalid monster %d", i);
2177
2178 Monst = &monster[i];
2179 if (Monst->MType == NULL)
2180 app_fatal("M_DoAttack: Monster %d \"%s\" MType NULL", i, Monst->mName);
2181 if (Monst->MType == NULL) // BUGFIX: should check MData
2182 app_fatal("M_DoAttack: Monster %d \"%s\" MData NULL", i, Monst->mName);
2183
2184 if (monster[i]._mAnimFrame == monster[i].MData->mAFNum) {
2185 M_TryH2HHit(i, monster[i]._menemy, monster[i].mHit, monster[i].mMinDamage, monster[i].mMaxDamage);
2186 if (monster[i]._mAi != AI_SNAKE)
2187 PlayEffect(i, 0);
2188 }
2189 if (monster[i].MType->mtype >= MT_NMAGMA && monster[i].MType->mtype <= MT_WMAGMA && monster[i]._mAnimFrame == 9) {
2190 M_TryH2HHit(i, monster[i]._menemy, monster[i].mHit + 10, monster[i].mMinDamage - 2, monster[i].mMaxDamage - 2);
2191 PlayEffect(i, 0);
2192 }
2193 if (monster[i].MType->mtype >= MT_STORM && monster[i].MType->mtype <= MT_MAEL && monster[i]._mAnimFrame == 13) {
2194 M_TryH2HHit(i, monster[i]._menemy, monster[i].mHit - 20, monster[i].mMinDamage + 4, monster[i].mMaxDamage + 4);
2195 PlayEffect(i, 0);
2196 }
2197 if (monster[i]._mAi == AI_SNAKE && monster[i]._mAnimFrame == 1)
2198 PlayEffect(i, 0);
2199 if (monster[i]._mAnimFrame == monster[i]._mAnimLen) {
2200 M_StartStand(i, monster[i]._mdir);
2201 return TRUE;
2202 }
2203
2204 return FALSE;
2205}
2206
2207BOOL M_DoRAttack(int i)
2208{

Callers 1

ProcessMonstersFunction · 0.85

Calls 4

app_fatalFunction · 0.85
M_TryH2HHitFunction · 0.85
PlayEffectFunction · 0.85
M_StartStandFunction · 0.85

Tested by

no test coverage detected