Crossfire Server, Trunk  1.75.0
treasure.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
20 #include "global.h"
21 
22 #include <ctype.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <math.h>
26 
27 #include "loader.h"
28 #include "sproto.h"
29 #include "treasure.h"
30 #include "assets.h"
31 #include "AssetsManager.h"
32 
39 static int resist_table[] = {
45 };
46 
50 static archetype *ring_arch = NULL, *amulet_arch = NULL, *crown_arch = NULL;
51 
53 #define num_resist_table 19
54 
55 static void change_treasure(treasure *t, object *op); /* overrule default values */
56 static int special_potion(object *op);
57 static void fix_flesh_item(object *item, const object *donor);
58 
63  if (ring_arch == NULL)
64  ring_arch = find_archetype("ring");
65  if (amulet_arch == NULL)
66  amulet_arch = find_archetype("amulet");
67  if (crown_arch == NULL)
68  crown_arch = find_archetype("crown");
69 }
70 
82 static void put_treasure(object *op, object *creator, int flags) {
83  /* Bit of a hack - spells should never be put onto the map. The entire
84  * treasure stuff is a problem - there is no clear idea of knowing
85  * this is the original object, or if this is an object that should be created
86  * by another object.
87  */
88  if (flags&GT_ENVIRONMENT && op->type != SPELL) {
91  if (QUERY_FLAG(op, FLAG_IS_FLOOR))
93  object_insert_in_map_at(op, creator->map, op, flags, creator->x, creator->y);
94  } else
95  object_insert_in_ob(op, creator);
96 }
97 
108 static void change_treasure(treasure *t, object *op) {
109  /* CMD: change_name xxxx */
110  if (t->change_arch.name) {
111  FREE_AND_COPY(op->name, t->change_arch.name);
112  /* not great, but better than something that is completely wrong */
113  FREE_AND_COPY(op->name_pl, t->change_arch.name);
114  }
115 
116  if (t->change_arch.title) {
117  if (op->title)
118  free_string(op->title);
119  op->title = add_string(t->change_arch.title);
120  }
121 
122  if (t->change_arch.slaying) {
123  if (op->slaying)
124  free_string(op->slaying);
125  op->slaying = add_string(t->change_arch.slaying);
126  }
127 }
128 
129 static int AT_LEAST_1(int x) {
130  if (x < 1) {
131  return 1;
132  } else {
133  return x;
134  }
135 }
136 
150 static bool do_single_item(treasure *t, object *op, int flag, int difficulty) {
151  if (!(t->item))
152  return false;
153 
154  object *tmp = arch_to_object(t->item);
155  if (t->nrof && tmp->nrof <= 1) {
156  for (int i = 0; i < AT_LEAST_1(t->nrof_rolls); i++) {
157  tmp->nrof += RANDOM()%((int)t->nrof)+1;
158  }
159  }
160  if (t->artifact) {
161  const artifact *art = find_artifact(tmp, t->artifact);
162  if (!art || !legal_artifact_combination(tmp, art)) {
163  LOG(llevError, "Invalid artifact %s for treasure %s\n", t->artifact, tmp->arch->name);
164  goto reject;
165  } else {
166  give_artifact_abilities(tmp, art->item);
167  }
168  } else {
169  fix_generated_item(tmp, op, difficulty, t->magic, flag);
170  change_treasure(t, tmp);
171  }
172 
173  // We need to apply artifact changes before we know the properties of the final item. Previous
174  // versions of this code only checked the arch 'clone' object, which is not correct.
175  if (flag&GT_ONLY_GOOD && (QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)))
176  goto reject;
177 
178  if (op->type == SHOP_FLOOR && price_base(tmp) < (op->map ? MAX(op->map->shopmin, 1) : 1))
179  goto reject;
180 
181  if (flag&GT_INVISIBLE && tmp->invisible)
182  goto reject;
183 
184  put_treasure(tmp, op, flag);
185  return true;
186 
187 reject:
189  return false;
190 }
191 
207 static void create_all_treasures(treasure *t, object *op, int flag, int difficulty, int tries) {
208  if (chance(t->chance, 100)) {
209  if (t->name) {
210  if (strcmp(t->name, "NONE") && difficulty >= t->magic)
211  create_treasure(find_treasurelist(t->name), op, flag, t->list_magic_value ? t->list_magic_value : difficulty + t->list_magic_adjustment, tries);
212  } else {
213  while (tries < 100) {
214  if (do_single_item(t, op, flag, difficulty))
215  break;
216  tries++;
217  }
218  }
219  if (t->next_yes != NULL)
220  create_all_treasures(t->next_yes, op, flag, difficulty, tries);
221  } else
222  if (t->next_no != NULL)
223  create_all_treasures(t->next_no, op, flag, difficulty, tries);
224  if (t->next != NULL)
225  create_all_treasures(t->next, op, flag, difficulty, tries);
226 }
227 
246 static void create_one_treasure(treasurelist *tl, object *op, int flag, int difficulty, int tries) {
247  int value = RANDOM()%tl->total_chance;
248  treasure *t;
249 
250  if (tries++ > 100) {
251  LOG(llevDebug, "create_one_treasure: tries exceeded 100, returning without making treasure\n");
252  return;
253  }
254 
255  for (t = tl->items; t != NULL; t = t->next) {
256  value -= t->chance;
257  if (value < 0)
258  break;
259  }
260 
261  if (!t || value >= 0) {
262  LOG(llevError, "create_one_treasure: got null object or not able to find treasure\n");
263  abort();
264  }
265  if (t->name) {
266  if (!strcmp(t->name, "NONE"))
267  return;
268  if (difficulty >= t->magic)
269  create_treasure(find_treasurelist(t->name), op, flag, t->list_magic_value ? t->list_magic_value : difficulty + t->list_magic_adjustment, tries);
270  else if (t->nrof)
271  create_one_treasure(tl, op, flag, difficulty, tries);
272  return;
273  }
274  bool got_one = false;
275  while (tries < 100) {
276  if (do_single_item(t, op, flag, difficulty)) {
277  got_one = true;
278  break;
279  }
280  tries++;
281  }
282  if (!got_one)
283  LOG(llevWarn, "create_one_treasure failed to create at least one treasure for item %s on list %s\n", t->item->name, tl->name);
284 }
285 
301 void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries) {
302  if (tries++ > 100) {
303  LOG(llevDebug, "createtreasure: tries exceeded 100, returning without making treasure\n");
304  return;
305  }
306  if (!t->items) {
307  LOG(llevError, "Empty treasure list %s\n", t->name);
308  return;
309  }
310  if (t->total_chance)
311  create_one_treasure(t, op, flag, difficulty, tries);
312  else
313  create_all_treasures(t->items, op, flag, difficulty, tries);
314 }
315 
333 object *generate_treasure(treasurelist *t, int difficulty) {
334  object *ob = object_new(), *tmp;
335 
336  create_treasure(t, ob, 0, difficulty, 0);
337 
338  /* Don't want to free the object we are about to return */
339  tmp = ob->inv;
340  if (tmp != NULL)
341  object_remove(tmp);
342  if (ob->inv) {
343  LOG(llevError, "In generate treasure, created multiple objects.\n");
344  }
346  return tmp;
347 }
348 
361 static int level_for_item(const object *op, int difficulty) {
362  int level, mult, olevel;
363 
364  if (!op->inv) {
365  LOG(llevError, "level_for_item: Object %s has no inventory!\n", op->name);
366  return 0;
367  }
368  level = op->inv->level;
369 
370  /* Basically, we set mult to the lowest spell increase attribute that is
371  * not zero - zero's mean no modification is done, so we don't want those.
372  * given we want non zero results, we can't just use a few MIN's here.
373  */
374  mult = op->inv->dam_modifier;
375  if (op->inv->range_modifier && (op->inv->range_modifier < mult || mult == 0))
376  mult = op->inv->range_modifier;
377  if (op->inv->duration_modifier && (op->inv->duration_modifier < mult || mult == 0))
378  mult = op->inv->duration_modifier;
379 
380  if (mult == 0)
381  mult = 5;
382 
383  // This should give us roughly a normal distribution averaged at difficulty.
384  olevel = rndm(0, difficulty)+rndm(0, difficulty);
385  // Now we truncate to the closest level + n * mult value below.
386  olevel = ((olevel-level)/mult)*mult+level; // This should truncate to a multiple of mult for us.
387  if (olevel > MAX_SPELLITEM_LEVEL)
388  olevel = MAX_SPELLITEM_LEVEL;
389  // Make sure we hit the minimum spell level, too
390  else if (olevel < level)
391  olevel = level;
392 
393  return olevel;
394 }
395 
403 static const int difftomagic_list[DIFFLEVELS][MAXMAGIC+1] = {
404 /*chance of magic difficulty*/
405 /* +0 +1 +2 +3 +4 */
406  { 94, 3, 2, 1, 0 }, /*1*/
407  { 94, 3, 2, 1, 0 }, /*2*/
408  { 94, 3, 2, 1, 0 }, /*3*/
409  { 94, 3, 2, 1, 0 }, /*4*/
410  { 94, 3, 2, 1, 0 }, /*5*/
411  { 90, 4, 3, 2, 1 }, /*6*/
412  { 90, 4, 3, 2, 1 }, /*7*/
413  { 90, 4, 3, 2, 1 }, /*8*/
414  { 90, 4, 3, 2, 1 }, /*9*/
415  { 90, 4, 3, 2, 1 }, /*10*/
416  { 85, 6, 4, 3, 2 }, /*11*/
417  { 85, 6, 4, 3, 2 }, /*12*/
418  { 85, 6, 4, 3, 2 }, /*13*/
419  { 85, 6, 4, 3, 2 }, /*14*/
420  { 85, 6, 4, 3, 2 }, /*15*/
421  { 81, 8, 5, 4, 3 }, /*16*/
422  { 81, 8, 5, 4, 3 }, /*17*/
423  { 81, 8, 5, 4, 3 }, /*18*/
424  { 81, 8, 5, 4, 3 }, /*19*/
425  { 81, 8, 5, 4, 3 }, /*20*/
426  { 75, 10, 6, 5, 4 }, /*21*/
427  { 75, 10, 6, 5, 4 }, /*22*/
428  { 75, 10, 6, 5, 4 }, /*23*/
429  { 75, 10, 6, 5, 4 }, /*24*/
430  { 75, 10, 6, 5, 4 }, /*25*/
431  { 70, 12, 7, 6, 5 }, /*26*/
432  { 70, 12, 7, 6, 5 }, /*27*/
433  { 70, 12, 7, 6, 5 }, /*28*/
434  { 70, 12, 7, 6, 5 }, /*29*/
435  { 70, 12, 7, 6, 5 }, /*30*/
436  { 70, 9, 8, 7, 6 }, /*31*/
437  { 70, 9, 8, 7, 6 }, /*32*/
438  { 70, 9, 8, 7, 6 }, /*33*/
439  { 70, 9, 8, 7, 6 }, /*34*/
440  { 70, 9, 8, 7, 6 }, /*35*/
441  { 70, 6, 9, 8, 7 }, /*36*/
442  { 70, 6, 9, 8, 7 }, /*37*/
443  { 70, 6, 9, 8, 7 }, /*38*/
444  { 70, 6, 9, 8, 7 }, /*39*/
445  { 70, 6, 9, 8, 7 }, /*40*/
446  { 70, 3, 10, 9, 8 }, /*41*/
447  { 70, 3, 10, 9, 8 }, /*42*/
448  { 70, 3, 10, 9, 8 }, /*43*/
449  { 70, 3, 10, 9, 8 }, /*44*/
450  { 70, 3, 10, 9, 8 }, /*45*/
451  { 70, 2, 9, 10, 9 }, /*46*/
452  { 70, 2, 9, 10, 9 }, /*47*/
453  { 70, 2, 9, 10, 9 }, /*48*/
454  { 70, 2, 9, 10, 9 }, /*49*/
455  { 70, 2, 9, 10, 9 }, /*50*/
456  { 70, 2, 7, 11, 10 }, /*51*/
457  { 70, 2, 7, 11, 10 }, /*52*/
458  { 70, 2, 7, 11, 10 }, /*53*/
459  { 70, 2, 7, 11, 10 }, /*54*/
460  { 70, 2, 7, 11, 10 }, /*55*/
461  { 70, 2, 5, 12, 11 }, /*56*/
462  { 70, 2, 5, 12, 11 }, /*57*/
463  { 70, 2, 5, 12, 11 }, /*58*/
464  { 70, 2, 5, 12, 11 }, /*59*/
465  { 70, 2, 5, 12, 11 }, /*60*/
466  { 70, 2, 3, 13, 12 }, /*61*/
467  { 70, 2, 3, 13, 12 }, /*62*/
468  { 70, 2, 3, 13, 12 }, /*63*/
469  { 70, 2, 3, 13, 12 }, /*64*/
470  { 70, 2, 3, 13, 12 }, /*65*/
471  { 70, 2, 3, 12, 13 }, /*66*/
472  { 70, 2, 3, 12, 13 }, /*67*/
473  { 70, 2, 3, 12, 13 }, /*68*/
474  { 70, 2, 3, 12, 13 }, /*69*/
475  { 70, 2, 3, 12, 13 }, /*70*/
476  { 70, 2, 3, 11, 14 }, /*71*/
477  { 70, 2, 3, 11, 14 }, /*72*/
478  { 70, 2, 3, 11, 14 }, /*73*/
479  { 70, 2, 3, 11, 14 }, /*74*/
480  { 70, 2, 3, 11, 14 }, /*75*/
481  { 70, 2, 3, 10, 15 }, /*76*/
482  { 70, 2, 3, 10, 15 }, /*77*/
483  { 70, 2, 3, 10, 15 }, /*78*/
484  { 70, 2, 3, 10, 15 }, /*79*/
485  { 70, 2, 3, 10, 15 }, /*80*/
486  { 70, 2, 3, 9, 16 }, /*81*/
487  { 70, 2, 3, 9, 16 }, /*82*/
488  { 70, 2, 3, 9, 16 }, /*83*/
489  { 70, 2, 3, 9, 16 }, /*84*/
490  { 70, 2, 3, 9, 16 }, /*85*/
491  { 70, 2, 3, 8, 17 }, /*86*/
492  { 70, 2, 3, 8, 17 }, /*87*/
493  { 70, 2, 3, 8, 17 }, /*88*/
494  { 70, 2, 3, 8, 17 }, /*89*/
495  { 70, 2, 3, 8, 17 }, /*90*/
496  { 70, 2, 3, 7, 18 }, /*91*/
497  { 70, 2, 3, 7, 18 }, /*92*/
498  { 70, 2, 3, 7, 18 }, /*93*/
499  { 70, 2, 3, 7, 18 }, /*94*/
500  { 70, 2, 3, 7, 18 }, /*95*/
501  { 70, 2, 3, 6, 19 }, /*96*/
502  { 70, 2, 3, 6, 19 }, /*97*/
503  { 70, 2, 3, 6, 19 }, /*98*/
504  { 70, 2, 3, 6, 19 }, /*99*/
505  { 70, 2, 3, 6, 19 }, /*100*/
506  { 70, 2, 3, 6, 19 }, /*101*/
507  { 70, 2, 3, 6, 19 }, /*101*/
508  { 70, 2, 3, 6, 19 }, /*102*/
509  { 70, 2, 3, 6, 19 }, /*103*/
510  { 70, 2, 3, 6, 19 }, /*104*/
511  { 70, 2, 3, 6, 19 }, /*105*/
512  { 70, 2, 3, 6, 19 }, /*106*/
513  { 70, 2, 3, 6, 19 }, /*107*/
514  { 70, 2, 3, 6, 19 }, /*108*/
515  { 70, 2, 3, 6, 19 }, /*109*/
516  { 70, 2, 3, 6, 19 }, /*110*/
517  { 70, 2, 3, 6, 19 }, /*111*/
518  { 70, 2, 3, 6, 19 }, /*112*/
519  { 70, 2, 3, 6, 19 }, /*113*/
520  { 70, 2, 3, 6, 19 }, /*114*/
521  { 70, 2, 3, 6, 19 }, /*115*/
522  { 70, 2, 3, 6, 19 }, /*116*/
523  { 70, 2, 3, 6, 19 }, /*117*/
524  { 70, 2, 3, 6, 19 }, /*118*/
525  { 70, 2, 3, 6, 19 }, /*119*/
526  { 70, 2, 3, 6, 19 }, /*120*/
527  { 70, 2, 3, 6, 19 }, /*121*/
528  { 70, 2, 3, 6, 19 }, /*122*/
529  { 70, 2, 3, 6, 19 }, /*123*/
530  { 70, 2, 3, 6, 19 }, /*124*/
531  { 70, 2, 3, 6, 19 }, /*125*/
532  { 70, 2, 3, 6, 19 }, /*126*/
533  { 70, 2, 3, 6, 19 }, /*127*/
534  { 70, 2, 3, 6, 19 }, /*128*/
535  { 70, 2, 3, 6, 19 }, /*129*/
536  { 70, 2, 3, 6, 19 }, /*130*/
537  { 70, 2, 3, 6, 19 }, /*131*/
538  { 70, 2, 3, 6, 19 }, /*132*/
539  { 70, 2, 3, 6, 19 }, /*133*/
540  { 70, 2, 3, 6, 19 }, /*134*/
541  { 70, 2, 3, 6, 19 }, /*135*/
542  { 70, 2, 3, 6, 19 }, /*136*/
543  { 70, 2, 3, 6, 19 }, /*137*/
544  { 70, 2, 3, 6, 19 }, /*138*/
545  { 70, 2, 3, 6, 19 }, /*139*/
546  { 70, 2, 3, 6, 19 }, /*140*/
547  { 70, 2, 3, 6, 19 }, /*141*/
548  { 70, 2, 3, 6, 19 }, /*142*/
549  { 70, 2, 3, 6, 19 }, /*143*/
550  { 70, 2, 3, 6, 19 }, /*144*/
551  { 70, 2, 3, 6, 19 }, /*145*/
552  { 70, 2, 3, 6, 19 }, /*146*/
553  { 70, 2, 3, 6, 19 }, /*147*/
554  { 70, 2, 3, 6, 19 }, /*148*/
555  { 70, 2, 3, 6, 19 }, /*149*/
556  { 70, 2, 3, 6, 19 }, /*150*/
557  { 70, 2, 3, 6, 19 }, /*151*/
558  { 70, 2, 3, 6, 19 }, /*152*/
559  { 70, 2, 3, 6, 19 }, /*153*/
560  { 70, 2, 3, 6, 19 }, /*154*/
561  { 70, 2, 3, 6, 19 }, /*155*/
562  { 70, 2, 3, 6, 19 }, /*156*/
563  { 70, 2, 3, 6, 19 }, /*157*/
564  { 70, 2, 3, 6, 19 }, /*158*/
565  { 70, 2, 3, 6, 19 }, /*159*/
566  { 70, 2, 3, 6, 19 }, /*160*/
567  { 70, 2, 3, 6, 19 }, /*161*/
568  { 70, 2, 3, 6, 19 }, /*162*/
569  { 70, 2, 3, 6, 19 }, /*163*/
570  { 70, 2, 3, 6, 19 }, /*164*/
571  { 70, 2, 3, 6, 19 }, /*165*/
572  { 70, 2, 3, 6, 19 }, /*166*/
573  { 70, 2, 3, 6, 19 }, /*167*/
574  { 70, 2, 3, 6, 19 }, /*168*/
575  { 70, 2, 3, 6, 19 }, /*169*/
576  { 70, 2, 3, 6, 19 }, /*170*/
577  { 70, 2, 3, 6, 19 }, /*171*/
578  { 70, 2, 3, 6, 19 }, /*172*/
579  { 70, 2, 3, 6, 19 }, /*173*/
580  { 70, 2, 3, 6, 19 }, /*174*/
581  { 70, 2, 3, 6, 19 }, /*175*/
582  { 70, 2, 3, 6, 19 }, /*176*/
583  { 70, 2, 3, 6, 19 }, /*177*/
584  { 70, 2, 3, 6, 19 }, /*178*/
585  { 70, 2, 3, 6, 19 }, /*179*/
586  { 70, 2, 3, 6, 19 }, /*180*/
587  { 70, 2, 3, 6, 19 }, /*181*/
588  { 70, 2, 3, 6, 19 }, /*182*/
589  { 70, 2, 3, 6, 19 }, /*183*/
590  { 70, 2, 3, 6, 19 }, /*184*/
591  { 70, 2, 3, 6, 19 }, /*185*/
592  { 70, 2, 3, 6, 19 }, /*186*/
593  { 70, 2, 3, 6, 19 }, /*187*/
594  { 70, 2, 3, 6, 19 }, /*188*/
595  { 70, 2, 3, 6, 19 }, /*189*/
596  { 70, 2, 3, 6, 19 }, /*190*/
597  { 70, 2, 3, 6, 19 }, /*191*/
598  { 70, 2, 3, 6, 19 }, /*192*/
599  { 70, 2, 3, 6, 19 }, /*193*/
600  { 70, 2, 3, 6, 19 }, /*194*/
601  { 70, 2, 3, 6, 19 }, /*195*/
602  { 70, 2, 3, 6, 19 }, /*196*/
603  { 70, 2, 3, 6, 19 }, /*197*/
604  { 70, 2, 3, 6, 19 }, /*198*/
605  { 70, 2, 3, 6, 19 }, /*199*/
606  { 70, 2, 3, 6, 19 }, /*200*/
607 };
608 
616 static int magic_from_difficulty(int difficulty) {
617  int percent, loop;
618 
619  difficulty--;
620  if (difficulty < 0)
621  difficulty = 0;
622 
623  if (difficulty >= DIFFLEVELS)
624  difficulty = DIFFLEVELS-1;
625 
626  percent = RANDOM()%100;
627 
628  for (loop = 0; loop < (MAXMAGIC+1); ++loop) {
629  percent -= difftomagic_list[difficulty][loop];
630  if (percent < 0)
631  break;
632  }
633  if (loop == (MAXMAGIC+1)) {
634  LOG(llevError, "Warning, table for difficulty %d bad.\n", difficulty);
635  loop = 0;
636  }
637  /* LOG(llevDebug, "Chose magic %d for difficulty %d\n", loop, difficulty);*/
638  return (RANDOM()%3) ? loop : -loop;
639 }
640 
656 void set_abs_magic(object *op, int magic) {
657  int32_t base_weight, base_speed;
658  if (!magic)
659  return;
660 
661  op->magic = magic;
662  if (op->arch) {
663  base_weight = op->arch->clone.weight;
664  base_speed = ARMOUR_SPEED(&op->arch->clone);
665  }
666  else {
667  base_weight = op->weight;
668  base_speed = ARMOUR_SPEED(op);
669  }
670  // Now we do the calculations
671  if (op->type == ARMOUR) {
673  ARMOUR_SPEED(op) = base_speed*(100+magic*settings.armor_speed_improvement)/100;
674  else
675  // This could have been done with a loop, but that seems to be less scalable.
676  // This will introduce less roundoff error than a loop, anyway
677  ARMOUR_SPEED(op) = (int32_t)(base_speed * pow(((float)(100+settings.armor_speed_improvement))/100, magic));
678  }
679  // Prepare for handling the weight. Sometimes cursed ones will have low weight like good ones.
680  if (magic < 0 && !(RANDOM()%3)) /* You can't just check the weight always */
681  magic = (-magic);
683  op->weight = (base_weight*(100-magic*settings.armor_weight_reduction))/100;
684  else
685  op->weight = (int32_t)(base_weight * pow(((float)(100-settings.armor_weight_reduction))/100, magic));
686 
687 }
688 
704 static void set_magic(int difficulty, object *op, int max_magic, int flags) {
705  int i;
706 
707  i = magic_from_difficulty(difficulty);
708  if ((flags&GT_ONLY_GOOD) && i < 0)
709  i = -i;
710  if (i > max_magic)
711  i = max_magic;
712  set_abs_magic(op, i);
713  if (i < 0)
714  SET_FLAG(op, FLAG_CURSED);
715 }
716 
733 static void set_ring_bonus(object *op, int bonus) {
734  int r = RANDOM()%(bonus > 0 ? 25 : 11);
735 
736  if (op->type == AMULET) {
737  if (!(RANDOM()%21))
738  r = 20+RANDOM()%2;
739  else {
740  if (RANDOM()&2)
741  r = 10;
742  else
743  r = 11+RANDOM()%9;
744  }
745  }
746 
747  switch (r) {
748  /* Redone by MSW 2000-11-26 to have much less code. Also,
749  * bonuses and penalties will stack and add to existing values.
750  * of the item.
751  */
752  case 0:
753  case 1:
754  case 2:
755  case 3:
756  case 4:
757  case 5:
758  case 6:
759  set_attr_value(&op->stats, r, (signed char)(bonus+get_attr_value(&op->stats, r)));
760  break;
761 
762  case 7:
763  op->stats.dam += bonus;
764  break;
765 
766  case 8:
767  op->stats.wc += bonus;
768  break;
769 
770  case 9:
771  op->stats.food += bonus; /* hunger/sustenance */
772  break;
773 
774  case 10:
775  op->stats.ac += bonus;
776  break;
777 
778  /* Item that gives protections/vulnerabilities */
779  case 11:
780  case 12:
781  case 13:
782  case 14:
783  case 15:
784  case 16:
785  case 17:
786  case 18:
787  case 19: {
788  int b = 5+FABS(bonus), val, resist = RANDOM()%num_resist_table;
789 
790  /* Roughly generate a bonus between 100 and 35 (depending on the bonus) */
791  val = 10+RANDOM()%b+RANDOM()%b+RANDOM()%b+RANDOM()%b;
792 
793  /* Cursed items need to have higher negative values to equal out with
794  * positive values for how protections work out. Put another
795  * little random element in since that they don't always end up with
796  * even values.
797  */
798  if (bonus < 0)
799  val = 2*-val-RANDOM()%b;
800  if (val > 35)
801  val = 35; /* Upper limit */
802  b = 0;
803  while (op->resist[resist_table[resist]] != 0 && b++ < 4) {
804  resist = RANDOM()%num_resist_table;
805  }
806  if (b == 4)
807  return; /* Not able to find a free resistance */
808  op->resist[resist_table[resist]] = val;
809  /* We should probably do something more clever here to adjust value
810  * based on how good a resistance we gave.
811  */
812  break;
813  }
814 
815  case 20:
816  if (op->type == AMULET) {
818  op->value *= 11;
819  } else {
820  op->stats.hp = 1; /* regenerate hit points */
821  op->value *= 4;
822  }
823  break;
824 
825  case 21:
826  if (op->type == AMULET) {
828  op->value *= 9;
829  } else {
830  op->stats.sp = 1; /* regenerate spell points */
831  op->value *= 3;
832  }
833  break;
834 
835  case 22:
836  op->stats.grace += bonus; /* regenerate grace */
837  op->value *= 5;
838  break;
839 
840  case 23:
841  op->stats.exp += bonus; /* Speed! */
842  op->value = (op->value*2)/3;
843  break;
844  }
845  if (bonus > 0)
846  op->value *= 2*bonus;
847  else
848  op->value = -(op->value*2*bonus)/3;
849 }
850 
861 static void trap_adjust(object *trap, int difficulty) {
862  int i;
863 
864  /* now we set the trap level to match the difficulty of the level
865  * the formula below will give a level from 1 to (2*difficulty) with
866  * a peak probability at difficulty
867  */
868 
869  trap->level = rndm(0, difficulty-1)+rndm(0, difficulty-1);
870  if (trap->level < 1)
871  trap->level = 1;
872 
873  /* set the hiddenness of the trap, similar formula to above */
874  trap->stats.Cha = rndm(0, 19)+rndm(0, difficulty-1)+rndm(0, difficulty-1);
875 
876  if (!trap->other_arch && !trap->inv) {
877  /* set the damage of the trap.
878  * we get 0-4 pts of damage per level of difficulty of the map in
879  * the trap
880  */
881 
882  trap->stats.dam = 0;
883  for (i = 0; i < difficulty; i++)
884  trap->stats.dam += rndm(0, 4);
885 
886  /* the poison trap special case */
887  if (trap->attacktype&AT_POISON) {
888  trap->stats.dam = rndm(0, difficulty-1);
889  if (trap->stats.dam < 1)
890  trap->stats.dam = 1;
891  }
892 
893  /* so we get an appropriate amnt of exp for AT_DEATH traps */
894  if (trap->attacktype&AT_DEATH)
895  trap->stats.dam = 127;
896  }
897 }
898 
899 #define DICE2 (dice2())
900 
904 bool chance(int a, int b) {
905  // Example: chance(2, 3). RANDOM%3 is 0, 1, or 2. 2/3 chance is the result < 2.
906  return RANDOM() % uint32_t(b) < uint32_t(a);
907 }
908 
909 static int dice2() {
910  return chance(2, 27) ? 2 : 1;
911 }
912 
913 #define DICESPELL (RANDOM()%3+RANDOM()%3+RANDOM()%3+RANDOM()%3+RANDOM()%3)
914 
941 void fix_generated_item(object *op, object *creator, int difficulty, int max_magic, int flags) {
942  int was_magic = op->magic, num_enchantments = 0, save_item_power;
943 
944  if (!creator || creator->type == op->type)
945  creator = op; /* safety & to prevent polymorphed objects giving attributes */
946 
947  /* If we make an artifact, this information will be destroyed */
948  save_item_power = op->item_power;
949  op->item_power = 0;
950 
951  if (op->randomitems && op->type != SPELL) {
952  create_treasure(op->randomitems, op, flags, difficulty, 0);
953  if (!op->inv)
954  LOG(llevDebug, "fix_generated_item: Unable to generate treasure for %s\n", op->name);
955  /* So the treasure doesn't get created again */
956  op->randomitems = NULL;
957  }
958 
959  if (difficulty < 1)
960  difficulty = 1;
961  if (!(flags&GT_MINIMAL)) {
962  if (op->arch == crown_arch) {
963  set_magic(difficulty > 25 ? 30 : difficulty+5, op, max_magic, flags);
964  num_enchantments = calc_item_power(op);
965  generate_artifact(op, difficulty);
966  } else {
967  if (!op->magic && max_magic)
968  set_magic(difficulty, op, max_magic, flags);
969  num_enchantments = calc_item_power(op);
970  if ((!was_magic && !(RANDOM()%CHANCE_FOR_ARTIFACT))
971  || op->type == ROD
972  || difficulty >= 999)
973  generate_artifact(op, difficulty);
974  }
975 
976  /* Object was made an artifact. Calculate its item_power rating.
977  * the item_power in the object is what the artifact adds.
978  */
979  if (op->title) {
980  /* if save_item_power is set, then most likely we started with an
981  * artifact and have added new abilities to it - this is rare, but
982  * but I have seen things like 'strange rings of fire'. So just
983  * figure out the power from the base power plus what this one adds.
984  * Note that since item_power is not quite linear, this actually
985  * ends up being somewhat of a bonus.
986  */
987  if (save_item_power)
988  op->item_power = save_item_power+get_power_from_ench(op->item_power);
989  else
990  op->item_power += get_power_from_ench(num_enchantments);
991  } else if (save_item_power) {
992  /* restore the item_power field to the object if we haven't changed
993  * it. we don't care about num_enchantments - that will basically
994  * just have calculated some value from the base attributes of the
995  * archetype.
996  */
997  op->item_power = save_item_power;
998  } else {
999  /* item_power was zero. This is suspicious, as it may be because it
1000  * was never previously calculated. Let's compute a value and see if
1001  * it is non-zero. If it indeed is, then assign it as the new
1002  * item_power value.
1003  * - gros, 21th of July 2006.
1004  */
1005  op->item_power = calc_item_power(op);
1006  save_item_power = op->item_power; /* Just in case it would get used
1007  * again below */
1008  }
1009  } else {
1010  /* If flag is GT_MINIMAL, we want to restore item power */
1011  op->item_power = save_item_power;
1012  }
1013 
1014  /* materialtype modifications. Note we allow this on artifacts. */
1015  set_materialname(op);
1016 
1017  if (flags&GT_MINIMAL) {
1018  if (op->type == POTION)
1019  /* Handle healing and magic power potions */
1020  if (op->stats.sp && !op->randomitems) {
1021  object *tmp;
1022  if (spell_mapping[op->stats.sp]) {
1023  tmp = create_archetype(spell_mapping[op->stats.sp]);
1024  object_insert_in_ob(tmp, op);
1025  }
1026  op->stats.sp = 0;
1027  }
1028  } else if (!op->title) { /* Only modify object if not special */
1029  switch (op->type) {
1030  case WEAPON:
1031  case ARMOUR:
1032  case SHIELD:
1033  case HELMET:
1034  case CLOAK:
1035  if (QUERY_FLAG(op, FLAG_CURSED) && !(RANDOM()%4))
1036  set_ring_bonus(op, -DICE2);
1037  break;
1038 
1039  case BRACERS:
1040  if (!(RANDOM()%(QUERY_FLAG(op, FLAG_CURSED) ? 5 : 20))) {
1042  if (!QUERY_FLAG(op, FLAG_CURSED))
1043  op->value *= 3;
1044  }
1045  break;
1046 
1047  case POTION: {
1048  int too_many_tries = 0, is_special = 0;
1049 
1050  /* Handle healing and magic power potions */
1051  if (op->stats.sp && !op->randomitems) {
1052  object *tmp;
1053 
1054  tmp = create_archetype(spell_mapping[op->stats.sp]);
1055  object_insert_in_ob(tmp, op);
1056  op->stats.sp = 0;
1057  }
1058 
1059  while (!(is_special = special_potion(op)) && !op->inv) {
1060  generate_artifact(op, difficulty);
1061  if (too_many_tries++ > 10)
1062  break;
1063  }
1064  /* don't want to change value for healing/magic power potions,
1065  * since the value set on those is already correct.
1066  */
1067  if (op->inv && op->randomitems) {
1068  /* value multiplier is same as for scrolls */
1069  op->value = (op->value*op->inv->value);
1070  op->level = op->inv->level/2+RANDOM()%difficulty+RANDOM()%difficulty;
1071  } else {
1072  FREE_AND_COPY(op->name, "potion");
1073  FREE_AND_COPY(op->name_pl, "potions");
1074  }
1075  if (!(flags&GT_ONLY_GOOD) && RANDOM()%2)
1076  SET_FLAG(op, FLAG_CURSED);
1077  break;
1078  }
1079 
1080  case AMULET:
1081  if (op->arch == amulet_arch)
1082  op->value *= 5; /* Since it's not just decoration */
1083  /* fall through */
1084  case RING:
1085  if (op->arch == NULL) {
1086  object_remove(op);
1088  op = NULL;
1089  return;
1090  }
1091  if (op->arch != ring_arch && op->arch != amulet_arch)
1092  /* It's a special artifact!*/
1093  break;
1094 
1095  if (GET_ANIM_ID(op))
1096  SET_ANIMATION(op, RANDOM()%((int)NUM_ANIMATIONS(op)));
1097  if (!(flags&GT_ONLY_GOOD) && !(RANDOM()%3))
1098  SET_FLAG(op, FLAG_CURSED);
1100  if (op->type != RING) /* Amulets have only one ability */
1101  break;
1102  if (!(RANDOM()%4)) {
1103  int d = (RANDOM()%2 || QUERY_FLAG(op, FLAG_CURSED)) ? -DICE2 : DICE2;
1104  if (d > 0)
1105  op->value *= 3;
1106  set_ring_bonus(op, d);
1107  if (!(RANDOM()%4)) {
1108  int d = (RANDOM()%3 || QUERY_FLAG(op, FLAG_CURSED)) ? -DICE2 : DICE2;
1109  if (d > 0)
1110  op->value *= 5;
1111  set_ring_bonus(op, d);
1112  }
1113  }
1114  break;
1115 
1116  case BOOK:
1117  /* Is it an empty book?, if yes lets make a special
1118  * msg for it, and tailor its properties based on the
1119  * creator and/or map level we found it on.
1120  */
1121  if (!op->msg && RANDOM()%10) {
1122  /* set the book level properly */
1123  if (creator->level == 0 || QUERY_FLAG(creator, FLAG_ALIVE)) {
1124  if (op->map && op->map->difficulty)
1125  op->level = RANDOM()%(op->map->difficulty)+RANDOM()%10+1;
1126  else
1127  op->level = RANDOM()%20+1;
1128  } else
1129  op->level = RANDOM()%creator->level;
1130 
1131  tailor_readable_ob(op, creator->stats.sp);
1132  /* books w/ info are worth more! */
1133  if (op->msg != NULL)
1134  op->value *= ((op->level > 10 ? op->level : (op->level+1)/2)*((strlen(op->msg)/250)+1));
1135  /* creator related stuff */
1136 
1137  if (creator->slaying && !op->slaying) /* for check_inv floors */
1138  op->slaying = add_string(creator->slaying);
1139 
1140  /* add exp so reading it gives xp (once)*/
1141  op->stats.exp = op->value > 10000 ? op->value/5 : op->value/10;
1142  }
1143  /* for library, chained books. Note that some monsters have
1144  * no_pick set - we don't want to set no pick in that case. */
1145  if (QUERY_FLAG(creator, FLAG_NO_PICK)
1146  && !QUERY_FLAG(creator, FLAG_MONSTER)
1147  && creator->type != SHOP_FLOOR) // shop readables need to be pickable
1148  SET_FLAG(op, FLAG_NO_PICK);
1149  break;
1150 
1151  case SPELLBOOK:
1152  if (!op->inv) {
1153  LOG(llevError, "Generated a spellbook without a spell\n");
1154  break;
1155  }
1156  op->value = op->value*op->inv->value;
1157  /* add exp so learning gives xp */
1158  op->level = op->inv->level;
1159  op->stats.exp = op->value;
1160  /* some more fun */
1161  if (!(flags&GT_ONLY_GOOD) && rndm(1, 100) <= 5) {
1162  if (rndm(1, 6) <= 1)
1163  SET_FLAG(op, FLAG_DAMNED);
1164  else
1165  SET_FLAG(op, FLAG_CURSED);
1166  } else if (rndm(1, 100) <= 1) {
1167  SET_FLAG(op, FLAG_BLESSED);
1168  }
1169  break;
1170 
1171  case WAND:
1172  if (!op->inv) {
1173  LOG(llevError, "Generated a wand without a spell\n");
1174  break;
1175  }
1176  /* nrof in the treasure list is number of charges,
1177  * not number of wands. So copy that into food (charges),
1178  * and reset nrof.
1179  */
1180  op->stats.food = op->inv->nrof;
1181  op->nrof = 1;
1182  /* If the spell changes by level, choose a random level
1183  * for it, and adjust price. If the spell doesn't
1184  * change by level, just set the wand to the level of
1185  * the spell, and value calculation is simpler.
1186  */
1187  if (op->inv->duration_modifier
1188  || op->inv->dam_modifier
1189  || op->inv->range_modifier) {
1190  op->level = level_for_item(op, difficulty);
1191  op->value = op->value*op->inv->value*(op->level+50)/(op->inv->level+50);
1192  } else {
1193  op->level = op->inv->level;
1194  op->value = op->value*op->inv->value;
1195  }
1196  break;
1197 
1198  case ROD:
1199  op->level = level_for_item(op, difficulty);
1200  rod_adjust(op);
1201  break;
1202 
1203  case SCROLL:
1204  if (!op->inv) {
1205  // Somehow generated a scroll without a spell...
1206  LOG(llevWarn, "Generated a scroll without a spell\n");
1207  break;
1208  }
1209  op->level = level_for_item(op, difficulty);
1210  op->value = op->value*op->inv->value*(op->level+50)/(op->inv->level+50);
1211  /* add exp so reading them properly gives xp */
1212  op->stats.exp = op->value/5;
1213  op->nrof = op->inv->nrof;
1214  /* some more fun */
1215  if (!(flags&GT_ONLY_GOOD) && rndm(1, 100) <= 20) {
1216  if (rndm(1, 6) <= 1)
1217  SET_FLAG(op, FLAG_DAMNED);
1218  else
1219  SET_FLAG(op, FLAG_CURSED);
1220  } else if (rndm(1, 100) <= 2) {
1221  SET_FLAG(op, FLAG_BLESSED);
1222  }
1223  break;
1224 
1225  case RUNE:
1226  trap_adjust(op, difficulty);
1227  break;
1228 
1229  case TRAP:
1230  trap_adjust(op, difficulty);
1231  break;
1232  } /* switch type */
1233  }
1234  if (flags&GT_STARTEQUIP) {
1235  if (op->nrof < 2
1236  && op->type != CONTAINER
1237  && op->type != MONEY
1238  && !QUERY_FLAG(op, FLAG_IS_THROWN)) {
1240  SET_FLAG(op, FLAG_INV_LOCKED); // make it harder to accidentally drop
1241  }
1242  else if (op->type != MONEY)
1243  op->value = 0;
1244  }
1245 
1246  if (!(flags&GT_ENVIRONMENT))
1247  fix_flesh_item(op, creator);
1248 }
1249 
1253 static void dump_monster_treasure_rec(const char *name, treasure *t, int depth) {
1254  treasurelist *tl;
1255  int i;
1256 
1257  if (depth > 100)
1258  return;
1259 
1260  while (t != NULL) {
1261  if (t->name != NULL) {
1262  for (i = 0; i < depth; i++)
1263  fprintf(logfile, " ");
1264  fprintf(logfile, "{ (list: %s)\n", t->name);
1265  tl = find_treasurelist(t->name);
1266  dump_monster_treasure_rec(name, tl->items, depth+2);
1267  for (i = 0; i < depth; i++)
1268  fprintf(logfile, " ");
1269  fprintf(logfile, "} (end of list: %s)\n", t->name);
1270  } else {
1271  for (i = 0; i < depth; i++)
1272  fprintf(logfile, " ");
1273  if (t->item->clone.type == FLESH)
1274  fprintf(logfile, "%s's %s\n", name, t->item->clone.name);
1275  else
1276  fprintf(logfile, "%s\n", t->item->clone.name);
1277  }
1278  if (t->next_yes != NULL) {
1279  for (i = 0; i < depth; i++)
1280  fprintf(logfile, " ");
1281  fprintf(logfile, " (if yes)\n");
1282  dump_monster_treasure_rec(name, t->next_yes, depth+1);
1283  }
1284  if (t->next_no != NULL) {
1285  for (i = 0; i < depth; i++)
1286  fprintf(logfile, " ");
1287  fprintf(logfile, " (if no)\n");
1288  dump_monster_treasure_rec(name, t->next_no, depth+1);
1289  }
1290  t = t->next;
1291  }
1292 }
1293 
1298 void dump_monster_treasure(const char *name) {
1299  int found;
1300 
1301  found = 0;
1302  fprintf(logfile, "\n");
1303  getManager()->archetypes()->each([&] (const auto at) {
1304  if (!strcasecmp(at->clone.name, name) && at->clone.title == NULL) {
1305  fprintf(logfile, "treasures for %s (arch: %s)\n", at->clone.name, at->name);
1306  if (at->clone.randomitems != NULL)
1307  dump_monster_treasure_rec(at->clone.name, at->clone.randomitems->items, 1);
1308  else
1309  fprintf(logfile, "(nothing)\n");
1310  fprintf(logfile, "\n");
1311  found++;
1312  }
1313  });
1314 
1315  if (found == 0)
1316  fprintf(logfile, "No objects have the name %s!\n\n", name);
1317 }
1318 
1326 static void fix_flesh_item(object *item, const object *donor) {
1327  char tmpbuf[MAX_BUF];
1328  int i;
1329 
1330  if (item->type == FLESH && donor && QUERY_FLAG(donor, FLAG_MONSTER)) {
1331  /* change the name */
1332  snprintf(tmpbuf, sizeof(tmpbuf), "%s's %s", donor->name, item->name);
1333  FREE_AND_COPY(item->name, tmpbuf);
1334  snprintf(tmpbuf, sizeof(tmpbuf), "%s's %s", donor->name, item->name_pl);
1335  FREE_AND_COPY(item->name_pl, tmpbuf);
1336 
1337  /* store original arch in other_arch */
1338  if (!item->other_arch) {
1339  if (!donor->arch->reference_count) {
1340  item->other_arch = donor->arch;
1341  } else {
1342  /* If dealing with custom monsters, other_arch still needs to
1343  * point back to the original. Otherwise what happens
1344  * is that other_arch points at the custom archetype, but
1345  * that can be freed. Reference count doesn't work because
1346  * the loader will not be able to resolve the other_arch at
1347  * load time (server may has restarted, etc.)
1348  */
1349  archetype *original = find_archetype(donor->arch->name);
1350 
1351  if (original)
1352  item->other_arch = original;
1353  else {
1354  LOG(llevError, "could not find original archetype %s for custom monster!\n", donor->arch->name);
1355  abort();
1356  }
1357  }
1358  }
1359 
1360  /* weight is FLESH weight/100 * donor */
1361  if ((item->weight = (signed long)(((double)item->weight/(double)100.0)*(double)donor->weight)) == 0)
1362  item->weight = 1;
1363 
1364  /* value is multiplied by level of donor */
1365  item->value *= isqrt(donor->level*2);
1366 
1367  /* food value */
1368  item->stats.food += (donor->stats.hp/100)+donor->stats.Con;
1369 
1370  /* flesh items inherit some abilities of donor, but not full effect. */
1371  for (i = 0; i < NROFATTACKS; i++)
1372  item->resist[i] = donor->resist[i]/2;
1373 
1374  /* item inherits donor's level and exp (important for dragons) */
1375  item->level = donor->level;
1376  item->stats.exp = donor->stats.exp;
1377 
1378  /* if donor has some attacktypes, the flesh is poisonous */
1379  if (donor->attacktype&AT_POISON)
1380  item->type = POISON;
1381  if (donor->attacktype&AT_ACID)
1382  item->stats.hp = -1*item->stats.food;
1383  SET_FLAG(item, FLAG_NO_STEAL);
1384 
1385  /* attempt to change the face - will take a face named "donor's arch"_"item's face". We ignore the animation for now */
1386  if (item->face != NULL) {
1387  snprintf(tmpbuf, sizeof(tmpbuf), "%s_%s", donor->arch->name, item->face->name);
1388  item->face = try_find_face(tmpbuf, item->face);
1389  }
1390  }
1391 }
1392 
1401 static int special_potion(object *op) {
1402  int i;
1403 
1404  if (op->attacktype)
1405  return 1;
1406 
1407  if (op->stats.Str
1408  || op->stats.Dex
1409  || op->stats.Con
1410  || op->stats.Pow
1411  || op->stats.Wis
1412  || op->stats.Int
1413  || op->stats.Cha)
1414  return 1;
1415 
1416  for (i = 0; i < NROFATTACKS; i++)
1417  if (op->resist[i])
1418  return 1;
1419 
1420  return 0;
1421 }
1422 
1435  treasure *t = (treasure *)calloc(1, sizeof(treasure));
1436  if (t == NULL)
1438  t->item = NULL;
1439  t->name = NULL;
1440  t->next = NULL;
1441  t->next_yes = NULL;
1442  t->next_no = NULL;
1443  t->chance = 100;
1444  t->magic = 0;
1445  t->nrof = 0;
1446  return t;
1447 }
1448 
1456  if (t->name)
1457  free_string(t->name);
1458  if (t->artifact)
1459  free_string(t->artifact);
1460  if (t->next)
1461  treasure_free(t->next);
1462  if (t->next_yes)
1463  treasure_free(t->next_yes);
1464  if (t->next_no)
1465  treasure_free(t->next_no);
1466  free(t);
1467 }
1468 
1469 
1477  treasure *added = get_empty_treasure();
1478  if (list->items == NULL || position <= 0) {
1479  added->next = list->items;
1480  list->items = added;
1481  return added;
1482  }
1483  treasure *prev = list->items;
1484  position--;
1485  while (position > 0 && prev->next) {
1486  position--;
1487  prev = prev->next;
1488  }
1489  added->next = prev->next;
1490  prev->next = added;
1491  return added;
1492 }
1493 
1500  if (list->items == 0 || position < 0) {
1501  return;
1502  }
1503  if (position == 0) {
1504  treasure *next = list->items->next;
1505  list->items->next = NULL;
1506  treasure_free(list->items);
1507  list->items = next;
1508  return;
1509  }
1510  position--;
1511  treasure *prev = list->items;
1512  while (prev && position > 0) {
1513  position--;
1514  prev = prev->next;
1515  }
1516  if (!prev) {
1517  return;
1518  }
1519  treasure *next = prev->next->next;
1520  prev->next->next = NULL;
1521  treasure_free(prev->next);
1522  prev->next = next;
1523 }
Face::name
sstring name
Face name, as used by archetypes and such.
Definition: face.h:19
object::name_pl
sstring name_pl
The plural name of the object.
Definition: object.h:325
living::exp
int64_t exp
Experience.
Definition: living.h:47
ATNR_PARALYZE
#define ATNR_PARALYZE
Definition: attack.h:59
set_magic
static void set_magic(int difficulty, object *op, int max_magic, int flags)
Sets a random magical bonus in the given object based upon the given difficulty, and the given max po...
Definition: treasure.cpp:704
global.h
settings
struct Settings settings
Global settings.
Definition: init.cpp:139
set_abs_magic
void set_abs_magic(object *op, int magic)
Sets magical bonus in an object, and recalculates the effect on the armour variable,...
Definition: treasure.cpp:656
object::range_modifier
uint8_t range_modifier
How going up in level affects range
Definition: object.h:420
dump_monster_treasure_rec
static void dump_monster_treasure_rec(const char *name, treasure *t, int depth)
For debugging purposes.
Definition: treasure.cpp:1253
AT_ACID
#define AT_ACID
Random equipped item might corrode when hit (64)
Definition: attack.h:84
BRACERS
@ BRACERS
Definition: object.h:222
find_artifact
const artifact * find_artifact(const object *op, const char *name)
Searches and returns a specific artifact compatible with an object, NULL if not found.
Definition: artifact.cpp:585
llevError
@ llevError
Problems requiring server admin to fix.
Definition: logger.h:11
DICE2
#define DICE2
Definition: treasure.cpp:899
FABS
#define FABS(x)
Decstations have trouble with fabs()...
Definition: define.h:22
mapstruct::difficulty
uint16_t difficulty
What level the player should be to play here.
Definition: map.h:337
WAND
@ WAND
Definition: object.h:225
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:82
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:369
Settings::armor_speed_linear
uint8_t armor_speed_linear
If 1, speed improvement is linear, else exponantiel.
Definition: global.h:311
FLESH
@ FLESH
animal 'body parts' -b.t.
Definition: object.h:192
object::inv
object * inv
Pointer to the first object in the inventory.
Definition: object.h:300
ATNR_ACID
#define ATNR_ACID
Definition: attack.h:53
num_resist_table
#define num_resist_table
Number of items in resist_table.
Definition: treasure.cpp:53
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:371
mapstruct::shopmin
uint64_t shopmin
Minimum price a shop will trade for.
Definition: map.h:354
treasurelist::items
treasure * items
Items in this list, linked.
Definition: treasure.h:93
AssetsManager.h
level_for_item
static int level_for_item(const object *op, int difficulty)
Calculate the appropriate level for wands staves and scrolls.
Definition: treasure.cpp:361
object::item_power
int8_t item_power
Power rating of the object.
Definition: object.h:374
object::arch
struct archetype * arch
Pointer to archetype.
Definition: object.h:426
SHOP_FLOOR
@ SHOP_FLOOR
Definition: object.h:188
if
if(!(yy_init))
Definition: loader.cpp:36440
treasurelist::total_chance
int16_t total_chance
If non-zero, only 1 item on this list should be generated.
Definition: treasure.h:88
object::invisible
int16_t invisible
How much longer the object will be invis.
Definition: object.h:372
living::Dex
int8_t Dex
Definition: living.h:36
TRAP
@ TRAP
Definition: object.h:246
object::x
int16_t x
Definition: object.h:337
ARMOUR
@ ARMOUR
Definition: object.h:125
give_artifact_abilities
void give_artifact_abilities(object *op, const object *artifact)
Fixes the given object, giving it the abilities and titles it should have due to the second artifact-...
Definition: artifact.cpp:230
object::map
struct mapstruct * map
Pointer to the map in which this object is present.
Definition: object.h:307
WEAPON
@ WEAPON
Definition: object.h:124
find_treasurelist
treasurelist * find_treasurelist(const char *name)
Search for the given treasurelist by name.
Definition: assets.cpp:253
generate_treasure
object * generate_treasure(treasurelist *t, int difficulty)
Generate a treasure from a list generating a single item.
Definition: treasure.cpp:333
GT_ONLY_GOOD
@ GT_ONLY_GOOD
Don't generate bad/cursed items.
Definition: treasure.h:34
artifact::item
object * item
Special values of the artifact.
Definition: artifact.h:15
SET_ANIMATION
#define SET_ANIMATION(ob, newanim)
Definition: global.h:168
ATNR_SLOW
#define ATNR_SLOW
Definition: attack.h:58
AMULET
@ AMULET
Definition: object.h:144
do_single_item
static bool do_single_item(treasure *t, object *op, int flag, int difficulty)
Creates the item for a treasure.
Definition: treasure.cpp:150
fix_generated_item
void fix_generated_item(object *op, object *creator, int difficulty, int max_magic, int flags)
fix_generated_item(): This is called after an item is generated, in order to set it up right.
Definition: treasure.cpp:941
get_power_from_ench
int get_power_from_ench(int ench)
Definition: item.cpp:213
flags
static const flag_definition flags[]
Flag mapping.
Definition: gridarta-types-convert.cpp:101
MAXMAGIC
#define MAXMAGIC
Maximum magic for difficulty/magic mapping.
Definition: treasure.h:13
llevWarn
@ llevWarn
Warnings or major code issues.
Definition: logger.h:12
RUNE
@ RUNE
Definition: object.h:245
set_materialname
void set_materialname(object *op)
Set the material name and type for an item, if not set.
Definition: utils.cpp:303
MAX_SPELLITEM_LEVEL
#define MAX_SPELLITEM_LEVEL
Highest level of rods/staves/scrolls to generate.
Definition: treasure.h:19
ATNR_DISEASE
#define ATNR_DISEASE
Definition: attack.h:72
FREE_OBJ_FREE_INVENTORY
#define FREE_OBJ_FREE_INVENTORY
Free inventory objects; if not set, drop inventory.
Definition: object.h:545
get_empty_treasure
treasure * get_empty_treasure(void)
Allocate and return the pointer to an empty treasure structure.
Definition: treasure.cpp:1434
rod_adjust
void rod_adjust(object *rod)
Adjusts rod attributes.
Definition: main.cpp:404
ATNR_PHYSICAL
#define ATNR_PHYSICAL
Definition: attack.h:47
ARMOUR_SPEED
#define ARMOUR_SPEED(xyz)
Definition: define.h:451
special_potion
static int special_potion(object *op)
Check if object is a special potion.
Definition: treasure.cpp:1401
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:15
create_all_treasures
static void create_all_treasures(treasure *t, object *op, int flag, int difficulty, int tries)
Creates all the treasures.
Definition: treasure.cpp:207
rndm
int rndm(int min, int max)
Returns a number between min and max.
Definition: utils.cpp:163
ATNR_TURN_UNDEAD
#define ATNR_TURN_UNDEAD
Definition: attack.h:60
object::title
sstring title
Of foo, etc.
Definition: object.h:327
FLAG_CURSED
#define FLAG_CURSED
The object is cursed.
Definition: define.h:303
FLAG_BLESSED
#define FLAG_BLESSED
Item has a blessing, opposite of cursed/damned.
Definition: define.h:356
object::level
int16_t level
Level of creature or object.
Definition: object.h:363
GT_STARTEQUIP
@ GT_STARTEQUIP
Generated items have the FLAG_STARTEQUIP.
Definition: treasure.h:33
getManager
AssetsManager * getManager()
Definition: assets.cpp:309
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
Definition: object.cpp:2856
put_treasure
static void put_treasure(object *op, object *creator, int flags)
Inserts generated treasure where it should go.
Definition: treasure.cpp:82
MAX
#define MAX(x, y)
Definition: compat.h:24
object::resist
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:353
ATNR_CONFUSION
#define ATNR_CONFUSION
Definition: attack.h:52
ATNR_HOLYWORD
#define ATNR_HOLYWORD
Definition: attack.h:68
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
change_treasure
static void change_treasure(treasure *t, object *op)
if there are change_xxx commands in the treasure, we include the changes in the generated object
Definition: treasure.cpp:108
ATNR_BLIND
#define ATNR_BLIND
Definition: attack.h:69
FLAG_ALIVE
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:217
object::y
int16_t y
Position in the map for this object.
Definition: object.h:337
CLOAK
@ CLOAK
Definition: object.h:209
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects,...
Definition: object.cpp:1558
HELMET
@ HELMET
Definition: object.h:141
POISON
@ POISON
Definition: object.h:118
magic_from_difficulty
static int magic_from_difficulty(int difficulty)
This is used when determining the magical bonus created on specific maps.
Definition: treasure.cpp:616
trap_adjust
static void trap_adjust(object *trap, int difficulty)
Adjust trap difficulty to the map.
Definition: treasure.cpp:861
init_archetype_pointers
void init_archetype_pointers(void)
Initialize global archtype pointers:
Definition: treasure.cpp:62
amulet_arch
static archetype * amulet_arch
Definition: treasure.cpp:50
FREE_OBJ_NO_DESTROY_CALLBACK
#define FREE_OBJ_NO_DESTROY_CALLBACK
Do not run the destroy callback.
Definition: object.h:546
POTION
@ POTION
Definition: object.h:116
GT_INVISIBLE
@ GT_INVISIBLE
Unused?
Definition: treasure.h:32
treasurelist
treasurelist represents one logical group of items to be generated together.
Definition: treasure.h:86
archetype::clone
object clone
An object from which to do object_copy()
Definition: object.h:489
FLAG_NO_STEAL
#define FLAG_NO_STEAL
Item can't be stolen.
Definition: define.h:329
price_base
uint64_t price_base(const object *obj)
Price an item based on its value or archetype value, type, identification/BUC status,...
Definition: item.cpp:1505
add_string
sstring add_string(const char *str)
Share a string.
Definition: shstr.cpp:137
treasurelist::name
sstring name
Usually monster-name/combination.
Definition: treasure.h:87
FLAG_MONSTER
#define FLAG_MONSTER
Will attack players.
Definition: define.h:232
ROD
@ ROD
Definition: object.h:114
CONTAINER
@ CONTAINER
Definition: object.h:236
set_attr_value
void set_attr_value(living *stats, int attr, int8_t value)
Sets Str/Dex/con/Wis/Cha/Int/Pow in stats to value, depending on what attr is (STR to POW).
Definition: living.cpp:218
object::face
const Face * face
Face with colors.
Definition: object.h:343
treasure_free
void treasure_free(treasure *t)
Frees a treasure, including its yes, no and next items.
Definition: treasure.cpp:1455
tailor_readable_ob
void tailor_readable_ob(object *book, int msg_type)
The main routine.
Definition: readable.cpp:1896
dice2
static int dice2()
Definition: treasure.cpp:909
object::value
int32_t value
How much money it is worth (or contains)
Definition: object.h:362
Settings::armor_weight_reduction
int armor_weight_reduction
Weight reduction per enchantment.
Definition: global.h:308
isqrt
int isqrt(int n)
Compute the square root.
Definition: utils.cpp:567
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
Definition: global.h:210
object::type
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:350
living::dam
int16_t dam
How much damage this object does when hitting.
Definition: living.h:46
object::magic
int8_t magic
Any magical bonuses to this item.
Definition: object.h:360
t
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn t
Definition: server-directories.txt:27
ATNR_DRAIN
#define ATNR_DRAIN
Definition: attack.h:54
object_free
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects,...
Definition: object.cpp:1590
FLAG_NO_PICK
#define FLAG_NO_PICK
Object can't be picked up.
Definition: define.h:226
living::food
int32_t food
How much food in stomach.
Definition: living.h:48
FLAG_REFL_MISSILE
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:260
archetype
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:485
ATNR_POISON
#define ATNR_POISON
Definition: attack.h:57
sproto.h
resist_table
static int resist_table[]
Resistances which can show up on rings and amulets.
Definition: treasure.cpp:39
logfile
FILE * logfile
Used by server/daemon.c.
Definition: init.cpp:114
ATNR_DEATH
#define ATNR_DEATH
Definition: attack.h:64
living::sp
int16_t sp
Spell points.
Definition: living.h:42
AssetsCollection::each
void each(std::function< void(T *)> op)
Apply a function to each asset.
Definition: AssetsCollection.h:158
FLAG_IS_FLOOR
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
Definition: define.h:289
GET_ANIM_ID
#define GET_ANIM_ID(ob)
Definition: global.h:171
living::Int
int8_t Int
Definition: living.h:36
BOOK
@ BOOK
Definition: object.h:119
GT_ENVIRONMENT
@ GT_ENVIRONMENT
?
Definition: treasure.h:31
RING
@ RING
Definition: object.h:190
INS_NO_WALK_ON
#define INS_NO_WALK_ON
Don't call check_walk_on against the originator.
Definition: object.h:583
set_ring_bonus
static void set_ring_bonus(object *op, int bonus)
Randomly adds one magical ability to the given object.
Definition: treasure.cpp:733
object_insert_in_map_at
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
Definition: object.cpp:2099
object::other_arch
struct archetype * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
Definition: object.h:427
FLAG_INV_LOCKED
#define FLAG_INV_LOCKED
Item will not be dropped from inventory.
Definition: define.h:316
treasure::next
treasure * next
Next treasure-item in a linked list.
Definition: treasure.h:69
fatal
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
Definition: utils.cpp:595
AssetsManager::archetypes
Archetypes * archetypes()
Get archetypes.
Definition: AssetsManager.h:44
treasure.h
MAX_BUF
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
d
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for d
Definition: INSTALL_WIN32.txt:13
object_new
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it.
Definition: object.cpp:1270
treasure_remove_item
void treasure_remove_item(treasurelist *list, int position)
Remove the treasure at the specified position from the list.
Definition: treasure.cpp:1499
create_archetype
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
Definition: arch.cpp:276
object::weight
int32_t weight
Attributes of the object.
Definition: object.h:377
free_string
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.cpp:294
spell_mapping
const char *const spell_mapping[SPELL_MAPPINGS]
This table is only necessary to convert objects that existed before the spell object conversion to th...
Definition: object.cpp:76
living::wc
int8_t wc
Weapon Class, lower WC increases probability of hitting.
Definition: living.h:37
RANDOM
#define RANDOM()
Definition: define.h:628
difftomagic_list
static const int difftomagic_list[DIFFLEVELS][MAXMAGIC+1]
Based upon the specified difficulty and upon the difftomagic_list array, a random magical bonus is re...
Definition: treasure.cpp:403
AT_LEAST_1
static int AT_LEAST_1(int x)
Definition: treasure.cpp:129
ATNR_FIRE
#define ATNR_FIRE
Definition: attack.h:49
FLAG_DAMNED
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:304
is_valid_types_gen.found
found
Definition: is_valid_types_gen.py:39
living::Wis
int8_t Wis
Definition: living.h:36
object::dam_modifier
uint8_t dam_modifier
How going up in level affects damage.
Definition: object.h:421
object::slaying
sstring slaying
Which race to do double damage to.
Definition: object.h:329
object::duration_modifier
uint8_t duration_modifier
how level modifies duration
Definition: object.h:418
object::name
sstring name
The name of the object, obviously...
Definition: object.h:321
INS_ABOVE_FLOOR_ONLY
#define INS_ABOVE_FLOOR_ONLY
Put object immediatly above the floor.
Definition: object.h:582
ATNR_DEPLETE
#define ATNR_DEPLETE
Definition: attack.h:63
FLAG_IS_THROWN
#define FLAG_IS_THROWN
Object is designed to be thrown.
Definition: define.h:236
living::Cha
int8_t Cha
Definition: living.h:36
AT_POISON
#define AT_POISON
Some damage each turn thereafter (1024)
Definition: attack.h:88
find_archetype
archetype * find_archetype(const char *name)
Definition: assets.cpp:270
object::msg
sstring msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:332
archetype::reference_count
int reference_count
How many times this temporary archetype is used.
Definition: object.h:492
ATNR_MAGIC
#define ATNR_MAGIC
Definition: attack.h:48
assets.h
FLAG_STARTEQUIP
#define FLAG_STARTEQUIP
Object was given to player at start.
Definition: define.h:255
CHANCE_FOR_ARTIFACT
#define CHANCE_FOR_ARTIFACT
Chance an item becomes an artifact if not magic is 1 in this value.
Definition: treasure.h:10
living::ac
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
Definition: living.h:38
fix_flesh_item
static void fix_flesh_item(object *item, const object *donor)
Objects of type FLESH are similar to type FOOD, except they inherit properties (name,...
Definition: treasure.cpp:1326
NUM_ANIMATIONS
#define NUM_ANIMATIONS(ob)
Definition: global.h:177
treasure_insert
treasure * treasure_insert(treasurelist *list, int position)
Insert a new treasure in the treasure list, at a specific position in the children list.
Definition: treasure.cpp:1476
dump_monster_treasure
void dump_monster_treasure(const char *name)
For debugging purposes.
Definition: treasure.cpp:1298
INS_NO_MERGE
#define INS_NO_MERGE
Don't try to merge with other items.
Definition: object.h:581
arch_to_object
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
Definition: arch.cpp:227
level
int level
Definition: readable.cpp:1562
DIFFLEVELS
#define DIFFLEVELS
Maximum difficulty for difficulty/magic mapping.
Definition: treasure.h:16
Settings::armor_weight_linear
uint8_t armor_weight_linear
If 1, weight reduction is linear, else exponantiel.
Definition: global.h:309
strcasecmp
int strcasecmp(const char *s1, const char *s2)
loader.h
object::randomitems
struct treasurelist * randomitems
Items to be generated.
Definition: object.h:397
FLAG_OBJ_ORIGINAL
#define FLAG_OBJ_ORIGINAL
NEVER SET THIS.
Definition: define.h:344
object_remove
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to.
Definition: object.cpp:1832
a
Magical Runes Runes are magical inscriptions on the dungeon which cast a spell or detonate when something steps on them Flying objects don t detonate runes Beware ! Runes are invisible most of the time They are only visible occasionally ! There are several runes which are there are some special runes which may only be called with the invoke and people may apply it to read it Maybe useful for mazes ! This rune will not nor is it ordinarily invisible Partial Visibility of they ll be visible only part of the time They have a(your level/2) chance of being visible in any given round
try_find_face
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:290
crown_arch
static archetype * crown_arch
Definition: treasure.cpp:50
ATNR_GHOSTHIT
#define ATNR_GHOSTHIT
Definition: attack.h:56
ATNR_COLD
#define ATNR_COLD
Definition: attack.h:51
AT_DEATH
#define AT_DEATH
Chance of instant death, otherwise nothing (131072) peterm@soda.berkeley.edu.
Definition: attack.h:95
SCROLL
@ SCROLL
Definition: object.h:226
archetype::name
sstring name
More definite name, like "generate_kobold".
Definition: object.h:486
object::nrof
uint32_t nrof
Number of objects.
Definition: object.h:344
chance
bool chance(int a, int b)
Return true with a probability of a/b.
Definition: treasure.cpp:904
living::grace
int16_t grace
Grace.
Definition: living.h:44
object::stats
living stats
Str, Con, Dex, etc.
Definition: object.h:380
treasure
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
list
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o except the maps ! You must download a map package and install them the share folder Its must look like doubleclick on crossfire32 dsw There are projects in your libcross lib and plugin_python You need to compile all Easiest way is to select the plugin_python ReleaseLog as active this will compile all others too Then in Visual C press< F7 > to compile If you don t have an appropriate compiler you can try to get the the VC copies the crossfire32 exe in the crossfire folder and the plugin_python dll in the crossfire share plugins folder we will remove it when we get time for it o Last showing lots of weird write to the Crossfire mailing list
Definition: INSTALL_WIN32.txt:50
artifact
This is one artifact, ie one special item.
Definition: artifact.h:14
get_attr_value
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
Definition: living.cpp:313
calc_item_power
int calc_item_power(const object *op)
This takes an object 'op' and figures out what its item_power rating should be.
Definition: item.cpp:318
bonus
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various what they and how they effect the player s actions Also in this section are the stat modifiers that specific classes professions bring Player and sps the current and maximum the Current and Maximum The Current Sp can go somewhat negative When Sp is negative not all spells can be and a more negative Sp makes spell casting less likey to succeed can affect Damage and how the characters as well as how often the character can attack this affects the prices when buying and selling items if this drops the player will start losing hit points wd Cleric or Dwarf sm Elf wd Fireborn ft Human ra Mage C Monk se Ninja hi Priest C Quetzalcoatl mw Swashbuckler si Thief st Viking ba Warrior or Wizard C Wraith C Class Prof Str Dex Con Wis Cha Int Pow Net Skills Enclosed are codes used for the skills above The ones in and fighting should all be pretty self explanatory For the other a brief description is for a more detailed look at the skills doc file Skill remove use magic items phys no fire cold Fireborns are supposed to be fire spirits They re closely in tune with magic and are powerful and learn magic easily Being fire they are immune to fire and and vulnerable to cold They are vulnerable to ghosthit and drain because being mostly non anything which strikes directly at the spirit hits them harder race attacktype restrictions immunities prot vuln Quetzalcoatl physical no armour fire cold Quetzalcoatl s are now born knowing the spell of burning but because of their negative wisdom bonus
Definition: stats.txt:176
ATNR_ELECTRICITY
#define ATNR_ELECTRICITY
Definition: attack.h:50
SPELL
@ SPELL
Definition: object.h:219
ring_arch
static archetype * ring_arch
Arches for rings, amulets and crowns.
Definition: treasure.cpp:50
living::Pow
int8_t Pow
Definition: living.h:36
SHIELD
@ SHIELD
Definition: object.h:140
object::attacktype
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:354
OUT_OF_MEMORY
@ OUT_OF_MEMORY
Definition: define.h:48
ATNR_LIFE_STEALING
#define ATNR_LIFE_STEALING
Definition: attack.h:71
generate_artifact
void generate_artifact(object *op, int difficulty)
Decides randomly which artifact the object should be turned into.
Definition: artifact.cpp:177
create_one_treasure
static void create_one_treasure(treasurelist *tl, object *op, int flag, int difficulty, int tries)
Creates one treasure from the list.
Definition: treasure.cpp:246
Settings::armor_speed_improvement
int armor_speed_improvement
Speed improvement.
Definition: global.h:310
SPELLBOOK
@ SPELLBOOK
Definition: object.h:208
GT_MINIMAL
@ GT_MINIMAL
Do minimal adjustments, don't make artifacts, and so on.
Definition: treasure.h:36
living::hp
int16_t hp
Hit Points.
Definition: living.h:40
create_treasure
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
Definition: treasure.cpp:301
llevDebug
@ llevDebug
Only for debugging purposes.
Definition: logger.h:15
MONEY
@ MONEY
Definition: object.h:142
FLAG_REFL_SPELL
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
Definition: define.h:262
living::Con
int8_t Con
Definition: living.h:36
legal_artifact_combination
int legal_artifact_combination(const object *op, const artifact *art)
Checks if op can be combined with art.
Definition: artifact.cpp:252
living::Str
int8_t Str
Definition: living.h:36
ATNR_FEAR
#define ATNR_FEAR
Definition: attack.h:61