/* * Do not use this hard-coded value. */ #define MAX_GOLD 18 /* Number of "gold" entries */ /* * Make a treasure object. * * Note that there are so many hacks in this function, it should probably * be rewritten to use lookup tables or some such. * * The location must be a legal, clean, floor grid. */ bool make_gold(object_type *j_ptr) { int i, k_idx; s32b base; /* Hack -- Pick a Treasure variety */ i = ((randint(object_level + 2) + 2) / 2) - 1; /* Lookup that entry */ k_idx = lookup_kind(TV_GOLD, 0) + i; /* Apply "extra" magic */ if (rand_int(GREAT_OBJ) == 0) { i += randint(object_level + 1); } /* Hack -- Creeping Coins only generate "themselves" */ if (coin_type) i = coin_type; /* Do not create "illegal" Treasure Types */ if (i >= MAX_GOLD) i = MAX_GOLD - 1; /* Prepare a gold object */ object_prep(j_ptr, k_idx); /* Hack -- Base coin cost */ base = k_info[k_idx].cost; /* Determine how much the treasure is "worth" */ j_ptr->pval = (base + (8L * randint(base)) + randint(8)); /* Success */ return (TRUE); }