PageRenderTime 61ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 1ms

/src/spells2.c

https://github.com/NickMcConnell/Beleriand
C | 5718 lines | 3076 code | 1215 blank | 1427 comment | 827 complexity | 6d694e94c9c09f28d257dafde9823057 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /** \file spells2.c
  2. \brief Spells
  3. * Healing spells, glyphs of warding, reducing or sustaining a stat, ID
  4. * everything, chance for enchant spells to fail, remove curses, regain
  5. * exp, detection spells, create stairs. Definitions of armour & weapons,
  6. * enchantment, branding, temporary branding, cursing, and ID code, what
  7. * items are rechargable and the recharging code. Various special object
  8. * spells. Spells that effect an area or LOS, lighten & darken rooms and
  9. * areas, casting ball, projection, beam, and bolt spells. Some miscel-
  10. * lanious non-damage spell functions.
  11. *
  12. * Copyright (c) 2009 Nick McConnell, Leon Marrick & Bahman Rabii,
  13. * Ben Harrison, James E. Wilson, Robert A. Koeneke
  14. *
  15. * This work is free software; you can redistribute it and/or modify it
  16. * under the terms of either:
  17. *
  18. * a) the GNU General Public License as published by the Free Software
  19. * Foundation, version 2, or
  20. *
  21. * b) the "Angband licence":
  22. * This software may be copied and distributed for educational, research,
  23. * and not for profit purposes provided that this copyright and statement
  24. * are included in all such copies. Other copyrights may also apply.
  25. */
  26. #include "angband.h"
  27. #include "cave.h"
  28. #include "history.h"
  29. #include "generate.h"
  30. #include "monster.h"
  31. #include "player.h"
  32. #include "spells.h"
  33. #include "squelch.h"
  34. #include "target.h"
  35. #include "trap.h"
  36. #include "ui-menu.h"
  37. /* Element to be proofed against in element-proofing */
  38. static bitflag el_to_proof[OF_SIZE];
  39. /**
  40. * Alter player's shape. Taken from Sangband.
  41. */
  42. void shapechange(s16b shape)
  43. {
  44. char *shapedesc = "";
  45. bool landing = FALSE;
  46. /* Were we flying? */
  47. landing = ((p_ptr->schange == SHAPE_BAT)
  48. || (p_ptr->schange == SHAPE_WYRM));
  49. /* Wonder Twin powers -- Activate! */
  50. p_ptr->schange = (byte) shape;
  51. p_ptr->update |= PU_BONUS;
  52. switch (shape) {
  53. case SHAPE_MOUSE:
  54. shapedesc = "mouse";
  55. break;
  56. case SHAPE_FERRET:
  57. shapedesc = "ferret";
  58. break;
  59. case SHAPE_HOUND:
  60. shapedesc = "hound";
  61. break;
  62. case SHAPE_GAZELLE:
  63. shapedesc = "gazelle";
  64. break;
  65. case SHAPE_LION:
  66. shapedesc = "lion";
  67. break;
  68. case SHAPE_ENT:
  69. shapedesc = "elder ent";
  70. break;
  71. case SHAPE_BAT:
  72. shapedesc = "bat";
  73. break;
  74. case SHAPE_WEREWOLF:
  75. shapedesc = "werewolf";
  76. break;
  77. case SHAPE_VAMPIRE:
  78. if ((chunk_list[p_ptr->stage].z_pos == 0)
  79. && ((turn % (10L * TOWN_DAWN)) < ((10L * TOWN_DAWN) / 2))) {
  80. msg("The sunlight prevents your shapechange!");
  81. shape = SHAPE_NORMAL;
  82. p_ptr->schange = (byte) shape;
  83. break;
  84. }
  85. shapedesc = "vampire";
  86. break;
  87. case SHAPE_WYRM:
  88. shapedesc = "dragon";
  89. break;
  90. case SHAPE_BEAR:
  91. shapedesc = "bear";
  92. break;
  93. default:
  94. msg("You return to your normal form.");
  95. break;
  96. }
  97. if (shape) {
  98. msg("You assume the form of a %s.", shapedesc);
  99. msg("Your equipment merges into your body.");
  100. }
  101. /* Recalculate mana. */
  102. p_ptr->update |= (PU_MANA);
  103. /* Show or hide shapechange on main window. */
  104. p_ptr->redraw |= (PR_SHAPE);
  105. if (landing) {
  106. int y = p_ptr->py, x = p_ptr->px;
  107. feature_type *f_ptr = &f_info[cave_feat[y][x]];
  108. if (tf_has(f_ptr->flags, TF_FALL))
  109. fall_off_cliff(0);
  110. else if (cave_invisible_trap(y, x)) {
  111. /* Disturb */
  112. disturb(0, 0);
  113. /* Hit the trap. */
  114. hit_trap(y, x);
  115. }
  116. /* Set off a visible trap */
  117. else if (cave_visible_trap(y, x)) {
  118. /* Disturb */
  119. disturb(0, 0);
  120. /* Hit the floor trap. */
  121. hit_trap(y, x);
  122. }
  123. }
  124. }
  125. /**
  126. * Type for choosing an elemental attack
  127. */
  128. typedef struct ele_attack_type {
  129. char *desc;
  130. u32b type;
  131. } ele_attack_type;
  132. static ele_attack_type ele_attack[] = {
  133. {"Fire Brand", ATTACK_FIRE},
  134. {"Cold Brand", ATTACK_COLD},
  135. {"Acid Brand", ATTACK_ACID},
  136. {"Elec Brand", ATTACK_ELEC}
  137. };
  138. char el_tag(menu_type * menu, int oid)
  139. {
  140. return I2A(oid);
  141. }
  142. /**
  143. * Display an entry on the sval menu
  144. */
  145. void el_display(menu_type * menu, int oid, bool cursor, int row, int col,
  146. int width)
  147. {
  148. const u16b *choice = menu->menu_data;
  149. int idx = choice[oid];
  150. byte attr = (cursor ? TERM_L_BLUE : TERM_WHITE);
  151. /* Print it */
  152. c_put_str(attr, format("%s", ele_attack[idx].desc), row, col);
  153. }
  154. /**
  155. * Deal with events on the sval menu
  156. */
  157. bool el_action(menu_type * menu, const ui_event * e, int oid)
  158. {
  159. u16b *choice = menu->menu_data;
  160. /* Choose */
  161. if (e->type == EVT_SELECT) {
  162. int idx = choice[oid];
  163. set_ele_attack(ele_attack[idx].type, 200);
  164. return FALSE;
  165. }
  166. else if (e->type == EVT_ESCAPE)
  167. return FALSE;
  168. else {
  169. int idx = choice[oid];
  170. set_ele_attack(ele_attack[idx].type, 200);
  171. return FALSE;
  172. }
  173. return FALSE;
  174. }
  175. /**
  176. * Display list of svals to be squelched.
  177. */
  178. bool el_menu(void)
  179. {
  180. menu_type menu;
  181. menu_iter menu_f = { el_tag, 0, el_display, el_action, 0 };
  182. region area = { 15, 1, 48, -1 };
  183. ui_event evt = { 0 };
  184. int cursor = 0;
  185. int num = 0;
  186. int i;
  187. u16b *choice;
  188. /* See how many attacks available */
  189. num = (p_ptr->lev - 20) / 7;
  190. /* Create the array */
  191. choice = C_ZNEW(num, u16b);
  192. /* Obvious */
  193. for (i = 0; i < num; i++) {
  194. /* Add this item to our possibles list */
  195. choice[i] = i;
  196. }
  197. /* Clear space */
  198. area.page_rows = num + 2;
  199. /* Return here if there are no attacks */
  200. if (!num) {
  201. FREE(choice);
  202. return FALSE;
  203. }
  204. /* Save the screen and clear it */
  205. screen_save();
  206. /* Help text */
  207. /* Set up the menu */
  208. WIPE(&menu, menu);
  209. menu_init(&menu, MN_SKIN_SCROLL, &menu_f);
  210. menu.title = "Choose a temporary elemental brand";
  211. menu_setpriv(&menu, num, choice);
  212. menu_layout(&menu, &area);
  213. /* Select an entry */
  214. evt = menu_select(&menu, cursor, TRUE);
  215. /* Free memory */
  216. FREE(choice);
  217. /* Load screen */
  218. screen_load();
  219. return (evt.type != EVT_ESCAPE);
  220. }
  221. /**
  222. * Choose a paladin elemental attack. -LM-
  223. */
  224. bool choose_ele_attack(void)
  225. {
  226. bool brand = FALSE;
  227. /* Save screen */
  228. screen_save();
  229. /* Choose */
  230. if (!el_menu())
  231. msg("You cancel the temporary branding.");
  232. else
  233. brand = TRUE;
  234. /* Load screen */
  235. screen_load();
  236. return brand;
  237. }
  238. /**
  239. * Array of elemental resistances
  240. */
  241. const char *ele_resist[] = {
  242. "Fire Resistance",
  243. "Cold Resistance",
  244. "Acid Resistance",
  245. "Electricity Resistance",
  246. "Poison Resistance"
  247. };
  248. char res_tag(menu_type * menu, int oid)
  249. {
  250. return I2A(oid);
  251. }
  252. /**
  253. * Display an entry on the sval menu
  254. */
  255. void res_display(menu_type * menu, int oid, bool cursor, int row, int col,
  256. int width)
  257. {
  258. const u16b *choice = menu->menu_data;
  259. int idx = choice[oid];
  260. byte attr = (cursor ? TERM_L_BLUE : TERM_WHITE);
  261. /* Print it */
  262. c_put_str(attr, format("%s", ele_resist[idx]), row, col);
  263. }
  264. /**
  265. * Deal with events on the sval menu
  266. */
  267. bool res_action(menu_type * menu, const ui_event * e, int oid)
  268. {
  269. u16b *choice = menu->menu_data;
  270. int plev = p_ptr->lev;
  271. /* Choose */
  272. if (e->type == EVT_ESCAPE)
  273. return FALSE;
  274. switch (choice[oid]) {
  275. case 0:
  276. {
  277. (void) inc_timed(TMD_OPP_FIRE, randint1(plev) + plev, TRUE);
  278. return FALSE;
  279. }
  280. case 1:
  281. {
  282. (void) inc_timed(TMD_OPP_COLD, randint1(plev) + plev, TRUE);
  283. return FALSE;
  284. }
  285. case 2:
  286. {
  287. (void) inc_timed(TMD_OPP_ACID, randint1(plev) + plev, TRUE);
  288. return FALSE;
  289. }
  290. case 3:
  291. {
  292. (void) inc_timed(TMD_OPP_ELEC, randint1(plev) + plev, TRUE);
  293. return FALSE;
  294. }
  295. case 4:
  296. {
  297. (void) inc_timed(TMD_OPP_POIS, randint1(plev) + plev, TRUE);
  298. return FALSE;
  299. }
  300. default:
  301. {
  302. return TRUE;
  303. }
  304. }
  305. }
  306. /**
  307. * Display list of svals to be squelched.
  308. */
  309. bool res_menu(void)
  310. {
  311. menu_type menu;
  312. menu_iter menu_f = { res_tag, 0, res_display, res_action, 0 };
  313. region area = { 15, 1, 48, 7 };
  314. ui_event evt = { 0 };
  315. int cursor = 0;
  316. size_t i;
  317. u16b *choice;
  318. /* Create the array */
  319. choice = C_ZNEW(5, u16b);
  320. /* Obvious */
  321. for (i = 0; i < 5; i++) {
  322. /* Add this item to our possibles list */
  323. choice[i] = i;
  324. }
  325. /* Save the screen and clear it */
  326. screen_save();
  327. /* Help text */
  328. /* Set up the menu */
  329. WIPE(&menu, menu);
  330. menu_init(&menu, MN_SKIN_SCROLL, &menu_f);
  331. menu.title = "Choose a temporary resistance";
  332. menu_setpriv(&menu, 5, choice);
  333. menu_layout(&menu, &area);
  334. /* Select an entry */
  335. evt = menu_select(&menu, cursor, TRUE);
  336. /* Free memory */
  337. FREE(choice);
  338. /* Load screen */
  339. screen_load();
  340. return (evt.type != EVT_ESCAPE);
  341. }
  342. /**
  343. * Choose an elemental resistance
  344. */
  345. extern bool choose_ele_resist(void)
  346. {
  347. bool resist = FALSE;
  348. /* Save screen */
  349. screen_save();
  350. /* Choose */
  351. if (!res_menu())
  352. msg("You cancel the temporary resistance.");
  353. else
  354. resist = TRUE;
  355. /* Load screen */
  356. screen_load();
  357. return resist;
  358. }
  359. /**
  360. * Hack -- The Athelas-creation code. -LM-
  361. */
  362. void create_athelas(void)
  363. {
  364. int py = p_ptr->py;
  365. int px = p_ptr->px;
  366. object_type *i_ptr;
  367. object_type object_type_body;
  368. /* Get local object */
  369. i_ptr = &object_type_body;
  370. /* Hack -- Make some Athelas, identify it, and drop it near the player. */
  371. object_prep(i_ptr, lookup_kind(TV_FOOD, SV_FOOD_ATHELAS), MINIMISE);
  372. /* Prevent money-making. */
  373. i_ptr->discount = 80;
  374. object_aware(i_ptr);
  375. object_known(i_ptr);
  376. drop_near(i_ptr, -1, py, px, TRUE);
  377. }
  378. /**
  379. * Controlled teleportation. -LM-
  380. * Idea from PsiAngband, through Zangband.
  381. */
  382. void dimen_door(void)
  383. {
  384. s16b ny;
  385. s16b nx;
  386. bool okay;
  387. okay = target_set_interactive(TARGET_LOOK | TARGET_GRID, -1, -1);
  388. if (!okay)
  389. return;
  390. /* grab the target coords. */
  391. target_get(&nx, &ny);
  392. /* Test for empty floor, forbid vaults or too large a distance, and insure
  393. * that this spell is never certain. */
  394. if (!cave_empty_bold(ny, nx) || cave_has(cave_info[ny][nx], CAVE_ICKY)
  395. || (distance(ny, nx, p_ptr->py, p_ptr->px) > 25)
  396. || (randint0(p_ptr->lev) == 0)) {
  397. msg("You fail to exit the astral plane correctly!");
  398. p_ptr->energy -= 50;
  399. teleport_player(15, FALSE);
  400. handle_stuff(p_ptr);
  401. }
  402. /* Controlled teleport. */
  403. else
  404. teleport_player_to(ny, nx, TRUE);
  405. }
  406. /**
  407. * Rebalance Weapon. This is a rather powerful spell, because it can be
  408. * used with any non-artifact throwing weapon, including ego-items. It is
  409. * therefore high-level, and curses weapons on failure. Do not give Assas-
  410. * sins "Break Curse". -LM-
  411. */
  412. void rebalance_weapon(void)
  413. {
  414. object_type *o_ptr;
  415. char o_name[120];
  416. /* Select the wielded melee weapon */
  417. o_ptr = &p_ptr->inventory[INVEN_WIELD];
  418. /* Nothing to rebalance */
  419. if (!o_ptr->k_idx) {
  420. msg("You are not wielding any melee weapon.");
  421. return;
  422. }
  423. /* Artifacts not allowed. */
  424. if (o_ptr->name1) {
  425. msg("Artifacts cannot be rebalanced.");
  426. return;
  427. }
  428. /* Not a throwing weapon. */
  429. if (!of_has(o_ptr->flags_obj, OF_THROWING)) {
  430. msg("The melee weapon you are wielding is not designed for throwing.");
  431. return;
  432. }
  433. /* 20% chance to curse weapon. */
  434. else if (randint1(5) == 1) {
  435. /* Description */
  436. object_desc(o_name, sizeof(o_name), o_ptr, ODESC_BASE);
  437. /* Light curse and lower to_h and to_d by 2 to 5 each. */
  438. o_ptr->to_h -= (s16b) (2 + randint0(4));
  439. o_ptr->to_d -= (s16b) (2 + randint0(4));
  440. cf_on(o_ptr->flags_curse, FLAG_START + randint0(CF_MAX));
  441. /* Describe */
  442. msg("Oh no! A dreadful black aura surrounds your %s!", o_name);
  443. /* Recalculate bonuses */
  444. p_ptr->update |= (PU_BONUS);
  445. }
  446. /* Rebalance. */
  447. else {
  448. /* Grant perfect balance. */
  449. of_on(o_ptr->flags_obj, OF_PERFECT_BALANCE);
  450. /* Description */
  451. object_desc(o_name, sizeof(o_name), o_ptr, ODESC_BASE);
  452. /* Describe */
  453. msg("Your %s gleams steel blue!", o_name);
  454. /* Prevent money-making. */
  455. o_ptr->discount = 80;
  456. }
  457. }
  458. /*
  459. * Increase players hit points, notice effects
  460. */
  461. bool hp_player(int num)
  462. {
  463. /* Healing needed */
  464. if (p_ptr->chp < p_ptr->mhp) {
  465. /* Gain hitpoints */
  466. p_ptr->chp += num;
  467. /* Enforce maximum */
  468. if (p_ptr->chp >= p_ptr->mhp) {
  469. p_ptr->chp = p_ptr->mhp;
  470. p_ptr->chp_frac = 0;
  471. }
  472. /* Redraw */
  473. p_ptr->redraw |= (PR_HP);
  474. /* Heal 0-4 */
  475. if (num < 5) {
  476. msg("You feel a little better.");
  477. }
  478. /* Heal 5-14 */
  479. else if (num < 15) {
  480. msg("You feel better.");
  481. }
  482. /* Heal 15-34 */
  483. else if (num < 35) {
  484. msg("You feel much better.");
  485. }
  486. /* Heal 35+ */
  487. else {
  488. msg("You feel very good.");
  489. }
  490. /* Notice */
  491. return (TRUE);
  492. }
  493. /* Ignore */
  494. return (FALSE);
  495. }
  496. /**
  497. * Jam a closed door with a magical spike.
  498. * Code is taken from do_cmd_spike. -LM-
  499. */
  500. void magic_spiking(void)
  501. {
  502. int py = p_ptr->py;
  503. int px = p_ptr->px;
  504. int y, x, i, dir;
  505. feature_type *f_ptr;
  506. /* Get a direction (or abort) */
  507. if (!get_rep_dir(&dir))
  508. return;
  509. /* Get location */
  510. y = py + ddy[dir];
  511. x = px + ddx[dir];
  512. f_ptr = &f_info[cave_feat[y][x]];
  513. /* Verify legality */
  514. if (!do_cmd_spike_test(y, x))
  515. return;
  516. /* Monster */
  517. if (cave_m_idx[y][x] > 0) {
  518. /* Message */
  519. msg("There is a monster in the way!");
  520. /* Attack */
  521. if (py_attack(y, x, TRUE))
  522. return;
  523. }
  524. /* Go for it */
  525. else {
  526. /* Verify legality */
  527. if (!do_cmd_spike_test(y, x))
  528. return;
  529. /* Successful jamming */
  530. msg("You magically jam the door.");
  531. /* Successful jamming */
  532. msg("You jam the door with a spike.");
  533. /* Convert "locked" to "stuck" XXX XXX XXX */
  534. if (!tf_has(f_ptr->flags, TF_DOOR_JAMMED)) {
  535. cave_feat[y][x] += 0x08;
  536. }
  537. /* Add three magical spikes to the door. */
  538. for (i = 0; i < 3; i++) {
  539. if (cave_feat[y][x] != FEAT_DOOR_TAIL) {
  540. cave_feat[y][x] += 0x01;
  541. }
  542. }
  543. }
  544. }
  545. /**
  546. * Leave a rune
  547. */
  548. bool lay_rune(int type)
  549. {
  550. int py = p_ptr->py;
  551. int px = p_ptr->px;
  552. trap_kind *trap_ptr = &trap_info[type];
  553. bool takes_rune = tf_has(f_info[cave_feat[py][px]].flags, TF_RUNE);
  554. /* If we're standing on a rune of mana, we can add mana to it */
  555. if ((type == RUNE_MANA) && (cave_trap_specific(py, px, RUNE_MANA))) {
  556. /* Standard mana amount */
  557. int mana = 40;
  558. /* Already full? */
  559. if (mana_reserve >= MAX_MANA_RESERVE) {
  560. msg("The rune cannot hold more mana");
  561. return (FALSE);
  562. }
  563. /* Don't put in more than we have */
  564. if (p_ptr->csp < mana)
  565. mana = p_ptr->csp;
  566. /* Don't put in more than it will hold */
  567. mana_reserve += mana;
  568. if (mana_reserve > MAX_MANA_RESERVE)
  569. mana_reserve = MAX_MANA_RESERVE;
  570. return (TRUE);
  571. }
  572. /* Need appropriate terrain and no monster */
  573. if (!takes_rune || cave_m_idx[py][px] > 0) {
  574. msg("You cannot lay a rune here.");
  575. return (FALSE);
  576. }
  577. #if 0
  578. /* Scan all objects in the grid */
  579. for (this_o_idx = cave_o_idx[py][px]; this_o_idx;
  580. this_o_idx = next_o_idx) {
  581. /* Acquire object */
  582. o_ptr = &o_list[this_o_idx];
  583. /* Acquire next object */
  584. next_o_idx = o_ptr->next_o_idx;
  585. /* Artifact */
  586. if (o_ptr->name1) {
  587. msg("There is an indestructible object here.");
  588. return (FALSE);
  589. }
  590. }
  591. /* Verify */
  592. if (cave_o_idx[py][px]) {
  593. if (!get_check("Destroy all items and lay a rune?"))
  594. return (FALSE);
  595. else {
  596. for (this_o_idx = cave_o_idx[py][px]; this_o_idx;
  597. this_o_idx = next_o_idx) {
  598. /* Acquire object */
  599. o_ptr = &o_list[this_o_idx];
  600. /* Acquire next object */
  601. next_o_idx = o_ptr->next_o_idx;
  602. /* Delete the object */
  603. delete_object_idx(this_o_idx);
  604. }
  605. /* Redraw */
  606. light_spot(py, px);
  607. }
  608. }
  609. #endif
  610. /* Limit total number of runes. */
  611. if (num_runes_on_level[type - 1] >= trap_ptr->max_num) {
  612. msg("You have reached the maximum number of runes of this type.");
  613. return (FALSE);
  614. }
  615. /* Create a rune */
  616. place_trap(py, px, type, 0);
  617. /* Increment the rune count. */
  618. num_runes_on_level[type - 1]++;
  619. /* Warning. */
  620. if (num_runes_on_level[type - 1] == trap_ptr->max_num) {
  621. msg("You have now reached your limit for runes of this type.");
  622. msg("In order to set more, remove some.");
  623. }
  624. return (TRUE);
  625. }
  626. /**
  627. * Array of stat "descriptions"
  628. */
  629. static const char *desc_stat_pos[] = {
  630. "strong",
  631. "smart",
  632. "wise",
  633. "dextrous",
  634. "healthy",
  635. "cute"
  636. };
  637. /**
  638. * Array of stat "descriptions"
  639. */
  640. static const char *desc_stat_neg[] = {
  641. "weak",
  642. "stupid",
  643. "naive",
  644. "clumsy",
  645. "sickly",
  646. "ugly"
  647. };
  648. /**
  649. * Lose a "point"
  650. */
  651. bool do_dec_stat(int stat)
  652. {
  653. bool sust = FALSE;
  654. bool clarity = (player_has(PF_CLARITY));
  655. bool athletics = (player_has(PF_ATHLETICS));
  656. /* Access the "sustain" and specialty skills */
  657. switch (stat) {
  658. case A_STR:
  659. if (p_ptr->state.sustain_str)
  660. sust = TRUE;
  661. break;
  662. case A_INT:
  663. if ((p_ptr->state.sustain_int) || (clarity && (randint0(2) != 0)))
  664. sust = TRUE;
  665. break;
  666. case A_WIS:
  667. if ((p_ptr->state.sustain_wis) || (clarity && (randint0(2) != 0)))
  668. sust = TRUE;
  669. break;
  670. case A_DEX:
  671. if ((p_ptr->state.sustain_dex)
  672. || (athletics && (randint0(2) != 0)))
  673. sust = TRUE;
  674. break;
  675. case A_CON:
  676. if ((p_ptr->state.sustain_con)
  677. || (athletics && (randint0(2) != 0)))
  678. sust = TRUE;
  679. break;
  680. case A_CHR:
  681. if (p_ptr->state.sustain_chr)
  682. sust = TRUE;
  683. break;
  684. }
  685. /* Sustain */
  686. if (sust) {
  687. /* Message */
  688. msg("You feel very %s for a moment, but the feeling passes.",
  689. desc_stat_neg[stat]);
  690. /* Notice effect */
  691. notice_obj(OBJECT_RAND_BASE_SUSTAIN + stat, 0);
  692. return (TRUE);
  693. }
  694. /* Attempt to reduce the stat */
  695. if (dec_stat(stat, 10, FALSE)) {
  696. /* Message */
  697. msg("You feel very %s.", desc_stat_neg[stat]);
  698. /* Notice effect */
  699. return (TRUE);
  700. }
  701. /* Nothing obvious */
  702. return (FALSE);
  703. }
  704. /**
  705. * Restore lost "points" in a stat
  706. */
  707. bool do_res_stat(int stat)
  708. {
  709. /* Attempt to increase */
  710. if (res_stat(stat)) {
  711. /* Message */
  712. msg("You feel less %s.", desc_stat_neg[stat]);
  713. /* Notice */
  714. return (TRUE);
  715. }
  716. /* Nothing obvious */
  717. return (FALSE);
  718. }
  719. /**
  720. * Gain a "point" in a stat
  721. */
  722. bool do_inc_stat(int stat, bool star)
  723. {
  724. bool res;
  725. /* Restore stst */
  726. res = res_stat(stat);
  727. /* Attempt to increase */
  728. if (inc_stat(stat, star)) {
  729. /* Message */
  730. msg("You feel very %s!", desc_stat_pos[stat]);
  731. /* Notice */
  732. return (TRUE);
  733. }
  734. /* Restoration worked */
  735. if (res) {
  736. /* Message */
  737. msg("You feel less %s.", desc_stat_neg[stat]);
  738. /* Notice */
  739. return (TRUE);
  740. }
  741. /* Nothing obvious */
  742. return (FALSE);
  743. }
  744. void identify_object(object_type * o_ptr)
  745. {
  746. object_kind *k_ptr;
  747. bool was_dubious = FALSE;
  748. /* Get the object kind. */
  749. k_ptr = &k_info[o_ptr->k_idx];
  750. /* See what we thought of it before */
  751. if ((o_ptr->feel == FEEL_PERILOUS)
  752. || (o_ptr->feel == FEEL_DUBIOUS_WEAK)
  753. || (o_ptr->feel == FEEL_DUBIOUS_STRONG))
  754. was_dubious = TRUE;
  755. /* Identify it fully */
  756. object_aware(o_ptr);
  757. object_known(o_ptr);
  758. /* Now we know about any ego-item type */
  759. if (o_ptr->name2)
  760. e_info[o_ptr->name2].everseen = TRUE;
  761. /* Check for known curses */
  762. if ((of_has(o_ptr->flags_obj, OF_SHOW_CURSE))
  763. || (artifact_p(o_ptr) && (o_ptr->name1 < ART_MIN_RANDOM))) {
  764. cf_copy(o_ptr->id_curse, o_ptr->flags_curse);
  765. o_ptr->ident |= IDENT_KNOW_CURSES;
  766. if (!cf_is_empty(o_ptr->flags_curse))
  767. o_ptr->ident |= IDENT_CURSED;
  768. else
  769. o_ptr->ident |= IDENT_UNCURSED;
  770. }
  771. /* If it seemed dubious but has no identifiable negatives, it's cursed */
  772. if (!item_dubious(o_ptr, FALSE) && was_dubious)
  773. o_ptr->ident |= IDENT_CURSED;
  774. /* Log artifacts to the history list. */
  775. if (artifact_p(o_ptr))
  776. history_add_artifact(o_ptr->name1, TRUE, TRUE);
  777. /* If the object is flavored, also make all items of that type, except for
  778. * variable rings and amulets, fully known. */
  779. if (k_ptr->flavor) {
  780. if ((o_ptr->tval == TV_FOOD) || (o_ptr->tval == TV_STAFF)
  781. || (o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
  782. k_ptr->known_effect = TRUE;
  783. }
  784. /* Set squelch flag as appropriate */
  785. p_ptr->notice |= PN_SQUELCH;
  786. }
  787. /**
  788. * Identify everything being carried.
  789. * Done by a potion of "*Enlightenment*".
  790. */
  791. void identify_pack(void)
  792. {
  793. int i;
  794. /* Simply identify and know every item */
  795. for (i = 0; i < INVEN_TOTAL; i++) {
  796. object_type *o_ptr = &p_ptr->inventory[i];
  797. /* Skip non-objects */
  798. if (!o_ptr->k_idx)
  799. continue;
  800. /* Identify it */
  801. identify_object(o_ptr);
  802. }
  803. /* Recalculate bonuses */
  804. p_ptr->update |= (PU_BONUS);
  805. /* Combine / Reorder the pack (later) */
  806. p_ptr->notice |= (PN_COMBINE | PN_REORDER | PN_SORT_QUIVER);
  807. /* Redraw stuff */
  808. p_ptr->redraw |= (PR_INVEN | PR_EQUIP);
  809. }
  810. /**
  811. * Used by the "enchant" function (chance of failure)
  812. */
  813. static int enchant_table[16] = {
  814. 0, 10, 50, 100, 200,
  815. 300, 400, 500, 700, 950,
  816. 990, 992, 995, 997, 999,
  817. 1000
  818. };
  819. static bool item_tester_cursed(const object_type * o_ptr)
  820. {
  821. if (known_cursed_p(o_ptr)
  822. && !(of_has(o_ptr->flags_obj, OF_PERMA_CURSE)))
  823. return TRUE;
  824. else
  825. return FALSE;
  826. }
  827. /**
  828. * Attempts to remove curses from items in inventory
  829. *
  830. * Note that Items which are "Perma-Cursed"
  831. * can NEVER be uncursed.
  832. *
  833. * If good is TRUE, there is a better chance of removal. Using this spell
  834. * once makes an item fragile, which means it is likely to be destroyed on
  835. * a second attempt.
  836. */
  837. static bool remove_curse_aux(int good)
  838. {
  839. int i, item, slot;
  840. object_type *o_ptr;
  841. char o_name[120];
  842. const char *q, *s;
  843. bitflag curses[CF_SIZE];
  844. int destroy_chance = 50;
  845. int uncurse_chance = 50;
  846. bool heavy = FALSE;
  847. int feel;
  848. cf_wipe(curses);
  849. /* Only cursed items */
  850. item_tester_hook = item_tester_cursed;
  851. /* Don't restrict choices */
  852. item_tester_tval = 0;
  853. /* Get an item. */
  854. q = "Attempt to uncurse which item? ";
  855. s = "You have no curses which can be removed.";
  856. if (!get_item
  857. (&item, q, s, CMD_NULL, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
  858. return (FALSE);
  859. /* Get the item (in the pack) */
  860. if (item >= 0) {
  861. o_ptr = &p_ptr->inventory[item];
  862. }
  863. /* Get the item (on the floor) */
  864. else {
  865. o_ptr = &o_list[0 - item];
  866. }
  867. /* Artifacts are harder to uncurse and destroy */
  868. if (artifact_p(o_ptr)) {
  869. destroy_chance -= 25;
  870. uncurse_chance -= 25;
  871. }
  872. /* Try every curse, even unknown ones */
  873. for (i = cf_next(o_ptr->flags_curse, FLAG_START); i != FLAG_END;
  874. i = cf_next(o_ptr->flags_curse, i + 1))
  875. if (cf_has(o_ptr->flags_curse, i)) {
  876. /* If fragile, bad things can happen */
  877. if ((of_has(o_ptr->flags_obj, OF_FRAGILE))
  878. && (randint0(100) < destroy_chance - (good ? 10 : 0))) {
  879. /* Message */
  880. msg("There is a bang and a flash!");
  881. /* Damage */
  882. take_hit(damroll(5, 5), "Failed uncursing");
  883. /* Gone */
  884. if (item >= 0) {
  885. inven_item_increase(item, -1);
  886. inven_item_describe(item);
  887. inven_item_optimize(item);
  888. } else {
  889. floor_item_increase(0 - item, -1);
  890. floor_item_describe(0 - item);
  891. floor_item_optimize(0 - item);
  892. }
  893. return (TRUE);
  894. }
  895. /* Try once */
  896. if (randint0(100) < uncurse_chance)
  897. cf_on(curses, i);
  898. /* If good, try again */
  899. if (good && (randint0(100) < uncurse_chance))
  900. cf_on(curses, i);
  901. }
  902. /* Uncurse it */
  903. cf_negate(curses);
  904. cf_inter(o_ptr->flags_curse, curses);
  905. cf_inter(o_ptr->id_curse, curses);
  906. /* May not be cursed any more */
  907. if (cf_is_empty(o_ptr->id_curse))
  908. o_ptr->ident &= ~(IDENT_CURSED);
  909. /* Fragile now */
  910. of_on(o_ptr->flags_obj, OF_FRAGILE);
  911. of_on(o_ptr->id_obj, OF_FRAGILE);
  912. /* Known objects get free curse notification now */
  913. if (object_known_p(o_ptr)) {
  914. if (!cf_is_empty(o_ptr->flags_curse))
  915. o_ptr->ident |= IDENT_CURSED;
  916. else
  917. o_ptr->ident |= (IDENT_UNCURSED | IDENT_KNOW_CURSES);
  918. }
  919. /* Redo feeling if it's not known */
  920. else {
  921. /* Heavy sensing */
  922. heavy = (player_has(PF_PSEUDO_ID_HEAVY));
  923. /* Type of feeling */
  924. feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr));
  925. /* Check the slot */
  926. slot = wield_slot(o_ptr);
  927. /* Redo feeling */
  928. if (!(o_ptr->feel == feel)) {
  929. /* Get an object description */
  930. object_desc(o_name, sizeof(o_name), o_ptr, ODESC_BASE);
  931. msg("You feel the %s (%c) you are %s %s now %s...", o_name,
  932. index_to_label(slot), describe_use(slot),
  933. ((o_ptr->number == 1) ? "is" : "are"), feel_text[feel]);
  934. /* We have "felt" it */
  935. o_ptr->ident |= (IDENT_SENSE);
  936. /* Inscribe it textually */
  937. o_ptr->feel = feel;
  938. /* Set squelch flag as appropriate */
  939. p_ptr->notice |= PN_SQUELCH;
  940. }
  941. }
  942. /* Recalculate the bonuses */
  943. p_ptr->update |= (PU_BONUS);
  944. /* Redraw stuff */
  945. p_ptr->redraw |= (PR_EQUIP | PR_INVEN);
  946. /* Something uncursed */
  947. if (cf_is_empty(curses))
  948. msg("You feel as if someone is watching over you.");
  949. /* Return scroll used/spell cast */
  950. return (TRUE);
  951. }
  952. /**
  953. * Remove most curses
  954. */
  955. bool remove_curse(void)
  956. {
  957. return (remove_curse_aux(FALSE));
  958. }
  959. /**
  960. * Remove all curses
  961. */
  962. bool remove_curse_good(void)
  963. {
  964. return (remove_curse_aux(TRUE));
  965. }
  966. /**
  967. * Restores any drained experience
  968. */
  969. bool restore_level(void)
  970. {
  971. /* Restore experience */
  972. if (p_ptr->exp < p_ptr->max_exp) {
  973. /* Message */
  974. msg("You feel your life energies returning.");
  975. /* Restore the experience */
  976. p_ptr->exp = p_ptr->max_exp;
  977. /* Check the experience */
  978. check_experience();
  979. /* Did something */
  980. return (TRUE);
  981. }
  982. /* No effect */
  983. return (FALSE);
  984. }
  985. /**
  986. * Forget everything
  987. */
  988. bool lose_all_info(void)
  989. {
  990. /* Mega-Hack -- Forget the map */
  991. wiz_dark();
  992. /* It worked */
  993. return (TRUE);
  994. }
  995. /**
  996. * Hack - displays areas effected by detection spells.
  997. *
  998. */
  999. static void animate_detect(int rad)
  1000. {
  1001. int py = p_ptr->py;
  1002. int px = p_ptr->px;
  1003. int x, y;
  1004. byte a, c;
  1005. int msec = op_ptr->delay_factor * op_ptr->delay_factor;
  1006. /* Exit if not desired */
  1007. if (!OPT(show_detect))
  1008. return;
  1009. /* Hack - Needs to last a bit longer to be visible */
  1010. msec *= 6;
  1011. /* Scan the maximal area of detection */
  1012. for (y = py - rad; y <= py + rad; y++) {
  1013. for (x = px - rad; x <= px + rad; x++) {
  1014. /* Ignore "illegal" locations */
  1015. if (!in_bounds(y, x))
  1016. continue;
  1017. /* Enforce a "circular" area */
  1018. if (distance(py, px, y, x) > rad)
  1019. continue;
  1020. /* Only show the region that the player can see */
  1021. if (panel_contains(y, x)) {
  1022. /* Hack - Obtain attr/char */
  1023. a = gf_to_attr[GF_DETECT][BOLT_NO_MOTION];
  1024. c = gf_to_char[GF_DETECT][BOLT_NO_MOTION];
  1025. /* Hack -- Visual effects -- Display a yellow star */
  1026. print_rel(c, a, y, x);
  1027. }
  1028. }
  1029. }
  1030. /* Flush the image of detected region */
  1031. Term_fresh();
  1032. if (p_ptr->redraw)
  1033. redraw_stuff(p_ptr);
  1034. /* Delay (efficiently) */
  1035. Term_xtra(TERM_XTRA_DELAY, msec);
  1036. /* Now erase the effect */
  1037. for (y = py - rad; y <= py + rad; y++) {
  1038. for (x = px - rad; x <= px + rad; x++) {
  1039. /* Ignore "illegal" locations */
  1040. if (!in_bounds(y, x))
  1041. continue;
  1042. /* Enforce a "circular" area */
  1043. if (distance(py, px, y, x) > rad)
  1044. continue;
  1045. /* Hack -- Erase only if needed */
  1046. if (panel_contains(y, x)) {
  1047. light_spot(y, x);
  1048. }
  1049. }
  1050. }
  1051. /* Hack -- center the cursor */
  1052. move_cursor_relative(py, px);
  1053. /* Flush screen back to normal */
  1054. Term_fresh();
  1055. if (p_ptr->redraw)
  1056. redraw_stuff(p_ptr);
  1057. /* Exit */
  1058. return;
  1059. }
  1060. /**
  1061. * Detect all traps within range
  1062. */
  1063. bool detect_traps(int range, bool show)
  1064. {
  1065. int y, x;
  1066. int py = p_ptr->py;
  1067. int px = p_ptr->px;
  1068. bool detect = FALSE;
  1069. /* Hack - flash the effected region on the current panel */
  1070. if (show)
  1071. animate_detect(range);
  1072. /* Scan the map */
  1073. for (y = 0; y < ARENA_HGT; y++) {
  1074. for (x = 0; x < ARENA_WID; x++) {
  1075. /* check range */
  1076. if (distance(py, px, y, x) <= range) {
  1077. /* Detect invisible traps */
  1078. if (cave_invisible_trap(y, x)) {
  1079. if (reveal_trap(y, x, 100, FALSE)) {
  1080. detect = TRUE;
  1081. }
  1082. }
  1083. /* Mark grid as detected */
  1084. cave_on(cave_info[y][x], CAVE_DTRAP);
  1085. }
  1086. }
  1087. }
  1088. /* Found some */
  1089. if (detect) {
  1090. /* Print success message */
  1091. msg("You detect traps.");
  1092. }
  1093. /* Redraw DTrap Status */
  1094. p_ptr->redraw |= (PR_DTRAP);
  1095. /* Result - trap detection items are easy to recognize for now -BR- */
  1096. return (TRUE);
  1097. }
  1098. /**
  1099. * Detect all doors within range
  1100. */
  1101. bool detect_doors(int range, bool show)
  1102. {
  1103. int y, x;
  1104. int py = p_ptr->py;
  1105. int px = p_ptr->px;
  1106. bool detect = FALSE;
  1107. int num = 0;
  1108. feature_type *f_ptr = NULL;
  1109. /* Hack - flash the effected region on the current panel */
  1110. if (show)
  1111. animate_detect(range);
  1112. /* Scan the map */
  1113. for (y = 0; y < ARENA_HGT; y++) {
  1114. for (x = 0; x < ARENA_WID; x++) {
  1115. /* check range */
  1116. if (distance(py, px, y, x) <= range) {
  1117. /* Detect secret doors */
  1118. if (cave_feat[y][x] == FEAT_SECRET) {
  1119. /* Pick a door */
  1120. place_closed_door(y, x);
  1121. }
  1122. /* Set the feature */
  1123. f_ptr = &f_info[cave_feat[y][x]];
  1124. /* Detect doors */
  1125. if (tf_has(f_ptr->flags, TF_DOOR_ANY)) {
  1126. /* Hack -- Memorize */
  1127. cave_on(cave_info[y][x], CAVE_MARK);
  1128. /* Redraw */
  1129. light_spot(y, x);
  1130. /* increment number found */
  1131. num++;
  1132. }
  1133. }
  1134. }
  1135. }
  1136. /* Found some */
  1137. if (num > 0) {
  1138. /* Obvious */
  1139. detect = TRUE;
  1140. /* Print success message */
  1141. msg("You detect doors.");
  1142. }
  1143. /* Result */
  1144. return (detect);
  1145. }
  1146. /**
  1147. * Detect all stairs within range
  1148. */
  1149. bool detect_stairs(int range, bool show)
  1150. {
  1151. int y, x;
  1152. int py = p_ptr->py;
  1153. int px = p_ptr->px;
  1154. int num = 0;
  1155. bool detect = FALSE;
  1156. /* Hack - flash the effected region on the current panel */
  1157. if (show)
  1158. animate_detect(range);
  1159. /* Scan the map */
  1160. for (y = 0; y < ARENA_HGT; y++) {
  1161. for (x = 0; x < ARENA_WID; x++) {
  1162. /* check range */
  1163. if (distance(py, px, y, x) <= range) {
  1164. feature_type *f_ptr = &f_info[cave_feat[y][x]];
  1165. /* Detect stairs */
  1166. if (tf_has(f_ptr->flags, TF_STAIR) ||
  1167. tf_has(f_ptr->flags, TF_PATH)) {
  1168. /* Hack -- Memorize */
  1169. cave_on(cave_info[y][x], CAVE_MARK);
  1170. /* Redraw */
  1171. light_spot(y, x);
  1172. /* increment number found */
  1173. num++;
  1174. }
  1175. }
  1176. }
  1177. }
  1178. /* Found some */
  1179. if (num > 0) {
  1180. /* Obvious */
  1181. detect = TRUE;
  1182. /* Print success message */
  1183. msg("You detect stairs.");
  1184. }
  1185. /* Result */
  1186. return (detect);
  1187. }
  1188. /**
  1189. * Detect any treasure within range
  1190. */
  1191. bool detect_treasure(int range, bool show)
  1192. {
  1193. int y, x;
  1194. int py = p_ptr->py;
  1195. int px = p_ptr->px;
  1196. bool detect = FALSE;
  1197. int num = 0;
  1198. /* Hack - flash the effected region on the current panel */
  1199. if (show)
  1200. animate_detect(range);
  1201. /* Scan the map */
  1202. for (y = 0; y < ARENA_HGT; y++) {
  1203. for (x = 0; x < ARENA_WID; x++) {
  1204. /* check range */
  1205. if (distance(py, px, y, x) <= range) {
  1206. /* Notice embedded gold */
  1207. if (cave_feat[y][x] == FEAT_MAGMA_H) {
  1208. /* Expose the gold */
  1209. cave_feat[y][x] = FEAT_MAGMA_K;
  1210. }
  1211. /* Notice embedded gold */
  1212. if (cave_feat[y][x] == FEAT_QUARTZ_H) {
  1213. /* Expose the gold */
  1214. cave_feat[y][x] = FEAT_QUARTZ_K;
  1215. }
  1216. /* Magma/Quartz + Known Gold */
  1217. if ((cave_feat[y][x] == FEAT_MAGMA_K)
  1218. || (cave_feat[y][x] == FEAT_QUARTZ_K)) {
  1219. /* Hack -- Memorize */
  1220. cave_on(cave_info[y][x], CAVE_MARK);
  1221. /* Redraw */
  1222. light_spot(y, x);
  1223. /* increment number found */
  1224. num++;
  1225. }
  1226. }
  1227. }
  1228. }
  1229. /* Found some */
  1230. if (num > 0) {
  1231. /* Obvious */
  1232. detect = TRUE;
  1233. /* Print success message */
  1234. msg("You detect buried treasure.");
  1235. }
  1236. /* Result */
  1237. return (detect);
  1238. }
  1239. /**
  1240. * Detect all "gold" objects within range
  1241. */
  1242. bool detect_objects_gold(int range, bool show)
  1243. {
  1244. int i, y, x;
  1245. int py = p_ptr->py;
  1246. int px = p_ptr->px;
  1247. int num = 0;
  1248. bool detect = FALSE;
  1249. /* Hack - flash the effected region on the current panel */
  1250. if (show)
  1251. animate_detect(range);
  1252. /* Scan objects */
  1253. for (i = 1; i < o_max; i++) {
  1254. object_type *o_ptr = &o_list[i];
  1255. /* Skip dead objects */
  1256. if (!o_ptr->k_idx)
  1257. continue;
  1258. /* Skip held objects */
  1259. if (o_ptr->held_m_idx)
  1260. continue;
  1261. /* Location */
  1262. y = o_ptr->iy;
  1263. x = o_ptr->ix;
  1264. /* check range */
  1265. if (distance(py, px, y, x) > range)
  1266. continue;
  1267. /* Detect "gold" objects */
  1268. if (o_ptr->tval == TV_GOLD) {
  1269. /* Hack -- memorize it */
  1270. o_ptr->marked = TRUE;
  1271. /* Redraw */
  1272. light_spot(y, x);
  1273. /* increment number found */
  1274. num++;
  1275. }
  1276. }
  1277. /* Found some */
  1278. if (num > 0) {
  1279. /* Obvious */
  1280. detect = TRUE;
  1281. msg("You detect treasure.");
  1282. }
  1283. /* Result */
  1284. return (detect);
  1285. }
  1286. /**
  1287. * Detect all "normal" objects within range
  1288. */
  1289. bool detect_objects_normal(int range, bool show)
  1290. {
  1291. int i, y, x;
  1292. int py = p_ptr->py;
  1293. int px = p_ptr->px;
  1294. int num = 0;
  1295. bool detect = FALSE;
  1296. /* Hack - flash the effected region on the current panel */
  1297. if (show)
  1298. animate_detect(range);
  1299. /* Scan objects */
  1300. for (i = 1; i < o_max; i++) {
  1301. object_type *o_ptr = &o_list[i];
  1302. /* Skip dead objects */
  1303. if (!o_ptr->k_idx)
  1304. continue;
  1305. /* Skip held objects */
  1306. if (o_ptr->held_m_idx)
  1307. continue;
  1308. /* Location */
  1309. y = o_ptr->iy;
  1310. x = o_ptr->ix;
  1311. /* check range */
  1312. if (distance(py, px, y, x) > range)
  1313. continue;
  1314. /* Detect "real" objects */
  1315. if (o_ptr->tval != TV_GOLD) {
  1316. /* Hack -- memorize it */
  1317. o_ptr->marked = TRUE;
  1318. /* Redraw */
  1319. light_spot(y, x);
  1320. /* increment number found */
  1321. if (!squelch_hide_item(o_ptr))
  1322. num++;
  1323. }
  1324. }
  1325. /* Found some */
  1326. if (num > 0) {
  1327. /* Obvious */
  1328. detect = TRUE;
  1329. /* Print success message */
  1330. msg("You detect objects.");
  1331. }
  1332. /* Result */
  1333. return (detect);
  1334. }
  1335. /**
  1336. * Detect all "magic" objects within range.
  1337. *
  1338. * This will light up all spaces with "magic" items, including artifacts,
  1339. * ego-items, potions, scrolls, books, rods, wands, staves, amulets, rings,
  1340. * and "enchanted" items of the "good" variety.
  1341. *
  1342. * It can probably be argued that this function is now too powerful.
  1343. */
  1344. bool detect_objects_magic(int range, bool show)
  1345. {
  1346. int i, y, x, tv;
  1347. int py = p_ptr->py;
  1348. int px = p_ptr->px;
  1349. bool detect = FALSE;
  1350. int num = 0;
  1351. /* Hack - flash the effected region on the current panel */
  1352. if (show)
  1353. animate_detect(range);
  1354. /* Scan all objects */
  1355. for (i = 1; i < o_max; i++) {
  1356. object_type *o_ptr = &o_list[i];
  1357. /* Skip dead objects */
  1358. if (!o_ptr->k_idx)
  1359. continue;
  1360. /* Skip held objects */
  1361. if (o_ptr->held_m_idx)
  1362. continue;
  1363. /* Location */
  1364. y = o_ptr->iy;
  1365. x = o_ptr->ix;
  1366. /* check range */
  1367. if (distance(py, px, y, x) > range)
  1368. continue;
  1369. /* Examine the tval */
  1370. tv = o_ptr->tval;
  1371. /* Artifacts, misc magic items, or enchanted wearables */
  1372. if (artifact_p(o_ptr) || ego_item_p(o_ptr) || (tv == TV_AMULET)
  1373. || (tv == TV_RING) || (tv == TV_STAFF) || (tv == TV_WAND)
  1374. || (tv == TV_ROD) || (tv == TV_SCROLL) || (tv == TV_POTION)
  1375. || (tv == TV_MAGIC_BOOK) || (tv == TV_PRAYER_BOOK)
  1376. || (tv == TV_DRUID_BOOK) || (tv == TV_NECRO_BOOK)
  1377. || ((o_ptr->to_a > 0) || (o_ptr->to_h + o_ptr->to_d > 0))) {
  1378. /* Memorize the item */
  1379. o_ptr->marked = TRUE;
  1380. /* Redraw */
  1381. light_spot(y, x);
  1382. /* increment number found */
  1383. if (!squelch_hide_item(o_ptr))
  1384. num++;
  1385. }
  1386. }
  1387. /* Found some */
  1388. if (num > 0) {
  1389. /* Obvious */
  1390. detect = TRUE;
  1391. /* Print success message */
  1392. msg("You detect magic objects.");
  1393. }
  1394. /* Return result */
  1395. return (detect);
  1396. }
  1397. /**
  1398. * Detect all "normal" monsters within range
  1399. */
  1400. bool detect_monsters_normal(int range, bool show)
  1401. {
  1402. int i, y, x;
  1403. int py = p_ptr->py;
  1404. int px = p_ptr->px;
  1405. bool flag = FALSE;
  1406. int num = 0;
  1407. int num_off = 0;
  1408. /* Hack - flash the effected region on the current panel */
  1409. if (show)
  1410. animate_detect(range);
  1411. /* Scan monsters */
  1412. for (i = 1; i < m_max; i++) {
  1413. monster_type *m_ptr = &m_list[i];
  1414. monster_race *r_ptr = &r_info[m_ptr->r_idx];
  1415. /* Skip dead monsters */
  1416. if (!m_ptr->r_idx)
  1417. continue;
  1418. /* Location */
  1419. y = m_ptr->fy;
  1420. x = m_ptr->fx;
  1421. /* check range */
  1422. if (distance(py, px, y, x) > range)
  1423. continue;
  1424. /* Detect all non-invisible monsters */
  1425. if (!(rf_has(r_ptr->flags, RF_INVISIBLE))) {
  1426. /* Optimize -- Repair flags */
  1427. repair_mflag_mark = repair_mflag_show = TRUE;
  1428. /* Hack -- Detect the monster */
  1429. m_ptr->mflag |= (MFLAG_MARK | MFLAG_SHOW);
  1430. /* Update the monster */
  1431. update_mon(i, FALSE);
  1432. /* increment number found */
  1433. num++;
  1434. /* increment number found offscreen */
  1435. if (!panel_contains(y, x))
  1436. num_off++;
  1437. }
  1438. }
  1439. /* Found some */
  1440. if (num > 0) {
  1441. /* Obvious */
  1442. flag = TRUE;
  1443. /* Print success message */
  1444. if (num_off > 0)
  1445. msg("You detect monsters (%i offscreen).", num_off);
  1446. else
  1447. msg("You detect monsters.");
  1448. }
  1449. /* Result */
  1450. return (flag);
  1451. }
  1452. /**
  1453. * Detect all "invisible" monsters within range
  1454. */
  1455. bool detect_monsters_invis(int range, bool show)
  1456. {
  1457. int i, y, x;
  1458. int py = p_ptr->py;
  1459. int px = p_ptr->px;
  1460. bool flag = FALSE;
  1461. int num = 0;
  1462. int num_off = 0;
  1463. /* Hack - flash the effected region on the current panel */
  1464. if (show)
  1465. animate_detect(range);
  1466. /* Scan monsters */
  1467. for (i = 1; i < m_max; i++) {
  1468. monster_type *m_ptr = &m_list[i];
  1469. monster_race *r_ptr = &r_info[m_ptr->r_idx];
  1470. monster_lore *l_ptr = &l_list[m_ptr->r_idx];
  1471. /* Skip dead monsters */
  1472. if (!m_ptr->r_idx)
  1473. continue;
  1474. /* Location */
  1475. y = m_ptr->fy;
  1476. x = m_ptr->fx;
  1477. /* check range */
  1478. if (distance(py, px, y, x) > range)
  1479. continue;
  1480. /* Detect invisible monsters */
  1481. if (rf_has(r_ptr->flags, RF_INVISIBLE)) {
  1482. /* Take note that they are invisible */
  1483. rf_on(l_ptr->flags, RF_INVISIBLE);
  1484. /* Update monster recall window */
  1485. if (p_ptr->monster_race_idx == m_ptr->r_idx) {
  1486. /* Redraw stuff */
  1487. p_ptr->redraw |= (PR_MONSTER);
  1488. }
  1489. /* Optimize -- Repair flags */
  1490. repair_mflag_mark = repair_mflag_show = TRUE;
  1491. /* Hack -- Detect the monster */
  1492. m_ptr->mflag |= (MFLAG_MARK | MFLAG_SHOW);
  1493. /* Update the monster */
  1494. update_mon(i, FALSE);
  1495. /* increment number found */
  1496. num++;
  1497. /* increment number found offscreen */
  1498. if (!panel_contains(y, x))
  1499. num_off++;
  1500. }
  1501. }
  1502. /* Found some */
  1503. if (num > 0) {
  1504. /* Obvious */
  1505. flag = TRUE;
  1506. /* Print success message */
  1507. if (num_off > 0)
  1508. msg("You detect invisible creatures (%i offscreen).", num_off);
  1509. else
  1510. msg("You detect invisible creatures.");
  1511. }
  1512. /* Result */
  1513. return (flag);
  1514. }
  1515. /**
  1516. * Detect all "evil" monsters within range
  1517. */
  1518. bool detect_monsters_evil(int range, bool show)
  1519. {
  1520. int i, y, x;
  1521. int py = p_ptr->py;
  1522. int px = p_ptr->px;
  1523. bool flag = FALSE;
  1524. int num = 0;
  1525. int num_off = 0;
  1526. /* Hack - flash the effected region on the current panel */
  1527. if (show)
  1528. animate_detect(range);
  1529. /* Scan monsters */
  1530. for (i = 1; i < m_max; i++) {
  1531. monster_type *m_ptr = &m_list[i];
  1532. monster_race *r_ptr = &r_info[m_ptr->r_idx];
  1533. monster_lore *l_ptr = &l_list[m_ptr->r_idx];
  1534. /* Skip dead monsters */
  1535. if (!m_ptr->r_idx)
  1536. continue;
  1537. /* Location */
  1538. y = m_ptr->fy;
  1539. x = m_ptr->fx;
  1540. /* check range */
  1541. if (distance(py, px, y, x) > range)
  1542. continue;
  1543. /* Detect evil monsters */
  1544. if (rf_has(r_ptr->flags, RF_EVIL)) {
  1545. /* Take note that they are evil */
  1546. rf_on(l_ptr->flags, RF_EVIL);
  1547. /* Update monster recall window */
  1548. if (p_ptr->monster_race_idx == m_ptr->r_idx) {
  1549. /* Redraw stuff */
  1550. p_ptr->redraw |= (PR_MONSTER);
  1551. }
  1552. /* Optimize -- Repair flags */
  1553. repair_mflag_mark = repair_mflag_show = TRUE;
  1554. /* Detect the monster */
  1555. m_ptr->mflag |= (MFLAG_MARK | MFLAG_SHOW);
  1556. /* Update the monster */
  1557. update_mon(i, FALSE);
  1558. /* increment number found */
  1559. num++;
  1560. /* increment number found offscreen */
  1561. if (!panel_contains(y, x))
  1562. num_off++;
  1563. }
  1564. }
  1565. /* Found some */
  1566. if (num > 0) {
  1567. /* Obvious */
  1568. flag = TRUE;
  1569. /* Print success message */
  1570. if (num_off > 0)
  1571. msg("You detect evil creatures (%i offscreen).", num_off);
  1572. else
  1573. msg("You detect evil creatures.");
  1574. }
  1575. /* Result */
  1576. return (flag);
  1577. }
  1578. /**
  1579. * Detect all "living" monsters within range.
  1580. */
  1581. bool detect_monsters_living(int range, bool show)
  1582. {
  1583. int i, y, x;
  1584. int py = p_ptr->py;
  1585. int px = p_ptr->px;
  1586. bool flag = FALSE;
  1587. int num = 0;
  1588. int num_off = 0;
  1589. /* Hack - flash the effected region on the current panel */
  1590. if (show)
  1591. animate_detect(range);
  1592. /* Scan monsters */
  1593. for (i = 1; i < m_max; i++) {
  1594. monster_type *m_ptr = &m_list[i];
  1595. monster_race *r_ptr = &r_info[m_ptr->r_idx];
  1596. /* Skip dead monsters */
  1597. if (!m_ptr->r_idx)
  1598. continue;
  1599. /* Location */
  1600. y = m_ptr->fy;
  1601. x = m_ptr->fx;
  1602. /* check range */
  1603. if (distance(py, px, y, x) > range)
  1604. continue;
  1605. /* Hack -- Detect all living monsters. */
  1606. if ((!strchr("Egv", r_ptr->d_char))
  1607. && (!(rf_has(r_ptr->flags, RF_UNDEAD)))) {
  1608. /* Optimize -- Repair flags */
  1609. repair_mflag_mark = repair_mflag_show = TRUE;
  1610. /* Hack -- Detect the monster */
  1611. m_ptr->mflag |= (MFLAG_MARK | MFLAG_SHOW);
  1612. /* Update the monster */
  1613. update_mon(i, FALSE);
  1614. /* increment number found */
  1615. num++;
  1616. /* increment number found offscreen */
  1617. if (!panel_contains(y, x))
  1618. num_off++;
  1619. }
  1620. }
  1621. /* Found some */
  1622. if (num > 0) {
  1623. /* Obvious */
  1624. flag = TRUE;
  1625. /* Print success message */
  1626. if (num_off > 0)
  1627. msg("You detect living creatures (%i offscreen).", num_off);
  1628. else
  1629. msg("You detect living creatures.");
  1630. }
  1631. /* Now detect trees */
  1632. num = 0;
  1633. /* Scan the maximal area of mapping */
  1634. for (y = py - range; y <= py + range; y++) {
  1635. for (x = px - range; x <= px + range; x++) {
  1636. feature_type *f_ptr = &f_info[cave_feat[y][x]];
  1637. /* Ignore "illegal" locations */
  1638. if (!in_bounds(y, x))
  1639. continue;
  1640. /* Enforce a "circular" area */
  1641. if (distance(py, px, y, x) > range)
  1642. continue;
  1643. /* Notice trees */
  1644. if (tf_has(f_ptr->flags, TF_TREE)) {
  1645. /* Mark it */
  1646. cave_on(cave_info[y][x], CAVE_MARK);
  1647. /* Count it */
  1648. num++;
  1649. }
  1650. }
  1651. }
  1652. /* Found some */
  1653. if (num > 0) {
  1654. flag = TRUE;
  1655. /* Print message */
  1656. msg("You detect trees.");
  1657. /* Update */
  1658. p_ptr->redraw |= PR_MAP;
  1659. redraw_stuff(p_ptr);
  1660. }
  1661. /* Result */
  1662. return (flag);
  1663. }
  1664. /**
  1665. * Detect everything
  1666. */
  1667. bool detect_all(int range, bool show)
  1668. {
  1669. bool detect = FALSE;
  1670. /* Hack - flash the effected region on the current panel */
  1671. if (show)
  1672. animate_detect(range);
  1673. /* Detect everything */
  1674. /* Do not 'show' the affected region for each detect individually */
  1675. if (detect_traps(range, FALSE))
  1676. detect = TRUE;
  1677. if (detect_doors(range, FALSE))
  1678. detect = TRUE;
  1679. if (detect_stairs(range, FALSE))
  1680. detect = TRUE;
  1681. if (detect_treasure(range, FALSE))
  1682. detect = TRUE;
  1683. if (detect_objects_gold(range, FALSE))
  1684. detect = TRUE;
  1685. if (detect_objects_normal(range, FALSE))
  1686. detect = TRUE;
  1687. if (detect_monsters_invis(range, FALSE))
  1688. detect = TRUE;
  1689. if (detect_monsters_normal(range, FALSE))
  1690. detect = TRUE;
  1691. /* Result */
  1692. return (detect);
  1693. }
  1694. /**
  1695. * Create stairs at the player location
  1696. */
  1697. void stair_creation(void)
  1698. {
  1699. int py = p_ptr->py;
  1700. int px = p_ptr->px;
  1701. /* XXX XXX XXX */
  1702. if (!cave_valid_bold(py, px)) {
  1703. msg("The object resists the spell.");
  1704. return;
  1705. }
  1706. /* Doesn't work outside caves */
  1707. if (chunk_list[p_ptr->stage].z_pos == 0) {
  1708. msg("You can only create stairs in caves!");
  1709. return;
  1710. }
  1711. /* XXX XXX XXX */
  1712. delete_object(py, px);
  1713. /* Create a staircase */
  1714. if (is_quest(p_ptr->stage) || (chunk_list[p_ptr->stage].z_pos == 127)) {
  1715. cave_set_feat(py, px, FEAT_LESS);
  1716. } else if (chunk_list[p_ptr->stage].z_pos == 0) {
  1717. cave_set_feat(py, px, FEAT_MORE);
  1718. } else if (randint0(100) < 50) {
  1719. cave_set_feat(py, px, FEAT_MORE);
  1720. } else {
  1721. cave_set_feat(py, px, FEAT_LESS);
  1722. }
  1723. }
  1724. /**
  1725. * Hook to specify "weapon"
  1726. */
  1727. static bool item_tester_hook_weapon(const object_type * o_ptr)
  1728. {
  1729. switch (o_ptr->tval) {
  1730. case TV_SWORD:
  1731. case TV_HAFTED:
  1732. case TV_POLEARM:
  1733. case TV_DIGGING:
  1734. case TV_BOW:
  1735. case TV_BOLT:
  1736. case TV_ARROW:
  1737. case TV_SHOT:
  1738. {
  1739. return (TRUE);
  1740. }
  1741. }
  1742. return (FALSE);
  1743. }
  1744. /**
  1745. * Hook to specify "ammunition"
  1746. */
  1747. static bool item_tester_hook_ammo(const object_type * o_ptr)
  1748. {
  1749. switch (o_ptr->tval) {
  1750. case TV_BOLT:
  1751. case TV_ARROW:
  1752. case TV_SHOT:
  1753. {
  1754. return (TRUE);
  1755. }
  1756. }
  1757. return (FALSE);
  1758. }
  1759. /**
  1760. * Hook to specify "armour"
  1761. */
  1762. static bool item_tester_hook_armour(const object_type * o_ptr)
  1763. {
  1764. switch (o_ptr->tval) {
  1765. case TV_DRAG_ARMOR:
  1766. case TV_HARD_ARMOR:
  1767. case TV_SOFT_ARMOR:
  1768. case TV_SHIELD:
  1769. case TV_CLOAK:
  1770. case TV_CROWN:
  1771. case TV_HELM:
  1772. case TV_BOOTS:
  1773. case TV_GLOVES:
  1774. {
  1775. return (TRUE);
  1776. }
  1777. }
  1778. return (FALSE);
  1779. }
  1780. static bool item_tester_unknown(const object_type * o_ptr)
  1781. {
  1782. if (object_known_p(o_ptr))
  1783. return FALSE;
  1784. else
  1785. return TRUE;
  1786. }
  1787. static bool item_tester_unknown_curse(const object_type * o_ptr)
  1788. {
  1789. if (object_known_p(o_ptr) && (o_ptr->ident & IDENT_KNOW_CURSES))
  1790. return FALSE;
  1791. else
  1792. return TRUE;
  1793. }
  1794. static bool item_tester_unproofed(const object_type * o_ptr)
  1795. {
  1796. if (o_ptr->number != 1)
  1797. return FALSE;
  1798. if (of_is_subset(o_ptr->flags_obj, el_to_proof))
  1799. return FALSE;
  1800. else
  1801. return TRUE;
  1802. }
  1803. /**
  1804. * Enchant an item
  1805. *
  1806. * Revamped! Now takes item pointer, number of times to try enchanting,
  1807. * and a flag of what to try enchanting. Artifacts resist enchantment
  1808. * some of the time, and successful enchantment to at least +0 might
  1809. * break a curse on the item. -CFT
  1810. *
  1811. * Note that an item can technically be enchanted all the way to +15 if
  1812. * you wait a very, very, long time. Going from +9 to +10 only works
  1813. * about 5% of the time, and from +10 to +11 only about 1% of the time.
  1814. *
  1815. * Note that this function can now be used on "piles" of items, and
  1816. * the larger the pile, the lower the chance of success.
  1817. */
  1818. bool enchant(object_type * o_ptr, int n, int eflag)
  1819. {
  1820. int i, chance, prob;
  1821. bool res = FALSE;
  1822. bool a = artifact_p(o_ptr);
  1823. /* Large piles resist enchantment */
  1824. prob = o_ptr->number * 100;
  1825. /* Missiles are easy to enchant */
  1826. if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW)
  1827. || (o_ptr->tval == TV_SHOT)) {
  1828. prob = prob / 35;
  1829. }
  1830. /* Try "n" times */
  1831. for (i = 0; i < n; i++) {
  1832. /* Hack -- Roll for pile resistance */
  1833. if ((prob > 100) && (randint0(prob) >= 100))
  1834. continue;
  1835. /* Enchant to hit */
  1836. if (eflag & (ENCH_TOHIT)) {
  1837. if (o_ptr->to_h < 0)
  1838. chance = 0;
  1839. else if (o_ptr->to_h > 15)
  1840. chance = 1000;
  1841. else
  1842. chance = enchant_table[o_ptr->to_h];
  1843. /* Attempt to enchant */
  1844. if ((randint1(1000) > chance) && (!a || (randint0(100) < 50))) {
  1845. res = TRUE;
  1846. /* Enchant */
  1847. o_ptr->to_h++;
  1848. }
  1849. }
  1850. /* Enchant to damage */
  1851. if (eflag & (ENCH_TODAM)) {
  1852. if (o_ptr->to_d < 0)
  1853. chance = 0;
  1854. else if (o_ptr->to_d > 15)
  1855. chance = 1000;
  1856. else
  1857. chance = enchant_table[o_ptr->to_d];
  1858. if ((randint1(1000) > chance) && (!a || (randint0(100) < 50))) {
  1859. res = TRUE;
  1860. /* Enchant */
  1861. o_ptr->to_d++;
  1862. }
  1863. }
  1864. /* Enchant to armor class */
  1865. if (eflag & (ENCH_TOAC)) {
  1866. if (o_ptr->to_a < 0)
  1867. chance = 0;
  1868. else if (o_ptr->to_a > 15)
  1869. chance = 1000;
  1870. else
  1871. chance = enchant_table[o_ptr->to_a];
  1872. if ((randint1(1000) > chance) && (!a || (randint0(100) < 50))) {
  1873. res = TRUE;
  1874. /* Enchant */
  1875. o_ptr->to_a++;
  1876. }
  1877. }
  1878. }
  1879. /* Failure */
  1880. if (!res)
  1881. return (FALSE);
  1882. /* Recalculate bonuses */
  1883. p_ptr->update |= (PU_BONUS);
  1884. /* Combine / Reorder the pack (later) */
  1885. p_ptr->notice |= (PN_COMBINE | PN_REORDER | PN_SORT_QUIVER);
  1886. /* Redraw stuff */
  1887. p_ptr->redraw |= (PR_INVEN | PR_EQUIP);
  1888. /* Success */
  1889. return (TRUE);
  1890. }
  1891. /**
  1892. * Enchant an item (in the inventory or on the floor)
  1893. * Note that "num_ac" requires armour, else weapon
  1894. * Returns TRUE if attempted, FALSE if cancelled
  1895. */
  1896. bool enchant_spell(int num_hit, int num_dam, int num_ac)
  1897. {
  1898. int item;
  1899. bool okay = FALSE;
  1900. object_type *o_ptr;
  1901. char o_name[120];
  1902. const char *q, *s;
  1903. /* Assume enchant weapon */
  1904. item_tester_hook = item_tester_hook_weapon;
  1905. /* Don't restrict choices */
  1906. item_tester_tval = 0;
  1907. /* Enchant armor if requested */
  1908. if (num_ac)
  1909. item_tester_hook = item_tester_hook_armour;
  1910. /* Get an item */
  1911. q = "Enchant which item? ";
  1912. s = "You have nothing to enchant.";
  1913. if (!get_item
  1914. (&item, q, s, CMD_NULL, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
  1915. return (FALSE);
  1916. /* Get the item (in the pack) */
  1917. if (item >= 0) {
  1918. o_ptr = &p_ptr->inventory[item];
  1919. }
  1920. /* Get the item (on the floor) */
  1921. else {
  1922. o_ptr = &o_list[0 - item];
  1923. }
  1924. /* Description */
  1925. object_desc(o_name, sizeof(o_name), o_ptr, ODESC_BASE);
  1926. /* Describe */
  1927. msg("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name,
  1928. ((o_ptr->number > 1) ? "" : "s"));
  1929. /* Enchant */
  1930. if (enchant(o_ptr, num_hit, ENCH_TOHIT))
  1931. okay = TRUE;
  1932. if (enchant(o_ptr, num_dam, ENCH_TODAM))
  1933. okay = TRUE;
  1934. if (enchant(o_ptr, num_ac, ENCH_TOAC))
  1935. okay = TRUE;
  1936. /* Failure */
  1937. if (!okay) {
  1938. /* Flush */
  1939. if (OPT(flush_failure))
  1940. flush();
  1941. /* Message */
  1942. msg("The enchantment failed.");
  1943. }
  1944. /* Something happened */
  1945. return (TRUE);
  1946. }
  1947. /**
  1948. * Enchant some missiles and give them an elemental brand
  1949. *
  1950. * Combines the old brand_bolts and brand_missiles routines.
  1951. *
  1952. * ammo_type is the tval of the relevant ammunition.
  1953. * If set to 0, any ammunition is enchantable.
  1954. *
  1955. * Brand type is the EGO flag for the relevant type element.
  1956. * If set to 0, a non-poison brand is picked randomly.
  1957. *
  1958. */
  1959. bool brand_missile(int ammo_type, int brand_type)
  1960. {
  1961. int item, choice;
  1962. object_type *o_ptr;
  1963. const char *q, *s;
  1964. bool status;
  1965. /* Restrict choices Hack - check for restricted choice */
  1966. if ((ammo_type >= TV_SHOT) && (ammo_type <= TV_BOLT))
  1967. item_tester_tval = ammo_type;
  1968. /* Otherwise any ammo will do */
  1969. else
  1970. item_tester_hook = item_tester_hook_ammo;
  1971. /* Get an item */
  1972. q = "Enchant which ammunition? ";
  1973. s = "You have no ammunition to brand.";
  1974. status = get_item(&item, q, s, 0, (USE_EQUIP | USE_INVEN | USE_FLOOR));
  1975. /* Hack - if failed, return, but only after resetting the ammo hack */
  1976. if (!status)
  1977. return (FALSE);
  1978. if (item >= 0) {
  1979. o_ptr = &p_ptr->inventory[item];
  1980. }
  1981. /* Get the item (on the floor) */
  1982. else {
  1983. o_ptr = &o_list[0 - item];
  1984. }
  1985. /*
  1986. * Don't enchant artifacts or ego-items
  1987. */
  1988. if (artifact_p(o_ptr) || ego_item_p(o_ptr)) {
  1989. /* Flush */
  1990. if (OPT(flush_failure))
  1991. flush();
  1992. /* Fail */
  1993. msg("The ammunition enchantment failed.");
  1994. /* Notice */
  1995. return (TRUE);
  1996. }
  1997. /* Type of brand may be restricted */
  1998. if (brand_type)
  1999. choice = brand_type;
  2000. /* Otherwise choose randomly Hack - Never get poison brand randomly */
  2001. else
  2002. choice = randint0(4) + EGO_ACIDIC;
  2003. switch (choice) {
  2004. case EGO_FLAME:
  2005. {
  2006. /* Print message and fire brand missiles. */
  2007. msg("Your missiles are covered in a fiery aura!");
  2008. break;
  2009. }
  2010. case EGO_FROST:
  2011. {
  2012. /* Print message and frost brand missiles. */
  2013. msg("Your missiles are covered in a frosty sheath!");
  2014. break;
  2015. }
  2016. case EGO_ACIDIC:
  2017. {
  2018. /* Print message and acid brand missiles. */
  2019. msg("Your missiles sizzle with acid!");
  2020. break;
  2021. }
  2022. case EGO_ELECT:
  2023. {
  2024. /* Print message and electric brand missiles. */
  2025. msg("Your missiles are covered in sparks!");
  2026. break;
  2027. }
  2028. case EGO_POISON:
  2029. {
  2030. /* Print message and poison brand missiles. */
  2031. msg("Your missiles drip with deadly poison!");
  2032. break;
  2033. }
  2034. default:
  2035. {
  2036. /* Oops */
  2037. return (FALSE);
  2038. }
  2039. }
  2040. /* Brand */
  2041. o_ptr->name2 = choice;
  2042. o_ptr->m

Large files files are truncated, but you can click here to view the full file