Changeset 856
- Timestamp:
- 04/28/08 22:51:05 (3 months ago)
- Files:
-
- trunk/lib/edit/cost_adj.txt (deleted)
- trunk/src/init1.c (modified) (2 diffs)
- trunk/src/init2.c (modified) (2 diffs)
- trunk/src/store.c (modified) (5 diffs)
- trunk/src/tables.c (modified) (1 diff)
- trunk/src/types.h (modified) (1 diff)
- trunk/src/variable.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/init1.c
r849 r856 2972 2972 2973 2973 /* Scan for the values */ 2974 if (3 != sscanf(buf+2, "%d:%d :%d",2975 &idx, &gld , &inflate)) return (PARSE_ERROR_GENERIC);2974 if (3 != sscanf(buf+2, "%d:%d", 2975 &idx, &gld)) return (PARSE_ERROR_GENERIC); 2976 2976 2977 2977 /* Save the values */ 2978 2978 ot_ptr->owner_race = idx; 2979 2979 ot_ptr->max_cost = gld; 2980 ot_ptr->inflate = inflate;2981 2980 } 2982 2981 else … … 2991 2990 2992 2991 2993 2994 2995 /*2996 * Initialize the "g_info" array, by parsing an ascii "template" file2997 */2998 errr parse_g_info(char *buf, header *head)2999 {3000 int i, j;3001 3002 char *s;3003 3004 /* Current entry */3005 static byte *g_ptr;3006 3007 3008 /* Process 'A' for "Adjustments" */3009 if (buf[0] == 'A')3010 {3011 int adj;3012 3013 /* Start the string */3014 s = buf+1;3015 3016 /* Initialize the counter to max races */3017 j = z_info->p_max;3018 3019 /* Repeat */3020 while (j-- > 0)3021 {3022 /* Hack - get the index */3023 i = error_idx + 1;3024 3025 /* Verify information */3026 if (i <= error_idx) return (PARSE_ERROR_NON_SEQUENTIAL_RECORDS);3027 3028 /* Verify information */3029 if (i >= head->info_num) return (PARSE_ERROR_TOO_MANY_ENTRIES);3030 3031 /* Save the index */3032 error_idx = i;3033 3034 /* Point at the "info" */3035 g_ptr = (byte*)head->info_ptr + i;3036 3037 /* Find the colon before the subindex */3038 s = strchr(s, ':');3039 3040 /* Verify that colon */3041 if (!s) return (PARSE_ERROR_GENERIC);3042 3043 /* Nuke the colon, advance to the subindex */3044 *s++ = '\0';3045 3046 /* Get the value */3047 adj = atoi(s);3048 3049 /* Save the value */3050 *g_ptr = adj;3051 }3052 }3053 else3054 {3055 /* Oops */3056 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);3057 }3058 3059 /* Success */3060 return (0);3061 }3062 2992 3063 2993 trunk/src/init2.c
r815 r856 877 877 878 878 /* 879 * Initialize the "g_info" array880 */881 static errr init_g_info(void)882 {883 errr err;884 885 /* Init the header */886 init_header(&g_head, (u16b)(z_info->p_max * z_info->p_max), sizeof(byte));887 888 #ifdef ALLOW_TEMPLATES889 890 /* Save a pointer to the parsing function */891 g_head.parse_info_txt = parse_g_info;892 893 #endif /* ALLOW_TEMPLATES */894 895 err = init_info("cost_adj", &g_head);896 897 /* Set the global variables */898 g_info = g_head.info_ptr;899 g_name = g_head.name_ptr;900 g_text = g_head.text_ptr;901 902 return (err);903 }904 905 906 /*907 879 * Initialize the "flavor_info" array 908 880 */ … … 1465 1437 event_signal_string(EVENT_INITSTATUS, "Initializing arrays... (owners)"); 1466 1438 if (init_b_info()) quit("Cannot initialize owners"); 1467 1468 /* Initialize price info */1469 event_signal_string(EVENT_INITSTATUS, "Initializing arrays... (prices)");1470 if (init_g_info()) quit("Cannot initialize prices");1471 1439 1472 1440 /* Initialize flavor info */ trunk/src/store.c
r847 r856 393 393 * == FALSE means the shop is selling, player buying 394 394 * 395 * This function takes into account the player's charisma, and the 396 * shop-keepers friendliness, and the shop-keeper's base greed, but 395 * This function takes into account the player's charisma, but 397 396 * never lets a shop-keeper lose money in a transaction. 398 397 * … … 401 400 * 402 401 * Hack -- the black market always charges twice as much as it should. 403 *404 * Charisma adjustment runs from 80 to 130405 * Racial adjustment runs from 95 to 130406 *407 * Since greed/charisma/racial adjustments are centered at 100, we need408 * to adjust (by 200) to extract a usable multiplier. Note that the409 * "greed" value is always something (?).410 402 */ 411 403 s32b price_item(const object_type *o_ptr, bool store_buying, int qty) 412 404 { 413 int factor;414 405 int adjust; 415 406 s32b price; 416 407 417 408 owner_type *ot_ptr = store_owner(store_current); 418 419 /* The greed value is always of the current store's owner */420 int greed = ot_ptr->inflate;421 409 422 410 … … 431 419 432 420 433 /* Compute the racial factor */434 factor = g_info[(ot_ptr->owner_race * z_info->p_max) + p_ptr->prace];435 436 421 /* Add in the charisma factor */ 437 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]]; 422 if (store_current == STORE_B_MARKET) 423 adjust = 150; 424 else 425 adjust = adj_chr_gold[p_ptr->stat_ind[A_CHR]]; 438 426 439 427 … … 441 429 if (store_buying) 442 430 { 443 /* Adjust for greed */ 444 adjust = 100 + (300 - (greed + factor)); 445 446 /* Never get "silly" */ 431 /* Set the factor */ 432 adjust = 100 + (100 - adjust); 447 433 if (adjust > 100) adjust = 100; 448 434 … … 454 440 else 455 441 { 456 /* Adjust for greed */ 457 adjust = 100 + ((greed + factor) - 300); 458 459 /* Never get "silly" */ 442 /* Fix the factor */ 460 443 if (adjust < 100) adjust = 100; 461 444 trunk/src/tables.c
r855 r856 246 246 const byte adj_chr_gold[] = 247 247 { 248 1 30/* 3 */,249 1 25/* 4 */,250 1 22/* 5 */,251 1 20/* 6 */,252 1 18/* 7 */,253 1 16/* 8 */,254 1 14/* 9 */,255 1 12 /* 10 */,256 1 10/* 11 */,257 1 08 /* 12 */,258 1 06 /* 13 */,259 1 04/* 14 */,260 1 03 /* 15 */,261 1 02 /* 16 */,262 1 01 /* 17 */,263 1 00 /* 18/00-18/09 */,264 99/* 18/10-18/19 */,265 98/* 18/20-18/29 */,266 97/* 18/30-18/39 */,267 96/* 18/40-18/49 */,268 95/* 18/50-18/59 */,269 94/* 18/60-18/69 */,270 93/* 18/70-18/79 */,271 92/* 18/80-18/89 */,272 91/* 18/90-18/99 */,273 9 0/* 18/100-18/109 */,274 89/* 18/110-18/119 */,275 88/* 18/120-18/129 */,276 87/* 18/130-18/139 */,277 86/* 18/140-18/149 */,278 85/* 18/150-18/159 */,279 84/* 18/160-18/169 */,280 83/* 18/170-18/179 */,281 82/* 18/180-18/189 */,282 81/* 18/190-18/199 */,283 80 /* 18/200-18/209 */,284 80 /* 18/210-18/219 */,285 80 /* 18/220+ */248 143 /* 3 */, 249 137 /* 4 */, 250 134 /* 5 */, 251 132 /* 6 */, 252 129 /* 7 */, 253 127 /* 8 */, 254 123 /* 9 */, 255 122 /* 10 */, 256 121 /* 11 */, 257 118 /* 12 */, 258 116 /* 13 */, 259 113 /* 14 */, 260 113 /* 15 */, 261 112 /* 16 */, 262 111 /* 17 */, 263 110 /* 18/00-18/09 */, 264 108 /* 18/10-18/19 */, 265 107 /* 18/20-18/29 */, 266 106 /* 18/30-18/39 */, 267 105 /* 18/40-18/49 */, 268 104 /* 18/50-18/59 */, 269 103 /* 18/60-18/69 */, 270 102 /* 18/70-18/79 */, 271 101 /* 18/80-18/89 */, 272 100 /* 18/90-18/99 */, 273 99 /* 18/100-18/109 */, 274 97 /* 18/110-18/119 */, 275 96 /* 18/120-18/129 */, 276 95 /* 18/130-18/139 */, 277 94 /* 18/140-18/149 */, 278 93 /* 18/150-18/159 */, 279 92 /* 18/160-18/169 */, 280 91 /* 18/170-18/179 */, 281 90 /* 18/180-18/189 */, 282 90 /* 18/190-18/199 */, 283 90 /* 18/200-18/209 */, 284 90 /* 18/210-18/219 */, 285 90 /* 18/220+ */ 286 286 }; 287 287 trunk/src/types.h
r849 r856 579 579 s32b max_cost; /* Purse limit */ 580 580 581 byte inflate; /* Inflation */582 583 581 byte owner_race; /* Owner race */ 584 582 }; trunk/src/variable.c
r816 r856 640 640 641 641 /* 642 * The racial price adjustment arrays643 */644 byte *g_info;645 char *g_name;646 char *g_text;647 648 649 /*650 642 * The object flavor arrays 651 643 */
