Crossfire Server, Trunk
item.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
22 #include "global.h"
23 
24 #include <assert.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 
29 #include "living.h"
30 #include "spells.h"
31 
55  { "body_range", "in your range slot", "in a human's range slot" },
56  { "body_arm", "on your arm", "on a human's arm" },
57  { "body_torso", "on your body", "on a human's torso" },
58  { "body_head", "on your head", "on a human's head" },
59  { "body_neck", "around your neck", "around a humans neck" },
60  { "body_skill", "in your skill slot", "in a human's skill slot" },
61  { "body_finger", "on your finger", "on a human's finger" },
62  { "body_shoulder", "around your shoulders", "around a human's shoulders" },
63  { "body_foot", "on your feet", "on a human's feet" },
64  { "body_hand", "on your hands", "on a human's hands" },
65  { "body_wrist", "around your wrists", "around a human's wrist" },
66  { "body_waist", "around your waist", "around a human's waist" },
67  { "body_leg", "around your legs", "around a human's legs" },
68  /*{"body_dragon_torso", "your body", "a dragon's body"} */
69 };
70 
78 static const typedata item_types[] = {
79  { 0, "none", "none", 0, 0 },
80  { PLAYER, "player", "players", 0, 0 },
81  { ROD, "rod", "rods", SK_THAUMATURGY, 0 },
82  { TREASURE, "treasure", "treasure", 0, 0 },
83  { POTION, "potion", "potions", SK_ALCHEMY, 0 },
84  { FOOD, "food", "food", SK_WOODSMAN, 0 },
85  { POISON, "poison", "poisons", SK_ALCHEMY, 0 },
86  { BOOK, "book", "books", SK_LITERACY, 0 },
87  { CLOCK, "clock", "clocks", 0, 0 },
88  { ARROW, "arrow", "arrows", SK_BOWYER, 0 },
89  { BOW, "bow", "bows", SK_BOWYER, 0 },
90  { WEAPON, "weapon", "weapons", SK_SMITHERY, 0 },
91  { ARMOUR, "armour", "armour", SK_SMITHERY, 0 },
92  { PEDESTAL, "pedestal", "pedestals", 0, 0 },
93  { ALTAR, "altar", "altars", 0, 0 },
94  { LOCKED_DOOR, "locked door", "locked doors", 0, 0 },
95  { SPECIAL_KEY, "special key", "special keys", 0, 0 },
96  { MAP, "map", "maps", 0, 0 },
97  { DOOR, "door", "doors", 0, 0 },
98  { KEY, "key", "keys", 0, 0 },
99  { TIMED_GATE, "timed_gate", "timed_gates", 0, 0 },
100  { TRIGGER, "trigger", "triggers", 0, 0 },
101  { GRIMREAPER, "grimreaper", "grimreapers", 0, 0 },
102  { MAGIC_EAR, "magic ear", "magic ears", 0, 0 },
103  { TRIGGER_BUTTON, "trigger button", "trigger buttons", 0, 0 },
104  { TRIGGER_ALTAR, "trigger altar", "trigger altars", 0, 0 },
105  { TRIGGER_PEDESTAL, "trigger pedestal", "trigger pedestals", 0, 0 },
106  { SHIELD, "shield", "shields", SK_SMITHERY, 0 },
107  { HELMET, "helmet", "helmets", SK_SMITHERY, 0 },
108  { MONEY, "money", "money", 0, 0 },
109  { CLASS, "class", "classes", 0, 0 },
110  { AMULET, "amulet", "amulets", SK_JEWELER, 0 },
111  { PLAYERMOVER, "player mover", "player movers", 0, 0 },
112  { TELEPORTER, "teleporter", "teleporters", 0, 0 },
113  { CREATOR, "creator", "creators", 0, 0 },
114  { SKILL, "skill", "skills", 0, 0 },
115  { EARTHWALL, "earthwall", "earthwalls", 0, 0 },
116  { GOLEM, "golem", "golems", 0, 0 },
117  { THROWN_OBJ, "projectile", "projectiles", 0, 0 },
118  { BLINDNESS, "blindness", "blindness", 0, 0 },
119  { GOD, "god", "gods", 0, 0 },
120  { DETECTOR, "detector", "detectors", 0, 0 },
121  { TRIGGER_MARKER, "trigger marker", "trigger markers", 0, 0 },
122  { DEAD_OBJECT, "dead object", "dead objects", 0, 0 },
123  { DRINK, "drink", "drinks", SK_WOODSMAN, SK_ALCHEMY },
124  { MARKER, "marker", "markers", 0, 0 },
125  { HOLY_ALTAR, "holy altar", "holy altars", 0, 0 },
126  { PLAYER_CHANGER, "player changer", "player changers", 0, 0 },
127  { BATTLEGROUND, "battleground", "battlegrounds", 0, 0 },
128  { PEACEMAKER, "peacemaker", "peacemakers", 0, 0 },
129  { GEM, "gem", "gems", SK_JEWELER, 0 },
130  { FIREWALL, "firewall", "firewalls", 0, 0 },
131  { CHECK_INV, "inventory checker", "inventory checkers", 0, 0 },
132  { MOOD_FLOOR, "mood floor", "mood floors", 0, 0 },
133  { EXIT, "exit", "exits", 0, 0 },
134  { ENCOUNTER, "encounter", "encounters", 0, 0 },
135  { SHOP_FLOOR, "shop floor", "shop floors", 0, 0 },
136  { SHOP_MAT, "shop mat", "shop mats", 0, 0 },
137  { RING, "ring", "rings", SK_JEWELER, 0 },
138  { FLOOR, "floor", "floors", 0, 0 },
139  { FLESH, "flesh", "flesh", SK_WOODSMAN, 0 },
140  { INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0 },
141  { SKILL_TOOL, "skill tool", "skill tools", 0, 0 },
142  { LIGHTER, "lighter", "lighters", 0, 0 },
143  { WALL, "wall", "walls", 0, 0 },
144  { MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0 },
145  { MONSTER, "monster", "monsters", 0, 0 },
146  { LAMP, "lamp", "lamps", 0, 0 },
147  { DUPLICATOR, "duplicator", "duplicators", 0, 0 },
148  { SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0 },
149  { CLOAK, "cloak", "cloaks", SK_SMITHERY, 0 },
150  { SPINNER, "spinner", "spinners", 0, 0 },
151  { GATE, "gate", "gates", 0, 0 },
152  { BUTTON, "button", "buttons", 0, 0 },
153  { CF_HANDLE, "cf handle", "cf handles", 0, 0 },
154  { HOLE, "hole", "holes", 0, 0 },
155  { TRAPDOOR, "trapdoor", "trapdoors", 0, 0 },
156  { SIGN, "sign", "signs", 0, 0 },
157  { BOOTS, "boots", "boots", SK_SMITHERY, 0 },
158  { GLOVES, "gloves", "gloves", SK_SMITHERY, 0 },
159  { SPELL, "spell", "spells", 0, 0 },
160  { SPELL_EFFECT, "spell effect", "spell effects", 0, 0 },
161  { CONVERTER, "converter", "converters", 0, 0 },
162  { BRACERS, "bracers", "bracers", SK_SMITHERY, 0 },
163  { POISONING, "poisoning", "poisonings", 0, 0 },
164  { SAVEBED, "savebed", "savebeds", 0, 0 },
165  { WAND, "wand", "wands", SK_THAUMATURGY, 0 },
166  { SCROLL, "scroll", "scrolls", SK_LITERACY, 0 },
167  { DIRECTOR, "director", "directors", 0, 0 },
168  { GIRDLE, "girdle", "girdles", SK_SMITHERY, 0 },
169  { FORCE, "force", "forces", 0, 0 },
170  { POTION_RESIST_EFFECT, "potion effect", "potion effects", 0, 0 },
171  { CLOSE_CON, "closed container", "closed container", SK_ALCHEMY, 0 },
172  { CONTAINER, "container", "containers", SK_ALCHEMY, 0 },
173  { ARMOUR_IMPROVER, "armour improver", "armour improvers", SK_LITERACY, 0 },
174  { WEAPON_IMPROVER, "weapon improver", "weapon improvers", SK_LITERACY, 0 },
175  { SKILLSCROLL, "skillscroll", "skillscrolls", SK_LITERACY, 0 },
176  { DEEP_SWAMP, "deep swamp", "deep swamps", 0, 0 },
177  { IDENTIFY_ALTAR, "identify altar", "identify altars", 0, 0 },
178  { SHOP_INVENTORY, "inventory list", "inventory lists", 0, 0 },
179  { RUNE, "rune", "runes", 0, 0 },
180  { TRAP, "trap", "traps", 0, 0 },
181  { POWER_CRYSTAL, "power_crystal", "power_crystals", SK_THAUMATURGY, 0 },
182  { CORPSE, "corpse", "corpses", 0, 0 },
183  { DISEASE, "disease", "diseases", 0, 0 },
184  { SYMPTOM, "symptom", "symptoms", 0, 0 },
185  { BUILDER, "item builder", "item builders", 0, 0 },
186  { MATERIAL, "building material", "building materials", 0, 0 },
187  { MIMIC, "mimic", "mimics", SK_ALCHEMY, 0 },
188  { LIGHTABLE, "lightable", "lightables", 0, 0 },
189 };
190 
192 static const int item_types_size = sizeof(item_types)/sizeof(*item_types);
193 
203 static const int enc_to_item_power[] = {
204  0, 0, 1, 2, 3, 4, /* 5 */
205  5, 7, 9, 11, 13, /* 10 */
206  15, 18, 21, 24, 27, /* 15 */
207  30, 35, 40, 45, 50 /* 20 */
208 };
209 
210 int get_power_from_ench(int ench) {
211  if (ench < 0)
212  ench = 0;
213  if (ench > (int)(sizeof(enc_to_item_power)/sizeof(*enc_to_item_power)-1))
214  ench = sizeof(enc_to_item_power)/sizeof(*enc_to_item_power)-1;
215  return enc_to_item_power[ench];
216 }
217 
218 static int bits_set(uint32_t x, int start, int end) {
219  int enc = 0;
220  for (int i = start; i < end; i++) {
221  if (x&(1<<i)) {
222  enc++;
223  }
224  }
225  return enc;
226 }
227 
238 int calc_item_power(const object *op) {
239  int i, tmp, enc;
240 
241  enc = 0;
242  for (i = 0; i < NUM_STATS; i++)
243  enc += get_attr_value(&op->stats, i);
244 
245  /* This protection logic is pretty flawed. 20% fire resistance
246  * is much more valuable than 20% confusion, or 20% slow, or
247  * several others. Start at 1 - ignore physical - all that normal
248  * armour shouldn't be counted against
249  */
250  tmp = 0;
251  for (i = 1; i < NROFATTACKS; i++)
252  tmp += op->resist[i];
253 
254  /* Add/substract 10 so that the rounding works out right */
255  if (tmp > 0)
256  enc += (tmp+10)/20;
257  else if (tmp < 0)
258  enc += (tmp-10)/20;
259 
260  enc += op->magic;
261 
262  /* For each attacktype a weapon has, one more encantment. Start at 1 -
263  * physical doesn't count against total.
264  */
265  if (op->type == WEAPON) {
266  enc += bits_set(op->attacktype, 1, NROFATTACKS);
267  if (op->slaying)
268  enc += 2; /* What it slays is probably more relevent */
269  }
270  /* Items the player can equip */
271  if ((op->type == WEAPON)
272  || (op->type == ARMOUR)
273  || (op->type == HELMET)
274  || (op->type == SHIELD)
275  || (op->type == RING)
276  || (op->type == BOOTS)
277  || (op->type == GLOVES)
278  || (op->type == AMULET)
279  || (op->type == GIRDLE)
280  || (op->type == BRACERS)
281  || (op->type == CLOAK)) {
282  enc += op->stats.food; /* sustenance */
283  enc += op->stats.hp; /* hp regen */
284  enc += op->stats.sp; /* mana regen */
285  enc += op->stats.grace; /* grace regen */
286  enc += op->stats.exp; /* speed bonus */
287  }
288  enc += op->stats.luck;
289 
290  /* Do spell paths now */
291  enc += bits_set(op->path_attuned, 1, NRSPELLPATHS);
292  enc -= bits_set(op->path_repelled, 1, NRSPELLPATHS);
293  enc -= 2*bits_set(op->path_denied, 1, NRSPELLPATHS);
294 
296  enc += 5;
298  enc += 3;
300  enc += 2;
301  if (QUERY_FLAG(op, FLAG_STEALTH))
302  enc += 1;
303  if (QUERY_FLAG(op, FLAG_XRAYS))
304  enc += 2;
306  enc += 1;
308  enc += 1;
309 
310  return get_power_from_ench(enc);
311 }
312 
319 const typedata *get_typedata(int itemtype) {
320  int i;
321 
322  for (i = 0; i < item_types_size; i++)
323  if (item_types[i].number == itemtype)
324  return &item_types[i];
325  return NULL;
326 }
327 
339 const typedata *get_typedata_by_name(const char *name) {
340  int i;
341 
342  for (i = 0; i < item_types_size; i++)
343  if (!strcmp(item_types[i].name, name))
344  return &item_types[i];
345  for (i = 0; i < item_types_size; i++)
346  if (!strcmp(item_types[i].name_pl, name)) {
347  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);
348  return &item_types[i];
349  }
350  return NULL;
351 }
352 
368 StringBuffer *describe_resistance(const object *op, int newline, int use_media_tags, StringBuffer *buf) {
369  int tmpvar;
370 
371  if (buf == NULL)
372  buf = stringbuffer_new();
373 
374  for (tmpvar = 0; tmpvar < NROFATTACKS; tmpvar++) {
375  if (op->resist[tmpvar] && (op->type != FLESH || atnr_is_dragon_enabled(tmpvar) == 1)) {
376  if (use_media_tags) {
377  if (resist_color[tmpvar] != NULL) {
378  stringbuffer_append_printf(buf, "[color=%s]", resist_color[tmpvar]);
379  }
380  if (op->resist[tmpvar] == 100 || op->resist[tmpvar] == -100) {
382  }
383  }
384  if (!newline)
385  stringbuffer_append_printf(buf, "(%s %+d)", resist_plus[tmpvar], op->resist[tmpvar]);
386  else
387  stringbuffer_append_printf(buf, "%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]);
388  if (use_media_tags) {
389  if (op->resist[tmpvar] == 100 || op->resist[tmpvar] == -100) {
391  }
392  if (resist_color[tmpvar] != NULL) {
393  stringbuffer_append_string(buf, "[/color]");
394  }
395  }
396  }
397  }
398 
399  return buf;
400 }
401 
411 void query_weight(const object *op, char *buf, size_t size) {
412  int32_t i = NROF(op)*op->weight+op->carrying;
413 
414  if (op->weight < 0)
415  snprintf(buf, size, " ");
416  else if (i%1000)
417  snprintf(buf, size, "%6.1f", i/1000.0);
418  else
419  snprintf(buf, size, "%4d ", i/1000);
420 }
421 
434 static StringBuffer *ring_desc(const object *op, int use_media_tags, StringBuffer *buf) {
435  int attr, val;
436  size_t len;
437 
438  assert(op != NULL);
439  assert(op->type == RING || op->type == AMULET || op->type == SKILL);
440 
441  if (buf == NULL)
442  buf = stringbuffer_new();
443  len = stringbuffer_length(buf);
444 
446  return buf;
447 
448  for (attr = 0; attr < NUM_STATS; attr++) {
449  if ((val = get_attr_value(&(op->stats), attr)) != 0) {
450  stringbuffer_append_printf(buf, "(%s%+d)", short_stat_name[attr], val);
451  }
452  }
453  if (op->stats.exp)
454  stringbuffer_append_printf(buf, "(speed %+"FMT64")", op->stats.exp);
455  if (op->stats.wc)
456  stringbuffer_append_printf(buf, "(wc%+d)", op->stats.wc);
457  if (op->stats.dam)
458  stringbuffer_append_printf(buf, "(dam%+d)", op->stats.dam);
459  if (op->stats.ac)
460  stringbuffer_append_printf(buf, "(ac%+d)", op->stats.ac);
461 
462  describe_resistance(op, 0, use_media_tags, buf);
463 
464  if (op->stats.food != 0)
465  stringbuffer_append_printf(buf, "(sustenance%+d)", op->stats.food);
466  if (op->stats.grace)
467  stringbuffer_append_printf(buf, "(grace%+d)", op->stats.grace);
468  if (op->stats.sp && op->type != SKILL)
469  stringbuffer_append_printf(buf, "(magic%+d)", op->stats.sp);
470  if (op->stats.hp)
471  stringbuffer_append_printf(buf, "(regeneration%+d)", op->stats.hp);
472  if (op->stats.luck)
473  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
475  stringbuffer_append_printf(buf, "(lifesaving)");
477  stringbuffer_append_printf(buf, "(reflect spells)");
479  stringbuffer_append_printf(buf, "(reflect missiles)");
480  if (QUERY_FLAG(op, FLAG_STEALTH))
481  stringbuffer_append_printf(buf, "(stealth)");
482  if (op->glow_radius)
483  stringbuffer_append_string(buf, "(glowing)");
484 
485  describe_spellpath_attenuation("Attuned", op->path_attuned, buf);
486  describe_spellpath_attenuation("Repelled", op->path_repelled, buf);
487  describe_spellpath_attenuation("Denied", op->path_denied, buf);
488 
489  /* item_power is done by the caller */
490  /* if (op->item_power)
491  snprintf(buf+strlen(buf), size-strlen(buf), "(item_power %+d)", op->item_power);*/
492  if (stringbuffer_length(buf) == len && op->type != SKILL)
493  stringbuffer_append_string(buf, "of adornment");
494 
495  return buf;
496 }
497 
509 void query_short_name(const object *op, char *buf, size_t size) {
510  size_t len = 0;
511 
512  if (op->name == NULL) {
513  snprintf(buf, size, "(null)");
514  return;
515  }
516  if (!op->nrof && !op->weight && !op->title && !is_magical(op)) {
517  strlcpy(buf, op->name, size); /* To speed things up (or make things slower?) */
518  return;
519  }
520  buf[0] = '\0';
521 
522  if (op->nrof <= 1)
523  safe_strcat(buf, op->name, &len, size);
524  else
525  safe_strcat(buf, op->name_pl, &len, size);
526 
527  if (op->title && QUERY_FLAG(op, FLAG_IDENTIFIED)) {
528  safe_strcat(buf, " ", &len, size);
529  safe_strcat(buf, op->title, &len, size);
530  }
531 
532  switch (op->type) {
533  case SPELLBOOK:
534  case SCROLL:
535  case WAND:
536  case ROD:
538  if (!op->title && (op->inv)) {
539  safe_strcat(buf, " of ", &len, size);
540  safe_strcat(buf, op->inv->name, &len, size);
541  }
542  if (op->type != SPELLBOOK) {
543  snprintf(buf+len, size-len, " (lvl %d)", op->level);
544  len += strlen(buf+len);
545  }
546  }
547  break;
548 
549  case SKILL:
550  case AMULET:
551  case RING:
552  if (!op->title) {
553  /* If ring has a title, full description isn't so useful */
554  char* desc;
555 
556  desc = stringbuffer_finish(ring_desc(op, 0, NULL));
557  if (desc[0]) {
558  safe_strcat(buf, " ", &len, size);
559  safe_strcat(buf, desc, &len, size);
560  }
561  free(desc);
562  }
563  break;
564 
565  default:
566  if (op->magic
568  snprintf(buf+len, size-len, " %+d", op->magic);
569  len += strlen(buf+len);
570  }
571  }
572 }
573 
584 void query_name(const object *op, char *buf, size_t size) {
585  size_t len = 0;
586 
587  buf[0] = '\0';
588  /*
589  * Since len is initialized to zero, but is not changed
590  * up to this point, I see no reason to have buf+len and size-len;
591  * buf and size should suffice, since we're just adding and
592  * subtracting zero here, anyway.
593  *
594  * SilverNexus 2014-06-04
595  */
596  query_short_name(op, buf, size);
597  len = strlen(buf);
598 
600  safe_strcat(buf, " *", &len, size);
601  if (op->type == CONTAINER
602  && ((op->env && op->env->container == op) || (!op->env && QUERY_FLAG(op, FLAG_APPLIED))))
603  safe_strcat(buf, " (open)", &len, size);
604 
606  if (QUERY_FLAG(op, FLAG_DAMNED))
607  safe_strcat(buf, " (damned)", &len, size);
608  else if (QUERY_FLAG(op, FLAG_CURSED))
609  safe_strcat(buf, " (cursed)", &len, size);
610  }
612  safe_strcat(buf, " (blessed)", &len, size);
613 
614  /* Basically, if the object is known magical (detect magic spell on it),
615  * and it isn't identified, print out the fact that
616  * it is magical. Assume that the detect magical spell will only set
617  * KNOWN_MAGICAL if the item actually is magical.
618  *
619  * Changed in V 0.91.4 - still print that the object is magical even
620  * if it has been applied. Equipping an item does not tell full
621  * abilities, especially for artifact items.
622  */
624  safe_strcat(buf, " (magic)", &len, size);
625 
626  if (QUERY_FLAG(op, FLAG_APPLIED)) {
627  switch (op->type) {
628  case BOW:
629  case WAND:
630  case ROD:
631  safe_strcat(buf, " (readied)", &len, size);
632  break;
633 
634  case WEAPON:
635  safe_strcat(buf, " (wielded)", &len, size);
636  break;
637 
638  case ARMOUR:
639  case HELMET:
640  case SHIELD:
641  case RING:
642  case BOOTS:
643  case GLOVES:
644  case AMULET:
645  case GIRDLE:
646  case BRACERS:
647  case CLOAK:
648  safe_strcat(buf, " (worn)", &len, size);
649  break;
650 
651  case CONTAINER:
652  safe_strcat(buf, " (active)", &len, size);
653  break;
654 
655  case SKILL:
656  default:
657  safe_strcat(buf, " (applied)", &len, size);
658  }
659  }
660  // NO_SKILL_IDENT is set when identification fails or when the book is read. So the book is read only when it is
661  // both identified and NO_SKILL_IDENT.
663  safe_strcat(buf, " (read)", &len, size);
664  if (QUERY_FLAG(op, FLAG_UNPAID))
665  safe_strcat(buf, " (unpaid)", &len, size);
666 }
667 
685 void query_base_name(const object *op, int plural, char *buf, size_t size) {
686  size_t len;
687 
688  if ((!plural && !op->name)
689  || (plural && !op->name_pl)) {
690  strncpy(buf, "(null)", size);
691  return;
692  }
693 
694  if (!op->nrof && !op->weight && !op->title && !is_magical(op)) {
695  strncpy(buf, op->name, size); /* To speed things up (or make things slower?) */
696  return;
697  }
698 
699  buf[0] = '\0';
700 
701  strlcpy(buf, plural ? op->name_pl : op->name, size);
702  len = strlen(buf);
703 
704  if (op->title && QUERY_FLAG(op, FLAG_IDENTIFIED)) {
705  safe_strcat(buf, " ", &len, size);
706  safe_strcat(buf, op->title, &len, size);
707  }
708 
709  switch (op->type) {
710  case SPELLBOOK:
711  case SCROLL:
712  case WAND:
713  case ROD:
715  if (!op->title && (op->inv)) {
716  safe_strcat(buf, " of ", &len, size);
717  safe_strcat(buf, op->inv->name, &len, size);
718  }
719  if (op->type != SPELLBOOK) {
720  snprintf(buf+len, size-len, " (lvl %d)", op->level);
721  len += strlen(buf+len);
722  }
723  }
724  break;
725 
726  case SKILL:
727  case AMULET:
728  case RING:
729  if (!op->title) {
730  /* If ring has a title, full description isn't so useful */
731  char* s;
732 
733  s = stringbuffer_finish(ring_desc(op, 0, NULL));
734  if (s[0]) {
735  safe_strcat(buf, " ", &len, size);
736  safe_strcat(buf, s, &len, size);
737  }
738  free(s);
739  }
740  break;
741 
742  default:
743  if (op->magic
745  snprintf(buf+strlen(buf), size-strlen(buf), " %+d", op->magic);
746  }
747  }
748 }
749 
766 StringBuffer *describe_monster(const object *op, int use_media_tags, StringBuffer *buf) {
767  assert(op != NULL);
768  assert(QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER);
769 
770  if (buf == NULL)
771  buf = stringbuffer_new();
772 
773  /* Note that the resolution this provides for players really isn't
774  * very good. Any player with a speed greater than .67 will
775  * fall into the 'lightning fast movement' category.
776  */
777  if (FABS(op->speed) > MIN_ACTIVE_SPEED) {
778  switch ((int)((FABS(op->speed))*15)) {
779  case 0:
780  stringbuffer_append_string(buf, "(very slow movement)");
781  break;
782 
783  case 1:
784  stringbuffer_append_string(buf, "(slow movement)");
785  break;
786 
787  case 2:
788  stringbuffer_append_string(buf, "(normal movement)");
789  break;
790 
791  case 3:
792  case 4:
793  stringbuffer_append_string(buf, "(fast movement)");
794  break;
795 
796  case 5:
797  case 6:
798  stringbuffer_append_string(buf, "(very fast movement)");
799  break;
800 
801  case 7:
802  case 8:
803  case 9:
804  case 10:
805  stringbuffer_append_string(buf, "(extremely fast movement)");
806  break;
807 
808  default:
809  stringbuffer_append_string(buf, "(lightning fast movement)");
810  break;
811  }
812  }
813  if (QUERY_FLAG(op, FLAG_UNDEAD))
814  stringbuffer_append_string(buf, "(undead)");
816  stringbuffer_append_string(buf, "(see invisible)");
818  stringbuffer_append_string(buf, "(wield weapon)");
819  if (QUERY_FLAG(op, FLAG_USE_BOW))
820  stringbuffer_append_string(buf, "(archer)");
822  stringbuffer_append_string(buf, "(wear armour)");
824  stringbuffer_append_string(buf, "(wear ring)");
826  stringbuffer_append_string(buf, "(read scroll)");
828  stringbuffer_append_string(buf, "(fires wand/rod/horn)");
830  stringbuffer_append_string(buf, "(skill user)");
832  stringbuffer_append_string(buf, "(spellcaster)");
834  stringbuffer_append_string(buf, "(friendly)");
836  stringbuffer_append_string(buf, "(unaggressive)");
837  if (QUERY_FLAG(op, FLAG_HITBACK))
838  stringbuffer_append_string(buf, "(hitback)");
839  if (QUERY_FLAG(op, FLAG_STEALTH))
840  stringbuffer_append_string(buf, "(stealthy)");
841  if (op->randomitems != NULL) {
842  treasure *t;
843  int first = 1;
844 
845  for (t = op->randomitems->items; t != NULL; t = t->next)
846  if (t->item && (t->item->clone.type == SPELL)) {
847  if (first) {
848  first = 0;
849  stringbuffer_append_string(buf, "(Spell abilities:)");
850  }
851  stringbuffer_append_printf(buf, "(%s)", t->item->clone.name);
852  }
853  }
854  if (op->type == PLAYER) {
855  if (op->contr->digestion) {
856  if (op->contr->digestion != 0)
857  stringbuffer_append_printf(buf, "(sustenance%+d)", op->contr->digestion);
858  }
859  if (op->contr->gen_grace) {
860  stringbuffer_append_printf(buf, "(grace%+d)", op->contr->gen_grace);
861  }
862  if (op->contr->gen_sp) {
863  stringbuffer_append_printf(buf, "(magic%+d)", op->contr->gen_sp);
864  }
865  if (op->contr->gen_hp) {
866  stringbuffer_append_printf(buf, "(regeneration%+d)", op->contr->gen_hp);
867  }
868  if (op->stats.luck) {
869  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
870  }
871  }
872 
873  /* describe attacktypes */
874  if (is_dragon_pl(op)) {
875  /* for dragon players display the attacktypes from clawing skill
876  * Break apart the for loop - move the comparison checking down -
877  * this makes it more readable.
878  */
879  object *tmp;
880 
881  tmp = object_find_by_type_and_name(op, SKILL, "clawing");
882  if (tmp && tmp->attacktype != 0) {
883  describe_attacktype("Claws", tmp->attacktype, buf);
884  } else {
885  describe_attacktype("Attacks", op->attacktype, buf);
886  }
887  } else {
888  describe_attacktype("Attacks", op->attacktype, buf);
889  }
890  describe_spellpath_attenuation("Attuned", op->path_attuned &~ op->path_denied, buf);
891  describe_spellpath_attenuation("Repelled", op->path_repelled &~ op->path_denied, buf );
892  describe_spellpath_attenuation("Denied", op->path_denied, buf);
893  describe_resistance(op, 0, use_media_tags, buf);
894 
895  return buf;
896 }
897 
940 StringBuffer *describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf) {
941  int identified, i;
942 
943  if (buf == NULL)
944  buf = stringbuffer_new();
945 
946  if (QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER) {
947  return describe_monster(op, use_media_tags, buf);
948  }
949 
950  /* figure this out once, instead of making multiple calls to is_identified.
951  * also makes the code easier to read.
952  */
953  if (is_identified(op)) {
954  identified = 1;
955  } else {
956  stringbuffer_append_string(buf, "(unidentified)");
957  identified = 0;
958  }
959  switch (op->type) {
960  case BOW:
961  case ARROW:
962  case WAND:
963  case ROD:
964  case WEAPON:
965  case ARMOUR:
966  case HELMET:
967  case SHIELD:
968  case BOOTS:
969  case GLOVES:
970  case GIRDLE:
971  case BRACERS:
972  case CLOAK:
973  case SKILL_TOOL:
974  break; /* We have more information to do below this switch */
975 
976  case LAMP:
977  break; /* just so we get the "glowing" part. */
978 
979  case FOOD:
980  case FLESH:
981  case DRINK:
982  if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) {
983  stringbuffer_append_printf(buf, "(food+%d)", op->stats.food);
984 
985  if (op->type == FLESH && op->last_eat > 0 && atnr_is_dragon_enabled(op->last_eat)) {
986  stringbuffer_append_printf(buf, "(%s metabolism)", change_resist_msg[op->last_eat]);
987  }
988 
989  if (!QUERY_FLAG(op, FLAG_CURSED)) {
990  if (op->stats.hp)
991  stringbuffer_append_string(buf, "(heals)");
992  if (op->stats.sp)
993  stringbuffer_append_string(buf, "(spellpoint regen)");
994  } else {
995  if (op->stats.hp)
996  stringbuffer_append_string(buf, "(damages)");
997  if (op->stats.sp)
998  stringbuffer_append_string(buf, "(spellpoint depletion)");
999  }
1000  }
1001  break;
1002 
1003  case SKILL:
1004  case RING:
1005  case AMULET:
1006  if (op->item_power) {
1007  stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power);
1008  }
1009  ring_desc(op, use_media_tags, buf);
1010  return buf;
1011 
1012  default:
1013  return buf;
1014  }
1015 
1016  /* Down here, we more further describe equipment type items.
1017  * only describe them if they have been identified or the like.
1018  */
1019  if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) {
1020  int attr, val;
1021 
1022  for (attr = 0; attr < NUM_STATS; attr++) {
1023  if ((val = get_attr_value(&(op->stats), attr)) != 0) {
1024  stringbuffer_append_printf(buf, "(%s%+d)", short_stat_name[attr], val);
1025  }
1026  }
1027  if (op->glow_radius)
1028  stringbuffer_append_string(buf, "(glowing)");
1029 
1030  switch (op->type) {
1031  case FLESH:
1032  break;
1033 
1034  default:
1035  if (op->stats.exp) {
1036  stringbuffer_append_printf(buf, "(speed %+"FMT64")", op->stats.exp);
1037  }
1038  break;
1039  }
1040  switch (op->type) {
1041  case BOW:
1042  case ARROW:
1043  case GIRDLE:
1044  case HELMET:
1045  case SHIELD:
1046  case BOOTS:
1047  case GLOVES:
1048  case WEAPON:
1049  case SKILL:
1050  case RING:
1051  case AMULET:
1052  case ARMOUR:
1053  case BRACERS:
1054  case FORCE:
1055  case CLOAK:
1056  if (op->stats.wc) {
1057  stringbuffer_append_printf(buf, "(wc%+d)", op->stats.wc);
1058  }
1059  if (op->stats.dam) {
1060  stringbuffer_append_printf(buf, "(dam%+d)", op->stats.dam);
1061  }
1062  if (op->stats.ac) {
1063  stringbuffer_append_printf(buf, "(ac%+d)", op->stats.ac);
1064  }
1065  if ((op->type == WEAPON || op->type == BOW) && op->level > 0) {
1066  stringbuffer_append_printf(buf, "(improved %d/%d)", op->last_eat, op->level);
1067  }
1068  break;
1069 
1070  default:
1071  break;
1072  }
1073  if (QUERY_FLAG(op, FLAG_XRAYS))
1074  stringbuffer_append_string(buf, "(xray-vision)");
1076  stringbuffer_append_string(buf, "(infravision)");
1077 
1078  /* levitate was what is was before, so we'll keep it */
1079  if (op->move_type&MOVE_FLY_LOW)
1080  stringbuffer_append_string(buf, "(levitate)");
1081 
1082  if (op->move_type&MOVE_FLY_HIGH)
1083  stringbuffer_append_string(buf, "(fly)");
1084 
1085  if (op->move_type&MOVE_SWIM)
1086  stringbuffer_append_string(buf, "(swim)");
1087 
1088  /* walking is presumed as 'normal', so doesn't need mentioning */
1089 
1090  if (op->item_power) {
1091  stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power);
1092  }
1093  } /* End if identified or applied */
1094 
1095  /* This blocks only deals with fully identified object.
1096  * it is intentional that this is not an 'else' from a above -
1097  * in this way, information is added.
1098  */
1099  if (identified) {
1100  int more_info = 0;
1101 
1102  switch (op->type) {
1103  case ROD: /* These use stats.sp for spell selection and stats.food */
1104  /* and stats.hp for spell-point regeneration... */
1105  case ARROW:
1106  case WAND:
1107  case FOOD:
1108  case FLESH:
1109  case DRINK:
1110  more_info = 0;
1111  break;
1112 
1113  /* Bows use sp for firing rate. Per fire_bow(), the bow can be fired every 100/firing rate
1114  * character movements. It also makes sure it calculates the speed at no less than 1, to avoid floating point errors
1115  */
1116  case BOW:
1117  if (op->stats.sp) {
1118  stringbuffer_append_printf(buf, "(Firing delay %.2f)", 100./op->stats.sp);
1119  }
1120  more_info = 0;
1121  break;
1122 
1123  /* Armor type objects */
1124  case ARMOUR:
1125  case HELMET:
1126  case SHIELD:
1127  case BOOTS:
1128  case GLOVES:
1129  case GIRDLE:
1130  case BRACERS:
1131  case CLOAK:
1132  if (ARMOUR_SPEED(op)) {
1133  stringbuffer_append_printf(buf, "(Max speed %1.2f)", ARMOUR_SPEED(op)/10.0);
1134  }
1135  if (ARMOUR_SPELLS(op)) {
1136  stringbuffer_append_printf(buf, "(Spell regen penalty %d)", ARMOUR_SPELLS(op));
1137  }
1138  more_info = 1;
1139  break;
1140 
1141  case WEAPON:
1142  /* Calculate it the same way fix_object does so the results
1143  * make sense.
1144  */
1145  i = (WEAPON_SPEED(op)*2-op->magic)/2;
1146  if (i < 0)
1147  i = 0;
1148 
1149  stringbuffer_append_printf(buf, "(weapon speed %d)", i);
1150  /* If the reflecting flag is set, the weapon will bounce off walls when thrown. */
1151  if (QUERY_FLAG(op, FLAG_REFLECTING)) {
1152  stringbuffer_append_string(buf, "(ricochet)");
1153  }
1154  more_info = 1;
1155  break;
1156  }
1157  if (more_info) {
1158  if (op->stats.food) {
1159  if (op->stats.food != 0)
1160  stringbuffer_append_printf(buf, "(sustenance%+d)", op->stats.food);
1161  }
1162  if (op->stats.grace) {
1163  stringbuffer_append_printf(buf, "(grace%+d)", op->stats.grace);
1164  }
1165  if (op->stats.sp) {
1166  stringbuffer_append_printf(buf, "(magic%+d)", op->stats.sp);
1167  }
1168  if (op->stats.hp) {
1169  stringbuffer_append_printf(buf, "(regeneration%+d)", op->stats.hp);
1170  }
1171  }
1172 
1173  if (op->stats.luck) {
1174  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
1175  }
1176  if (QUERY_FLAG(op, FLAG_LIFESAVE))
1177  stringbuffer_append_string(buf, "(lifesaving)");
1179  stringbuffer_append_string(buf, "(reflect spells)");
1181  stringbuffer_append_string(buf, "(reflect missiles)");
1182  if (QUERY_FLAG(op, FLAG_STEALTH))
1183  stringbuffer_append_string(buf, "(stealth)");
1184  if (op->slaying != NULL && op->type != FOOD) {
1185  stringbuffer_append_printf(buf, "(slay %s)", op->slaying);
1186  }
1187  describe_attacktype("Attacks", op->attacktype, buf);
1188  /* resistance on flesh is only visible for dragons. If
1189  * non flesh, everyone can see its resistances
1190  */
1191  if (op->type != FLESH || (owner && is_dragon_pl(owner))) {
1192  describe_resistance(op, 0, 1, buf);
1193  }
1194  describe_spellpath_attenuation("Attuned", op->path_attuned &~ op->path_denied, buf);
1195  describe_spellpath_attenuation("Repelled", op->path_repelled &~ op->path_denied, buf);
1196  describe_spellpath_attenuation("Denied", op->path_denied, buf);
1197  }
1198 
1199  return buf;
1200 }
1201 
1214 int is_magical(const object *op) {
1215  int i;
1216 
1217  /* living creatures are considered non magical */
1218  if (QUERY_FLAG(op, FLAG_ALIVE))
1219  return 0;
1220 
1221  /* This is a test for it being an artifact, as artifacts have titles */
1222  if (op->title != NULL)
1223  return 1;
1224 
1225  /* Handle rings and amulets specially. If they change any of these
1226  * values, it means they are magical.
1227  */
1228  if ((op->type == AMULET || op->type == RING)
1229  && (op->stats.ac || op->stats.food || op->stats.exp || op->stats.dam || op->stats.wc || op->stats.sp || op->stats.hp || op->stats.luck))
1230  return 1;
1231 
1232  /* Check for stealty, speed, flying, or just plain magic in the boots */
1233  /* Presume any boots that have a move_type are special. */
1234  if (op->type == BOOTS
1235  && ((QUERY_FLAG(op, FLAG_STEALTH) || op->move_type || op->stats.exp)))
1236  return 1;
1237 
1238  /* Take care of amulet/shield that reflects spells/missiles */
1239  if ((op->type == AMULET || op->type == SHIELD)
1241  return 1;
1242 
1243  /* Take care of helmet of xrays */
1244  if (op->type == HELMET
1245  && QUERY_FLAG(op, FLAG_XRAYS))
1246  return 1;
1247 
1248  /* Potions & rods are always magical. Wands/staves are also magical,
1249  * assuming they still have any charges left.
1250  */
1251  if (op->type == POTION || op->type == ROD || (op->type == WAND && op->stats.food))
1252  return 1;
1253 
1254  /* if something gives a protection, either positive or negative, its magical */
1255  /* This is really a pretty bad hack - as of now, ATNR_PHYSICAL is 0,
1256  * so this always works out fine.
1257  */
1258  for (i = ATNR_PHYSICAL+1; i < NROFATTACKS; i++)
1259  if (op->resist[i])
1260  return 1;
1261 
1262  /* Physical protection is expected on some item types, so they should
1263  * not be considered magical.
1264  */
1265  if (op->resist[ATNR_PHYSICAL]
1266  && op->type != HELMET
1267  && op->type != SHIELD
1268  && op->type != BOOTS
1269  && op->type != GLOVES
1270  && op->type != ARMOUR)
1271  return 1;
1272 
1273  /* power crystal, spellbooks, and scrolls are always magical. */
1274  if (op->magic
1275  || op->type == POWER_CRYSTAL
1276  || op->type == SPELLBOOK
1277  || op->type == SCROLL
1278  || op->type == GIRDLE)
1279  return 1;
1280 
1281  /* Check to see if it increases/decreases any stats */
1282  for (i = 0; i < NUM_STATS; i++)
1283  if (get_attr_value(&(op->stats), i) != 0)
1284  return 1;
1285 
1286  /* If it doesn't fall into any of the above categories, must
1287  * be non magical.
1288  */
1289  return 0;
1290 }
1291 
1311 int is_identifiable_type(const object *op) {
1312  /* Special case -- skill tools don't have an associated identification
1313  * skill but still need IDing. TODO: we should probably have per-tool ID
1314  * skills, e.g. thievery for lockpicks and thaumaturgy for talismans, but
1315  * currently there's no good way to do this because the identifyskill is
1316  * tied to the itemtype rather than to the arch. */
1317  if (op->type == SKILL_TOOL) return true;
1318 
1319  /* Sometimes an itemtype has no associated typedata?! */
1320  const typedata *td = get_typedata(op->type);
1321  return td && td->identifyskill;
1322 }
1323 
1335 int is_identified(const object *op) {
1337 }
1338 
1344  sstring key;
1345 
1346  key = object_get_value(op, "identified_face");
1347  if (key != NULL) {
1348  op->face = try_find_face(key, op->face);
1349  /* if the face is defined, clean the animation, because else
1350  * the face can be lost ; if an animation is defined, it'll be
1351  * processed later on */
1354  op->anim_speed = 0;
1355  op->animation = 0;
1356  object_set_value(op, "identified_face", NULL, 0);
1357  }
1358 
1359  if (object_get_value(op, "identified_anim_random") != NULL) {
1361  object_set_value(op, "identified_anim_random", NULL, 0);
1362  }
1363 
1364  key = object_get_value(op, "identified_anim_speed");
1365  if (key != NULL) {
1366  op->anim_speed = atoi(key);
1367  op->last_anim = 1;
1368  object_set_value(op, "identified_anim_speed", NULL, 0);
1369  }
1370 
1371  key = object_get_value(op, "identified_animation");
1372  if (key != NULL) {
1374  if (anim) {
1375  op->animation = anim;
1378  animate_object(op, op->facing);
1379  }
1380  object_set_value(op, "identified_animation", NULL, 0);
1381  }
1382 
1383  key = object_get_value(op, "identified_name");
1384  if (key != NULL) {
1385  FREE_AND_COPY(op->name, key);
1386  object_set_value(op, "identified_name", NULL, 0);
1387  }
1388  key = object_get_value(op, "identified_name_pl");
1389  if (key != NULL) {
1390  FREE_AND_COPY(op->name_pl, key);
1391  object_set_value(op, "identified_name_pl", NULL, 0);
1392  }
1393 }
1394 
1408 object *identify(object *op) {
1409  object *pl, *op1;
1410 
1413 
1415 
1416  /*
1417  * We want autojoining of equal objects:
1418  */
1421 
1422  if (QUERY_FLAG(op, FLAG_BLESSED))
1424 
1425  if (op->type == POTION) {
1426  if (op->inv && op->randomitems) {
1427  if (op->title)
1428  free_string(op->title);
1429  op->title = add_refcount(op->inv->name);
1430  } else if (op->arch) {
1431  free_string(op->name);
1432  op->name = add_refcount(op->arch->clone.name);
1433  free_string(op->name_pl);
1434  op->name_pl = add_refcount(op->arch->clone.name_pl);
1435  }
1436  }
1437 
1438  if (op->map) {
1439  /* If the object is on a map, make sure we update its face.
1440  * Also send name and such information to a player standing on it.
1441  */
1442  object *player = map_find_by_type(op->map, op->x, op->y, PLAYER);
1443 
1445  op1 = object_merge(op, GET_MAP_TOP(op->map, op->x, op->y));
1446  if (op1) op = op1;
1447 
1448  if (player)
1450 
1451  } else {
1453  op1 = object_merge(op, op->env->inv);
1454  if (op1) op = op1;
1455 
1456  if (pl)
1457  /* A lot of the values can change from an update - might as well send
1458  * it all.
1459  */
1461  }
1462  return op;
1463 }
CLASS
@ CLASS
Definition: object.h:138
FLAG_USE_BOW
#define FLAG_USE_BOW
Definition: define.h:293
UP_OBJ_FACE
#define UP_OBJ_FACE
Definition: object.h:520
TRIGGER
@ TRIGGER
Definition: object.h:129
MIMIC
@ MIMIC
Definition: object.h:249
PLAYER
@ PLAYER
Definition: object.h:107
global.h
UPD_FACE
#define UPD_FACE
Definition: newclient.h:317
add_refcount
sstring add_refcount(sstring str)
Definition: shstr.c:210
CF_HANDLE
@ CF_HANDLE
Definition: object.h:208
MAP
@ MAP
Definition: object.h:125
stringbuffer_new
StringBuffer * stringbuffer_new(void)
Definition: stringbuffer.c:57
NUM_BODY_LOCATIONS
#define NUM_BODY_LOCATIONS
Definition: object.h:13
MONSTER
@ MONSTER
Definition: object.h:200
BOW
@ BOW
Definition: object.h:118
BRACERS
@ BRACERS
Definition: object.h:217
GET_MAP_TOP
#define GET_MAP_TOP(M, X, Y)
Definition: map.h:175
CLOSE_CON
@ CLOSE_CON
Definition: object.h:229
FABS
#define FABS(x)
Definition: define.h:22
FLAG_CLIENT_ANIM_RANDOM
#define FLAG_CLIENT_ANIM_RANDOM
Definition: define.h:241
ARMOUR_IMPROVER
@ ARMOUR_IMPROVER
Definition: object.h:232
SYMPTOM
@ SYMPTOM
Definition: object.h:245
WAND
@ WAND
Definition: object.h:220
FLAG_USE_RING
#define FLAG_USE_RING
Definition: define.h:297
FLAG_UNDEAD
#define FLAG_UNDEAD
Definition: define.h:270
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
FLESH
@ FLESH
Definition: object.h:187
ENCOUNTER
@ ENCOUNTER
Definition: object.h:182
SK_ALCHEMY
@ SK_ALCHEMY
Definition: skills.h:25
GLOVES
@ GLOVES
Definition: object.h:213
GIRDLE
@ GIRDLE
Definition: object.h:223
BUTTON
@ BUTTON
Definition: object.h:207
object_update
void object_update(object *op, int action)
Definition: object.c:1407
diamondslots.x
x
Definition: diamondslots.py:15
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
FLAG_REFL_MISSILE
#define FLAG_REFL_MISSILE
Definition: define.h:273
TRIGGER_PEDESTAL
@ TRIGGER_PEDESTAL
Definition: object.h:134
KEY
@ KEY
Definition: object.h:127
FLAG_IS_TURNABLE
#define FLAG_IS_TURNABLE
Definition: define.h:256
FLAG_SEE_IN_DARK
#define FLAG_SEE_IN_DARK
Definition: define.h:337
calc_item_power
int calc_item_power(const object *op)
Definition: item.c:238
SHOP_FLOOR
@ SHOP_FLOOR
Definition: object.h:183
GEM
@ GEM
Definition: object.h:167
pl
Definition: player.h:92
TRAP
@ TRAP
Definition: object.h:241
ARMOUR
@ ARMOUR
Definition: object.h:120
WEAPON
@ WEAPON
Definition: object.h:119
TIMED_GATE
@ TIMED_GATE
Definition: object.h:128
typedata::identifyskill
int identifyskill
Definition: define.h:93
FLAG_SEE_INVISIBLE
#define FLAG_SEE_INVISIBLE
Definition: define.h:253
AMULET
@ AMULET
Definition: object.h:139
CHECK_INV
@ CHECK_INV
Definition: object.h:169
TREASURE
@ TREASURE
Definition: object.h:110
SKILL
@ SKILL
Definition: object.h:143
ARMOUR_SPELLS
#define ARMOUR_SPELLS(xyz)
Definition: define.h:467
RUNE
@ RUNE
Definition: object.h:240
Ice.tmp
int tmp
Definition: Ice.py:207
CREATOR
@ CREATOR
Definition: object.h:142
describe_resistance
StringBuffer * describe_resistance(const object *op, int newline, int use_media_tags, StringBuffer *buf)
Definition: item.c:368
FLAG_BLESSED
#define FLAG_BLESSED
Definition: define.h:369
ATNR_PHYSICAL
#define ATNR_PHYSICAL
Definition: attack.h:49
POTION_RESIST_EFFECT
@ POTION_RESIST_EFFECT
Definition: object.h:225
FLOOR
@ FLOOR
Definition: object.h:186
ARMOUR_SPEED
#define ARMOUR_SPEED(xyz)
Definition: define.h:466
SIGN
@ SIGN
Definition: object.h:211
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
TRIGGER_BUTTON
@ TRIGGER_BUTTON
Definition: object.h:132
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition: item.c:940
FLAG_INV_LOCKED
#define FLAG_INV_LOCKED
Definition: define.h:329
FLAG_APPLIED
#define FLAG_APPLIED
Definition: define.h:235
FLAG_STEALTH
#define FLAG_STEALTH
Definition: define.h:312
POWER_CRYSTAL
@ POWER_CRYSTAL
Definition: object.h:242
treasurestruct
Definition: treasure.h:63
POISONING
@ POISONING
Definition: object.h:218
describe_monster
StringBuffer * describe_monster(const object *op, int use_media_tags, StringBuffer *buf)
Definition: item.c:766
FLAG_ALIVE
#define FLAG_ALIVE
Definition: define.h:230
animate_object
void animate_object(object *op, int dir)
Definition: anim.c:43
object_merge
object * object_merge(object *op, object *top)
Definition: object.c:2018
object_get_value
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4354
TRIGGER_MARKER
@ TRIGGER_MARKER
Definition: object.h:153
identify
object * identify(object *op)
Definition: item.c:1408
free_string
void free_string(sstring str)
Definition: shstr.c:280
typedata
Definition: define.h:89
CLOAK
@ CLOAK
Definition: object.h:204
FMT64
#define FMT64
Definition: compat.h:16
NROF
static uint32_t NROF(const object *const ob)
Definition: object.h:612
HELMET
@ HELMET
Definition: object.h:136
POISON
@ POISON
Definition: object.h:113
DEEP_SWAMP
@ DEEP_SWAMP
Definition: object.h:236
is_identifiable_type
int is_identifiable_type(const object *op)
Definition: item.c:1311
SK_JEWELER
@ SK_JEWELER
Definition: skills.h:24
MARKER
@ MARKER
Definition: object.h:158
query_name
void query_name(const object *op, char *buf, size_t size)
Definition: item.c:584
SAVEBED
@ SAVEBED
Definition: object.h:219
FLAG_USE_RANGE
#define FLAG_USE_RANGE
Definition: define.h:292
FLAG_KNOWN_BLESSED
#define FLAG_KNOWN_BLESSED
Definition: define.h:370
LIGHTABLE
@ LIGHTABLE
Definition: object.h:250
POTION
@ POTION
Definition: object.h:111
FLAG_KNOWN_CURSED
#define FLAG_KNOWN_CURSED
Definition: define.h:320
BUILDER
@ BUILDER
Definition: object.h:246
SK_LITERACY
@ SK_LITERACY
Definition: skills.h:27
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition: stringbuffer.c:95
SK_BOWYER
@ SK_BOWYER
Definition: skills.h:23
ROD
@ ROD
Definition: object.h:109
CONTAINER
@ CONTAINER
Definition: object.h:231
INORGANIC
@ INORGANIC
Definition: object.h:188
LOCKED_DOOR
@ LOCKED_DOOR
Definition: object.h:123
PLAYERMOVER
@ PLAYERMOVER
Definition: object.h:140
query_short_name
void query_short_name(const object *op, char *buf, size_t size)
Definition: item.c:509
FLAG_MAKE_INVIS
#define FLAG_MAKE_INVIS
Definition: define.h:328
SPECIAL_KEY
@ SPECIAL_KEY
Definition: object.h:124
HOLE
@ HOLE
Definition: object.h:209
PEACEMAKER
@ PEACEMAKER
Definition: object.h:164
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Definition: global.h:202
CONVERTER
@ CONVERTER
Definition: object.h:216
SKILLSCROLL
@ SKILLSCROLL
Definition: object.h:234
FLAG_DAMNED
#define FLAG_DAMNED
Definition: define.h:317
UPD_FLAGS
#define UPD_FLAGS
Definition: newclient.h:315
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
is_magical
int is_magical(const object *op)
Definition: item.c:1214
LAMP
@ LAMP
Definition: object.h:201
GOLEM
@ GOLEM
Definition: object.h:145
object_set_value
int object_set_value(object *op, const char *key, const char *value, int add_key)
Definition: object.c:4489
sstring
const typedef char * sstring
Definition: global.h:40
FLAG_UNAGGRESSIVE
#define FLAG_UNAGGRESSIVE
Definition: define.h:272
object_give_identified_properties
void object_give_identified_properties(object *op)
Definition: item.c:1343
MOOD_FLOOR
@ MOOD_FLOOR
Definition: object.h:170
resist_plus
const EXTERN char *const resist_plus[NROFATTACKS]
Definition: attack.h:136
FLAG_USE_WEAPON
#define FLAG_USE_WEAPON
Definition: define.h:296
ARROW
@ ARROW
Definition: object.h:117
FLAG_CAN_USE_SKILL
#define FLAG_CAN_USE_SKILL
Definition: define.h:321
animate.anim
string anim
Definition: animate.py:20
resist_color
const EXTERN char *const resist_color[NROFATTACKS]
Definition: attack.h:137
BOOK
@ BOOK
Definition: object.h:114
is_dragon_pl
int is_dragon_pl(const object *op)
Definition: player.c:125
RING
@ RING
Definition: object.h:185
BLINDNESS
@ BLINDNESS
Definition: object.h:147
ring_desc
static StringBuffer * ring_desc(const object *op, int use_media_tags, StringBuffer *buf)
Definition: item.c:434
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
describe_spellpath_attenuation
StringBuffer * describe_spellpath_attenuation(const char *attenuation, int value, StringBuffer *buf)
Definition: utils.c:534
CLOCK
@ CLOCK
Definition: object.h:115
bits_set
static int bits_set(uint32_t x, int start, int end)
Definition: item.c:218
FLAG_HITBACK
#define FLAG_HITBACK
Definition: define.h:267
strlcpy
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: porting.c:220
SHOP_MAT
@ SHOP_MAT
Definition: object.h:184
try_find_animation
Animations * try_find_animation(const char *name)
Definition: assets.cpp:294
StringBuffer
Definition: stringbuffer.c:25
MOVE_FLY_LOW
#define MOVE_FLY_LOW
Definition: define.h:393
FLAG_CLIENT_ANIM_SYNC
#define FLAG_CLIENT_ANIM_SYNC
Definition: define.h:240
item_types
static const typedata item_types[]
Definition: item.c:78
EXIT
@ EXIT
Definition: object.h:181
FLAG_KNOWN_MAGICAL
#define FLAG_KNOWN_MAGICAL
Definition: define.h:319
MAGIC_EAR
@ MAGIC_EAR
Definition: object.h:131
get_typedata_by_name
const typedata * get_typedata_by_name(const char *name)
Definition: item.c:339
animations_struct
Definition: face.h:25
FLAG_REFL_SPELL
#define FLAG_REFL_SPELL
Definition: define.h:275
llevInfo
@ llevInfo
Definition: logger.h:12
SK_WOODSMAN
@ SK_WOODSMAN
Definition: skills.h:40
change_resist_msg
const EXTERN char *const change_resist_msg[NROFATTACKS]
Definition: attack.h:135
enc_to_item_power
static const int enc_to_item_power[]
Definition: item.c:203
Floor.t
t
Definition: Floor.py:62
FLAG_FRIENDLY
#define FLAG_FRIENDLY
Definition: define.h:246
spells.h
BATTLEGROUND
@ BATTLEGROUND
Definition: object.h:163
WEAPON_SPEED
#define WEAPON_SPEED(xyz)
Definition: define.h:468
GRIMREAPER
@ GRIMREAPER
Definition: object.h:130
FLAG_USE_ARMOUR
#define FLAG_USE_ARMOUR
Definition: define.h:295
FLAG_CAST_SPELL
#define FLAG_CAST_SPELL
Definition: define.h:290
EARTHWALL
@ EARTHWALL
Definition: object.h:144
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
DUPLICATOR
@ DUPLICATOR
Definition: object.h:202
DISEASE
@ DISEASE
Definition: object.h:244
FIREWALL
@ FIREWALL
Definition: object.h:168
TRIGGER_ALTAR
@ TRIGGER_ALTAR
Definition: object.h:133
PLAYER_CHANGER
@ PLAYER_CHANGER
Definition: object.h:162
query_weight
void query_weight(const object *op, char *buf, size_t size)
Definition: item.c:411
item_types_size
static const int item_types_size
Definition: item.c:192
LIGHTER
@ LIGHTER
Definition: object.h:190
give.op
op
Definition: give.py:33
get_power_from_ench
int get_power_from_ench(int ench)
Definition: item.c:210
MATERIAL
@ MATERIAL
Definition: object.h:248
stringbuffer_length
size_t stringbuffer_length(StringBuffer *sb)
Definition: stringbuffer.c:184
FLAG_REFLECTING
#define FLAG_REFLECTING
Definition: define.h:262
query_base_name
void query_base_name(const object *op, int plural, char *buf, size_t size)
Definition: item.c:685
SPINNER
@ SPINNER
Definition: object.h:205
SPELL_EFFECT
@ SPELL_EFFECT
Definition: object.h:215
map_find_by_type
object * map_find_by_type(mapstruct *m, int x, int y, uint8_t type)
Definition: object.c:3095
SKILL_TOOL
@ SKILL_TOOL
Definition: object.h:189
SHOP_INVENTORY
@ SHOP_INVENTORY
Definition: object.h:238
PEDESTAL
@ PEDESTAL
Definition: object.h:121
FLAG_BEEN_APPLIED
#define FLAG_BEEN_APPLIED
Definition: define.h:323
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
buf
StringBuffer * buf
Definition: readable.c:1606
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition: stringbuffer.c:104
short_stat_name
const char *const short_stat_name[NUM_STATS]
Definition: living.c:195
get_typedata
const typedata * get_typedata(int itemtype)
Definition: item.c:319
DEAD_OBJECT
@ DEAD_OBJECT
Definition: object.h:156
DIRECTOR
@ DIRECTOR
Definition: object.h:222
CORPSE
@ CORPSE
Definition: object.h:243
castle_read.key
key
Definition: castle_read.py:64
MIN_ACTIVE_SPEED
#define MIN_ACTIVE_SPEED
Definition: define.h:637
FLAG_ANIMATE
#define FLAG_ANIMATE
Definition: define.h:242
UPD_NAME
#define UPD_NAME
Definition: newclient.h:318
describe_attacktype
StringBuffer * describe_attacktype(const char *attack, int value, StringBuffer *buf)
Definition: utils.c:562
get_attr_value
int8_t get_attr_value(const living *stats, int attr)
Definition: living.c:314
SK_SMITHERY
@ SK_SMITHERY
Definition: skills.h:22
FOOD
@ FOOD
Definition: object.h:112
MOVE_FLY_HIGH
#define MOVE_FLY_HIGH
Definition: define.h:394
ALTAR
@ ALTAR
Definition: object.h:122
DOOR
@ DOOR
Definition: object.h:126
FLAG_UNPAID
#define FLAG_UNPAID
Definition: define.h:236
try_find_face
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:306
SK_THAUMATURGY
@ SK_THAUMATURGY
Definition: skills.h:48
DRINK
@ DRINK
Definition: object.h:157
UPD_ALL
#define UPD_ALL
Definition: newclient.h:322
WALL
@ WALL
Definition: object.h:191
WEAPON_IMPROVER
@ WEAPON_IMPROVER
Definition: object.h:233
SCROLL
@ SCROLL
Definition: object.h:221
FLAG_XRAYS
#define FLAG_XRAYS
Definition: define.h:300
object_find_by_type_and_name
object * object_find_by_type_and_name(const object *who, int type, const char *name)
Definition: object.c:4116
body_locations_struct
Definition: object.h:20
esrv_update_item
void esrv_update_item(int flags, object *pl, object *op)
Definition: item.c:410
atnr_is_dragon_enabled
int atnr_is_dragon_enabled(int attacknr)
Definition: player.c:106
MOVE_SWIM
#define MOVE_SWIM
Definition: define.h:396
BOOTS
@ BOOTS
Definition: object.h:212
object_get_player_container
object * object_get_player_container(object *op)
Definition: object.c:600
IDENTIFY_ALTAR
@ IDENTIFY_ALTAR
Definition: object.h:237
SPELL
@ SPELL
Definition: object.h:214
SHIELD
@ SHIELD
Definition: object.h:135
FLAG_NO_SKILL_IDENT
#define FLAG_NO_SKILL_IDENT
Definition: define.h:335
FLAG_USE_SCROLL
#define FLAG_USE_SCROLL
Definition: define.h:291
FLAG_CURSED
#define FLAG_CURSED
Definition: define.h:316
TELEPORTER
@ TELEPORTER
Definition: object.h:141
body_locations
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
Definition: item.c:54
altar_valkyrie.pl
pl
Definition: altar_valkyrie.py:28
living.h
if
if(!(yy_init))
Definition: loader.c:2589
THROWN_OBJ
@ THROWN_OBJ
Definition: object.h:146
SPELLBOOK
@ SPELLBOOK
Definition: object.h:203
NUM_STATS
@ NUM_STATS
Definition: living.h:18
FORCE
@ FORCE
Definition: object.h:224
HOLY_ALTAR
@ HOLY_ALTAR
Definition: object.h:161
TRAPDOOR
@ TRAPDOOR
Definition: object.h:210
DETECTOR
@ DETECTOR
Definition: object.h:149
safe_strcat
void safe_strcat(char *dest, const char *orig, size_t *curlen, size_t maxlen)
Definition: porting.c:200
GOD
@ GOD
Definition: object.h:148
FLAG_LIFESAVE
#define FLAG_LIFESAVE
Definition: define.h:305
MISC_OBJECT
@ MISC_OBJECT
Definition: object.h:193
MONEY
@ MONEY
Definition: object.h:137
NRSPELLPATHS
#define NRSPELLPATHS
Definition: spells.h:40
GATE
@ GATE
Definition: object.h:206
FLAG_IDENTIFIED
#define FLAG_IDENTIFIED
Definition: define.h:261
give.name
name
Definition: give.py:27
is_identified
int is_identified(const object *op)
Definition: item.c:1335