Crossfire Server, Trunk  1.75.0
item.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 
22 #include "global.h"
23 
24 #include <assert.h>
25 #include <bitset>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <cmath>
30 
31 #include "living.h"
32 #include "spells.h"
33 
57  { "body_range", "in your range slot", "in a human's range slot" },
58  { "body_arm", "on your arm", "on a human's arm" },
59  { "body_torso", "on your body", "on a human's torso" },
60  { "body_head", "on your head", "on a human's head" },
61  { "body_neck", "around your neck", "around a human's neck" },
62  { "body_skill", "in your skill slot", "in a human's skill slot" },
63  { "body_finger", "on your finger", "on a human's finger" },
64  { "body_shoulder", "around your shoulders", "around a human's shoulders" },
65  { "body_foot", "on your feet", "on a human's feet" },
66  { "body_hand", "on your hands", "on a human's hands" },
67  { "body_wrist", "around your wrists", "around a human's wrist" },
68  { "body_waist", "around your waist", "around a human's waist" },
69  { "body_leg", "around your legs", "around a human's legs" },
70  /*{"body_dragon_torso", "your body", "a dragon's body"} */
71 };
72 
80 static const typedata item_types[] = {
81  { 0, "none", "none", 0, 0 },
82  { PLAYER, "player", "players", 0, 0 },
83  { TRANSPORT, "transport", "transports", 0, 0 },
84  { ROD, "rod", "rods", SK_THAUMATURGY, 0 },
85  { TREASURE, "treasure", "treasure", 0, 0 },
86  { POTION, "potion", "potions", SK_ALCHEMY, 0 },
87  { FOOD, "food", "food", SK_WOODSMAN, 0 },
88  { POISON, "poison", "poisons", SK_ALCHEMY, 0 },
89  { BOOK, "book", "books", SK_LITERACY, 0 },
90  { CLOCK, "clock", "clocks", 0, 0 },
91  { ARROW, "arrow", "arrows", SK_BOWYER, 0 },
92  { BOW, "bow", "bows", SK_BOWYER, 0 },
93  { WEAPON, "weapon", "weapons", SK_SMITHERY, 0 },
94  { ARMOUR, "armour", "armour", SK_SMITHERY, 0 },
95  { PEDESTAL, "pedestal", "pedestals", 0, 0 },
96  { ALTAR, "altar", "altars", 0, 0 },
97  { LOCKED_DOOR, "locked door", "locked doors", 0, 0 },
98  { SPECIAL_KEY, "special key", "special keys", 0, 0 },
99  { MAP, "map", "maps", 0, 0 },
100  { DOOR, "door", "doors", 0, 0 },
101  { KEY, "key", "keys", 0, 0 },
102  { TIMED_GATE, "timed_gate", "timed_gates", 0, 0 },
103  { TRIGGER, "trigger", "triggers", 0, 0 },
104  { GRIMREAPER, "grimreaper", "grimreapers", 0, 0 },
105  { MAGIC_EAR, "magic ear", "magic ears", 0, 0 },
106  { TRIGGER_BUTTON, "trigger button", "trigger buttons", 0, 0 },
107  { TRIGGER_ALTAR, "trigger altar", "trigger altars", 0, 0 },
108  { TRIGGER_PEDESTAL, "trigger pedestal", "trigger pedestals", 0, 0 },
109  { SHIELD, "shield", "shields", SK_SMITHERY, 0 },
110  { HELMET, "helmet", "helmets", SK_SMITHERY, 0 },
111  { MONEY, "money", "money", 0, 0 },
112  { CLASS, "class", "classes", 0, 0 },
113  { AMULET, "amulet", "amulets", SK_JEWELER, 0 },
114  { PLAYERMOVER, "player mover", "player movers", 0, 0 },
115  { TELEPORTER, "teleporter", "teleporters", 0, 0 },
116  { CREATOR, "creator", "creators", 0, 0 },
117  { SKILL, "skill", "skills", 0, 0 },
118  { EARTHWALL, "earthwall", "earthwalls", 0, 0 },
119  { GOLEM, "golem", "golems", 0, 0 },
120  { THROWN_OBJ, "projectile", "projectiles", 0, 0 },
121  { BLINDNESS, "blindness", "blindness", 0, 0 },
122  { GOD, "god", "gods", 0, 0 },
123  { DETECTOR, "detector", "detectors", 0, 0 },
124  { TRIGGER_MARKER, "trigger marker", "trigger markers", 0, 0 },
125  { DEAD_OBJECT, "dead object", "dead objects", 0, 0 },
126  { DRINK, "drink", "drinks", SK_WOODSMAN, SK_ALCHEMY },
127  { MARKER, "marker", "markers", 0, 0 },
128  { HOLY_ALTAR, "holy altar", "holy altars", 0, 0 },
129  { PLAYER_CHANGER, "player changer", "player changers", 0, 0 },
130  { BATTLEGROUND, "battleground", "battlegrounds", 0, 0 },
131  { PEACEMAKER, "peacemaker", "peacemakers", 0, 0 },
132  { GEM, "gem", "gems", SK_JEWELER, 0 },
133  { FIREWALL, "firewall", "firewalls", 0, 0 },
134  { CHECK_INV, "inventory checker", "inventory checkers", 0, 0 },
135  { MOOD_FLOOR, "mood floor", "mood floors", 0, 0 },
136  { EXIT, "exit", "exits", 0, 0 },
137  { ENCOUNTER, "encounter", "encounters", 0, 0 },
138  { SHOP_FLOOR, "shop floor", "shop floors", 0, 0 },
139  { SHOP_MAT, "shop mat", "shop mats", 0, 0 },
140  { RING, "ring", "rings", SK_JEWELER, 0 },
141  { FLOOR, "floor", "floors", 0, 0 },
142  { FLESH, "flesh", "flesh", SK_WOODSMAN, 0 },
143  { INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0 },
144  { SKILL_TOOL, "skill tool", "skill tools", 0, 0 },
145  { LIGHTER, "lighter", "lighters", 0, 0 },
146  { WALL, "wall", "walls", 0, 0 },
147  { MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0 },
148  { MONSTER, "monster", "monsters", 0, 0 },
149  { LAMP, "lamp", "lamps", 0, 0 },
150  { DUPLICATOR, "duplicator", "duplicators", 0, 0 },
151  { SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0 },
152  { CLOAK, "cloak", "cloaks", SK_SMITHERY, 0 },
153  { SPINNER, "spinner", "spinners", 0, 0 },
154  { GATE, "gate", "gates", 0, 0 },
155  { BUTTON, "button", "buttons", 0, 0 },
156  { CF_HANDLE, "cf handle", "cf handles", 0, 0 },
157  { HOLE, "hole", "holes", 0, 0 },
158  { TRAPDOOR, "trapdoor", "trapdoors", 0, 0 },
159  { SIGN, "sign", "signs", 0, 0 },
160  { BOOTS, "boots", "boots", SK_SMITHERY, 0 },
161  { GLOVES, "gloves", "gloves", SK_SMITHERY, 0 },
162  { SPELL, "spell", "spells", 0, 0 },
163  { SPELL_EFFECT, "spell effect", "spell effects", 0, 0 },
164  { CONVERTER, "converter", "converters", 0, 0 },
165  { BRACERS, "bracers", "bracers", SK_SMITHERY, 0 },
166  { POISONING, "poisoning", "poisonings", 0, 0 },
167  { SAVEBED, "savebed", "savebeds", 0, 0 },
168  { WAND, "wand", "wands", SK_THAUMATURGY, 0 },
169  { SCROLL, "scroll", "scrolls", SK_LITERACY, 0 },
170  { DIRECTOR, "director", "directors", 0, 0 },
171  { GIRDLE, "girdle", "girdles", SK_SMITHERY, 0 },
172  { FORCE, "force", "forces", 0, 0 },
173  { POTION_RESIST_EFFECT, "potion effect", "potion effects", 0, 0 },
174  { CLOSE_CON, "closed container", "closed container", SK_ALCHEMY, 0 },
175  { CONTAINER, "container", "containers", SK_ALCHEMY, 0 },
176  { ARMOUR_IMPROVER, "armour improver", "armour improvers", SK_LITERACY, 0 },
177  { WEAPON_IMPROVER, "weapon improver", "weapon improvers", SK_LITERACY, 0 },
178  { SKILLSCROLL, "skillscroll", "skillscrolls", SK_LITERACY, 0 },
179  { DEEP_SWAMP, "deep swamp", "deep swamps", 0, 0 },
180  { IDENTIFY_ALTAR, "identify altar", "identify altars", 0, 0 },
181  { SHOP_INVENTORY, "inventory list", "inventory lists", 0, 0 },
182  { RUNE, "rune", "runes", 0, 0 },
183  { TRAP, "trap", "traps", 0, 0 },
184  { POWER_CRYSTAL, "power_crystal", "power_crystals", SK_THAUMATURGY, 0 },
185  { CORPSE, "corpse", "corpses", 0, 0 },
186  { DISEASE, "disease", "diseases", 0, 0 },
187  { SYMPTOM, "symptom", "symptoms", 0, 0 },
188  { BUILDER, "item builder", "item builders", 0, 0 },
189  { MATERIAL, "building material", "building materials", 0, 0 },
190  { MIMIC, "mimic", "mimics", SK_ALCHEMY, 0 },
191  { LIGHTABLE, "lightable", "lightables", 0, 0 },
192 };
193 
195 static const int item_types_size = sizeof(item_types)/sizeof(*item_types);
196 
206 static const int enc_to_item_power[] = {
207  0, 0, 1, 2, 3, 4, /* 5 */
208  5, 7, 9, 11, 13, /* 10 */
209  15, 18, 21, 24, 27, /* 15 */
210  30, 35, 40, 45, 50 /* 20 */
211 };
212 
213 int get_power_from_ench(int ench) {
214  if (ench < 0)
215  ench = 0;
216  if (ench > (int)(sizeof(enc_to_item_power)/sizeof(*enc_to_item_power)-1))
217  ench = sizeof(enc_to_item_power)/sizeof(*enc_to_item_power)-1;
218  return enc_to_item_power[ench];
219 }
220 
221 static int bits_set(uint32_t x) {
222  std::bitset<32> xs = x;
223  return xs.count();
224 }
225 
226 int calc_item_enhancement(const object *op) {
227  int i, tmp, enc;
228 
229  // If we get, for example, a pile of gypsum here,
230  // don't give it an item power. Nothing in the inorganic
231  // type can be applied; their resistances are just to avoid
232  // or encourage destruction by specific attacktypes.
233  if (op->type == INORGANIC)
234  return 0;
235 
236  enc = 0;
237  for (i = 0; i < NUM_STATS; i++)
238  enc += get_attr_value(&op->stats, i);
239 
240  /* This protection logic is pretty flawed. 20% fire resistance
241  * is much more valuable than 20% confusion, or 20% slow, or
242  * several others. Start at 1 - ignore physical - all that normal
243  * armour shouldn't be counted against
244  */
245  tmp = 0;
246  for (i = 1; i < NROFATTACKS; i++)
247  tmp += op->resist[i];
248 
249  /* Add/substract 10 so that the rounding works out right */
250  if (tmp > 0)
251  enc += (tmp+10)/20;
252  else if (tmp < 0)
253  enc += (tmp-10)/20;
254 
255  enc += op->magic;
256 
257  /* For each attacktype a weapon has, one more encantment. Start at 1 -
258  * physical doesn't count against total.
259  */
260  if (op->type == WEAPON) {
261  enc += bits_set(op->attacktype);
262  if (op->slaying)
263  enc += 2; /* What it slays is probably more relevent */
264  }
265  /* Items the player can equip */
266  if ((op->type == WEAPON)
267  || (op->type == ARMOUR)
268  || (op->type == HELMET)
269  || (op->type == SHIELD)
270  || (op->type == RING)
271  || (op->type == BOOTS)
272  || (op->type == GLOVES)
273  || (op->type == AMULET)
274  || (op->type == GIRDLE)
275  || (op->type == BRACERS)
276  || (op->type == CLOAK)) {
277  enc += op->stats.food; /* sustenance */
278  enc += op->stats.hp; /* hp regen */
279  enc += op->stats.sp; /* mana regen */
280  enc += op->stats.grace; /* grace regen */
281  enc += op->stats.exp; /* speed bonus */
282  }
283  enc += op->stats.luck;
284 
285  /* Do spell paths now */
286  enc += bits_set(op->path_attuned);
287  enc -= bits_set(op->path_repelled);
288  enc -= 2*bits_set(op->path_denied);
289 
290  if (QUERY_FLAG(op, FLAG_LIFESAVE))
291  enc += 5;
292  if (QUERY_FLAG(op, FLAG_REFL_SPELL))
293  enc += 3;
294  if (QUERY_FLAG(op, FLAG_REFL_MISSILE))
295  enc += 2;
296  if (QUERY_FLAG(op, FLAG_STEALTH))
297  enc += 1;
298  if (QUERY_FLAG(op, FLAG_XRAYS))
299  enc += 2;
300  if (QUERY_FLAG(op, FLAG_SEE_IN_DARK))
301  enc += 1;
302  if (QUERY_FLAG(op, FLAG_MAKE_INVIS))
303  enc += 1;
304 
305  return enc;
306 }
307 
318 int calc_item_power(const object *op) {
320 }
321 
328 const typedata *get_typedata(int itemtype) {
329  int i;
330 
331  for (i = 0; i < item_types_size; i++)
332  if (item_types[i].number == itemtype)
333  return &item_types[i];
334  return NULL;
335 }
336 
348 const typedata *get_typedata_by_name(const char *name) {
349  int i;
350 
351  for (i = 0; i < item_types_size; i++)
352  if (!strcmp(item_types[i].name, name))
353  return &item_types[i];
354  for (i = 0; i < item_types_size; i++)
355  if (!strcmp(item_types[i].name_pl, name)) {
356  LOG(llevInfo, "get_typedata_by_name: I have been sent the plural %s, the singular form %s is preffered\n", name, item_types[i].name);
357  return &item_types[i];
358  }
359  return NULL;
360 }
361 
377 StringBuffer *describe_resistance(const object *op, int newline, int use_media_tags, StringBuffer *buf) {
378  int tmpvar;
379 
380  if (buf == NULL)
381  buf = stringbuffer_new();
382 
383  for (tmpvar = 0; tmpvar < NROFATTACKS; tmpvar++) {
384  if (op->resist[tmpvar] && (op->type != FLESH || atnr_is_dragon_enabled(tmpvar) == 1)) {
385  if (use_media_tags) {
386  if (resist_color[tmpvar] != NULL) {
387  stringbuffer_append_printf(buf, "[color=%s]", resist_color[tmpvar]);
388  }
389  if (op->resist[tmpvar] == 100 || op->resist[tmpvar] == -100) {
391  }
392  }
393  if (!newline)
394  stringbuffer_append_printf(buf, "(%s %+d)", resist_plus[tmpvar], op->resist[tmpvar]);
395  else
396  stringbuffer_append_printf(buf, "%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]);
397  if (use_media_tags) {
398  if (op->resist[tmpvar] == 100 || op->resist[tmpvar] == -100) {
400  }
401  if (resist_color[tmpvar] != NULL) {
402  stringbuffer_append_string(buf, "[/color]");
403  }
404  }
405  }
406  }
407 
408  return buf;
409 }
410 
420 void query_weight(const object *op, char *buf, size_t size) {
421  int32_t i = NROF(op)*op->weight+op->carrying;
422 
423  if (op->weight < 0)
424  snprintf(buf, size, " ");
425  else if (i%1000)
426  snprintf(buf, size, "%6.1f", i/1000.0);
427  else
428  snprintf(buf, size, "%4d ", i/1000);
429 }
430 
443 static StringBuffer *ring_desc(const object *op, int use_media_tags, StringBuffer *buf) {
444  int attr, val;
445  size_t len;
446 
447  assert(op != NULL);
448  assert(op->type == RING || op->type == AMULET || op->type == SKILL);
449 
450  if (buf == NULL)
451  buf = stringbuffer_new();
452  len = stringbuffer_length(buf);
453 
454  if (!QUERY_FLAG(op, FLAG_IDENTIFIED))
455  return buf;
456 
457  for (attr = 0; attr < NUM_STATS; attr++) {
458  if ((val = get_attr_value(&(op->stats), attr)) != 0) {
459  stringbuffer_append_printf(buf, "(%s%+d)", short_stat_name[attr], val);
460  }
461  }
462  if (op->stats.exp)
463  stringbuffer_append_printf(buf, "(speed %+" FMT64 ")", op->stats.exp);
464  if (op->stats.wc)
465  stringbuffer_append_printf(buf, "(wc%+d)", op->stats.wc);
466  if (op->stats.dam)
467  stringbuffer_append_printf(buf, "(dam%+d)", op->stats.dam);
468  if (op->stats.ac)
469  stringbuffer_append_printf(buf, "(ac%+d)", op->stats.ac);
470 
471  describe_resistance(op, 0, use_media_tags, buf);
472 
473  if (op->stats.food != 0)
474  stringbuffer_append_printf(buf, "(sustenance%+d)", op->stats.food);
475  if (op->stats.grace)
476  stringbuffer_append_printf(buf, "(grace%+d)", op->stats.grace);
477  if (op->stats.sp && op->type != SKILL)
478  stringbuffer_append_printf(buf, "(magic%+d)", op->stats.sp);
479  if (op->stats.hp)
480  stringbuffer_append_printf(buf, "(regeneration%+d)", op->stats.hp);
481  if (op->stats.luck)
482  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
483  if (QUERY_FLAG(op, FLAG_LIFESAVE))
484  stringbuffer_append_printf(buf, "(lifesaving)");
485  if (QUERY_FLAG(op, FLAG_REFL_SPELL))
486  stringbuffer_append_printf(buf, "(reflect spells)");
487  if (QUERY_FLAG(op, FLAG_REFL_MISSILE))
488  stringbuffer_append_printf(buf, "(reflect missiles)");
489  if (QUERY_FLAG(op, FLAG_STEALTH))
490  stringbuffer_append_printf(buf, "(stealth)");
491  if (op->glow_radius)
492  stringbuffer_append_string(buf, "(glowing)");
493 
497 
498  /* item_power is done by the caller */
499  /* if (op->item_power)
500  snprintf(buf+strlen(buf), size-strlen(buf), "(item_power %+d)", op->item_power);*/
501  if (stringbuffer_length(buf) == len && op->type != SKILL)
502  stringbuffer_append_string(buf, "of adornment");
503 
504  return buf;
505 }
506 
518 void query_short_name(const object *op, char *buf, size_t size) {
519  size_t len = 0;
520 
521  if (op->name == NULL) {
522  snprintf(buf, size, "(null)");
523  return;
524  }
525  if (!op->nrof && !op->weight && !op->title && !is_magical(op)) {
526  strlcpy(buf, op->name, size); /* To speed things up (or make things slower?) */
527  return;
528  }
529  buf[0] = '\0';
530 
531  if (op->nrof <= 1)
532  safe_strcat(buf, op->name, &len, size);
533  else
534  safe_strcat(buf, op->name_pl, &len, size);
535 
536  if (op->title && QUERY_FLAG(op, FLAG_IDENTIFIED)) {
537  safe_strcat(buf, " ", &len, size);
538  safe_strcat(buf, op->title, &len, size);
539  }
540 
541  switch (op->type) {
542  case SPELLBOOK:
543  case SCROLL:
544  case WAND:
545  case ROD:
547  if (!op->title && (op->inv)) {
548  safe_strcat(buf, " of ", &len, size);
549  safe_strcat(buf, op->inv->name, &len, size);
550  }
551  if (op->type != SPELLBOOK) {
552  snprintf(buf+len, size-len, " (lvl %d)", op->level);
553  len += strlen(buf+len);
554  }
555  }
556  break;
557 
558  case SKILL:
559  case AMULET:
560  case RING:
561  if (!op->title) {
562  /* If ring has a title, full description isn't so useful */
563  char* desc;
564 
565  desc = stringbuffer_finish(ring_desc(op, 0, NULL));
566  if (desc[0]) {
567  safe_strcat(buf, " ", &len, size);
568  safe_strcat(buf, desc, &len, size);
569  }
570  free(desc);
571  }
572  break;
573 
574  default:
575  if (op->magic
576  && (QUERY_FLAG(op, FLAG_BEEN_APPLIED) || is_identified(op))) {
577  snprintf(buf+len, size-len, " %+d", op->magic);
578  len += strlen(buf+len);
579  }
580  }
581 }
582 
593 void query_name(const object *op, char *buf, size_t size) {
594  size_t len = 0;
595 
596  buf[0] = '\0';
597  /*
598  * Since len is initialized to zero, but is not changed
599  * up to this point, I see no reason to have buf+len and size-len;
600  * buf and size should suffice, since we're just adding and
601  * subtracting zero here, anyway.
602  *
603  * SilverNexus 2014-06-04
604  */
605  query_short_name(op, buf, size);
606  len = strlen(buf);
607 
608  if (QUERY_FLAG(op, FLAG_INV_LOCKED))
609  safe_strcat(buf, " *", &len, size);
610 
611  if (QUERY_FLAG(op, FLAG_KNOWN_CURSED)) {
612  if (QUERY_FLAG(op, FLAG_DAMNED))
613  safe_strcat(buf, " (damned)", &len, size);
614  else if (QUERY_FLAG(op, FLAG_CURSED))
615  safe_strcat(buf, " (cursed)", &len, size);
616  }
618  safe_strcat(buf, " (blessed)", &len, size);
619 
620  /* Basically, if the object is known magical (detect magic spell on it),
621  * and it isn't identified, print out the fact that
622  * it is magical. Assume that the detect magical spell will only set
623  * KNOWN_MAGICAL if the item actually is magical.
624  *
625  * Changed in V 0.91.4 - still print that the object is magical even
626  * if it has been applied. Equipping an item does not tell full
627  * abilities, especially for artifact items.
628  */
630  safe_strcat(buf, " (magic)", &len, size);
631 
632  if (QUERY_FLAG(op, FLAG_APPLIED)) {
633  switch (op->type) {
634  case BOW:
635  case WAND:
636  case ROD:
637  safe_strcat(buf, " (readied)", &len, size);
638  break;
639 
640  case WEAPON:
641  safe_strcat(buf, " (wielded)", &len, size);
642  break;
643 
644  case ARMOUR:
645  case HELMET:
646  case SHIELD:
647  case RING:
648  case BOOTS:
649  case GLOVES:
650  case AMULET:
651  case GIRDLE:
652  case BRACERS:
653  case CLOAK:
654  safe_strcat(buf, " (worn)", &len, size);
655  break;
656 
657  case CONTAINER:
658  safe_strcat(buf, " (active)", &len, size);
659  break;
660 
661  case SKILL:
662  default:
663  safe_strcat(buf, " (applied)", &len, size);
664  }
665  }
666  // NO_SKILL_IDENT is set when identification fails or when the book is read. So the book is read only when it is
667  // both identified and NO_SKILL_IDENT.
669  safe_strcat(buf, " (read)", &len, size);
670  if (QUERY_FLAG(op, FLAG_UNPAID))
671  safe_strcat(buf, " (unpaid)", &len, size);
672 }
673 
691 void query_base_name(const object *op, int plural, char *buf, size_t size) {
692  size_t len;
693 
694  if ((!plural && !op->name)
695  || (plural && !op->name_pl)) {
696  strncpy(buf, "(null)", size);
697  return;
698  }
699 
700  if (!op->nrof && !op->weight && !op->title && !is_magical(op)) {
701  strncpy(buf, op->name, size); /* To speed things up (or make things slower?) */
702  return;
703  }
704 
705  buf[0] = '\0';
706 
707  strlcpy(buf, plural ? op->name_pl : op->name, size);
708  len = strlen(buf);
709 
710  if (op->title && QUERY_FLAG(op, FLAG_IDENTIFIED)) {
711  safe_strcat(buf, " ", &len, size);
712  safe_strcat(buf, op->title, &len, size);
713  }
714 
715  switch (op->type) {
716  case SPELLBOOK:
717  case SCROLL:
718  case WAND:
719  case ROD:
721  if (!op->title && (op->inv)) {
722  safe_strcat(buf, " of ", &len, size);
723  // If, for some reason, a spell on a scroll were to stop existing as an arch,
724  // we would get here. The scroll will hold an inventory object with no name.
725  // So, to prevent a segfault, only print the spell name if it exists.
726  if (op->inv->name)
727  safe_strcat(buf, op->inv->name, &len, size);
728  // scroll of nothing seems like a good replacement for when the name does not exist.
729  else
730  safe_strcat(buf, "nothing", &len, size);
731  }
732  if (op->type != SPELLBOOK) {
733  snprintf(buf+len, size-len, " (lvl %d)", op->level);
734  len += strlen(buf+len);
735  }
736  }
737  break;
738 
739  case SKILL:
740  case AMULET:
741  case RING:
742  if (!op->title) {
743  /* If ring has a title, full description isn't so useful */
744  char* s;
745 
746  s = stringbuffer_finish(ring_desc(op, 0, NULL));
747  if (s[0]) {
748  safe_strcat(buf, " ", &len, size);
749  safe_strcat(buf, s, &len, size);
750  }
751  free(s);
752  }
753  break;
754 
755  default:
756  if (op->magic
757  && (QUERY_FLAG(op, FLAG_BEEN_APPLIED) || is_identified(op))) {
758  snprintf(buf+strlen(buf), size-strlen(buf), " %+d", op->magic);
759  }
760  }
761 }
762 
779 StringBuffer *describe_monster(const object *op, int use_media_tags, StringBuffer *buf) {
780  assert(op != NULL);
781  assert(QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER);
782 
783  if (buf == NULL)
784  buf = stringbuffer_new();
785 
786  /* Note that the resolution this provides for players really isn't
787  * very good. Any player with a speed greater than .67 will
788  * fall into the 'lightning fast movement' category.
789  */
790  if (FABS(op->speed) > MIN_ACTIVE_SPEED) {
791  switch ((int)((FABS(op->speed))*15)) {
792  case 0:
793  stringbuffer_append_string(buf, "(very slow movement)");
794  break;
795 
796  case 1:
797  stringbuffer_append_string(buf, "(slow movement)");
798  break;
799 
800  case 2:
801  stringbuffer_append_string(buf, "(normal movement)");
802  break;
803 
804  case 3:
805  case 4:
806  stringbuffer_append_string(buf, "(fast movement)");
807  break;
808 
809  case 5:
810  case 6:
811  stringbuffer_append_string(buf, "(very fast movement)");
812  break;
813 
814  case 7:
815  case 8:
816  case 9:
817  case 10:
818  stringbuffer_append_string(buf, "(extremely fast movement)");
819  break;
820 
821  default:
822  stringbuffer_append_string(buf, "(lightning fast movement)");
823  break;
824  }
825  }
826  if (QUERY_FLAG(op, FLAG_UNDEAD))
827  stringbuffer_append_string(buf, "(undead)");
829  stringbuffer_append_string(buf, "(see invisible)");
830  if (QUERY_FLAG(op, FLAG_USE_WEAPON))
831  stringbuffer_append_string(buf, "(wield weapon)");
832  if (QUERY_FLAG(op, FLAG_USE_BOW))
833  stringbuffer_append_string(buf, "(archer)");
834  if (QUERY_FLAG(op, FLAG_USE_ARMOUR))
835  stringbuffer_append_string(buf, "(wear armour)");
836  if (QUERY_FLAG(op, FLAG_USE_RING))
837  stringbuffer_append_string(buf, "(wear ring)");
838  if (QUERY_FLAG(op, FLAG_USE_SCROLL))
839  stringbuffer_append_string(buf, "(read scroll)");
840  if (QUERY_FLAG(op, FLAG_USE_RANGE))
841  stringbuffer_append_string(buf, "(fires wand/rod/horn)");
843  stringbuffer_append_string(buf, "(skill user)");
844  if (QUERY_FLAG(op, FLAG_CAST_SPELL))
845  stringbuffer_append_string(buf, "(spellcaster)");
846  if (QUERY_FLAG(op, FLAG_FRIENDLY))
847  stringbuffer_append_string(buf, "(friendly)");
848  if (QUERY_FLAG(op, FLAG_UNAGGRESSIVE))
849  stringbuffer_append_string(buf, "(unaggressive)");
850  if (QUERY_FLAG(op, FLAG_HITBACK))
851  stringbuffer_append_string(buf, "(hitback)");
852  if (QUERY_FLAG(op, FLAG_STEALTH))
853  stringbuffer_append_string(buf, "(stealthy)");
854  if (op->randomitems != NULL) {
855  treasure *t;
856  int first = 1;
857 
858  for (t = op->randomitems->items; t != NULL; t = t->next)
859  if (t->item && (t->item->clone.type == SPELL)) {
860  if (first) {
861  first = 0;
862  stringbuffer_append_string(buf, "(Spell abilities:)");
863  }
864  stringbuffer_append_printf(buf, "(%s)", t->item->clone.name);
865  }
866  }
867  if (op->type == PLAYER) {
868  if (op->contr->digestion) {
869  if (op->contr->digestion != 0)
870  stringbuffer_append_printf(buf, "(sustenance%+d)", op->contr->digestion);
871  }
872  if (op->contr->gen_grace) {
873  stringbuffer_append_printf(buf, "(grace%+d)", op->contr->gen_grace);
874  }
875  if (op->contr->gen_sp) {
876  stringbuffer_append_printf(buf, "(magic%+d)", op->contr->gen_sp);
877  }
878  if (op->contr->gen_hp) {
879  stringbuffer_append_printf(buf, "(regeneration%+d)", op->contr->gen_hp);
880  }
881  if (op->stats.luck) {
882  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
883  }
884  }
885 
886  /* describe attacktypes */
887  if (is_dragon_pl(op)) {
888  /* for dragon players display the attacktypes from clawing skill
889  * Break apart the for loop - move the comparison checking down -
890  * this makes it more readable.
891  */
892  object *tmp;
893 
894  tmp = object_find_by_type_and_name(op, SKILL, "clawing");
895  if (tmp && tmp->attacktype != 0) {
896  describe_attacktype("Claws", tmp->attacktype, buf);
897  } else {
898  describe_attacktype("Attacks", op->attacktype, buf);
899  }
900  } else {
901  describe_attacktype("Attacks", op->attacktype, buf);
902  }
906  describe_resistance(op, 0, use_media_tags, buf);
907 
908  return buf;
909 }
910 
953 StringBuffer *describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf) {
954  int identified, i;
955 
956  if (buf == NULL)
957  buf = stringbuffer_new();
958 
959  if (QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER) {
960  return describe_monster(op, use_media_tags, buf);
961  }
962 
963  /* figure this out once, instead of making multiple calls to is_identified.
964  * also makes the code easier to read.
965  */
966  if (is_identified(op)) {
967  identified = 1;
968  } else {
969  stringbuffer_append_string(buf, "(unidentified)");
970  identified = 0;
971  }
972  switch (op->type) {
973  case BOW:
974  case ARROW:
975  case WAND:
976  case ROD:
977  case WEAPON:
978  case ARMOUR:
979  case HELMET:
980  case SHIELD:
981  case BOOTS:
982  case GLOVES:
983  case GIRDLE:
984  case BRACERS:
985  case CLOAK:
986  case SKILL_TOOL:
987  break; /* We have more information to do below this switch */
988 
989  case LAMP:
990  break; /* just so we get the "glowing" part. */
991 
992  case FOOD:
993  case FLESH:
994  case DRINK:
995  if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) {
996  stringbuffer_append_printf(buf, "(food+%d)", op->stats.food);
997 
998  if (op->type == FLESH && op->last_eat > 0 && atnr_is_dragon_enabled(op->last_eat)) {
999  stringbuffer_append_printf(buf, "(%s metabolism)", change_resist_msg[op->last_eat]);
1000  }
1001 
1002  if (!QUERY_FLAG(op, FLAG_CURSED)) {
1003  if (op->stats.hp > 0)
1004  stringbuffer_append_string(buf, "(heals)");
1005  else if (op->stats.hp < 0)
1006  stringbuffer_append_string(buf, "(damages)");
1007 
1008  if (op->stats.sp > 0)
1009  stringbuffer_append_string(buf, "(spellpoint regen)");
1010  else if (op->stats.sp < 0)
1011  stringbuffer_append_string(buf, "(spellpoint depletion)");
1012  } else {
1013  if (op->stats.hp)
1014  stringbuffer_append_string(buf, "(damages)");
1015  if (op->stats.sp)
1016  stringbuffer_append_string(buf, "(spellpoint depletion)");
1017  }
1018  }
1019  break;
1020 
1021  case SKILL:
1022  case RING:
1023  case AMULET:
1024  if (op->item_power) {
1025  stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power);
1026  }
1027  if (op->title) {
1028  ring_desc(op, use_media_tags, buf);
1029  }
1030  return buf;
1031 
1032  default:
1033  return buf;
1034  }
1035 
1036  /* Down here, we more further describe equipment type items.
1037  * only describe them if they have been identified or the like.
1038  */
1039  if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) {
1040  int attr, val;
1041 
1042  for (attr = 0; attr < NUM_STATS; attr++) {
1043  if ((val = get_attr_value(&(op->stats), attr)) != 0) {
1044  stringbuffer_append_printf(buf, "(%s%+d)", short_stat_name[attr], val);
1045  }
1046  }
1047  if (op->glow_radius)
1048  stringbuffer_append_string(buf, "(glowing)");
1049 
1050  switch (op->type) {
1051  case FLESH:
1052  break;
1053 
1054  default:
1055  if (op->stats.exp) {
1056  stringbuffer_append_printf(buf, "(speed %+" FMT64 ")", op->stats.exp);
1057  }
1058  break;
1059  }
1060  switch (op->type) {
1061  case BOW:
1062  case ARROW:
1063  case GIRDLE:
1064  case HELMET:
1065  case SHIELD:
1066  case BOOTS:
1067  case GLOVES:
1068  case WEAPON:
1069  case SKILL:
1070  case RING:
1071  case AMULET:
1072  case ARMOUR:
1073  case BRACERS:
1074  case FORCE:
1075  case CLOAK:
1076  if (op->stats.wc) {
1077  stringbuffer_append_printf(buf, "(wc%+d)", op->stats.wc);
1078  }
1079  if (op->stats.dam) {
1080  stringbuffer_append_printf(buf, "(dam%+d)", op->stats.dam);
1081  }
1082  if (op->stats.ac) {
1083  stringbuffer_append_printf(buf, "(ac%+d)", op->stats.ac);
1084  }
1085  if ((op->type == WEAPON || op->type == BOW) && op->level > 0) {
1086  stringbuffer_append_printf(buf, "(improved %d/%d)", op->last_eat, op->level);
1087  }
1088  break;
1089 
1090  default:
1091  break;
1092  }
1093  if (QUERY_FLAG(op, FLAG_XRAYS))
1094  stringbuffer_append_string(buf, "(xray-vision)");
1095  if (QUERY_FLAG(op, FLAG_SEE_IN_DARK))
1096  stringbuffer_append_string(buf, "(infravision)");
1097 
1098  /* levitate was what is was before, so we'll keep it */
1099  if (op->move_type&MOVE_FLY_LOW)
1100  stringbuffer_append_string(buf, "(levitate)");
1101 
1102  if (op->move_type&MOVE_FLY_HIGH)
1103  stringbuffer_append_string(buf, "(fly)");
1104 
1105  if (op->move_type&MOVE_SWIM)
1106  stringbuffer_append_string(buf, "(swim)");
1107 
1108  /* walking is presumed as 'normal', so doesn't need mentioning */
1109 
1110  if (op->item_power) {
1111  stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power);
1112  }
1113  } /* End if identified or applied */
1114 
1115  /* This blocks only deals with fully identified object.
1116  * it is intentional that this is not an 'else' from a above -
1117  * in this way, information is added.
1118  */
1119  if (identified) {
1120  int more_info = 0;
1121 
1122  switch (op->type) {
1123  case ROD: /* These use stats.sp for spell selection and stats.food */
1124  /* and stats.hp for spell-point regeneration... */
1125  case ARROW:
1126  case WAND:
1127  case FOOD:
1128  case FLESH:
1129  case DRINK:
1130  more_info = 0;
1131  break;
1132 
1133  /* Bows use sp for firing rate. Per fire_bow(), the bow can be fired every 100/firing rate
1134  * character movements. It also makes sure it calculates the speed at no less than 1, to avoid floating point errors
1135  */
1136  case BOW:
1137  if (op->stats.sp) {
1138  stringbuffer_append_printf(buf, "(Firing delay %.2f)", 100./op->stats.sp);
1139  }
1140  more_info = 0;
1141  break;
1142 
1143  /* Armor type objects */
1144  case ARMOUR:
1145  case HELMET:
1146  case SHIELD:
1147  case BOOTS:
1148  case GLOVES:
1149  case GIRDLE:
1150  case BRACERS:
1151  case CLOAK:
1152  if (ARMOUR_SPEED(op)) {
1153  stringbuffer_append_printf(buf, "(Max speed %1.2f)", ARMOUR_SPEED(op)/10.0);
1154  }
1155  if (ARMOUR_SPELLS(op)) {
1156  stringbuffer_append_printf(buf, "(Spell regen penalty %d)", ARMOUR_SPELLS(op));
1157  }
1158  more_info = 1;
1159  break;
1160 
1161  case WEAPON:
1162  /* Calculate it the same way fix_object does so the results
1163  * make sense.
1164  */
1165  i = (WEAPON_SPEED(op)*2-op->magic)/2;
1166  if (i < 0)
1167  i = 0;
1168 
1169  stringbuffer_append_printf(buf, "(weapon speed %d)", i);
1170  /* If the reflecting flag is set, the weapon will bounce off walls when thrown. */
1171  if (QUERY_FLAG(op, FLAG_REFLECTING)) {
1172  stringbuffer_append_string(buf, "(ricochet)");
1173  }
1174  more_info = 1;
1175  break;
1176  }
1177  if (more_info) {
1178  if (op->stats.food) {
1179  if (op->stats.food != 0)
1180  stringbuffer_append_printf(buf, "(sustenance%+d)", op->stats.food);
1181  }
1182  if (op->stats.grace) {
1183  stringbuffer_append_printf(buf, "(grace%+d)", op->stats.grace);
1184  }
1185  if (op->stats.sp) {
1186  stringbuffer_append_printf(buf, "(magic%+d)", op->stats.sp);
1187  }
1188  if (op->stats.hp) {
1189  stringbuffer_append_printf(buf, "(regeneration%+d)", op->stats.hp);
1190  }
1191  }
1192 
1193  if (op->stats.luck) {
1194  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
1195  }
1196  if (QUERY_FLAG(op, FLAG_LIFESAVE))
1197  stringbuffer_append_string(buf, "(lifesaving)");
1198  if (QUERY_FLAG(op, FLAG_REFL_SPELL))
1199  stringbuffer_append_string(buf, "(reflect spells)");
1200  if (QUERY_FLAG(op, FLAG_REFL_MISSILE))
1201  stringbuffer_append_string(buf, "(reflect missiles)");
1202  if (QUERY_FLAG(op, FLAG_STEALTH))
1203  stringbuffer_append_string(buf, "(stealth)");
1204  if (op->slaying != NULL && op->type != FOOD) {
1205  stringbuffer_append_printf(buf, "(slay %s)", op->slaying);
1206  }
1207  describe_attacktype("Attacks", op->attacktype, buf);
1208  /* resistance on flesh is only visible for dragons. If
1209  * non flesh, everyone can see its resistances
1210  */
1211  if (op->type != FLESH || (owner && is_dragon_pl(owner))) {
1212  describe_resistance(op, 0, 1, buf);
1213  }
1217  }
1218 
1219  return buf;
1220 }
1221 
1234 int is_magical(const object *op) {
1235  int i;
1236 
1237  /* living creatures are considered non magical */
1238  if (QUERY_FLAG(op, FLAG_ALIVE))
1239  return 0;
1240 
1241  /* This is a test for it being an artifact, as artifacts have titles */
1242  if (op->title != NULL)
1243  return 1;
1244 
1245  /* Handle rings and amulets specially. If they change any of these
1246  * values, it means they are magical.
1247  */
1248  if ((op->type == AMULET || op->type == RING)
1249  && (op->stats.ac || op->stats.food || op->stats.exp || op->stats.dam || op->stats.wc || op->stats.grace || op->stats.sp || op->stats.hp || op->stats.luck))
1250  return 1;
1251 
1252  /* Check for stealty, speed, flying, or just plain magic in the boots */
1253  /* Presume any boots that have a move_type are special. */
1254  if (op->type == BOOTS
1255  && ((QUERY_FLAG(op, FLAG_STEALTH) || op->move_type || op->stats.exp)))
1256  return 1;
1257 
1258  /* Take care of amulet/shield that reflects spells/missiles */
1259  if ((op->type == AMULET || op->type == SHIELD)
1261  return 1;
1262 
1263  /* Take care of helmet of xrays */
1264  if (op->type == HELMET
1265  && QUERY_FLAG(op, FLAG_XRAYS))
1266  return 1;
1267 
1268  /* Potions & rods are always magical. Wands/staves are also magical,
1269  * assuming they still have any charges left.
1270  */
1271  if (op->type == POTION || op->type == ROD || (op->type == WAND && op->stats.food))
1272  return 1;
1273 
1274  /* if something gives a protection, either positive or negative, its magical */
1275  /* This is really a pretty bad hack - as of now, ATNR_PHYSICAL is 0,
1276  * so this always works out fine.
1277  */
1278  for (i = ATNR_PHYSICAL+1; i < NROFATTACKS; i++)
1279  if (op->resist[i])
1280  return 1;
1281 
1282  /* Physical protection is expected on some item types, so they should
1283  * not be considered magical.
1284  */
1285  if (op->resist[ATNR_PHYSICAL]
1286  && op->type != HELMET
1287  && op->type != SHIELD
1288  && op->type != BOOTS
1289  && op->type != GLOVES
1290  && op->type != ARMOUR)
1291  return 1;
1292 
1293  /* power crystal, spellbooks, and scrolls are always magical. */
1294  if (op->magic
1295  || op->type == POWER_CRYSTAL
1296  || op->type == SPELLBOOK
1297  || op->type == SCROLL
1298  || op->type == GIRDLE)
1299  return 1;
1300 
1301  /* Check to see if it increases/decreases any stats */
1302  for (i = 0; i < NUM_STATS; i++)
1303  if (get_attr_value(&(op->stats), i) != 0)
1304  return 1;
1305 
1306  /* If it doesn't fall into any of the above categories, must
1307  * be non magical.
1308  */
1309  return 0;
1310 }
1311 
1331 int is_identifiable_type(const object *op) {
1332  /* Special case -- skill tools don't have an associated identification
1333  * skill but still need IDing. TODO: we should probably have per-tool ID
1334  * skills, e.g. thievery for lockpicks and thaumaturgy for talismans, but
1335  * currently there's no good way to do this because the identifyskill is
1336  * tied to the itemtype rather than to the arch. */
1337  if (op->type == SKILL_TOOL) return true;
1338 
1339  /* Sometimes an itemtype has no associated typedata?! */
1340  const typedata *td = get_typedata(op->type);
1341  return td && td->identifyskill;
1342 }
1343 
1355 int is_identified(const object *op) {
1356  return !is_identifiable_type(op) || QUERY_FLAG(op, FLAG_IDENTIFIED);
1357 }
1358 
1364  // Make sure identified objects stack correctly
1368 
1369  // The rest only apply to identifiable items. We don't want, e.g. shop
1370  // floors to show up as 'damned'.
1371  if (!is_identifiable_type(op))
1372  return;
1373 
1374  if (QUERY_FLAG(op, FLAG_CURSED) || QUERY_FLAG(op, FLAG_DAMNED))
1376 
1377  if (QUERY_FLAG(op, FLAG_BLESSED))
1379 
1380  sstring key;
1381 
1382  key = object_get_value(op, "identified_face");
1383  if (key != NULL) {
1384  op->face = try_find_face(key, op->face);
1385  /* if the face is defined, clean the animation, because else
1386  * the face can be lost ; if an animation is defined, it'll be
1387  * processed later on */
1390  op->anim_speed = 0;
1391  op->animation = 0;
1392  object_set_value(op, "identified_face", NULL, 0);
1393  }
1394 
1395  if (object_get_value(op, "identified_anim_random") != NULL) {
1397  object_set_value(op, "identified_anim_random", NULL, 0);
1398  }
1399 
1400  key = object_get_value(op, "identified_anim_speed");
1401  if (key != NULL) {
1402  op->anim_speed = atoi(key);
1403  op->last_anim = 1;
1404  object_set_value(op, "identified_anim_speed", NULL, 0);
1405  }
1406 
1407  key = object_get_value(op, "identified_animation");
1408  if (key != NULL) {
1409  Animations *anim = try_find_animation(key);
1410  if (anim) {
1411  op->animation = anim;
1412  if (!QUERY_FLAG(op, FLAG_IS_TURNABLE))
1413  SET_FLAG(op, FLAG_ANIMATE);
1414  animate_object(op, op->facing);
1415  }
1416  object_set_value(op, "identified_animation", NULL, 0);
1417  }
1418 
1419  key = object_get_value(op, "identified_name");
1420  if (key != NULL) {
1421  FREE_AND_COPY(op->name, key);
1422  object_set_value(op, "identified_name", NULL, 0);
1423  }
1424  key = object_get_value(op, "identified_name_pl");
1425  if (key != NULL) {
1426  FREE_AND_COPY(op->name_pl, key);
1427  object_set_value(op, "identified_name_pl", NULL, 0);
1428  }
1429 }
1430 
1444 object *identify(object *op) {
1445  object *pl, *op1;
1446 
1449 
1450  if (op->type == POTION) {
1451  if (op->inv && op->randomitems) {
1452  if (op->title)
1453  free_string(op->title);
1454  op->title = add_refcount(op->inv->name);
1455  } else if (op->arch) {
1456  free_string(op->name);
1457  op->name = add_refcount(op->arch->clone.name);
1458  free_string(op->name_pl);
1459  op->name_pl = add_refcount(op->arch->clone.name_pl);
1460  }
1461  }
1462 
1463  if (op->map) {
1464  /* If the object is on a map, make sure we update its face.
1465  * Also send name and such information to a player standing on it.
1466  */
1467  object *player = map_find_by_type(op->map, op->x, op->y, PLAYER);
1468 
1470  op1 = object_merge(op, GET_MAP_TOP(op->map, op->x, op->y));
1471  if (op1) op = op1;
1472 
1473  if (player)
1475 
1476  } else if (op->env) {
1477  /* If the object is in an inventory, merge it.
1478  */
1479  pl = object_get_player_container(op->env);
1480  op1 = object_merge(op, op->env->inv);
1481  if (op1) op = op1;
1482 
1483  if (pl)
1484  /* Item is directly in the player's inventory
1485  * A lot of the values can change from an update - might as well send
1486  * it all.
1487  */
1488  esrv_update_item(UPD_ALL, pl, op);
1489  else if (op->env->map &&
1490  (pl = map_find_by_type(op->env->map, op->env->x, op->env->y, PLAYER))
1491  && (pl->container == op->env)) {
1492  /* The item is in a container (on the ground) opened by a player, update */
1494  }
1495  }
1496  /* There is a third option where we do nothing extra:
1497  * identifying a created item as it is created. */
1498  return op;
1499 }
1500 
1505 uint64_t price_base(const object *obj) {
1506  // When there are zero objects, there is really one.
1507  const int number = NROF(obj);
1508  const bool identified = is_identified(obj);
1509  uint64_t val = (uint64_t)obj->value * number;
1510 
1511  // Objects with price adjustments skip the rest of the calculations.
1512  const char *key = object_get_value(obj, "price_adjustment");
1513  if (key != NULL) {
1514  float ratio = atof(key);
1515  return val * ratio;
1516  }
1517 
1518  // Money and gems have fixed prices at shops.
1519  if (obj->type == MONEY || obj->type == GEM) {
1520  return val;
1521  }
1522 
1523  // Assume that good items, e.g. artifacts have that priced into their
1524  // value. Bad items may not.
1525  if (calc_item_enhancement(obj) < 0) {
1526  return 0;
1527  }
1528 
1529  // If unidentified, price item based on its archetype.
1530  if (!identified && obj->arch) {
1531  val = obj->arch->clone.value * number;
1532  }
1533 
1539  if (QUERY_FLAG(obj, FLAG_BLESSED)){
1540  val *= 1.15;
1541  } else if (QUERY_FLAG(obj, FLAG_CURSED)) {
1542  val *= 0.8;
1543  } else if (QUERY_FLAG(obj, FLAG_DAMNED)) {
1544  val *= 0.6;
1545  }
1546 
1547  // If an item is identified to have an enchantment above its archetype
1548  // enchantment, increase price exponentially.
1549  if (obj->arch != NULL && identified) {
1550  int diff = obj->magic - obj->arch->clone.magic;
1551  val *= pow(1.15, diff);
1552  }
1553 
1554  // FIXME: Is the 'baseline' 50 charges per wand?
1555  if (obj->type == WAND) {
1556  val *= obj->stats.food / 50.0;
1557  }
1558 
1559  /* we need to multiply these by 4.0 to keep buy costs roughly the same
1560  * (otherwise, you could buy a potion of charisma for around 400 pp.
1561  * Arguable, the costs in the archetypes should be updated to better
1562  * reflect values (potion charisma list for 1250 gold)
1563  */
1564  val *= 4; // FIXME
1565 
1566  return val;
1567 }
player::gen_sp
int16_t gen_sp
Bonuses to regeneration speed of sp.
Definition: player.h:129
FLAG_IS_TURNABLE
#define FLAG_IS_TURNABLE
Object can change face with direction.
Definition: define.h:243
CLASS
@ CLASS
Object for applying character class modifications to someone.
Definition: object.h:143
object::name_pl
sstring name_pl
The plural name of the object.
Definition: object.h:323
FLAG_USE_BOW
#define FLAG_USE_BOW
(Monster) can apply and fire bows
Definition: define.h:280
living::exp
int64_t exp
Experience.
Definition: living.h:47
TRIGGER
@ TRIGGER
Definition: object.h:134
MIMIC
@ MIMIC
Definition: object.h:254
FLAG_KNOWN_BLESSED
#define FLAG_KNOWN_BLESSED
Item is known to be blessed.
Definition: define.h:357
PLAYER
@ PLAYER
Definition: object.h:112
global.h
UPD_FACE
#define UPD_FACE
Definition: newclient.h:321
CF_HANDLE
@ CF_HANDLE
Definition: object.h:213
stringbuffer_length
size_t stringbuffer_length(StringBuffer *sb)
Return the current length of the buffer.
Definition: stringbuffer.cpp:213
MAP
@ MAP
Definition: object.h:130
FLAG_USE_RANGE
#define FLAG_USE_RANGE
(Monster) can apply and use range items
Definition: define.h:279
NUM_BODY_LOCATIONS
#define NUM_BODY_LOCATIONS
Number of body locations.
Definition: object.h:15
MONSTER
@ MONSTER
A real, living creature.
Definition: object.h:205
BOW
@ BOW
Definition: object.h:123
BRACERS
@ BRACERS
Definition: object.h:222
GET_MAP_TOP
#define GET_MAP_TOP(M, X, Y)
Gets the top object on a map.
Definition: map.h:175
CLOSE_CON
@ CLOSE_CON
Eneq((at)csd.uu.se): Id for close_container archetype.
Definition: object.h:234
FABS
#define FABS(x)
Decstations have trouble with fabs()...
Definition: define.h:22
FLAG_ANIMATE
#define FLAG_ANIMATE
The object looks at archetype for faces.
Definition: define.h:229
ARMOUR_IMPROVER
@ ARMOUR_IMPROVER
Definition: object.h:237
SYMPTOM
@ SYMPTOM
Definition: object.h:250
object::path_attuned
uint32_t path_attuned
Paths the object is attuned to.
Definition: object.h:353
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:58
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:369
FLAG_HITBACK
#define FLAG_HITBACK
Object will hit back when hit.
Definition: define.h:254
FLESH
@ FLESH
animal 'body parts' -b.t.
Definition: object.h:192
player::digestion
int16_t digestion
Any bonuses/penalties to digestion.
Definition: player.h:127
ENCOUNTER
@ ENCOUNTER
Definition: object.h:187
FLAG_USE_SCROLL
#define FLAG_USE_SCROLL
(Monster) can read scroll
Definition: define.h:278
SK_ALCHEMY
@ SK_ALCHEMY
Alchemy.
Definition: skills.h:25
player
One player.
Definition: player.h:107
GLOVES
@ GLOVES
Definition: object.h:218
object::inv
object * inv
Pointer to the first object in the inventory.
Definition: object.h:298
GIRDLE
@ GIRDLE
Definition: object.h:228
player::gen_grace
int16_t gen_grace
Bonuses to regeneration speed of grace.
Definition: player.h:131
safe_strcat
void safe_strcat(char *dest, const char *orig, size_t *curlen, size_t maxlen)
Simple function we use below to keep adding to the same string but also make sure we don't overwrite ...
Definition: porting.cpp:202
BUTTON
@ BUTTON
Definition: object.h:212
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:371
treasurelist::items
treasure * items
Items in this list, linked.
Definition: treasure.h:92
TRIGGER_PEDESTAL
@ TRIGGER_PEDESTAL
Definition: object.h:139
KEY
@ KEY
Definition: object.h:132
object_merge
object * object_merge(object *op, object *top)
This function goes through all objects below and including top, and merges op to the first matching o...
Definition: object.cpp:2036
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
Definition: stringbuffer.cpp:138
object::item_power
int8_t item_power
Power rating of the object.
Definition: object.h:372
FLAG_FRIENDLY
#define FLAG_FRIENDLY
Will help players.
Definition: define.h:233
object::arch
struct archetype * arch
Pointer to archetype.
Definition: object.h:424
stringbuffer_new
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
Definition: stringbuffer.cpp:57
bits_set
static int bits_set(uint32_t x)
Definition: item.cpp:221
SHOP_FLOOR
@ SHOP_FLOOR
Definition: object.h:188
object::speed
float speed
Frequency of object 'moves' relative to server tick rate.
Definition: object.h:337
if
if(!(yy_init))
Definition: loader.cpp:36440
GEM
@ GEM
Definition: object.h:172
FLAG_LIFESAVE
#define FLAG_LIFESAVE
Saves a players' life once, then destr.
Definition: define.h:292
TRAP
@ TRAP
Definition: object.h:246
object::x
int16_t x
Definition: object.h:335
ARMOUR
@ ARMOUR
Definition: object.h:125
FLAG_USE_ARMOUR
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
Definition: define.h:282
object::map
struct mapstruct * map
Pointer to the map in which this object is present.
Definition: object.h:305
WEAPON
@ WEAPON
Definition: object.h:124
TIMED_GATE
@ TIMED_GATE
Definition: object.h:133
typedata::identifyskill
int identifyskill
Skill used to identify this object class.
Definition: define.h:93
AMULET
@ AMULET
Definition: object.h:144
CHECK_INV
@ CHECK_INV
b.t.
Definition: object.h:174
FLAG_BEEN_APPLIED
#define FLAG_BEEN_APPLIED
Object was ever applied, for identification purposes.
Definition: define.h:310
TREASURE
@ TREASURE
Definition: object.h:115
SKILL
@ SKILL
Also see SKILL_TOOL (74) below.
Definition: object.h:148
get_power_from_ench
int get_power_from_ench(int ench)
Definition: item.cpp:213
FLAG_XRAYS
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:287
ARMOUR_SPELLS
#define ARMOUR_SPELLS(xyz)
Definition: define.h:452
RUNE
@ RUNE
Definition: object.h:245
FLAG_MAKE_INVIS
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
Definition: define.h:315
esrv_update_item
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
Definition: item.cpp:414
CREATOR
@ CREATOR
Definition: object.h:147
TRANSPORT
@ TRANSPORT
see doc/Developers/objects
Definition: object.h:113
ATNR_PHYSICAL
#define ATNR_PHYSICAL
Definition: attack.h:47
POTION_RESIST_EFFECT
@ POTION_RESIST_EFFECT
A force, holding the effect of a resistance potion.
Definition: object.h:230
FLOOR
@ FLOOR
Floor tile -> native layer 0.
Definition: object.h:191
ARMOUR_SPEED
#define ARMOUR_SPEED(xyz)
Definition: define.h:451
SIGN
@ SIGN
Definition: object.h:216
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:15
FLAG_STEALTH
#define FLAG_STEALTH
Will wake monsters with less range.
Definition: define.h:299
TRIGGER_BUTTON
@ TRIGGER_BUTTON
Definition: object.h:137
FLAG_CAST_SPELL
#define FLAG_CAST_SPELL
(Monster) can learn and cast spells
Definition: define.h:277
object::title
sstring title
Of foo, etc.
Definition: object.h:325
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:361
POWER_CRYSTAL
@ POWER_CRYSTAL
Definition: object.h:247
FLAG_NO_SKILL_IDENT
#define FLAG_NO_SKILL_IDENT
If set, item cannot be identified w/ a skill.
Definition: define.h:322
buf
StringBuffer * buf
Definition: readable.cpp:1565
POISONING
@ POISONING
Definition: object.h:223
object::resist
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:351
item_types
static const typedata item_types[]
The following is a large table of item types, the fields are: item number, item name,...
Definition: item.cpp:80
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
FLAG_KNOWN_CURSED
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
Definition: define.h:307
object::path_denied
uint32_t path_denied
Paths the object is denied access to.
Definition: object.h:355
short_stat_name
const char *const short_stat_name[NUM_STATS]
Short name of stats.
Definition: living.cpp:194
object::carrying
int32_t carrying
How much weight this object contains.
Definition: object.h:377
TRIGGER_MARKER
@ TRIGGER_MARKER
inserts an invisible, weightless force into a player with a specified string WHEN TRIGGERED.
Definition: object.h:158
typedata
Link an object type with skill needed to identify, and general name.
Definition: define.h:89
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:335
object::path_repelled
uint32_t path_repelled
Paths the object is repelled from.
Definition: object.h:354
FLAG_SEE_INVISIBLE
#define FLAG_SEE_INVISIBLE
Will see invisible player.
Definition: define.h:240
CLOAK
@ CLOAK
Definition: object.h:209
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
Definition: stringbuffer.cpp:76
object_update
void object_update(object *op, int action)
object_update() updates the array which represents the map.
Definition: object.cpp:1419
object::contr
struct player * contr
Pointer to the player which control this object.
Definition: object.h:284
FMT64
#define FMT64
Definition: compat.h:16
NROF
static uint32_t NROF(const object *const ob)
Returns ob->nrof, unless it is 0, in which case return 1.
Definition: object.h:625
HELMET
@ HELMET
Definition: object.h:141
POISON
@ POISON
Definition: object.h:118
add_refcount
sstring add_refcount(sstring str)
Like add_string(), but the string is already a shared string.
Definition: shstr.cpp:224
FLAG_KNOWN_MAGICAL
#define FLAG_KNOWN_MAGICAL
The object is known to be magical.
Definition: define.h:306
DEEP_SWAMP
@ DEEP_SWAMP
Definition: object.h:241
describe_resistance
StringBuffer * describe_resistance(const object *op, int newline, int use_media_tags, StringBuffer *buf)
Generates the visible naming for resistances.
Definition: item.cpp:377
object::anim_speed
uint8_t anim_speed
Ticks between animation-frames.
Definition: object.h:429
SK_JEWELER
@ SK_JEWELER
Jeweler.
Definition: skills.h:24
MARKER
@ MARKER
inserts an invisible, weightless force into a player with a specified string.
Definition: object.h:163
get_typedata
const typedata * get_typedata(int itemtype)
Definition: item.cpp:328
FLAG_UNPAID
#define FLAG_UNPAID
Object hasn't been paid for yet.
Definition: define.h:223
query_name
void query_name(const object *op, char *buf, size_t size)
Describes an item.
Definition: item.cpp:593
SAVEBED
@ SAVEBED
Definition: object.h:224
map_find_by_type
object * map_find_by_type(mapstruct *m, int x, int y, uint8_t type)
Searches for any objects with a matching type variable at the given map and coordinates.
Definition: object.cpp:3130
LIGHTABLE
@ LIGHTABLE
Definition: object.h:255
POTION
@ POTION
Definition: object.h:116
BUILDER
@ BUILDER
Generic item builder, see subtypes below.
Definition: object.h:251
SK_LITERACY
@ SK_LITERACY
Literacy.
Definition: skills.h:27
archetype::clone
object clone
An object from which to do object_copy()
Definition: object.h:487
describe_spellpath_attenuation
StringBuffer * describe_spellpath_attenuation(const char *attenuation, int value, StringBuffer *buf)
Describe the specified path attenuation.
Definition: utils.cpp:507
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
FLAG_MONSTER
#define FLAG_MONSTER
Will attack players.
Definition: define.h:232
FLAG_CAN_USE_SKILL
#define FLAG_CAN_USE_SKILL
The monster can use skills.
Definition: define.h:308
SK_BOWYER
@ SK_BOWYER
Bowyer.
Definition: skills.h:23
ROD
@ ROD
Definition: object.h:114
CONTAINER
@ CONTAINER
Definition: object.h:236
FLAG_UNAGGRESSIVE
#define FLAG_UNAGGRESSIVE
Monster doesn't attack players.
Definition: define.h:259
INORGANIC
@ INORGANIC
metals, minerals, dragon scales
Definition: object.h:193
object::move_type
MoveType move_type
Type of movement this object uses.
Definition: object.h:436
object_find_by_type_and_name
object * object_find_by_type_and_name(const object *who, int type, const char *name)
Find object in inventory by type and name.
Definition: object.cpp:4093
query_short_name
void query_short_name(const object *op, char *buf, size_t size)
query_short_name(object) is similar to query_name(), but doesn't contain any information about object...
Definition: item.cpp:518
LOCKED_DOOR
@ LOCKED_DOOR
Definition: object.h:128
ring_desc
static StringBuffer * ring_desc(const object *op, int use_media_tags, StringBuffer *buf)
Describes a ring or amulet, or a skill.
Definition: item.cpp:443
FLAG_CLIENT_ANIM_RANDOM
#define FLAG_CLIENT_ANIM_RANDOM
Client animate this, randomized.
Definition: define.h:228
PLAYERMOVER
@ PLAYERMOVER
Definition: object.h:145
object::face
const Face * face
Face with colors.
Definition: object.h:341
describe_attacktype
StringBuffer * describe_attacktype(const char *attack, int value, StringBuffer *buf)
Describe the specified attack type.
Definition: utils.cpp:538
change_resist_msg
const char *const change_resist_msg[NROFATTACKS]
These are the descriptions of the resistances displayed when a player puts on/takes off an item.
Definition: init.cpp:70
object::last_eat
int32_t last_eat
How long since we last ate.
Definition: object.h:366
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:1355
SPECIAL_KEY
@ SPECIAL_KEY
Definition: object.h:129
HOLE
@ HOLE
Definition: object.h:214
object::last_anim
uint8_t last_anim
Last sequence used to draw face.
Definition: object.h:430
PEACEMAKER
@ PEACEMAKER
Object owned by a player which can convert a monster into a peaceful being incapable of attack.
Definition: object.h:169
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:206
CONVERTER
@ CONVERTER
Definition: object.h:221
object::type
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
SKILLSCROLL
@ SKILLSCROLL
can add a skill to player's inventory -bt.
Definition: object.h:239
living::dam
int16_t dam
How much damage this object does when hitting.
Definition: living.h:46
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::magic
int8_t magic
Any magical bonuses to this item.
Definition: object.h:358
UPD_FLAGS
#define UPD_FLAGS
Definition: newclient.h:319
LAMP
@ LAMP
Lamp.
Definition: object.h:206
calc_item_enhancement
int calc_item_enhancement(const object *op)
Definition: item.cpp:226
living::food
int32_t food
How much food in stomach.
Definition: living.h:48
GOLEM
@ GOLEM
Definition: object.h:150
FLAG_REFL_MISSILE
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:260
body_locations
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
The ordering of this is actually doesn't make a difference However, for ease of use,...
Definition: item.cpp:56
MOOD_FLOOR
@ MOOD_FLOOR
b.t.
Definition: object.h:175
ARROW
@ ARROW
Definition: object.h:122
living::sp
int16_t sp
Spell points.
Definition: living.h:42
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
Definition: stringbuffer.cpp:95
BOOK
@ BOOK
Definition: object.h:119
object::facing
int8_t facing
Object is oriented/facing that way.
Definition: object.h:345
object::animation
const Animations * animation
Animation of this item, NULL if not animated.
Definition: object.h:428
RING
@ RING
Definition: object.h:190
BLINDNESS
@ BLINDNESS
Definition: object.h:152
FLAG_INV_LOCKED
#define FLAG_INV_LOCKED
Item will not be dropped from inventory.
Definition: define.h:316
get_typedata_by_name
const typedata * get_typedata_by_name(const char *name)
Definition: item.cpp:348
CLOCK
@ CLOCK
Definition: object.h:120
resist_plus
const char *const resist_plus[NROFATTACKS]
Attack types to show to the player.
Definition: init.cpp:49
FLAG_USE_WEAPON
#define FLAG_USE_WEAPON
(Monster) can wield weapons
Definition: define.h:283
strlcpy
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
Definition: porting.cpp:222
SHOP_MAT
@ SHOP_MAT
Definition: object.h:189
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Describes an item, in all its details.
Definition: item.cpp:953
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:294
item_types_size
static const int item_types_size
Number of items in item_types array.
Definition: item.cpp:195
living::wc
int8_t wc
Weapon Class, lower WC increases probability of hitting.
Definition: living.h:37
try_find_animation
Animations * try_find_animation(const char *name)
Definition: assets.cpp:282
FLAG_SEE_IN_DARK
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:324
StringBuffer
A buffer that will be expanded as content is added to it.
Definition: stringbuffer.cpp:25
FLAG_DAMNED
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:304
EXIT
@ EXIT
Definition: object.h:186
MAGIC_EAR
@ MAGIC_EAR
Definition: object.h:136
player::gen_hp
int16_t gen_hp
Bonuses to regeneration speed of hp.
Definition: player.h:128
llevInfo
@ llevInfo
Information.
Definition: logger.h:12
SK_WOODSMAN
@ SK_WOODSMAN
Woodsman.
Definition: skills.h:40
object::slaying
sstring slaying
Which race to do double damage to.
Definition: object.h:327
object::glow_radius
int8_t glow_radius
indicates the glow radius of the object
Definition: object.h:374
spells.h
query_weight
void query_weight(const object *op, char *buf, size_t size)
Formats the item's weight.
Definition: item.cpp:420
object::name
sstring name
The name of the object, obviously...
Definition: object.h:319
BATTLEGROUND
@ BATTLEGROUND
battleground, by Andreas Vogl
Definition: object.h:168
WEAPON_SPEED
#define WEAPON_SPEED(xyz)
Definition: define.h:453
is_dragon_pl
int is_dragon_pl(const object *op)
Checks if player is a dragon.
Definition: player.cpp:123
FLAG_REFLECTING
#define FLAG_REFLECTING
Object reflects from walls (lightning)
Definition: define.h:249
GRIMREAPER
@ GRIMREAPER
Definition: object.h:135
EARTHWALL
@ EARTHWALL
Definition: object.h:149
DUPLICATOR
@ DUPLICATOR
Duplicator/multiplier object.
Definition: object.h:207
is_magical
int is_magical(const object *op)
Checks whether object is magical.
Definition: item.cpp:1234
DISEASE
@ DISEASE
Definition: object.h:249
FIREWALL
@ FIREWALL
Definition: object.h:173
is_identifiable_type
int is_identifiable_type(const object *op)
Return true if this item's type is one that cares about whether or not it's been identified – e....
Definition: item.cpp:1331
TRIGGER_ALTAR
@ TRIGGER_ALTAR
Definition: object.h:138
PLAYER_CHANGER
@ PLAYER_CHANGER
Definition: object.h:167
object::env
object * env
Pointer to the object which is the environment.
Definition: object.h:301
sstring
const typedef char * sstring
Definition: sstring.h:2
LIGHTER
@ LIGHTER
Definition: object.h:195
FLAG_UNDEAD
#define FLAG_UNDEAD
Monster is undead.
Definition: define.h:257
Animations
This represents one animation.
Definition: face.h:25
animate_object
void animate_object(object *op, int dir)
Updates the face-variable of an object.
Definition: anim.cpp:44
MATERIAL
@ MATERIAL
Material for building.
Definition: object.h:253
FLAG_APPLIED
#define FLAG_APPLIED
Object is ready for use by living.
Definition: define.h:222
SPINNER
@ SPINNER
Definition: object.h:210
SPELL_EFFECT
@ SPELL_EFFECT
Definition: object.h:220
SKILL_TOOL
@ SKILL_TOOL
Allows the use of a skill.
Definition: object.h:194
object_get_value
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.cpp:4331
SHOP_INVENTORY
@ SHOP_INVENTORY
Mark Wedel (mark@pyramid.com) Shop inventories.
Definition: object.h:243
PEDESTAL
@ PEDESTAL
Definition: object.h:126
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:370
living::ac
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
Definition: living.h:38
atnr_is_dragon_enabled
int atnr_is_dragon_enabled(int attacknr)
Determine if the attacktype represented by the specified attack-number is enabled for dragon players.
Definition: player.cpp:104
enc_to_item_power
static const int enc_to_item_power[]
This curve may be too steep.
Definition: item.cpp:206
resist_color
const char *const resist_color[NROFATTACKS]
Colors to add to the resistances for media tags.
Definition: init.cpp:61
object_give_identified_properties
void object_give_identified_properties(object *op)
Ensure op has all its "identified" properties set.
Definition: item.cpp:1363
UP_OBJ_FACE
#define UP_OBJ_FACE
Only thing that changed was the face.
Definition: object.h:533
MOVE_SWIM
#define MOVE_SWIM
Swimming object.
Definition: define.h:387
DEAD_OBJECT
@ DEAD_OBJECT
Definition: object.h:161
FLAG_CLIENT_ANIM_SYNC
#define FLAG_CLIENT_ANIM_SYNC
Let client animate this, synchronized.
Definition: define.h:227
DIRECTOR
@ DIRECTOR
Definition: object.h:227
CORPSE
@ CORPSE
Definition: object.h:248
MIN_ACTIVE_SPEED
#define MIN_ACTIVE_SPEED
Cut off point of when an object is put on the active list or not.
Definition: define.h:623
MOVE_FLY_HIGH
#define MOVE_FLY_HIGH
High flying object.
Definition: define.h:385
UPD_NAME
#define UPD_NAME
Definition: newclient.h:322
object::randomitems
struct treasurelist * randomitems
Items to be generated.
Definition: object.h:395
SK_SMITHERY
@ SK_SMITHERY
Smithery.
Definition: skills.h:22
FOOD
@ FOOD
Definition: object.h:117
object::container
object * container
Current container being used.
Definition: object.h:299
ALTAR
@ ALTAR
Definition: object.h:127
DOOR
@ DOOR
Definition: object.h:131
try_find_face
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:290
SK_THAUMATURGY
@ SK_THAUMATURGY
Thaumaturgy.
Definition: skills.h:48
MOVE_FLY_LOW
#define MOVE_FLY_LOW
Low flying object.
Definition: define.h:384
DRINK
@ DRINK
Definition: object.h:162
UPD_ALL
#define UPD_ALL
Definition: newclient.h:326
WALL
@ WALL
Wall.
Definition: object.h:196
WEAPON_IMPROVER
@ WEAPON_IMPROVER
Definition: object.h:238
SCROLL
@ SCROLL
Definition: object.h:226
object::nrof
uint32_t nrof
Number of objects.
Definition: object.h:342
describe_monster
StringBuffer * describe_monster(const object *op, int use_media_tags, StringBuffer *buf)
Describes a monster.
Definition: item.cpp:779
body_locations_struct
One body location.
Definition: object.h:22
living::grace
int16_t grace
Grace.
Definition: living.h:44
query_base_name
void query_base_name(const object *op, int plural, char *buf, size_t size)
Query a short name for the item.
Definition: item.cpp:691
object::stats
living stats
Str, Con, Dex, etc.
Definition: object.h:378
treasure
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
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:4484
FLAG_USE_RING
#define FLAG_USE_RING
(Monster) can use rings, boots, gauntlets, etc
Definition: define.h:284
get_attr_value
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
Definition: living.cpp:313
FLAG_IDENTIFIED
#define FLAG_IDENTIFIED
Item is identifiable (e.g.
Definition: define.h:248
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
BOOTS
@ BOOTS
Definition: object.h:217
IDENTIFY_ALTAR
@ IDENTIFY_ALTAR
Definition: object.h:242
SPELL
@ SPELL
Definition: object.h:219
SHIELD
@ SHIELD
Definition: object.h:140
object::attacktype
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:352
TELEPORTER
@ TELEPORTER
Definition: object.h:146
object_get_player_container
object * object_get_player_container(object *op)
Finds the player carrying an object.
Definition: object.cpp:592
living.h
THROWN_OBJ
@ THROWN_OBJ
Definition: object.h:151
SPELLBOOK
@ SPELLBOOK
Definition: object.h:208
NUM_STATS
@ NUM_STATS
Number of statistics.
Definition: living.h:18
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
FORCE
@ FORCE
Definition: object.h:229
HOLY_ALTAR
@ HOLY_ALTAR
Definition: object.h:166
TRAPDOOR
@ TRAPDOOR
Definition: object.h:215
DETECTOR
@ DETECTOR
peterm: detector is an object which notices the presense of another object and is triggered like butt...
Definition: object.h:154
GOD
@ GOD
Definition: object.h:153
MISC_OBJECT
@ MISC_OBJECT
misc.
Definition: object.h:198
MONEY
@ MONEY
Definition: object.h:142
FLAG_REFL_SPELL
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
Definition: define.h:262
GATE
@ GATE
Definition: object.h:211
identify
object * identify(object *op)
Identifies an item.
Definition: item.cpp:1444