MCPcopy Index your code
hub / github.com/NetHack/NetHack / dobuzz

Function dobuzz

src/zap.c:4779–5037  ·  view source on GitHub ↗

* type == 0 to 9 : you zapping a wand * type == 10 to 19 : you casting a spell * type == 20 to 29 : you breathing as a monster * type == -10 to -19 : monster casting spell * type == -20 to -29 : monster breathing at you * type == -30 to -39 : monster zapping a wand * called with dx = dy = 0 for vertical bolts */

Source from the content-addressed store, hash-verified

4777 * called with dx = dy = 0 for vertical bolts
4778 */
4779void
4780dobuzz(
4781 int type, /* 0..29 (by hero) or -39..-10 (by monster) */
4782 int nd, /* damage strength ('number of dice') */
4783 coordxy sx, coordxy sy, /* starting point */
4784 int dx, int dy, /* direction delta */
4785 boolean sayhit, boolean saymiss, /* report out of sight hit/miss events */
4786 boolean forcemiss)
4787{
4788 int range, fltyp = zaptype(type), damgtype = fltyp % 10;
4789 coordxy lsx, lsy;
4790 struct monst *mon;
4791 coord save_bhitpos;
4792 boolean shopdamage = FALSE,
4793 fireball = (type == ZT_SPELL(ZT_FIRE)), /* set once */
4794 gas_hit = FALSE; /* will be set during each iteration */
4795 struct obj *otmp;
4796 int spell_type;
4797 int hdmgtype = Hallucination ? rn2(6) : damgtype;
4798
4799 /* if it's a hero spell then get its SPE_TYPE */
4800 spell_type = is_hero_spell(type) ? SPE_MAGIC_MISSILE + damgtype : 0;
4801
4802 if (u.uswallow) {
4803 int tmp;
4804
4805 if (type < 0)
4806 return;
4807 tmp = zhitm(u.ustuck, type, nd, &otmp);
4808 if (!u.ustuck) {
4809 u.uswallow = 0;
4810 } else {
4811 pline("%s rips into %s%s", The(flash_str(fltyp, FALSE)),
4812 mon_nam(u.ustuck), exclam(tmp));
4813 /* Using disintegration from the inside only makes a hole... */
4814 if (tmp == MAGIC_COOKIE)
4815 u.ustuck->mhp = 0;
4816 if (DEADMONSTER(u.ustuck))
4817 killed(u.ustuck);
4818 }
4819 return;
4820 }
4821 if (type < 0)
4822 newsym(u.ux, u.uy);
4823 range = rn1(7, 7);
4824 if (dx == 0 && dy == 0)
4825 range = 1;
4826 save_bhitpos = gb.bhitpos;
4827
4828 tmp_at(DISP_BEAM, zapdir_to_glyph(dx, dy, hdmgtype));
4829 while (range-- > 0) {
4830 lsx = sx;
4831 sx += dx;
4832 lsy = sy;
4833 sy += dy;
4834 if (!isok(sx, sy) || levl[sx][sy].typ == STONE)
4835 goto make_bounce;
4836

Callers 4

ubuzzFunction · 0.85
buzzFunction · 0.85
buzz_force_missFunction · 0.85
breammFunction · 0.85

Calls 15

zaptypeFunction · 0.85
rn2Function · 0.85
zhitmFunction · 0.85
TheFunction · 0.85
flash_strFunction · 0.85
mon_namFunction · 0.85
exclamFunction · 0.85
killedFunction · 0.85
newsymFunction · 0.85
tmp_atFunction · 0.85
zapdir_to_glyphFunction · 0.85
isokFunction · 0.85

Tested by

no test coverage detected