Changeset 483
- Timestamp:
- 08/10/07 08:29:13 (1 year ago)
- Files:
-
- trunk/src/cave.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cave.c
r476 r483 333 333 * Hack -- Hallucinatory monster 334 334 */ 335 static u16b image_monster(void)335 static u16b hallucinatory_monster(void) 336 336 { 337 337 monster_race *r_ptr; 338 338 339 339 byte a; 340 340 char c; 341 341 342 342 while (1) 343 343 { 344 344 /* Select a random monster */ 345 345 r_ptr = &r_info[rand_int(z_info->r_max)]; 346 346 347 347 /* Skip non-entries */ 348 348 if (!r_ptr->name) continue; 349 349 350 350 /* Retrieve attr/char */ 351 351 a = r_ptr->x_attr; 352 352 c = r_ptr->x_char; 353 353 354 354 /* Encode */ 355 355 return (PICT(a,c)); … … 361 361 * Hack -- Hallucinatory object 362 362 */ 363 static u16b image_object(void)363 static u16b hallucinatory_object(void) 364 364 { 365 365 object_kind *k_ptr; 366 366 367 367 byte a; 368 368 char c; 369 369 370 370 while (1) 371 371 { 372 372 /* Select a random object */ 373 373 k_ptr = &k_info[rand_int(z_info->k_max - 1) + 1]; 374 374 375 375 /* Skip non-entries */ 376 376 if (!k_ptr->name) continue; 377 377 378 378 /* Retrieve attr/char (HACK - without flavors) */ 379 379 a = k_ptr->x_attr; 380 380 c = k_ptr->x_char; 381 381 382 382 /* HACK - Skip empty entries */ 383 383 if ((a == 0) || (c == 0)) continue; 384 384 385 385 /* Encode */ 386 386 return (PICT(a,c)); … … 388 388 } 389 389 390 391 /*392 * Hack -- Random hallucination393 */394 static u16b image_random(void)395 {396 /* Normally, assume monsters */397 if (rand_int(100) < 75)398 {399 return (image_monster());400 }401 402 /* Otherwise, assume objects */403 else404 {405 return (image_object());406 }407 }408 390 409 391 … … 649 631 if (g->first_k_idx) 650 632 { 651 object_kind *k_ptr = &k_info[g->first_k_idx]; 652 653 /* Normal attr and char */ 654 a = k_ptr->x_attr; 655 c = k_ptr->x_char; 656 657 if (show_piles && g->multiple_objects) 658 { 659 /* Get the "pile" feature instead */ 660 k_ptr = &k_info[0]; 633 if (g->hallucinate) 634 { 635 /* Just pick a random object to display. */ 636 int i = hallucinatory_object(); 661 637 638 a = PICT_A(i); 639 c = PICT_C(i); 640 } 641 else 642 { 643 object_kind *k_ptr = &k_info[g->first_k_idx]; 644 645 /* Normal attr and char */ 662 646 a = k_ptr->x_attr; 663 647 c = k_ptr->x_char; 664 } 665 } 666 667 /* If there's a monster (that's not the player) */ 648 649 if (show_piles && g->multiple_objects) 650 { 651 /* Get the "pile" feature instead */ 652 k_ptr = &k_info[0]; 653 654 a = k_ptr->x_attr; 655 c = k_ptr->x_char; 656 } 657 } 658 } 659 660 /* If there's a monster */ 668 661 if (g->m_idx > 0) 669 662 { 670 monster_type *m_ptr = &mon_list[g->m_idx]; 671 672 /* Visible monster */ 673 if (m_ptr->ml) 674 { 675 monster_race *r_ptr = &r_info[m_ptr->r_idx]; 676 677 byte da; 678 char dc; 679 680 /* Desired attr & char*/ 681 da = r_ptr->x_attr; 682 dc = r_ptr->x_char; 683 684 /* Special attr/char codes */ 685 if ((da & 0x80) && (dc & 0x80)) 686 { 687 /* Use attr */ 688 a = da; 689 690 /* Use char */ 691 c = dc; 692 } 693 694 /* Multi-hued monster */ 695 else if (r_ptr->flags1 & (RF1_ATTR_MULTI)) 696 { 697 /* Multi-hued attr */ 698 a = randint(15); 699 700 /* Normal char */ 701 c = dc; 702 } 703 704 /* Normal monster (not "clear" in any way) */ 705 else if (!(r_ptr->flags1 & (RF1_ATTR_CLEAR | RF1_CHAR_CLEAR))) 706 { 707 /* Use attr */ 708 a = da; 709 710 /* Use char */ 711 c = dc; 712 } 713 714 /* Hack -- Bizarre grid under monster */ 715 else if ((a & 0x80) || (c & 0x80)) 716 { 717 /* Use attr */ 718 a = da; 719 720 /* Use char */ 721 c = dc; 722 } 723 724 /* Normal char, Clear attr, monster */ 725 else if (!(r_ptr->flags1 & (RF1_CHAR_CLEAR))) 726 { 727 /* Normal char */ 728 c = dc; 729 } 730 731 /* Normal attr, Clear char, monster */ 732 else if (!(r_ptr->flags1 & (RF1_ATTR_CLEAR))) 733 { 734 /* Normal attr */ 735 a = da; 663 if (g->hallucinate) 664 { 665 /* Just pick a random monster to display. */ 666 int i = hallucinatory_monster(); 667 668 a = PICT_A(i); 669 c = PICT_C(i); 670 } 671 else 672 { 673 monster_type *m_ptr = &mon_list[g->m_idx]; 674 675 /* Visible monster */ 676 if (m_ptr->ml) 677 { 678 monster_race *r_ptr = &r_info[m_ptr->r_idx]; 679 680 byte da; 681 char dc; 682 683 /* Desired attr & char*/ 684 da = r_ptr->x_attr; 685 dc = r_ptr->x_char; 686 687 /* Special attr/char codes */ 688 if ((da & 0x80) && (dc & 0x80)) 689 { 690 /* Use attr */ 691 a = da; 692 693 /* Use char */ 694 c = dc; 695 } 696 697 /* Multi-hued monster */ 698 else if (r_ptr->flags1 & (RF1_ATTR_MULTI)) 699 { 700 /* Multi-hued attr */ 701 a = randint(15); 702 703 /* Normal char */ 704 c = dc; 705 } 706 707 /* Normal monster (not "clear" in any way) */ 708 else if (!(r_ptr->flags1 & (RF1_ATTR_CLEAR | RF1_CHAR_CLEAR))) 709 { 710 /* Use attr */ 711 a = da; 712 713 /* Use char */ 714 c = dc; 715 } 716 717 /* Hack -- Bizarre grid under monster */ 718 else if ((a & 0x80) || (c & 0x80)) 719 { 720 /* Use attr */ 721 a = da; 722 723 /* Use char */ 724 c = dc; 725 } 726 727 /* Normal char, Clear attr, monster */ 728 else if (!(r_ptr->flags1 & (RF1_CHAR_CLEAR))) 729 { 730 /* Normal char */ 731 c = dc; 732 } 733 734 /* Normal attr, Clear char, monster */ 735 else if (!(r_ptr->flags1 & (RF1_ATTR_CLEAR))) 736 { 737 /* Normal attr */ 738 a = da; 739 } 736 740 } 737 741 } … … 739 743 740 744 /* Handle "player" */ 741 else if (g-> m_idx < 0)745 else if (g->is_player) 742 746 { 743 747 monster_race *r_ptr = &r_info[0]; … … 802 806 * Note that lighting is always LIGHT_GLOW for known "interesting" grids 803 807 * like walls. 808 * - g->is_player is TRUE if the player is on the given grid. 809 * - g->hallucinate is TRUE if the player is hallucinating something "strange" 810 * for this grid - this should pick a random monster to show if the m_idx 811 * is non-zero, and a random object if first_k_idx is non-zero. 804 812 * 805 813 * NOTES: … … 822 830 object_type *o_ptr; 823 831 byte info = cave_info[y][x]; 824 825 #if HALLUCINATION_SUPPORT 826 s16b image = p_ptr->timed[TMD_IMAGE]; 827 #endif 828 832 829 833 /* Default "clear" values, others will be set later where appropriate. */ 830 834 g->first_k_idx = 0; … … 832 836 g->lighting = LIGHT_GLOW; 833 837 834 /* Set various indexes */ 835 g->m_idx = cave_m_idx[y][x]; 838 /* Set things we can work out right now */ 836 839 g->f_idx = cave_feat[y][x]; 837 838 #if HALLUCINATION_SUPPORT839 /* Hack -- rare random hallucination on non-outer walls */840 if (image && (!rand_int(256)) && (g->f_idx < FEAT_PERM_SOLID))841 {842 int i = image_random();843 844 a = PICT_A(i);845 c = PICT_C(i);846 }847 #endif848 849 840 g->in_view = (info & CAVE_SEEN) ? TRUE : FALSE; 841 g->is_player = (cave_m_idx[y][x] < 0) ? TRUE : FALSE; 842 g->m_idx = (g->is_player) ? 0 : cave_m_idx[y][x]; 843 g->hallucinate = p_ptr->timed[TMD_IMAGE] ? TRUE : FALSE; 850 844 851 845 /* If the grid is memorised or can currently be seen */ … … 875 869 g->lighting = LIGHT_DARK; 876 870 } 877 else878 {879 }880 871 } 881 872 /* Unknown */ … … 893 884 if (o_ptr->marked && !squelch_hide_item(o_ptr)) 894 885 { 895 #ifdef HALLUCINATION_SUPPORT896 /* Hack -- object hallucination */897 if (image)898 {899 int i = image_object();900 901 a = PICT_A(i);902 c = PICT_C(i);903 904 break;905 }906 #endif907 886 /* First item found */ 908 887 if (g->first_k_idx == 0) … … 920 899 } 921 900 922 923 #if HALLUCINATION_SUPPORT 924 /* Monsters */925 if (g->m_idx > 0)926 {927 /* Hack -- monster hallucination*/928 if (image)929 {930 int i = image_monster();931 932 a = PICT_A(i);933 c = PICT_C(i);934 }935 }936 #endif 937 938 /* Handle the player */939 if (g->m_idx < 0)940 {941 g->m_idx = -1;901 /* Rare random hallucination on non-outer walls */ 902 if (g->hallucinate && g->m_idx == 0 && g->first_k_idx == 0) 903 { 904 if (rand_int(256) == 0 && g->f_idx < FEAT_PERM_SOLID) 905 { 906 /* Normally, make an imaginary monster */ 907 if (rand_int(100) < 75) 908 { 909 g->m_idx = 1; 910 } 911 /* Otherwise, an imaginary object */ 912 else 913 { 914 g->first_k_idx = 1; 915 } 916 } 917 else 918 { 919 g->hallucinate = FALSE; 920 } 942 921 } 943 922 }
