Crossfire Server  1.75.0
artifact.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 <stdlib.h>
23 #include <string.h>
24 #include <ctype.h>
25 
26 #include "loader.h"
27 
38  artifactlist *tl = new artifactlist();
39  if (tl == NULL)
41  tl->next = NULL;
42  tl->total_chance = 0;
43  return tl;
44 }
45 
56  artifact *t = new artifact();
57  if (t == NULL)
59  t->item = NULL;
60  t->chance = 0;
61  t->difficulty = 0;
62  return t;
63 }
64 
74 static void free_artifact(artifact *at) {
75  object *next;
76 
77  for (auto allowed : at->allowed)
78  free_string(allowed);
79  while (at->item) {
80  next = at->item->next;
81  if (at->item->name)
82  free_string(at->item->name);
83  if (at->item->name_pl)
84  free_string(at->item->name_pl);
85  if (at->item->msg)
86  free_string(at->item->msg);
87  if (at->item->title)
88  free_string(at->item->title);
90  free(at->item);
91  at->item = next;
92  }
93  delete at;
94 }
95 
102 static void free_artifactlist(artifactlist *al) {
103  artifactlist *nextal;
104 
105  for (; al != NULL; al = nextal) {
106  nextal = al->next;
107  for (auto art : al->items) {
108  free_artifact(art);
109  }
110  delete al;
111  }
112 }
113 
117 void free_all_artifacts(void) {
119  first_artifactlist = NULL;
120 }
121 
123 #define ARTIFACT_TRIES 2
124 
133 void artifact_compute_chance_for_item(const object *op, const artifact *art, int *numerator, int *denominator) {
134  (*numerator) = 0;
135  (*denominator) = 1;
136  const artifactlist *list = find_artifactlist(op->type);
137  if (!list || list->total_chance == 0) {
138  return;
139  }
140 
141  int chance_of_invalid_item = 0;
142  for (auto check : list->items) {
143  if (!legal_artifact_combination(op, check)) {
144  chance_of_invalid_item += check->chance;
145  }
146  }
147 
148  /*
149  Let:
150  - 'ac' be the artifact's chance as given in the list (art->chance)
151  - 'ic' the chance to find an illegal artifact in the list (chance_of_invalid_item)
152  - 'tc' the total chance of the list (list->total_chance)
153 
154  The chance of the artifact being generated at the first try is ac/tc
155  The chance of finding an invalid artifact is ic/tc
156  So the chance of generating an item on the second try is (ic/tc) * (ac/tc)
157  The chance of the artifact being generated is thus (ac/tc) + (ic/tc) * (ac/tc)
158 
159  In numerator/denominator notation, this gives ac * (tc + ic) / (tc²)
160  */
161 
162  (*numerator) = art->chance * (list->total_chance + chance_of_invalid_item);
163  (*denominator) = list->total_chance * list->total_chance;
164 }
165 
177 void generate_artifact(object *op, int difficulty) {
178  const artifactlist *al;
179  const artifact *art = NULL;
180  int i;
181 
182  al = find_artifactlist(op->type);
183 
184  if (al == NULL) {
185  return;
186  }
187 
188  for (i = 0; i < ARTIFACT_TRIES; i++) {
189  int roll = RANDOM()%al->total_chance;
190 
191  for (auto r : al->items) {
192  roll -= r->chance;
193  if (roll < 0) {
194  art = r;
195  break;
196  }
197  }
198 
199  if (art == NULL || roll >= 0) {
200  LOG(llevError, "Got null entry and non zero roll in generate_artifact, type %d\n", op->type);
201  return;
202  }
203  if (!strcmp(art->item->name, "NONE"))
204  return;
205  if (FABS(op->magic) < art->item->magic)
206  continue; /* Not magic enough to be this item */
207 
208  /* Map difficulty not high enough */
209  if (difficulty < art->difficulty)
210  continue;
211 
212  if (!legal_artifact_combination(op, art)) {
213 #ifdef TREASURE_VERBOSE
214  LOG(llevDebug, "%s of %s was not a legal combination.\n", op->name, art->item->name);
215 #endif
216  continue;
217  }
218  give_artifact_abilities(op, art->item);
219  return;
220  }
221 }
222 
230 void give_artifact_abilities(object *op, const object *artifact) {
231  char new_name[MAX_BUF];
232 
233  snprintf(new_name, sizeof(new_name), "of %s", artifact->name);
234  if (op->title)
235  free_string(op->title);
236  op->title = add_string(new_name);
237  if (op->artifact)
238  free_string(op->artifact);
239  op->artifact = add_refcount(artifact->name);
240  add_abilities(op, artifact); /* Give out the bonuses */
241 
242  return;
243 }
244 
252 int legal_artifact_combination(const object *op, const artifact *art) {
253  int neg, success = 0;
254  const char *name;
255 
256  if (art->allowed.empty())
257  return 1; /* Ie, "all" */
258  for (auto tmp : art->allowed) {
259 #ifdef TREASURE_VERBOSE
260  LOG(llevDebug, "legal_art: %s\n", tmp->name);
261 #endif
262  if (*tmp == '!') {
263  name = tmp+1;
264  neg = 1;
265  } else {
266  name = tmp;
267  neg = 0;
268  }
269 
270  /* If we match name, then return the opposite of 'neg' */
271  if (op->name && (!strcmp(name, op->name) || (op->arch && !strcmp(name, op->arch->name))))
272  return !neg;
273 
274  /* Set success as true, since if the match was an inverse, it means
275  * everything is allowed except what we match
276  */
277  else if (neg)
278  success = 1;
279  }
280  return success;
281 }
282 
290 static void compute_face_name(char* buf, size_t size, const char* name, const char* suffix)
291 {
292  const char* dot = name + strlen(name) - 1;
293  while (dot > name && (isdigit(*dot) || (*dot == 'x')))
294  {
295  dot--;
296  }
297 
298  if (*dot == '.')
299  {
300  buf[0] = '0';
301  strlcpy(buf, name, dot - name + 1);
302  snprintf(buf + strlen(buf), size - strlen(buf), "_%s%s", suffix, dot);
303  }
304  else
305  {
306  snprintf(buf, size, "%s_%s", name, suffix);
307  }
308 }
309 
310 /* Keys used for artifact stuff, not copied */
311 #define KEY_FACE_SUFFIX "face_suffix"
312 #define KEY_ANIMATION_SUFFIX "animation_suffix"
313 
320 void add_abilities(object *op, const object *change) {
321  int i, tmp;
322  char buf[MAX_BUF];
323  sstring key;
324 
325  if (change->face != NULL && change->face != blank_face) {
326 #ifdef TREASURE_VERBOSE
327  LOG(llevDebug, "FACE: %d\n", change->face->number);
328 #endif
329 
330  object_set_value(op, "identified_face", change->face->name, 1);
331  } else if ((key = object_get_value(change, KEY_FACE_SUFFIX)) != NULL) {
332  const Face* face;
333  compute_face_name(buf, sizeof(buf), op->face->name, key);
334  face = try_find_face(buf, op->face);
335  object_set_value(op, "identified_face", face->name, 1);
336  }
337  if (QUERY_FLAG(change, FLAG_CLIENT_ANIM_RANDOM)) {
338  object_set_value(op, "identified_anim_random", "1", 1);
339  }
340  if (change->anim_speed > 0) {
341  snprintf(buf, sizeof(buf), "%d", change->anim_speed);
342  object_set_value(op, "identified_anim_speed", buf, 1);
343  }
344  if (change->animation != NULL && op->arch != NULL) {
345  /* op->arch can be NULL when called from artifact_msg(). */
346  object_set_value(op, "identified_animation", change->animation->name, 1);
347  } else if (op->animation != NULL && (key = object_get_value(change, KEY_ANIMATION_SUFFIX)) != NULL) {
348  const Animations *anim;
349  snprintf(buf, sizeof(buf), "%s_%s", op->animation->name, key);
350  anim = try_find_animation(buf);
351  if (anim != NULL) {
352  object_set_value(op, "identified_animation", anim->name, 1);
353  }
354  }
355 
368  if (op->arch && is_identified(op))
370 
371  for (i = 0; i < NUM_STATS; i++)
372  change_attr_value(&(op->stats), i, get_attr_value(&(change->stats), i));
373 
374  op->attacktype |= change->attacktype;
375  op->path_attuned |= change->path_attuned;
376  op->path_repelled |= change->path_repelled;
377  op->path_denied |= change->path_denied;
378  op->move_type |= change->move_type;
379  op->stats.luck += change->stats.luck;
380 
381  if (QUERY_FLAG(change, FLAG_CURSED))
382  SET_FLAG(op, FLAG_CURSED);
383  if (QUERY_FLAG(change, FLAG_DAMNED))
384  SET_FLAG(op, FLAG_DAMNED);
385  if ((QUERY_FLAG(change, FLAG_CURSED) || QUERY_FLAG(change, FLAG_DAMNED))
386  && op->magic > 0)
387  set_abs_magic(op, -op->magic);
388 
389  if (QUERY_FLAG(change, FLAG_LIFESAVE))
390  SET_FLAG(op, FLAG_LIFESAVE);
391  if (QUERY_FLAG(change, FLAG_REFL_SPELL))
393  if (QUERY_FLAG(change, FLAG_STEALTH))
394  SET_FLAG(op, FLAG_STEALTH);
395  if (QUERY_FLAG(change, FLAG_XRAYS))
396  SET_FLAG(op, FLAG_XRAYS);
397  if (QUERY_FLAG(change, FLAG_BLIND))
398  SET_FLAG(op, FLAG_BLIND);
399  if (QUERY_FLAG(change, FLAG_CONFUSED))
400  SET_FLAG(op, FLAG_CONFUSED);
401  if (QUERY_FLAG(change, FLAG_SEE_IN_DARK))
403  if (QUERY_FLAG(change, FLAG_REFL_MISSILE))
405  if (QUERY_FLAG(change, FLAG_MAKE_INVIS))
407  if (QUERY_FLAG(change, FLAG_REFLECTING))
409 
410  if (QUERY_FLAG(change, FLAG_STAND_STILL)) {
412  /* so artifacts will join */
413  if (!QUERY_FLAG(op, FLAG_ALIVE))
414  op->speed = 0.0;
416  }
417  op->stats.exp += change->stats.exp; /* Speed modifier */
418  op->stats.wc += change->stats.wc;
419  op->stats.ac += change->stats.ac;
420 
421  if (change->other_arch) {
422  /* Basically, for horns & potions, the other_arch field is the spell
423  * to cast. So convert that to into a spell and put it into
424  * this object.
425  */
426  if (op->type == ROD || op->type == POTION) {
427  object *tmp_obj;
428 
429  /* Remove any spells this object currently has in it */
430  while (op->inv) {
431  tmp_obj = op->inv;
432  object_remove(tmp_obj);
434  }
435  tmp_obj = arch_to_object(change->other_arch);
436  /* This is an artifact, so this function will be called at load time,
437  * thus we don't need to keep the inventory */
438  SET_FLAG(tmp_obj, FLAG_NO_SAVE);
439  object_insert_in_ob(tmp_obj, op);
440  }
441  /* No harm setting this for potions/horns */
442  op->other_arch = change->other_arch;
443  }
444 
445  if (change->stats.hp < 0)
446  op->stats.hp = -change->stats.hp;
447  else
448  op->stats.hp += change->stats.hp;
449  if (change->stats.maxhp < 0)
450  op->stats.maxhp = -change->stats.maxhp;
451  else
452  op->stats.maxhp += change->stats.maxhp;
453  if (change->stats.sp < 0)
454  op->stats.sp = -change->stats.sp;
455  else
456  op->stats.sp += change->stats.sp;
457  if (change->stats.maxsp < 0)
458  op->stats.maxsp = -change->stats.maxsp;
459  else
460  op->stats.maxsp += change->stats.maxsp;
461  if (change->stats.grace < 0)
462  op->stats.grace = -change->stats.grace;
463  else
464  op->stats.grace += change->stats.grace;
465  if (change->stats.maxgrace < 0)
466  op->stats.maxgrace = -change->stats.maxgrace;
467  else
468  op->stats.maxgrace += change->stats.maxgrace;
469  if (change->stats.food < 0)
470  op->stats.food = -(change->stats.food);
471  else
472  op->stats.food += change->stats.food;
473  if (change->level < 0)
474  op->level = -(change->level);
475  else
476  op->level += change->level;
477 
478  op->item_power = change->item_power;
479 
480  for (i = 0; i < NROFATTACKS; i++) {
481  if (change->resist[i]) {
482  op->resist[i] += change->resist[i];
483  }
484  }
485  if (change->stats.dam) {
486  if (change->stats.dam < 0)
487  op->stats.dam = (-change->stats.dam);
488  else if (op->stats.dam) {
489  tmp = (int)(((int)op->stats.dam*(int)change->stats.dam)/10);
490  if (tmp == op->stats.dam) {
491  if (change->stats.dam < 10)
492  op->stats.dam--;
493  else
494  op->stats.dam++;
495  } else
496  op->stats.dam = tmp;
497  }
498  }
499  if (change->weight) {
500  if (change->weight < 0)
501  op->weight = (-change->weight);
502  else
503  op->weight = (op->weight*(change->weight))/100;
504  }
505  if (change->last_sp) {
506  if (change->last_sp < 0)
507  op->last_sp = (-change->last_sp);
508  else
509  op->last_sp = (signed char)(((int)op->last_sp*(int)change->last_sp)/(int)100);
510  }
511  if (change->gen_sp_armour) {
512  if (change->gen_sp_armour < 0)
513  op->gen_sp_armour = (-change->gen_sp_armour);
514  else
515  op->gen_sp_armour = (signed char)(((int)op->gen_sp_armour*((int)change->gen_sp_armour))/(int)100);
516  }
517  op->value *= change->value;
518 
519  if (change->material)
520  op->material = change->material;
521 
522  if (change->materialname) {
523  if (op->materialname)
525  op->materialname = add_refcount(change->materialname);
526  }
527 
528  if (change->slaying) {
529  if (op->slaying)
530  free_string(op->slaying);
531  op->slaying = add_refcount(change->slaying);
532  }
533  if (change->race) {
534  if (op->race)
535  free_string(op->race);
536  op->race = add_refcount(change->race);
537  }
538  if (change->msg)
539  object_set_msg(op, change->msg);
540 
541  if (change->key_values) {
542  const key_value *kv = change->key_values;
543  while (kv) {
544  if (strcmp(kv->key, KEY_FACE_SUFFIX) != 0 && strcmp(kv->key, KEY_ANIMATION_SUFFIX) != 0) {
545  object_set_value(op, kv->key, kv->value, 1);
546  }
547  kv = kv->next;
548  }
549  }
550 
551  if (change->inv) {
552  object *copy;
553 
554  FOR_INV_PREPARE(change, inv) {
555  copy = object_new();
556  object_copy(inv, copy);
557  SET_FLAG(copy, FLAG_NO_SAVE);
558  object_insert_in_ob(copy, op);
559  } FOR_INV_FINISH();
560  }
561 }
562 
571  artifactlist *al;
572 
573  for (al = first_artifactlist; al != NULL; al = al->next)
574  if (al->type == type)
575  return al;
576  return NULL;
577 }
578 
585 const artifact *find_artifact(const object *op, const char *name) {
586  artifactlist *list;
587  sstring sname = find_string(name);
588 
589  if (sname == NULL)
590  return NULL;
591 
592  list = find_artifactlist(op->type);
593  if (list == NULL)
594  return NULL;
595 
596  for (const auto at : list->items) {
597  if (at->item->name == sname && legal_artifact_combination(op, at))
598  return at;
599  }
600 
601  return NULL;
602 }
603 
610 void dump_artifacts(void) {
611  artifactlist *al;
612 
613  fprintf(logfile, "\n");
614  for (al = first_artifactlist; al != NULL; al = al->next) {
615  fprintf(logfile, "Artifact has type %d, total_chance=%d\n", al->type, al->total_chance);
616  for (const auto art : al->items) {
617  fprintf(logfile, "Artifact %-30s Difficulty %3d Chance %5d\n", art->item->name, art->difficulty, art->chance);
618  if (!art->allowed.empty()) {
619  fprintf(logfile, "\tAllowed combinations:");
620  for (auto allowed : art->allowed)
621  fprintf(logfile, "%s,", allowed);
622  fprintf(logfile, "\n");
623  }
624  }
625  }
626  fprintf(logfile, "\n");
627 }
628 
634 uint16_t artifact_get_face(const artifact *art) {
635  if (art->item->face != blank_face && art->item->face != NULL)
636  return art->item->face->number;
637 
638  archetype *arch = get_next_archetype(NULL);
639 
640  if (!art->allowed.empty()) {
641  if (*art->allowed[0] == '!') {
642  while (arch) {
643  if (!arch->head && arch->clone.type == art->item->type) {
644  bool allowed = std::none_of(art->allowed.cbegin(), art->allowed.cend(),
645  [&] (const auto name) { return strcmp(arch->name, name + 1) == 0; });
646  if (allowed && arch->clone.face != NULL) {
647  return arch->clone.face->number;
648  }
649  }
650  arch = get_next_archetype(arch);
651  }
652  return (uint16_t)-1;
653  } else {
654  const archetype *arch = try_find_archetype(art->allowed[0]);
655  if (arch == NULL) {
656  arch = find_archetype_by_object_name(art->allowed[0]);
657  }
658  if (arch != NULL)
659  return arch->clone.face->number;
660  return (uint16_t)-1;
661  }
662  }
663 
664  while (arch != NULL) {
665  if (arch->clone.type == art->item->type && arch->clone.face != NULL)
666  return arch->clone.face->number;
667 
668  arch = get_next_archetype(arch);
669  }
670  return (uint16_t)-1;
671 }
672 
673 void artifact_check(const artifact *art) {
674  if (art->item->nrof != 0 && art->item->nrof != 1)
675  LOG(llevDebug, "Artifact with nonzero nrof: %s\n", art->item->name);
676  if (!art->chance)
677  LOG(llevDebug, "Artifact with no chance: %s\n", art->item->name);
678 }
679 
681  for (auto al = first_artifactlist; al != NULL; al = al->next) {
682  al->total_chance = 0;
683  for (auto art : al->items) {
684  artifact_check(art);
685  al->total_chance += art->chance;
686  }
687  }
688 }
Error, serious thing.
Definition: logger.h:11
void object_free_key_values(object *op)
Zero the key_values on op, decrementing the shared-string refcounts and freeing the links...
Definition: object.cpp:939
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:325
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:305
int8_t item_power
Power rating of the object.
Definition: object.h:372
This represents one animation.
Definition: face.h:25
static void free_artifact(artifact *at)
Totally frees an artifact, its next items, and such.
Definition: artifact.cpp:74
struct archetype * arch
Pointer to archetype.
Definition: object.h:424
FILE * logfile
Used by server/daemon.c.
Definition: init.cpp:114
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
#define FABS(x)
Decstations have trouble with fabs()...
Definition: define.h:22
#define FLAG_STAND_STILL
NPC will not (ever) move.
Definition: define.h:296
#define KEY_FACE_SUFFIX
Definition: artifact.cpp:311
int16_t grace
Grace.
Definition: living.h:44
void object_set_msg(object *op, const char *msg)
Set the message field of an object.
Definition: object.cpp:4796
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:1818
int16_t maxgrace
Maximum grace.
Definition: living.h:45
New face structure - this enforces the notion that data is face by face only - you can not change the...
Definition: face.h:14
Number of statistics.
Definition: living.h:18
sstring slaying
Which race to do double damage to.
Definition: object.h:327
sstring add_string(const char *str)
Share a string.
Definition: shstr.cpp:137
int32_t value
How much money it is worth (or contains)
Definition: object.h:360
int8_t luck
Affects thaco and ac from time to time.
Definition: living.h:39
#define FLAG_BLIND
If set, object cannot see (visually)
Definition: define.h:324
Each object (this also means archetypes!) could have a few of these "dangling" from it; this could al...
Definition: object.h:42
sstring find_string(const char *str)
Searches a string in the shared strings.
Definition: shstr.cpp:250
void generate_artifact(object *op, int difficulty)
Decides randomly which artifact the object should be turned into.
Definition: artifact.cpp:177
#define FLAG_CONFUSED
Will also be unable to cast spells.
Definition: define.h:299
#define FLAG_STEALTH
Will wake monsters with less range.
Definition: define.h:300
static void free_artifactlist(artifactlist *al)
Free specified list and its items.
Definition: artifact.cpp:102
See Rod.
Definition: object.h:114
int8_t magic
Any magical bonuses to this item.
Definition: object.h:358
#define ARTIFACT_TRIES
Give 1 re-roll attempt per artifact.
Definition: artifact.cpp:123
uint16_t material
What materials this object consist of.
Definition: object.h:357
sstring add_refcount(sstring str)
Like add_string(), but the string is already a shared string.
Definition: shstr.cpp:224
object * next
Pointer to the next object in the free/used list.
Definition: object.h:285
void artifact_compute_chance_for_item(const object *op, const artifact *art, int *numerator, int *denominator)
Compute the chance for a specified item to become the specified artifact.
Definition: artifact.cpp:133
artifactlist * find_artifactlist(int type)
Finds the artifact list for a certain item type.
Definition: artifact.cpp:570
artifact * get_empty_artifact(void)
Allocate and return the pointer to an empty artifact structure.
Definition: artifact.cpp:55
uint32_t path_repelled
Paths the object is repelled from.
Definition: object.h:354
#define FLAG_REFLECTING
Object reflects from walls (lightning)
Definition: define.h:249
Global type definitions and header inclusions.
void free_all_artifacts(void)
Free all artifact-related information.
Definition: artifact.cpp:117
uint8_t anim_speed
Ticks between animation-frames.
Definition: object.h:429
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:274
static void compute_face_name(char *buf, size_t size, const char *name, const char *suffix)
Compute the name of a face with a suffix, taking into account names like &#39;.123&#39; or &#39;...
Definition: artifact.cpp:290
int32_t weight
Attributes of the object.
Definition: object.h:375
archetype * head
The main part of a linked object.
Definition: object.h:485
#define KEY_ANIMATION_SUFFIX
Definition: artifact.cpp:312
#define NROFATTACKS
Definition: attack.h:15
const Face * blank_face
Following can just as easily be pointers, but it is easier to keep them like this.
Definition: image.cpp:36
uint16_t total_chance
Sum of chance for are artifacts on this list.
Definition: artifact.h:26
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:290
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.cpp:294
int16_t level
Level of creature or object.
Definition: object.h:361
int16_t sp
Spell points.
Definition: living.h:42
uint16_t artifact_get_face(const artifact *art)
Get a suitable face number for representing an artifact.
Definition: artifact.cpp:634
int legal_artifact_combination(const object *op, const artifact *art)
Checks if op can be combined with art.
Definition: artifact.cpp:252
sstring key
Name of the key.
Definition: object.h:43
void dump_artifacts(void)
For debugging purposes.
Definition: artifact.cpp:610
std::vector< artifact * > items
Artifacts for this type.
Definition: artifact.h:28
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:217
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:351
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
Definition: define.h:262
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:483
sstring materialname
Specific material name.
Definition: object.h:356
sstring name
More definite name, like "generate_kobold".
Definition: object.h:484
Defines for loader.l / loader.c.
float speed
Frequency of object &#39;moves&#39; relative to server tick rate.
Definition: object.h:337
uint8_t difficulty
Minimum map difficulty for the artifact to happen.
Definition: artifact.h:17
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
Definition: arch.cpp:227
#define SET_FLAG(xyz, p)
Definition: define.h:384
int32_t last_sp
As last_heal, but for spell points.
Definition: object.h:368
#define QUERY_FLAG(xyz, p)
Definition: define.h:386
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
artifactlist * next
Next list of artifacts.
Definition: artifact.h:27
#define FLAG_NO_SAVE
If set (through plugins), the object is not saved on maps.
Definition: define.h:231
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
void object_give_identified_properties(object *op)
Ensure op has all its "identified" properties set.
Definition: item.cpp:1365
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
Definition: object.cpp:1545
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
Definition: define.h:700
sstring msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:330
void set_abs_magic(object *op, int magic)
Sets magical bonus in an object, and recalculates the effect on the armour variable, and the effect on speed of armour.
Definition: treasure.cpp:642
void artifact_check(const artifact *art)
Definition: artifact.cpp:673
sstring race
Human, goblin, dragon, etc.
Definition: object.h:326
const Animations * animation
Animation of this item, NULL if not animated.
Definition: object.h:428
artifactlist * first_artifactlist
First artifact.
Definition: init.cpp:109
key_value * key_values
Fields not explictly known by the loader.
Definition: object.h:444
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.cpp:4331
key_value * next
Next key in the list.
Definition: object.h:45
const Face * face
Face with colors.
Definition: object.h:341
This represents all archetypes for one particular object type.
Definition: artifact.h:24
int is_identified(const object *op)
Return true if the item is identified, either because it is of a type that doesn&#39;t ever need identifi...
Definition: item.cpp:1357
See Potion.
Definition: object.h:116
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:266
void artifact_post_load()
Definition: artifact.cpp:680
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it...
Definition: object.cpp:1258
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:288
uint16_t number
This is the image unique identifier.
Definition: face.h:15
int16_t dam
How much damage this object does when hitting.
Definition: living.h:46
uint32_t path_denied
Paths the object is denied access to.
Definition: object.h:355
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
Definition: utils.cpp:590
living stats
Str, Con, Dex, etc.
Definition: object.h:378
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
Definition: porting.cpp:222
void object_copy(const object *src_ob, object *dest_ob)
Copy object first frees everything allocated by the second object, and then copies the contents of th...
Definition: object.cpp:1177
#define FLAG_CURSED
The object is cursed.
Definition: define.h:304
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:425
#define FLAG_ANIMATE
The object looks at archetype for faces.
Definition: define.h:229
sstring name_pl
The plural name of the object.
Definition: object.h:323
#define RANDOM()
Definition: define.h:667
Animations * try_find_animation(const char *name)
Definition: assets.cpp:282
MoveType move_type
Type of movement this object uses.
Definition: object.h:436
sstring name
The name of the object, obviously...
Definition: object.h:319
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
Definition: living.cpp:313
sstring title
Of foo, etc.
Definition: object.h:325
Only for debugging purposes.
Definition: logger.h:13
uint32_t nrof
Number of objects.
Definition: object.h:342
#define CLEAR_FLAG(xyz, p)
Definition: define.h:385
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
void add_abilities(object *op, const object *change)
Apply artifact properties to an object.
Definition: artifact.cpp:320
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
Definition: living.h:38
void change_attr_value(living *stats, int attr, int8_t value)
Like set_attr_value(), but instead the value (which can be negative) is added to the specified stat...
Definition: living.cpp:264
sstring value
Key&#39;s value.
Definition: object.h:44
#define FLAG_LIFESAVE
Saves a players&#39; life once, then destr.
Definition: define.h:293
void object_update_speed(object *op)
Updates the speed of an object.
Definition: object.cpp:1334
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
Definition: object.cpp:4484
object * inv
Pointer to the first object in the inventory.
Definition: object.h:298
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
Definition: define.h:316
sstring name
Name of the animation sequence.
Definition: face.h:26
int8_t gen_sp_armour
Sp regen penalty this object has (was last_heal)
Definition: object.h:373
archetype * find_archetype_by_object_name(const char *name)
This function retrieves an archetype given the name that appears during the game (for example...
Definition: arch.cpp:51
int64_t exp
Experience.
Definition: living.h:47
int16_t maxsp
Max spell points.
Definition: living.h:43
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:352
#define FLAG_CLIENT_ANIM_RANDOM
Client animate this, randomized.
Definition: define.h:228
int32_t food
How much food in stomach.
Definition: living.h:48
StringBuffer * buf
Definition: readable.cpp:1563
int16_t maxhp
Max hit points.
Definition: living.h:41
artifactlist * get_empty_artifactlist(void)
Allocate and return the pointer to an empty artifactlist structure.
Definition: artifact.cpp:37
const char * sstring
Definition: sstring.h:2
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:2842
int8_t wc
Weapon Class, lower WC increases probability of hitting.
Definition: living.h:37
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:260
This is one artifact, ie one special item.
Definition: artifact.h:14
sstring name
Face name, as used by archetypes and such.
Definition: face.h:19
sstring artifact
If set, the item is the artifact with this name and the matching type.
Definition: object.h:322
object clone
An object from which to do object_copy()
Definition: object.h:487
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Definition: define.h:693
object * item
Special values of the artifact.
Definition: artifact.h:15
int16_t hp
Hit Points.
Definition: living.h:40
uint16_t chance
Chance of the artifact to happen.
Definition: artifact.h:16
std::vector< sstring > allowed
List of archetypes the artifact can affect.
Definition: artifact.h:18
uint8_t type
Object type that this list represents.
Definition: artifact.h:25
uint32_t path_attuned
Paths the object is attuned to.
Definition: object.h:353