PageRenderTime 53ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/src/object/randart.c

https://bitbucket.org/ekolis/jackband
C | 3283 lines | 2280 code | 441 blank | 562 comment | 707 complexity | a2069a83996d7cacbdedc6489a21b7bb MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * File: randart.c
  3. * Purpose: Random artifact generation
  4. *
  5. * Copyright (c) 1998 Greg Wooledge, Ben Harrison, Robert Ruhlmann
  6. * Copyright (c) 2001 Chris Carr, Chris Robertson
  7. *
  8. * This work is free software; you can redistribute it and/or modify it
  9. * under the terms of either:
  10. *
  11. * a) the GNU General Public License as published by the Free Software
  12. * Foundation, version 2, or
  13. *
  14. * b) the "Angband licence":
  15. * This software may be copied and distributed for educational, research,
  16. * and not for profit purposes provided that this copyright and statement
  17. * are included in all such copies. Other copyrights may also apply.
  18. */
  19. #include "angband.h"
  20. #include "object/tvalsval.h"
  21. #include "init.h"
  22. #include "effects.h"
  23. /*
  24. * Original random artifact generator (randart) by Greg Wooledge.
  25. * Updated by Chris Carr / Chris Robertson 2001-2010.
  26. */
  27. #define MAX_TRIES 200
  28. #define BUFLEN 1024
  29. #define MIN_NAME_LEN 5
  30. #define MAX_NAME_LEN 9
  31. #define S_WORD 26
  32. #define E_WORD S_WORD
  33. /*
  34. * Inhibiting factors for large bonus values
  35. * "HIGH" values use INHIBIT_WEAK
  36. * "VERYHIGH" values use INHIBIT_STRONG
  37. */
  38. #define INHIBIT_STRONG (one_in_(6))
  39. #define INHIBIT_WEAK (one_in_(2))
  40. /*
  41. * Power rating below which uncursed randarts cannot aggravate
  42. * (so that aggravate is found only on endgame-quality items or
  43. * cursed items)
  44. */
  45. #define AGGR_POWER 300
  46. /*
  47. * Numerical index values for the different learned probabilities
  48. * These are to make the code more readable.
  49. * ToDo: turn these into an enum
  50. */
  51. #define ART_IDX_BOW_SHOTS 0
  52. #define ART_IDX_BOW_MIGHT 1
  53. #define ART_IDX_BOW_BRAND 80
  54. #define ART_IDX_BOW_SLAY 81
  55. #define ART_IDX_WEAPON_HIT 2
  56. #define ART_IDX_WEAPON_DAM 3
  57. #define ART_IDX_NONWEAPON_HIT 4
  58. #define ART_IDX_NONWEAPON_DAM 5
  59. #define ART_IDX_NONWEAPON_HIT_DAM 6
  60. #define ART_IDX_NONWEAPON_BRAND 78
  61. #define ART_IDX_NONWEAPON_SLAY 79
  62. #define ART_IDX_NONWEAPON_BLOWS 83
  63. #define ART_IDX_NONWEAPON_SHOTS 84
  64. #define ART_IDX_MELEE_BLESS 7
  65. #define ART_IDX_MELEE_BRAND 8
  66. #define ART_IDX_MELEE_SLAY 76
  67. #define ART_IDX_MELEE_SINV 9
  68. #define ART_IDX_MELEE_BLOWS 10
  69. #define ART_IDX_MELEE_AC 11
  70. #define ART_IDX_MELEE_DICE 12
  71. #define ART_IDX_MELEE_WEIGHT 13
  72. #define ART_IDX_MELEE_TUNN 14
  73. #define ART_IDX_ALLARMOR_WEIGHT 15
  74. #define ART_IDX_BOOT_AC 16
  75. #define ART_IDX_BOOT_FEATHER 17
  76. #define ART_IDX_BOOT_STEALTH 18
  77. #define ART_IDX_BOOT_SPEED 19
  78. #define ART_IDX_GLOVE_AC 20
  79. #define ART_IDX_GLOVE_FA 21
  80. #define ART_IDX_GLOVE_DEX 22
  81. #define ART_IDX_HELM_AC 23
  82. #define ART_IDX_HELM_RBLIND 24
  83. #define ART_IDX_HELM_ESP 25
  84. #define ART_IDX_HELM_SINV 26
  85. #define ART_IDX_HELM_WIS 27
  86. #define ART_IDX_HELM_INT 28
  87. #define ART_IDX_SHIELD_AC 29
  88. #define ART_IDX_SHIELD_LRES 30
  89. #define ART_IDX_CLOAK_AC 31
  90. #define ART_IDX_CLOAK_STEALTH 32
  91. #define ART_IDX_ARMOR_AC 33
  92. #define ART_IDX_ARMOR_STEALTH 34
  93. #define ART_IDX_ARMOR_HLIFE 35
  94. #define ART_IDX_ARMOR_CON 36
  95. #define ART_IDX_ARMOR_LRES 37
  96. #define ART_IDX_ARMOR_ALLRES 38
  97. #define ART_IDX_ARMOR_HRES 39
  98. #define ART_IDX_GEN_STAT 40
  99. #define ART_IDX_GEN_SUST 41
  100. #define ART_IDX_GEN_STEALTH 42
  101. #define ART_IDX_GEN_SEARCH 43
  102. #define ART_IDX_GEN_INFRA 44
  103. #define ART_IDX_GEN_SPEED 45
  104. #define ART_IDX_GEN_IMMUNE 46
  105. #define ART_IDX_GEN_FA 47
  106. #define ART_IDX_GEN_HLIFE 48
  107. #define ART_IDX_GEN_FEATHER 49
  108. #define ART_IDX_GEN_LIGHT 50
  109. #define ART_IDX_GEN_SINV 51
  110. #define ART_IDX_GEN_ESP 52
  111. #define ART_IDX_GEN_SDIG 53
  112. #define ART_IDX_GEN_REGEN 54
  113. #define ART_IDX_GEN_LRES 55
  114. #define ART_IDX_GEN_RPOIS 56
  115. #define ART_IDX_GEN_RFEAR 57
  116. #define ART_IDX_GEN_RLIGHT 58
  117. #define ART_IDX_GEN_RDARK 59
  118. #define ART_IDX_GEN_RBLIND 60
  119. #define ART_IDX_GEN_RCONF 61
  120. #define ART_IDX_GEN_RSOUND 62
  121. #define ART_IDX_GEN_RSHARD 63
  122. #define ART_IDX_GEN_RNEXUS 64
  123. #define ART_IDX_GEN_RNETHER 65
  124. #define ART_IDX_GEN_RCHAOS 66
  125. #define ART_IDX_GEN_RDISEN 67
  126. #define ART_IDX_GEN_AC 68
  127. #define ART_IDX_GEN_TUNN 69
  128. #define ART_IDX_GEN_ACTIV 82
  129. /* Supercharged abilities - treated differently in algorithm */
  130. #define ART_IDX_MELEE_DICE_SUPER 70
  131. #define ART_IDX_BOW_SHOTS_SUPER 71
  132. #define ART_IDX_BOW_MIGHT_SUPER 72
  133. #define ART_IDX_GEN_SPEED_SUPER 73
  134. #define ART_IDX_MELEE_BLOWS_SUPER 77
  135. #define ART_IDX_GEN_AC_SUPER 85
  136. /* Aggravation - weapon and nonweapon */
  137. #define ART_IDX_WEAPON_AGGR 74
  138. #define ART_IDX_NONWEAPON_AGGR 75
  139. /* Total of abilities */
  140. #define ART_IDX_TOTAL 86
  141. /* Tallies of different ability types */
  142. /* ToDo: use N_ELEMENTS for these */
  143. #define ART_IDX_BOW_COUNT 4
  144. #define ART_IDX_WEAPON_COUNT 3
  145. #define ART_IDX_NONWEAPON_COUNT 8
  146. #define ART_IDX_MELEE_COUNT 9
  147. #define ART_IDX_ALLARMOR_COUNT 1
  148. #define ART_IDX_BOOT_COUNT 4
  149. #define ART_IDX_GLOVE_COUNT 3
  150. #define ART_IDX_HELM_COUNT 6
  151. #define ART_IDX_SHIELD_COUNT 2
  152. #define ART_IDX_CLOAK_COUNT 2
  153. #define ART_IDX_ARMOR_COUNT 7
  154. #define ART_IDX_GEN_COUNT 31
  155. #define ART_IDX_HIGH_RESIST_COUNT 12
  156. /* Arrays of indices by item type, used in frequency generation */
  157. static s16b art_idx_bow[] =
  158. {ART_IDX_BOW_SHOTS, ART_IDX_BOW_MIGHT, ART_IDX_BOW_BRAND, ART_IDX_BOW_SLAY};
  159. static s16b art_idx_weapon[] =
  160. {ART_IDX_WEAPON_HIT, ART_IDX_WEAPON_DAM, ART_IDX_WEAPON_AGGR};
  161. static s16b art_idx_nonweapon[] =
  162. {ART_IDX_NONWEAPON_HIT, ART_IDX_NONWEAPON_DAM, ART_IDX_NONWEAPON_HIT_DAM,
  163. ART_IDX_NONWEAPON_AGGR, ART_IDX_NONWEAPON_BRAND, ART_IDX_NONWEAPON_SLAY,
  164. ART_IDX_NONWEAPON_BLOWS, ART_IDX_NONWEAPON_SHOTS};
  165. static s16b art_idx_melee[] =
  166. {ART_IDX_MELEE_BLESS, ART_IDX_MELEE_SINV, ART_IDX_MELEE_BRAND, ART_IDX_MELEE_SLAY,
  167. ART_IDX_MELEE_BLOWS, ART_IDX_MELEE_AC, ART_IDX_MELEE_DICE,
  168. ART_IDX_MELEE_WEIGHT, ART_IDX_MELEE_TUNN};
  169. static s16b art_idx_allarmor[] =
  170. {ART_IDX_ALLARMOR_WEIGHT};
  171. static s16b art_idx_boot[] =
  172. {ART_IDX_BOOT_AC, ART_IDX_BOOT_FEATHER, ART_IDX_BOOT_STEALTH, ART_IDX_BOOT_SPEED};
  173. static s16b art_idx_glove[] =
  174. {ART_IDX_GLOVE_AC, ART_IDX_GLOVE_FA, ART_IDX_GLOVE_DEX};
  175. static s16b art_idx_headgear[] =
  176. {ART_IDX_HELM_AC, ART_IDX_HELM_RBLIND, ART_IDX_HELM_ESP, ART_IDX_HELM_SINV,
  177. ART_IDX_HELM_WIS, ART_IDX_HELM_INT};
  178. static s16b art_idx_shield[] =
  179. {ART_IDX_SHIELD_AC, ART_IDX_SHIELD_LRES};
  180. static s16b art_idx_cloak[] =
  181. {ART_IDX_CLOAK_AC, ART_IDX_CLOAK_STEALTH};
  182. static s16b art_idx_armor[] =
  183. {ART_IDX_ARMOR_AC, ART_IDX_ARMOR_STEALTH, ART_IDX_ARMOR_HLIFE, ART_IDX_ARMOR_CON,
  184. ART_IDX_ARMOR_LRES, ART_IDX_ARMOR_ALLRES, ART_IDX_ARMOR_HRES};
  185. static s16b art_idx_gen[] =
  186. {ART_IDX_GEN_STAT, ART_IDX_GEN_SUST, ART_IDX_GEN_STEALTH,
  187. ART_IDX_GEN_SEARCH, ART_IDX_GEN_INFRA, ART_IDX_GEN_SPEED,
  188. ART_IDX_GEN_IMMUNE, ART_IDX_GEN_FA, ART_IDX_GEN_HLIFE,
  189. ART_IDX_GEN_FEATHER, ART_IDX_GEN_LIGHT, ART_IDX_GEN_SINV,
  190. ART_IDX_GEN_ESP, ART_IDX_GEN_SDIG, ART_IDX_GEN_REGEN,
  191. ART_IDX_GEN_LRES, ART_IDX_GEN_RPOIS, ART_IDX_GEN_RFEAR,
  192. ART_IDX_GEN_RLIGHT, ART_IDX_GEN_RDARK, ART_IDX_GEN_RBLIND,
  193. ART_IDX_GEN_RCONF, ART_IDX_GEN_RSOUND, ART_IDX_GEN_RSHARD,
  194. ART_IDX_GEN_RNEXUS, ART_IDX_GEN_RNETHER, ART_IDX_GEN_RCHAOS,
  195. ART_IDX_GEN_RDISEN, ART_IDX_GEN_AC, ART_IDX_GEN_TUNN,
  196. ART_IDX_GEN_ACTIV};
  197. static s16b art_idx_high_resist[] =
  198. {ART_IDX_GEN_RPOIS, ART_IDX_GEN_RFEAR,
  199. ART_IDX_GEN_RLIGHT, ART_IDX_GEN_RDARK, ART_IDX_GEN_RBLIND,
  200. ART_IDX_GEN_RCONF, ART_IDX_GEN_RSOUND, ART_IDX_GEN_RSHARD,
  201. ART_IDX_GEN_RNEXUS, ART_IDX_GEN_RNETHER, ART_IDX_GEN_RCHAOS,
  202. ART_IDX_GEN_RDISEN};
  203. /* Initialize the data structures for learned probabilities */
  204. static s16b artprobs[ART_IDX_TOTAL];
  205. s16b *baseprobs;
  206. static s16b art_bow_total = 0;
  207. static s16b art_melee_total = 0;
  208. static s16b art_boot_total = 0;
  209. static s16b art_glove_total = 0;
  210. static s16b art_headgear_total = 0;
  211. static s16b art_shield_total = 0;
  212. static s16b art_cloak_total = 0;
  213. static s16b art_armor_total = 0;
  214. static s16b art_other_total = 0;
  215. static s16b art_total = 0;
  216. /*
  217. * Working arrays for holding frequency values - global to avoid repeated
  218. * allocation of memory
  219. */
  220. static s16b art_freq[ART_IDX_TOTAL]; /* artifact attributes */
  221. s16b *base_freq; /* base items */
  222. /*
  223. * Mean start and increment values for to_hit, to_dam and AC. Update these
  224. * if the algorithm changes. They are used in frequency generation.
  225. */
  226. static s16b mean_hit_increment = 4;
  227. static s16b mean_dam_increment = 4;
  228. static s16b mean_hit_startval = 10;
  229. static s16b mean_dam_startval = 10;
  230. static s16b mean_ac_startval = 15;
  231. static s16b mean_ac_increment = 5;
  232. /*
  233. * Pointer for logging file
  234. */
  235. static ang_file *log_file = NULL;
  236. /*
  237. * Store the original artifact power ratings
  238. */
  239. static s32b *base_power;
  240. static s16b max_power;
  241. static s16b min_power;
  242. static s16b avg_power;
  243. static s16b var_power;
  244. /*
  245. * Store the original base item levels
  246. */
  247. static byte *base_item_level;
  248. /*
  249. * Store the original base item rarities
  250. */
  251. static byte *base_item_prob;
  252. /*
  253. * Store the original artifact rarities
  254. */
  255. static byte *base_art_alloc;
  256. /* Global just for convenience. */
  257. static int verbose = 1;
  258. /*
  259. * Object flag names
  260. */
  261. static const char *flag_names[] =
  262. {
  263. #define OF(a, b) #a,
  264. #include "list-object-flags.h"
  265. #undef OF
  266. ""
  267. };
  268. /*
  269. * Use W. Sheldon Simms' random name generator.
  270. */
  271. static errr init_names(void)
  272. {
  273. char buf[BUFLEN];
  274. size_t name_size;
  275. char *a_base;
  276. char *a_next;
  277. int i;
  278. /* Temporary space for names, while reading and randomizing them. */
  279. char **names;
  280. /* Allocate the "names" array */
  281. /* ToDo: Make sure the memory is freed correctly in case of errors */
  282. names = C_ZNEW(z_info->a_max, char *);
  283. for (i = 0; i < z_info->a_max; i++)
  284. {
  285. char word[MAX_NAME_LEN + 1];
  286. randname_make(RANDNAME_TOLKIEN, MIN_NAME_LEN, MAX_NAME_LEN,
  287. word, sizeof word);
  288. word[0] = toupper((unsigned char) word[0]);
  289. if (one_in_(3))
  290. strnfmt(buf, sizeof(buf), "'%s'", word);
  291. else
  292. strnfmt(buf, sizeof(buf), "of %s", word);
  293. names[i] = string_make(buf);
  294. }
  295. /* Special cases -- keep these three names separate. */
  296. string_free(names[ART_POWER - 1]);
  297. string_free(names[ART_GROND - 1]);
  298. string_free(names[ART_MORGOTH - 1]);
  299. names[ART_POWER - 1] = string_make("of Power (The One Ring)");
  300. names[ART_GROND - 1] = string_make("'Grond'");
  301. names[ART_MORGOTH - 1] = string_make("of Morgoth");
  302. /* Convert our names array into an a_name structure for later use. */
  303. name_size = 0;
  304. for (i = 1; i < z_info->a_max; i++)
  305. {
  306. name_size += strlen(names[i-1]) + 2; /* skip first char */
  307. }
  308. a_base = C_ZNEW(name_size, char);
  309. a_next = a_base + 1; /* skip first char */
  310. for (i = 1; i < z_info->a_max; i++)
  311. {
  312. my_strcpy(a_next, names[i-1], name_size - 1);
  313. if (a_info[i].tval > 0) /* skip unused! */
  314. a_info[i].name = a_next - a_base;
  315. a_next += strlen(names[i-1]) + 1;
  316. }
  317. /* Free the old names */
  318. FREE(a_name);
  319. for (i = 0; i < z_info->a_max; i++)
  320. {
  321. string_free(names[i]);
  322. }
  323. /* Free the "names" array */
  324. FREE(names);
  325. /* Store the names */
  326. a_name = a_base;
  327. a_head.name_ptr = a_base;
  328. a_head.name_size = name_size;
  329. /* Success */
  330. return (0);
  331. }
  332. /*
  333. * Return the artifact power, by generating a "fake" object based on the
  334. * artifact, and calling the common object_power function
  335. */
  336. static s32b artifact_power(int a_idx)
  337. {
  338. object_type obj;
  339. LOG_PRINT("********** ENTERING EVAL POWER ********\n");
  340. LOG_PRINT1("Artifact index is %d\n", a_idx);
  341. if(!make_fake_artifact(&obj, a_idx))
  342. {
  343. return 0;
  344. }
  345. return object_power(&obj, verbose, log_file, TRUE);
  346. }
  347. /*
  348. * Store the original artifact power ratings as a baseline
  349. */
  350. static void store_base_power (void)
  351. {
  352. int i, j;
  353. artifact_type *a_ptr;
  354. object_kind *k_ptr;
  355. s16b k_idx;
  356. int *fake_power;
  357. max_power = 0;
  358. min_power = 32767;
  359. var_power = 0;
  360. fake_power = C_ZNEW(z_info->a_max, int);
  361. j = 0;
  362. for(i = 0; i < z_info->a_max; i++, j++)
  363. {
  364. base_power[i] = artifact_power(i);
  365. /* capture power stats, ignoring cursed and uber arts */
  366. if (base_power[i] > max_power && base_power[i] < INHIBIT_POWER)
  367. max_power = base_power[i];
  368. if (base_power[i] < min_power && base_power[i] > 0)
  369. min_power = base_power[i];
  370. if (base_power[i] > 0 && base_power[i] < INHIBIT_POWER)
  371. fake_power[j] = (int)base_power[i];
  372. else
  373. j--;
  374. a_ptr = &a_info[i];
  375. k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
  376. k_ptr = &k_info[k_idx];
  377. base_item_level[i] = k_ptr->level;
  378. base_item_prob[i] = k_ptr->alloc_prob;
  379. base_art_alloc[i] = a_ptr->alloc_prob;
  380. }
  381. avg_power = mean(fake_power, j);
  382. var_power = variance(fake_power, j);
  383. LOG_PRINT2("Max power is %d, min is %d\n", max_power, min_power);
  384. LOG_PRINT2("Mean is %d, variance is %d\n", avg_power, var_power);
  385. /* Store the number of different types, for use later */
  386. /* ToDo: replace this with full combination tracking */
  387. for (i = 0; i < z_info->a_max; i++)
  388. {
  389. switch (a_info[i].tval)
  390. {
  391. case TV_SWORD:
  392. case TV_POLEARM:
  393. case TV_HAFTED:
  394. art_melee_total++; break;
  395. case TV_BOW:
  396. art_bow_total++; break;
  397. case TV_SOFT_ARMOR:
  398. case TV_HARD_ARMOR:
  399. case TV_DRAG_ARMOR:
  400. art_armor_total++; break;
  401. case TV_SHIELD:
  402. art_shield_total++; break;
  403. case TV_CLOAK:
  404. art_cloak_total++; break;
  405. case TV_HELM:
  406. case TV_CROWN:
  407. art_headgear_total++; break;
  408. case TV_GLOVES:
  409. art_glove_total++; break;
  410. case TV_BOOTS:
  411. art_boot_total++; break;
  412. default:
  413. art_other_total++;
  414. }
  415. }
  416. art_total = art_melee_total + art_bow_total + art_armor_total +
  417. art_shield_total + art_cloak_total + art_headgear_total +
  418. art_glove_total + art_boot_total + art_other_total;
  419. }
  420. /*
  421. * Randomly select a base item type (tval,sval). Assign the various fields
  422. * corresponding to that choice.
  423. *
  424. * The return value gives the index of the new item type. The method is
  425. * passed a pointer to a rarity value in order to return the rarity of the
  426. * new item.
  427. */
  428. static s16b choose_item(int a_idx)
  429. {
  430. artifact_type *a_ptr = &a_info[a_idx];
  431. int tval = 0;
  432. int sval = 0;
  433. object_kind *k_ptr;
  434. int i;
  435. s16b k_idx, r;
  436. /*
  437. * Pick a base item from the cumulative frequency table.
  438. *
  439. * Although this looks hideous, it provides for easy addition of
  440. * future artifact types, simply by removing the tvals from this
  441. * loop.
  442. *
  443. * N.B. Could easily generate lights, rings and amulets this way if
  444. * the whole special/flavour issue was sorted out (see ticket #1014)
  445. * Note that Carlammas and Barahir have the same sval as Grond/Morgoth
  446. */
  447. while (tval == 0 || tval == TV_SKELETON || tval == TV_BOTTLE ||
  448. tval == TV_JUNK || tval == TV_SPIKE || tval == TV_CHEST ||
  449. tval == TV_SHOT || tval == TV_ARROW || tval == TV_BOLT ||
  450. tval == TV_STAFF || tval == TV_WAND || tval == TV_ROD ||
  451. tval == TV_SCROLL || tval == TV_POTION || tval == TV_FLASK ||
  452. tval == TV_FOOD || tval == TV_MAGIC_BOOK || tval ==
  453. TV_PRAYER_BOOK || tval == TV_GOLD || tval == TV_LIGHT ||
  454. tval == TV_AMULET || tval == TV_RING || sval == SV_GROND ||
  455. sval == SV_MORGOTH)
  456. {
  457. r = randint1(base_freq[z_info->k_max - 1]);
  458. i = 0;
  459. while (r > base_freq[i])
  460. {
  461. i++;
  462. }
  463. tval = k_info[i].tval;
  464. sval = k_info[i].sval;
  465. }
  466. LOG_PRINT2("Creating tval %d sval %d\n", tval, sval);
  467. k_idx = lookup_kind(tval, sval);
  468. k_ptr = &k_info[k_idx];
  469. a_ptr->tval = k_ptr->tval;
  470. a_ptr->sval = k_ptr->sval;
  471. a_ptr->pval = randcalc(k_ptr->pval, 0, MINIMISE);
  472. a_ptr->to_h = randcalc(k_ptr->to_h, 0, MINIMISE);
  473. a_ptr->to_d = randcalc(k_ptr->to_d, 0, MINIMISE);
  474. a_ptr->to_a = randcalc(k_ptr->to_a, 0, MINIMISE);
  475. a_ptr->ac = k_ptr->ac;
  476. a_ptr->dd = k_ptr->dd;
  477. a_ptr->ds = k_ptr->ds;
  478. a_ptr->weight = k_ptr->weight;
  479. of_copy(a_ptr->flags, k_ptr->flags);
  480. a_ptr->effect = 0;
  481. /* Artifacts ignore everything */
  482. flags_set(a_ptr->flags, OF_SIZE, OF_IGNORE_MASK, FLAG_END);
  483. /* Assign basic stats to the artifact based on its artifact level. */
  484. /*
  485. * CR, 2001-09-03: changed to a simpler version to match the hit-dam
  486. * parsing algorithm. We use random ranges averaging mean_hit_startval
  487. * and mean_dam_startval, but permitting variation of 50% to 150%.
  488. * Level-dependent term has been removed for the moment.
  489. */
  490. switch (a_ptr->tval)
  491. {
  492. case TV_BOW:
  493. case TV_DIGGING:
  494. case TV_HAFTED:
  495. case TV_SWORD:
  496. case TV_POLEARM:
  497. a_ptr->to_h += (s16b)(mean_hit_startval / 2 +
  498. randint0(mean_hit_startval) );
  499. a_ptr->to_d += (s16b)(mean_dam_startval / 2 +
  500. randint0(mean_dam_startval) );
  501. LOG_PRINT2("Assigned basic stats, to_hit: %d, to_dam: %d\n", a_ptr->to_h, a_ptr->to_d);
  502. break;
  503. case TV_BOOTS:
  504. case TV_GLOVES:
  505. case TV_HELM:
  506. case TV_CROWN:
  507. case TV_SHIELD:
  508. case TV_CLOAK:
  509. case TV_SOFT_ARMOR:
  510. case TV_HARD_ARMOR:
  511. case TV_DRAG_ARMOR:
  512. /* CR: adjusted this to work with parsing logic */
  513. a_ptr->to_a += (s16b)(mean_ac_startval / 2 +
  514. randint0(mean_ac_startval) );
  515. LOG_PRINT1("Assigned basic stats, AC bonus: %d\n", a_ptr->to_a);
  516. break;
  517. }
  518. /* Done - return the index of the new object kind. */
  519. return k_idx;
  520. }
  521. /*
  522. * We've just added an ability which uses the pval bonus. Make sure it's
  523. * not zero. If it's currently negative, leave it negative (heh heh).
  524. */
  525. static void do_pval(artifact_type *a_ptr)
  526. {
  527. int factor = 1;
  528. /* Track whether we have blows, might or shots on this item */
  529. if (of_has(a_ptr->flags, OF_BLOWS)) factor++;
  530. if (of_has(a_ptr->flags, OF_MIGHT)) factor++;
  531. if (of_has(a_ptr->flags, OF_SHOTS)) factor++;
  532. if (a_ptr->pval == 0)
  533. {
  534. /* Blows, might, shots handled separately */
  535. if (factor > 1)
  536. {
  537. a_ptr->pval = (s16b)randint1(2);
  538. /* Give it a shot at +3 */
  539. if (INHIBIT_STRONG) a_ptr->pval = 3;
  540. }
  541. else a_ptr->pval = (s16b)randint1(4);
  542. LOG_PRINT1("Assigned initial pval, value is: %d\n", a_ptr->pval);
  543. }
  544. else if (a_ptr->pval < 0)
  545. {
  546. if (one_in_(2))
  547. {
  548. a_ptr->pval--;
  549. LOG_PRINT1("Decreasing pval by 1, new value is: %d\n", a_ptr->pval);
  550. }
  551. }
  552. else if (one_in_(a_ptr->pval * factor))
  553. {
  554. /*
  555. * CR: made this a bit rarer and diminishing with higher pval -
  556. * also rarer if item has blows/might/shots already
  557. */
  558. a_ptr->pval++;
  559. LOG_PRINT1("Increasing pval by 1, new value is: %d\n", a_ptr->pval);
  560. }
  561. }
  562. static void remove_contradictory(artifact_type *a_ptr)
  563. {
  564. if (of_has(a_ptr->flags, OF_AGGRAVATE)) of_off(a_ptr->flags, OF_STEALTH);
  565. if (of_has(a_ptr->flags, OF_IM_ACID)) of_off(a_ptr->flags, OF_RES_ACID);
  566. if (of_has(a_ptr->flags, OF_IM_ELEC)) of_off(a_ptr->flags, OF_RES_ELEC);
  567. if (of_has(a_ptr->flags, OF_IM_FIRE)) of_off(a_ptr->flags, OF_RES_FIRE);
  568. if (of_has(a_ptr->flags, OF_IM_COLD)) of_off(a_ptr->flags, OF_RES_COLD);
  569. if (a_ptr->pval < 0)
  570. {
  571. if (of_has(a_ptr->flags, OF_STR)) of_off(a_ptr->flags, OF_SUST_STR);
  572. if (of_has(a_ptr->flags, OF_INT)) of_off(a_ptr->flags, OF_SUST_INT);
  573. if (of_has(a_ptr->flags, OF_WIS)) of_off(a_ptr->flags, OF_SUST_WIS);
  574. if (of_has(a_ptr->flags, OF_DEX)) of_off(a_ptr->flags, OF_SUST_DEX);
  575. if (of_has(a_ptr->flags, OF_CON)) of_off(a_ptr->flags, OF_SUST_CON);
  576. if (of_has(a_ptr->flags, OF_CHR)) of_off(a_ptr->flags, OF_SUST_CHR);
  577. of_off(a_ptr->flags, OF_BLOWS);
  578. }
  579. if (of_has(a_ptr->flags, OF_LIGHT_CURSE)) of_off(a_ptr->flags, OF_BLESSED);
  580. if (of_has(a_ptr->flags, OF_KILL_DRAGON)) of_off(a_ptr->flags, OF_SLAY_DRAGON);
  581. if (of_has(a_ptr->flags, OF_KILL_DEMON)) of_off(a_ptr->flags, OF_SLAY_DEMON);
  582. if (of_has(a_ptr->flags, OF_KILL_UNDEAD)) of_off(a_ptr->flags, OF_SLAY_UNDEAD);
  583. if (of_has(a_ptr->flags, OF_DRAIN_EXP)) of_off(a_ptr->flags, OF_HOLD_LIFE);
  584. }
  585. /*
  586. * Adjust the parsed frequencies for any peculiarities of the
  587. * algorithm. For example, if stat bonuses and sustains are
  588. * being added in a correlated fashion, it will tend to push
  589. * the frequencies up for both of them. In this method we
  590. * compensate for cases like this by applying corrective
  591. * scaling.
  592. */
  593. static void adjust_freqs(void)
  594. {
  595. /*
  596. * Enforce minimum values for any frequencies that might potentially
  597. * be missing in the standard set, especially supercharged ones.
  598. * Numbers here represent the average number of times this ability
  599. * would appear if the entire randart set was eligible to receive
  600. * it (so in the case of a bow ability: if the set was all bows).
  601. *
  602. * Note that low numbers here for very specialized abilities could
  603. * mean that there's a good chance this ability will not appear in
  604. * a given randart set. If this is a problem, raise the number.
  605. */
  606. if (artprobs[ART_IDX_GEN_RFEAR] < 5)
  607. artprobs[ART_IDX_GEN_RFEAR] = 5;
  608. if (artprobs[ART_IDX_MELEE_DICE_SUPER] < 5)
  609. artprobs[ART_IDX_MELEE_DICE_SUPER] = 5;
  610. if (artprobs[ART_IDX_BOW_SHOTS_SUPER] < 5)
  611. artprobs[ART_IDX_BOW_SHOTS_SUPER] = 5;
  612. if (artprobs[ART_IDX_BOW_MIGHT_SUPER] < 5)
  613. artprobs[ART_IDX_BOW_MIGHT_SUPER] = 5;
  614. if (artprobs[ART_IDX_MELEE_BLOWS_SUPER] < 5)
  615. artprobs[ART_IDX_MELEE_BLOWS_SUPER] = 5;
  616. if (artprobs[ART_IDX_GEN_SPEED_SUPER] < 5)
  617. artprobs[ART_IDX_GEN_SPEED_SUPER] = 5;
  618. if (artprobs[ART_IDX_GEN_AC] < 5)
  619. artprobs[ART_IDX_GEN_AC] = 5;
  620. if (artprobs[ART_IDX_GEN_TUNN] < 5)
  621. artprobs[ART_IDX_GEN_TUNN] = 5;
  622. if (artprobs[ART_IDX_NONWEAPON_BRAND] < 2)
  623. artprobs[ART_IDX_NONWEAPON_BRAND] = 2;
  624. if (artprobs[ART_IDX_NONWEAPON_SLAY] < 2)
  625. artprobs[ART_IDX_NONWEAPON_SLAY] = 2;
  626. if (artprobs[ART_IDX_BOW_BRAND] < 2)
  627. artprobs[ART_IDX_BOW_BRAND] = 2;
  628. if (artprobs[ART_IDX_BOW_SLAY] < 2)
  629. artprobs[ART_IDX_BOW_SLAY] = 2;
  630. if (artprobs[ART_IDX_NONWEAPON_BLOWS] < 2)
  631. artprobs[ART_IDX_NONWEAPON_BLOWS] = 2;
  632. if (artprobs[ART_IDX_NONWEAPON_SHOTS] < 2)
  633. artprobs[ART_IDX_NONWEAPON_SHOTS] = 2;
  634. if (artprobs[ART_IDX_GEN_AC_SUPER] < 5)
  635. artprobs[ART_IDX_GEN_AC_SUPER] = 5;
  636. if (artprobs[ART_IDX_MELEE_AC] < 5)
  637. artprobs[ART_IDX_MELEE_AC] = 5;
  638. /* Cut aggravation frequencies in half since they're used twice */
  639. artprobs[ART_IDX_NONWEAPON_AGGR] /= 2;
  640. artprobs[ART_IDX_WEAPON_AGGR] /= 2;
  641. }
  642. /*
  643. * Parse the list of artifacts and count up the frequencies of the various
  644. * abilities. This is used to give dynamic generation probabilities.
  645. */
  646. static void parse_frequencies(void)
  647. {
  648. int i, j;
  649. const artifact_type *a_ptr;
  650. object_kind *k_ptr;
  651. s32b temp, temp2;
  652. s16b k_idx;
  653. LOG_PRINT("\n****** BEGINNING GENERATION OF FREQUENCIES\n\n");
  654. /* Zero the frequencies for artifact attributes */
  655. for (i = 0; i < ART_IDX_TOTAL; i++)
  656. {
  657. artprobs[i] = 0;
  658. }
  659. /*
  660. * Initialise the frequencies for base items so that each item could
  661. * be chosen - we check for illegal items during choose_item()
  662. */
  663. for (i = 0; i < z_info->k_max; i++)
  664. {
  665. baseprobs[i] = 1;
  666. }
  667. /* Go through the list of all artifacts */
  668. for (i = 0; i < z_info->a_max; i++)
  669. {
  670. LOG_PRINT1("Current artifact index is %d\n", i);
  671. a_ptr = &a_info[i];
  672. /* Special cases -- don't parse these! */
  673. if ((i == ART_POWER) ||
  674. (i == ART_GROND) ||
  675. (i == ART_MORGOTH))
  676. continue;
  677. /* Also don't parse cursed items */
  678. if (base_power[i] < 0) continue;
  679. /* Get a pointer to the base item for this artifact */
  680. k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
  681. k_ptr = &k_info[k_idx];
  682. /* Add the base item to the baseprobs array */
  683. baseprobs[k_idx]++;
  684. LOG_PRINT1("Base item is %d\n", k_idx);
  685. /* Count up the abilities for this artifact */
  686. if (a_ptr->tval == TV_BOW)
  687. {
  688. if(of_has(a_ptr->flags, OF_SHOTS))
  689. {
  690. /* Do we have 3 or more extra shots? (Unlikely) */
  691. if(a_ptr->pval > 2)
  692. {
  693. LOG_PRINT("Adding 1 for supercharged shots (3 or more!)\n");
  694. (artprobs[ART_IDX_BOW_SHOTS_SUPER])++;
  695. }
  696. else {
  697. LOG_PRINT("Adding 1 for extra shots\n");
  698. (artprobs[ART_IDX_BOW_SHOTS])++;
  699. }
  700. }
  701. if(of_has(a_ptr->flags, OF_MIGHT))
  702. {
  703. /* Do we have 3 or more extra might? (Unlikely) */
  704. if(a_ptr->pval > 2)
  705. {
  706. LOG_PRINT("Adding 1 for supercharged might (3 or more!)\n");
  707. (artprobs[ART_IDX_BOW_MIGHT_SUPER])++;
  708. }
  709. else {
  710. LOG_PRINT("Adding 1 for extra might\n");
  711. (artprobs[ART_IDX_BOW_MIGHT])++;
  712. }
  713. }
  714. /* Brands or slays - count all together */
  715. if (flags_test(a_ptr->flags, OF_SIZE, OF_ALL_SLAY_MASK, FLAG_END))
  716. {
  717. const slay_t *s_ptr;
  718. /* We have some brands or slays - count them */
  719. temp = 0;
  720. temp2 = 0;
  721. for (s_ptr = slay_table; s_ptr->slay_flag; s_ptr++)
  722. {
  723. if (of_has(a_ptr->flags, s_ptr->slay_flag))
  724. {
  725. bitflag slay_kill_mask[OF_SIZE], brand_mask[OF_SIZE];
  726. flags_init(brand_mask, OF_SIZE, OF_BRAND_MASK, FLAG_END);
  727. flags_init(slay_kill_mask, OF_SIZE, OF_SLAY_MASK, OF_KILL_MASK, FLAG_END);
  728. if (of_has(slay_kill_mask, s_ptr->slay_flag)) temp++;
  729. if (of_has(brand_mask, s_ptr->slay_flag)) temp2++;
  730. }
  731. }
  732. LOG_PRINT1("Adding %d for slays\n", temp);
  733. LOG_PRINT1("Adding %d for brands\n", temp2);
  734. /* Add these to the frequency count */
  735. artprobs[ART_IDX_BOW_SLAY] += temp;
  736. artprobs[ART_IDX_BOW_BRAND] += temp2;
  737. }
  738. }
  739. /* Handle hit / dam ratings - are they higher than normal? */
  740. /* Also handle other weapon/nonweapon abilities */
  741. if (a_ptr->tval == TV_BOW || a_ptr->tval == TV_DIGGING ||
  742. a_ptr->tval == TV_HAFTED || a_ptr->tval == TV_POLEARM ||
  743. a_ptr->tval == TV_SWORD)
  744. {
  745. if (a_ptr->to_h - randcalc(k_ptr->to_h, 0, MINIMISE) - mean_hit_startval > 0)
  746. {
  747. temp = (a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE) - mean_dam_startval) /
  748. mean_dam_increment;
  749. if (temp > 0)
  750. {
  751. LOG_PRINT1("Adding %d instances of extra to-hit bonus for weapon\n", temp);
  752. (artprobs[ART_IDX_WEAPON_HIT]) += temp;
  753. }
  754. }
  755. else if (a_ptr->to_h - randcalc(k_ptr->to_h, 0, MINIMISE) - mean_hit_startval < 0)
  756. {
  757. temp = ( -(a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE) - mean_dam_startval) ) /
  758. mean_dam_increment;
  759. if (temp > 0)
  760. {
  761. LOG_PRINT1("Subtracting %d instances of extra to-hit bonus for weapon\n", temp);
  762. (artprobs[ART_IDX_WEAPON_HIT]) -= temp;
  763. }
  764. }
  765. if (a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE) - mean_dam_startval > 0)
  766. {
  767. temp = (a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE) - mean_dam_startval) /
  768. mean_dam_increment;
  769. if (temp > 0)
  770. {
  771. LOG_PRINT1("Adding %d instances of extra to-dam bonus for weapon\n", temp);
  772. (artprobs[ART_IDX_WEAPON_DAM]) += temp;
  773. }
  774. }
  775. else if (a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE) - mean_dam_startval < 0)
  776. {
  777. temp = ( -(a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE) - mean_dam_startval)) /
  778. mean_dam_increment;
  779. if (temp > 0)
  780. {
  781. LOG_PRINT1("Subtracting %d instances of extra to-dam bonus for weapon\n", temp);
  782. (artprobs[ART_IDX_WEAPON_DAM]) -= temp;
  783. }
  784. }
  785. /* Aggravation */
  786. if (of_has(a_ptr->flags, OF_AGGRAVATE))
  787. {
  788. LOG_PRINT("Adding 1 for aggravation - weapon\n");
  789. (artprobs[ART_IDX_WEAPON_AGGR])++;
  790. }
  791. /* End weapon stuff */
  792. }
  793. else
  794. {
  795. if ( (a_ptr->to_h - randcalc(k_ptr->to_h, 0, MINIMISE) > 0) &&
  796. (a_ptr->to_h - randcalc(k_ptr->to_h, 0, MINIMISE) == a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE)) )
  797. {
  798. /* Special case: both hit and dam bonuses present and equal */
  799. temp = (a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE)) / mean_dam_increment;
  800. if (temp > 0)
  801. {
  802. LOG_PRINT1("Adding %d instances of extra to-hit and to-dam bonus for non-weapon\n", temp);
  803. (artprobs[ART_IDX_NONWEAPON_HIT_DAM]) += temp;
  804. }
  805. }
  806. else
  807. {
  808. /* Uneven bonuses - handle separately */
  809. if (a_ptr->to_h - randcalc(k_ptr->to_h, 0, MINIMISE) > 0)
  810. {
  811. temp = (a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE)) / mean_dam_increment;
  812. if (temp > 0)
  813. {
  814. LOG_PRINT1("Adding %d instances of extra to-hit bonus for non-weapon\n", temp);
  815. (artprobs[ART_IDX_NONWEAPON_HIT]) += temp;
  816. }
  817. }
  818. if (a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE) > 0)
  819. {
  820. temp = (a_ptr->to_d - randcalc(k_ptr->to_d, 0, MINIMISE)) / mean_dam_increment;
  821. if (temp > 0)
  822. {
  823. LOG_PRINT1("Adding %d instances of extra to-dam bonus for non-weapon\n", temp);
  824. (artprobs[ART_IDX_NONWEAPON_DAM]) += temp;
  825. }
  826. }
  827. }
  828. /* Aggravation */
  829. if (of_has(a_ptr->flags, OF_AGGRAVATE))
  830. {
  831. LOG_PRINT("Adding 1 for aggravation - nonweapon\n");
  832. (artprobs[ART_IDX_NONWEAPON_AGGR])++;
  833. }
  834. /* Brands or slays - count all together */
  835. if (flags_test(a_ptr->flags, OF_SIZE, OF_ALL_SLAY_MASK, FLAG_END))
  836. {
  837. const slay_t *s_ptr;
  838. /* We have some brands or slays - count them */
  839. temp = 0;
  840. temp2 = 0;
  841. for (s_ptr = slay_table; s_ptr->slay_flag; s_ptr++)
  842. {
  843. if (of_has(a_ptr->flags, s_ptr->slay_flag))
  844. {
  845. bitflag slay_kill_mask[OF_SIZE], brand_mask[OF_SIZE];
  846. flags_init(brand_mask, OF_SIZE, OF_BRAND_MASK, FLAG_END);
  847. flags_init(slay_kill_mask, OF_SIZE, OF_SLAY_MASK, FLAG_END);
  848. flags_set(slay_kill_mask, OF_SIZE, OF_KILL_MASK, FLAG_END);
  849. if (of_has(slay_kill_mask, s_ptr->slay_flag)) temp++;
  850. if (of_has(brand_mask, s_ptr->slay_flag)) temp2++;
  851. }
  852. }
  853. LOG_PRINT1("Adding %d for slays\n", temp);
  854. LOG_PRINT1("Adding %d for brands\n", temp2);
  855. /* Add these to the frequency count */
  856. artprobs[ART_IDX_NONWEAPON_SLAY] += temp;
  857. artprobs[ART_IDX_NONWEAPON_BRAND] += temp2;
  858. }
  859. if (of_has(a_ptr->flags, OF_BLOWS))
  860. {
  861. LOG_PRINT("Adding 1 for extra blows on nonweapon\n");
  862. (artprobs[ART_IDX_NONWEAPON_BLOWS])++;
  863. }
  864. if (of_has(a_ptr->flags, OF_SHOTS))
  865. {
  866. LOG_PRINT("Adding 1 for extra shots on nonweapon\n");
  867. (artprobs[ART_IDX_NONWEAPON_SHOTS])++;
  868. }
  869. }
  870. if (a_ptr->tval == TV_DIGGING || a_ptr->tval == TV_HAFTED ||
  871. a_ptr->tval == TV_POLEARM || a_ptr->tval == TV_SWORD)
  872. {
  873. /* Blessed weapon? */
  874. if (of_has(a_ptr->flags, OF_BLESSED))
  875. {
  876. LOG_PRINT("Adding 1 for blessed weapon\n");
  877. (artprobs[ART_IDX_MELEE_BLESS])++;
  878. }
  879. /* See invisible? */
  880. if (of_has(a_ptr->flags, OF_SEE_INVIS))
  881. {
  882. LOG_PRINT("Adding 1 for see invisible (weapon case)\n");
  883. (artprobs[ART_IDX_MELEE_SINV])++;
  884. }
  885. /* Does this weapon have extra blows? */
  886. if (of_has(a_ptr->flags, OF_BLOWS))
  887. {
  888. /* Do we have 3 or more extra blows? (Unlikely) */
  889. if(a_ptr->pval > 2)
  890. {
  891. LOG_PRINT("Adding 1 for supercharged blows (3 or more!)\n");
  892. (artprobs[ART_IDX_MELEE_BLOWS_SUPER])++;
  893. }
  894. else {
  895. LOG_PRINT("Adding 1 for extra blows\n");
  896. (artprobs[ART_IDX_MELEE_BLOWS])++;
  897. }
  898. }
  899. /* Does this weapon have an unusual bonus to AC? */
  900. if ( (a_ptr->to_a - randcalc(k_ptr->to_a, 0, MAXIMISE)) > 0)
  901. {
  902. temp = (a_ptr->to_a - randcalc(k_ptr->to_a, 0, MAXIMISE)) / mean_ac_increment;
  903. if (temp > 0)
  904. {
  905. LOG_PRINT1("Adding %d instances of extra AC bonus for weapon\n", temp);
  906. (artprobs[ART_IDX_MELEE_AC]) += temp;
  907. }
  908. }
  909. /* Check damage dice - are they more than normal? */
  910. if (a_ptr->dd > k_ptr->dd)
  911. {
  912. /* Difference of 3 or more? */
  913. if ( (a_ptr->dd - k_ptr->dd) > 2)
  914. {
  915. LOG_PRINT("Adding 1 for super-charged damage dice!\n");
  916. (artprobs[ART_IDX_MELEE_DICE_SUPER])++;
  917. }
  918. else
  919. {
  920. LOG_PRINT("Adding 1 for extra damage dice.\n");
  921. (artprobs[ART_IDX_MELEE_DICE])++;
  922. }
  923. }
  924. /* Check weight - is it different from normal? */
  925. if (a_ptr->weight != k_ptr->weight)
  926. {
  927. LOG_PRINT("Adding 1 for unusual weight.\n");
  928. (artprobs[ART_IDX_MELEE_WEIGHT])++;
  929. }
  930. /* Check for tunnelling ability */
  931. if (of_has(a_ptr->flags, OF_TUNNEL))
  932. {
  933. LOG_PRINT("Adding 1 for tunnelling bonus.\n");
  934. (artprobs[ART_IDX_MELEE_TUNN])++;
  935. }
  936. /* Brands or slays - count all together */
  937. if (flags_test(a_ptr->flags, OF_SIZE, OF_ALL_SLAY_MASK, FLAG_END))
  938. {
  939. const slay_t *s_ptr;
  940. /* We have some brands or slays - count them */
  941. temp = 0;
  942. temp2 = 0;
  943. for (s_ptr = slay_table; s_ptr->slay_flag; s_ptr++)
  944. {
  945. if (of_has(a_ptr->flags, s_ptr->slay_flag))
  946. {
  947. bitflag slay_kill_mask[OF_SIZE], brand_mask[OF_SIZE];
  948. flags_init(brand_mask, OF_SIZE, OF_BRAND_MASK, FLAG_END);
  949. flags_init(slay_kill_mask, OF_SIZE, OF_SLAY_MASK, FLAG_END);
  950. flags_set(slay_kill_mask, OF_SIZE, OF_KILL_MASK, FLAG_END);
  951. if (of_has(slay_kill_mask, s_ptr->slay_flag)) temp++;
  952. if (of_has(brand_mask, s_ptr->slay_flag)) temp2++;
  953. }
  954. }
  955. LOG_PRINT1("Adding %d for slays\n", temp);
  956. LOG_PRINT1("Adding %d for brands\n", temp2);
  957. /* Add these to the frequency count */
  958. artprobs[ART_IDX_MELEE_SLAY] += temp;
  959. artprobs[ART_IDX_MELEE_BRAND] += temp2;
  960. }
  961. /* End of weapon-specific stuff */
  962. }
  963. else
  964. {
  965. /* Check for tunnelling ability */
  966. if (of_has(a_ptr->flags, OF_TUNNEL))
  967. {
  968. LOG_PRINT("Adding 1 for tunnelling bonus - general.\n");
  969. (artprobs[ART_IDX_GEN_TUNN])++;
  970. }
  971. }
  972. /*
  973. * Count up extra AC bonus values.
  974. * Could also add logic to subtract for lower values here, but it's
  975. * probably not worth the trouble since it's so rare.
  976. */
  977. if ( (a_ptr->to_a - randcalc(k_ptr->to_a, 0, MINIMISE) - mean_ac_startval) > 0)
  978. {
  979. temp = (a_ptr->to_a - randcalc(k_ptr->to_a, 0, MINIMISE) - mean_ac_startval) /
  980. mean_ac_increment;
  981. if (temp > 0)
  982. {
  983. if (a_ptr->to_a > 20)
  984. {
  985. LOG_PRINT1("Adding %d for supercharged AC\n", temp);
  986. (artprobs[ART_IDX_GEN_AC_SUPER])++;
  987. }
  988. else if (a_ptr->tval == TV_BOOTS)
  989. {
  990. LOG_PRINT1("Adding %d for AC bonus - boots\n", temp);
  991. (artprobs[ART_IDX_BOOT_AC]) += temp;
  992. }
  993. else if (a_ptr->tval == TV_GLOVES)
  994. {
  995. LOG_PRINT1("Adding %d for AC bonus - gloves\n", temp);
  996. (artprobs[ART_IDX_GLOVE_AC]) += temp;
  997. }
  998. else if (a_ptr->tval == TV_HELM || a_ptr->tval == TV_CROWN)
  999. {
  1000. LOG_PRINT1("Adding %d for AC bonus - headgear\n", temp);
  1001. (artprobs[ART_IDX_HELM_AC]) += temp;
  1002. }
  1003. else if (a_ptr->tval == TV_SHIELD)
  1004. {
  1005. LOG_PRINT1("Adding %d for AC bonus - shield\n", temp);
  1006. (artprobs[ART_IDX_SHIELD_AC]) += temp;
  1007. }
  1008. else if (a_ptr->tval == TV_CLOAK)
  1009. {
  1010. LOG_PRINT1("Adding %d for AC bonus - cloak\n", temp);
  1011. (artprobs[ART_IDX_CLOAK_AC]) += temp;
  1012. }
  1013. else if (a_ptr->tval == TV_SOFT_ARMOR || a_ptr->tval == TV_HARD_ARMOR ||
  1014. a_ptr->tval == TV_DRAG_ARMOR)
  1015. {
  1016. LOG_PRINT1("Adding %d for AC bonus - body armor\n", temp);
  1017. (artprobs[ART_IDX_ARMOR_AC]) += temp;
  1018. }
  1019. else
  1020. {
  1021. LOG_PRINT1("Adding %d for AC bonus - general\n", temp);
  1022. (artprobs[ART_IDX_GEN_AC]) += temp;
  1023. }
  1024. }
  1025. }
  1026. /* Generic armor abilities */
  1027. if (a_ptr->tval == TV_BOOTS || a_ptr->tval == TV_GLOVES ||
  1028. a_ptr->tval == TV_HELM || a_ptr->tval == TV_CROWN ||
  1029. a_ptr->tval == TV_SHIELD || a_ptr->tval == TV_CLOAK ||
  1030. a_ptr->tval == TV_SOFT_ARMOR || a_ptr->tval == TV_HARD_ARMOR ||
  1031. a_ptr->tval == TV_DRAG_ARMOR)
  1032. {
  1033. /* Check weight - is it different from normal? */
  1034. /* ToDo: count higher and lower separately */
  1035. if (a_ptr->weight != k_ptr->weight)
  1036. {
  1037. LOG_PRINT("Adding 1 for unusual weight.\n");
  1038. (artprobs[ART_IDX_ALLARMOR_WEIGHT])++;
  1039. }
  1040. /* Done with generic armor abilities */
  1041. }
  1042. /*
  1043. * General abilities. This section requires a bit more work
  1044. * than the others, because we have to consider cases where
  1045. * a certain ability might be found in a particular item type.
  1046. * For example, ESP is commonly found on headgear, so when
  1047. * we count ESP we must add it to either the headgear or
  1048. * general tally, depending on the base item. This permits
  1049. * us to have general abilities appear more commonly on a
  1050. * certain item type.
  1051. */
  1052. if (flags_test(a_ptr->flags, OF_SIZE, OF_STR, OF_INT, OF_WIS,
  1053. OF_DEX, OF_CON, OF_CHR, FLAG_END))
  1054. {
  1055. /* Stat bonus case. Add up the number of individual
  1056. bonuses */
  1057. temp = 0;
  1058. if (of_has(a_ptr->flags, OF_STR)) temp++;
  1059. if (of_has(a_ptr->flags, OF_INT)) temp++;
  1060. if (of_has(a_ptr->flags, OF_WIS)) temp++;
  1061. if (of_has(a_ptr->flags, OF_DEX)) temp++;
  1062. if (of_has(a_ptr->flags, OF_CON)) temp++;
  1063. if (of_has(a_ptr->flags, OF_CHR)) temp++;
  1064. /* Handle a few special cases separately. */
  1065. if((a_ptr->tval == TV_HELM || a_ptr->tval == TV_CROWN) &&
  1066. (of_has(a_ptr->flags, OF_WIS) || of_has(a_ptr->flags, OF_INT)))
  1067. {
  1068. /* Handle WIS and INT on helms and crowns */
  1069. if(of_has(a_ptr->flags, OF_WIS))
  1070. {
  1071. LOG_PRINT("Adding 1 for WIS bonus on headgear.\n");
  1072. (artprobs[ART_IDX_HELM_WIS])++;
  1073. /* Counted this one separately so subtract it here */
  1074. temp--;
  1075. }
  1076. if(of_has(a_ptr->flags, OF_INT))
  1077. {
  1078. LOG_PRINT("Adding 1 for INT bonus on headgear.\n");
  1079. (artprobs[ART_IDX_HELM_INT])++;
  1080. /* Counted this one separately so subtract it here */
  1081. temp--;
  1082. }
  1083. }
  1084. else if ((a_ptr->tval == TV_SOFT_ARMOR ||
  1085. a_ptr->tval == TV_HARD_ARMOR ||
  1086. a_ptr->tval == TV_DRAG_ARMOR) && of_has(a_ptr->flags, OF_CON))
  1087. {
  1088. /* Handle CON bonus on armor */
  1089. LOG_PRINT("Adding 1 for CON bonus on body armor.\n");
  1090. (artprobs[ART_IDX_ARMOR_CON])++;
  1091. /* Counted this one separately so subtract it here */
  1092. temp--;
  1093. }
  1094. else if (a_ptr->tval == TV_GLOVES && of_has(a_ptr->flags, OF_DEX))
  1095. {
  1096. /* Handle DEX bonus on gloves */
  1097. LOG_PRINT("Adding 1 for DEX bonus on gloves.\n");
  1098. (artprobs[ART_IDX_GLOVE_DEX])++;
  1099. /* Counted this one separately so subtract it here */
  1100. temp--;
  1101. }
  1102. /* Now the general case */
  1103. if (temp > 0)
  1104. {
  1105. /* There are some bonuses that weren't handled above */
  1106. LOG_PRINT1("Adding %d for stat bonuses - general.\n", temp);
  1107. (artprobs[ART_IDX_GEN_STAT]) += temp;
  1108. /* Done with stat bonuses */
  1109. }
  1110. }
  1111. if (flags_test(a_ptr->flags, OF_SIZE, OF_SUST_STR, OF_SUST_INT,
  1112. OF_SUST_WIS, OF_SUST_DEX, OF_SUST_CON,
  1113. OF_SUST_CHR, FLAG_END))
  1114. {
  1115. /* Now do sustains, in a similar manner */
  1116. temp = 0;
  1117. if (of_has(a_ptr->flags, OF_SUST_STR)) temp++;
  1118. if (of_has(a_ptr->flags, OF_SUST_INT)) temp++;
  1119. if (of_has(a_ptr->flags, OF_SUST_WIS)) temp++;
  1120. if (of_has(a_ptr->flags, OF_SUST_DEX)) temp++;
  1121. if (of_has(a_ptr->flags, OF_SUST_CON)) temp++;
  1122. if (of_has(a_ptr->flags, OF_SUST_CHR)) temp++;
  1123. LOG_PRINT1("Adding %d for stat sustains.\n", temp);
  1124. (artprobs[ART_IDX_GEN_SUST]) += temp;
  1125. }
  1126. if (of_has(a_ptr->flags, OF_STEALTH))
  1127. {
  1128. /* Handle stealth, including a couple of special cases */
  1129. if(a_ptr->tval == TV_BOOTS)
  1130. {
  1131. LOG_PRINT("Adding 1 for stealth bonus on boots.\n");
  1132. (artprobs[ART_IDX_BOOT_STEALTH])++;
  1133. }
  1134. else if (a_ptr->tval == TV_CLOAK)
  1135. {
  1136. LOG_PRINT("Adding 1 for stealth bonus on cloak.\n");
  1137. (artprobs[ART_IDX_CLOAK_STEALTH])++;
  1138. }
  1139. else if (a_ptr->tval == TV_SOFT_ARMOR ||
  1140. a_ptr->tval == TV_HARD_ARMOR || a_ptr->tval == TV_DRAG_ARMOR)
  1141. {
  1142. LOG_PRINT("Adding 1 for stealth bonus on armor.\n");
  1143. (artprobs[ART_IDX_ARMOR_STEALTH])++;
  1144. }
  1145. else
  1146. {
  1147. /* General case */
  1148. LOG_PRINT("Adding 1 for stealth bonus - general.\n");
  1149. (artprobs[ART_IDX_GEN_STEALTH])++;
  1150. }
  1151. /* Done with stealth */
  1152. }
  1153. if (of_has(a_ptr->flags, OF_SEARCH))
  1154. {
  1155. /* Handle searching bonus - fully generic this time */
  1156. LOG_PRINT("Adding 1 for search bonus - general.\n");
  1157. (artprobs[ART_IDX_GEN_SEARCH])++;
  1158. }
  1159. if (of_has(a_ptr->flags, OF_INFRA))
  1160. {
  1161. /* Handle infravision bonus - fully generic */
  1162. LOG_PRINT("Adding 1 for infravision bonus - general.\n");
  1163. (artprobs[ART_IDX_GEN_INFRA])++;
  1164. }
  1165. if (of_has(a_ptr->flags, OF_SPEED))
  1166. {
  1167. /*
  1168. * Speed - boots handled separately.
  1169. * This is something of a special case in that we use the same
  1170. * frequency for the supercharged value and the normal value.
  1171. * We get away with this by using a somewhat lower average value
  1172. * for the supercharged ability than in the basic set (around
  1173. * +7 or +8 - c.f. Ringil and the others at +10 and upwards).
  1174. * This then allows us to add an equal number of
  1175. * small bonuses around +3 or so without unbalancing things.
  1176. */
  1177. if (a_ptr->pval > 7)
  1178. {
  1179. /* Supercharge case */
  1180. LOG_PRINT("Adding 1 for supercharged speed bonus!\n");
  1181. (artprobs[ART_IDX_GEN_SPEED_SUPER])++;
  1182. }
  1183. else if(a_ptr->tval == TV_BOOTS)
  1184. {
  1185. /* Handle boots separately */
  1186. LOG_PRINT("Adding 1 for normal speed bonus on boots.\n");
  1187. (artprobs[ART_IDX_BOOT_SPEED])++;
  1188. }
  1189. else
  1190. {
  1191. LOG_PRINT("Adding 1 for normal speed bonus - general.\n");
  1192. (artprobs[ART_IDX_GEN_SPEED])++;
  1193. }
  1194. /* Done with speed */
  1195. }
  1196. if (flags_test(a_ptr->flags, OF_SIZE, OF_IM_ACID, OF_IM_ELEC,
  1197. OF_IM_FIRE, OF_IM_COLD, FLAG_END))
  1198. {
  1199. /* Count up immunities for this item, if any */
  1200. temp = 0;
  1201. if (of_has(a_ptr->flags, OF_IM_ACID)) temp++;
  1202. if (of_has(a_ptr->flags, OF_IM_ELEC)) temp++;
  1203. if (of_has(a_ptr->flags, OF_IM_FIRE)) temp++;
  1204. if (of_has(a_ptr->flags, OF_IM_COLD)) temp++;
  1205. LOG_PRINT1("Adding %d for immunities.\n", temp);
  1206. (artprobs[ART_IDX_GEN_IMMUNE]) += temp;
  1207. }
  1208. if (of_has(a_ptr->flags, OF_FREE_ACT))
  1209. {
  1210. /* Free action - handle gloves separately */
  1211. if(a_ptr->tval == TV_GLOVES)
  1212. {
  1213. LOG_PRINT("Adding 1 for free action on gloves.\n");
  1214. (artprobs[ART_IDX_GLOVE_FA])++;
  1215. }
  1216. else
  1217. {
  1218. LOG_PRINT("Adding 1 for free action - general.\n");
  1219. (artprobs[ART_IDX_GEN_FA])++;
  1220. }
  1221. }
  1222. if (of_has(a_ptr->flags, OF_HOLD_LIFE))
  1223. {
  1224. /* Hold life - do body armor separately */
  1225. if( (a_ptr->tval == TV_SOFT_ARMOR) || (a_ptr->tval == TV_HARD_ARMOR) ||
  1226. (a_ptr->tval == TV_DRAG_ARMOR))
  1227. {
  1228. LOG_PRINT("Adding 1 for hold life on armor.\n");
  1229. (artprobs[ART_IDX_ARMOR_HLIFE])++;
  1230. }
  1231. else
  1232. {
  1233. LOG_PRINT("Adding 1 for hold life - general.\n");
  1234. (artprobs[ART_IDX_GEN_HLIFE])++;
  1235. }
  1236. }
  1237. if (of_has(a_ptr->flags, OF_FEATHER))
  1238. {
  1239. /* Feather fall - handle boots separately */
  1240. if(a_ptr->tval == TV_BOOTS)
  1241. {
  1242. LOG_PRINT("Adding 1 for feather fall on boots.\n");
  1243. (artprobs[ART_IDX_BOOT_FEATHER])++;
  1244. }
  1245. else
  1246. {
  1247. LOG_PRINT("Adding 1 for feather fall - general.\n");
  1248. (artprobs[ART_IDX_GEN_FEATHER])++;
  1249. }
  1250. }
  1251. if (of_has(a_ptr->flags, OF_LIGHT))
  1252. {
  1253. /* Handle permanent light */
  1254. LOG_PRINT("Adding 1 for permanent light - general.\n");
  1255. (artprobs[ART_IDX_GEN_LIGHT])++;
  1256. }
  1257. if (of_has(a_ptr->flags, OF_SEE_INVIS))
  1258. {
  1259. /*
  1260. * Handle see invisible - do helms / crowns separately
  1261. * (Weapons were done already so exclude them)
  1262. */
  1263. if( !(a_ptr->tval == TV_DIGGING || a_ptr->tval == TV_HAFTED ||
  1264. a_ptr->tval == TV_POLEARM || a_ptr->tval == TV_SWORD))
  1265. {
  1266. if (a_ptr->tval == TV_HELM || a_ptr->tval == TV_CROWN)
  1267. {
  1268. LOG_PRINT("Adding 1 for see invisible - headgear.\n");
  1269. (artprobs[ART_IDX_HELM_SINV])++;
  1270. }
  1271. else
  1272. {
  1273. LOG_PRINT("Adding 1 for see invisible - general.\n");
  1274. (artprobs[ART_IDX_GEN_SINV])++;
  1275. }
  1276. }
  1277. }
  1278. if (of_has(a_ptr->flags, OF_TELEPATHY))
  1279. {
  1280. /* ESP case. Handle helms/crowns separately. */
  1281. if(a_ptr->tval == TV_HELM || a_ptr->tval == TV_CROWN)
  1282. {
  1283. LOG_PRINT("Adding 1 for ESP on headgear.\n");
  1284. (artprobs[ART_IDX_HELM_ESP])++;
  1285. }
  1286. else
  1287. {
  1288. LOG_PRINT("Adding 1 for ESP - general.\n");
  1289. (artprobs[ART_IDX_GEN_ESP])++;
  1290. }
  1291. }
  1292. if (of_has(a_ptr->flags, OF_SLOW_DIGEST))
  1293. {
  1294. /* Slow digestion case - generic. */
  1295. LOG_PRINT("Adding 1 for slow digestion - general.\n");
  1296. (artprobs[ART_IDX_GEN_SDIG])++;
  1297. }
  1298. if (of_has(a_ptr->flags, OF_REGEN))
  1299. {
  1300. /* Regeneration case - generic. */
  1301. LOG_PRINT("Adding 1 for regeneration - general.\n");
  1302. (artprobs[ART_IDX_GEN_REGEN])++;
  1303. }
  1304. if (flags_test(a_ptr->flags, OF_SIZE, OF_RES_ACID, OF_RES_ELEC,
  1305. OF_RES_FIRE, OF_RES_COLD, FLAG_END))
  1306. {
  1307. /* Count up low resists (not the type, just the number) */
  1308. temp = 0;
  1309. if (of_has(a_ptr->flags, OF_RES_ACID)) temp++;
  1310. if (of_has(a_ptr->flags, OF_RES_ELEC)) temp++;
  1311. if (of_has(a_ptr->flags, OF_RES_FIRE)) temp++;
  1312. if (of_has(a_ptr->flags, OF_RES_COLD)) temp++;
  1313. /* Shields treated separately */
  1314. if (a_ptr->tval == TV_SHIELD)
  1315. {
  1316. LOG_PRINT1("Adding %d for low resists on shield.\n", temp);
  1317. (artprobs[ART_IDX_SHIELD_LRES]) += temp;
  1318. }
  1319. else if (a_ptr->tval == TV_SOFT_ARMOR ||
  1320. a_ptr->tval == TV_HARD_ARMOR || a_ptr->tval == TV_DRAG_ARMOR)
  1321. {
  1322. /* Armor also treated separately */
  1323. if (temp == 4)
  1324. {
  1325. /* Special case: armor has all four low resists */
  1326. LOG_PRINT("Adding 1 for ALL LOW RESISTS on body armor.\n");
  1327. (artprobs[ART_IDX_ARMOR_ALLRES])++;
  1328. }
  1329. else
  1330. {
  1331. /* Just tally up the resists as usual */
  1332. LOG_PRINT1("Adding %d for low resists on body armor.\n", temp);
  1333. (artprobs[ART_IDX_ARMOR_LRES]) += temp;
  1334. }
  1335. }
  1336. else
  1337. {
  1338. /* General case */
  1339. LOG_PRINT1("Adding %d for low resists - general.\n", temp);
  1340. (artprobs[ART_IDX_GEN_LRES]) += temp;
  1341. }
  1342. /* Done with low resists */
  1343. }
  1344. /*
  1345. * If the item is body armor then count up all the high resists before
  1346. * going through them individually. High resists are an important
  1347. * component of body armor so we track probability for them separately.
  1348. * The proportions of the high resists will be determined by the
  1349. * generic frequencies - this number just tracks the total.
  1350. */
  1351. if (a_ptr->tval == TV_SOFT_ARMOR ||
  1352. a_ptr->tval == TV_HARD_ARMOR || a_ptr->tval == TV_DRAG_ARMOR)
  1353. {
  1354. temp = 0;
  1355. if (of_has(a_ptr->flags, OF_RES_POIS)) temp++;
  1356. if (of_has(a_ptr->flags, OF_RES_FEAR)) temp++;
  1357. if (of_has(a_ptr->flags, OF_RES_LIGHT)) temp++;
  1358. if (of_has(a_ptr->flags, OF_RES_DARK)) temp++;
  1359. if (of_has(a_ptr->flags, OF_RES_BLIND)) temp++;
  1360. if (of_has(a_ptr->flags, OF_RES_CONFU)) temp++;
  1361. if (of_has(a_ptr->flags, OF_RES_SOUND)) temp++;
  1362. if (of_has(a_ptr->flags, OF_RES_SHARD)) temp++;
  1363. if (of_has(a_ptr->flags, OF_RES_NEXUS)) temp++;
  1364. if (of_has(a_ptr->flags, OF_RES_NETHR)) temp++;
  1365. if (of_has(a_ptr->flags, OF_RES_CHAOS)) temp++;
  1366. if (of_has(a_ptr->flags, OF_RES_DISEN)) temp++;
  1367. LOG_PRINT1("Adding %d for high resists on body armor.\n", temp);
  1368. (artprobs[ART_IDX_ARMOR_HRES]) += temp;
  1369. }
  1370. /* Now do the high resists individually */
  1371. if (of_has(a_ptr->flags, OF_RES_POIS))
  1372. {
  1373. /* Resist poison ability */
  1374. LOG_PRINT("Adding 1 for resist poison - general.\n");
  1375. (artprobs[ART_IDX_GEN_RPOIS])++;
  1376. }
  1377. if (of_has(a_ptr->flags, OF_RES_FEAR))
  1378. {
  1379. /* Resist fear ability */
  1380. LOG_PRINT("Adding 1 for resist fear - general.\n");
  1381. (artprobs[ART_IDX_GEN_RFEAR])++;
  1382. }
  1383. if (of_has(a_ptr->flags, OF_RES_LIGHT))
  1384. {
  1385. /* Resist light ability */
  1386. LOG_PRINT("Adding 1 for resist light - general.\n");
  1387. (artprobs[ART_IDX_GEN_RLIGHT])++;
  1388. }
  1389. if (of_has(a_ptr->flags, OF_RES_DARK))
  1390. {
  1391. /* Resist dark ability */
  1392. LOG_PRINT("Adding 1 for resist dark - general.\n");
  1393. (artprobs[ART_IDX_GEN_RDARK])++;
  1394. }
  1395. if (of_has(a_ptr->flags, OF_RES_BLIND))
  1396. {
  1397. /* Resist blind ability - helms/crowns are separate */
  1398. if(a_ptr->tval == TV_HELM || a_ptr->tval == TV_CROWN)
  1399. {
  1400. LOG_PRINT("Adding 1 for resist blindness - headgear.\n");
  1401. (artprobs[ART_IDX_HELM_RBLIND])++;
  1402. }
  1403. else
  1404. {
  1405. /* General case */
  1406. LOG_PRINT("Adding 1 for resist blindness - general.\n");
  1407. (artprobs[ART_IDX_GEN_RBLIND])++;
  1408. }
  1409. }
  1410. if (of_has(a_ptr->flags, OF_RES_CONFU))
  1411. {
  1412. /* Resist confusion ability */
  1413. LOG_PRINT("Adding 1 for resist confusion - general.\n");
  1414. (artprobs[ART_IDX_GEN_RCONF])++;
  1415. }
  1416. if (of_has(a_ptr->flags, OF_RES_SOUND))
  1417. {
  1418. /* Resist sound ability */
  1419. LOG_PRINT("Adding 1 for resist sound - general.\n");
  1420. (artprobs[ART_IDX_GEN_RSOUND])++;
  1421. }
  1422. if (of_has(a_ptr->flags, OF_RES_SHARD))
  1423. {
  1424. /* Resist shards ability */
  1425. LOG_PRINT("Adding 1 for resist shards - general.\n");
  1426. (artprobs[ART_IDX_GEN_RSHARD])++;
  1427. }
  1428. if (of_has(a_ptr->flags, OF_RES_NEXUS))
  1429. {
  1430. /* Resist nexus ability */
  1431. LOG_PRINT("Adding 1 for resist nexus - general.\n");
  1432. (artprobs[ART_IDX_GEN_RNEXUS])++;
  1433. }
  1434. if (of_has(a_ptr->flags, OF_RES_NETHR))
  1435. {
  1436. /* Resist nether ability */
  1437. LOG_PRINT("Adding 1 for resist nether - general.\n");
  1438. (artprobs[ART_IDX_GEN_RNETHER])++;
  1439. }
  1440. if (of_has(a_ptr->flags, OF_RES_CHAOS))
  1441. {
  1442. /* Resist chaos ability */
  1443. LOG_PRINT("Adding 1 for resist chaos - general.\n");
  1444. (artprobs[ART_IDX_GEN_RCHAOS])++;
  1445. }
  1446. if (of_has(a_ptr->flags, OF_RES_DISEN))
  1447. {
  1448. /* Resist disenchantment ability */
  1449. LOG_PRINT("Adding 1 for resist disenchantment - general.\n");
  1450. (artprobs[ART_IDX_GEN_RDISEN])++;
  1451. }
  1452. if (a_ptr->effect)
  1453. {
  1454. /* Activation */
  1455. LOG_PRINT("Adding 1 for activation.\n");
  1456. (artprobs[ART_IDX_GEN_ACTIV])++;
  1457. }
  1458. /* Done with parsing of frequencies for this item */
  1459. }
  1460. /* End for loop */
  1461. if (verbose)
  1462. {
  1463. /* Print out some of the abilities, to make sure that everything's fine */
  1464. for (i = 0; i < ART_IDX_TOTAL; i++)
  1465. {
  1466. file_putf(log_file, "Frequency of ability %d: %d\n", i, artprobs[i]);
  1467. }

Large files files are truncated, but you can click here to view the full file