Changeset 889

Show
Ignore:
Timestamp:
05/11/08 21:11:07 (2 months ago)
Author:
takkaria
Message:

Use a new algorithm for how much gold is in each gold drop. It replaces to the previous and somewhat insane system such that gold increases linearly with level.

The graph at http://rephial.org/research/avg_gold_drop.pdf shows the effect of the change; in short, gold amounts up to dungeon level 40 are mostly the same, but vastly reduced after that. Additionally, there is less variance in the amount of gold (it is now 50%), such that most dungeon levels now have a higher minimum gold drop but a lower maximum.

Files:

Legend:

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

    r813 r889  
    35843584N:480:copper 
    35853585G:$:u 
     3586I:100:0:0 
     3587 
     3588N:481:silver 
     3589G:$:s 
    35863590I:100:1:0 
    3587 W:1:0:0:3 
    3588  
    3589 N:481:copper 
    3590 G:$:u 
     3591 
     3592N:482:garnets 
     3593G:$:r 
    35913594I:100:2:0 
    3592 W:1:0:0:4 
    3593  
    3594 N:482:copper 
    3595 G:$:u 
     3595 
     3596N:483:gold 
     3597G:$:y 
    35963598I:100:3:0 
    3597 W:1:0:0:5 
    3598  
    3599 N:483:silver 
    3600 G:$:s 
     3599 
     3600N:484:opals 
     3601G:$:W 
    36013602I:100:4:0 
    3602 W:1:0:0:6 
    3603  
    3604 N:484:silver 
    3605 G:$:s 
     3603 
     3604N:485:sapphires 
     3605G:$:b 
    36063606I:100:5:0 
    3607 W:1:0:0:7 
    3608  
    3609 N:485:silver 
    3610 G:$:s 
     3607 
     3608N:486:rubies 
     3609G:$:r 
    36113610I:100:6:0 
    3612 W:1:0:0:8 
    3613  
    3614 N:486:garnets 
    3615 G:$:r 
     3611 
     3612N:487:diamonds 
     3613G:$:w 
    36163614I:100:7:0 
    3617 W:1:0:0:9 
    3618  
    3619 N:487:garnets 
    3620 G:$:r 
     3615 
     3616N:488:emeralds 
     3617G:$:g 
    36213618I:100:8:0 
    3622 W:1:0:0:10 
    3623  
    3624 N:488:gold 
    3625 G:$:y 
     3619 
     3620N:489:mithril 
     3621G:$:B 
    36263622I:100:9:0 
    3627 W:1:0:0:12 
    3628  
    3629 N:489:gold 
    3630 G:$:y 
     3623 
     3624N:490:adamantite 
     3625G:$:G 
    36313626I:100:10:0 
    3632 W:1:0:0:14 
    3633  
    3634 N:490:gold 
    3635 G:$:y 
    3636 I:100:11:0 
    3637 W:1:0:0:16 
    3638  
    3639 N:491:opals 
    3640 G:$:W 
    3641 I:100:12:0 
    3642 W:1:0:0:18 
    3643  
    3644 N:492:sapphires 
    3645 G:$:b 
    3646 I:100:13:0 
    3647 W:1:0:0:20 
    3648  
    3649 N:493:rubies 
    3650 G:$:r 
    3651 I:100:14:0 
    3652 W:1:0:0:24 
    3653  
    3654 N:494:diamonds 
    3655 G:$:w 
    3656 I:100:15:0 
    3657 W:1:0:0:28 
    3658  
    3659 N:495:emeralds 
    3660 G:$:g 
    3661 I:100:16:0 
    3662 W:1:0:0:32 
    3663  
    3664 N:496:mithril 
    3665 G:$:B 
    3666 I:100:17:0 
    3667 W:1:0:0:38 
    3668  
    3669 N:497:adamantite 
    3670 G:$:G 
    3671 I:100:18:0 
    3672 W:1:0:0:46 
    36733627 
    36743628 
  • trunk/src/cmd1.c

    r887 r889  
    135135        for (this_o_idx = cave_o_idx[py][px]; this_o_idx; this_o_idx = next_o_idx) 
    136136        { 
    137                 int gold_type; 
    138  
    139137                /* Get the object */ 
    140138                o_ptr = &o_list[this_o_idx]; 
     
    147145                    (o_ptr->sval >= SV_GOLD_MAX)) continue; 
    148146 
    149                 /* Hack -- adjust treasure type (to avoid picking up "gold, gold, and gold") */ 
    150                 gold_type = o_ptr->sval; 
    151                 if ((gold_type == SV_COPPER2) || (gold_type == SV_COPPER3)) 
    152                         gold_type = SV_COPPER1; 
    153                 if ((gold_type == SV_SILVER2) || (gold_type == SV_SILVER3)) 
    154                         gold_type = SV_SILVER1; 
    155                 if ((gold_type == SV_GOLD2)   || (gold_type == SV_GOLD3)) 
    156                         gold_type = SV_GOLD1; 
    157                 if (gold_type == SV_GARNETS2) 
    158                         gold_type = SV_GARNETS1; 
    159  
    160147                /* Note that we have this kind of treasure */ 
    161                 treasure[gold_type]++; 
     148                treasure[o_ptr->sval]++; 
    162149 
    163150                /* Increment total value */ 
  • trunk/src/cmd2.c

    r887 r889  
    230230                /* Small chests often drop gold */ 
    231231                if (tiny && (rand_int(100) < 75)) 
    232                 { 
    233                         /* Make some gold */ 
    234                         if (!make_gold(i_ptr, value)) continue; 
    235                 } 
     232                        make_gold(i_ptr, value); 
    236233 
    237234                /* Otherwise drop an item */ 
    238235                else 
    239236                { 
    240                         /* Make an object */ 
    241                         if (!make_object(i_ptr, value, FALSE, FALSE)) continue; 
     237                        if (!make_object(i_ptr, value, FALSE, FALSE)) 
     238                               continue; 
    242239                } 
    243240 
  • trunk/src/load.c

    r887 r889  
    196196        switch (*tval) 
    197197        { 
     198                case TV_GOLD: 
     199                { 
     200                        if (*sval > SV_GOLD_MAX) 
     201                                *sval = SV_GOLD_MAX; 
     202                        return; 
     203                } 
     204 
    198205                case TV_FOOD: 
    199206                { 
  • trunk/src/obj-make.c

    r887 r889  
    14311431 
    14321432 
    1433 /* 
    1434  * XXX XXX XXX Do not use these hard-coded values. 
    1435  */ 
    1436 #define MAX_GOLD        18      /* Number of "gold" entries */ 
    1437  
    1438 /* 
    1439  * Make a treasure object 
    1440  * 
    1441  * The location must be a legal, clean, floor grid. 
    1442  */ 
    1443 bool make_gold(object_type *j_ptr, int lev) 
     1433/* The largest possible average gold drop at max depth with biggest spread */ 
     1434#define MAX_GOLD_DROP     (3*MAX_DEPTH + 30) 
     1435 
     1436 
     1437/* 
     1438 * Make a money object 
     1439 */ 
     1440void make_gold(object_type *j_ptr, int lev) 
    14441441{ 
    14451442        int sval; 
    14461443        int k_idx; 
    1447         s32b base; 
    1448  
    1449  
    1450         /* Hack -- Pick a Treasure variety */ 
    1451         sval = ((randint(lev + 2) + 2) / 2); 
    1452  
    1453         /* Apply "extra" magic */ 
    1454         if (one_in_(GREAT_OBJ)) 
    1455         { 
    1456                 sval += randint(lev + 1); 
    1457         } 
    1458  
    1459         /* Hack -- Creeping Coins only generate "themselves" */ 
    1460         if (coin_type) sval = coin_type; 
    1461  
    1462         /* Do not create "illegal" Treasure Types */ 
    1463         if (sval > MAX_GOLD) sval = MAX_GOLD; 
    1464  
     1444 
     1445        /* This average is 20 at dlev0, 105 at dlev40, 220 at dlev100. */ 
     1446        /* Follows the formula: y=2x+20 */ 
     1447        s32b avg = 2*lev + 20; 
     1448        s32b spread = lev + 10; 
     1449        s32b value = rand_spread(avg, spread); 
     1450 
     1451        /* Pick a treasure variety scaled by level, or force a type */ 
     1452        if (coin_type) 
     1453                sval = coin_type; 
     1454        else 
     1455                sval = (((value * 100) / MAX_GOLD_DROP) * SV_GOLD_MAX) / 100; 
     1456 
     1457        /* Do not create illegal treasure types */ 
     1458        if (sval > SV_GOLD_MAX) sval = SV_GOLD_MAX; 
     1459 
     1460        /* Prepare a gold object */ 
    14651461        k_idx = lookup_kind(TV_GOLD, sval); 
    1466  
    1467         /* Prepare a gold object */ 
    14681462        object_prep(j_ptr, k_idx); 
    1469  
    1470         /* Hack -- Base coin cost */ 
    1471         base = k_info[k_idx].cost; 
    1472  
    1473         /* Determine how much the treasure is "worth" */ 
    1474         j_ptr->pval = (base + (8L * randint(base)) + randint(8)); 
    1475  
    1476         /* Success */ 
    1477         return (TRUE); 
     1463        j_ptr->pval = value; 
    14781464} 
    14791465 
  • trunk/src/obj-util.c

    r887 r889  
    23842384 
    23852385        /* Make some gold */ 
    2386         if (make_gold(i_ptr, level)) 
    2387         { 
    2388                 /* Give it to the floor */ 
    2389                 (void)floor_carry(y, x, i_ptr); 
    2390         } 
     2386        make_gold(i_ptr, level); 
     2387 
     2388        /* Give it to the floor */ 
     2389        (void)floor_carry(y, x, i_ptr); 
    23912390} 
    23922391 
  • trunk/src/object.h

    r854 r889  
    6666void apply_magic(object_type *o_ptr, int lev, bool okay, bool good, bool great); 
    6767bool make_object(object_type *j_ptr, int lev, bool good, bool great); 
    68 bool make_gold(object_type *j_ptr, int lev); 
     68void make_gold(object_type *j_ptr, int lev); 
    6969int object_pseudo_heavy(const object_type *o_ptr); 
    7070int object_pseudo_light(const object_type *o_ptr); 
  • trunk/src/tvalsval.h

    r887 r889  
    510510 
    511511/* The "sval" codes for TV_GOLD */ 
    512 #define SV_COPPER1                        1 
    513 #define SV_COPPER2                        2 
    514 #define SV_COPPER3                        3 
    515 #define SV_SILVER1                        4 
    516 #define SV_SILVER2                        5 
    517 #define SV_SILVER3                        6 
    518 #define SV_GARNETS1                       7 
    519 #define SV_GARNETS2                       8 
    520 #define SV_GOLD1                          9 
    521 #define SV_GOLD2                         10 
    522 #define SV_GOLD3                         11 
    523 #define SV_OPALS                         12 
    524 #define SV_SAPPHIRES                     13 
    525 #define SV_RUBIES                        14 
    526 #define SV_DIAMONDS                      15 
    527 #define SV_EMERALDS                      16 
    528 #define SV_MITHRIL                       17 
    529 #define SV_ADAMANTITE                    18 
    530  
    531 #define SV_GOLD_MAX                      19 
    532  
     512enum 
     513
     514        SV_COPPER = 0, 
     515        SV_SILVER = 1, 
     516        SV_GARNETS = 2, 
     517        SV_GOLD = 3, 
     518        SV_OPALS = 4, 
     519        SV_SAPPHIRES = 5, 
     520        SV_RUBIES = 6, 
     521        SV_DIAMONDS = 7, 
     522        SV_EMERALDS = 8, 
     523        SV_MITHRIL = 9, 
     524        SV_ADAMANTITE = 10, 
     525 
     526        SV_GOLD_MAX = 10 
     527}; 
    533528 
    534529 
  • trunk/src/wizard.c

    r887 r889  
    10351035        if (k_info[k_idx].tval == TV_GOLD) 
    10361036        { 
    1037                 /* Hack -- Base coin cost */ 
    1038                 s32b base = k_info[k_idx].cost; 
    1039  
    1040                 /* Determine how much the treasure is "worth" */ 
    1041                 i_ptr->pval = (base + (8L * randint(base)) + randint(8)); 
     1037                coin_type = k_info[k_idx].sval; 
     1038                make_gold(i_ptr, p_ptr->depth); 
     1039                coin_type = 0; 
    10421040        } 
    10431041 
  • trunk/src/xtra2.c

    r887 r889  
    10931093        { 
    10941094                /* Look for textual clues */ 
    1095                 if (strstr(name, " copper ")) return (3); 
    1096                 if (strstr(name, " silver ")) return (6); 
    1097                 if (strstr(name, " gold ")) return (11); 
    1098                 if (strstr(name, " mithril ")) return (17); 
    1099                 if (strstr(name, " adamantite ")) return (18); 
     1095                if (strstr(name, " copper ")) return (SV_COPPER); 
     1096                if (strstr(name, " silver ")) return (SV_SILVER); 
     1097                if (strstr(name, " gold ")) return (SV_GOLD); 
     1098                if (strstr(name, " mithril ")) return (SV_MITHRIL); 
     1099                if (strstr(name, " adamantite ")) return (SV_ADAMANTITE); 
    11001100 
    11011101                /* Look for textual clues */ 
    1102                 if (strstr(name, "Copper ")) return (3); 
    1103                 if (strstr(name, "Silver ")) return (6); 
    1104                 if (strstr(name, "Gold ")) return (11); 
    1105                 if (strstr(name, "Mithril ")) return (17); 
    1106                 if (strstr(name, "Adamantite ")) return (18); 
     1102                if (strstr(name, "Copper ")) return (SV_COPPER); 
     1103                if (strstr(name, "Silver ")) return (SV_SILVER); 
     1104                if (strstr(name, "Gold ")) return (SV_GOLD); 
     1105                if (strstr(name, "Mithril ")) return (SV_MITHRIL); 
     1106                if (strstr(name, "Adamantite ")) return (SV_ADAMANTITE); 
    11071107        } 
    11081108 
     
    13011301                { 
    13021302                        /* Make some gold */ 
    1303                         if (!make_gold(i_ptr, level)) continue; 
    1304  
    1305                         /* Assume seen XXX XXX XXX */ 
     1303                        make_gold(i_ptr, level); 
    13061304                        dump_gold++; 
    13071305                } 
     
    13121310                        /* Make an object */ 
    13131311                        if (!make_object(i_ptr, level, good, great)) continue; 
    1314  
    1315                         /* Assume seen XXX XXX XXX */ 
    13161312                        dump_item++; 
    13171313                }