Changeset 317

Show
Ignore:
Timestamp:
07/10/07 10:02:30 (1 year ago)
Author:
takkaria
Message:

Create some new infrastructure for unified effects code. Make food items use it for now. (work on #234)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/edit/object.txt

    r305 r317  
    9898A:5/1 
    9999F:EASY_KNOW 
    100 D:It causes blindness that lasts for 199+1d200 turns, unless you have 
    101 D: resistance to blindness. 
    102 D:  Mushrooms provide nourishment for about 250 turns under normal 
    103 D: conditions. 
     100E:BLIND 
    104101 
    105102N:2:Paranoia 
     
    109106A:5/1 
    110107F:EASY_KNOW 
    111 D:It induces fear that lasts for 9+1d10 turns, unless you have 
    112 D: resistance to fear. 
    113 D:  Mushrooms provide nourishment for about 250 turns under normal 
    114 D: conditions. 
     108E:SCARE 
    115109 
    116110N:3:Confusion 
     
    120114A:5/1 
    121115F:EASY_KNOW 
    122 D:It induces confusion that lasts for 9+1d10 turns, unless you have 
    123 D: resistance to confusion. 
    124 D:  Mushrooms provide nourishment for about 250 turns under normal 
    125 D: conditions. 
     116E:CONFUSE 
    126117 
    127118N:4:Hallucination 
     
    131122A:10/1 
    132123F:EASY_KNOW 
    133 D:It causes you to hallucinate for 249+1d250 turns, unless you have 
    134 D: resistance to chaos. 
    135 D:  Mushrooms provide nourishment for about 250 turns under normal 
    136 D: conditions. 
     124E:HALLUC 
    137125 
    138126N:5:Cure Poison 
     
    142130A:10/1 
    143131F:EASY_KNOW 
    144 D:It neutralizes poison. 
    145 D:  Mushrooms provide nourishment for about 250 turns under normal 
    146 D: conditions. 
     132E:CURE_POISON 
    147133 
    148134N:6:Cure Blindness 
     
    152138A:10/1 
    153139F:EASY_KNOW 
    154 D:It cures blindness. 
    155 D:  Mushrooms provide nourishment for about 250 turns under normal 
    156 D: conditions. 
     140E:CURE_BLINDNESS 
    157141 
    158142N:7:Cure Paranoia 
     
    162146A:10/1 
    163147F:EASY_KNOW 
    164 D:It removes your fear. 
    165 D:  Mushrooms provide nourishment for about 250 turns under normal 
    166 D: conditions. 
     148E:CURE_PARANOIA 
    167149 
    168150N:8:Cure Confusion 
     
    172154A:10/1 
    173155F:EASY_KNOW 
    174 D:It cures confusion. 
    175 D:  Mushrooms provide nourishment for about 250 turns under normal 
    176 D: conditions. 
     156E:CURE_CONFUSION 
    177157 
    178158N:9:Weakness 
     
    182162A:10/1 
    183163F:EASY_KNOW 
    184 D:It inflicts 6d6 points of damage, and also reduces strength unless you 
    185 D: have sustain strength. 
    186 D:  Mushrooms provide nourishment for about 250 turns under normal 
    187 D: conditions. 
     164E:LOSE_STR 
    188165 
    189166N:10:Unhealth 
     
    194171P:0:10d10:0:0:0 
    195172F:EASY_KNOW 
    196 D:It inflicts 10d10 points of damage, and also reduces constitution 
    197 D: unless you have sustain constitution. 
    198 D:  It may also be thrown to inflict 10d10 points of damage. 
    199 D:  Mushrooms provide nourishment for about 250 turns under normal 
    200 D: conditions. 
     173E:LOSE_CON2 
     174D:It may also be thrown to inflict 10d10 points of damage. 
    201175 
    202176N:11:Restore Constitution 
     
    206180A:20/1 
    207181F:EASY_KNOW 
    208 D:It restores constitution to maximum if it is currently below maximum. 
    209 D:  Mushrooms provide nourishment for about 250 turns under normal 
    210 D: conditions. 
     182E:RESTORE_CON 
    211183 
    212184N:12:Restoring 
     
    216188A:20/8:30/4:40/1 
    217189F:EASY_KNOW 
    218 D:It restores to maximum all stats that are currently below maximum. 
    219 D:  Mushrooms provide nourishment for about 250 turns under normal 
    220 D: conditions. 
     190E:RESTORE_ALL 
    221191 
    222192N:13:Stupidity 
     
    226196A:15/1 
    227197F:EASY_KNOW 
    228 D:It inflicts 8d8 points of damage, and also reduces intelligence unless 
    229 D: you have sustain intelligence. 
    230 D:  Mushrooms provide nourishment for about 250 turns under normal 
    231 D: conditions. 
     198E:LOSE_INT 
    232199 
    233200N:14:Naivety 
     
    237204A:15/1 
    238205F:EASY_KNOW 
    239 D:It inflicts 8d8 points of damage, and also reduces wisdom unless you 
    240 D: have sustain wisdom. 
    241 D:  Mushrooms provide nourishment for about 250 turns under normal 
    242 D: conditions. 
     206E:LOSE_WIS 
    243207 
    244208N:15:Poison 
     
    248212A:5/1:5/1 
    249213F:EASY_KNOW 
    250 D:It poisons you (adding 9+1d10 points to the poison counter), unless 
    251 D: you have resistance to poison. 
    252 D:  Mushrooms provide nourishment for about 250 turns under normal 
    253 D: conditions. 
     214E:POISON 
    254215 
    255216N:16:Sickness 
     
    259220A:10/1 
    260221F:EASY_KNOW 
    261 D:It inflicts 6d6 points of damage, and also reduces constitution unless 
    262 D: you have sustain constitution. 
    263 D:  Mushrooms provide nourishment for about 250 turns under normal 
    264 D: conditions. 
     222E:LOSE_CON 
    265223 
    266224N:17:Paralysis 
     
    270228A:20/1 
    271229F:EASY_KNOW 
    272 D:It induces paralysis that lasts for 9+1d10 turns, unless you have free 
    273 D: action. 
    274 D:  Mushrooms provide nourishment for about 250 turns under normal 
    275 D: conditions. 
     230E:PARALYZE 
    276231 
    277232N:18:Restore Strength 
     
    281236A:20/1 
    282237F:EASY_KNOW 
    283 D:It restores strength to maximum if it is currently below maximum. 
    284 D:  Mushrooms provide nourishment for about 250 turns under normal 
    285 D: conditions. 
     238E:RESTORE_STR 
    286239 
    287240N:19:Disease 
     
    292245P:0:10d10:0:0:0 
    293246F:EASY_KNOW 
    294 D:It inflicts 10d10 points of damage, and also reduces strength unless 
    295 D: you have sustain strength. 
    296 D:  It may also be thrown to inflict 10d10 points of damage. 
    297 D:  Mushrooms provide nourishment for about 250 turns under normal 
    298 D: conditions. 
     247E:LOSE_STR2 
     248D:It may also be thrown to inflict 10d10 points of damage. 
    299249 
    300250N:20:Cure Serious Wounds 
     
    305255F:EASY_KNOW 
    306256D:It cures 4d8 points of damage. 
    307 D:  Mushrooms provide nourishment for about 250 turns under normal 
    308 D: conditions. 
    309257 
    310258##### Normal Food ##### 
     
    316264A:0/1:5/1:10/1 
    317265F:EASY_KNOW 
    318 D:It provides nourishment for about 2500 turns under normal conditions. 
     266E:FOOD_GOOD 
    319267 
    320268N:22:& Hard Biscuit~ 
     
    323271W:0:0:2:1 
    324272F:EASY_KNOW 
    325 D:It provides nourishment for about 250 turns under normal conditions. 
     273E:FOOD_GOOD 
    326274 
    327275N:23:& Strip~ of Beef Jerky 
     
    330278W:0:0:2:2 
    331279F:EASY_KNOW 
    332 D:It provides nourishment for about 750 turns under normal conditions. 
     280E:FOOD_GOOD 
    333281 
    334282N:24:& Slime Mold~ 
     
    338286A:1/1 
    339287F:EASY_KNOW 
    340 D:It provides nourishment for about 1500 turns under normal conditions. 
     288E:FOOD_GOOD 
    341289 
    342290N:25:& Piece~ of Elvish Waybread 
     
    346294A:5/1:10/1:20/1 
    347295F:EASY_KNOW 
    348 D:It cures 4d8 points of damage and neutralizes poison. 
    349 D:  It provides nourishment for about 3750 turns under normal 
    350 D: conditions. 
     296E:FOOD_WAYBREAD 
    351297 
    352298N:26:& Pint~ of Fine Ale 
     
    355301W:0:0:5:1 
    356302F:EASY_KNOW 
    357 D:It provides nourishment for about 250 turns under normal conditions. 
     303E:FOOD_GOOD 
    358304 
    359305N:27:& Pint~ of Fine Wine 
     
    362308W:0:0:10:2 
    363309F:EASY_KNOW 
    364 D:It provides nourishment for about 500 turns under normal conditions. 
     310E:FOOD_GOOD 
    365311 
    366312 
  • trunk/src/Makefile.src

    r182 r317  
    2929        cmd6.o \ 
    3030        dungeon.o \ 
     31        effects.o \ 
    3132        files.o \ 
    3233        generate.o \ 
  • trunk/src/init1.c

    r306 r317  
    88 * are included in all such copies.  Other copyrights may also apply. 
    99 */ 
    10  
    1110#include "angband.h" 
    1211 
     
    474473        "PERMA_CURSE" 
    475474}; 
     475 
     476/* Use a slightly unusual include method to create effect_list[] */ 
     477#define LIST_STRINGS 
     478#include "effects.h" 
     479#undef LIST_STRINGS 
    476480 
    477481 
     
    11931197 
    11941198 
     1199/* 
     1200 * Figure out what index an activation should have 
     1201 */ 
     1202static u32b grab_one_effect(const char *what) 
     1203{ 
     1204        size_t i; 
     1205 
     1206        /* Scan activations */ 
     1207        for (i = 0; i < N_ELEMENTS(effect_list); i++) 
     1208        { 
     1209                if (streq(what, effect_list[i])) 
     1210                        return i; 
     1211        } 
     1212 
     1213        /* Oops */ 
     1214        msg_format("Unknown effect '%s'.", what); 
     1215 
     1216        /* Error */ 
     1217        return 0; 
     1218} 
     1219 
     1220 
    11951221 
    11961222/* 
     
    12401266                if (!(k_ptr->name = add_name(head, s))) 
    12411267                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    1242         } 
     1268 
     1269                /* Success (return early) */ 
     1270                return (0); 
     1271        } 
     1272 
     1273        /* There better be a current k_ptr */ 
     1274        if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    12431275 
    12441276        /* Process 'G' for "Graphics" (one line only) */ 
    1245         else if (buf[0] == 'G') 
     1277        if (buf[0] == 'G') 
    12461278        { 
    12471279                char d_char; 
    12481280                int d_attr; 
    1249  
    1250                 /* There better be a current k_ptr */ 
    1251                 if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    12521281 
    12531282                /* Paranoia */ 
     
    12871316                int tval, sval, pval; 
    12881317 
    1289                 /* There better be a current k_ptr */ 
    1290                 if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    1291  
    12921318                /* Scan for the values */ 
    12931319                if (3 != sscanf(buf+2, "%d:%d:%d", 
     
    13051331                int level, extra, wgt; 
    13061332                long cost; 
    1307  
    1308                 /* There better be a current k_ptr */ 
    1309                 if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    13101333 
    13111334                /* Scan for the values */ 
     
    13241347        { 
    13251348                int i; 
    1326  
    1327                 /* There better be a current k_ptr */ 
    1328                 if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    13291349 
    13301350                /* XXX Simply read each number following a colon */ 
     
    13601380                int ac, hd1, hd2, th, td, ta; 
    13611381 
    1362                 /* There better be a current k_ptr */ 
    1363                 if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    1364  
    13651382                /* Scan for the values */ 
    13661383                if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d", 
     
    13821399                int dd = 1; 
    13831400 
    1384                 /* There better be a current k_ptr */ 
    1385                 if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    1386  
    13871401                /* Assign base values */ 
    13881402                k_ptr->charge_base = 0; 
     
    14221436                int prob, dice, side; 
    14231437 
    1424                 /* There better be a current k_ptr */ 
    1425                 if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    1426  
    14271438                /* Scan for the values */ 
    14281439                if (3 != sscanf(buf+2, "%d:%dd%d", &prob, &dice, &side)) 
     
    14411452        else if (buf[0] == 'F') 
    14421453        { 
    1443                 /* There better be a current k_ptr */ 
    1444                 if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    1445  
    14461454                /* Parse every entry textually */ 
    14471455                for (s = buf + 2; *s; ) 
     
    14651473        } 
    14661474 
     1475        /* Process 'E' for effect */ 
     1476        else if (buf[0] == 'E') 
     1477        { 
     1478                /* Get the activation */ 
     1479                k_ptr->effect = grab_one_effect(buf + 2); 
     1480 
     1481                /* No luck */ 
     1482                if (!k_ptr->effect) 
     1483                        return (PARSE_ERROR_GENERIC); 
     1484        } 
     1485 
    14671486        /* Process 'D' for "Description" */ 
    14681487        else if (buf[0] == 'D') 
    14691488        { 
    1470                 /* There better be a current k_ptr */ 
    1471                 if (!k_ptr) return (PARSE_ERROR_MISSING_RECORD_HEADER); 
    1472  
    1473                 /* Get the text */ 
    1474                 s = buf+2; 
    1475  
    14761489                /* Store the text */ 
    1477                 if (!add_text(&(k_ptr->text), head, s)) 
     1490                if (!add_text(&(k_ptr->text), head, buf + 2)) 
    14781491                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    14791492        } 
  • trunk/src/obj-info.c

    r314 r317  
    479479        object_info_out_flags(o_ptr, &f1, &f2, &f3); 
    480480 
     481 
     482        /* New para */ 
     483        new_paragraph = TRUE; 
     484 
     485        /* Describe boring bits */ 
     486        if (o_ptr->tval == TV_FOOD) 
     487        { 
     488                p_text_out("It provides nourishment for about "); 
     489                text_out_c(TERM_L_GREEN, "%d", o_ptr->pval / 2); 
     490                text_out(" turns under normal conditions."); 
     491        } 
     492 
     493 
    481494        /* Describe the object */ 
     495        new_paragraph = TRUE; 
    482496        if (describe_stats(o_ptr, f1)) something = TRUE; 
    483497        if (describe_slay(o_ptr, f1)) something = TRUE; 
     
    573587 
    574588        /* Dump the info */ 
    575         new_paragraph = TRUE; 
    576589        has_info = object_info_out(o_ptr); 
    577590 
  • trunk/src/types.h

    r316 r317  
    190190        char x_char;            /* Desired object character */ 
    191191 
     192        u32b effect;            /* Effect (defined in effects.h) */ 
     193 
    192194        byte charge_base;       /* Charge base */ 
    193195        byte charge_dd, charge_ds;      /* Charge dice/sides */ 
  • trunk/src/use-obj.c

    r316 r317  
    1111#include "angband.h" 
    1212#include "script.h" 
    13  
    14  
    15 static bool eat_food(object_type *o_ptr, bool *ident) 
    16 
    17         /* Analyze the food */ 
    18         switch (o_ptr->sval) 
    19         { 
    20                 case SV_FOOD_POISON: 
    21                 { 
    22                         if (!(p_ptr->resist_pois || p_ptr->timed[TMD_OPP_POIS])) 
    23                         { 
    24                                 if (inc_timed(TMD_POISONED, rand_int(10) + 10)) 
    25                                 { 
    26                                         *ident = TRUE; 
    27                                 } 
    28                         } 
    29                         break; 
    30                 } 
    31  
    32                 case SV_FOOD_BLINDNESS: 
    33                 { 
    34                         if (!p_ptr->resist_blind) 
    35                         { 
    36                                 if (inc_timed(TMD_BLIND, rand_int(200) + 200)) 
    37                                 { 
    38                                         *ident = TRUE; 
    39                                 } 
    40                         } 
    41                         break; 
    42                 } 
    43  
    44                 case SV_FOOD_PARANOIA: 
    45                 { 
    46                         if (!p_ptr->resist_fear) 
    47                         { 
    48                                 if (inc_timed(TMD_AFRAID, rand_int(10) + 10)) 
    49                                 { 
    50                                         *ident = TRUE; 
    51                                 } 
    52                         } 
    53                         break; 
    54                 } 
    55  
    56                 case SV_FOOD_CONFUSION: 
    57                 { 
    58                         if (!p_ptr->resist_confu) 
    59                         { 
    60                                 if (inc_timed(TMD_CONFUSED, rand_int(10) + 10)) 
    61                                 { 
    62                                         *ident = TRUE; 
    63                                 } 
    64                         } 
    65                         break; 
    66                 } 
    67  
    68                 case SV_FOOD_HALLUCINATION: 
    69                 { 
    70                         if (!p_ptr->resist_chaos) 
    71                         { 
    72                                 if (inc_timed(TMD_IMAGE, rand_int(250) + 250)) 
    73                                 { 
    74                                         *ident = TRUE; 
    75                                 } 
    76                         } 
    77                         break; 
    78                 } 
    79  
    80                 case SV_FOOD_PARALYSIS: 
    81                 { 
    82                         if (!p_ptr->free_act) 
    83                         { 
    84                                 if (inc_timed(TMD_PARALYZED, rand_int(10) + 10)) 
    85                                 { 
    86                                         *ident = TRUE; 
    87                                 } 
    88                         } 
    89                         break; 
    90                 } 
    91  
    92                 case SV_FOOD_WEAKNESS: 
    93                 { 
    94                         take_hit(damroll(6, 6), "poisonous food"); 
    95                         (void)do_dec_stat(A_STR); 
    96                         *ident = TRUE; 
    97                         break; 
    98                 } 
    99  
    100                 case SV_FOOD_SICKNESS: 
    101                 { 
    102                         take_hit(damroll(6, 6), "poisonous food"); 
    103                         (void)do_dec_stat(A_CON); 
    104                         *ident = TRUE; 
    105                         break; 
    106                 } 
    107  
    108                 case SV_FOOD_STUPIDITY: 
    109                 { 
    110                         take_hit(damroll(8, 8), "poisonous food"); 
    111                         (void)do_dec_stat(A_INT); 
    112                         *ident = TRUE; 
    113                         break; 
    114                 } 
    115  
    116                 case SV_FOOD_NAIVETY: 
    117                 { 
    118                         take_hit(damroll(8, 8), "poisonous food"); 
    119                         (void)do_dec_stat(A_WIS); 
    120                         *ident = TRUE; 
    121                         break; 
    122                 } 
    123  
    124                 case SV_FOOD_UNHEALTH: 
    125                 { 
    126                         take_hit(damroll(10, 10), "poisonous food"); 
    127                         (void)do_dec_stat(A_CON); 
    128                         *ident = TRUE; 
    129                         break; 
    130                 } 
    131  
    132                 case SV_FOOD_DISEASE: 
    133                 { 
    134                         take_hit(damroll(10, 10), "poisonous food"); 
    135                         (void)do_dec_stat(A_STR); 
    136                         *ident = TRUE; 
    137                         break; 
    138                 } 
    139  
    140                 case SV_FOOD_CURE_POISON: 
    141                 { 
    142                         if (clear_timed(TMD_POISONED)) *ident = TRUE; 
    143                         break; 
    144                 } 
    145  
    146                 case SV_FOOD_CURE_BLINDNESS: 
    147                 { 
    148                         if (clear_timed(TMD_BLIND)) *ident = TRUE; 
    149                         break; 
    150                 } 
    151  
    152                 case SV_FOOD_CURE_PARANOIA: 
    153                 { 
    154                         if (clear_timed(TMD_AFRAID)) *ident = TRUE; 
    155                         break; 
    156                 } 
    157  
    158                 case SV_FOOD_CURE_CONFUSION: 
    159                 { 
    160                         if (clear_timed(TMD_CONFUSED)) *ident = TRUE; 
    161                         break; 
    162                 } 
    163  
    164                 case SV_FOOD_CURE_SERIOUS: 
    165                 { 
    166                         if (hp_player(damroll(4, 8))) *ident = TRUE; 
    167                         break; 
    168                 } 
    169  
    170                 case SV_FOOD_RESTORE_STR: 
    171                 { 
    172                         if (do_res_stat(A_STR)) *ident = TRUE; 
    173                         break; 
    174                 } 
    175  
    176                 case SV_FOOD_RESTORE_CON: 
    177                 { 
    178                         if (do_res_stat(A_CON)) *ident = TRUE; 
    179                         break; 
    180                 } 
    181  
    182                 case SV_FOOD_RESTORING: 
    183                 { 
    184                         if (do_res_stat(A_STR)) *ident = TRUE; 
    185                         if (do_res_stat(A_INT)) *ident = TRUE; 
    186                         if (do_res_stat(A_WIS)) *ident = TRUE; 
    187                         if (do_res_stat(A_DEX)) *ident = TRUE; 
    188                         if (do_res_stat(A_CON)) *ident = TRUE; 
    189                         if (do_res_stat(A_CHR)) *ident = TRUE; 
    190                         break; 
    191                 } 
    192  
    193  
    194                 case SV_FOOD_RATION: 
    195                 case SV_FOOD_BISCUIT: 
    196                 case SV_FOOD_JERKY: 
    197                 case SV_FOOD_SLIME_MOLD: 
    198                 { 
    199                         msg_print("That tastes good."); 
    200                         *ident = TRUE; 
    201                         break; 
    202                 } 
    203  
    204                 case SV_FOOD_WAYBREAD: 
    205                 { 
    206                         msg_print("That tastes good."); 
    207                         (void)clear_timed(TMD_POISONED); 
    208                         (void)hp_player(damroll(4, 8)); 
    209                         *ident = TRUE; 
    210                         break; 
    211                 } 
    212  
    213                 case SV_FOOD_PINT_OF_ALE: 
    214                 case SV_FOOD_PINT_OF_WINE: 
    215                 { 
    216                         msg_print("That tastes good."); 
    217                         *ident = TRUE; 
    218                         break; 
    219                 } 
    220         } 
    221  
    222         /* Food can feed the player */ 
    223         (void)set_food(p_ptr->food + o_ptr->pval); 
    224  
    225         return (TRUE); 
    226 
     13#include "effects.h" 
    22714 
    22815 
     
    24192206                case TV_FOOD: 
    24202207                { 
    2421                         used = eat_food(o_ptr, ident); 
     2208                        /* Food can feed the player */ 
     2209                        (void)set_food(p_ptr->food + o_ptr->pval); 
     2210 
     2211                        /* Make it happen! */ 
     2212                        used = do_effect(o_ptr, ident, dir); 
     2213 
    24222214                        break; 
    24232215                }