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

Function hurtle

src/dothrow.c:1077–1126  ·  view source on GitHub ↗

* The player moves through the air for a few squares as a result of * throwing or kicking something. * * dx and dy should be the direction of the hurtle, not of the original * kick or throw. */

Source from the content-addressed store, hash-verified

1075 * kick or throw.
1076 */
1077void
1078hurtle(int dx, int dy, int range, boolean verbose)
1079{
1080 coord uc, cc;
1081
1082 /* The chain is stretched vertically, so you shouldn't be able to move
1083 * very far diagonally. The premise that you should be able to move one
1084 * spot leads to calculations that allow you to only move one spot away
1085 * from the ball, if you are levitating over the ball, or one spot
1086 * towards the ball, if you are at the end of the chain. Rather than
1087 * bother with all of that, assume that there is no slack in the chain
1088 * for diagonal movement, give the player a message and return.
1089 */
1090 if (Punished && !carried(uball)) {
1091 You_feel("a tug from the iron ball.");
1092 nomul(0);
1093 return;
1094 } else if (u.utrap) {
1095 You("are anchored by the %s.",
1096 (u.utraptype == TT_WEB) ? "web"
1097 : (u.utraptype == TT_LAVA) ? hliquid("lava")
1098 : (u.utraptype == TT_INFLOOR) ? surface(u.ux, u.uy)
1099 : (u.utraptype == TT_BURIEDBALL) ? "buried ball"
1100 : "trap");
1101 nomul(0);
1102 return;
1103 }
1104
1105 /* make sure dx and dy are [-1,0,1] */
1106 dx = sgn(dx);
1107 dy = sgn(dy);
1108
1109 if (!range || (!dx && !dy) || u.ustuck)
1110 return; /* paranoia */
1111
1112 nomul(-range);
1113 gm.multi_reason = "moving through the air";
1114 gn.nomovemsg = ""; /* it just happens */
1115 if (verbose)
1116 You("%s in the opposite direction.",
1117 (range > 1) ? "hurtle" : "float");
1118 /* if we're in the midst of shooting multiple projectiles, stop */
1119 endmultishot(TRUE);
1120 uc.x = u.ux;
1121 uc.y = u.uy;
1122 /* this setting of cc is only correct if dx and dy are [-1,0,1] only */
1123 cc.x = u.ux + (dx * range);
1124 cc.y = u.uy + (dy * range);
1125 (void) walk_path(&uc, &cc, hurtle_step, (genericptr_t) &range);
1126}
1127
1128/* Move a monster through the air for a few squares. */
1129void

Callers 8

mhitm_knockbackFunction · 0.85
slip_or_tripFunction · 0.85
throwitFunction · 0.85
wiz_telekinesisFunction · 0.85
kick_dumbFunction · 0.85
kick_ouchFunction · 0.85
dokickFunction · 0.85
use_grappleFunction · 0.85

Calls 8

You_feelFunction · 0.85
nomulFunction · 0.85
YouFunction · 0.85
hliquidFunction · 0.85
surfaceFunction · 0.85
sgnFunction · 0.85
endmultishotFunction · 0.85
walk_pathFunction · 0.85

Tested by

no test coverage detected