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:
546  case POTION:
548  if (!op->title && (op->inv)) {
549  safe_strcat(buf, " of ", &len, size);
550  safe_strcat(buf, op->inv->name, &len, size);
551  }
552  if (op->type != SPELLBOOK) {
553  snprintf(buf+len, size-len, " (lvl %d)", op->level);
554  len += strlen(buf+len);
555  }
556  }
557  break;
558 
559  case SKILL:
560  case AMULET:
561  case RING:
562  if (!op->title) {
563  /* If ring has a title, full description isn't so useful */
564  char* desc;
565 
566  desc = stringbuffer_finish(ring_desc(op, 0, NULL));
567  if (desc[0]) {
568  safe_strcat(buf, " ", &len, size);
569  safe_strcat(buf, desc, &len, size);
570  }
571  free(desc);
572  }
573  break;
574 
575  default:
576  if (op->magic
577  && (QUERY_FLAG(op, FLAG_BEEN_APPLIED) || is_identified(op))) {
578  snprintf(buf+len, size-len, " %+d", op->magic);
579  len += strlen(buf+len);
580  }
581  }
582 }
583 
594 void query_name(const object *op, char *buf, size_t size) {
595  size_t len = 0;
596 
597  buf[0] = '\0';
598  /*
599  * Since len is initialized to zero, but is not changed
600  * up to this point, I see no reason to have buf+len and size-len;
601  * buf and size should suffice, since we're just adding and
602  * subtracting zero here, anyway.
603  *
604  * SilverNexus 2014-06-04
605  */
606  query_short_name(op, buf, size);
607  len = strlen(buf);
608 
609  if (QUERY_FLAG(op, FLAG_INV_LOCKED))
610  safe_strcat(buf, " *", &len, size);
611 
612  if (QUERY_FLAG(op, FLAG_KNOWN_CURSED)) {
613  if (QUERY_FLAG(op, FLAG_DAMNED))
614  safe_strcat(buf, " (damned)", &len, size);
615  else if (QUERY_FLAG(op, FLAG_CURSED))
616  safe_strcat(buf, " (cursed)", &len, size);
617  }
619  safe_strcat(buf, " (blessed)", &len, size);
620 
621  /* Basically, if the object is known magical (detect magic spell on it),
622  * and it isn't identified, print out the fact that
623  * it is magical. Assume that the detect magical spell will only set
624  * KNOWN_MAGICAL if the item actually is magical.
625  *
626  * Changed in V 0.91.4 - still print that the object is magical even
627  * if it has been applied. Equipping an item does not tell full
628  * abilities, especially for artifact items.
629  */
631  safe_strcat(buf, " (magic)", &len, size);
632 
633  if (QUERY_FLAG(op, FLAG_APPLIED)) {
634  switch (op->type) {
635  case BOW:
636  case WAND:
637  case ROD:
638  safe_strcat(buf, " (readied)", &len, size);
639  break;
640 
641  case WEAPON:
642  safe_strcat(buf, " (wielded)", &len, size);
643  break;
644 
645  case ARMOUR:
646  case HELMET:
647  case SHIELD:
648  case RING:
649  case BOOTS:
650  case GLOVES:
651  case AMULET:
652  case GIRDLE:
653  case BRACERS:
654  case CLOAK:
655  safe_strcat(buf, " (worn)", &len, size);
656  break;
657 
658  case CONTAINER:
659  safe_strcat(buf, " (active)", &len, size);
660  break;
661 
662  case SKILL:
663  default:
664  safe_strcat(buf, " (applied)", &len, size);
665  }
666  }
667  // NO_SKILL_IDENT is set when identification fails or when the book is read. So the book is read only when it is
668  // both identified and NO_SKILL_IDENT.
670  safe_strcat(buf, " (read)", &len, size);
671  if (QUERY_FLAG(op, FLAG_UNPAID))
672  safe_strcat(buf, " (unpaid)", &len, size);
673 }
674 
692 void query_base_name(const object *op, int plural, char *buf, size_t size) {
693  size_t len;
694 
695  if ((!plural && !op->name)
696  || (plural && !op->name_pl)) {
697  strncpy(buf, "(null)", size);
698  return;
699  }
700 
701  if (!op->nrof && !op->weight && !op->title && !is_magical(op)) {
702  strncpy(buf, op->name, size); /* To speed things up (or make things slower?) */
703  return;
704  }
705 
706  buf[0] = '\0';
707 
708  strlcpy(buf, plural ? op->name_pl : op->name, size);
709  len = strlen(buf);
710 
711  if (op->title && QUERY_FLAG(op, FLAG_IDENTIFIED)) {
712  safe_strcat(buf, " ", &len, size);
713  safe_strcat(buf, op->title, &len, size);
714  }
715 
716  switch (op->type) {
717  case SPELLBOOK:
718  case SCROLL:
719  case WAND:
720  case ROD:
721  case POTION:
723  if (!op->title && (op->inv)) {
724  safe_strcat(buf, " of ", &len, size);
725  // If, for some reason, a spell on a scroll were to stop existing as an arch,
726  // we would get here. The scroll will hold an inventory object with no name.
727  // So, to prevent a segfault, only print the spell name if it exists.
728  if (op->inv->name)
729  safe_strcat(buf, op->inv->name, &len, size);
730  // scroll of nothing seems like a good replacement for when the name does not exist.
731  else
732  safe_strcat(buf, "nothing", &len, size);
733  }
734  if (op->type != SPELLBOOK) {
735  snprintf(buf+len, size-len, " (lvl %d)", op->level);
736  len += strlen(buf+len);
737  }
738  }
739  break;
740 
741  case SKILL:
742  case AMULET:
743  case RING:
744  if (!op->title) {
745  /* If ring has a title, full description isn't so useful */
746  char* s;
747 
748  s = stringbuffer_finish(ring_desc(op, 0, NULL));
749  if (s[0]) {
750  safe_strcat(buf, " ", &len, size);
751  safe_strcat(buf, s, &len, size);
752  }
753  free(s);
754  }
755  break;
756 
757  default:
758  if (op->magic
759  && (QUERY_FLAG(op, FLAG_BEEN_APPLIED) || is_identified(op))) {
760  snprintf(buf+strlen(buf), size-strlen(buf), " %+d", op->magic);
761  }
762  }
763 }
764 
781 StringBuffer *describe_monster(const object *op, int use_media_tags, StringBuffer *buf) {
782  assert(op != NULL);
783  assert(QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER);
784 
785  if (buf == NULL)
786  buf = stringbuffer_new();
787 
788  /* Note that the resolution this provides for players really isn't
789  * very good. Any player with a speed greater than .67 will
790  * fall into the 'lightning fast movement' category.
791  */
792  if (FABS(op->speed) > MIN_ACTIVE_SPEED) {
793  switch ((int)((FABS(op->speed))*15)) {
794  case 0:
795  stringbuffer_append_string(buf, "(very slow movement)");
796  break;
797 
798  case 1:
799  stringbuffer_append_string(buf, "(slow movement)");
800  break;
801 
802  case 2:
803  stringbuffer_append_string(buf, "(normal movement)");
804  break;
805 
806  case 3:
807  case 4:
808  stringbuffer_append_string(buf, "(fast movement)");
809  break;
810 
811  case 5:
812  case 6:
813  stringbuffer_append_string(buf, "(very fast movement)");
814  break;
815 
816  case 7:
817  case 8:
818  case 9:
819  case 10:
820  stringbuffer_append_string(buf, "(extremely fast movement)");
821  break;
822 
823  default:
824  stringbuffer_append_string(buf, "(lightning fast movement)");
825  break;
826  }
827  }
828  if (QUERY_FLAG(op, FLAG_UNDEAD))
829  stringbuffer_append_string(buf, "(undead)");
831  stringbuffer_append_string(buf, "(see invisible)");
832  if (QUERY_FLAG(op, FLAG_USE_WEAPON))
833  stringbuffer_append_string(buf, "(wield weapon)");
834  if (QUERY_FLAG(op, FLAG_USE_BOW))
835  stringbuffer_append_string(buf, "(archer)");
836  if (QUERY_FLAG(op, FLAG_USE_ARMOUR))
837  stringbuffer_append_string(buf, "(wear armour)");
838  if (QUERY_FLAG(op, FLAG_USE_RING))
839  stringbuffer_append_string(buf, "(wear ring)");
840  if (QUERY_FLAG(op, FLAG_USE_SCROLL))
841  stringbuffer_append_string(buf, "(read scroll)");
842  if (QUERY_FLAG(op, FLAG_USE_RANGE))
843  stringbuffer_append_string(buf, "(fires wand/rod/horn)");
845  stringbuffer_append_string(buf, "(skill user)");
846  if (QUERY_FLAG(op, FLAG_CAST_SPELL))
847  stringbuffer_append_string(buf, "(spellcaster)");
848  if (QUERY_FLAG(op, FLAG_FRIENDLY))
849  stringbuffer_append_string(buf, "(friendly)");
850  if (QUERY_FLAG(op, FLAG_UNAGGRESSIVE))
851  stringbuffer_append_string(buf, "(unaggressive)");
852  if (QUERY_FLAG(op, FLAG_HITBACK))
853  stringbuffer_append_string(buf, "(hitback)");
854  if (QUERY_FLAG(op, FLAG_STEALTH))
855  stringbuffer_append_string(buf, "(stealthy)");
856  if (op->randomitems != NULL) {
857  treasure *t;
858  int first = 1;
859 
860  for (t = op->randomitems->items; t != NULL; t = t->next)
861  if (t->item && (t->item->clone.type == SPELL)) {
862  if (first) {
863  first = 0;
864  stringbuffer_append_string(buf, "(Spell abilities:)");
865  }
866  stringbuffer_append_printf(buf, "(%s)", t->item->clone.name);
867  }
868  }
869  if (op->type == PLAYER) {
870  if (op->contr->digestion) {
871  if (op->contr->digestion != 0)
872  stringbuffer_append_printf(buf, "(sustenance%+d)", op->contr->digestion);
873  }
874  if (op->contr->gen_grace) {
875  stringbuffer_append_printf(buf, "(grace%+d)", op->contr->gen_grace);
876  }
877  if (op->contr->gen_sp) {
878  stringbuffer_append_printf(buf, "(magic%+d)", op->contr->gen_sp);
879  }
880  if (op->contr->gen_hp) {
881  stringbuffer_append_printf(buf, "(regeneration%+d)", op->contr->gen_hp);
882  }
883  if (op->stats.luck) {
884  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
885  }
886  }
887 
888  /* describe attacktypes */
889  if (is_dragon_pl(op)) {
890  /* for dragon players display the attacktypes from clawing skill
891  * Break apart the for loop - move the comparison checking down -
892  * this makes it more readable.
893  */
894  object *tmp;
895 
896  tmp = object_find_by_type_and_name(op, SKILL, "clawing");
897  if (tmp && tmp->attacktype != 0) {
898  describe_attacktype("Claws", tmp->attacktype, buf);
899  } else {
900  describe_attacktype("Attacks", op->attacktype, buf);
901  }
902  } else {
903  describe_attacktype("Attacks", op->attacktype, buf);
904  }
908  describe_resistance(op, 0, use_media_tags, buf);
909 
910  return buf;
911 }
912 
955 StringBuffer *describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf) {
956  int identified, i;
957 
958  if (buf == NULL)
959  buf = stringbuffer_new();
960 
961  if (QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER) {
962  return describe_monster(op, use_media_tags, buf);
963  }
964 
965  /* figure this out once, instead of making multiple calls to is_identified.
966  * also makes the code easier to read.
967  */
968  if (is_identified(op)) {
969  identified = 1;
970  } else {
971  stringbuffer_append_string(buf, "(unidentified)");
972  identified = 0;
973  }
974  switch (op->type) {
975  case BOW:
976  case ARROW:
977  case WAND:
978  case ROD:
979  case WEAPON:
980  case ARMOUR:
981  case HELMET:
982  case SHIELD:
983  case BOOTS:
984  case GLOVES:
985  case GIRDLE:
986  case BRACERS:
987  case CLOAK:
988  case SKILL_TOOL:
989  break; /* We have more information to do below this switch */
990 
991  case LAMP:
992  break; /* just so we get the "glowing" part. */
993 
994  case FOOD:
995  case FLESH:
996  case DRINK:
997  if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) {
998  stringbuffer_append_printf(buf, "(food+%d)", op->stats.food);
999 
1000  if (op->type == FLESH && op->last_eat > 0 && atnr_is_dragon_enabled(op->last_eat)) {
1001  stringbuffer_append_printf(buf, "(%s metabolism)", change_resist_msg[op->last_eat]);
1002  }
1003 
1004  if (!QUERY_FLAG(op, FLAG_CURSED)) {
1005  if (op->stats.hp > 0)
1006  stringbuffer_append_string(buf, "(heals)");
1007  else if (op->stats.hp < 0)
1008  stringbuffer_append_string(buf, "(damages)");
1009 
1010  if (op->stats.sp > 0)
1011  stringbuffer_append_string(buf, "(spellpoint regen)");
1012  else if (op->stats.sp < 0)
1013  stringbuffer_append_string(buf, "(spellpoint depletion)");
1014  } else {
1015  if (op->stats.hp)
1016  stringbuffer_append_string(buf, "(damages)");
1017  if (op->stats.sp)
1018  stringbuffer_append_string(buf, "(spellpoint depletion)");
1019  }
1020  }
1021  break;
1022 
1023  case SKILL:
1024  case RING:
1025  case AMULET:
1026  if (op->item_power) {
1027  stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power);
1028  }
1029  if (op->title) {
1030  ring_desc(op, use_media_tags, buf);
1031  }
1032  return buf;
1033 
1034  default:
1035  return buf;
1036  }
1037 
1038  /* Down here, we more further describe equipment type items.
1039  * only describe them if they have been identified or the like.
1040  */
1041  if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) {
1042  int attr, val;
1043 
1044  for (attr = 0; attr < NUM_STATS; attr++) {
1045  if ((val = get_attr_value(&(op->stats), attr)) != 0) {
1046  stringbuffer_append_printf(buf, "(%s%+d)", short_stat_name[attr], val);
1047  }
1048  }
1049  if (op->glow_radius)
1050  stringbuffer_append_string(buf, "(glowing)");
1051 
1052  switch (op->type) {
1053  case FLESH:
1054  break;
1055 
1056  default:
1057  if (op->stats.exp) {
1058  stringbuffer_append_printf(buf, "(speed %+" FMT64 ")", op->stats.exp);
1059  }
1060  break;
1061  }
1062  switch (op->type) {
1063  case BOW:
1064  case ARROW:
1065  case GIRDLE:
1066  case HELMET:
1067  case SHIELD:
1068  case BOOTS:
1069  case GLOVES:
1070  case WEAPON:
1071  case SKILL:
1072  case RING:
1073  case AMULET:
1074  case ARMOUR:
1075  case BRACERS:
1076  case FORCE:
1077  case CLOAK:
1078  if (op->stats.wc) {
1079  stringbuffer_append_printf(buf, "(wc%+d)", op->stats.wc);
1080  }
1081  if (op->stats.dam) {
1082  stringbuffer_append_printf(buf, "(dam%+d)", op->stats.dam);
1083  }
1084  if (op->stats.ac) {
1085  stringbuffer_append_printf(buf, "(ac%+d)", op->stats.ac);
1086  }
1087  if ((op->type == WEAPON || op->type == BOW) && op->level > 0) {
1088  stringbuffer_append_printf(buf, "(improved %d/%d)", op->last_eat, op->level);
1089  }
1090  break;
1091 
1092  default:
1093  break;
1094  }
1095  if (QUERY_FLAG(op, FLAG_XRAYS))
1096  stringbuffer_append_string(buf, "(xray-vision)");
1097  if (QUERY_FLAG(op, FLAG_SEE_IN_DARK))
1098  stringbuffer_append_string(buf, "(infravision)");
1099 
1100  /* levitate was what is was before, so we'll keep it */
1101  if (op->move_type&MOVE_FLY_LOW)
1102  stringbuffer_append_string(buf, "(levitate)");
1103 
1104  if (op->move_type&MOVE_FLY_HIGH)
1105  stringbuffer_append_string(buf, "(fly)");
1106 
1107  if (op->move_type&MOVE_SWIM)
1108  stringbuffer_append_string(buf, "(swim)");
1109 
1110  /* walking is presumed as 'normal', so doesn't need mentioning */
1111 
1112  if (op->item_power) {
1113  stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power);
1114  }
1115  } /* End if identified or applied */
1116 
1117  /* This blocks only deals with fully identified object.
1118  * it is intentional that this is not an 'else' from a above -
1119  * in this way, information is added.
1120  */
1121  if (identified) {
1122  int more_info = 0;
1123 
1124  switch (op->type) {
1125  case ROD: /* These use stats.sp for spell selection and stats.food */
1126  /* and stats.hp for spell-point regeneration... */
1127  case ARROW:
1128  case WAND:
1129  case FOOD:
1130  case FLESH:
1131  case DRINK:
1132  more_info = 0;
1133  break;
1134 
1135  /* Bows use sp for firing rate. Per fire_bow(), the bow can be fired every 100/firing rate
1136  * character movements. It also makes sure it calculates the speed at no less than 1, to avoid floating point errors
1137  */
1138  case BOW:
1139  if (op->stats.sp) {
1140  stringbuffer_append_printf(buf, "(Firing delay %.2f)", 100./op->stats.sp);
1141  }
1142  more_info = 0;
1143  break;
1144 
1145  /* Armor type objects */
1146  case ARMOUR:
1147  case HELMET:
1148  case SHIELD:
1149  case BOOTS:
1150  case GLOVES:
1151  case GIRDLE:
1152  case BRACERS:
1153  case CLOAK:
1154  if (ARMOUR_SPEED(op)) {
1155  stringbuffer_append_printf(buf, "(Max speed %1.2f)", ARMOUR_SPEED(op)/10.0);
1156  }
1157  if (ARMOUR_SPELLS(op)) {
1158  stringbuffer_append_printf(buf, "(Spell regen penalty %d)", ARMOUR_SPELLS(op));
1159  }
1160  more_info = 1;
1161  break;
1162 
1163  case WEAPON:
1164  /* Calculate it the same way fix_object does so the results
1165  * make sense.
1166  */
1167  i = (WEAPON_SPEED(op)*2-op->magic)/2;
1168  if (i < 0)
1169  i = 0;
1170 
1171  stringbuffer_append_printf(buf, "(weapon speed %d)", i);
1172  /* If the reflecting flag is set, the weapon will bounce off walls when thrown. */
1173  if (QUERY_FLAG(op, FLAG_REFLECTING)) {
1174  stringbuffer_append_string(buf, "(ricochet)");
1175  }
1176  more_info = 1;
1177  break;
1178  }
1179  if (more_info) {
1180  if (op->stats.food) {
1181  if (op->stats.food != 0)
1182  stringbuffer_append_printf(buf, "(sustenance%+d)", op->stats.food);
1183  }
1184  if (op->stats.grace) {
1185  stringbuffer_append_printf(buf, "(grace%+d)", op->stats.grace);
1186  }
1187  if (op->stats.sp) {
1188  stringbuffer_append_printf(buf, "(magic%+d)", op->stats.sp);
1189  }
1190  if (op->stats.hp) {
1191  stringbuffer_append_printf(buf, "(regeneration%+d)", op->stats.hp);
1192  }
1193  }
1194 
1195  if (op->stats.luck) {
1196  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
1197  }
1198  if (QUERY_FLAG(op, FLAG_LIFESAVE))
1199  stringbuffer_append_string(buf, "(lifesaving)");
1200  if (QUERY_FLAG(op, FLAG_REFL_SPELL))
1201  stringbuffer_append_string(buf, "(reflect spells)");
1202  if (QUERY_FLAG(op, FLAG_REFL_MISSILE))
1203  stringbuffer_append_string(buf, "(reflect missiles)");
1204  if (QUERY_FLAG(op, FLAG_STEALTH))
1205  stringbuffer_append_string(buf, "(stealth)");
1206  if (op->slaying != NULL && op->type != FOOD) {
1207  stringbuffer_append_printf(buf, "(slay %s)", op->slaying);
1208  }
1209  describe_attacktype("Attacks", op->attacktype, buf);
1210  /* resistance on flesh is only visible for dragons. If
1211  * non flesh, everyone can see its resistances
1212  */
1213  if (op->type != FLESH || (owner && is_dragon_pl(owner))) {
1214  describe_resistance(op, 0, 1, buf);
1215  }
1219  }
1220 
1221  return buf;
1222 }
1223 
1236 int is_magical(const object *op) {
1237  int i;
1238 
1239  /* living creatures are considered non magical */
1240  if (QUERY_FLAG(op, FLAG_ALIVE))
1241  return 0;
1242 
1243  /* This is a test for it being an artifact, as artifacts have titles */
1244  if (op->title != NULL)
1245  return 1;
1246 
1247  /* Handle rings and amulets specially. If they change any of these
1248  * values, it means they are magical.
1249  */
1250  if ((op->type == AMULET || op->type == RING)
1251  && (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))
1252  return 1;
1253 
1254  /* Check for stealty, speed, flying, or just plain magic in the boots */
1255  /* Presume any boots that have a move_type are special. */
1256  if (op->type == BOOTS
1257  && ((QUERY_FLAG(op, FLAG_STEALTH) || op->move_type || op->stats.exp)))
1258  return 1;
1259 
1260  /* Take care of amulet/shield that reflects spells/missiles */
1261  if ((op->type == AMULET || op->type == SHIELD)
1263  return 1;
1264 
1265  /* Take care of helmet of xrays */
1266  if (op->type == HELMET
1267  && QUERY_FLAG(op, FLAG_XRAYS))
1268  return 1;
1269 
1270  /* Potions & rods are always magical. Wands/staves are also magical,
1271  * assuming they still have any charges left.
1272  */
1273  if (op->type == POTION || op->type == ROD || (op->type == WAND && op->stats.food))
1274  return 1;
1275 
1276  /* if something gives a protection, either positive or negative, its magical */
1277  /* This is really a pretty bad hack - as of now, ATNR_PHYSICAL is 0,
1278  * so this always works out fine.
1279  */
1280  for (i = ATNR_PHYSICAL+1; i < NROFATTACKS; i++)
1281  if (op->resist[i])
1282  return 1;
1283 
1284  /* Physical protection is expected on some item types, so they should
1285  * not be considered magical.
1286  */
1287  if (op->resist[ATNR_PHYSICAL]
1288  && op->type != HELMET
1289  && op->type != SHIELD
1290  && op->type != BOOTS
1291  && op->type != GLOVES
1292  && op->type != ARMOUR)
1293  return 1;
1294 
1295  /* power crystal, spellbooks, and scrolls are always magical. */
1296  if (op->magic
1297  || op->type == POWER_CRYSTAL
1298  || op->type == SPELLBOOK
1299  || op->type == SCROLL
1300  || op->type == GIRDLE)
1301  return 1;
1302 
1303  /* Check to see if it increases/decreases any stats */
1304  for (i = 0; i < NUM_STATS; i++)
1305  if (get_attr_value(&(op->stats), i) != 0)
1306  return 1;
1307 
1308  /* If it doesn't fall into any of the above categories, must
1309  * be non magical.
1310  */
1311  return 0;
1312 }
1313 
1333 int is_identifiable_type(const object *op) {
1334  /* Special case -- skill tools don't have an associated identification
1335  * skill but still need IDing. TODO: we should probably have per-tool ID
1336  * skills, e.g. thievery for lockpicks and thaumaturgy for talismans, but
1337  * currently there's no good way to do this because the identifyskill is
1338  * tied to the itemtype rather than to the arch. */
1339  if (op->type == SKILL_TOOL) return true;
1340 
1341  /* Sometimes an itemtype has no associated typedata?! */
1342  const typedata *td = get_typedata(op->type);
1343  return td && td->identifyskill;
1344 }
1345 
1357 int is_identified(const object *op) {
1358  return !is_identifiable_type(op) || QUERY_FLAG(op, FLAG_IDENTIFIED);
1359 }
1360 
1366  // Make sure identified objects stack correctly
1370 
1371  // The rest only apply to identifiable items. We don't want, e.g. shop
1372  // floors to show up as 'damned'.
1373  if (!is_identifiable_type(op))
1374  return;
1375 
1376  if (QUERY_FLAG(op, FLAG_CURSED) || QUERY_FLAG(op, FLAG_DAMNED))
1378 
1379  if (QUERY_FLAG(op, FLAG_BLESSED))
1381 
1382  sstring key;
1383 
1384  key = object_get_value(op, "identified_face");
1385  if (key != NULL) {
1386  op->face = try_find_face(key, op->face);
1387  /* if the face is defined, clean the animation, because else
1388  * the face can be lost ; if an animation is defined, it'll be
1389  * processed later on */
1392  op->anim_speed = 0;
1393  op->animation = 0;
1394  object_set_value(op, "identified_face", NULL, 0);
1395  }
1396 
1397  if (object_get_value(op, "identified_anim_random") != NULL) {
1399  object_set_value(op, "identified_anim_random", NULL, 0);
1400  }
1401 
1402  key = object_get_value(op, "identified_anim_speed");
1403  if (key != NULL) {
1404  op->anim_speed = atoi(key);
1405  op->last_anim = 1;
1406  object_set_value(op, "identified_anim_speed", NULL, 0);
1407  }
1408 
1409  key = object_get_value(op, "identified_animation");
1410  if (key != NULL) {
1411  Animations *anim = try_find_animation(key);
1412  if (anim) {
1413  op->animation = anim;
1414  if (!QUERY_FLAG(op, FLAG_IS_TURNABLE))
1415  SET_FLAG(op, FLAG_ANIMATE);
1416  animate_object(op, op->facing);
1417  }
1418  object_set_value(op, "identified_animation", NULL, 0);
1419  }
1420 
1421  key = object_get_value(op, "identified_name");
1422  if (key != NULL) {
1423  FREE_AND_COPY(op->name, key);
1424  object_set_value(op, "identified_name", NULL, 0);
1425  }
1426  key = object_get_value(op, "identified_name_pl");
1427  if (key != NULL) {
1428  FREE_AND_COPY(op->name_pl, key);
1429  object_set_value(op, "identified_name_pl", NULL, 0);
1430  }
1431 }
1432 
1446 object *identify(object *op) {
1447  object *pl, *op1;
1448 
1451 
1452  if (op->type == POTION) {
1453  if (op->inv && op->randomitems) {
1454  if (op->title)
1455  free_string(op->title);
1456  op->title = add_refcount(op->inv->name);
1457  } else if (op->arch) {
1458  free_string(op->name);
1459  op->name = add_refcount(op->arch->clone.name);
1460  free_string(op->name_pl);
1461  op->name_pl = add_refcount(op->arch->clone.name_pl);
1462  }
1463  }
1464 
1465  if (op->map) {
1466  /* If the object is on a map, make sure we update its face.
1467  * Also send name and such information to a player standing on it.
1468  */
1469  object *player = map_find_by_type(op->map, op->x, op->y, PLAYER);
1470 
1472  op1 = object_merge(op, GET_MAP_TOP(op->map, op->x, op->y));
1473  if (op1) op = op1;
1474 
1475  if (player)
1477 
1478  } else if (op->env) {
1479  /* If the object is in an inventory, merge it.
1480  */
1481  pl = object_get_player_container(op->env);
1482  op1 = object_merge(op, op->env->inv);
1483  if (op1) op = op1;
1484 
1485  if (pl)
1486  /* Item is directly in the player's inventory
1487  * A lot of the values can change from an update - might as well send
1488  * it all.
1489  */
1490  esrv_update_item(UPD_ALL, pl, op);
1491  else if (op->env->map &&
1492  (pl = map_find_by_type(op->env->map, op->env->x, op->env->y, PLAYER))
1493  && (pl->container == op->env)) {
1494  /* The item is in a container (on the ground) opened by a player, update */
1496  }
1497  }
1498  /* There is a third option where we do nothing extra:
1499  * identifying a created item as it is created. */
1500  return op;
1501 }
1502 
1507 uint64_t price_base(const object *obj) {
1508  // When there are zero objects, there is really one.
1509  const int number = NROF(obj);
1510  const bool identified = is_identified(obj);
1511  uint64_t val = (uint64_t)obj->value * number;
1512 
1513  // Objects with price adjustments skip the rest of the calculations.
1514  const char *key = object_get_value(obj, "price_adjustment");
1515  if (key != NULL) {
1516  float ratio = atof(key);
1517  return val * ratio;
1518  }
1519 
1520  // Money and gems have fixed prices at shops.
1521  if (obj->type == MONEY || obj->type == GEM) {
1522  return val;
1523  }
1524 
1525  // Assume that good items, e.g. artifacts have that priced into their
1526  // value. Bad items may not.
1527  if (calc_item_enhancement(obj) < 0) {
1528  return 0;
1529  }
1530 
1531  // If unidentified, price item based on its archetype.
1532  if (!identified && obj->arch) {
1533  val = obj->arch->clone.value * number;
1534  }
1535 
1541  if (QUERY_FLAG(obj, FLAG_BLESSED)){
1542  val *= 1.15;
1543  } else if (QUERY_FLAG(obj, FLAG_CURSED)) {
1544  val *= 0.8;
1545  } else if (QUERY_FLAG(obj, FLAG_DAMNED)) {
1546  val *= 0.6;
1547  }
1548 
1549  // If an item is identified to have an enchantment above its archetype
1550  // enchantment, increase price exponentially.
1551  if (obj->arch != NULL && identified) {
1552  int diff = obj->magic - obj->arch->clone.magic;
1553  val *= pow(1.15, diff);
1554  }
1555 
1556  // FIXME: Is the 'baseline' 50 charges per wand?
1557  if (obj->type == WAND) {
1558  val *= obj->stats.food / 50.0;
1559  }
1560 
1561  /* we need to multiply these by 4.0 to keep buy costs roughly the same
1562  * (otherwise, you could buy a potion of charisma for around 400 pp.
1563  * Arguable, the costs in the archetypes should be updated to better
1564  * reflect values (potion charisma list for 1250 gold)
1565  */
1566  val *= 4; // FIXME
1567 
1568  return val;
1569 }
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:36435
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:594
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:1507
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:1357
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:955
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:1236
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:1333
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:1365
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:781
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:692
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:1446