Crossfire Server, Trunk  R20911
artifact.c
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 <stdlib.h>
23 #include <string.h>
24 #include <ctype.h>
25 
26 #include "loader.h"
27 
40  artifactlist *tl = (artifactlist *)malloc(sizeof(artifactlist));
41  if (tl == NULL)
43  tl->next = NULL;
44  tl->items = NULL;
45  tl->total_chance = 0;
46  return tl;
47 }
48 
59  artifact *t = (artifact *)malloc(sizeof(artifact));
60  if (t == NULL)
62  t->item = NULL;
63  t->next = NULL;
64  t->chance = 0;
65  t->difficulty = 0;
66  t->allowed = NULL;
67  t->allowed_size = 0;
68  return t;
69 }
70 
77 static void free_charlinks(linked_char *lc) {
78  if (lc->next)
79  free_charlinks(lc->next);
80  free(lc);
81 }
82 
95 static void free_artifact(artifact *at) {
96  object *next;
97 
98  if (at->next)
99  free_artifact(at->next);
100  if (at->allowed)
101  free_charlinks(at->allowed);
102  while (at->item) {
103  next = at->item->next;
104  if (at->item->name)
105  free_string(at->item->name);
106  if (at->item->name_pl)
107  free_string(at->item->name_pl);
108  if (at->item->msg)
109  free_string(at->item->msg);
110  if (at->item->title)
111  free_string(at->item->title);
113  free(at->item);
114  at->item = next;
115  }
116  free(at);
117 }
118 
125 static void free_artifactlist(artifactlist *al) {
126  artifactlist *nextal;
127 
128  for (; al != NULL; al = nextal) {
129  nextal = al->next;
130  if (al->items) {
131  free_artifact(al->items);
132  }
133  free(al);
134  }
135 }
136 
140 void free_all_artifacts(void) {
142  first_artifactlist = NULL;
143 }
144 
146 #define ARTIFACT_TRIES 2
147 
155 void generate_artifact(object *op, int difficulty) {
156  const artifactlist *al;
157  const artifact *art;
158  int i;
159 
160  al = find_artifactlist(op->type);
161 
162  if (al == NULL) {
163  return;
164  }
165 
166  for (i = 0; i < ARTIFACT_TRIES; i++) {
167  int roll = RANDOM()%al->total_chance;
168 
169  for (art = al->items; art != NULL; art = art->next) {
170  roll -= art->chance;
171  if (roll < 0)
172  break;
173  }
174 
175  if (art == NULL || roll >= 0) {
176  LOG(llevError, "Got null entry and non zero roll in generate_artifact, type %d\n", op->type);
177  return;
178  }
179  if (!strcmp(art->item->name, "NONE"))
180  return;
181  if (FABS(op->magic) < art->item->magic)
182  continue; /* Not magic enough to be this item */
183 
184  /* Map difficulty not high enough */
185  if (difficulty < art->difficulty)
186  continue;
187 
188  if (!legal_artifact_combination(op, art)) {
189 #ifdef TREASURE_VERBOSE
190  LOG(llevDebug, "%s of %s was not a legal combination.\n", op->name, art->item->name);
191 #endif
192  continue;
193  }
194  give_artifact_abilities(op, art->item);
195  return;
196  }
197 }
198 
203 void give_artifact_abilities(object *op, const object *artifact) {
204  char new_name[MAX_BUF];
205 
206  snprintf(new_name, sizeof(new_name), "of %s", artifact->name);
207  if (op->title)
208  free_string(op->title);
209  op->title = add_string(new_name);
210  if (op->artifact)
211  free_string(op->artifact);
212  op->artifact = add_refcount(artifact->name);
213  add_abilities(op, artifact); /* Give out the bonuses */
214 
215  return;
216 }
217 
221 int legal_artifact_combination(const object *op, const artifact *art) {
222  int neg, success = 0;
223  linked_char *tmp;
224  const char *name;
225 
226  if (art->allowed == (linked_char *)NULL)
227  return 1; /* Ie, "all" */
228  for (tmp = art->allowed; tmp; tmp = tmp->next) {
229 #ifdef TREASURE_VERBOSE
230  LOG(llevDebug, "legal_art: %s\n", tmp->name);
231 #endif
232  if (*tmp->name == '!') {
233  name = tmp->name+1;
234  neg = 1;
235  } else {
236  name = tmp->name;
237  neg = 0;
238  }
239 
240  /* If we match name, then return the opposite of 'neg' */
241  if (!strcmp(name, op->name) || (op->arch && !strcmp(name, op->arch->name)))
242  return !neg;
243 
244  /* Set success as true, since if the match was an inverse, it means
245  * everything is allowed except what we match
246  */
247  else if (neg)
248  success = 1;
249  }
250  return success;
251 }
252 
260 static void compute_face_name(char* buf, size_t size, const char* name, const char* suffix)
261 {
262  const char* dot = name + strlen(name) - 1;
263  while (dot > name && (isdigit(*dot) || (*dot == 'x')))
264  {
265  dot--;
266  }
267 
268  if (*dot == '.')
269  {
270  buf[0] = '0';
271  snprintf(buf, dot - name + 1, "%s", name);
272  snprintf(buf + strlen(buf), size - strlen(buf), "_%s%s", suffix, dot);
273  }
274  else
275  {
276  snprintf(buf, size, "%s_%s", name, suffix);
277  }
278 }
279 
284 void add_abilities(object *op, const object *change) {
285  int i, tmp;
286  char buf[MAX_BUF];
287  sstring key;
288 
289  if (change->face != blank_face) {
290 #ifdef TREASURE_VERBOSE
291  LOG(llevDebug, "FACE: %d\n", change->face->number);
292 #endif
293 
294  object_set_value(op, "identified_face", change->face->name, 1);
295  } else if ((key = object_get_value(change, "face_suffix")) != NULL) {
296  New_Face* face;
297  compute_face_name(buf, sizeof(buf), op->face->name, key);
298  face = &new_faces[find_face(buf, op->face->number)];
299  object_set_value(op, "identified_face", face->name, 1);
300  }
301  if (QUERY_FLAG(change, FLAG_CLIENT_ANIM_RANDOM)) {
302  object_set_value(op, "identified_anim_random", "1", 1);
303  }
304  if (change->anim_speed > 0) {
305  snprintf(buf, sizeof(buf), "%d", change->anim_speed);
306  object_set_value(op, "identified_anim_speed", buf, 1);
307  }
308  if (change->animation_id != 0 && op->arch != NULL) {
309  /* op->arch can be NULL when called from artifact_msg(). */
310  snprintf(buf, sizeof(buf),"%d", change->animation_id);
311  object_set_value(op, "identified_animation", buf, 1);
312  } else if (op->animation_id != 0 && (key = object_get_value(change, "animation_suffix")) != NULL) {
313  snprintf(buf, sizeof(buf), "%s_%s", animations[op->animation_id].name, key);
314  i = try_find_animation(buf);
315  if (i != 0) {
316  snprintf(buf, sizeof(buf),"%d", i);
317  object_set_value(op, "identified_animation", buf, 1);
318  }
319  }
320 
333  if (op->arch && (!need_identify(op) || QUERY_FLAG(change, FLAG_IDENTIFIED) || QUERY_FLAG(op, FLAG_IDENTIFIED)))
335 
336  for (i = 0; i < NUM_STATS; i++)
337  change_attr_value(&(op->stats), i, get_attr_value(&(change->stats), i));
338 
339  op->attacktype |= change->attacktype;
340  op->path_attuned |= change->path_attuned;
341  op->path_repelled |= change->path_repelled;
342  op->path_denied |= change->path_denied;
343  op->move_type |= change->move_type;
344  op->stats.luck += change->stats.luck;
345 
346  if (QUERY_FLAG(change, FLAG_CURSED))
347  SET_FLAG(op, FLAG_CURSED);
348  if (QUERY_FLAG(change, FLAG_DAMNED))
349  SET_FLAG(op, FLAG_DAMNED);
350  if ((QUERY_FLAG(change, FLAG_CURSED) || QUERY_FLAG(change, FLAG_DAMNED))
351  && op->magic > 0)
352  set_abs_magic(op, -op->magic);
353 
354  if (QUERY_FLAG(change, FLAG_LIFESAVE))
355  SET_FLAG(op, FLAG_LIFESAVE);
356  if (QUERY_FLAG(change, FLAG_REFL_SPELL))
358  if (QUERY_FLAG(change, FLAG_STEALTH))
359  SET_FLAG(op, FLAG_STEALTH);
360  if (QUERY_FLAG(change, FLAG_XRAYS))
361  SET_FLAG(op, FLAG_XRAYS);
362  if (QUERY_FLAG(change, FLAG_BLIND))
363  SET_FLAG(op, FLAG_BLIND);
364  if (QUERY_FLAG(change, FLAG_CONFUSED))
365  SET_FLAG(op, FLAG_CONFUSED);
366  if (QUERY_FLAG(change, FLAG_SEE_IN_DARK))
368  if (QUERY_FLAG(change, FLAG_REFL_MISSILE))
370  if (QUERY_FLAG(change, FLAG_MAKE_INVIS))
372 
373  if (QUERY_FLAG(change, FLAG_STAND_STILL)) {
375  /* so artifacts will join */
376  if (!QUERY_FLAG(op, FLAG_ALIVE))
377  op->speed = 0.0;
379  }
380  if (change->nrof)
381  op->nrof = RANDOM()%((int)change->nrof)+1;
382  op->stats.exp += change->stats.exp; /* Speed modifier */
383  op->stats.wc += change->stats.wc;
384  op->stats.ac += change->stats.ac;
385 
386  if (change->other_arch) {
387  /* Basically, for horns & potions, the other_arch field is the spell
388  * to cast. So convert that to into a spell and put it into
389  * this object.
390  */
391  if (op->type == ROD || op->type == POTION) {
392  object *tmp_obj;
393 
394  /* Remove any spells this object currently has in it */
395  while (op->inv) {
396  tmp_obj = op->inv;
397  object_remove(tmp_obj);
399  }
400  tmp_obj = arch_to_object(change->other_arch);
401  /* This is an artifact, so this function will be called at load time,
402  * thus we don't need to keep the inventory */
403  SET_FLAG(tmp_obj, FLAG_NO_SAVE);
404  object_insert_in_ob(tmp_obj, op);
405  }
406  /* No harm setting this for potions/horns */
407  op->other_arch = change->other_arch;
408  }
409 
410  if (change->stats.hp < 0)
411  op->stats.hp = -change->stats.hp;
412  else
413  op->stats.hp += change->stats.hp;
414  if (change->stats.maxhp < 0)
415  op->stats.maxhp = -change->stats.maxhp;
416  else
417  op->stats.maxhp += change->stats.maxhp;
418  if (change->stats.sp < 0)
419  op->stats.sp = -change->stats.sp;
420  else
421  op->stats.sp += change->stats.sp;
422  if (change->stats.maxsp < 0)
423  op->stats.maxsp = -change->stats.maxsp;
424  else
425  op->stats.maxsp += change->stats.maxsp;
426  if (change->stats.food < 0)
427  op->stats.food = -(change->stats.food);
428  else
429  op->stats.food += change->stats.food;
430  if (change->level < 0)
431  op->level = -(change->level);
432  else
433  op->level += change->level;
434 
435  op->item_power = change->item_power;
436 
437  for (i = 0; i < NROFATTACKS; i++) {
438  if (change->resist[i]) {
439  op->resist[i] += change->resist[i];
440  }
441  }
442  if (change->stats.dam) {
443  if (change->stats.dam < 0)
444  op->stats.dam = (-change->stats.dam);
445  else if (op->stats.dam) {
446  tmp = (int)(((int)op->stats.dam*(int)change->stats.dam)/10);
447  if (tmp == op->stats.dam) {
448  if (change->stats.dam < 10)
449  op->stats.dam--;
450  else
451  op->stats.dam++;
452  } else
453  op->stats.dam = tmp;
454  }
455  }
456  if (change->weight) {
457  if (change->weight < 0)
458  op->weight = (-change->weight);
459  else
460  op->weight = (op->weight*(change->weight))/100;
461  }
462  if (change->last_sp) {
463  if (change->last_sp < 0)
464  op->last_sp = (-change->last_sp);
465  else
466  op->last_sp = (signed char)(((int)op->last_sp*(int)change->last_sp)/(int)100);
467  }
468  if (change->gen_sp_armour) {
469  if (change->gen_sp_armour < 0)
470  op->gen_sp_armour = (-change->gen_sp_armour);
471  else
472  op->gen_sp_armour = (signed char)(((int)op->gen_sp_armour*((int)change->gen_sp_armour))/(int)100);
473  }
474  op->value *= change->value;
475 
476  if (change->material)
477  op->material = change->material;
478 
479  if (change->materialname) {
480  if (op->materialname)
482  op->materialname = add_refcount(change->materialname);
483  }
484 
485  if (change->slaying) {
486  if (op->slaying)
487  free_string(op->slaying);
488  op->slaying = add_refcount(change->slaying);
489  }
490  if (change->race) {
491  if (op->race)
492  free_string(op->race);
493  op->race = add_refcount(change->race);
494  }
495  if (change->msg)
496  object_set_msg(op, change->msg);
497 
498  if (change->inv) {
499  object *copy;
500 
501  FOR_INV_PREPARE(change, inv) {
502  copy = object_new();
503  object_copy(inv, copy);
504  object_insert_in_ob(copy, op);
505  } FOR_INV_FINISH();
506  }
507 }
508 
518  artifactlist *al;
519 
520  for (al = first_artifactlist; al != NULL; al = al->next)
521  if (al->type == type)
522  return al;
523  return NULL;
524 }
525 
530 void init_artifacts(void) {
531  static int has_been_inited = 0;
532  FILE *fp;
533  char filename[MAX_BUF], buf[HUGE_BUF], *cp, *next;
534  artifact *art = NULL;
535  linked_char *tmp;
536  int value;
537  artifactlist *al;
538  archetype dummy_archetype;
539 
540  memset(&dummy_archetype, 0, sizeof(archetype));
541 
542  if (has_been_inited)
543  return;
544  else
545  has_been_inited = 1;
546 
547  artifact_init = 1;
548 
549  snprintf(filename, sizeof(filename), "%s/artifacts", settings.datadir);
550  LOG(llevDebug, "Reading artifacts from %s...\n", filename);
551  if ((fp = fopen(filename, "r")) == NULL) {
552  LOG(llevError, "Can't open %s.\n", filename);
553  return;
554  }
555 
556  while (fgets(buf, HUGE_BUF, fp) != NULL) {
557  if (*buf == '#')
558  continue;
559  if ((cp = strchr(buf, '\n')) != NULL)
560  *cp = '\0';
561  cp = buf;
562  while (*cp == ' ') /* Skip blanks */
563  cp++;
564  if (*cp == '\0')
565  continue;
566 
567  if (!strncmp(cp, "Allowed", 7)) {
568  if (art == NULL) {
569  art = get_empty_artifact();
570  nrofartifacts++;
571  }
572 
573  cp = strchr(cp, ' ')+1;
574  while (*(cp+strlen(cp)-1) == ' ')
575  cp[strlen(cp)-1] = '\0';
576 
577  if (!strcmp(cp, "all"))
578  continue;
579 
580  do {
581  while (*cp == ' ')
582  cp++;
583  nrofallowedstr++;
584  if ((next = strchr(cp, ',')) != NULL)
585  *(next++) = '\0';
586  tmp = (linked_char *)malloc(sizeof(linked_char));
587  tmp->name = add_string(cp);
588  tmp->next = art->allowed;
589  art->allowed = tmp;
590  art->allowed_size++;
591  } while ((cp = next) != NULL);
592  } else if (sscanf(cp, "chance %d", &value))
593  art->chance = (uint16_t)value;
594  else if (sscanf(cp, "difficulty %d", &value))
595  art->difficulty = (uint8_t)value;
596  else if (!strncmp(cp, "Object", 6)) {
597  art->item = (object *)calloc(1, sizeof(object));
598  if (art->item == NULL) {
599  LOG(llevError, "init_artifacts: memory allocation failure.\n");
600  abort();
601  }
602  object_reset(art->item);
603  art->item->arch = &dummy_archetype;
604  if (!load_object(fp, art->item, LO_LINEMODE, MAP_STYLE))
605  LOG(llevError, "Init_Artifacts: Could not load object.\n");
606  art->item->arch = NULL;
607  art->item->name = add_string((strchr(cp, ' ')+1));
609  if (al == NULL) {
610  al = get_empty_artifactlist();
611  al->type = art->item->type;
612  al->next = first_artifactlist;
613  first_artifactlist = al;
614  }
615  art->next = al->items;
616  al->items = art;
617  art = NULL;
618  } else
619  LOG(llevError, "Unknown input in artifact file: %s\n", buf);
620  }
621 
622  fclose(fp);
623 
624  for (al = first_artifactlist; al != NULL; al = al->next) {
625  for (art = al->items; art != NULL; art = art->next) {
626  if (!art->chance)
627  LOG(llevError, "Warning: artifact with no chance: %s\n", art->item->name);
628  else
629  al->total_chance += art->chance;
630  }
631 #if 0
632  LOG(llevDebug, "Artifact list type %d has %d total chance\n", al->type, al->total_chance);
633 #endif
634  }
635 
636  LOG(llevDebug, "done artifacts.\n");
637  artifact_init = 0;
638 }
639 
647 const artifactlist *find_artifactlist(int type) {
648  return find_artifactlist_internal(type);
649 }
650 
657 const artifact *find_artifact(const object *op, const char *name) {
658  artifactlist *list;
659  artifact *at;
660  sstring sname = find_string(name);
661 
662  if (sname == NULL)
663  return NULL;
664 
665  list = find_artifactlist_internal(op->type);
666  if (list == NULL)
667  return NULL;
668 
669  for (at = list->items; at != NULL; at = at->next) {
670  if (at->item->name == sname && legal_artifact_combination(op, at))
671  return at;
672  }
673 
674  return NULL;
675 }
676 
683 void dump_artifacts(void) {
684  artifactlist *al;
685  artifact *art;
686  linked_char *next;
687 
688  fprintf(logfile, "\n");
689  for (al = first_artifactlist; al != NULL; al = al->next) {
690  fprintf(logfile, "Artifact has type %d, total_chance=%d\n", al->type, al->total_chance);
691  for (art = al->items; art != NULL; art = art->next) {
692  fprintf(logfile, "Artifact %-30s Difficulty %3d Chance %5d\n", art->item->name, art->difficulty, art->chance);
693  if (art->allowed != NULL) {
694  fprintf(logfile, "\tAllowed combinations:");
695  for (next = art->allowed; next != NULL; next = next->next)
696  fprintf(logfile, "%s,", next->name);
697  fprintf(logfile, "\n");
698  }
699  }
700  }
701  fprintf(logfile, "\n");
702 }
703 
709 unsigned artifact_get_face(const artifact *art) {
710  const archetype *arch = first_archetype;
711 
712  if (art->item->face != blank_face && art->item->face != NULL)
713  return art->item->face->number;
714 
715  if (art->allowed_size > 0) {
716  if (art->allowed->name[0] == '!') {
717  linked_char *allowed;
718  while (arch) {
719  if (arch->clone.type != art->item->type)
720  arch = arch->next;
721 
722  for (allowed = art->allowed; allowed != NULL; allowed = allowed->next) {
723  if (strcmp(arch->name, allowed->name + 1) == 0) {
724  break;
725  }
726  }
727  if (allowed != NULL)
728  continue;
729 
730  if (arch->clone.face == NULL)
731  continue;
732  return arch->clone.face->number;
733  }
734  return (unsigned)-1;
735  } else {
736  const archetype *arch = find_archetype(art->allowed->name);
737  if (arch != NULL)
738  return arch->clone.face->number;
739  return (unsigned)-1;
740  }
741  }
742 
743  while (arch != NULL) {
744  if (arch->clone.type == art->item->type && arch->clone.face != NULL)
745  return arch->clone.face->number;
746 
747  arch = arch->next;
748  }
749  return (unsigned)-1;
750 }
EXTERN FILE * logfile
Definition: global.h:142
static artifactlist * find_artifactlist_internal(int type)
Definition: artifact.c:517
#define FLAG_SEE_IN_DARK
Definition: define.h:338
archetype * find_archetype(const char *name)
Definition: arch.c:692
#define FLAG_DAMNED
Definition: define.h:318
int8_t ac
Definition: living.h:37
#define MAP_STYLE
Definition: map.h:98
MoveType move_type
Definition: object.h:424
#define LO_LINEMODE
Definition: loader.h:16
const char * race
Definition: object.h:318
void object_give_identified_properties(object *op)
Definition: item.c:1376
#define SET_FLAG(xyz, p)
Definition: define.h:223
sstring add_refcount(sstring str)
Definition: shstr.c:210
const artifactlist * find_artifactlist(int type)
Definition: artifact.c:647
#define FABS(x)
Definition: define.h:22
unsigned artifact_get_face(const artifact *art)
Definition: artifact.c:709
unsigned char uint8_t
Definition: win32.h:161
New_Face * new_faces
Definition: image.c:33
uint16_t animation_id
Definition: object.h:416
uint16_t material
Definition: object.h:347
const char * name
Definition: face.h:27
uint8_t anim_speed
Definition: object.h:417
sstring artifact
Definition: object.h:314
#define FLAG_STAND_STILL
Definition: define.h:309
void fatal(enum fatal_error err)
Definition: utils.c:597
struct artifactstruct * items
Definition: artifact.h:30
void free_string(sstring str)
Definition: shstr.c:280
#define HUGE_BUF
Definition: define.h:37
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4249
object clone
Definition: object.h:470
const char * slaying
Definition: object.h:319
#define FLAG_CONFUSED
Definition: define.h:312
int32_t last_sp
Definition: object.h:358
#define FLAG_STEALTH
Definition: define.h:313
Definition: object.h:109
int64_t exp
Definition: living.h:46
int8_t get_attr_value(const living *stats, int attr)
Definition: living.c:313
uint32_t path_attuned
Definition: object.h:343
int16_t sp
Definition: living.h:41
static void free_artifactlist(artifactlist *al)
Definition: artifact.c:125
uint32_t path_repelled
Definition: object.h:344
struct archt * other_arch
Definition: object.h:413
Definition: object.h:465
int16_t maxsp
Definition: living.h:42
int16_t hp
Definition: living.h:39
uint16_t number
Definition: face.h:15
int object_set_value(object *op, const char *key, const char *value, int add_key)
Definition: object.c:4378
void object_free_drop_inventory(object *ob)
Definition: object.c:1368
const char * name
Definition: face.h:20
const char * title
Definition: object.h:317
static artifactlist * get_empty_artifactlist(void)
Definition: artifact.c:39
int16_t maxhp
Definition: living.h:40
sstring find_string(const char *str)
Definition: shstr.c:236
#define FLAG_CLIENT_ANIM_RANDOM
Definition: define.h:241
uint32_t path_denied
Definition: object.h:345
uint16_t total_chance
Definition: artifact.h:28
#define FLAG_ALIVE
Definition: define.h:230
#define FLAG_REFL_SPELL
Definition: define.h:275
int legal_artifact_combination(const object *op, const artifact *art)
Definition: artifact.c:221
struct artifactliststruct * next
Definition: artifact.h:29
object * object_new(void)
Definition: object.c:1037
const char * name_pl
Definition: object.h:315
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2690
const char * materialname
Definition: object.h:346
int32_t weight
Definition: object.h:365
#define snprintf
Definition: win32.h:46
void dump_artifacts(void)
Definition: artifact.c:683
#define FLAG_NO_SAVE
Definition: define.h:244
uint8_t difficulty
Definition: artifact.h:17
const artifact * find_artifact(const object *op, const char *name)
Definition: artifact.c:657
struct linked_char * next
Definition: global.h:88
#define FLAG_IDENTIFIED
Definition: define.h:261
#define FOR_INV_FINISH()
Definition: define.h:712
int16_t dam
Definition: living.h:45
void change_attr_value(living *stats, int attr, int8_t value)
Definition: living.c:264
const char * name
Definition: object.h:311
linked_char * allowed
Definition: artifact.h:19
int8_t gen_sp_armour
Definition: object.h:363
void object_reset(object *op)
Definition: object.c:704
uint32_t nrof
Definition: object.h:333
EXTERN Animations * animations
Definition: global.h:163
Definition: object.h:111
int8_t item_power
Definition: object.h:362
int try_find_animation(const char *name)
Definition: anim.c:185
#define FLAG_XRAYS
Definition: define.h:301
int8_t luck
Definition: living.h:38
float speed
Definition: object.h:328
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
EXTERN artifactlist * first_artifactlist
Definition: global.h:121
#define ARTIFACT_TRIES
Definition: artifact.c:146
#define MAX_BUF
Definition: define.h:35
void generate_artifact(object *op, int difficulty)
Definition: artifact.c:155
void give_artifact_abilities(object *op, const object *artifact)
Definition: artifact.c:203
int8_t wc
Definition: living.h:36
unsigned short uint16_t
Definition: win32.h:163
void free_all_artifacts(void)
Definition: artifact.c:140
struct obj * next
Definition: object.h:277
int16_t resist[NROFATTACKS]
Definition: object.h:341
EXTERN long nrofartifacts
Definition: global.h:146
const char * sstring
Definition: global.h:40
int need_identify(const object *op)
Definition: item.c:1332
#define FLAG_CURSED
Definition: define.h:317
const char * datadir
Definition: global.h:242
EXTERN long nrofallowedstr
Definition: global.h:147
#define FLAG_ANIMATE
Definition: define.h:242
static void free_artifact(artifact *at)
Definition: artifact.c:95
const char * name
Definition: global.h:87
static void free_charlinks(linked_char *lc)
Definition: artifact.c:77
uint32_t attacktype
Definition: object.h:342
#define FLAG_BLIND
Definition: define.h:337
#define RANDOM()
Definition: define.h:679
New_Face * blank_face
Definition: image.c:39
living stats
Definition: object.h:368
int load_object(FILE *fp, object *op, int bufstate, int map_flags)
struct archt * arch
Definition: object.h:412
int allowed_size
Definition: artifact.h:20
static void compute_face_name(char *buf, size_t size, const char *name, const char *suffix)
Definition: artifact.c:260
uint8_t type
Definition: object.h:338
struct Settings settings
Definition: init.c:40
static artifact * get_empty_artifact(void)
Definition: artifact.c:58
struct archt * next
Definition: object.h:467
#define NROFATTACKS
Definition: attack.h:17
#define FLAG_LIFESAVE
Definition: define.h:306
void add_abilities(object *op, const object *change)
Definition: artifact.c:284
const char * msg
Definition: object.h:322
#define FLAG_MAKE_INVIS
Definition: define.h:329
sstring add_string(const char *str)
Definition: shstr.c:124
int artifact_init
Definition: artifact.c:28
void object_copy(const object *src_ob, object *dest_ob)
Definition: object.c:838
struct obj * inv
Definition: object.h:290
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
void set_abs_magic(object *op, int magic)
Definition: treasure.c:836
void object_set_msg(object *op, const char *msg)
Definition: object.c:4698
object * item
Definition: artifact.h:15
uint16_t chance
Definition: artifact.h:16
const New_Face * face
Definition: object.h:332
#define FLAG_REFL_MISSILE
Definition: define.h:273
void object_free_key_values(object *op)
Definition: object.c:727
int16_t level
Definition: object.h:351
unsigned find_face(const char *name, unsigned error)
Definition: image.c:303
EXTERN archetype * first_archetype
Definition: global.h:122
object * arch_to_object(archetype *at)
Definition: arch.c:569
void object_update_speed(object *op)
Definition: object.c:1129
int32_t value
Definition: object.h:350
int8_t magic
Definition: object.h:348
const char * name
Definition: object.h:466
void init_artifacts(void)
Definition: artifact.c:530
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:705
void object_remove(object *op)
Definition: object.c:1654
struct artifactstruct * next
Definition: artifact.h:18
int32_t food
Definition: living.h:47