Changeset 483

Show
Ignore:
Timestamp:
08/10/07 08:29:13 (1 year ago)
Author:
ajps
Message:

Put hallucination support back in - the actual choice of which object or monster should be hallucinated is still down to the display, but map_info decides whether a given grid should contain a 'monster' or 'object'.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/cave.c

    r476 r483  
    333333 * Hack -- Hallucinatory monster 
    334334 */ 
    335 static u16b image_monster(void) 
     335static u16b hallucinatory_monster(void) 
    336336{ 
    337337        monster_race *r_ptr; 
    338  
     338         
    339339        byte a; 
    340340        char c; 
    341  
     341         
    342342        while (1) 
    343343        { 
    344344                /* Select a random monster */ 
    345345                r_ptr = &r_info[rand_int(z_info->r_max)]; 
    346  
     346                 
    347347                /* Skip non-entries */ 
    348348                if (!r_ptr->name) continue; 
    349  
     349                 
    350350                /* Retrieve attr/char */ 
    351351                a = r_ptr->x_attr; 
    352352                c = r_ptr->x_char; 
    353  
     353                 
    354354                /* Encode */ 
    355355                return (PICT(a,c)); 
     
    361361 * Hack -- Hallucinatory object 
    362362 */ 
    363 static u16b image_object(void) 
     363static u16b hallucinatory_object(void) 
    364364{ 
    365365        object_kind *k_ptr; 
    366  
     366         
    367367        byte a; 
    368368        char c; 
    369  
     369         
    370370        while (1) 
    371371        { 
    372372                /* Select a random object */ 
    373373                k_ptr = &k_info[rand_int(z_info->k_max - 1) + 1]; 
    374  
     374                 
    375375                /* Skip non-entries */ 
    376376                if (!k_ptr->name) continue; 
    377  
     377                 
    378378                /* Retrieve attr/char (HACK - without flavors) */ 
    379379                a = k_ptr->x_attr; 
    380380                c = k_ptr->x_char; 
    381  
     381                 
    382382                /* HACK - Skip empty entries */ 
    383383                if ((a == 0) || (c == 0)) continue; 
    384  
     384                 
    385385                /* Encode */ 
    386386                return (PICT(a,c)); 
     
    388388} 
    389389 
    390  
    391 /* 
    392  * Hack -- Random hallucination 
    393  */ 
    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         else 
    404         { 
    405                 return (image_object()); 
    406         } 
    407 } 
    408390 
    409391 
     
    649631        if (g->first_k_idx) 
    650632        { 
    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(); 
    661637                         
     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 */ 
    662646                        a = k_ptr->x_attr; 
    663647                        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 */ 
    668661        if (g->m_idx > 0) 
    669662        { 
    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                                } 
    736740                        } 
    737741                } 
     
    739743 
    740744        /* Handle "player" */ 
    741         else if (g->m_idx < 0
     745        else if (g->is_player
    742746        { 
    743747                monster_race *r_ptr = &r_info[0]; 
     
    802806 *    Note that lighting is always LIGHT_GLOW for known "interesting" grids 
    803807 *    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. 
    804812 *        
    805813 * NOTES: 
     
    822830        object_type *o_ptr; 
    823831        byte info = cave_info[y][x]; 
    824  
    825 #if HALLUCINATION_SUPPORT 
    826         s16b image = p_ptr->timed[TMD_IMAGE]; 
    827 #endif 
    828  
     832         
    829833        /* Default "clear" values, others will be set later where appropriate. */ 
    830834        g->first_k_idx = 0; 
     
    832836        g->lighting = LIGHT_GLOW; 
    833837 
    834         /* Set various indexes */ 
    835         g->m_idx = cave_m_idx[y][x]; 
     838        /* Set things we can work out right now */ 
    836839        g->f_idx = cave_feat[y][x]; 
    837  
    838 #if HALLUCINATION_SUPPORT 
    839         /* 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 #endif 
    848  
    849840        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; 
    850844 
    851845        /* If the grid is memorised or can currently be seen */ 
     
    875869                                g->lighting = LIGHT_DARK; 
    876870                } 
    877                 else 
    878                 { 
    879                 } 
    880871        } 
    881872        /* Unknown */ 
     
    893884                if (o_ptr->marked && !squelch_hide_item(o_ptr)) 
    894885                { 
    895 #ifdef HALLUCINATION_SUPPORT 
    896                         /* 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 #endif 
    907886                        /* First item found */ 
    908887                        if (g->first_k_idx == 0) 
     
    920899        } 
    921900 
    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                } 
    942921        } 
    943922}