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

Function trapeffect_dart_trap

src/trap.c:1250–1321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1248}
1249
1250staticfn int
1251trapeffect_dart_trap(
1252 struct monst *mtmp,
1253 struct trap *trap,
1254 unsigned int trflags UNUSED)
1255{
1256 struct obj *otmp;
1257 int dam;
1258
1259 if (mtmp == &gy.youmonst) {
1260 int oldumort = u.umortality;
1261
1262 if (trap->once && trap->tseen && !rn2(15)) {
1263 Soundeffect(se_soft_click, 30);
1264 You_hear("a soft click.");
1265 deltrap(trap);
1266 newsym(u.ux, u.uy);
1267 return Trap_Is_Gone;
1268 }
1269 trap->once = 1;
1270 seetrap(trap);
1271 pline("A little dart shoots out at you!");
1272 otmp = t_missile(DART, trap);
1273 if (!rn2(6))
1274 otmp->opoisoned = 1;
1275 dam = dmgval(otmp, &gy.youmonst);
1276 if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) {
1277 ; /* nothing */
1278 } else if (thitu(7, Maybe_Half_Phys(dam), &otmp, "little dart")) {
1279 if (otmp) {
1280 if (otmp->opoisoned)
1281 poisoned("dart", A_CON, "little dart",
1282 /* if damage triggered life-saving,
1283 poison is limited to attrib loss */
1284 (u.umortality > oldumort) ? 0 : 10, TRUE);
1285 obfree(otmp, (struct obj *) 0);
1286 }
1287 } else {
1288 place_object(otmp, u.ux, u.uy);
1289 if (!Blind)
1290 observe_object(otmp);
1291 stackobj(otmp);
1292 newsym(u.ux, u.uy);
1293 }
1294 } else {
1295 boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
1296 boolean see_it = cansee(mtmp->mx, mtmp->my);
1297 boolean trapkilled = FALSE;
1298
1299 if (trap->once && trap->tseen && !rn2(15)) {
1300 if (in_sight && see_it)
1301 pline_mon(mtmp,
1302 "%s triggers a trap but nothing happens.",
1303 Monnam(mtmp));
1304 deltrap(trap);
1305 newsym(mtmp->mx, mtmp->my);
1306 return Trap_Is_Gone;
1307 }

Callers 1

trapeffect_selectorFunction · 0.85

Calls 15

rn2Function · 0.85
You_hearFunction · 0.85
deltrapFunction · 0.85
newsymFunction · 0.85
seetrapFunction · 0.85
t_missileFunction · 0.85
dmgvalFunction · 0.85
steedintrapFunction · 0.85
thituFunction · 0.85
poisonedFunction · 0.85
obfreeFunction · 0.85
place_objectFunction · 0.85

Tested by

no test coverage detected