Changeset 163

Show
Ignore:
Timestamp:
06/06/07 18:20:49 (3 years ago)
Author:
takkaria
Message:

Code for #88 (lantern/torch behaviour and features).

Normal stores no longer sell lanterns, and no longer buy back food or non-ego/artifact lights. Lights don't use up any fuel during the daytime in the town.

Introduce the following ego-items:

  • of Brightness; LITE (+1 radius light)
  • (Everburning); NO_FUEL

Also add these, commented out until the ID issue can be fixed:

  • of Shadows; STEALTH | RES_LITE (may eventually have a chance of being cursed)
    • of True Sight; RES_BLIND | SEE_INVIS
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/COPYING

    r150 r163  
    2424   otherwise, would be much appreciated.  Note that as a result of these 
    2525   remaining restrictions, the game itself is not quite GPL-clean. 
     26 
     27 * The SDL runtime libraries (if provided with your copy of the game) are under 
     28   the following licence: 
     29 
     30     The Simple DirectMedia Layer (SDL for short) is a cross-platfrom library 
     31     designed to make it easy to write multi-media software, such as games and 
     32     emulators. 
     33 
     34     The Simple DirectMedia Layer library source code is available from: 
     35     http://www.libsdl.org/ 
     36 
     37     This library is distributed under the terms of the GNU LGPL license: 
     38     http://www.gnu.org/copyleft/lesser.html 
    2639 
    2740 * Adam Bolt's (16x16) graphics may be redistributed and used for any purpose,  
  • trunk/lib/edit/artifact.txt

    r157 r163  
    8484W:5:5:10:10000 
    8585P:0:1d1:0:0:0 
    86 F:ACTIVATE |  
     86F:ACTIVATE | NO_FUEL | 
    8787F:INSTA_ART 
    8888A:ILLUMINATION:10:10 
     
    9797W:30:25:5:30000 
    9898P:0:1d1:0:0:0 
    99 F:ACTIVATE | SEE_INVIS |  
     99F:ACTIVATE | SEE_INVIS | NO_FUEL | 
    100100F:INSTA_ART 
    101101A:MAGIC_MAP:50:50 
     
    108108W:50:50:5:50000 
    109109P:0:1d1:0:0:0 
    110 F:ACTIVATE | SEE_INVIS | HOLD_LIFE | RES_LITE | RES_DARK |  
     110F:ACTIVATE | SEE_INVIS | HOLD_LIFE | RES_LITE | RES_DARK | NO_FUEL | 
    111111F:INSTA_ART 
    112112A:DETECT:30:30 
     
    163163P:0:10d10:0:0:0 
    164164# F:DRAIN_MANA |  
    165 F:ACTIVATE |  
     165F:ACTIVATE | NO_FUEL | 
    166166F:INT | WIS | SEARCH | INFRA | SEE_INVIS | TELEPATHY |  
    167167F:RES_CHAOS | RES_BLIND | AGGRAVATE | DRAIN_EXP |  
  • trunk/lib/edit/ego_item.txt

    r157 r163  
    755755F:CON | KILL_DRAGON | RES_FEAR 
    756756 
    757 # 96 (unused) 
    758  
    759 # 97 (unused) 
    760  
    761 # 98 (unused) 
    762  
    763 # 99 (unused) 
     757 
     758### Lanterns/torches 
     759 
     760# Not for now -- need to figure out how ID applies 
     761#N:96:of Shadows 
     762#X:10:0 
     763#W:5:4:0:1000 (imported from NPP) 
     764#C:0:0:0:2 
     765#T:39:0:1 
     766#F:STEALTH | HIDE_TYPE | RES_LITE 
     767 
     768N:97:of Brightness 
     769X:10:0 
     770W:0:2:0:2000 
     771C:0:0:0:0 
     772T:39:0:1 
     773F:LITE 
     774 
     775N:98:(Everburning) 
     776X:10:0 
     777W:0:3:0:2500 
     778C:0:0:0:0 
     779T:39:1:1 (lanterns only) 
     780F:NO_FUEL 
     781 
     782#N:99:of True Sight 
     783#X:10:0 
     784#W:depth:rarity:extra weight:cost 
     785#W:20:8:0:6000 (imported from S) 
     786#C:0:0:0:0 
     787#T:39:0:1 
     788#F:RES_BLIND | SEE_INVIS 
     789 
    764790 
    765791### Digging Tools 
  • trunk/lib/edit/object.txt

    r157 r163  
    31343134D: turns of light. 
    31353135 
    3136 N:347:& Brass Lantern~ 
     3136N:347:& Lantern~ 
    31373137G:~:U 
    31383138I:39:1:0 
     
    31513151P:0:2d6:0:0:0 
    31523152F:EASY_KNOW 
    3153 D:It can be used to fuel a brass lantern with 7500 turns of light, up to 
     3153D:It can be used to fuel a lantern with 7500 turns of light, up to 
    31543154D: a maximum of 15000 turns of light. 
    31553155D:  When thrown, it is considered lit, so it does more than nominal 
  • trunk/src/defines.h

    r158 r163  
    288288 * Refueling constants 
    289289 */ 
    290 #define FUEL_TORCH      5000  /* Maximum amount of fuel in a torch */ 
     290#define FUEL_TORCH      6000  /* Maximum amount of fuel in a torch */ 
    291291#define FUEL_LAMP       15000   /* Maximum amount of fuel in a lantern */ 
    292292 
     
    18501850#define TR3_FREE_ACT        0x00000040L /* Free action */ 
    18511851#define TR3_HOLD_LIFE       0x00000080L /* Hold life */ 
    1852 #define TR3_XXX1            0x00000100L 
     1852#define TR3_NO_FUEL         0x00000100L /* Light source uses no fuel */ 
    18531853#define TR3_XXX2            0x00000200L 
    18541854#define TR3_XXX3            0x00000400L 
  • trunk/src/dungeon.c

    r156 r163  
    896896        if (o_ptr->tval == TV_LITE) 
    897897        { 
    898                 /* Hack -- Use some fuel (except on artifacts) */ 
    899                 if (!artifact_p(o_ptr) && (o_ptr->timeout > 0)) 
     898                u32b f1, f2, f3; 
     899                bool burn_fuel = TRUE; 
     900 
     901                /* Get the object flags */ 
     902                object_flags(o_ptr, &f1, &f2, &f3); 
     903 
     904                /* Turn off the wanton burning of light during the day in the town */ 
     905                if (!p_ptr->depth && ((turn % (10L * TOWN_DAWN)) < ((10L * TOWN_DAWN) / 2))) 
     906                        burn_fuel = FALSE; 
     907 
     908                /* If the light has the NO_FUEL flag, well... */ 
     909                if (f3 & TR3_NO_FUEL) 
     910                    burn_fuel = FALSE; 
     911 
     912                /* Use some fuel (except on artifacts, or during the day) */ 
     913                if (burn_fuel && o_ptr->timeout > 0) 
    900914                { 
    901915                        /* Decrease life-span */ 
  • trunk/src/init1.c

    r155 r163  
    449449        "FREE_ACT", 
    450450        "HOLD_LIFE", 
    451         "XXX1", 
     451        "NO_FUEL", 
    452452        "XXX2", 
    453453        "XXX3", 
  • trunk/src/main-sdl.c

    r148 r163  
    34783478        while (my_dread(dir, buf, sizeof buf)) 
    34793479        { 
    3480                 /* Check for at least an extension */ 
    3481                 signed extension_pos = strlen(buf) - 4; 
    3482                 if (extension_pos <= 0) continue; 
    3483  
    34843480                /* Check for file extension */ 
    3485                 if (strcmp((buf + extension_pos), ".fon") == 0
     3481                if (suffix(buf, ".fon")
    34863482                        FontList[num_fonts++] = string_make(buf); 
    34873483 
  • trunk/src/object1.c

    r156 r163  
    13101310        if (mode < 2) goto object_desc_done; 
    13111311 
    1312         /* Hack -- Process Lanterns/Torches */ 
    1313         if ((o_ptr->tval == TV_LITE) && (!artifact_p(o_ptr))) 
    1314         { 
    1315                 /* Hack -- Turns of light for normal lites */ 
    1316                 object_desc_str_macro(t, " (with "); 
     1312        /* Fuelled light sources get number of remaining turns appended */ 
     1313        if ((o_ptr->tval == TV_LITE) && !(f3 & TR3_NO_FUEL)) 
     1314        { 
     1315                /* Turns of light for normal lites */ 
     1316                object_desc_str_macro(t, " ("); 
    13171317                object_desc_num_macro(t, o_ptr->timeout); 
    1318                 object_desc_str_macro(t, " turns of light)"); 
     1318                object_desc_str_macro(t, " turns)"); 
    13191319        } 
    13201320 
  • trunk/src/spells2.c

    r158 r163  
    515515        { 
    516516                info[i++] = "You land gently."; 
    517         } 
    518         if (p_ptr->lite) 
    519         { 
    520                 info[i++] = "You are glowing with light."; 
    521517        } 
    522518        if (p_ptr->regenerate) 
  • trunk/src/store.c

    r156 r163  
    251251                        switch (o_ptr->tval) 
    252252                        { 
    253                                 case TV_FOOD: 
    254                                 case TV_LITE: 
    255                                 case TV_FLASK: 
    256253                                case TV_SPIKE: 
    257254                                case TV_SHOT: 
     
    260257                                case TV_DIGGING: 
    261258                                case TV_CLOAK: 
    262                                 break; 
     259                                        break; 
     260 
     261                                case TV_LITE: 
     262                                        if (artifact_p(o_ptr) || ego_item_p(o_ptr)) 
     263                                                break; 
     264 
    263265                                default: 
    264                                 return (FALSE); 
     266                                       return (FALSE); 
    265267                        } 
    266268                        break; 
     
    282284                                case TV_HARD_ARMOR: 
    283285                                case TV_DRAG_ARMOR: 
    284                                 break; 
     286                                        break; 
     287 
    285288                                default: 
    286                                 return (FALSE); 
     289                                       return (FALSE); 
    287290                        } 
    288291                        break; 
     
    303306                                case TV_POLEARM: 
    304307                                case TV_SWORD: 
    305                                 break; 
     308                                        break; 
     309 
    306310                                default: 
    307                                 return (FALSE); 
     311                                       return (FALSE); 
    308312                        } 
    309313                        break; 
     
    320324                                case TV_POTION: 
    321325                                case TV_HAFTED: 
    322                                 break; 
     326                                        break; 
     327 
    323328                                case TV_POLEARM: 
    324329                                case TV_SWORD: 
     
    327332                                        if (is_blessed(o_ptr) && object_known_p(o_ptr)) break; 
    328333                                } 
     334 
    329335                                default: 
    330                                 return (FALSE); 
     336                                       return (FALSE); 
    331337                        } 
    332338                        break; 
     
    341347                                case TV_SCROLL: 
    342348                                case TV_POTION: 
    343                                 break; 
     349                                        break; 
     350 
    344351                                default: 
    345                                 return (FALSE); 
     352                                       return (FALSE); 
    346353                        } 
    347354                        break; 
     
    362369                                case TV_SCROLL: 
    363370                                case TV_POTION: 
    364                                 break; 
     371                                        break; 
     372                                 
    365373                                default: 
    366                                 return (FALSE); 
     374                                       return (FALSE); 
    367375                        } 
    368376                        break; 
     
    10481056 * 
    10491057 * Based on a suggestion by Lee Vogt <lvogt@cig.mcel.mot.com>. 
    1050  * 
    1051  * If the stores ever become truly externalised, i.e. if Lua becomes more 
    1052  * integrated, then there should be some way to get this out of the compiled 
    1053  * code, as it is a little hacky.  XXX 
    10541058 */ 
    10551059static bool black_market_ok(const object_type *o_ptr) 
     
    10581062 
    10591063        /* Ego items are always fine */ 
    1060         if (o_ptr->name2) return (TRUE); 
     1064        if (ego_item_p(o_ptr)) return (TRUE); 
    10611065 
    10621066        /* Good items are normally fine */ 
     
    12791283        { TV_FOOD, SV_FOOD_PINT_OF_WINE, MAKE_NORMAL }, 
    12801284        { TV_LITE, SV_LITE_TORCH, MAKE_NORMAL }, 
    1281         { TV_LITE, SV_LITE_LANTERN, MAKE_NORMAL }, 
    12821285        { TV_FLASK, 0, MAKE_NORMAL }, 
    12831286        { TV_SPIKE, 0, MAKE_NORMAL }, 
  • trunk/src/types.h

    r156 r163  
    10181018        bool slow_digest;       /* Slower digestion */ 
    10191019        bool ffall;                     /* Feather falling */ 
    1020         bool lite;                      /* Permanent light */ 
    10211020        bool regenerate;        /* Regeneration */ 
    10221021        bool telepathy;         /* Telepathy */ 
  • trunk/src/variable.c

    r141 r163  
    372372        "kill_king", 
    373373        "drain_stat", 
    374         "multiply", 
     374        "multiply" 
    375375}; 
    376376 
  • trunk/src/xtra1.c

    r158 r163  
    847847 
    848848/* 
    849  * Prints the speed of a character.                    -CJS- 
     849 * Prints the speed of a character. 
    850850 */ 
    851851static void prt_speed(int row, int col) 
     
    854854 
    855855        byte attr = TERM_WHITE; 
     856        const char *type = NULL; 
    856857        char buf[32] = ""; 
    857858 
     
    863864        { 
    864865                attr = TERM_L_GREEN; 
    865                 strnfmt(buf, sizeof(buf), "Fast (+%d)", (i - 110))
     866                type = "Fast"
    866867        } 
    867868 
     
    870871        { 
    871872                attr = TERM_L_UMBER; 
    872                 strnfmt(buf, sizeof(buf), "Slow (-%d)", (110 - i)); 
    873         } 
     873                type = "Slow"; 
     874        } 
     875 
     876        if (type) 
     877                strnfmt(buf, sizeof(buf), "%s (%+d)", type, (i - 110)); 
    874878 
    875879        /* Display the speed */ 
     
    16491653 
    16501654/* 
    1651  * Extract and set the current "lite radius" 
     1655 * Calculate and set the current light radius. 
     1656 * 
     1657 * The brightest wielded object counts as the light source; radii do not add 
     1658 * up anymore. 
     1659 * 
     1660 * Note that a cursed light source no longer emits light. 
    16521661 */ 
    16531662static void calc_torch(void) 
    16541663{ 
    16551664        int i; 
    1656         object_type *o_ptr; 
    1657         u32b f1, f2, f3; 
    16581665 
    16591666        s16b old_lite = p_ptr->cur_lite; 
    1660  
    1661  
    1662         /* Assume no light */ 
    1663         p_ptr->cur_lite = 0; 
    1664  
    1665         /* Loop through all wielded items */ 
     1667        s16b new_lite = 0; 
     1668        bool burn_light = TRUE; 
     1669 
     1670 
     1671        /* Ascertain lightness if in the town */ 
     1672        if (!p_ptr->depth && ((turn % (10L * TOWN_DAWN)) < ((10L * TOWN_DAWN) / 2))) 
     1673                burn_light = FALSE; 
     1674 
     1675 
     1676        /* Examine all wielded objects, use the brightest */ 
    16661677        for (i = INVEN_WIELD; i < INVEN_TOTAL; i++) 
    16671678        { 
    1668                 o_ptr = &inventory[i]; 
     1679                u32b f1, f2, f3; 
     1680 
     1681                int amt = 0; 
     1682                object_type *o_ptr = &inventory[i]; 
    16691683 
    16701684                /* Skip empty slots */ 
    16711685                if (!o_ptr->k_idx) continue; 
    16721686 
     1687                /* Extract the flags */ 
     1688                object_flags(o_ptr, &f1, &f2, &f3); 
     1689 
     1690                /* LITE flag on an object always increases radius */ 
     1691                if (f3 & TR3_LITE) amt++; 
     1692 
     1693                /* Cursed objects emit no light */ 
     1694                if (o_ptr->ident & IDENT_CURSED) 
     1695                { 
     1696                        amt = 0; 
     1697                } 
     1698 
    16731699                /* Examine actual lites */ 
    1674                 if (o_ptr->tval == TV_LITE) 
    1675                 { 
    1676                         /* Artifact Lites provide permanent, bright, lite */ 
     1700                else if (o_ptr->tval == TV_LITE) 
     1701                { 
     1702                        /* Artifact Lites provide permanent bright light */ 
    16771703                        if (artifact_p(o_ptr)) 
     1704                                amt += 3; 
     1705 
     1706                        /* Non-artifact lights and those without fuel provide no light */ 
     1707                        else if (!burn_light || o_ptr->timeout == 0) 
     1708                            amt = 0; 
     1709 
     1710                        /* All lit lights provide at least radius 2 light */ 
     1711                        else 
    16781712                        { 
    1679                                 p_ptr->cur_lite += 3; 
    1680                                 continue; 
     1713                                amt += 2; 
     1714 
     1715                                /* Torches below half fuel provide less light */ 
     1716                                if (o_ptr->sval == SV_LITE_TORCH && o_ptr->timeout < (FUEL_TORCH / 4)) 
     1717                                    amt--; 
    16811718                        } 
    1682                          
    1683                         /* Lanterns (with fuel) provide more lite */ 
    1684                         if ((o_ptr->sval == SV_LITE_LANTERN) && (o_ptr->timeout > 0)) 
    1685                         { 
    1686                                 p_ptr->cur_lite += 2; 
    1687                                 continue; 
    1688                         } 
    1689                          
    1690                         /* Torches (with fuel) provide some lite */ 
    1691                         if ((o_ptr->sval == SV_LITE_TORCH) && (o_ptr->timeout > 0)) 
    1692                         { 
    1693                                 p_ptr->cur_lite += 1; 
    1694                                 continue; 
    1695                         } 
    1696                 } 
    1697                 else 
    1698                 { 
    1699                         /* Extract the flags */ 
    1700                         object_flags(o_ptr, &f1, &f2, &f3); 
    1701  
    1702                         /* does this item glow? */ 
    1703                         if (f3 & TR3_LITE) p_ptr->cur_lite++; 
    1704                 } 
    1705         } 
    1706  
    1707  
    1708         /* Player is glowing */ 
    1709         if (p_ptr->lite) p_ptr->cur_lite++; 
    1710  
     1719                } 
     1720 
     1721                /* Alter p_ptr->cur_lite if reasonable */ 
     1722                if (new_lite < amt) 
     1723                    new_lite = amt; 
     1724        } 
     1725 
     1726        /* Limit light radius (paranoia) */ 
     1727        new_lite = MIN(new_lite, 4); 
     1728        new_lite = MAX(new_lite, 0); 
    17111729 
    17121730        /* Notice changes in the "lite radius" */ 
    1713         if (old_lite != p_ptr->cur_lite) 
     1731        if (old_lite != new_lite) 
    17141732        { 
    17151733                /* Update the visuals */ 
     1734                p_ptr->cur_lite = new_lite; 
    17161735                p_ptr->update |= (PU_UPDATE_VIEW | PU_MONSTERS); 
    17171736        } 
     
    18491868        p_ptr->hold_life = FALSE; 
    18501869        p_ptr->telepathy = FALSE; 
    1851         p_ptr->lite = FALSE; 
    18521870        p_ptr->sustain_str = FALSE; 
    18531871        p_ptr->sustain_int = FALSE; 
     
    19211939        if (f3 & (TR3_SLOW_DIGEST)) p_ptr->slow_digest = TRUE; 
    19221940        if (f3 & (TR3_FEATHER)) p_ptr->ffall = TRUE; 
    1923         if (f3 & (TR3_LITE)) p_ptr->lite = TRUE; 
    19241941        if (f3 & (TR3_REGEN)) p_ptr->regenerate = TRUE; 
    19251942        if (f3 & (TR3_TELEPATHY)) p_ptr->telepathy = TRUE; 
  • trunk/src/xtra2.c

    r158 r163  
    5858        { "Your eyes begin to tingle!", "Your eyes stop tingling.", 0, 0, (PU_BONUS | PU_MONSTERS), MSG_INFRARED }, 
    5959        { "You feel resistant to poison!", "You feel less resistant to poison", PR_OPPOSE_ELEMENTS, 0, 0, MSG_RES_POIS }, 
    60         { "You feel your memories fade.", "Suddenly you can remember things again.", PR_CONFUSED, 0, 0, MSG_GENERIC }, 
     60        { "You feel your memories fade.", "Your memories come flooding back.", PR_CONFUSED, 0, 0, MSG_GENERIC }, 
    6161}; 
    6262