| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
#include "angband.h" |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
static bool check_hit(int power) |
|---|
| 27 |
{ |
|---|
| 28 |
return test_hit(power, p_ptr->ac + p_ptr->to_a, TRUE); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
void pick_trap(int y, int x) |
|---|
| 41 |
{ |
|---|
| 42 |
int feat; |
|---|
| 43 |
|
|---|
| 44 |
const static int min_level[] = |
|---|
| 45 |
{ |
|---|
| 46 |
2, |
|---|
| 47 |
2, |
|---|
| 48 |
2, |
|---|
| 49 |
2, |
|---|
| 50 |
3, |
|---|
| 51 |
1, |
|---|
| 52 |
2, |
|---|
| 53 |
2, |
|---|
| 54 |
2, |
|---|
| 55 |
6, |
|---|
| 56 |
6, |
|---|
| 57 |
6, |
|---|
| 58 |
2, |
|---|
| 59 |
1, |
|---|
| 60 |
2, |
|---|
| 61 |
2, |
|---|
| 62 |
}; |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
if (cave_feat[y][x] != FEAT_INVIS) return; |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
while (1) |
|---|
| 69 |
{ |
|---|
| 70 |
|
|---|
| 71 |
feat = FEAT_TRAP_HEAD + randint0(16); |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
if (min_level[feat - FEAT_TRAP_HEAD] > p_ptr->depth) continue; |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
if ((feat == FEAT_TRAP_HEAD + 0x00) && is_quest(p_ptr->depth)) continue; |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
if ((feat == FEAT_TRAP_HEAD + 0x00) && (p_ptr->depth >= MAX_DEPTH-1)) continue; |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
break; |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
cave_set_feat(y, x, feat); |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
void place_trap(int y, int x) |
|---|
| 102 |
{ |
|---|
| 103 |
|
|---|
| 104 |
if (!in_bounds(y, x)) return; |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
if (!cave_naked_bold(y, x)) return; |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
cave_set_feat(y, x, FEAT_INVIS); |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
void hit_trap(int y, int x) |
|---|
| 120 |
{ |
|---|
| 121 |
int i, num, dam; |
|---|
| 122 |
|
|---|
| 123 |
cptr name = "a trap"; |
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
disturb(0, 0); |
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
switch (cave_feat[y][x]) |
|---|
| 131 |
{ |
|---|
| 132 |
case FEAT_TRAP_HEAD + 0x00: |
|---|
| 133 |
{ |
|---|
| 134 |
msg_print("You fall through a trap door!"); |
|---|
| 135 |
if (p_ptr->ffall) |
|---|
| 136 |
{ |
|---|
| 137 |
msg_print("You float gently down to the next level."); |
|---|
| 138 |
} |
|---|
| 139 |
else |
|---|
| 140 |
{ |
|---|
| 141 |
dam = damroll(2, 8); |
|---|
| 142 |
take_hit(dam, name); |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
p_ptr->depth++; |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
p_ptr->leaving = TRUE; |
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
p_ptr->create_down_stair = FALSE; |
|---|
| 153 |
p_ptr->create_up_stair = FALSE; |
|---|
| 154 |
|
|---|
| 155 |
break; |
|---|
| 156 |
} |
|---|
| 157 |
|
|---|
| 158 |
case FEAT_TRAP_HEAD + 0x01: |
|---|
| 159 |
{ |
|---|
| 160 |
msg_print("You fall into a pit!"); |
|---|
| 161 |
if (p_ptr->ffall) |
|---|
| 162 |
{ |
|---|
| 163 |
msg_print("You float gently to the bottom of the pit."); |
|---|
| 164 |
} |
|---|
| 165 |
else |
|---|
| 166 |
{ |
|---|
| 167 |
dam = damroll(2, 6); |
|---|
| 168 |
take_hit(dam, name); |
|---|
| 169 |
} |
|---|
| 170 |
break; |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
case FEAT_TRAP_HEAD + 0x02: |
|---|
| 174 |
{ |
|---|
| 175 |
msg_print("You fall into a spiked pit!"); |
|---|
| 176 |
|
|---|
| 177 |
if (p_ptr->ffall) |
|---|
| 178 |
{ |
|---|
| 179 |
msg_print("You float gently to the floor of the pit."); |
|---|
| 180 |
msg_print("You carefully avoid touching the spikes."); |
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
else |
|---|
| 184 |
{ |
|---|
| 185 |
|
|---|
| 186 |
dam = damroll(2, 6); |
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
if (one_in_(2)) |
|---|
| 190 |
{ |
|---|
| 191 |
msg_print("You are impaled!"); |
|---|
| 192 |
|
|---|
| 193 |
dam = dam * 2; |
|---|
| 194 |
(void)inc_timed(TMD_CUT, randint1(dam)); |
|---|
| 195 |
} |
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
take_hit(dam, name); |
|---|
| 199 |
} |
|---|
| 200 |
break; |
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
case FEAT_TRAP_HEAD + 0x03: |
|---|
| 204 |
{ |
|---|
| 205 |
msg_print("You fall into a spiked pit!"); |
|---|
| 206 |
|
|---|
| 207 |
if (p_ptr->ffall) |
|---|
| 208 |
{ |
|---|
| 209 |
msg_print("You float gently to the floor of the pit."); |
|---|
| 210 |
msg_print("You carefully avoid touching the spikes."); |
|---|
| 211 |
} |
|---|
| 212 |
|
|---|
| 213 |
else |
|---|
| 214 |
{ |
|---|
| 215 |
|
|---|
| 216 |
dam = damroll(2, 6); |
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
if (one_in_(2)) |
|---|
| 220 |
{ |
|---|
| 221 |
msg_print("You are impaled on poisonous spikes!"); |
|---|
| 222 |
|
|---|
| 223 |
dam = dam * 2; |
|---|
| 224 |
(void)inc_timed(TMD_CUT, randint1(dam)); |
|---|
| 225 |
|
|---|
| 226 |
if (p_ptr->resist_pois || p_ptr->timed[TMD_OPP_POIS]) |
|---|
| 227 |
{ |
|---|
| 228 |
msg_print("The poison does not affect you!"); |
|---|
| 229 |
} |
|---|
| 230 |
else |
|---|
| 231 |
{ |
|---|
| 232 |
dam = dam * 2; |
|---|
| 233 |
(void)inc_timed(TMD_POISONED, randint1(dam)); |
|---|
| 234 |
} |
|---|
| 235 |
} |
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 |
take_hit(dam, name); |
|---|
| 239 |
} |
|---|
| 240 |
|
|---|
| 241 |
break; |
|---|
| 242 |
} |
|---|
| 243 |
|
|---|
| 244 |
case FEAT_TRAP_HEAD + 0x04: |
|---|
| 245 |
{ |
|---|
| 246 |
sound(MSG_SUM_MONSTER); |
|---|
| 247 |
msg_print("You are enveloped in a cloud of smoke!"); |
|---|
| 248 |
cave_info[y][x] &= ~(CAVE_MARK); |
|---|
| 249 |
cave_set_feat(y, x, FEAT_FLOOR); |
|---|
| 250 |
num = 2 + randint1(3); |
|---|
| 251 |
for (i = 0; i < num; i++) |
|---|
| 252 |
{ |
|---|
| 253 |
(void)summon_specific(y, x, p_ptr->depth, 0); |
|---|
| 254 |
} |
|---|
| 255 |
break; |
|---|
| 256 |
} |
|---|
| 257 |
|
|---|
| 258 |
case FEAT_TRAP_HEAD + 0x05: |
|---|
| 259 |
{ |
|---|
| 260 |
msg_print("You hit a teleport trap!"); |
|---|
| 261 |
teleport_player(100); |
|---|
| 262 |
break; |
|---|
| 263 |
} |
|---|
| 264 |
|
|---|
| 265 |
case FEAT_TRAP_HEAD + 0x06: |
|---|
| 266 |
{ |
|---|
| 267 |
msg_print("You are enveloped in flames!"); |
|---|
| 268 |
dam = damroll(4, 6); |
|---|
| 269 |
fire_dam(dam, "a fire trap"); |
|---|
| 270 |
break; |
|---|
| 271 |
} |
|---|
| 272 |
|
|---|
| 273 |
case FEAT_TRAP_HEAD + 0x07: |
|---|
| 274 |
{ |
|---|
| 275 |
msg_print("You are splashed with acid!"); |
|---|
| 276 |
dam = damroll(4, 6); |
|---|
| 277 |
acid_dam(dam, "an acid trap"); |
|---|
| 278 |
break; |
|---|
| 279 |
} |
|---|
| 280 |
|
|---|
| 281 |
case FEAT_TRAP_HEAD + 0x08: |
|---|
| 282 |
{ |
|---|
| 283 |
if (check_hit(125)) |
|---|
| 284 |
{ |
|---|
| 285 |
msg_print("A small dart hits you!"); |
|---|
| 286 |
dam = damroll(1, 4); |
|---|
| 287 |
take_hit(dam, name); |
|---|
| 288 |
(void)inc_timed(TMD_SLOW, randint0(20) + 20); |
|---|
| 289 |
} |
|---|
| 290 |
else |
|---|
| 291 |
{ |
|---|
| 292 |
msg_print("A small dart barely misses you."); |
|---|
| 293 |
} |
|---|
| 294 |
break; |
|---|
| 295 |
} |
|---|
| 296 |
|
|---|
| 297 |
case FEAT_TRAP_HEAD + 0x09: |
|---|
| 298 |
{ |
|---|
| 299 |
if (check_hit(125)) |
|---|
| 300 |
{ |
|---|
| 301 |
msg_print("A small dart hits you!"); |
|---|
| 302 |
dam = damroll(1, 4); |
|---|
| 303 |
take_hit(dam, name); |
|---|
| 304 |
(void)do_dec_stat(A_STR, FALSE); |
|---|
| 305 |
} |
|---|
| 306 |
else |
|---|
| 307 |
{ |
|---|
| 308 |
msg_print("A small dart barely misses you."); |
|---|
| 309 |
} |
|---|
| 310 |
break; |
|---|
| 311 |
} |
|---|
| 312 |
|
|---|
| 313 |
case FEAT_TRAP_HEAD + 0x0A: |
|---|
| 314 |
{ |
|---|
| 315 |
if (check_hit(125)) |
|---|
| 316 |
{ |
|---|
| 317 |
msg_print("A small dart hits you!"); |
|---|
| 318 |
dam = damroll(1, 4); |
|---|
| 319 |
take_hit(dam, name); |
|---|
| 320 |
(void)do_dec_stat(A_DEX, FALSE); |
|---|
| 321 |
} |
|---|
| 322 |
else |
|---|
| 323 |
{ |
|---|
| 324 |
msg_print("A small dart barely misses you."); |
|---|
| 325 |
} |
|---|
| 326 |
break; |
|---|
| 327 |
} |
|---|
| 328 |
|
|---|
| 329 |
case FEAT_TRAP_HEAD + 0x0B: |
|---|
| 330 |
{ |
|---|
| 331 |
if (check_hit(125)) |
|---|
| 332 |
{ |
|---|
| 333 |
msg_print("A small dart hits you!"); |
|---|
| 334 |
dam = damroll(1, 4); |
|---|
| 335 |
take_hit(dam, name); |
|---|
| 336 |
(void)do_dec_stat(A_CON, FALSE); |
|---|
| 337 |
} |
|---|
| 338 |
else |
|---|
| 339 |
{ |
|---|
| 340 |
msg_print("A small dart barely misses you."); |
|---|
| 341 |
} |
|---|
| 342 |
break; |
|---|
| 343 |
} |
|---|
| 344 |
|
|---|
| 345 |
case FEAT_TRAP_HEAD + 0x0C: |
|---|
| 346 |
{ |
|---|
| 347 |
msg_print("You are surrounded by a black gas!"); |
|---|
| 348 |
if (!p_ptr->resist_blind) |
|---|
| 349 |
{ |
|---|
| 350 |
(void)inc_timed(TMD_BLIND, randint0(50) + 25); |
|---|
| 351 |
} |
|---|
| 352 |
break; |
|---|
| 353 |
} |
|---|
| 354 |
|
|---|
| 355 |
case FEAT_TRAP_HEAD + 0x0D: |
|---|
| 356 |
{ |
|---|
| 357 |
msg_print("You are surrounded by a gas of scintillating colors!"); |
|---|
| 358 |
if (!p_ptr->resist_confu) |
|---|
| 359 |
{ |
|---|
| 360 |
(void)inc_timed(TMD_CONFUSED, randint0(20) + 10); |
|---|
| 361 |
} |
|---|
| 362 |
break; |
|---|
| 363 |
} |
|---|
| 364 |
|
|---|
| 365 |
case FEAT_TRAP_HEAD + 0x0E: |
|---|
| 366 |
{ |
|---|
| 367 |
msg_print("You are surrounded by a pungent green gas!"); |
|---|
| 368 |
if (!p_ptr->resist_pois && !p_ptr->timed[TMD_OPP_POIS]) |
|---|
| 369 |
{ |
|---|
| 370 |
(void)inc_timed(TMD_POISONED, randint0(20) + 10); |
|---|
| 371 |
} |
|---|
| 372 |
break; |
|---|
| 373 |
} |
|---|
| 374 |
|
|---|
| 375 |
case FEAT_TRAP_HEAD + 0x0F: |
|---|
| 376 |
{ |
|---|
| 377 |
msg_print("You are surrounded by a strange white mist!"); |
|---|
| 378 |
if (!p_ptr->free_act) |
|---|
| 379 |
{ |
|---|
| 380 |
(void)inc_timed(TMD_PARALYZED, randint0(10) + 5); |
|---|
| 381 |
} |
|---|
| 382 |
break; |
|---|
| 383 |
} |
|---|
| 384 |
} |
|---|
| 385 |
} |
|---|