PageRenderTime 56ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/src/wizard.c

https://bitbucket.org/ekolis/jackband
C | 1858 lines | 1108 code | 352 blank | 398 comment | 212 complexity | baa9010d48c9a573cf997a148cb4d195 MD5 | raw file
  1. /*
  2. * File: wizard2.c
  3. * Purpose: Debug mode commands
  4. *
  5. * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
  6. *
  7. * This work is free software; you can redistribute it and/or modify it
  8. * under the terms of either:
  9. *
  10. * a) the GNU General Public License as published by the Free Software
  11. * Foundation, version 2, or
  12. *
  13. * b) the "Angband licence":
  14. * This software may be copied and distributed for educational, research,
  15. * and not for profit purposes provided that this copyright and statement
  16. * are included in all such copies. Other copyrights may also apply.
  17. */
  18. #include "angband.h"
  19. #include "wizard.h"
  20. #include "cmds.h"
  21. #include "object/tvalsval.h"
  22. //#ifdef ALLOW_DEBUG
  23. // HACK - disabled wizmode due to funkiness with player classes
  24. #if 0
  25. /*
  26. * This is a nice utility function; it determines if a (NULL-terminated)
  27. * string consists of only digits (starting with a non-zero digit).
  28. */
  29. s16b get_idx_from_name(char *s)
  30. {
  31. char *endptr = NULL;
  32. long l = strtol(s, &endptr, 10);
  33. return *endptr == '\0' ? (s16b)l : 0;
  34. }
  35. /*
  36. * Hack -- quick debugging hook
  37. */
  38. static void do_cmd_wiz_hack_ben(void)
  39. {
  40. int py = p_ptr->py;
  41. int px = p_ptr->px;
  42. int i, y, x;
  43. for (i = 0; i < MONSTER_FLOW_DEPTH; ++i)
  44. {
  45. /* Update map */
  46. for (y = Term->offset_y; y < Term->offset_y + SCREEN_HGT; y++)
  47. {
  48. for (x = Term->offset_x; x < Term->offset_x + SCREEN_WID; x++)
  49. {
  50. byte a = TERM_RED;
  51. if (!in_bounds_fully(y, x)) continue;
  52. /* Display proper cost */
  53. if (cave_cost[y][x] != i) continue;
  54. /* Reliability in yellow */
  55. if (cave_when[y][x] == cave_when[py][px])
  56. {
  57. a = TERM_YELLOW;
  58. }
  59. /* Display player/floors/walls */
  60. if ((y == py) && (x == px))
  61. {
  62. print_rel('@', a, y, x);
  63. }
  64. else if (cave_floor_bold(y, x))
  65. {
  66. print_rel('*', a, y, x);
  67. }
  68. else
  69. {
  70. print_rel('#', a, y, x);
  71. }
  72. }
  73. }
  74. /* Prompt */
  75. prt(format("Depth %d: ", i), 0, 0);
  76. /* Get key */
  77. if (inkey() == ESCAPE) break;
  78. /* Redraw map */
  79. prt_map();
  80. }
  81. /* Done */
  82. prt("", 0, 0);
  83. /* Redraw map */
  84. prt_map();
  85. }
  86. /*
  87. * Output part of a bitflag set in binary format.
  88. */
  89. static void prt_binary(const bitflag *flags, int offset, int row, int col, char ch, int num)
  90. {
  91. int flag;
  92. /* Scan the flags */
  93. for (flag = FLAG_START + offset; flag < FLAG_START + offset + num; flag++)
  94. {
  95. if (of_has(flags, flag))
  96. Term_putch(col++, row, TERM_BLUE, ch);
  97. else
  98. Term_putch(col++, row, TERM_WHITE, '-');
  99. }
  100. }
  101. /*
  102. * Hack -- Teleport to the target
  103. */
  104. static void do_cmd_wiz_bamf(void)
  105. {
  106. s16b x, y;
  107. /* Must have a target */
  108. if (!target_okay()) return;
  109. /* Teleport to the target */
  110. target_get(&x, &y);
  111. teleport_player_to(y, x);
  112. }
  113. /*
  114. * Aux function for "do_cmd_wiz_change()"
  115. */
  116. static void do_cmd_wiz_change_aux(void)
  117. {
  118. int i;
  119. int tmp_int;
  120. long tmp_long;
  121. char tmp_val[160];
  122. char ppp[80];
  123. /* Query the stats */
  124. for (i = 0; i < A_MAX; i++)
  125. {
  126. /* Prompt */
  127. strnfmt(ppp, sizeof(ppp), "%s (3-118): ", stat_names[i]);
  128. /* Default */
  129. strnfmt(tmp_val, sizeof(tmp_val), "%d", p_ptr->stat_max[i]);
  130. /* Query */
  131. if (!get_string(ppp, tmp_val, 4)) return;
  132. /* Extract */
  133. tmp_int = atoi(tmp_val);
  134. /* Verify */
  135. if (tmp_int > 18+100) tmp_int = 18+100;
  136. else if (tmp_int < 3) tmp_int = 3;
  137. /* Save it */
  138. p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int;
  139. }
  140. /* Default */
  141. strnfmt(tmp_val, sizeof(tmp_val), "%ld", (long)(p_ptr->au));
  142. /* Query */
  143. if (!get_string("Gold: ", tmp_val, 10)) return;
  144. /* Extract */
  145. tmp_long = atol(tmp_val);
  146. /* Verify */
  147. if (tmp_long < 0) tmp_long = 0L;
  148. /* Save */
  149. p_ptr->au = tmp_long;
  150. /* Default */
  151. strnfmt(tmp_val, sizeof(tmp_val), "%ld", (long)(p_curclass.exp));
  152. /* Query */
  153. if (!get_string("Experience: ", tmp_val, 10)) return;
  154. /* Extract */
  155. tmp_long = atol(tmp_val);
  156. /* Verify */
  157. if (tmp_long < 0) tmp_long = 0L;
  158. /* Save */
  159. p_curclass.exp = tmp_long;
  160. /* Update */
  161. check_experience();
  162. /* Default */
  163. strnfmt(tmp_val, sizeof(tmp_val), "%ld", (long)(p_curclass.max_exp));
  164. /* Query */
  165. if (!get_string("Max Exp: ", tmp_val, 10)) return;
  166. /* Extract */
  167. tmp_long = atol(tmp_val);
  168. /* Verify */
  169. if (tmp_long < 0) tmp_long = 0L;
  170. /* Save */
  171. p_curclass.max_exp = tmp_long;
  172. /* Update */
  173. check_experience();
  174. }
  175. /*
  176. * Change various "permanent" player variables.
  177. */
  178. static void do_cmd_wiz_change(void)
  179. {
  180. /* Interact */
  181. do_cmd_wiz_change_aux();
  182. /* Redraw everything */
  183. do_cmd_redraw();
  184. }
  185. /*
  186. * Wizard routines for creating objects and modifying them
  187. *
  188. * This has been rewritten to make the whole procedure
  189. * of debugging objects much easier and more comfortable.
  190. *
  191. * Here are the low-level functions
  192. *
  193. * - wiz_display_item()
  194. * display an item's debug-info
  195. * - wiz_create_itemtype()
  196. * specify tval and sval (type and subtype of object)
  197. * - wiz_tweak_item()
  198. * specify pval, +AC, +tohit, +todam
  199. * Note that the wizard can leave this function anytime,
  200. * thus accepting the default-values for the remaining values.
  201. * pval comes first now, since it is most important.
  202. * - wiz_reroll_item()
  203. * apply some magic to the item or turn it into an artifact.
  204. * - wiz_roll_item()
  205. * Get some statistics about the rarity of an item:
  206. * We create a lot of fake items and see if they are of the
  207. * same type (tval and sval), then we compare pval and +AC.
  208. * If the fake-item is better or equal it is counted.
  209. * Note that cursed items that are better or equal (absolute values)
  210. * are counted, too.
  211. * HINT: This is *very* useful for balancing the game!
  212. * - wiz_quantity_item()
  213. * change the quantity of an item, but be sane about it.
  214. *
  215. * And now the high-level functions
  216. * - do_cmd_wiz_play()
  217. * play with an existing object
  218. * - wiz_create_item()
  219. * create a new object
  220. *
  221. * Note -- You do not have to specify "pval" and other item-properties
  222. * directly. Just apply magic until you are satisfied with the item.
  223. *
  224. * Note -- For some items (such as wands, staffs, some rings, etc), you
  225. * must apply magic, or you will get "broken" or "uncharged" objects.
  226. *
  227. * Note -- Redefining artifacts via "do_cmd_wiz_play()" may destroy
  228. * the artifact. Be careful.
  229. *
  230. * Hack -- this function will allow you to create multiple artifacts.
  231. * This "feature" may induce crashes or other nasty effects.
  232. */
  233. /*
  234. * Display an item's properties
  235. */
  236. static void wiz_display_item(const object_type *o_ptr, bool all)
  237. {
  238. int j = 0;
  239. bitflag f[OF_SIZE];
  240. char buf[256];
  241. /* Extract the flags */
  242. if (all)
  243. object_flags(o_ptr, f);
  244. else
  245. object_flags_known(o_ptr, f);
  246. /* Clear screen */
  247. Term_clear();
  248. /* Describe fully */
  249. object_desc(buf, sizeof(buf), o_ptr,
  250. ODESC_PREFIX | ODESC_FULL | ODESC_SPOIL);
  251. prt(buf, 2, j);
  252. prt(format("combat = (%dd%d) (%+d,%+d) [%d,%+d]",
  253. o_ptr->dd, o_ptr->ds, o_ptr->to_h, o_ptr->to_d, o_ptr->ac, o_ptr->to_a), 4, j);
  254. prt(format("kind = %-5d tval = %-5d sval = %-5d wgt = %-3d timeout = %-d",
  255. o_ptr->k_idx, o_ptr->tval, o_ptr->sval, o_ptr->weight, o_ptr->timeout), 5, j);
  256. prt(format("number = %-3d pval = %-5d name1 = %-4d name2 = %-4d cost = %ld",
  257. o_ptr->number, o_ptr->pval, o_ptr->name1, o_ptr->name2, (long)object_value(o_ptr, 1, FALSE)), 6, j);
  258. prt("+------------FLAGS0------------+", 8, j);
  259. prt("AFFECT..........SLAY.......BRAND", 9, j);
  260. prt(" ae xxxpaefc", 10, j);
  261. prt("siwdcc ssidsasmnvudotgddduoclio", 11, j);
  262. prt("tnieoh trnipthgiinmrrnrrmniierl", 12, j);
  263. prt("rtsxna..lcfgdkttmldncltggndsdced", 13, j);
  264. prt_binary(f, 0, 14, j, '*', 32);
  265. prt_binary(o_ptr->known_flags, 0, 15, j, '+', 32);
  266. prt("+------------FLAGS1------------+", 16, j);
  267. prt("SUST........IMM.RESIST.........", 17, j);
  268. prt(" afecaefcpfldbc s n ", 18, j);
  269. prt("siwdcc cilocliooeialoshnecd", 19, j);
  270. prt("tnieoh irelierliatrnnnrethi", 20, j);
  271. prt("rtsxna......decddcedsrekdfddxhss", 21, j);
  272. prt_binary(f, 32, 22, j, '*', 32);
  273. prt_binary(o_ptr->known_flags, 32, 23, j, '+', 32);
  274. prt("+------------FLAGS2------------+", 8, j+34);
  275. prt("s ts hn tadiiii aiehs hp", 9, j+34);
  276. prt("lf eefoo egrgggg bcnaih vr", 10, j+34);
  277. prt("we lerlf ilgannnn ltssdo ym", 11, j+34);
  278. prt("da reiedu merirrrr eityew ccc", 12, j+34);
  279. prt("itlepnele ppanaefc svaktm uuu", 13, j+34);
  280. prt("ghigavail aoveclio saanyo rrr", 14, j+34);
  281. prt("seteticf craxierl etropd sss", 15, j+34);
  282. prt("trenhste tttpdced detwes eee", 16, j+34);
  283. prt_binary(f, 64, 17, j + 34, '*', 32);
  284. prt_binary(o_ptr->known_flags, 64, 18, j + 34, '+', 32);
  285. prt("o_ptr->ident:", 20, j+34);
  286. prt(format("sense %c worn %c empty %c known %c",
  287. (o_ptr->ident & IDENT_SENSE) ? '+' : ' ',
  288. (o_ptr->ident & IDENT_WORN) ? '+' : ' ',
  289. (o_ptr->ident & IDENT_EMPTY) ? '+' : ' ',
  290. (o_ptr->ident & IDENT_KNOWN) ? '+' : ' '), 21, j+34);
  291. prt(format("store %c attack %c defence %c effect %c",
  292. (o_ptr->ident & IDENT_STORE) ? '+' : ' ',
  293. (o_ptr->ident & IDENT_ATTACK) ? '+' : ' ',
  294. (o_ptr->ident & IDENT_DEFENCE) ? '+' : ' ',
  295. (o_ptr->ident & IDENT_EFFECT) ? '+' : ' '), 22, j+34);
  296. prt(format("indest %c ego %c",
  297. (o_ptr->ident & IDENT_INDESTRUCT) ? '+' : ' ',
  298. (o_ptr->ident & IDENT_NAME) ? '+' : ' '), 23, j+34);
  299. }
  300. /*
  301. * A structure to hold a tval and its description
  302. */
  303. typedef struct tval_desc
  304. {
  305. int tval;
  306. cptr desc;
  307. } tval_desc;
  308. /*
  309. * A list of tvals and their textual names
  310. */
  311. static const tval_desc tvals[] =
  312. {
  313. { TV_SWORD, "Sword" },
  314. { TV_POLEARM, "Polearm" },
  315. { TV_HAFTED, "Hafted Weapon" },
  316. { TV_BOW, "Bow" },
  317. { TV_ARROW, "Arrows" },
  318. { TV_BOLT, "Bolts" },
  319. { TV_SHOT, "Shots" },
  320. { TV_SHIELD, "Shield" },
  321. { TV_CROWN, "Crown" },
  322. { TV_HELM, "Helm" },
  323. { TV_GLOVES, "Gloves" },
  324. { TV_BOOTS, "Boots" },
  325. { TV_CLOAK, "Cloak" },
  326. { TV_DRAG_ARMOR, "Dragon Scale Mail" },
  327. { TV_HARD_ARMOR, "Hard Armor" },
  328. { TV_SOFT_ARMOR, "Soft Armor" },
  329. { TV_RING, "Ring" },
  330. { TV_AMULET, "Amulet" },
  331. { TV_LIGHT, "Light" },
  332. { TV_POTION, "Potion" },
  333. { TV_SCROLL, "Scroll" },
  334. { TV_WAND, "Wand" },
  335. { TV_STAFF, "Staff" },
  336. { TV_ROD, "Rod" },
  337. { TV_PRAYER_BOOK, "Priest Book" },
  338. { TV_MAGIC_BOOK, "Magic Book" },
  339. { TV_SPIKE, "Spikes" },
  340. { TV_DIGGING, "Digger" },
  341. { TV_CHEST, "Chest" },
  342. { TV_FOOD, "Food" },
  343. { TV_FLASK, "Flask" },
  344. { TV_SKELETON, "Skeletons" },
  345. { TV_BOTTLE, "Empty bottle" },
  346. { TV_JUNK, "Junk" },
  347. { TV_GOLD, "Gold" },
  348. { 0, NULL }
  349. };
  350. /*
  351. * Get an object kind for creation (or zero)
  352. *
  353. * List up to 60 choices in three columns
  354. */
  355. static int wiz_create_itemtype(void)
  356. {
  357. int i, num, max_num;
  358. int col, row;
  359. int tval;
  360. cptr tval_desc;
  361. char ch;
  362. int choice[60];
  363. static const char choice_name[] = "abcdefghijklmnopqrst"
  364. "ABCDEFGHIJKLMNOPQRST"
  365. "0123456789:;<=>?@%&*";
  366. const char *cp;
  367. char buf[160];
  368. /* Clear screen */
  369. Term_clear();
  370. /* Print all tval's and their descriptions */
  371. for (num = 0; (num < 60) && tvals[num].tval; num++)
  372. {
  373. row = 2 + (num % 20);
  374. col = 30 * (num / 20);
  375. ch = choice_name[num];
  376. prt(format("[%c] %s", ch, tvals[num].desc), row, col);
  377. }
  378. /* We need to know the maximal possible tval_index */
  379. max_num = num;
  380. /* Choose! */
  381. if (!get_com("Get what type of object? ", &ch)) return (0);
  382. /* Analyze choice */
  383. num = -1;
  384. if ((cp = strchr(choice_name, ch)) != NULL)
  385. num = cp - choice_name;
  386. /* Bail out if choice is illegal */
  387. if ((num < 0) || (num >= max_num)) return (0);
  388. /* Base object type chosen, fill in tval */
  389. tval = tvals[num].tval;
  390. tval_desc = tvals[num].desc;
  391. /*** And now we go for k_idx ***/
  392. /* Clear screen */
  393. Term_clear();
  394. /* We have to search the whole itemlist. */
  395. for (num = 0, i = 1; (num < 60) && (i < z_info->k_max); i++)
  396. {
  397. object_kind *k_ptr = &k_info[i];
  398. /* Analyze matching items */
  399. if (k_ptr->tval == tval)
  400. {
  401. /* Hack -- Skip instant artifacts */
  402. if (of_has(k_ptr->flags, OF_INSTA_ART)) continue;
  403. /* Prepare it */
  404. row = 2 + (num % 20);
  405. col = 30 * (num / 20);
  406. ch = choice_name[num];
  407. /* Get the "name" of object "i" */
  408. object_kind_name(buf, sizeof buf, i, TRUE);
  409. /* Print it */
  410. prt(format("[%c] %s", ch, buf), row, col);
  411. /* Remember the object index */
  412. choice[num++] = i;
  413. }
  414. }
  415. /* Me need to know the maximal possible remembered object_index */
  416. max_num = num;
  417. /* Choose! */
  418. if (!get_com(format("What Kind of %s? ", tval_desc), &ch)) return (0);
  419. /* Analyze choice */
  420. num = -1;
  421. if ((cp = strchr(choice_name, ch)) != NULL)
  422. num = cp - choice_name;
  423. /* Bail out if choice is "illegal" */
  424. if ((num < 0) || (num >= max_num)) return (0);
  425. /* And return successful */
  426. return (choice[num]);
  427. }
  428. /*
  429. * Tweak an item
  430. */
  431. static void wiz_tweak_item(object_type *o_ptr)
  432. {
  433. cptr p;
  434. char tmp_val[80];
  435. /* Hack -- leave artifacts alone */
  436. if (artifact_p(o_ptr)) return;
  437. #define WIZ_TWEAK(attribute) do {\
  438. p = "Enter new '" #attribute "' setting: ";\
  439. strnfmt(tmp_val, sizeof(tmp_val), "%d", o_ptr->attribute);\
  440. if (!get_string(p, tmp_val, 6)) return;\
  441. o_ptr->attribute = atoi(tmp_val);\
  442. wiz_display_item(o_ptr, TRUE);\
  443. } while (0)
  444. WIZ_TWEAK(pval);
  445. WIZ_TWEAK(to_a);
  446. WIZ_TWEAK(to_h);
  447. WIZ_TWEAK(to_d);
  448. WIZ_TWEAK(name1);
  449. WIZ_TWEAK(name2);
  450. }
  451. /*
  452. * Apply magic to an item or turn it into an artifact. -Bernd-
  453. */
  454. static void wiz_reroll_item(object_type *o_ptr)
  455. {
  456. object_type *i_ptr;
  457. object_type object_type_body;
  458. char ch;
  459. bool changed = FALSE;
  460. /* Hack -- leave artifacts alone */
  461. if (artifact_p(o_ptr)) return;
  462. /* Get local object */
  463. i_ptr = &object_type_body;
  464. /* Copy the object */
  465. object_copy(i_ptr, o_ptr);
  466. /* Main loop. Ask for magification and artifactification */
  467. while (TRUE)
  468. {
  469. /* Display full item debug information */
  470. wiz_display_item(i_ptr, TRUE);
  471. /* Ask wizard what to do. */
  472. if (!get_com("[a]ccept, [n]ormal, [g]ood, [e]xcellent? ", &ch))
  473. break;
  474. /* Create/change it! */
  475. if (ch == 'A' || ch == 'a')
  476. {
  477. changed = TRUE;
  478. break;
  479. }
  480. /* Apply normal magic, but first clear object */
  481. else if (ch == 'n' || ch == 'N')
  482. {
  483. object_prep(i_ptr, o_ptr->k_idx, p_ptr->depth, RANDOMISE);
  484. apply_magic(i_ptr, p_ptr->depth, FALSE, FALSE, FALSE);
  485. }
  486. /* Apply good magic, but first clear object */
  487. else if (ch == 'g' || ch == 'g')
  488. {
  489. object_prep(i_ptr, o_ptr->k_idx, p_ptr->depth, RANDOMISE);
  490. apply_magic(i_ptr, p_ptr->depth, FALSE, TRUE, FALSE);
  491. }
  492. /* Apply great magic, but first clear object */
  493. else if (ch == 'e' || ch == 'e')
  494. {
  495. object_prep(i_ptr, o_ptr->k_idx, p_ptr->depth, RANDOMISE);
  496. apply_magic(i_ptr, p_ptr->depth, FALSE, TRUE, TRUE);
  497. }
  498. }
  499. /* Notice change */
  500. if (changed)
  501. {
  502. /* Mark as cheat */
  503. i_ptr->origin = ORIGIN_CHEAT;
  504. /* Restore the position information */
  505. i_ptr->iy = o_ptr->iy;
  506. i_ptr->ix = o_ptr->ix;
  507. i_ptr->next_o_idx = o_ptr->next_o_idx;
  508. i_ptr->marked = o_ptr->marked;
  509. /* Apply changes */
  510. object_copy(o_ptr, i_ptr);
  511. /* Recalculate bonuses */
  512. p_ptr->update |= (PU_BONUS);
  513. /* Combine / Reorder the pack (later) */
  514. p_ptr->notice |= (PN_COMBINE | PN_REORDER | PN_SORT_QUIVER);
  515. /* Window stuff */
  516. p_ptr->redraw |= (PR_INVEN | PR_EQUIP );
  517. }
  518. }
  519. /*
  520. * Maximum number of rolls
  521. */
  522. #define TEST_ROLL 100000
  523. /*
  524. * Try to create an item again. Output some statistics. -Bernd-
  525. *
  526. * The statistics are correct now. We acquire a clean grid, and then
  527. * repeatedly place an object in this grid, copying it into an item
  528. * holder, and then deleting the object. We fiddle with the artifact
  529. * counter flags to prevent weirdness. We use the items to collect
  530. * statistics on item creation relative to the initial item.
  531. */
  532. static void wiz_statistics(object_type *o_ptr, int level)
  533. {
  534. long i, matches, better, worse, other;
  535. char ch;
  536. cptr quality;
  537. bool good, great;
  538. object_type *i_ptr;
  539. object_type object_type_body;
  540. cptr q = "Rolls: %ld, Matches: %ld, Better: %ld, Worse: %ld, Other: %ld";
  541. artifact_type *a_ptr = artifact_of(o_ptr);
  542. /* Allow multiple artifacts, because breaking the game is fine here */
  543. if (a_ptr) a_ptr->created = FALSE;
  544. /* Interact */
  545. while (TRUE)
  546. {
  547. cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
  548. /* Display item */
  549. wiz_display_item(o_ptr, TRUE);
  550. /* Get choices */
  551. if (!get_com(pmt, &ch)) break;
  552. if (ch == 'n' || ch == 'N')
  553. {
  554. good = FALSE;
  555. great = FALSE;
  556. quality = "normal";
  557. }
  558. else if (ch == 'g' || ch == 'G')
  559. {
  560. good = TRUE;
  561. great = FALSE;
  562. quality = "good";
  563. }
  564. else if (ch == 'e' || ch == 'E')
  565. {
  566. good = TRUE;
  567. great = TRUE;
  568. quality = "excellent";
  569. }
  570. else
  571. {
  572. #if 0 /* unused */
  573. good = FALSE;
  574. great = FALSE;
  575. #endif /* unused */
  576. break;
  577. }
  578. /* Let us know what we are doing */
  579. msg_format("Creating a lot of %s items. Base level = %d.",
  580. quality, p_ptr->depth);
  581. message_flush();
  582. /* Set counters to zero */
  583. matches = better = worse = other = 0;
  584. /* Let's rock and roll */
  585. for (i = 0; i <= TEST_ROLL; i++)
  586. {
  587. /* Output every few rolls */
  588. if ((i < 100) || (i % 100 == 0))
  589. {
  590. /* Do not wait */
  591. inkey_scan = SCAN_INSTANT;
  592. /* Allow interupt */
  593. if (inkey())
  594. {
  595. /* Flush */
  596. flush();
  597. /* Stop rolling */
  598. break;
  599. }
  600. /* Dump the stats */
  601. prt(format(q, i, matches, better, worse, other), 0, 0);
  602. Term_fresh();
  603. }
  604. /* Get local object */
  605. i_ptr = &object_type_body;
  606. /* Wipe the object */
  607. object_wipe(i_ptr);
  608. /* Create an object */
  609. make_object(i_ptr, level, good, great);
  610. /* Allow multiple artifacts, because breaking the game is fine here */
  611. a_ptr = artifact_of(o_ptr);
  612. if (a_ptr) a_ptr->created = FALSE;
  613. /* Test for the same tval and sval. */
  614. if ((o_ptr->tval) != (i_ptr->tval)) continue;
  615. if ((o_ptr->sval) != (i_ptr->sval)) continue;
  616. /* Check for match */
  617. if ((i_ptr->pval == o_ptr->pval) &&
  618. (i_ptr->to_a == o_ptr->to_a) &&
  619. (i_ptr->to_h == o_ptr->to_h) &&
  620. (i_ptr->to_d == o_ptr->to_d))
  621. {
  622. matches++;
  623. }
  624. /* Check for better */
  625. else if ((i_ptr->pval >= o_ptr->pval) &&
  626. (i_ptr->to_a >= o_ptr->to_a) &&
  627. (i_ptr->to_h >= o_ptr->to_h) &&
  628. (i_ptr->to_d >= o_ptr->to_d))
  629. {
  630. better++;
  631. }
  632. /* Check for worse */
  633. else if ((i_ptr->pval <= o_ptr->pval) &&
  634. (i_ptr->to_a <= o_ptr->to_a) &&
  635. (i_ptr->to_h <= o_ptr->to_h) &&
  636. (i_ptr->to_d <= o_ptr->to_d))
  637. {
  638. worse++;
  639. }
  640. /* Assume different */
  641. else
  642. {
  643. other++;
  644. }
  645. }
  646. /* Final dump */
  647. msg_format(q, i, matches, better, worse, other);
  648. message_flush();
  649. }
  650. /* Hack -- Normally only make a single artifact */
  651. if (artifact_p(o_ptr)) a_info[o_ptr->name1].created = TRUE;
  652. }
  653. /*
  654. * Change the quantity of a the item
  655. */
  656. static void wiz_quantity_item(object_type *o_ptr, bool carried)
  657. {
  658. int tmp_int;
  659. char tmp_val[3];
  660. /* Never duplicate artifacts */
  661. if (artifact_p(o_ptr)) return;
  662. /* Default */
  663. strnfmt(tmp_val, sizeof(tmp_val), "%d", o_ptr->number);
  664. /* Query */
  665. if (get_string("Quantity: ", tmp_val, 3))
  666. {
  667. /* Extract */
  668. tmp_int = atoi(tmp_val);
  669. /* Paranoia */
  670. if (tmp_int < 1) tmp_int = 1;
  671. if (tmp_int > 99) tmp_int = 99;
  672. /* Adjust total weight being carried */
  673. if (carried)
  674. {
  675. /* Remove the weight of the old number of objects */
  676. p_ptr->total_weight -= (o_ptr->number * o_ptr->weight);
  677. /* Add the weight of the new number of objects */
  678. p_ptr->total_weight += (tmp_int * o_ptr->weight);
  679. }
  680. /* Adjust charge for rods */
  681. if (o_ptr->tval == TV_ROD)
  682. {
  683. o_ptr->pval = (o_ptr->pval / o_ptr->number) * tmp_int;
  684. }
  685. /* Accept modifications */
  686. o_ptr->number = tmp_int;
  687. }
  688. }
  689. /**
  690. * Tweak the cursed status of an object.
  691. *
  692. * \param o_ptr is the object to curse or decurse
  693. */
  694. static void wiz_tweak_curse(object_type *o_ptr)
  695. {
  696. if (cursed_p(o_ptr))
  697. {
  698. msg_print("Resetting existing curses.");
  699. flags_clear(o_ptr->flags, OF_SIZE, OF_CURSE_MASK, FLAG_END);
  700. }
  701. if (get_check("Set light curse? "))
  702. flags_set(o_ptr->flags, OF_SIZE, OF_LIGHT_CURSE, FLAG_END);
  703. else if (get_check("Set heavy curse? "))
  704. flags_set(o_ptr->flags, OF_SIZE, OF_LIGHT_CURSE, OF_HEAVY_CURSE, FLAG_END);
  705. else if (get_check("Set permanent curse? "))
  706. flags_set(o_ptr->flags, OF_SIZE, OF_LIGHT_CURSE, OF_HEAVY_CURSE, OF_PERMA_CURSE, FLAG_END);
  707. }
  708. /*
  709. * Play with an item. Options include:
  710. * - Output statistics (via wiz_roll_item)
  711. * - Reroll item (via wiz_reroll_item)
  712. * - Change properties (via wiz_tweak_item)
  713. * - Change the number of items (via wiz_quantity_item)
  714. */
  715. static void do_cmd_wiz_play(void)
  716. {
  717. int item;
  718. object_type *i_ptr;
  719. object_type object_type_body;
  720. object_type *o_ptr;
  721. char ch;
  722. cptr q, s;
  723. bool changed = FALSE;
  724. bool all = TRUE;
  725. /* Get an item */
  726. q = "Play with which object? ";
  727. s = "You have nothing to play with.";
  728. if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
  729. o_ptr = object_from_item_idx(item);
  730. /* Save screen */
  731. screen_save();
  732. /* Get local object */
  733. i_ptr = &object_type_body;
  734. /* Copy object */
  735. object_copy(i_ptr, o_ptr);
  736. /* The main loop */
  737. while (TRUE)
  738. {
  739. /* Display the item */
  740. wiz_display_item(i_ptr, all);
  741. /* Get choice */
  742. if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [c]urse [q]uantity [k]nown? ", &ch))
  743. break;
  744. if (ch == 'A' || ch == 'a')
  745. {
  746. changed = TRUE;
  747. break;
  748. }
  749. else if (ch == 'c' || ch == 'C')
  750. wiz_tweak_curse(i_ptr);
  751. else if (ch == 's' || ch == 'S')
  752. wiz_statistics(i_ptr, p_ptr->depth);
  753. else if (ch == 'r' || ch == 'r')
  754. wiz_reroll_item(i_ptr);
  755. else if (ch == 't' || ch == 'T')
  756. wiz_tweak_item(i_ptr);
  757. else if (ch == 'k' || ch == 'K')
  758. all = !all;
  759. else if (ch == 'q' || ch == 'Q')
  760. {
  761. bool carried = (item >= 0) ? TRUE : FALSE;
  762. wiz_quantity_item(i_ptr, carried);
  763. }
  764. }
  765. /* Load screen */
  766. screen_load();
  767. /* Accept change */
  768. if (changed)
  769. {
  770. /* Message */
  771. msg_print("Changes accepted.");
  772. /* Change */
  773. object_copy(o_ptr, i_ptr);
  774. /* Recalculate bonuses */
  775. p_ptr->update |= (PU_BONUS);
  776. /* Combine / Reorder the pack (later) */
  777. p_ptr->notice |= (PN_COMBINE | PN_REORDER);
  778. /* Window stuff */
  779. p_ptr->redraw |= (PR_INVEN | PR_EQUIP );
  780. }
  781. /* Ignore change */
  782. else
  783. {
  784. msg_print("Changes ignored.");
  785. }
  786. }
  787. /*
  788. * Wizard routine for creating objects
  789. *
  790. * Note that wizards cannot create objects on top of other objects.
  791. *
  792. * Hack -- this routine always makes a "dungeon object", and applies
  793. * magic to it, and attempts to decline cursed items. XXX XXX XXX
  794. */
  795. static void wiz_create_item(void)
  796. {
  797. int py = p_ptr->py;
  798. int px = p_ptr->px;
  799. object_type *i_ptr;
  800. object_type object_type_body;
  801. int k_idx;
  802. /* Save screen */
  803. screen_save();
  804. /* Get object base type */
  805. k_idx = wiz_create_itemtype();
  806. /* Load screen */
  807. screen_load();
  808. /* Return if failed */
  809. if (!k_idx) return;
  810. /* Get local object */
  811. i_ptr = &object_type_body;
  812. /* Create the item */
  813. object_prep(i_ptr, k_idx, p_ptr->depth, RANDOMISE);
  814. /* Apply magic (no messages, no artifacts) */
  815. apply_magic(i_ptr, p_ptr->depth, FALSE, FALSE, FALSE);
  816. /* Mark as cheat, and where created */
  817. i_ptr->origin = ORIGIN_CHEAT;
  818. i_ptr->origin_depth = p_ptr->depth;
  819. if (k_info[k_idx].tval == TV_GOLD)
  820. make_gold(i_ptr, p_ptr->depth, k_info[k_idx].sval);
  821. /* Drop the object from heaven */
  822. drop_near(i_ptr, 0, py, px, TRUE);
  823. /* All done */
  824. msg_print("Allocated.");
  825. }
  826. /*
  827. * Create the artifact with the specified number
  828. */
  829. static void wiz_create_artifact(int a_idx)
  830. {
  831. object_type *i_ptr;
  832. object_type object_type_body;
  833. int k_idx;
  834. artifact_type *a_ptr = &a_info[a_idx];
  835. /* Ignore "empty" artifacts */
  836. if (!a_ptr->name) return;
  837. /* Get local object */
  838. i_ptr = &object_type_body;
  839. /* Wipe the object */
  840. object_wipe(i_ptr);
  841. /* Acquire the "kind" index */
  842. k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
  843. /* Oops */
  844. if (!k_idx) return;
  845. /* Create the artifact */
  846. object_prep(i_ptr, k_idx, a_ptr->alloc_min, RANDOMISE);
  847. /* Save the name */
  848. i_ptr->name1 = a_idx;
  849. /* Extract the fields */
  850. i_ptr->pval = a_ptr->pval;
  851. i_ptr->ac = a_ptr->ac;
  852. i_ptr->dd = a_ptr->dd;
  853. i_ptr->ds = a_ptr->ds;
  854. i_ptr->to_a = a_ptr->to_a;
  855. i_ptr->to_h = a_ptr->to_h;
  856. i_ptr->to_d = a_ptr->to_d;
  857. i_ptr->weight = a_ptr->weight;
  858. /* Hack -- extract the "cursed" flags */
  859. if (cursed_p(a_ptr))
  860. {
  861. bitflag curse_flags[OF_SIZE];
  862. of_copy(curse_flags, a_ptr->flags);
  863. flags_mask(curse_flags, OF_SIZE, OF_CURSE_MASK, FLAG_END);
  864. of_union(i_ptr->flags, curse_flags);
  865. }
  866. /* Mark that the artifact has been created. */
  867. a_ptr->created = TRUE;
  868. /* Mark as cheat */
  869. i_ptr->origin = ORIGIN_CHEAT;
  870. /* Drop the artifact from heaven */
  871. drop_near(i_ptr, 0, p_ptr->py, p_ptr->px, TRUE);
  872. /* All done */
  873. msg_print("Allocated.");
  874. }
  875. /*
  876. * Cure everything instantly
  877. */
  878. static void do_cmd_wiz_cure_all(void)
  879. {
  880. /* Remove curses */
  881. (void)remove_all_curse();
  882. /* Restore stats */
  883. (void)res_stat(A_STR);
  884. (void)res_stat(A_INT);
  885. (void)res_stat(A_WIS);
  886. (void)res_stat(A_CON);
  887. (void)res_stat(A_DEX);
  888. (void)res_stat(A_CHR);
  889. /* Restore the level */
  890. (void)restore_level();
  891. /* Heal the player */
  892. p_ptr->chp = p_get_mhp();
  893. p_ptr->chp_frac = 0;
  894. /* Restore mana */
  895. p_ptr->csp = p_get_msp();
  896. p_ptr->csp_frac = 0;
  897. /* Cure stuff */
  898. (void)clear_timed(TMD_BLIND, TRUE);
  899. (void)clear_timed(TMD_CONFUSED, TRUE);
  900. (void)clear_timed(TMD_POISONED, TRUE);
  901. (void)clear_timed(TMD_AFRAID, TRUE);
  902. (void)clear_timed(TMD_PARALYZED, TRUE);
  903. (void)clear_timed(TMD_IMAGE, TRUE);
  904. (void)clear_timed(TMD_STUN, TRUE);
  905. (void)clear_timed(TMD_CUT, TRUE);
  906. (void)clear_timed(TMD_SLOW, TRUE);
  907. (void)clear_timed(TMD_AMNESIA, TRUE);
  908. /* No longer hungry */
  909. (void)set_food(PY_FOOD_MAX - 1);
  910. /* Redraw everything */
  911. do_cmd_redraw();
  912. }
  913. /*
  914. * Go to any level
  915. */
  916. static void do_cmd_wiz_jump(void)
  917. {
  918. /* Ask for level */
  919. if (p_ptr->command_arg <= 0)
  920. {
  921. char ppp[80];
  922. char tmp_val[160];
  923. /* Prompt */
  924. strnfmt(ppp, sizeof(ppp), "Jump to level (0-%d): ", MAX_DEPTH-1);
  925. /* Default */
  926. strnfmt(tmp_val, sizeof(tmp_val), "%d", p_ptr->depth);
  927. /* Ask for a level */
  928. if (!get_string(ppp, tmp_val, 11)) return;
  929. /* Extract request */
  930. p_ptr->command_arg = atoi(tmp_val);
  931. }
  932. /* Paranoia */
  933. if (p_ptr->command_arg < 0) p_ptr->command_arg = 0;
  934. /* Paranoia */
  935. if (p_ptr->command_arg > MAX_DEPTH - 1) p_ptr->command_arg = MAX_DEPTH - 1;
  936. /* Accept request */
  937. msg_format("You jump to dungeon level %d.", p_ptr->command_arg);
  938. /* New depth */
  939. p_ptr->depth = p_ptr->command_arg;
  940. /* Leaving */
  941. p_ptr->leaving = TRUE;
  942. }
  943. /*
  944. * Become aware of a lot of objects
  945. */
  946. static void do_cmd_wiz_learn(void)
  947. {
  948. int i;
  949. object_type *i_ptr;
  950. object_type object_type_body;
  951. /* Scan every object */
  952. for (i = 1; i < z_info->k_max; i++)
  953. {
  954. object_kind *k_ptr = &k_info[i];
  955. /* Induce awareness */
  956. if (k_ptr->level <= p_ptr->command_arg)
  957. {
  958. /* Get local object */
  959. i_ptr = &object_type_body;
  960. /* Prepare object */
  961. object_prep(i_ptr, i, 0, MAXIMISE);
  962. /* Awareness */
  963. object_flavor_aware(i_ptr);
  964. }
  965. }
  966. }
  967. /*
  968. * Hack -- Rerate Hitpoints
  969. */
  970. static void do_cmd_rerate(void)
  971. {
  972. int min_value, max_value, i, percent;
  973. min_value = (PY_MAX_LEVEL * 3 * (p_curclass.hitdie - 1)) / 8;
  974. min_value += PY_MAX_LEVEL;
  975. max_value = (PY_MAX_LEVEL * 5 * (p_curclass.hitdie - 1)) / 8;
  976. max_value += PY_MAX_LEVEL;
  977. p_curclass.player_hp[0] = p_curclass.hitdie;
  978. /* Rerate */
  979. while (1)
  980. {
  981. /* Collect values */
  982. for (i = 1; i < PY_MAX_LEVEL; i++)
  983. {
  984. p_curclass.player_hp[i] = randint1(p_curclass.hitdie);
  985. p_curclass.player_hp[i] += p_curclass.player_hp[i - 1];
  986. }
  987. /* Legal values */
  988. if ((p_curclass.player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
  989. (p_curclass.player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
  990. }
  991. percent = (int)(((long)p_curclass.player_hp[PY_MAX_LEVEL - 1] * 200L) /
  992. (p_curclass.hitdie + ((PY_MAX_LEVEL - 1) * p_curclass.hitdie)));
  993. /* Update and redraw hitpoints */
  994. p_ptr->update |= (PU_HP);
  995. p_ptr->redraw |= (PR_HP);
  996. /* Handle stuff */
  997. handle_stuff();
  998. /* Message */
  999. msg_format("Current Life Rating is %d/100.", percent);
  1000. }
  1001. /*
  1002. * Summon some creatures
  1003. */
  1004. static void do_cmd_wiz_summon(int num)
  1005. {
  1006. int py = p_ptr->py;
  1007. int px = p_ptr->px;
  1008. int i;
  1009. for (i = 0; i < num; i++)
  1010. {
  1011. (void)summon_specific(py, px, p_ptr->depth, 0, 1);
  1012. }
  1013. }
  1014. /*
  1015. * Summon a creature of the specified type
  1016. *
  1017. * This function is rather dangerous XXX XXX XXX
  1018. */
  1019. static void do_cmd_wiz_named(int r_idx, bool slp)
  1020. {
  1021. int py = p_ptr->py;
  1022. int px = p_ptr->px;
  1023. int i, x, y;
  1024. /* Paranoia */
  1025. if (!r_idx) return;
  1026. if (r_idx >= z_info->r_max-1) return;
  1027. /* Try 10 times */
  1028. for (i = 0; i < 10; i++)
  1029. {
  1030. int d = 1;
  1031. /* Pick a location */
  1032. scatter(&y, &x, py, px, d, 0);
  1033. /* Require empty grids */
  1034. if (!cave_empty_bold(y, x)) continue;
  1035. /* Place it (allow groups) */
  1036. if (place_monster_aux(y, x, r_idx, slp, TRUE)) break;
  1037. }
  1038. }
  1039. /*
  1040. * Hack -- Delete all nearby monsters
  1041. */
  1042. static void do_cmd_wiz_zap(int d)
  1043. {
  1044. int i;
  1045. /* Banish everyone nearby */
  1046. for (i = 1; i < mon_max; i++)
  1047. {
  1048. monster_type *m_ptr = &mon_list[i];
  1049. /* Skip dead monsters */
  1050. if (!m_ptr->r_idx) continue;
  1051. /* Skip distant monsters */
  1052. if (m_ptr->cdis > d) continue;
  1053. /* Delete the monster */
  1054. delete_monster_idx(i);
  1055. }
  1056. /* Update monster list window */
  1057. p_ptr->redraw |= PR_MONLIST;
  1058. }
  1059. /*
  1060. * Un-hide all monsters
  1061. */
  1062. static void do_cmd_wiz_unhide(int d)
  1063. {
  1064. int i;
  1065. /* Process monsters */
  1066. for (i = 1; i < mon_max; i++)
  1067. {
  1068. monster_type *m_ptr = &mon_list[i];
  1069. /* Skip dead monsters */
  1070. if (!m_ptr->r_idx) continue;
  1071. /* Skip distant monsters */
  1072. if (m_ptr->cdis > d) continue;
  1073. /* Optimize -- Repair flags */
  1074. repair_mflag_mark = repair_mflag_show = TRUE;
  1075. /* Detect the monster */
  1076. m_ptr->mflag |= (MFLAG_MARK | MFLAG_SHOW);
  1077. /* Update the monster */
  1078. update_mon(i, FALSE);
  1079. }
  1080. }
  1081. /*
  1082. * Query the dungeon
  1083. */
  1084. static void do_cmd_wiz_query(void)
  1085. {
  1086. int py = p_ptr->py;
  1087. int px = p_ptr->px;
  1088. int y, x;
  1089. char cmd;
  1090. u16b mask = 0x00;
  1091. /* Get a "debug command" */
  1092. if (!get_com("Debug Command Query: ", &cmd)) return;
  1093. /* Extract a flag */
  1094. switch (cmd)
  1095. {
  1096. case '0': mask = (1 << 0); break;
  1097. case '1': mask = (1 << 1); break;
  1098. case '2': mask = (1 << 2); break;
  1099. case '3': mask = (1 << 3); break;
  1100. case '4': mask = (1 << 4); break;
  1101. case '5': mask = (1 << 5); break;
  1102. case '6': mask = (1 << 6); break;
  1103. case '7': mask = (1 << 7); break;
  1104. case 'm': mask |= (CAVE_MARK); break;
  1105. case 'g': mask |= (CAVE_GLOW); break;
  1106. case 'r': mask |= (CAVE_ROOM); break;
  1107. case 'i': mask |= (CAVE_ICKY); break;
  1108. case 's': mask |= (CAVE_SEEN); break;
  1109. case 'v': mask |= (CAVE_VIEW); break;
  1110. case 't': mask |= (CAVE_TEMP); break;
  1111. case 'w': mask |= (CAVE_WALL); break;
  1112. }
  1113. /* Scan map */
  1114. for (y = Term->offset_y; y < Term->offset_y + SCREEN_HGT; y++)
  1115. {
  1116. for (x = Term->offset_x; x < Term->offset_x + SCREEN_WID; x++)
  1117. {
  1118. byte a = TERM_RED;
  1119. if (!in_bounds_fully(y, x)) continue;
  1120. /* Given mask, show only those grids */
  1121. if (mask && !(cave_info[y][x] & mask)) continue;
  1122. /* Given no mask, show unknown grids */
  1123. if (!mask && (cave_info[y][x] & (CAVE_MARK))) continue;
  1124. /* Color */
  1125. if (cave_floor_bold(y, x)) a = TERM_YELLOW;
  1126. /* Display player/floors/walls */
  1127. if ((y == py) && (x == px))
  1128. {
  1129. print_rel('@', a, y, x);
  1130. }
  1131. else if (cave_floor_bold(y, x))
  1132. {
  1133. print_rel('*', a, y, x);
  1134. }
  1135. else
  1136. {
  1137. print_rel('#', a, y, x);
  1138. }
  1139. }
  1140. }
  1141. /* Get keypress */
  1142. msg_print("Press any key.");
  1143. message_flush();
  1144. /* Redraw map */
  1145. prt_map();
  1146. }
  1147. /*
  1148. * Create lots of items.
  1149. */
  1150. static void wiz_test_kind(int tval)
  1151. {
  1152. int py = p_ptr->py;
  1153. int px = p_ptr->px;
  1154. int sval;
  1155. object_type object_type_body;
  1156. object_type *i_ptr = &object_type_body;
  1157. for (sval = 0; sval < 255; sval++)
  1158. {
  1159. int k_idx = lookup_kind(tval, sval);
  1160. if (k_idx)
  1161. {
  1162. /* Create the item */
  1163. object_prep(i_ptr, k_idx, p_ptr->depth, RANDOMISE);
  1164. /* Apply magic (no messages, no artifacts) */
  1165. apply_magic(i_ptr, p_ptr->depth, FALSE, FALSE, FALSE);
  1166. /* Mark as cheat, and where created */
  1167. i_ptr->origin = ORIGIN_CHEAT;
  1168. i_ptr->origin_depth = p_ptr->depth;
  1169. if (k_info[k_idx].tval == TV_GOLD)
  1170. make_gold(i_ptr, p_ptr->depth, sval);
  1171. /* Drop the object from heaven */
  1172. drop_near(i_ptr, 0, py, px, TRUE);
  1173. }
  1174. }
  1175. msg_print("Done.");
  1176. }
  1177. /*
  1178. * Display the debug commands help file.
  1179. */
  1180. static void do_cmd_wiz_help(void)
  1181. {
  1182. char buf[80];
  1183. strnfmt(buf, sizeof(buf), "debug.txt");
  1184. screen_save();
  1185. show_file(buf, NULL, 0, 0);
  1186. screen_load();
  1187. }
  1188. /*
  1189. * Ask for and parse a "debug command"
  1190. *
  1191. * The "p_ptr->command_arg" may have been set.
  1192. */
  1193. void do_cmd_debug(void)
  1194. {
  1195. int py = p_ptr->py;
  1196. int px = p_ptr->px;
  1197. char cmd;
  1198. /* Get a "debug command" */
  1199. if (!get_com("Debug Command: ", &cmd)) return;
  1200. /* Analyze the command */
  1201. switch (cmd)
  1202. {
  1203. /* Ignore */
  1204. case ESCAPE:
  1205. case ' ':
  1206. case '\n':
  1207. case '\r':
  1208. {
  1209. break;
  1210. }
  1211. #ifdef ALLOW_SPOILERS
  1212. /* Hack -- Generate Spoilers */
  1213. case '"':
  1214. {
  1215. do_cmd_spoilers();
  1216. break;
  1217. }
  1218. #endif
  1219. /* Hack -- Help */
  1220. case '?':
  1221. {
  1222. do_cmd_wiz_help();
  1223. break;
  1224. }
  1225. /* Cure all maladies */
  1226. case 'a':
  1227. {
  1228. do_cmd_wiz_cure_all();
  1229. break;
  1230. }
  1231. /* Teleport to target */
  1232. case 'b':
  1233. {
  1234. do_cmd_wiz_bamf();
  1235. break;
  1236. }
  1237. /* Create any object */
  1238. case 'c':
  1239. {
  1240. wiz_create_item();
  1241. break;
  1242. }
  1243. /* Create an artifact */
  1244. case 'C':
  1245. {
  1246. if (p_ptr->command_arg > 0)
  1247. {
  1248. wiz_create_artifact(p_ptr->command_arg);
  1249. }
  1250. else
  1251. {
  1252. char name[80] = "";
  1253. int a_idx = -1;
  1254. /* Avoid the prompt getting in the way */
  1255. screen_save();
  1256. /* Prompt */
  1257. prt("Create which artifact? ", 0, 0);
  1258. /* Get the name */
  1259. if (askfor_aux(name, sizeof(name), NULL))
  1260. {
  1261. /* See if an a_idx was entered */
  1262. a_idx = get_idx_from_name(name);
  1263. /* If not, find the artifact with that name */
  1264. if (a_idx < 1)
  1265. a_idx = lookup_artifact_name(name);
  1266. /* Did we find a valid artifact? */
  1267. if (a_idx != -1)
  1268. wiz_create_artifact(a_idx);
  1269. }
  1270. /* Reload the screen */
  1271. screen_load();
  1272. }
  1273. break;
  1274. }
  1275. /* Detect everything */
  1276. case 'd':
  1277. {
  1278. detect_all(TRUE);
  1279. break;
  1280. }
  1281. /* Edit character */
  1282. case 'e':
  1283. {
  1284. do_cmd_wiz_change();
  1285. break;
  1286. }
  1287. case 'f':
  1288. {
  1289. stats_collect();
  1290. break;
  1291. }
  1292. /* Good Objects */
  1293. case 'g':
  1294. {
  1295. if (p_ptr->command_arg <= 0) p_ptr->command_arg = 1;
  1296. acquirement(py, px, p_ptr->depth, p_ptr->command_arg, FALSE);
  1297. break;
  1298. }
  1299. /* Hitpoint rerating */
  1300. case 'h':
  1301. {
  1302. do_cmd_rerate();
  1303. break;
  1304. }
  1305. /* Identify */
  1306. case 'i':
  1307. {
  1308. (void)ident_spell();
  1309. break;
  1310. }
  1311. /* Go up or down in the dungeon */
  1312. case 'j':
  1313. {
  1314. do_cmd_wiz_jump();
  1315. break;
  1316. }
  1317. /* Learn about objects */
  1318. case 'l':
  1319. {
  1320. do_cmd_wiz_learn();
  1321. break;
  1322. }
  1323. /* Magic Mapping */
  1324. case 'm':
  1325. {
  1326. map_area();
  1327. break;
  1328. }
  1329. /* Summon Named Monster */
  1330. case 'n':
  1331. {
  1332. if (p_ptr->command_arg > 0)
  1333. {
  1334. do_cmd_wiz_named(p_ptr->command_arg, TRUE);
  1335. }
  1336. else
  1337. {
  1338. char name[80] = "";
  1339. s16b r_idx;
  1340. /* Avoid the prompt getting in the way */
  1341. screen_save();
  1342. /* Prompt */
  1343. prt("Summon which monster? ", 0, 0);
  1344. /* Get the name */
  1345. if (askfor_aux(name, sizeof(name), NULL))
  1346. {
  1347. /* See if a r_idx was entered */
  1348. r_idx = get_idx_from_name(name);
  1349. /* If not, find the monster with that name */
  1350. if (r_idx < 1)
  1351. r_idx = lookup_monster(name);
  1352. /* Did we find a valid monster? */
  1353. if (r_idx != -1)
  1354. do_cmd_wiz_named(r_idx, TRUE);
  1355. }
  1356. p_ptr->redraw |= (PR_MAP | PR_MONLIST);
  1357. /* Reload the screen */
  1358. screen_load();
  1359. }
  1360. break;
  1361. }
  1362. /* Object playing routines */
  1363. case 'o':
  1364. {
  1365. do_cmd_wiz_play();
  1366. break;
  1367. }
  1368. /* Phase Door */
  1369. case 'p':
  1370. {
  1371. teleport_player(10);
  1372. break;
  1373. }
  1374. /* Query the dungeon */
  1375. case 'q':
  1376. {
  1377. do_cmd_wiz_query();
  1378. break;
  1379. }
  1380. /* Summon Random Monster(s) */
  1381. case 's':
  1382. {
  1383. if (p_ptr->command_arg <= 0) p_ptr->command_arg = 1;
  1384. do_cmd_wiz_summon(p_ptr->command_arg);
  1385. break;
  1386. }
  1387. /* Teleport */
  1388. case 't':
  1389. {
  1390. teleport_player(100);
  1391. break;
  1392. }
  1393. /* Create a trap */
  1394. case 'T':
  1395. {
  1396. cave_set_feat(p_ptr->py, p_ptr->px, FEAT_INVIS);
  1397. break;
  1398. }
  1399. /* Un-hide all monsters */
  1400. case 'u':
  1401. {
  1402. if (p_ptr->command_arg <= 0) p_ptr->command_arg = 255;
  1403. do_cmd_wiz_unhide(p_ptr->command_arg);
  1404. break;
  1405. }
  1406. /* Very Good Objects */
  1407. case 'v':
  1408. {
  1409. if (p_ptr->command_arg <= 0) p_ptr->command_arg = 1;
  1410. acquirement(py, px, p_ptr->depth, p_ptr->command_arg, TRUE);
  1411. break;
  1412. }
  1413. case 'V':
  1414. {
  1415. wiz_test_kind(p_ptr->command_arg);
  1416. break;
  1417. }
  1418. /* Wizard Light the Level */
  1419. case 'w':
  1420. {
  1421. wiz_light();
  1422. break;
  1423. }
  1424. /* Increase Experience */
  1425. case 'x':
  1426. {
  1427. if (p_ptr->command_arg)
  1428. {
  1429. gain_exp(p_ptr->command_arg);
  1430. }
  1431. else
  1432. {
  1433. gain_exp(p_curclass.exp + 1);
  1434. }
  1435. break;
  1436. }
  1437. /* Zap Monsters (Banishment) */
  1438. case 'z':
  1439. {
  1440. if (p_ptr->command_arg <= 0) p_ptr->command_arg = MAX_SIGHT;
  1441. do_cmd_wiz_zap(p_ptr->command_arg);
  1442. break;
  1443. }
  1444. /* Hack */
  1445. case '_':
  1446. {
  1447. do_cmd_wiz_hack_ben();
  1448. break;
  1449. }
  1450. /* Oops */
  1451. default:
  1452. {
  1453. msg_print("That is not a valid debug command.");
  1454. break;
  1455. }
  1456. }
  1457. }
  1458. #endif