MCPcopy Create free account
hub / github.com/NetHack/NetHack / boomhit

Function boomhit

src/zap.c:4147–4233  ·  view source on GitHub ↗

process thrown boomerang, which travels a curving path... * A multi-shot volley ought to have all missiles in flight at once, * but we're called separately for each one. We terminate the volley * early on a failed catch since continuing to throw after being hit * is too obviously silly. */

Source from the content-addressed store, hash-verified

4145 * is too obviously silly.
4146 */
4147struct monst *
4148boomhit(struct obj *obj, int dx, int dy)
4149{
4150 int i, ct;
4151 int boom; /* showsym[] index */
4152 struct monst *mtmp;
4153 boolean counterclockwise = URIGHTY; /* ULEFTY => clockwise */
4154 int nhits = max(1, obj->spe + 1);
4155
4156 /* counterclockwise traversal patterns, from @ to 1 then on through to 9
4157 * ..........................54.................................
4158 * ..................43.....6..3....765.........................
4159 * ..........32.....5..2...7...2...8...4....87..................
4160 * .........4..1....6..1...8..1....9...3...9..6.....98..........
4161 * ..21@....5...@...7..@....9@......@12....@...5...@..7.....@9..
4162 * .3...9....6..9....89.....................1..4...1..6....1..8.
4163 * .4...8.....78.............................23....2..5...2...7.
4164 * ..567............................................34....3..6..
4165 * ........................................................45...
4166 * (invert rows for corresponding clockwise patterns)
4167 */
4168
4169 gb.bhitpos.x = u.ux;
4170 gb.bhitpos.y = u.uy;
4171 boom = counterclockwise ? S_boomleft : S_boomright;
4172 i = xytodir(dx, dy);
4173 tmp_at(DISP_FLASH, cmap_to_glyph(boom));
4174 for (ct = 0; ct < 10; ct++) {
4175 i = DIR_CLAMP(i);
4176 boom = (S_boomleft + S_boomright - boom); /* toggle */
4177 tmp_at(DISP_CHANGE, cmap_to_glyph(boom)); /* change glyph */
4178 dx = xdir[i];
4179 dy = ydir[i];
4180 gb.bhitpos.x += dx;
4181 gb.bhitpos.y += dy;
4182 if (!isok(gb.bhitpos.x, gb.bhitpos.y)) {
4183 gb.bhitpos.x -= dx;
4184 gb.bhitpos.y -= dy;
4185 break;
4186 }
4187 if ((mtmp = m_at(gb.bhitpos.x, gb.bhitpos.y)) != 0) {
4188 m_respond(mtmp);
4189 if (nhits-- < 0) {
4190 tmp_at(DISP_END, 0);
4191 return mtmp;
4192 } else if (throwit_mon_hit(obj, mtmp) || !gt.thrownobj) {
4193 break;
4194 }
4195 }
4196 if (!ZAP_POS(levl[gb.bhitpos.x][gb.bhitpos.y].typ)
4197 || closed_door(gb.bhitpos.x, gb.bhitpos.y)) {
4198 gb.bhitpos.x -= dx;
4199 gb.bhitpos.y -= dy;
4200 break;
4201 }
4202 if (u_at(gb.bhitpos.x, gb.bhitpos.y)) { /* ct == 9 */
4203 if (Fumbling || rn2(20) >= ACURR(A_DEX)) {
4204 int dam = dmgval(obj, &gy.youmonst);

Callers 1

throwitFunction · 0.85

Calls 13

xytodirFunction · 0.85
tmp_atFunction · 0.85
isokFunction · 0.85
m_respondFunction · 0.85
throwit_mon_hitFunction · 0.85
closed_doorFunction · 0.85
rn2Function · 0.85
dmgvalFunction · 0.85
thituFunction · 0.85
endmultishotFunction · 0.85
YouFunction · 0.85
wake_neartoFunction · 0.85

Tested by

no test coverage detected