Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cmd-obj.c
r1429 r1431 402 402 { 403 403 int spell; 404 const magic_type *s_ptr; 405 404 406 cptr verb = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "cast" : "recite"); 407 cptr noun = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "spell" : "prayer"); 405 408 406 409 /* Track the object kind */ … … 412 415 if (spell < 0) 413 416 { 414 cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "spell" : "prayer"); 415 416 if (spell == -2) msg_format("You don't know any %ss in that book.", p); 417 return; 418 } 419 420 cmd_insert(CMD_CAST, spell); 417 if (spell == -2) msg_format("You don't know any %ss in that book.", noun); 418 return; 419 } 420 421 /* Get the spell */ 422 s_ptr = &mp_ptr->info[spell]; 423 424 /* Verify "dangerous" spells */ 425 if (s_ptr->smana > p_ptr->csp) 426 { 427 /* Warning */ 428 msg_format("You do not have enough mana to %s this %s.", verb, noun); 429 430 /* Flush input */ 431 flush(); 432 433 /* Verify */ 434 if (!get_check("Attempt it anyway? ")) return; 435 } 436 437 cmd_insert(CMD_CAST, spell, DIR_UNKNOWN); 421 438 } 422 439 -
trunk/src/cmd5.c
r1426 r1431 583 583 { 584 584 int spell = args[0].choice; 585 int dir = args[1].direction; 585 586 586 587 int item_list[INVEN_TOTAL + MAX_FLOOR_STACK]; … … 606 607 { 607 608 /* Cast a spell */ 608 if (spell_cast(spell ))609 if (spell_cast(spell, dir)) 609 610 p_ptr->energy_use = 100; 610 611 } … … 714 715 715 716 /* Cas the specified spell */ 716 bool spell_cast(int spell )717 bool spell_cast(int spell, int dir) 717 718 { 718 719 int chance; 719 720 const magic_type *s_ptr; 720 721 721 cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ?722 "cast this spell" :723 "recite this prayer");724 725 726 /* Get the spell */727 s_ptr = &mp_ptr->info[spell];728 729 730 /* Verify "dangerous" spells */731 if (s_ptr->smana > p_ptr->csp)732 {733 /* Warning */734 msg_format("You do not have enough mana to %s.", p);735 736 /* Flush input */737 flush();738 739 /* Verify */740 if (!get_check("Attempt it anyway? ")) return FALSE;741 }742 743 744 722 /* Spell failure chance */ 745 723 chance = spell_chance(spell); … … 756 734 { 757 735 /* Cast the spell */ 758 if (!cast_spell(cp_ptr->spell_book, spell )) return FALSE;736 if (!cast_spell(cp_ptr->spell_book, spell, dir)) return FALSE; 759 737 760 738 /* A spell was cast */ -
trunk/src/externs.h
r1417 r1431 303 303 s16b spell_chance(int spell); 304 304 bool spell_okay(int spell, bool known, bool browse); 305 bool spell_cast(int spell );305 bool spell_cast(int spell, int dir); 306 306 void spell_learn(int spell); 307 307 … … 647 647 extern cptr get_spell_name(int tval, int index); 648 648 extern void get_spell_info(int tval, int index, char *buf, size_t len); 649 extern bool cast_spell(int tval, int index); 649 extern bool cast_spell(int tval, int index, int dir); 650 extern bool spell_needs_aim(int tval, int spell); 650 651 651 652 /* xtra2.c */ -
trunk/src/game-cmd.c
r1428 r1431 99 99 case CMD_REST: 100 100 case CMD_STUDY_SPELL: 101 case CMD_CAST:102 101 { 103 102 cmd.args[0].choice = va_arg(vp, int); … … 187 186 if (cmd.args[1].direction == DIR_UNKNOWN && 188 187 obj_needs_aim(object_from_item_idx(cmd.args[0].choice))) 188 { 189 if (!get_aim_dir(&cmd.args[1].direction)) 190 return 1; 191 } 192 193 break; 194 } 195 196 /* This takes a choice and a direction. */ 197 case CMD_CAST: 198 { 199 cmd.args[0].choice = va_arg(vp, int); 200 cmd.args[1].direction = va_arg(vp, int); 201 202 if (cmd.args[1].direction == DIR_UNKNOWN && 203 spell_needs_aim(cp_ptr->spell_book, cmd.args[0].choice)) 189 204 { 190 205 if (!get_aim_dir(&cmd.args[1].direction)) -
trunk/src/x-spell.c
r1392 r1431 421 421 422 422 423 424 static bool cast_mage_spell(int spell) 423 bool spell_needs_aim(int tval, int spell) 424 { 425 if (tval == TV_MAGIC_BOOK) 426 { 427 switch (spell) 428 { 429 case SPELL_MAGIC_MISSILE: 430 case SPELL_STINKING_CLOUD: 431 case SPELL_CONFUSE_MONSTER: 432 case SPELL_LIGHTNING_BOLT: 433 case SPELL_SLEEP_MONSTER: 434 case SPELL_SPEAR_OF_LIGHT: 435 case SPELL_FROST_BOLT: 436 case SPELL_TURN_STONE_TO_MUD: 437 case SPELL_WONDER: 438 case SPELL_POLYMORPH_OTHER: 439 case SPELL_FIRE_BOLT: 440 case SPELL_SLOW_MONSTER: 441 case SPELL_FROST_BALL: 442 case SPELL_TELEPORT_OTHER: 443 case SPELL_BEDLAM: 444 case SPELL_FIRE_BALL: 445 case SPELL_ACID_BOLT: 446 case SPELL_CLOUD_KILL: 447 case SPELL_ACID_BALL: 448 case SPELL_ICE_STORM: 449 case SPELL_METEOR_SWARM: 450 case SPELL_MANA_STORM: 451 case SPELL_SHOCK_WAVE: 452 case SPELL_EXPLOSION: 453 case SPELL_RIFT: 454 case SPELL_REND_SOUL: 455 case SPELL_CHAOS_STRIKE: 456 return TRUE; 457 458 default: 459 return FALSE; 460 } 461 } 462 else 463 { 464 switch (spell) 465 { 466 case PRAYER_SCARE_MONSTER: 467 case PRAYER_ORB_OF_DRAINING: 468 case PRAYER_ANNIHILATION: 469 case PRAYER_TELEPORT_OTHER: 470 return TRUE; 471 472 default: 473 return FALSE; 474 } 475 } 476 } 477 478 479 static bool cast_mage_spell(int spell, int dir) 425 480 { 426 481 int py = p_ptr->py; 427 482 int px = p_ptr->px; 428 429 int dir;430 483 431 484 int plev = p_ptr->lev; … … 439 492 case SPELL_MAGIC_MISSILE: 440 493 { 441 if (!get_aim_dir(&dir)) return (FALSE);442 494 fire_bolt_or_beam(beam-10, GF_MISSILE, dir, 443 495 damroll(3 + ((plev - 1) / 5), 4)); … … 488 540 case SPELL_STINKING_CLOUD: 489 541 { 490 if (!get_aim_dir(&dir)) return (FALSE);491 542 fire_ball(GF_POIS, dir, 10 + (plev / 2), 2); 492 543 break; … … 495 546 case SPELL_CONFUSE_MONSTER: 496 547 { 497 if (!get_aim_dir(&dir)) return (FALSE);498 548 (void)confuse_monster(dir, plev); 499 549 break; … … 502 552 case SPELL_LIGHTNING_BOLT: 503 553 { 504 if (!get_aim_dir(&dir)) return (FALSE); 505 fire_beam(GF_ELEC, dir, 506 damroll(3+((plev-5)/6), 6)); 554 fire_beam(GF_ELEC, dir, damroll(3+((plev-5)/6), 6)); 507 555 break; 508 556 } … … 516 564 case SPELL_SLEEP_MONSTER: 517 565 { 518 if (!get_aim_dir(&dir)) return (FALSE);519 566 (void)sleep_monster(dir); 520 567 break; … … 533 580 } 534 581 535 case SPELL_SPEAR_OF_LIGHT: /* spear of light */ 536 { 537 if (!get_aim_dir(&dir)) return (FALSE); 582 case SPELL_SPEAR_OF_LIGHT: 583 { 538 584 msg_print("A line of blue shimmering light appears."); 539 585 lite_line(dir); … … 543 589 case SPELL_FROST_BOLT: 544 590 { 545 if (!get_aim_dir(&dir)) return (FALSE);546 591 fire_bolt_or_beam(beam-10, GF_COLD, dir, 547 592 damroll(5+((plev-5)/4), 8)); … … 551 596 case SPELL_TURN_STONE_TO_MUD: 552 597 { 553 if (!get_aim_dir(&dir)) return (FALSE);554 598 (void)wall_to_mud(dir); 555 599 break; … … 567 611 } 568 612 569 case SPELL_WONDER: /* wonder */ 570 { 571 if (!get_aim_dir(&dir)) return (FALSE); 613 case SPELL_WONDER: 614 { 572 615 (void)spell_wonder(dir); 573 616 break; … … 576 619 case SPELL_POLYMORPH_OTHER: 577 620 { 578 if (!get_aim_dir(&dir)) return (FALSE);579 621 (void)poly_monster(dir); 580 622 break; … … 594 636 case SPELL_FIRE_BOLT: 595 637 { 596 if (!get_aim_dir(&dir)) return (FALSE);597 638 fire_bolt_or_beam(beam, GF_FIRE, dir, 598 639 damroll(6+((plev-5)/4), 8)); … … 602 643 case SPELL_SLOW_MONSTER: 603 644 { 604 if (!get_aim_dir(&dir)) return (FALSE);605 645 (void)slow_monster(dir); 606 646 break; … … 609 649 case SPELL_FROST_BALL: 610 650 { 611 if (!get_aim_dir(&dir)) return (FALSE);612 651 fire_ball(GF_COLD, dir, 30 + (plev), 2); 613 652 break; … … 621 660 case SPELL_TELEPORT_OTHER: 622 661 { 623 if (!get_aim_dir(&dir)) return (FALSE);624 662 (void)teleport_monster(dir); 625 663 break; … … 628 666 case SPELL_BEDLAM: 629 667 { 630 if (!get_aim_dir(&dir)) return (FALSE);631 668 fire_ball(GF_OLD_CONF, dir, plev, 4); 632 669 break; … … 635 672 case SPELL_FIRE_BALL: 636 673 { 637 if (!get_aim_dir(&dir)) return (FALSE);638 674 fire_ball(GF_FIRE, dir, 55 + (plev), 2); 639 675 break; … … 684 720 case SPELL_ACID_BOLT: 685 721 { 686 if (!get_aim_dir(&dir)) return (FALSE);687 722 fire_bolt_or_beam(beam, GF_ACID, dir, damroll(8+((plev-5)/4), 8)); 688 723 break; … … 691 726 case SPELL_CLOUD_KILL: 692 727 { 693 if (!get_aim_dir(&dir)) return (FALSE);694 728 fire_ball(GF_POIS, dir, 40 + (plev / 2), 3); 695 729 break; … … 698 732 case SPELL_ACID_BALL: 699 733 { 700 if (!get_aim_dir(&dir)) return (FALSE);701 734 fire_ball(GF_ACID, dir, 40 + (plev), 2); 702 735 break; … … 705 738 case SPELL_ICE_STORM: 706 739 { 707 if (!get_aim_dir(&dir)) return (FALSE);708 740 fire_ball(GF_ICE, dir, 50 + (plev * 2), 3); 709 741 break; … … 712 744 case SPELL_METEOR_SWARM: 713 745 { 714 if (!get_aim_dir(&dir)) return (FALSE);715 746 fire_swarm(2 + plev / 20, GF_METEOR, dir, 30 + plev / 2, 1); 716 747 break; … … 719 750 case SPELL_MANA_STORM: 720 751 { 721 if (!get_aim_dir(&dir)) return (FALSE);722 752 fire_ball(GF_MANA, dir, 300 + (plev * 2), 3); 723 753 break; … … 737 767 case SPELL_SHOCK_WAVE: 738 768 { 739 if (!get_aim_dir(&dir)) return (FALSE);740 769 fire_ball(GF_SOUND, dir, 10 + plev, 2); 741 770 break; … … 744 773 case SPELL_EXPLOSION: 745 774 { 746 if (!get_aim_dir(&dir)) return (FALSE);747 775 fire_ball(GF_SHARD, dir, 20 + (plev * 2), 2); 748 776 break; … … 826 854 case SPELL_RIFT: 827 855 { 828 if (!get_aim_dir(&dir)) return (FALSE);829 856 fire_beam(GF_GRAVITY, dir, 40 + damroll(plev, 7)); 830 857 break; … … 833 860 case SPELL_REND_SOUL: /* rend soul */ 834 861 { 835 if (!get_aim_dir(&dir)) return (FALSE);836 862 fire_bolt_or_beam(beam / 4, GF_NETHER, dir, damroll(11, plev)); 837 863 break; … … 840 866 case SPELL_CHAOS_STRIKE: /* chaos strike */ 841 867 { 842 if (!get_aim_dir(&dir)) return (FALSE);843 868 fire_bolt_or_beam(beam, GF_CHAOS, dir, damroll(13, plev)); 844 869 break; … … 868 893 869 894 870 static bool cast_priest_spell(int spell )895 static bool cast_priest_spell(int spell, int dir) 871 896 { 872 897 int py = p_ptr->py; 873 898 int px = p_ptr->px; 874 875 int dir;876 899 877 900 int plev = p_ptr->lev; … … 934 957 case PRAYER_SCARE_MONSTER: 935 958 { 936 if (!get_aim_dir(&dir)) return (FALSE);937 959 (void)fear_monster(dir, plev); 938 960 break; … … 993 1015 case PRAYER_ORB_OF_DRAINING: 994 1016 { 995 if (!get_aim_dir(&dir)) return (FALSE);996 1017 fire_ball(GF_HOLY_ORB, dir, 997 1018 (damroll(3, 6) + plev + … … 1209 1230 case PRAYER_ANNIHILATION: 1210 1231 { 1211 if (!get_aim_dir(&dir)) return (FALSE);1212 1232 drain_life(dir, 200); 1213 1233 break; … … 1261 1281 case PRAYER_TELEPORT_OTHER: 1262 1282 { 1263 if (!get_aim_dir(&dir)) return (FALSE);1264 1283 (void)teleport_monster(dir); 1265 1284 break; … … 1294 1313 1295 1314 1296 bool cast_spell(int tval, int index )1315 bool cast_spell(int tval, int index, int dir) 1297 1316 { 1298 1317 if (tval == TV_MAGIC_BOOK) 1299 1318 { 1300 return cast_mage_spell(index );1319 return cast_mage_spell(index, dir); 1301 1320 } 1302 1321 else 1303 1322 { 1304 return cast_priest_spell(index );1323 return cast_priest_spell(index, dir); 1305 1324 } 1306 1325 }
