Changeset 526
- Timestamp:
- 08/15/07 14:10:49 (1 year ago)
- Files:
-
- trunk/src/cmd-obj.c (added)
- trunk/src/cmd0.c (modified) (3 diffs)
- trunk/src/cmd2.c (modified) (1 diff)
- trunk/src/cmd3.c (modified) (6 diffs)
- trunk/src/cmd5.c (modified) (11 diffs)
- trunk/src/cmd6.c (modified) (3 diffs)
- trunk/src/cmds.h (modified) (3 diffs)
- trunk/src/externs.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cmd0.c
r399 r526 38 38 /* Forward declare these, because they're really defined later */ 39 39 static do_cmd_type do_cmd_wizard, do_cmd_try_debug, 40 do_cmd_ cast_or_pray, do_cmd_quit, do_cmd_mouseclick, do_cmd_port,40 do_cmd_quit, do_cmd_mouseclick, do_cmd_port, 41 41 do_cmd_xxx_options, do_cmd_menu, do_cmd_monlist; 42 42 … … 61 61 { "Gain new spells or prayers", 'G', do_cmd_study }, 62 62 { "Browse a book", 'b', do_cmd_browse }, 63 { "Cast a spell", 'm', do_cmd_cast _or_pray},64 { "Pray a prayer", 'p', do_cmd_ cast_or_pray }63 { "Cast a spell", 'm', do_cmd_cast }, 64 { "Pray a prayer", 'p', do_cmd_pray } 65 65 }; 66 66 … … 303 303 304 304 305 306 /*307 * Helper -- cast or pray, depending on the character.308 */309 static void do_cmd_cast_or_pray(void)310 {311 if (cp_ptr->spell_book == TV_PRAYER_BOOK)312 do_cmd_pray();313 else314 do_cmd_cast();315 }316 317 318 305 /* 319 306 * Quit the game. trunk/src/cmd2.c
r507 r526 2326 2326 Term_fresh(); 2327 2327 } 2328 2329 2330 2331 /*2332 * See if one can squelch a given kind of item.2333 */2334 static bool squelchable_hook(const object_type *o_ptr)2335 {2336 object_kind *k_ptr = &k_info[o_ptr->k_idx];2337 2338 /* No point in double-squelching things */2339 if (k_ptr->squelch) return FALSE;2340 2341 /* Don't squelch bad tvals */2342 if (!squelch_tval(o_ptr->tval)) return FALSE;2343 2344 /* Only allow if aware */2345 return object_aware_p(o_ptr);2346 }2347 2348 2349 2350 /*2351 * Mark item as "squelch".2352 */2353 void do_cmd_mark_squelch()2354 {2355 const char *q = "Squelch which item kind? ";2356 const char *s = "You have nothing you can squelch.";2357 2358 object_type *o_ptr;2359 object_kind *k_ptr;2360 int item;2361 2362 /* Get an item */2363 item_tester_hook = squelchable_hook;2364 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;2365 2366 /* Get the object */2367 if (item >= 0)2368 o_ptr = &inventory[item];2369 else2370 o_ptr = &o_list[0 - item];2371 2372 /* Get object kind */2373 k_ptr = &k_info[o_ptr->k_idx];2374 2375 /* Set squelch flag */2376 k_ptr->squelch = TRUE;2377 }trunk/src/cmd3.c
r522 r526 109 109 110 110 /* 111 * The "wearable" tester112 */113 static bool item_tester_hook_wear(const object_type *o_ptr)114 {115 /* Check for a usable slot */116 if (wield_slot(o_ptr) >= INVEN_WIELD) return (TRUE);117 118 /* Assume not wearable */119 return (FALSE);120 }121 122 123 /*124 111 * Wield or wear a single item from the pack or floor 125 112 */ 126 void do_cmd_wield(void) 127 { 128 int item, slot; 129 130 object_type *o_ptr; 131 132 object_type *i_ptr; 113 void wield_item(object_type *o_ptr, int item) 114 { 133 115 object_type object_type_body; 134 135 object_type *equip_o_ptr; 116 object_type *i_ptr = &object_type_body; 136 117 137 118 cptr act; 138 139 cptr q, s;140 141 119 char o_name[80]; 142 char out_val[160]; 143 144 145 /* Restrict the choices */ 146 item_tester_hook = item_tester_hook_wear; 147 148 /* Get an item */ 149 q = "Wear/Wield which item? "; 150 s = "You have nothing you can wear or wield."; 151 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; 152 153 /* Get the item (in the pack) */ 154 if (item >= 0) 155 { 156 o_ptr = &inventory[item]; 157 } 158 159 /* Get the item (on the floor) */ 160 else 161 { 162 o_ptr = &o_list[0 - item]; 163 } 164 165 166 /* Check the slot */ 167 slot = wield_slot(o_ptr); 168 169 /* Get a pointer to the slot to be removed */ 170 equip_o_ptr = &inventory[slot]; 171 172 /* Prevent wielding into a cursed slot */ 173 if (cursed_p(equip_o_ptr)) 174 { 175 /* Describe it */ 176 object_desc(o_name, sizeof(o_name), equip_o_ptr, FALSE, 0); 177 178 /* Message */ 179 msg_format("The %s you are %s appears to be cursed.", 180 o_name, describe_use(slot)); 181 182 /* Cancel the command */ 183 return; 184 } 185 186 /* Double-check taking off an item with "!t" */ 187 if (equip_o_ptr->note) 188 { 189 /* Find a '!' */ 190 s = strchr(quark_str(equip_o_ptr->note), '!'); 191 192 /* Process preventions */ 193 /* XXX Perhaps this should be factored out to a separate function? */ 194 while (s) 195 { 196 /* Check the "restriction" */ 197 if (s[1] == 't') 198 { 199 /* Describe it */ 200 object_desc(o_name, sizeof(o_name), equip_o_ptr, TRUE, 3); 201 202 /* Prompt */ 203 strnfmt(out_val, sizeof(out_val), "Really take off %s? ", o_name); 204 205 /* Forget it */ 206 if (!get_check(out_val)) return; 207 } 208 209 /* Find another '!' */ 210 s = strchr(s + 1, '!'); 211 } 212 } 120 121 int slot = wield_slot(o_ptr); 213 122 214 123 /* Take a turn */ 215 124 p_ptr->energy_use = 100; 216 125 217 /* Get local object */218 i_ptr = &object_type_body;219 220 126 /* Obtain local object */ 221 127 object_copy(i_ptr, o_ptr); … … 259 165 /* Where is the item now */ 260 166 if (slot == INVEN_WIELD) 261 {262 167 act = "You are wielding"; 263 }264 168 else if (slot == INVEN_BOW) 265 {266 169 act = "You are shooting with"; 267 }268 170 else if (slot == INVEN_LITE) 269 {270 171 act = "Your light source is"; 271 } 272 else 273 { 172 else 274 173 act = "You are wearing"; 275 }276 174 277 175 /* Describe the result */ … … 302 200 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA); 303 201 p_ptr->redraw |= (PR_INVEN | PR_EQUIP); 304 }305 306 307 308 /*309 * Take off an item310 */311 void do_cmd_takeoff(void)312 {313 int item;314 315 object_type *o_ptr;316 317 cptr q, s;318 319 320 /* Get an item */321 q = "Take off which item? ";322 s = "You are not wearing anything to take off.";323 if (!get_item(&item, q, s, (USE_EQUIP))) return;324 325 /* Get the item (in the pack) */326 if (item >= 0)327 {328 o_ptr = &inventory[item];329 }330 331 /* Get the item (on the floor) */332 else333 {334 o_ptr = &o_list[0 - item];335 }336 337 338 /* Item is cursed */339 if (cursed_p(o_ptr))340 {341 /* Oops */342 msg_print("Hmmm, it seems to be cursed.");343 344 /* Nope */345 return;346 }347 348 349 /* Take a partial turn */350 p_ptr->energy_use = 50;351 352 /* Take off the item */353 (void)inven_takeoff(item, 255);354 }355 356 357 /*358 * Drop an item359 */360 void do_cmd_drop(void)361 {362 int item, amt;363 364 object_type *o_ptr;365 366 cptr q, s;367 368 369 /* Get an item */370 q = "Drop which item? ";371 s = "You have nothing to drop.";372 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;373 374 /* Get the item (in the pack) */375 if (item >= 0)376 {377 o_ptr = &inventory[item];378 }379 380 /* Get the item (on the floor) */381 else382 {383 o_ptr = &o_list[0 - item];384 }385 386 /* Get a quantity */387 amt = get_quantity(NULL, o_ptr->number);388 389 /* Allow user abort */390 if (amt <= 0) return;391 392 /* Hack -- Cannot remove cursed items */393 if ((item >= INVEN_WIELD) && cursed_p(o_ptr))394 {395 /* Oops */396 msg_print("Hmmm, it seems to be cursed.");397 398 /* Nope */399 return;400 }401 402 /* Take a partial turn */403 p_ptr->energy_use = 50;404 405 /* Drop (some of) the item */406 inven_drop(item, amt);407 202 } 408 203 … … 553 348 554 349 555 /* 556 * Observe an item, displaying what is known about it 557 */ 558 void do_cmd_observe(void) 559 { 560 int item; 561 562 object_type *o_ptr; 563 564 cptr q, s; 565 566 567 /* Get an item */ 568 q = "Examine which item? "; 569 s = "You have nothing to examine."; 570 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return; 571 572 /* Get the item (in the pack) */ 573 if (item >= 0) 574 { 575 o_ptr = &inventory[item]; 576 } 577 578 /* Get the item (on the floor) */ 579 else 580 { 581 o_ptr = &o_list[0 - item]; 582 } 583 584 /* Describe */ 585 object_info_screen(o_ptr); 586 } 587 588 589 /* 590 * Return whether the item has an inscription. 591 */ 592 static bool item_has_inscription(const object_type *o_ptr) 593 { 594 return (o_ptr->note ? TRUE : FALSE); 595 } 596 597 598 /* 599 * Remove the inscription from an object 600 * XXX Mention item (when done)? 601 */ 602 void do_cmd_uninscribe(void) 603 { 604 int item; 605 606 object_type *o_ptr; 607 608 cptr q, s; 609 610 611 /* Get an item */ 612 q = "Un-inscribe which item? "; 613 s = "You have nothing to un-inscribe."; 614 item_tester_hook = item_has_inscription; 615 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return; 616 617 /* Get the item (in the pack) */ 618 if (item >= 0) 619 { 620 o_ptr = &inventory[item]; 621 } 622 623 /* Get the item (on the floor) */ 624 else 625 { 626 o_ptr = &o_list[0 - item]; 627 } 628 629 /* Nothing to remove */ 630 if (!o_ptr->note) 631 { 632 msg_print("That item had no inscription to remove."); 633 return; 634 } 635 636 /* Message */ 637 msg_print("Inscription removed."); 638 639 /* Remove the inscription */ 640 o_ptr->note = 0; 641 642 /* Combine the pack, check for squelchables */ 643 p_ptr->notice |= (PN_COMBINE | PN_SQUELCH); 644 645 /* Redraw stuff */ 646 p_ptr->redraw |= (PR_INVEN | PR_EQUIP); 647 } 648 649 650 /* 651 * Inscribe an object with a comment 652 */ 653 void do_cmd_inscribe(void) 654 { 655 int item; 656 657 object_type *o_ptr; 658 659 char o_name[80]; 660 661 char tmp[80]; 662 663 cptr q, s; 664 665 666 /* Get an item */ 667 q = "Inscribe which item? "; 668 s = "You have nothing to inscribe."; 669 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return; 670 671 /* Get the item (in the pack) */ 672 if (item >= 0) 673 { 674 o_ptr = &inventory[item]; 675 } 676 677 /* Get the item (on the floor) */ 678 else 679 { 680 o_ptr = &o_list[0 - item]; 681 } 682 683 /* Describe the activity */ 684 object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); 685 686 /* Message */ 687 msg_format("Inscribing %s.", o_name); 688 message_flush(); 689 690 /* Start with nothing */ 691 tmp[0] = '\0'; 692 693 /* Use old inscription */ 694 if (o_ptr->note) 695 { 696 /* Start with the old inscription */ 697 strnfmt(tmp, sizeof(tmp), "%s", quark_str(o_ptr->note)); 698 } 699 700 /* Get a new inscription (possibly empty) */ 701 if (get_string("Inscription: ", tmp, sizeof(tmp))) 702 { 703 /* Save the inscription */ 704 o_ptr->note = quark_add(tmp); 705 706 /* Combine the pack, check for squelchables */ 707 p_ptr->notice |= (PN_COMBINE | PN_SQUELCH); 708 709 /* Redraw stuff */ 710 p_ptr->redraw |= (PR_INVEN | PR_EQUIP); 711 } 712 } 713 714 715 716 /* 717 * An "item_tester_hook" for refilling lanterns 718 */ 719 static bool item_tester_refill_lantern(const object_type *o_ptr) 720 { 721 u32b f1, f2, f3; 722 723 /* Get flags */ 724 object_flags(o_ptr, &f1, &f2, &f3); 725 726 /* Flasks of oil are okay */ 727 if (o_ptr->tval == TV_FLASK) return (TRUE); 728 729 /* Non-empty, non-everburning lanterns are okay */ 730 if ((o_ptr->tval == TV_LITE) && 731 (o_ptr->sval == SV_LITE_LANTERN) && 732 (o_ptr->timeout > 0) && 733 !(f3 & TR3_NO_FUEL)) 734 { 735 return (TRUE); 736 } 737 738 /* Assume not okay */ 739 return (FALSE); 740 } 741 742 743 /* 744 * Refill the players lamp (from the pack or floor) 745 */ 746 static void do_cmd_refill_lamp(void) 747 { 748 int item; 749 750 object_type *o_ptr; 751 object_type *j_ptr; 752 753 cptr q, s; 754 755 756 /* Restrict the choices */ 757 item_tester_hook = item_tester_refill_lantern; 758 759 /* Get an item */ 760 q = "Refill with which source of oil? "; 761 s = "You have no sources of oil."; 762 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; 763 764 /* Get the item (in the pack) */ 765 if (item >= 0) 766 { 767 o_ptr = &inventory[item]; 768 } 769 770 /* Get the item (on the floor) */ 771 else 772 { 773 o_ptr = &o_list[0 - item]; 774 } 775 776 777 /* Take a partial turn */ 778 p_ptr->energy_use = 50; 779 780 /* Get the lantern */ 781 j_ptr = &inventory[INVEN_LITE]; 782 350 351 352 void refill_lamp(object_type *j_ptr, object_type *o_ptr, int item) 353 { 783 354 /* Refuel */ 784 355 j_ptr->timeout += o_ptr->timeout ? o_ptr->timeout : o_ptr->pval; … … 868 439 869 440 870 871 /* 872 * An "item_tester_hook" for refilling torches 873 */ 874 static bool item_tester_refill_torch(const object_type *o_ptr) 875 { 876 u32b f1, f2, f3; 877 878 /* Get flags */ 879 object_flags(o_ptr, &f1, &f2, &f3); 880 881 /* Torches are okay */ 882 if ((o_ptr->tval == TV_LITE) && 883 (o_ptr->sval == SV_LITE_TORCH) && 884 !(f3 & TR3_NO_FUEL)) 885 { 886 return (TRUE); 887 } 888 889 /* Assume not okay */ 890 return (FALSE); 891 } 892 893 894 /* 895 * Refuel the players torch (from the pack or floor) 896 */ 897 static void do_cmd_refill_torch(void) 898 { 899 int item; 900 901 object_type *o_ptr; 902 object_type *j_ptr; 903 904 cptr q, s; 905 906 907 /* Restrict the choices */ 908 item_tester_hook = item_tester_refill_torch; 909 910 /* Get an item */ 911 q = "Refuel with which torch? "; 912 s = "You have no extra torches."; 913 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; 914 915 /* Get the item (in the pack) */ 916 if (item >= 0) 917 { 918 o_ptr = &inventory[item]; 919 } 920 921 /* Get the item (on the floor) */ 922 else 923 { 924 o_ptr = &o_list[0 - item]; 925 } 926 927 928 /* Take a partial turn */ 929 p_ptr->energy_use = 50; 930 931 /* Get the primary torch */ 932 j_ptr = &inventory[INVEN_LITE]; 933 441 void refuel_torch(object_type *j_ptr, object_type *o_ptr, int item) 442 { 934 443 /* Refuel */ 935 444 j_ptr->timeout += o_ptr->timeout + 5; … … 972 481 /* Redraw stuff */ 973 482 p_ptr->redraw |= (PR_EQUIP); 974 }975 976 977 978 979 /*980 * Refill the players lamp, or restock his torches981 */982 void do_cmd_refill(void)983 {984 object_type *o_ptr;985 u32b f1, f2, f3;986 987 /* Get the light */988 o_ptr = &inventory[INVEN_LITE];989 990 /* Get flags */991 object_flags(o_ptr, &f1, &f2, &f3);992 993 994 /* It is nothing */995 if (o_ptr->tval != TV_LITE)996 {997 msg_print("You are not wielding a light.");998 }999 1000 else if (!(f3 & TR3_NO_FUEL))1001 {1002 /* It's a lamp */1003 if (o_ptr->sval == SV_LITE_LANTERN)1004 {1005 do_cmd_refill_lamp();1006 }1007 1008 /* It's a torch */1009 else if (o_ptr->sval == SV_LITE_TORCH)1010 {1011 do_cmd_refill_torch();1012 }1013 }1014 1015 /* No torch to refill */1016 else1017 {1018 msg_print("Your light cannot be refilled.");1019 }1020 483 } 1021 484 trunk/src/cmd5.c
r522 r526 125 125 * Print a list of spells (for browsing or casting or viewing). 126 126 */ 127 void print_spells(const byte *spells, int num, int y, int x)127 static void print_spells(const byte *spells, int num, int y, int x) 128 128 { 129 129 int i, spell; … … 206 206 207 207 /* 208 * Hack -- display an object kind in the current window209 *210 * Include list of usable spells for readible books211 */212 void display_koff(int k_idx)213 {214 int y;215 216 object_type *i_ptr;217 object_type object_type_body;218 219 char o_name[80];220 221 222 /* Erase the window */223 for (y = 0; y < Term->hgt; y++)224 {225 /* Erase the line */226 Term_erase(0, y, 255);227 }228 229 /* No info */230 if (!k_idx) return;231 232 233 /* Get local object */234 i_ptr = &object_type_body;235 236 /* Prepare the object */237 object_wipe(i_ptr);238 239 /* Prepare the object */240 object_prep(i_ptr, k_idx);241 242 243 /* Describe */244 object_desc_spoil(o_name, sizeof(o_name), i_ptr, FALSE, 0);245 246 /* Mention the object name */247 Term_putstr(0, 0, -1, TERM_WHITE, o_name);248 249 250 /* Warriors are illiterate */251 if (!cp_ptr->spell_book) return;252 253 /* Display spells in readible books */254 if (i_ptr->tval == cp_ptr->spell_book)255 {256 int i;257 int spell;258 int num = 0;259 260 byte spells[PY_MAX_SPELLS];261 262 263 /* Extract spells */264 for (i = 0; i < SPELLS_PER_BOOK; i++)265 {266 spell = get_spell_index(i_ptr, i);267 268 /* Collect this spell */269 if (spell >= 0) spells[num++] = spell;270 }271 272 /* Print spells */273 print_spells(spells, num, 2, 0);274 }275 }276 277 278 279 /*280 208 * Allow user to choose a spell/prayer from the given book. 281 209 * … … 288 216 * The "browse" should be TRUE for browse, FALSE for cast/pray/study 289 217 */ 290 staticint get_spell(const object_type *o_ptr, cptr prompt, bool known, bool browse)218 int get_spell(const object_type *o_ptr, cptr prompt, bool known, bool browse) 291 219 { 292 220 int i; … … 587 515 588 516 /* 589 * Peruse the spells/prayers in a Book 590 * 591 * Note that *all* spells in the book are listed 592 * 593 * Note that browsing is allowed while confused or blind, 594 * and in the dark, primarily to allow browsing in stores. 595 */ 596 void do_cmd_browse(void) 597 { 598 int item; 599 600 object_type *o_ptr; 601 602 cptr q, s; 603 604 605 /* Warriors are illiterate */ 606 if (!cp_ptr->spell_book) 607 { 608 msg_print("You cannot read books!"); 609 return; 610 } 611 612 /* Restrict choices to "useful" books */ 613 item_tester_tval = cp_ptr->spell_book; 614 615 /* Get an item */ 616 q = "Browse which book? "; 617 s = "You have no books that you can read."; 618 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; 619 620 /* Get the item (in the pack) */ 621 if (item >= 0) 622 { 623 o_ptr = &inventory[item]; 624 } 625 626 /* Get the item (on the floor) */ 627 else 628 { 629 o_ptr = &o_list[0 - item]; 630 } 631 632 /* Browse the book */ 633 do_cmd_browse_aux(o_ptr); 634 } 635 636 637 638 639 /* 640 * Study a book to gain a new spell/prayer 641 */ 642 void do_cmd_study(void) 643 { 644 int i, item; 645 646 int spell; 647 517 * Choose a new spell from the book. 518 */ 519 int spell_choose_new(const object_type *o_ptr) 520 { 521 int i, k = 0; 522 int gift = -1; 523 648 524 cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "spell" : "prayer"); 649 650 cptr q, s;651 652 object_type *o_ptr;653 654 655 if (!cp_ptr->spell_book)656 {657 msg_print("You cannot read books!");658 return;659 }660 661 if (p_ptr->timed[TMD_BLIND] || no_lite())662 {663 msg_print("You cannot see!");664 return;665 }666 667 if (p_ptr->timed[TMD_CONFUSED])668 {669 msg_print("You are too confused!");670 return;671 }672 673 if (!(p_ptr->new_spells))674 {675 msg_format("You cannot learn any new %ss!", p);676 return;677 }678 679 680 /* Restrict choices to "useful" books */681 item_tester_tval = cp_ptr->spell_book;682 683 /* Get an item */684 q = "Study which book? ";685 s = "You have no books that you can read.";686 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;687 688 /* Get the item (in the pack) */689 if (item >= 0)690 {691 o_ptr = &inventory[item];692 }693 694 /* Get the item (on the floor) */695 else696 {697 o_ptr = &o_list[0 - item];698 }699 700 701 /* Track the object kind */702 object_kind_track(o_ptr->k_idx);703 704 /* Hack -- Handle stuff */705 handle_stuff();706 707 525 708 526 /* Mage -- Learn a selected spell */ 709 527 if (cp_ptr->flags & CF_CHOOSE_SPELLS) 710 528 { 711 /* Ask for a spell */ 712 spell = get_spell(o_ptr, "study", FALSE, FALSE); 713 714 /* Allow cancel */ 715 if (spell == -1) return; 716 } 717 else 718 { 719 int k = 0; 720 721 int gift = -1; 722 723 /* Extract spells */ 724 for (i = 0; i < SPELLS_PER_BOOK; i++) 725 { 726 spell = get_spell_index(o_ptr, i); 727 728 /* Skip empty spells */ 729 if (spell == -1) continue; 730 731 /* Skip non "okay" prayers */ 732 if (!spell_okay(spell, FALSE, FALSE)) continue; 733 734 /* Apply the randomizer */ 735 if ((++k > 1) && (rand_int(k) != 0)) continue; 736 737 /* Track it */ 738 gift = spell; 739 } 740 741 /* Accept gift */ 742 spell = gift; 529 return get_spell(o_ptr, "study", FALSE, FALSE); 530 } 531 532 /* Extract spells */ 533 for (i = 0; i < SPELLS_PER_BOOK; i++) 534 { 535 int spell = get_spell_index(o_ptr, i); 536 537 /* Skip non-OK spells */ 538 if (spell == -1) continue; 539 if (!spell_okay(spell, FALSE, FALSE)) continue; 540 541 /* Apply the randomizer */ 542 if ((++k > 1) && (rand_int(k) != 0)) continue; 543 544 /* Track it */ 545 gift = spell; 743 546 } 744 547 745 548 /* Nothing to study */ 746 if (spell < 0) 747 { 748 /* Message */ 549 if (gift < 0) 749 550 msg_format("You cannot learn any %ss in that book.", p); 750 551 751 /* Abort */ 752 return; 753 } 754 755 756 /* Take a turn */ 757 p_ptr->energy_use = 100; 552 return gift; 553 } 554 555 /* 556 * Learn the specified spell. 557 */ 558 void spell_learn(int spell) 559 { 560 int i; 561 cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "spell" : "prayer"); 758 562 759 563 /* Learn the spell */ … … 787 591 /* Redraw Study Status */ 788 592 p_ptr->redraw |= (PR_STUDY | PR_OBJECT); 789 790 } 791 792 793 794 /* 795 * Cast a spell 796 */ 797 void do_cmd_cast(void) 798 { 799 int item, spell; 593 } 594 595 596 /* Cas the specified spell */ 597 bool spell_cast(int spell) 598 { 800 599 int chance; 801 802 object_type *o_ptr;803 804 600 const magic_type *s_ptr; 805 601 806 cptr q, s; 807 808 809 /* Require spell ability */ 810 if (cp_ptr->spell_book != TV_MAGIC_BOOK) 811 { 812 msg_print("You cannot cast spells!"); 813 return; 814 } 815 816 /* Require lite */ 817 if (p_ptr->timed[TMD_BLIND] || no_lite()) 818 { 819 msg_print("You cannot see!"); 820 return; 821 } 822 823 /* Not when confused */ 824 if (p_ptr->timed[TMD_CONFUSED]) 825 { 826 msg_print("You are too confused!"); 827 return; 828 } 829 830 831 /* Restrict choices to spell books */ 832 item_tester_tval = cp_ptr->spell_book; 833 834 /* Get an item */ 835 q = "Use which book? "; 836 s = "You have no spell books!"; 837 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; 838 839 /* Get the item (in the pack) */ 840 if (item >= 0) 841 { 842 o_ptr = &inventory[item]; 843 } 844 845 /* Get the item (on the floor) */ 846 else 847 { 848 o_ptr = &o_list[0 - item]; 849 } 850 851 852 /* Track the object kind */ 853 object_kind_track(o_ptr->k_idx); 854 855 /* Hack -- Handle stuff */ 856 handle_stuff(); 857 858 859 /* Ask for a spell */ 860 spell = get_spell(o_ptr, "cast", TRUE, FALSE); 861 862 if (spell < 0) 863 { 864 if (spell == -2) msg_print("You don't know any spells in that book."); 865 return; 866 } 602 cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? 603 "cast this spell" : 604 "recite this prayer"); 867 605 868 606 … … 875 613 { 876 614 /* Warning */ 877 msg_ print("You do not have enough mana to cast this spell.");615 msg_format("You do not have enough mana to %s.", p); 878 616 879 617 /* Flush input */ … … 881 619 882 620 /* Verify */ 883 if (!get_check("Attempt it anyway? ")) return ;621 if (!get_check("Attempt it anyway? ")) return FALSE; 884 622 } 885 623 … … 892 630 { 893 631 if (flush_failure) flush(); 894 msg_print("You failed to get the spell off!");632 msg_print("You failed to concentrate hard enough!"); 895 633 } 896 634 … … 899 637 { 900 638 /* Cast the spell */ 901 if (!cast_spell(cp_ptr->spell_book, spell)) return ;639 if (!cast_spell(cp_ptr->spell_book, spell)) return FALSE; 902 640 903 641 /* A spell was cast */ … … 918 656 } 919 657 920 /* Take a turn */921 p_ptr->energy_use = 100;922 923 658 /* Sufficient mana */ 924 659 if (s_ptr->smana <= p_ptr->csp) … … 958 693 /* Redraw mana */ 959 694 p_ptr->redraw |= (PR_MANA); 960 } 961 962 963 /* 964 * Pray a prayer 965 */ 966 void do_cmd_pray(void) 967 { 968 int item, spell, chance; 969
