Changeset 319

Show
Ignore:
Timestamp:
07/10/07 12:12:46 (1 year ago)
Author:
takkaria
Message:

#234:

  • Move rings across to the new effects code.
  • Describe uses in the object recall again.
Files:

Legend:

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

    r318 r319  
    12441244F:RES_FIRE | IGNORE_FIRE |  
    12451245F:ACTIVATE 
     1246E:RING_FLAMES 
    12461247 
    12471248N:147:Acid 
     
    12531254F:RES_ACID | IGNORE_ACID |  
    12541255F:ACTIVATE 
     1256E:RING_ACID 
    12551257 
    12561258N:148:Ice 
     
    12621264F:RES_COLD | IGNORE_COLD |  
    12631265F:ACTIVATE 
     1266E:RING_ICE 
    12641267 
    12651268N:149:Woe 
     
    38063809A:50/2 
    38073810F:RES_ELEC | IGNORE_ELEC | ACTIVATE 
     3811E:RING_LIGHTNING 
    38083812 
    38093813### Items 432-436 unused ### 
  • trunk/src/effects.c

    r318 r319  
    1919#include "effects.h" 
    2020 
    21 #if 0 
    2221 
    2322/* 
     
    3837#undef MAKE_TABLE 
    3938 
    40 #endif 
     39 
     40/* 
     41 * Utility functions 
     42 */ 
     43bool effect_aim(int effect) 
     44
     45        if (effect < 1 || effect > EF_MAX) 
     46                return FALSE; 
     47 
     48        return effects[effect].aim; 
     49
     50 
     51const char *effect_desc(int effect) 
     52
     53        if (effect < 1 || effect > EF_MAX) 
     54                return FALSE; 
     55 
     56        return effects[effect].desc; 
     57
     58 
    4159 
    4260 
     
    529547                        return TRUE; 
    530548                } 
     549 
     550                case EF_RING_ACID: 
     551                { 
     552                        fire_ball(GF_ACID, dir, 70, 2); 
     553                        inc_timed(TMD_OPP_ACID, randint(20) + 20); 
     554                        return TRUE; 
     555                } 
     556 
     557                case EF_RING_FLAMES: 
     558                { 
     559                        fire_ball(GF_FIRE, dir, 80, 2); 
     560                        inc_timed(TMD_OPP_FIRE, randint(20) + 20); 
     561                        o_ptr->timeout = rand_int(50) + 50; 
     562                        return TRUE; 
     563                } 
     564 
     565                case EF_RING_ICE: 
     566                { 
     567                        fire_ball(GF_COLD, dir, 75, 2); 
     568                        inc_timed(TMD_OPP_COLD, randint(20) + 20); 
     569                        o_ptr->timeout = rand_int(50) + 50; 
     570                        return TRUE; 
     571                } 
     572 
     573                case EF_RING_LIGHTNING: 
     574                { 
     575                        fire_ball(GF_ELEC, dir, 85, 2); 
     576                        inc_timed(TMD_OPP_ELEC, randint(20) + 20); 
     577                        o_ptr->timeout = rand_int(50) + 50; 
     578                        return TRUE; 
     579                } 
    531580        } 
    532581 
  • trunk/src/effects.h

    r318 r319  
    1919 
    2020/* Function */ 
    21 extern bool do_effect(object_type *o_ptr, bool *ident, int dir); 
     21bool do_effect(object_type *o_ptr, bool *ident, int dir); 
     22bool effect_aim(int effect); 
     23const char *effect_desc(int effect); 
    2224 
    2325 
     
    2729 */ 
    2830#if defined(LIST_STRINGS) 
    29 # define START                          const char *effect_list[] = { 
     31# define START                          static const char *effect_list[] = { 
    3032# define EFFECT(x, y, z)        #x, 
    3133# define END                            }; 
    3234#elif defined(MAKE_TABLE) 
    33 # define START                          info_entry effects[] = { 
     35# define START                          static const info_entry effects[] = { 
    3436# define EFFECT(x, y, z)        { EF_##x, y, z }, 
    3537# define END                            }; 
     
    108110        EFFECT(FOOD_GOOD,      FALSE, NULL) 
    109111        EFFECT(FOOD_WAYBREAD,  FALSE, "restores 4d8 hit points and neutralizes poison")  
     112        EFFECT(RING_ACID,      TRUE,  "grants acid resistance for d20+20 turns and creates an acid ball of damage 70") 
     113        EFFECT(RING_FLAMES,    TRUE,  "grants fire resistance for d20+20 turns and creates an fire ball of damage 80") 
     114        EFFECT(RING_ICE,       TRUE,  "grants cold resistance for d20+20 turns and creates an cold ball of damage 75") 
     115        EFFECT(RING_LIGHTNING, TRUE,  "grants electricity resistance for d20+20 turns and creates an lightning ball of damage 85") 
    110116END 
    111117 
  • trunk/src/obj-info.c

    r317 r319  
    1717 */ 
    1818#include "angband.h" 
     19#include "effects.h" 
    1920#include "cmds.h" 
    2021 
     
    453454static bool describe_activation(const object_type *o_ptr, u32b f3) 
    454455{ 
    455         /* Check for the activation flag */ 
    456         if (f3 & TR3_ACTIVATE) 
    457         { 
    458                 p_text_out("It activates for "); 
    459                 describe_item_activation(o_ptr); 
     456        int effect = k_info[o_ptr->k_idx].effect; 
     457        char temp[] = "x"; 
     458 
     459        /* Make sure we have an effect */ 
     460        if (!k_info[o_ptr->k_idx].effect) 
     461        { 
     462                /* Check for the activation flag */ 
     463                if (f3 & TR3_ACTIVATE) 
     464                { 
     465                        p_text_out("It activates for "); 
     466                        describe_item_activation(o_ptr); 
     467                        text_out(".  "); 
     468 
     469                        return (TRUE); 
     470                } 
     471        } 
     472        else 
     473        { 
     474                const char *desc = effect_desc(effect); 
     475                if (!desc) return FALSE; 
     476 
     477                text_out("When "); 
     478 
     479                if (f3 & TR3_ACTIVATE) 
     480                        text_out("activated"); 
     481                else if (effect_aim(effect)) 
     482                        text_out("aimed"); 
     483                else if (o_ptr->tval == TV_FOOD || o_ptr->tval == TV_POTION) 
     484                        text_out("ingested"); 
     485                else if (o_ptr->tval == TV_SCROLL) 
     486                    text_out("read"); 
     487                else 
     488                    text_out("used"); 
     489 
     490                text_out(", it "); 
     491 
     492                /* Print a colourised description */ 
     493                do 
     494                { 
     495                        temp[0] = *desc; 
     496 
     497                        if (isdigit((unsigned char) *desc) || isdigit((unsigned char) *(desc + 1))) 
     498                                text_out_c(TERM_L_GREEN, temp); 
     499                        else 
     500                                text_out(temp); 
     501                } while (*desc++); 
     502 
    460503                text_out(".  "); 
    461  
    462                 return (TRUE); 
    463504        } 
    464505 
     
    488529                p_text_out("It provides nourishment for about "); 
    489530                text_out_c(TERM_L_GREEN, "%d", o_ptr->pval / 2); 
    490                 text_out(" turns under normal conditions."); 
     531                text_out(" turns under normal conditions.  "); 
    491532        } 
    492533 
  • trunk/src/use-obj.c

    r318 r319  
    17141714                        case SV_DRAGON_MULTIHUED: 
    17151715                        { 
    1716                                 chance = rand_int(5); 
    1717                                 sound(     ((chance == 1) ? MSG_BR_ELEC : 
    1718                                             ((chance == 2) ? MSG_BR_FROST : 
    1719                                              ((chance == 3) ? MSG_BR_ACID : 
    1720                                               ((chance == 4) ? MSG_BR_GAS : MSG_BR_FIRE))))); 
    1721                                 msg_format("You breathe %s.", 
    1722                                            ((chance == 1) ? "lightning" : 
    1723                                             ((chance == 2) ? "frost" : 
    1724                                              ((chance == 3) ? "acid" : 
    1725                                               ((chance == 4) ? "poison gas" : "fire"))))); 
    1726                                 fire_ball(((chance == 1) ? GF_ELEC : 
    1727                                            ((chance == 2) ? GF_COLD : 
    1728                                             ((chance == 3) ? GF_ACID : 
    1729                                              ((chance == 4) ? GF_POIS : GF_FIRE)))), 
    1730                                           dir, 250, 2); 
     1716                                static const struct 
     1717                                { 
     1718                                        int sound; 
     1719                                        const char *msg; 
     1720                                        int typ; 
     1721                                } mh[] = 
     1722                                { 
     1723                                        { MSG_BR_ELEC,  "lightning",  GF_ELEC }, 
     1724                                        { MSG_BR_FROST, "frost",      GF_COLD }, 
     1725                                        { MSG_BR_ACID,  "acid",       GF_ACID }, 
     1726                                        { MSG_BR_GAS,   "poison gas", GF_POIS }, 
     1727                                        { MSG_BR_FIRE,  "fire",       GF_FIRE } 
     1728                                }; 
     1729 
     1730                                chance = randint(5); 
     1731                                sound(mh[chance].sound); 
     1732                                msg_format("You breathe %s.", mh[chance].msg); 
     1733                                fire_ball(mh[chance].typ, dir, 250, 2); 
    17311734                                o_ptr->timeout = rand_int(225) + 225; 
    17321735                                break; 
     
    18181821        } 
    18191822 
    1820         /* Hack -- some Rings can be activated for double resist and element ball */ 
    1821         if (o_ptr->tval == TV_RING) 
    1822         { 
    1823                 /* Get a direction for firing (or abort) */ 
    1824                 if (!get_aim_dir(&dir)) return FALSE; 
    1825  
    1826                 /* Branch on the sub-type */ 
    1827                 switch (o_ptr->sval) 
    1828                 { 
    1829                         case SV_RING_ACID: 
    1830                         { 
    1831                                 fire_ball(GF_ACID, dir, 70, 2); 
    1832                                 inc_timed(TMD_OPP_ACID, randint(20) + 20); 
    1833                                 o_ptr->timeout = rand_int(50) + 50; 
    1834                                 break; 
    1835                         } 
    1836  
    1837                         case SV_RING_FLAMES: 
    1838                         { 
    1839                                 fire_ball(GF_FIRE, dir, 80, 2); 
    1840                                 inc_timed(TMD_OPP_FIRE, randint(20) + 20); 
    1841                                 o_ptr->timeout = rand_int(50) + 50; 
    1842                                 break; 
    1843                         } 
    1844  
    1845                         case SV_RING_ICE: 
    1846                         { 
    1847                                 fire_ball(GF_COLD, dir, 75, 2); 
    1848                                 inc_timed(TMD_OPP_COLD, randint(20) + 20); 
    1849                                 o_ptr->timeout = rand_int(50) + 50; 
    1850                                 break; 
    1851                         } 
    1852  
    1853                         case SV_RING_LIGHTNING: 
    1854                         { 
    1855                                 fire_ball(GF_ELEC, dir, 85, 2); 
    1856                                 inc_timed(TMD_OPP_ELEC, randint(20) + 20); 
    1857                                 o_ptr->timeout = rand_int(50) + 50; 
    1858                                 break; 
    1859                         } 
    1860                 } 
    1861  
    1862                 /* Window stuff */ 
    1863                 p_ptr->window |= (PW_EQUIP); 
    1864  
    1865                 /* Success */ 
    1866                 return FALSE; 
    1867         } 
    1868  
    18691823        /* Mistake */ 
    18701824        msg_print("Oops.  That object cannot be activated."); 
     
    19271881                default: 
    19281882                { 
    1929                         used = activate_object(o_ptr, ident); 
     1883                        if (artifact_p(o_ptr) || o_ptr->tval == TV_DRAG_ARMOR) 
     1884                                used = activate_object(o_ptr, ident); 
     1885                        else 
     1886                                used = do_effect(o_ptr, ident, dir); 
     1887 
    19301888                        break; 
    19311889                } 
     
    20301988        if (o_ptr->tval == TV_RING) 
    20311989        { 
    2032                 /* Branch on the sub-type */ 
    2033                 switch (o_ptr->sval) 
    2034                 { 
    2035                         case SV_RING_ACID: 
    2036                         { 
    2037                                 text_out("acid resistance (20+d20 turns) and acid ball (70) every 50+d50 turns"); 
    2038                                 break; 
    2039                         } 
    2040                         case SV_RING_FLAMES: 
    2041                         { 
    2042                                 text_out("fire resistance (20+d20 turns) and fire ball (80) every 50+d50 turns"); 
    2043                                 break; 
    2044                         } 
    2045                         case SV_RING_ICE: 
    2046                         { 
    2047                                 text_out("cold resistance (20+d20 turns) and cold ball (75) every 50+d50 turns"); 
    2048                                 break; 
    2049                         } 
    2050  
    2051                         case SV_RING_LIGHTNING: 
    2052                         { 
    2053                                 text_out("electricity resistance (20+d20 turns) and electricity ball (85) every 50+d50 turns"); 
    2054                                 break; 
    2055                         } 
    2056                 } 
     1990                text_out(" every 50+d50 turns"); 
    20571991 
    20581992                return;