| 565 | | * Determine if a trap affects the player. |
|---|
| 566 | | * Always miss 5% of the time, Always hit 5% of the time. |
|---|
| 567 | | * Otherwise, match trap power against player armor. |
|---|
| 568 | | */ |
|---|
| 569 | | static bool check_hit(int power) |
|---|
| 570 | | { |
|---|
| 571 | | return test_hit(power, p_ptr->ac + p_ptr->to_a, TRUE); |
|---|
| 572 | | } |
|---|
| 573 | | |
|---|
| 574 | | |
|---|
| 575 | | /* |
|---|
| 576 | | * Handle player hitting a real trap |
|---|
| 577 | | */ |
|---|
| 578 | | void hit_trap(int y, int x) |
|---|
| 579 | | { |
|---|
| 580 | | int i, num, dam; |
|---|
| 581 | | |
|---|
| 582 | | cptr name = "a trap"; |
|---|
| 583 | | |
|---|
| 584 | | |
|---|
| 585 | | /* Disturb the player */ |
|---|
| 586 | | disturb(0, 0); |
|---|
| 587 | | |
|---|
| 588 | | /* Analyze XXX XXX XXX */ |
|---|
| 589 | | switch (cave_feat[y][x]) |
|---|
| 590 | | { |
|---|
| 591 | | case FEAT_TRAP_HEAD + 0x00: |
|---|
| 592 | | { |
|---|
| 593 | | msg_print("You fall through a trap door!"); |
|---|
| 594 | | if (p_ptr->ffall) |
|---|
| 595 | | { |
|---|
| 596 | | msg_print("You float gently down to the next level."); |
|---|
| 597 | | } |
|---|
| 598 | | else |
|---|
| 599 | | { |
|---|
| 600 | | dam = damroll(2, 8); |
|---|
| 601 | | take_hit(dam, name); |
|---|
| 602 | | } |
|---|
| 603 | | |
|---|
| 604 | | /* New depth */ |
|---|
| 605 | | p_ptr->depth++; |
|---|
| 606 | | |
|---|
| 607 | | /* Leaving */ |
|---|
| 608 | | p_ptr->leaving = TRUE; |
|---|
| 609 | | |
|---|
| 610 | | break; |
|---|
| 611 | | } |
|---|
| 612 | | |
|---|
| 613 | | case FEAT_TRAP_HEAD + 0x01: |
|---|
| 614 | | { |
|---|
| 615 | | msg_print("You fall into a pit!"); |
|---|
| 616 | | if (p_ptr->ffall) |
|---|
| 617 | | { |
|---|
| 618 | | msg_print("You float gently to the bottom of the pit."); |
|---|
| 619 | | } |
|---|
| 620 | | else |
|---|
| 621 | | { |
|---|
| 622 | | dam = damroll(2, 6); |
|---|
| 623 | | take_hit(dam, name); |
|---|
| 624 | | } |
|---|
| 625 | | break; |
|---|
| 626 | | } |
|---|
| 627 | | |
|---|
| 628 | | case FEAT_TRAP_HEAD + 0x02: |
|---|
| 629 | | { |
|---|
| 630 | | msg_print("You fall into a spiked pit!"); |
|---|
| 631 | | |
|---|
| 632 | | if (p_ptr->ffall) |
|---|
| 633 | | { |
|---|
| 634 | | msg_print("You float gently to the floor of the pit."); |
|---|
| 635 | | msg_print("You carefully avoid touching the spikes."); |
|---|
| 636 | | } |
|---|
| 637 | | |
|---|
| 638 | | else |
|---|
| 639 | | { |
|---|
| 640 | | /* Base damage */ |
|---|
| 641 | | dam = damroll(2, 6); |
|---|
| 642 | | |
|---|
| 643 | | /* Extra spike damage */ |
|---|
| 644 | | if (rand_int(100) < 50) |
|---|
| 645 | | { |
|---|
| 646 | | msg_print("You are impaled!"); |
|---|
| 647 | | |
|---|
| 648 | | dam = dam * 2; |
|---|
| 649 | | (void)inc_timed(TMD_CUT, randint(dam)); |
|---|
| 650 | | } |
|---|
| 651 | | |
|---|
| 652 | | /* Take the damage */ |
|---|
| 653 | | take_hit(dam, name); |
|---|
| 654 | | } |
|---|
| 655 | | break; |
|---|
| 656 | | } |
|---|
| 657 | | |
|---|
| 658 | | case FEAT_TRAP_HEAD + 0x03: |
|---|
| 659 | | { |
|---|
| 660 | | msg_print("You fall into a spiked pit!"); |
|---|
| 661 | | |
|---|
| 662 | | if (p_ptr->ffall) |
|---|
| 663 | | { |
|---|
| 664 | | msg_print("You float gently to the floor of the pit."); |
|---|
| 665 | | msg_print("You carefully avoid touching the spikes."); |
|---|
| 666 | | } |
|---|
| 667 | | |
|---|
| 668 | | else |
|---|
| 669 | | { |
|---|
| 670 | | /* Base damage */ |
|---|
| 671 | | dam = damroll(2, 6); |
|---|
| 672 | | |
|---|
| 673 | | /* Extra spike damage */ |
|---|
| 674 | | if (rand_int(100) < 50) |
|---|
| 675 | | { |
|---|
| 676 | | msg_print("You are impaled on poisonous spikes!"); |
|---|
| 677 | | |
|---|
| 678 | | dam = dam * 2; |
|---|
| 679 | | (void)inc_timed(TMD_CUT, randint(dam)); |
|---|
| 680 | | |
|---|
| 681 | | if (p_ptr->resist_pois || p_ptr->timed[TMD_OPP_POIS]) |
|---|
| 682 | | { |
|---|
| 683 | | msg_print("The poison does not affect you!"); |
|---|
| 684 | | } |
|---|
| 685 | | else |
|---|
| 686 | | { |
|---|
| 687 | | dam = dam * 2; |
|---|
| 688 | | (void)inc_timed(TMD_POISONED, randint(dam)); |
|---|
| 689 | | } |
|---|
| 690 | | } |
|---|
| 691 | | |
|---|
| 692 | | /* Take the damage */ |
|---|
| 693 | | take_hit(dam, name); |
|---|
| 694 | | } |
|---|
| 695 | | |
|---|
| 696 | | break; |
|---|
| 697 | | } |
|---|
| 698 | | |
|---|
| 699 | | case FEAT_TRAP_HEAD + 0x04: |
|---|
| 700 | | { |
|---|
| 701 | | sound(MSG_SUM_MONSTER); |
|---|
| 702 | | msg_print("You are enveloped in a cloud of smoke!"); |
|---|
| 703 | | cave_info[y][x] &= ~(CAVE_MARK); |
|---|
| 704 | | cave_set_feat(y, x, FEAT_FLOOR); |
|---|
| 705 | | num = 2 + randint(3); |
|---|
| 706 | | for (i = 0; i < num; i++) |
|---|
| 707 | | { |
|---|
| 708 | | (void)summon_specific(y, x, p_ptr->depth, 0); |
|---|
| 709 | | } |
|---|
| 710 | | break; |
|---|
| 711 | | } |
|---|
| 712 | | |
|---|
| 713 | | case FEAT_TRAP_HEAD + 0x05: |
|---|
| 714 | | { |
|---|
| 715 | | msg_print("You hit a teleport trap!"); |
|---|
| 716 | | teleport_player(100); |
|---|
| 717 | | break; |
|---|
| 718 | | } |
|---|
| 719 | | |
|---|
| 720 | | case FEAT_TRAP_HEAD + 0x06: |
|---|
| 721 | | { |
|---|
| 722 | | msg_print("You are enveloped in flames!"); |
|---|
| 723 | | dam = damroll(4, 6); |
|---|
| 724 | | fire_dam(dam, "a fire trap"); |
|---|
| 725 | | break; |
|---|
| 726 | | } |
|---|
| 727 | | |
|---|
| 728 | | case FEAT_TRAP_HEAD + 0x07: |
|---|
| 729 | | { |
|---|
| 730 | | msg_print("You are splashed with acid!"); |
|---|
| 731 | | dam = damroll(4, 6); |
|---|
| 732 | | acid_dam(dam, "an acid trap"); |
|---|
| 733 | | break; |
|---|
| 734 | | } |
|---|
| 735 | | |
|---|
| 736 | | case FEAT_TRAP_HEAD + 0x08: |
|---|
| 737 | | { |
|---|
| 738 | | if (check_hit(125)) |
|---|
| 739 | | { |
|---|
| 740 | | msg_print("A small dart hits you!"); |
|---|
| 741 | | dam = damroll(1, 4); |
|---|
| 742 | | take_hit(dam, name); |
|---|
| 743 | | (void)inc_timed(TMD_SLOW, rand_int(20) + 20); |
|---|
| 744 | | } |
|---|
| 745 | | else |
|---|
| 746 | | { |
|---|
| 747 | | msg_print("A small dart barely misses you."); |
|---|
| 748 | | } |
|---|
| 749 | | break; |
|---|
| 750 | | } |
|---|
| 751 | | |
|---|
| 752 | | case FEAT_TRAP_HEAD + 0x09: |
|---|
| 753 | | { |
|---|
| 754 | | if (check_hit(125)) |
|---|
| 755 | | { |
|---|
| 756 | | msg_print("A small dart hits you!"); |
|---|
| 757 | | dam = damroll(1, 4); |
|---|
| 758 | | take_hit(dam, name); |
|---|
| 759 | | (void)do_dec_stat(A_STR, FALSE); |
|---|
| 760 | | } |
|---|
| 761 | | else |
|---|
| 762 | | { |
|---|
| 763 | | msg_print("A small dart barely misses you."); |
|---|
| 764 | | } |
|---|
| 765 | | break; |
|---|
| 766 | | } |
|---|
| 767 | | |
|---|
| 768 | | case FEAT_TRAP_HEAD + 0x0A: |
|---|
| 769 | | { |
|---|
| 770 | | if (check_hit(125)) |
|---|
| 771 | | { |
|---|
| 772 | | msg_print("A small dart hits you!"); |
|---|
| 773 | | dam = damroll(1, 4); |
|---|
| 774 | | take_hit(dam, name); |
|---|
| 775 | | (void)do_dec_stat(A_DEX, FALSE); |
|---|
| 776 | | } |
|---|
| 777 | | else |
|---|
| 778 | | { |
|---|
| 779 | | msg_print("A small dart barely misses you."); |
|---|
| 780 | | } |
|---|
| 781 | | break; |
|---|
| 782 | | } |
|---|
| 783 | | |
|---|
| 784 | | case FEAT_TRAP_HEAD + 0x0B: |
|---|
| 785 | | { |
|---|
| 786 | | if (check_hit(125)) |
|---|
| 787 | | { |
|---|
| 788 | | msg_print("A small dart hits you!"); |
|---|
| 789 | | dam = damroll(1, 4); |
|---|
| 790 | | take_hit(dam, name); |
|---|
| 791 | | (void)do_dec_stat(A_CON, FALSE); |
|---|
| 792 | | } |
|---|
| 793 | | else |
|---|
| 794 | | { |
|---|
| 795 | | msg_print("A small dart barely misses you."); |
|---|
| 796 | | } |
|---|
| 797 | | break; |
|---|
| 798 | | } |
|---|
| 799 | | |
|---|
| 800 | | case FEAT_TRAP_HEAD + 0x0C: |
|---|
| 801 | | { |
|---|
| 802 | | msg_print("You are surrounded by a black gas!"); |
|---|
| 803 | | if (!p_ptr->resist_blind) |
|---|
| 804 | | { |
|---|
| 805 | | (void)inc_timed(TMD_BLIND, rand_int(50) + 25); |
|---|
| 806 | | } |
|---|
| 807 | | break; |
|---|
| 808 | | } |
|---|
| 809 | | |
|---|
| 810 | | case FEAT_TRAP_HEAD + 0x0D: |
|---|
| 811 | | { |
|---|
| 812 | | msg_print("You are surrounded by a gas of scintillating colors!"); |
|---|
| 813 | | if (!p_ptr->resist_confu) |
|---|
| 814 | | { |
|---|
| 815 | | (void)inc_timed(TMD_CONFUSED, rand_int(20) + 10); |
|---|
| 816 | | } |
|---|
| 817 | | break; |
|---|
| 818 | | } |
|---|
| 819 | | |
|---|
| 820 | | case FEAT_TRAP_HEAD + 0x0E: |
|---|
| 821 | | { |
|---|
| 822 | | msg_print("You are surrounded by a pungent green gas!"); |
|---|
| 823 | | if (!p_ptr->resist_pois && !p_ptr->timed[TMD_OPP_POIS]) |
|---|
| 824 | | { |
|---|
| 825 | | (void)inc_timed(TMD_POISONED, rand_int(20) + 10); |
|---|
| 826 | | } |
|---|
| 827 | | break; |
|---|
| 828 | | } |
|---|
| 829 | | |
|---|
| 830 | | case FEAT_TRAP_HEAD + 0x0F: |
|---|
| 831 | | { |
|---|
| 832 | | msg_print("You are surrounded by a strange white mist!"); |
|---|
| 833 | | if (!p_ptr->free_act) |
|---|
| 834 | | { |
|---|
| 835 | | (void)inc_timed(TMD_PARALYZED, rand_int(10) + 5); |
|---|
| 836 | | } |
|---|
| 837 | | break; |
|---|
| 838 | | } |
|---|
| 839 | | } |
|---|
| 840 | | } |
|---|
| 841 | | |
|---|
| 842 | | |
|---|
| 843 | | |
|---|
| 844 | | |
|---|
| 845 | | /* |
|---|