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