/* Find a target for a ranged attack. */ struct monst * mfind_target(struct monst *mtmp, boolean helpful) { int dirx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, diry[8] = { 1, 1, 0, -1, -1, -1, 0, 1 }; int dir, origdir = -1; struct monst *mret; if (!helpful && !mtmp->mpeaceful && lined_up(mtmp)) return &youmonst; /* kludge - attack the player first if possible */ for (dir = rn2(8); dir != origdir; dir = ((dir + 1) % 8)) { if (origdir < 0) origdir = dir; if (m_beam_ok(mtmp, dirx[dir], diry[dir], &mret, helpful) && mret) { /* also check for a bounce */ if (m_beam_ok(mtmp, -dirx[dir], -diry[dir], NULL, helpful)) return mret; } } /* Nothing lined up? */ tbx = tby = 0; return NULL; }
/* monster uses spell (ranged) */ int buzzmu(struct monst *mtmp, const struct attack *mattk) { /* don't print constant stream of curse messages for 'normal' spellcasting monsters at range */ if (mattk->adtyp > AD_SPC2) return 0; if (mtmp->mcan) { cursetxt(mtmp, FALSE); return 0; } if (lined_up(mtmp) && rn2(3)) { nomul(0, NULL); if (mattk->adtyp && (mattk->adtyp < 11)) { /* no cf unsigned >0 */ if (canseemon(mtmp)) pline("%s zaps you with a %s!", Monnam(mtmp), flash_types[ad_to_typ(mattk->adtyp)]); buzz(-ad_to_typ(mattk->adtyp), (int)mattk->damn, mtmp->mx, mtmp->my, sgn(tbx), sgn(tby)); } } return 1; }