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

Function rndtrap

src/sp_lev.c:1158–1188  ·  view source on GitHub ↗

* Select a random trap */

Source from the content-addressed store, hash-verified

1156 * Select a random trap
1157 */
1158staticfn int
1159rndtrap(void)
1160{
1161 int rtrap;
1162
1163 do {
1164 rtrap = rnd(TRAPNUM - 1);
1165 switch (rtrap) {
1166 case HOLE: /* no random holes on special levels */
1167 case VIBRATING_SQUARE:
1168 case MAGIC_PORTAL:
1169 rtrap = NO_TRAP;
1170 break;
1171 case TRAPDOOR:
1172 if (!Can_dig_down(&u.uz))
1173 rtrap = NO_TRAP;
1174 break;
1175 case LEVEL_TELEP:
1176 case TELEP_TRAP:
1177 if (svl.level.flags.noteleport)
1178 rtrap = NO_TRAP;
1179 break;
1180 case ROLLING_BOULDER_TRAP:
1181 case ROCKTRAP:
1182 if (In_endgame(&u.uz))
1183 rtrap = NO_TRAP;
1184 break;
1185 }
1186 } while (rtrap == NO_TRAP);
1187 return rtrap;
1188}
1189
1190/*
1191 * Translate a given coordinate from a special level definition into an actual

Callers 1

fill_empty_mazeFunction · 0.85

Calls 2

rndFunction · 0.85
Can_dig_downFunction · 0.85

Tested by

no test coverage detected