Crossfire Server, Trunk  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) || QUERY_FLAG(change, FLAG_IDENTIFIED)))
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  if (change->nrof != 0 && change->nrof != 1) {
418  LOG(llevDebug, "archetype %s has nrof set to %d, which will be ignored\n",
419  change->name, change->nrof);
420  }
421  op->stats.exp += change->stats.exp; /* Speed modifier */
422  op->stats.wc += change->stats.wc;
423  op->stats.ac += change->stats.ac;
424 
425  if (change->other_arch) {
426  /* Basically, for horns & potions, the other_arch field is the spell
427  * to cast. So convert that to into a spell and put it into
428  * this object.
429  */
430  if (op->type == ROD || op->type == POTION) {
431  object *tmp_obj;
432 
433  /* Remove any spells this object currently has in it */
434  while (op->inv) {
435  tmp_obj = op->inv;
436  object_remove(tmp_obj);
438  }
439  tmp_obj = arch_to_object(change->other_arch);
440  /* This is an artifact, so this function will be called at load time,
441  * thus we don't need to keep the inventory */
442  SET_FLAG(tmp_obj, FLAG_NO_SAVE);
443  object_insert_in_ob(tmp_obj, op);
444  }
445  /* No harm setting this for potions/horns */
446  op->other_arch = change->other_arch;
447  }
448 
449  if (change->stats.hp < 0)
450  op->stats.hp = -change->stats.hp;
451  else
452  op->stats.hp += change->stats.hp;
453  if (change->stats.maxhp < 0)
454  op->stats.maxhp = -change->stats.maxhp;
455  else
456  op->stats.maxhp += change->stats.maxhp;
457  if (change->stats.sp < 0)
458  op->stats.sp = -change->stats.sp;
459  else
460  op->stats.sp += change->stats.sp;
461  if (change->stats.maxsp < 0)
462  op->stats.maxsp = -change->stats.maxsp;
463  else
464  op->stats.maxsp += change->stats.maxsp;
465  if (change->stats.grace < 0)
466  op->stats.grace = -change->stats.grace;
467  else
468  op->stats.grace += change->stats.grace;
469  if (change->stats.maxgrace < 0)
470  op->stats.maxgrace = -change->stats.maxgrace;
471  else
472  op->stats.maxgrace += change->stats.maxgrace;
473  if (change->stats.food < 0)
474  op->stats.food = -(change->stats.food);
475  else
476  op->stats.food += change->stats.food;
477  if (change->level < 0)
478  op->level = -(change->level);
479  else
480  op->level += change->level;
481 
482  op->item_power = change->item_power;
483 
484  for (i = 0; i < NROFATTACKS; i++) {
485  if (change->resist[i]) {
486  op->resist[i] += change->resist[i];
487  }
488  }
489  if (change->stats.dam) {
490  if (change->stats.dam < 0)
491  op->stats.dam = (-change->stats.dam);
492  else if (op->stats.dam) {
493  tmp = (int)(((int)op->stats.dam*(int)change->stats.dam)/10);
494  if (tmp == op->stats.dam) {
495  if (change->stats.dam < 10)
496  op->stats.dam--;
497  else
498  op->stats.dam++;
499  } else
500  op->stats.dam = tmp;
501  }
502  }
503  if (change->weight) {
504  if (change->weight < 0)
505  op->weight = (-change->weight);
506  else
507  op->weight = (op->weight*(change->weight))/100;
508  }
509  if (change->last_sp) {
510  if (change->last_sp < 0)
511  op->last_sp = (-change->last_sp);
512  else
513  op->last_sp = (signed char)(((int)op->last_sp*(int)change->last_sp)/(int)100);
514  }
515  if (change->gen_sp_armour) {
516  if (change->gen_sp_armour < 0)
517  op->gen_sp_armour = (-change->gen_sp_armour);
518  else
519  op->gen_sp_armour = (signed char)(((int)op->gen_sp_armour*((int)change->gen_sp_armour))/(int)100);
520  }
521  op->value *= change->value;
522 
523  if (change->material)
524  op->material = change->material;
525 
526  if (change->materialname) {
527  if (op->materialname)
529  op->materialname = add_refcount(change->materialname);
530  }
531 
532  if (change->slaying) {
533  if (op->slaying)
534  free_string(op->slaying);
535  op->slaying = add_refcount(change->slaying);
536  }
537  if (change->race) {
538  if (op->race)
539  free_string(op->race);
540  op->race = add_refcount(change->race);
541  }
542  if (change->msg)
543  object_set_msg(op, change->msg);
544 
545  if (change->key_values) {
546  const key_value *kv = change->key_values;
547  while (kv) {
548  if (strcmp(kv->key, KEY_FACE_SUFFIX) != 0 && strcmp(kv->key, KEY_ANIMATION_SUFFIX) != 0) {
549  object_set_value(op, kv->key, kv->value, 1);
550  }
551  kv = kv->next;
552  }
553  }
554 
555  if (change->inv) {
556  object *copy;
557 
558  FOR_INV_PREPARE(change, inv) {
559  copy = object_new();
560  object_copy(inv, copy);
561  SET_FLAG(copy, FLAG_NO_SAVE);
562  object_insert_in_ob(copy, op);
563  } FOR_INV_FINISH();
564  }
565 }
566 
575  artifactlist *al;
576 
577  for (al = first_artifactlist; al != NULL; al = al->next)
578  if (al->type == type)
579  return al;
580  return NULL;
581 }
582 
589 const artifact *find_artifact(const object *op, const char *name) {
591  sstring sname = find_string(name);
592 
593  if (sname == NULL)
594  return NULL;
595 
596  list = find_artifactlist(op->type);
597  if (list == NULL)
598  return NULL;
599 
600  for (const auto at : list->items) {
601  if (at->item->name == sname && legal_artifact_combination(op, at))
602  return at;
603  }
604 
605  return NULL;
606 }
607 
614 void dump_artifacts(void) {
615  artifactlist *al;
616 
617  fprintf(logfile, "\n");
618  for (al = first_artifactlist; al != NULL; al = al->next) {
619  fprintf(logfile, "Artifact has type %d, total_chance=%d\n", al->type, al->total_chance);
620  for (const auto art : al->items) {
621  fprintf(logfile, "Artifact %-30s Difficulty %3d Chance %5d\n", art->item->name, art->difficulty, art->chance);
622  if (!art->allowed.empty()) {
623  fprintf(logfile, "\tAllowed combinations:");
624  for (auto allowed : art->allowed)
625  fprintf(logfile, "%s,", allowed);
626  fprintf(logfile, "\n");
627  }
628  }
629  }
630  fprintf(logfile, "\n");
631 }
632 
638 uint16_t artifact_get_face(const artifact *art) {
639  if (art->item->face != blank_face && art->item->face != NULL)
640  return art->item->face->number;
641 
642  archetype *arch = get_next_archetype(NULL);
643 
644  if (!art->allowed.empty()) {
645  if (*art->allowed[0] == '!') {
646  while (arch) {
647  if (!arch->head && arch->clone.type == art->item->type) {
648  bool allowed = std::none_of(art->allowed.cbegin(), art->allowed.cend(),
649  [&] (const auto name) { return strcmp(arch->name, name + 1) == 0; });
650  if (allowed && arch->clone.face != NULL) {
651  return arch->clone.face->number;
652  }
653  }
654  arch = get_next_archetype(arch);
655  }
656  return (uint16_t)-1;
657  } else {
658  const archetype *arch = try_find_archetype(art->allowed[0]);
659  if (arch == NULL) {
660  arch = find_archetype_by_object_name(art->allowed[0]);
661  }
662  if (arch != NULL)
663  return arch->clone.face->number;
664  return (uint16_t)-1;
665  }
666  }
667 
668  while (arch != NULL) {
669  if (arch->clone.type == art->item->type && arch->clone.face != NULL)
670  return arch->clone.face->number;
671 
672  arch = get_next_archetype(arch);
673  }
674  return (uint16_t)-1;
675 }
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:323
Face
New face structure - this enforces the notion that data is face by face only - you can not change the...
Definition: face.h:14
living::exp
int64_t exp
Experience.
Definition: living.h:47
global.h
compute_face_name
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 '.123' or '....
Definition: artifact.cpp:290
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:618
living::maxhp
int16_t maxhp
Max hit points.
Definition: living.h:41
FLAG_STAND_STILL
#define FLAG_STAND_STILL
NPC will not (ever) move.
Definition: define.h:308
FLAG_CONFUSED
#define FLAG_CONFUSED
Will also be unable to cast spells.
Definition: define.h:311
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:589
llevError
@ llevError
Error, serious thing.
Definition: logger.h:11
FABS
#define FABS(x)
Decstations have trouble with fabs()...
Definition: define.h:22
FLAG_CLIENT_ANIM_RANDOM
#define FLAG_CLIENT_ANIM_RANDOM
Client animate this, randomized.
Definition: define.h:241
object::path_attuned
uint32_t path_attuned
Paths the object is attuned to.
Definition: object.h:353
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
object::inv
object * inv
Pointer to the first object in the inventory.
Definition: object.h:298
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
FLAG_REFL_MISSILE
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:273
get_next_archetype
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:261
FLAG_SEE_IN_DARK
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:337
object::item_power
int8_t item_power
Power rating of the object.
Definition: object.h:372
object::arch
struct archetype * arch
Pointer to archetype.
Definition: object.h:424
object::speed
float speed
Frequency of object 'moves' relative to server tick rate.
Definition: object.h:337
artifactlist::items
std::vector< artifact * > items
Artifacts for this type.
Definition: artifact.h:28
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
key_value
Each object (this also means archetypes!) could have a few of these "dangling" from it; this could al...
Definition: object.h:42
free_artifact
static void free_artifact(artifact *at)
Totally frees an artifact, its next items, and such.
Definition: artifact.cpp:74
get_empty_artifactlist
artifactlist * get_empty_artifactlist(void)
Allocate and return the pointer to an empty artifactlist structure.
Definition: artifact.cpp:37
artifact::item
object * item
Special values of the artifact.
Definition: artifact.h:15
add_abilities
void add_abilities(object *op, const object *change)
Apply artifact properties to an object.
Definition: artifact.cpp:320
archetype::head
archetype * head
The main part of a linked object.
Definition: object.h:485
object_copy
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:1192
artifactlist::next
artifactlist * next
Next list of artifacts.
Definition: artifact.h:27
artifact::allowed
std::vector< sstring > allowed
List of archetypes the artifact can affect.
Definition: artifact.h:18
blank_face
const Face * blank_face
Following can just as easily be pointers, but it is easier to keep them like this.
Definition: image.cpp:36
object::key_values
key_value * key_values
Fields not explictly known by the loader.
Definition: object.h:444
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
object::title
sstring title
Of foo, etc.
Definition: object.h:325
object_get_value
const char * object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.cpp:4346
object::level
int16_t level
Level of creature or object.
Definition: object.h:361
FLAG_STEALTH
#define FLAG_STEALTH
Will wake monsters with less range.
Definition: define.h:312
buf
StringBuffer * buf
Definition: readable.cpp:1565
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:2857
object::resist
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:351
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
FLAG_ALIVE
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:230
object::path_denied
uint32_t path_denied
Paths the object is denied access to.
Definition: object.h:355
key_value::value
const char * value
Key's value.
Definition: object.h:44
object::path_repelled
uint32_t path_repelled
Paths the object is repelled from.
Definition: object.h:354
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:1560
add_refcount
sstring add_refcount(sstring str)
This will increase the refcount of the string str.
Definition: shstr.cpp:210
key_value::next
key_value * next
Next key in the list.
Definition: object.h:45
object::anim_speed
uint8_t anim_speed
Ticks between animation-frames.
Definition: object.h:429
POTION
@ POTION
Definition: object.h:116
Face::number
uint16_t number
This is the image unique identifier.
Definition: face.h:15
free_all_artifacts
void free_all_artifacts(void)
Free all artifact-related information.
Definition: artifact.cpp:117
KEY_FACE_SUFFIX
#define KEY_FACE_SUFFIX
Definition: artifact.cpp:311
archetype::clone
object clone
An object from which to do object_copy()
Definition: object.h:487
add_string
sstring add_string(const char *str)
This will add 'str' to the hash table.
Definition: shstr.cpp:124
treasurelist::name
sstring name
Usually monster-name/combination.
Definition: treasure.h:86
ROD
@ ROD
Definition: object.h:114
object::move_type
MoveType move_type
Type of movement this object uses.
Definition: object.h:436
FLAG_BLIND
#define FLAG_BLIND
If set, object cannot see (visually)
Definition: define.h:336
object::face
const Face * face
Face with colors.
Definition: object.h:341
find_string
sstring find_string(const char *str)
Searches a string in the shared strings.
Definition: shstr.cpp:236
FLAG_MAKE_INVIS
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
Definition: define.h:328
object::value
int32_t value
How much money it is worth (or contains)
Definition: object.h:360
is_identified
int is_identified(const object *op)
Return true if the item is identified, either because it is of a type that doesn't ever need identifi...
Definition: item.cpp:1353
object_update_speed
void object_update_speed(object *op)
Updates the speed of an object.
Definition: object.cpp:1349
object::type
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
FLAG_DAMNED
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:317
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:358
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:28
object::materialname
sstring materialname
Specific material name.
Definition: object.h:356
artifactlist
This represents all archetypes for one particular object type.
Definition: artifact.h:24
FOR_INV_FINISH
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
Definition: define.h:671
living::food
int32_t food
How much food in stomach.
Definition: living.h:48
KEY_ANIMATION_SUFFIX
#define KEY_ANIMATION_SUFFIX
Definition: artifact.cpp:312
archetype
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:483
FLAG_NO_SAVE
#define FLAG_NO_SAVE
If set (through plugins), the object is not saved on maps.
Definition: define.h:244
logfile
FILE * logfile
Used by server/daemon.c.
Definition: init.cpp:114
living::sp
int16_t sp
Spell points.
Definition: living.h:42
object::race
sstring race
Human, goblin, dragon, etc.
Definition: object.h:326
object::animation
const Animations * animation
Animation of this item, NULL if not animated.
Definition: object.h:428
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:425
artifact
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn though Notes on Specific and settings file datadir Usually usr share crossfire Contains data that the server does not need to modify while such as the etc A default install will pack the artifact
Definition: server-directories.txt:47
artifact_compute_chance_for_item
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
fatal
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
Definition: utils.cpp:590
free_artifactlist
static void free_artifactlist(artifactlist *al)
Free specified list and its items.
Definition: artifact.cpp:102
MAX_BUF
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
strlcpy
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
Definition: porting.cpp:222
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:1273
object::weight
int32_t weight
Attributes of the object.
Definition: object.h:375
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:280
living::wc
int8_t wc
Weapon Class, lower WC increases probability of hitting.
Definition: living.h:37
RANDOM
#define RANDOM()
Definition: define.h:638
try_find_animation
Animations * try_find_animation(const char *name)
Definition: assets.cpp:277
living::maxgrace
int16_t maxgrace
Maximum grace.
Definition: living.h:45
key_value::key
const char * key
Name of the key.
Definition: object.h:43
FLAG_REFL_SPELL
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
Definition: define.h:275
object::slaying
sstring slaying
Which race to do double damage to.
Definition: object.h:327
find_archetype_by_object_name
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
object::name
sstring name
The name of the object, obviously...
Definition: object.h:319
object::artifact
sstring artifact
If set, the item is the artifact with this name and the matching type.
Definition: object.h:322
artifact::chance
uint16_t chance
Chance of the artifact to happen.
Definition: artifact.h:16
living::maxsp
int16_t maxsp
Max spell points.
Definition: living.h:43
change_attr_value
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
object::last_sp
int32_t last_sp
As last_heal, but for spell points.
Definition: object.h:368
sstring
const typedef char * sstring
Definition: sstring.h:2
Animations
This represents one animation.
Definition: face.h:25
object::gen_sp_armour
int8_t gen_sp_armour
Sp regen penalty this object has (was last_heal)
Definition: object.h:373
ARTIFACT_TRIES
#define ARTIFACT_TRIES
Give 1 re-roll attempt per artifact.
Definition: artifact.cpp:123
object_set_msg
void object_set_msg(object *op, const char *msg)
Set the message field of an object.
Definition: object.cpp:4811
artifact_get_face
uint16_t artifact_get_face(const artifact *art)
Get a suitable face number for representing an artifact.
Definition: artifact.cpp:638
FLAG_REFLECTING
#define FLAG_REFLECTING
Object reflects from walls (lightning)
Definition: define.h:262
object::msg
sstring msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:330
object_free_key_values
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:954
artifactlist::total_chance
uint16_t total_chance
Sum of chance for are artifacts on this list.
Definition: artifact.h:26
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
living::ac
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
Definition: living.h:38
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
object_give_identified_properties
void object_give_identified_properties(object *op)
Ensure op has all its "identified" properties set.
Definition: item.cpp:1361
first_artifactlist
artifactlist * first_artifactlist
First artifact.
Definition: init.cpp:109
FLAG_ANIMATE
#define FLAG_ANIMATE
The object looks at archetype for faces.
Definition: define.h:242
loader.h
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:1833
try_find_archetype
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:269
try_find_face
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:285
archetype::name
sstring name
More definite name, like "generate_kobold".
Definition: object.h:484
object::nrof
uint32_t nrof
Number of objects.
Definition: object.h:342
FLAG_XRAYS
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:300
living::grace
int16_t grace
Grace.
Definition: living.h:44
object::stats
living stats
Str, Con, Dex, etc.
Definition: object.h:378
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
object_set_value
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:4499
get_attr_value
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
Definition: living.cpp:313
dump_artifacts
void dump_artifacts(void)
For debugging purposes.
Definition: artifact.cpp:614
object::attacktype
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:352
OUT_OF_MEMORY
@ OUT_OF_MEMORY
Definition: define.h:48
FLAG_CURSED
#define FLAG_CURSED
The object is cursed.
Definition: define.h:316
get_empty_artifact
artifact * get_empty_artifact(void)
Allocate and return the pointer to an empty artifact structure.
Definition: artifact.cpp:55
generate_artifact
void generate_artifact(object *op, int difficulty)
Decides randomly which artifact the object should be turned into.
Definition: artifact.cpp:177
find_artifactlist
artifactlist * find_artifactlist(int type)
Finds the artifact list for a certain item type.
Definition: artifact.cpp:574
object::material
uint16_t material
What materials this object consist of.
Definition: object.h:357
NUM_STATS
@ NUM_STATS
Number of statistics.
Definition: living.h:18
object::next
object * next
Pointer to the next object in the free/used list.
Definition: object.h:285
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Definition: define.h:664
artifactlist::type
uint8_t type
Object type that this list represents.
Definition: artifact.h:25
living::hp
int16_t hp
Hit Points.
Definition: living.h:40
living::luck
int8_t luck
Affects thaco and ac from time to time.
Definition: living.h:39
Animations::name
sstring name
Name of the animation sequence.
Definition: face.h:26
llevDebug
@ llevDebug
Only for debugging purposes.
Definition: logger.h:13
FLAG_LIFESAVE
#define FLAG_LIFESAVE
Saves a players' life once, then destr.
Definition: define.h:305
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
FLAG_IDENTIFIED
#define FLAG_IDENTIFIED
Player knows full info about item.
Definition: define.h:261
face
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn though Notes on Specific and settings file datadir Usually usr share crossfire Contains data that the server does not need to modify while such as the etc A default install will pack the and treasurelist definitions into a single or trs file and the graphics into a face(metadata) and .tar(bitmaps) file
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