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

Function ProcessMonsters

Source/monster.cpp:4519–4662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4517}
4518
4519void ProcessMonsters()
4520{
4521 int i, mi, mx, my, _menemy;
4522 BOOL raflag;
4523 MonsterStruct *Monst;
4524
4525 DeleteMonsterList();
4526
4527 assert((DWORD)nummonsters <= MAXMONSTERS);
4528 for (i = 0; i < nummonsters; i++) {
4529 mi = monstactive[i];
4530 Monst = &monster[mi];
4531 raflag = FALSE;
4532 if (gbMaxPlayers > 1) {
4533 SetRndSeed(Monst->_mAISeed);
4534 Monst->_mAISeed = GetRndSeed();
4535 }
4536 if (!(monster[mi]._mFlags & MFLAG_NOHEAL) && Monst->_mhitpoints < Monst->_mmaxhp && Monst->_mhitpoints >> 6 > 0) {
4537 if (Monst->mLevel > 1) {
4538 Monst->_mhitpoints += Monst->mLevel >> 1;
4539 } else {
4540 Monst->_mhitpoints += Monst->mLevel;
4541 }
4542 }
4543 mx = Monst->_mx;
4544 my = Monst->_my;
4545#ifndef SPAWN
4546 if (dFlags[mx][my] & BFLAG_VISIBLE && Monst->_msquelch == 0) {
4547 if (Monst->MType->mtype == MT_CLEAVER) {
4548 PlaySFX(USFX_CLEAVER);
4549 }
4550 }
4551#endif
4552 if (Monst->_mFlags & MFLAG_TARGETS_MONSTER) {
4553 _menemy = Monst->_menemy;
4554 if ((DWORD)_menemy >= MAXMONSTERS) {
4555 app_fatal("Illegal enemy monster %d for monster \"%s\"", _menemy, Monst->mName);
4556 }
4557 Monst->_lastx = monster[Monst->_menemy]._mfutx;
4558 Monst->_menemyx = Monst->_lastx;
4559 Monst->_lasty = monster[Monst->_menemy]._mfuty;
4560 Monst->_menemyy = Monst->_lasty;
4561 } else {
4562 _menemy = Monst->_menemy;
4563 if ((DWORD)_menemy >= MAX_PLRS) {
4564 app_fatal("Illegal enemy player %d for monster \"%s\"", _menemy, Monst->mName);
4565 }
4566 Monst->_menemyx = plr[Monst->_menemy]._px;
4567 Monst->_menemyy = plr[Monst->_menemy]._py;
4568 if (dFlags[mx][my] & BFLAG_VISIBLE) {
4569 Monst->_msquelch = 255;
4570 Monst->_lastx = plr[Monst->_menemy]._px;
4571 Monst->_lasty = plr[Monst->_menemy]._py;
4572 } else if (Monst->_msquelch != 0 && Monst->_mAi != MT_DIABLO) { /// BUGFIX: change '_mAi' to 'MType->mtype'
4573 Monst->_msquelch--;
4574 }
4575 }
4576 do {

Callers 1

game_logicFunction · 0.85

Calls 15

DeleteMonsterListFunction · 0.85
SetRndSeedFunction · 0.85
GetRndSeedFunction · 0.85
PlaySFXFunction · 0.85
app_fatalFunction · 0.85
MAI_PathFunction · 0.85
M_DoStandFunction · 0.85
M_DoWalkFunction · 0.85
M_DoWalk2Function · 0.85
M_DoWalk3Function · 0.85
M_DoAttackFunction · 0.85
M_DoGotHitFunction · 0.85

Tested by

no test coverage detected