Crossfire Server, Trunk  R20513
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 
72 static const char *const numbers_10[] = {
73  "zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy",
74  "eighty", "ninety"
75 };
76 
78 static const char *const levelnumbers[] = {
79  "zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh",
80  "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth",
81  "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth",
82  "nineteenth", "twentieth"
83 };
84 
86 static const char *const levelnumbers_10[] = {
87  "zeroth", "tenth", "twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth",
88  "seventieth", "eightieth", "ninetieth"
89 };
90 
98 static const typedata item_types[] = {
99  { 0, "none", "none", 0, 0 },
100  { PLAYER, "player", "players", 0, 0 },
101  { ROD, "rod", "rods", SK_THAUMATURGY, 0 },
102  { TREASURE, "treasure", "treasure", 0, 0 },
103  { POTION, "potion", "potions", SK_ALCHEMY, 0 },
104  { FOOD, "food", "food", SK_WOODSMAN, 0 },
105  { POISON, "poison", "poisons", SK_ALCHEMY, 0 },
106  { BOOK, "book", "books", SK_LITERACY, 0 },
107  { CLOCK, "clock", "clocks", 0, 0 },
108  { ARROW, "arrow", "arrows", SK_BOWYER, 0 },
109  { BOW, "bow", "bows", SK_BOWYER, 0 },
110  { WEAPON, "weapon", "weapons", SK_SMITHERY, 0 },
111  { ARMOUR, "armour", "armour", SK_SMITHERY, 0 },
112  { PEDESTAL, "pedestal", "pedestals", 0, 0 },
113  { ALTAR, "altar", "altars", 0, 0 },
114  { LOCKED_DOOR, "locked door", "locked doors", 0, 0 },
115  { SPECIAL_KEY, "special key", "special keys", 0, 0 },
116  { MAP, "map", "maps", 0, 0 },
117  { DOOR, "door", "doors", 0, 0 },
118  { KEY, "key", "keys", 0, 0 },
119  { TIMED_GATE, "timed_gate", "timed_gates", 0, 0 },
120  { TRIGGER, "trigger", "triggers", 0, 0 },
121  { GRIMREAPER, "grimreaper", "grimreapers", 0, 0 },
122  { MAGIC_EAR, "magic ear", "magic ears", 0, 0 },
123  { TRIGGER_BUTTON, "trigger button", "trigger buttons", 0, 0 },
124  { TRIGGER_ALTAR, "trigger altar", "trigger altars", 0, 0 },
125  { TRIGGER_PEDESTAL, "trigger pedestal", "trigger pedestals", 0, 0 },
126  { SHIELD, "shield", "shields", SK_SMITHERY, 0 },
127  { HELMET, "helmet", "helmets", SK_SMITHERY, 0 },
128  { MONEY, "money", "money", 0, 0 },
129  { CLASS, "class", "classes", 0, 0 },
130  { AMULET, "amulet", "amulets", SK_JEWELER, 0 },
131  { PLAYERMOVER, "player mover", "player movers", 0, 0 },
132  { TELEPORTER, "teleporter", "teleporters", 0, 0 },
133  { CREATOR, "creator", "creators", 0, 0 },
134  { SKILL, "skill", "skills", 0, 0 },
135  { EARTHWALL, "earthwall", "earthwalls", 0, 0 },
136  { GOLEM, "golem", "golems", 0, 0 },
137  { THROWN_OBJ, "projectile", "projectiles", 0, 0 },
138  { BLINDNESS, "blindness", "blindness", 0, 0 },
139  { GOD, "god", "gods", 0, 0 },
140  { DETECTOR, "detector", "detectors", 0, 0 },
141  { TRIGGER_MARKER, "trigger marker", "trigger markers", 0, 0 },
142  { DEAD_OBJECT, "dead object", "dead objects", 0, 0 },
143  { DRINK, "drink", "drinks", SK_WOODSMAN, SK_ALCHEMY },
144  { MARKER, "marker", "markers", 0, 0 },
145  { HOLY_ALTAR, "holy altar", "holy altars", 0, 0 },
146  { PLAYER_CHANGER, "player changer", "player changers", 0, 0 },
147  { BATTLEGROUND, "battleground", "battlegrounds", 0, 0 },
148  { PEACEMAKER, "peacemaker", "peacemakers", 0, 0 },
149  { GEM, "gem", "gems", SK_JEWELER, 0 },
150  { FIREWALL, "firewall", "firewalls", 0, 0 },
151  { CHECK_INV, "inventory checker", "inventory checkers", 0, 0 },
152  { MOOD_FLOOR, "mood floor", "mood floors", 0, 0 },
153  { EXIT, "exit", "exits", 0, 0 },
154  { ENCOUNTER, "encounter", "encounters", 0, 0 },
155  { SHOP_FLOOR, "shop floor", "shop floors", 0, 0 },
156  { SHOP_MAT, "shop mat", "shop mats", 0, 0 },
157  { RING, "ring", "rings", SK_JEWELER, 0 },
158  { FLOOR, "floor", "floors", 0, 0 },
159  { FLESH, "flesh", "flesh", SK_WOODSMAN, 0 },
160  { INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0 },
161  { SKILL_TOOL, "skill tool", "skill tools", 0, 0 },
162  { LIGHTER, "lighter", "lighters", 0, 0 },
163  { WALL, "wall", "walls", 0, 0 },
164  { MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0 },
165  { MONSTER, "monster", "monsters", 0, 0 },
166  { LAMP, "lamp", "lamps", 0, 0 },
167  { DUPLICATOR, "duplicator", "duplicators", 0, 0 },
168  { SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0 },
169  { CLOAK, "cloak", "cloaks", SK_SMITHERY, 0 },
170  { SPINNER, "spinner", "spinners", 0, 0 },
171  { GATE, "gate", "gates", 0, 0 },
172  { BUTTON, "button", "buttons", 0, 0 },
173  { CF_HANDLE, "cf handle", "cf handles", 0, 0 },
174  { HOLE, "hole", "holes", 0, 0 },
175  { TRAPDOOR, "trapdoor", "trapdoors", 0, 0 },
176  { SIGN, "sign", "signs", 0, 0 },
177  { BOOTS, "boots", "boots", SK_SMITHERY, 0 },
178  { GLOVES, "gloves", "gloves", SK_SMITHERY, 0 },
179  { SPELL, "spell", "spells", 0, 0 },
180  { SPELL_EFFECT, "spell effect", "spell effects", 0, 0 },
181  { CONVERTER, "converter", "converters", 0, 0 },
182  { BRACERS, "bracers", "bracers", SK_SMITHERY, 0 },
183  { POISONING, "poisoning", "poisonings", 0, 0 },
184  { SAVEBED, "savebed", "savebeds", 0, 0 },
185  { WAND, "wand", "wands", SK_THAUMATURGY, 0 },
186  { SCROLL, "scroll", "scrolls", SK_LITERACY, 0 },
187  { DIRECTOR, "director", "directors", 0, 0 },
188  { GIRDLE, "girdle", "girdles", SK_SMITHERY, 0 },
189  { FORCE, "force", "forces", 0, 0 },
190  { POTION_RESIST_EFFECT, "potion effect", "potion effects", 0, 0 },
191  { CLOSE_CON, "closed container", "closed container", 0, 0 },
192  { CONTAINER, "container", "containers", SK_ALCHEMY, 0 },
193  { ARMOUR_IMPROVER, "armour improver", "armour improvers", SK_LITERACY, 0 },
194  { WEAPON_IMPROVER, "weapon improver", "weapon improvers", SK_LITERACY, 0 },
195  { SKILLSCROLL, "skillscroll", "skillscrolls", SK_LITERACY, 0 },
196  { DEEP_SWAMP, "deep swamp", "deep swamps", 0, 0 },
197  { IDENTIFY_ALTAR, "identify altar", "identify altars", 0, 0 },
198  { SHOP_INVENTORY, "inventory list", "inventory lists", 0, 0 },
199  { RUNE, "rune", "runes", 0, 0 },
200  { TRAP, "trap", "traps", 0, 0 },
201  { POWER_CRYSTAL, "power_crystal", "power_crystals", 0, 0 },
202  { CORPSE, "corpse", "corpses", 0, 0 },
203  { DISEASE, "disease", "diseases", 0, 0 },
204  { SYMPTOM, "symptom", "symptoms", 0, 0 },
205  { BUILDER, "item builder", "item builders", 0, 0 },
206  { MATERIAL, "building material", "building materials", 0, 0 },
207 };
208 
210 static const int item_types_size = sizeof(item_types)/sizeof(*item_types);
211 
221 static const int enc_to_item_power[] = {
222  0, 0, 1, 2, 3, 4, /* 5 */
223  5, 7, 9, 11, 13, /* 10 */
224  15, 18, 21, 24, 27, /* 15 */
225  30, 35, 40, 45, 50 /* 20 */
226 };
227 
228 int get_power_from_ench(int ench) {
229  if (ench < 0)
230  ench = 0;
231  if (ench > (int)(sizeof(enc_to_item_power)/sizeof(*enc_to_item_power)-1))
232  ench = sizeof(enc_to_item_power)/sizeof(*enc_to_item_power)-1;
233  return enc_to_item_power[ench];
234 }
235 
246 int calc_item_power(const object *op) {
247  int i, tmp, enc;
248 
249  enc = 0;
250  for (i = 0; i < NUM_STATS; i++)
251  enc += get_attr_value(&op->stats, i);
252 
253  /* This protection logic is pretty flawed. 20% fire resistance
254  * is much more valuable than 20% confusion, or 20% slow, or
255  * several others. Start at 1 - ignore physical - all that normal
256  * armour shouldn't be counted against
257  */
258  tmp = 0;
259  for (i = 1; i < NROFATTACKS; i++)
260  tmp += op->resist[i];
261 
262  /* Add/substract 10 so that the rounding works out right */
263  if (tmp > 0)
264  enc += (tmp+10)/20;
265  else if (tmp < 0)
266  enc += (tmp-10)/20;
267 
268  enc += op->magic;
269 
270  /* For each attacktype a weapon has, one more encantment. Start at 1 -
271  * physical doesn't count against total.
272  */
273  if (op->type == WEAPON) {
274  for (i = 1; i < NROFATTACKS; i++)
275  if (op->attacktype&(1<<i))
276  enc++;
277  if (op->slaying)
278  enc += 2; /* What it slays is probably more relevent */
279  }
280  /* Items the player can equip */
281  if ((op->type == WEAPON)
282  || (op->type == ARMOUR)
283  || (op->type == HELMET)
284  || (op->type == SHIELD)
285  || (op->type == RING)
286  || (op->type == BOOTS)
287  || (op->type == GLOVES)
288  || (op->type == AMULET)
289  || (op->type == GIRDLE)
290  || (op->type == BRACERS)
291  || (op->type == CLOAK)) {
292  enc += op->stats.food; /* sustenance */
293  enc += op->stats.hp; /* hp regen */
294  enc += op->stats.sp; /* mana regen */
295  enc += op->stats.grace; /* grace regen */
296  enc += op->stats.exp; /* speed bonus */
297  }
298  enc += op->stats.luck;
299 
300  /* Do spell paths now */
301  for (i = 1; i < NRSPELLPATHS; i++) {
302  if (op->path_attuned&(1<<i))
303  enc++;
304  else if (op->path_denied&(1<<i))
305  enc -= 2;
306  else if (op->path_repelled&(1<<i))
307  enc--;
308  }
309 
310  if (QUERY_FLAG(op, FLAG_LIFESAVE))
311  enc += 5;
312  if (QUERY_FLAG(op, FLAG_REFL_SPELL))
313  enc += 3;
314  if (QUERY_FLAG(op, FLAG_REFL_MISSILE))
315  enc += 2;
316  if (QUERY_FLAG(op, FLAG_STEALTH))
317  enc += 1;
318  if (QUERY_FLAG(op, FLAG_XRAYS))
319  enc += 2;
320  if (QUERY_FLAG(op, FLAG_SEE_IN_DARK))
321  enc += 1;
322  if (QUERY_FLAG(op, FLAG_MAKE_INVIS))
323  enc += 1;
324 
325  return get_power_from_ench(enc);
326 }
327 
334 const typedata *get_typedata(int itemtype) {
335  int i;
336 
337  for (i = 0; i < item_types_size; i++)
338  if (item_types[i].number == itemtype)
339  return &item_types[i];
340  return NULL;
341 }
342 
354 const typedata *get_typedata_by_name(const char *name) {
355  int i;
356 
357  for (i = 0; i < item_types_size; i++)
358  if (!strcmp(item_types[i].name, name))
359  return &item_types[i];
360  for (i = 0; i < item_types_size; i++)
361  if (!strcmp(item_types[i].name_pl, name)) {
362  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);
363  return &item_types[i];
364  }
365  return NULL;
366 }
367 
383 StringBuffer *describe_resistance(const object *op, int newline, int use_media_tags, StringBuffer *buf) {
384  int tmpvar;
385 
386  if (buf == NULL)
387  buf = stringbuffer_new();
388 
389  for (tmpvar = 0; tmpvar < NROFATTACKS; tmpvar++) {
390  if (op->resist[tmpvar] && (op->type != FLESH || atnr_is_dragon_enabled(tmpvar) == 1)) {
391  if (use_media_tags) {
392  if (resist_color[tmpvar] != NULL) {
393  stringbuffer_append_printf(buf, "[color=%s]", resist_color[tmpvar]);
394  }
395  if (op->resist[tmpvar] == 100 || op->resist[tmpvar] == -100) {
396  stringbuffer_append_string(buf, "[ul]");
397  }
398  }
399  if (!newline)
400  stringbuffer_append_printf(buf, "(%s %+d)", resist_plus[tmpvar], op->resist[tmpvar]);
401  else
402  stringbuffer_append_printf(buf, "%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]);
403  if (use_media_tags) {
404  if (op->resist[tmpvar] == 100 || op->resist[tmpvar] == -100) {
405  stringbuffer_append_string(buf, "[/ul]");
406  }
407  if (resist_color[tmpvar] != NULL) {
408  stringbuffer_append_string(buf, "[/color]");
409  }
410  }
411  }
412  }
413 
414  return buf;
415 }
416 
426 void query_weight(const object *op, char *buf, size_t size) {
427  int32_t i = (op->nrof ? op->nrof : 1)*op->weight+op->carrying;
428 
429  if (op->weight < 0)
430  snprintf(buf, size, " ");
431  else if (i%1000)
432  snprintf(buf, size, "%6.1f", i/1000.0);
433  else
434  snprintf(buf, size, "%4d ", i/1000);
435 }
436 
446 void get_levelnumber(int i, char *buf, size_t size) {
447  if (i > 99 || i < 0) {
448  snprintf(buf, size, "%d.", i);
449  return;
450  }
451  if (i < 21) {
452  snprintf(buf, size, "%s", levelnumbers[i]);
453  return;
454  }
455  if (!(i%10)) {
456  snprintf(buf, size, "%s", levelnumbers_10[i/10]);
457  return;
458  }
459  snprintf(buf, size, "%s%s", numbers_10[i/10], levelnumbers[i%10]);
460  return;
461 }
462 
472 static StringBuffer *ring_desc(const object *op, StringBuffer *buf) {
473  int attr, val;
474  size_t len;
475 
476  assert(op != NULL);
477  assert(op->type == RING || op->type == AMULET || op->type == SKILL);
478 
479  if (buf == NULL)
480  buf = stringbuffer_new();
481  len = stringbuffer_length(buf);
482 
483  if (!QUERY_FLAG(op, FLAG_IDENTIFIED))
484  return buf;
485 
486  for (attr = 0; attr < NUM_STATS; attr++) {
487  if ((val = get_attr_value(&(op->stats), attr)) != 0) {
488  stringbuffer_append_printf(buf, "(%s%+d)", short_stat_name[attr], val);
489  }
490  }
491  if (op->stats.exp)
492  stringbuffer_append_printf(buf, "(speed %+"FMT64")", op->stats.exp);
493  if (op->stats.wc)
494  stringbuffer_append_printf(buf, "(wc%+d)", op->stats.wc);
495  if (op->stats.dam)
496  stringbuffer_append_printf(buf, "(dam%+d)", op->stats.dam);
497  if (op->stats.ac)
498  stringbuffer_append_printf(buf, "(ac%+d)", op->stats.ac);
499 
500  describe_resistance(op, 0, 1, buf);
501 
502  if (op->stats.food != 0)
503  stringbuffer_append_printf(buf, "(sustenance%+d)", op->stats.food);
504  if (op->stats.grace)
505  stringbuffer_append_printf(buf, "(grace%+d)", op->stats.grace);
506  if (op->stats.sp && op->type != SKILL)
507  stringbuffer_append_printf(buf, "(magic%+d)", op->stats.sp);
508  if (op->stats.hp)
509  stringbuffer_append_printf(buf, "(regeneration%+d)", op->stats.hp);
510  if (op->stats.luck)
511  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
512  if (QUERY_FLAG(op, FLAG_LIFESAVE))
513  stringbuffer_append_printf(buf, "(lifesaving)");
514  if (QUERY_FLAG(op, FLAG_REFL_SPELL))
515  stringbuffer_append_printf(buf, "(reflect spells)");
516  if (QUERY_FLAG(op, FLAG_REFL_MISSILE))
517  stringbuffer_append_printf(buf, "(reflect missiles)");
518  if (QUERY_FLAG(op, FLAG_STEALTH))
519  stringbuffer_append_printf(buf, "(stealth)");
520  if (op->glow_radius)
521  stringbuffer_append_string(buf, "(glowing)");
522 
523  describe_spellpath_attenuation("Attuned", op->path_attuned, buf);
524  describe_spellpath_attenuation("Repelled", op->path_repelled, buf);
525  describe_spellpath_attenuation("Denied", op->path_denied, buf);
526 
527  /* item_power is done by the caller */
528  /* if (op->item_power)
529  snprintf(buf+strlen(buf), size-strlen(buf), "(item_power %+d)", op->item_power);*/
530  if (stringbuffer_length(buf) == len && op->type != SKILL)
531  stringbuffer_append_string(buf, "of adornment");
532 
533  return buf;
534 }
535 
547 void query_short_name(const object *op, char *buf, size_t size) {
548  size_t len = 0;
549 
550  if (op->name == NULL) {
551  snprintf(buf, size, "(null)");
552  return;
553  }
554  if (!op->nrof && !op->weight && !op->title && !is_magical(op)) {
555  snprintf(buf, size, "%s", op->name); /* To speed things up (or make things slower?) */
556  return;
557  }
558  buf[0] = '\0';
559 
560  if (op->nrof <= 1)
561  safe_strcat(buf, op->name, &len, size);
562  else
563  safe_strcat(buf, op->name_pl, &len, size);
564 
565  if (op->title && QUERY_FLAG(op, FLAG_IDENTIFIED)) {
566  safe_strcat(buf, " ", &len, size);
567  safe_strcat(buf, op->title, &len, size);
568  }
569 
570  switch (op->type) {
571  case SPELLBOOK:
572  case SCROLL:
573  case WAND:
574  case ROD:
576  if (!op->title) {
577  safe_strcat(buf, " of ", &len, size);
578  if (op->inv)
579  safe_strcat(buf, op->inv->name, &len, size);
580  else
581  LOG(llevError, "Spellbook %s lacks inventory\n", op->name);
582  }
583  if (op->type != SPELLBOOK) {
584  snprintf(buf+len, size-len, " (lvl %d)", op->level);
585  len += strlen(buf+len);
586  }
587  }
588  break;
589 
590  case SKILL:
591  case AMULET:
592  case RING:
593  if (!op->title) {
594  /* If ring has a title, full description isn't so useful */
595  char* desc;
596 
597  desc = stringbuffer_finish(ring_desc(op, NULL));
598  if (desc[0]) {
599  safe_strcat(buf, " ", &len, size);
600  safe_strcat(buf, desc, &len, size);
601  }
602  free(desc);
603  }
604  break;
605 
606  default:
607  if (op->magic
609  snprintf(buf+len, size-len, " %+d", op->magic);
610  len += strlen(buf+len);
611  }
612  }
613 }
614 
625 void query_name(const object *op, char *buf, size_t size) {
626  size_t len = 0;
627 
628  buf[0] = '\0';
629  /*
630  * Since len is initialized to zero, but is not changed
631  * up to this point, I see no reason to have buf+len and size-len;
632  * buf and size should suffice, since we're just adding and
633  * subtracting zero here, anyway.
634  *
635  * SilverNexus 2014-06-04
636  */
637  query_short_name(op, buf, size);
638  len = strlen(buf);
639 
640  if (QUERY_FLAG(op, FLAG_INV_LOCKED))
641  safe_strcat(buf, " *", &len, size);
642  if (op->type == CONTAINER
643  && ((op->env && op->env->container == op) || (!op->env && QUERY_FLAG(op, FLAG_APPLIED))))
644  safe_strcat(buf, " (open)", &len, size);
645 
646  if (QUERY_FLAG(op, FLAG_KNOWN_CURSED)) {
647  if (QUERY_FLAG(op, FLAG_DAMNED))
648  safe_strcat(buf, " (damned)", &len, size);
649  else if (QUERY_FLAG(op, FLAG_CURSED))
650  safe_strcat(buf, " (cursed)", &len, size);
651  }
653  safe_strcat(buf, " (blessed)", &len, size);
654 
655  /* Basically, if the object is known magical (detect magic spell on it),
656  * and it isn't identified, print out the fact that
657  * it is magical. Assume that the detect magical spell will only set
658  * KNOWN_MAGICAL if the item actually is magical.
659  *
660  * Changed in V 0.91.4 - still print that the object is magical even
661  * if it has been applied. Equipping an item does not tell full
662  * abilities, especially for artifact items.
663  */
665  safe_strcat(buf, " (magic)", &len, size);
666 
667  if (QUERY_FLAG(op, FLAG_APPLIED)) {
668  switch (op->type) {
669  case BOW:
670  case WAND:
671  case ROD:
672  safe_strcat(buf, " (readied)", &len, size);
673  break;
674 
675  case WEAPON:
676  safe_strcat(buf, " (wielded)", &len, size);
677  break;
678 
679  case ARMOUR:
680  case HELMET:
681  case SHIELD:
682  case RING:
683  case BOOTS:
684  case GLOVES:
685  case AMULET:
686  case GIRDLE:
687  case BRACERS:
688  case CLOAK:
689  safe_strcat(buf, " (worn)", &len, size);
690  break;
691 
692  case CONTAINER:
693  safe_strcat(buf, " (active)", &len, size);
694  break;
695 
696  case SKILL:
697  default:
698  safe_strcat(buf, " (applied)", &len, size);
699  }
700  }
701  if (QUERY_FLAG(op, FLAG_UNPAID))
702  safe_strcat(buf, " (unpaid)", &len, size);
703 }
704 
722 void query_base_name(const object *op, int plural, char *buf, size_t size) {
723  size_t len;
724 
725  if ((!plural && !op->name)
726  || (plural && !op->name_pl)) {
727  strncpy(buf, "(null)", size);
728  return;
729  }
730 
731  if (!op->nrof && !op->weight && !op->title && !is_magical(op)) {
732  strncpy(buf, op->name, size); /* To speed things up (or make things slower?) */
733  return;
734  }
735 
736  buf[0] = '\0';
737 
738  snprintf(buf, size, "%s", plural ? op->name_pl : op->name);
739  len = strlen(buf);
740 
741  if (op->title && QUERY_FLAG(op, FLAG_IDENTIFIED)) {
742  safe_strcat(buf, " ", &len, size);
743  safe_strcat(buf, op->title, &len, size);
744  }
745 
746  switch (op->type) {
747  case SPELLBOOK:
748  case SCROLL:
749  case WAND:
750  case ROD:
752  if (!op->title) {
753  safe_strcat(buf, " of ", &len, size);
754  if (op->inv)
755  safe_strcat(buf, op->inv->name, &len, size);
756  else
757  LOG(llevError, "Spellbook %s lacks inventory\n", op->name);
758  }
759  if (op->type != SPELLBOOK) {
760  snprintf(buf+len, size-len, " (lvl %d)", op->level);
761  len += strlen(buf+len);
762  }
763  }
764  break;
765 
766  case SKILL:
767  case AMULET:
768  case RING:
769  if (!op->title) {
770  /* If ring has a title, full description isn't so useful */
771  char* s;
772 
773  s = stringbuffer_finish(ring_desc(op, NULL));
774  if (s[0]) {
775  safe_strcat(buf, " ", &len, size);
776  safe_strcat(buf, s, &len, size);
777  }
778  free(s);
779  }
780  break;
781 
782  default:
783  if (op->magic
785  snprintf(buf+strlen(buf), size-strlen(buf), " %+d", op->magic);
786  }
787  }
788 }
789 
806 StringBuffer *describe_monster(const object *op, int use_media_tags, StringBuffer *buf) {
807  assert(op != NULL);
808  assert(QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER);
809 
810  if (buf == NULL)
811  buf = stringbuffer_new();
812 
813  /* Note that the resolution this provides for players really isn't
814  * very good. Any player with a speed greater than .67 will
815  * fall into the 'lightning fast movement' category.
816  */
817  if (FABS(op->speed) > MIN_ACTIVE_SPEED) {
818  switch ((int)((FABS(op->speed))*15)) {
819  case 0:
820  stringbuffer_append_string(buf, "(very slow movement)");
821  break;
822 
823  case 1:
824  stringbuffer_append_string(buf, "(slow movement)");
825  break;
826 
827  case 2:
828  stringbuffer_append_string(buf, "(normal movement)");
829  break;
830 
831  case 3:
832  case 4:
833  stringbuffer_append_string(buf, "(fast movement)");
834  break;
835 
836  case 5:
837  case 6:
838  stringbuffer_append_string(buf, "(very fast movement)");
839  break;
840 
841  case 7:
842  case 8:
843  case 9:
844  case 10:
845  stringbuffer_append_string(buf, "(extremely fast movement)");
846  break;
847 
848  default:
849  stringbuffer_append_string(buf, "(lightning fast movement)");
850  break;
851  }
852  }
853  if (QUERY_FLAG(op, FLAG_UNDEAD))
854  stringbuffer_append_string(buf, "(undead)");
856  stringbuffer_append_string(buf, "(see invisible)");
857  if (QUERY_FLAG(op, FLAG_USE_WEAPON))
858  stringbuffer_append_string(buf, "(wield weapon)");
859  if (QUERY_FLAG(op, FLAG_USE_BOW))
860  stringbuffer_append_string(buf, "(archer)");
861  if (QUERY_FLAG(op, FLAG_USE_ARMOUR))
862  stringbuffer_append_string(buf, "(wear armour)");
863  if (QUERY_FLAG(op, FLAG_USE_RING))
864  stringbuffer_append_string(buf, "(wear ring)");
865  if (QUERY_FLAG(op, FLAG_USE_SCROLL))
866  stringbuffer_append_string(buf, "(read scroll)");
867  if (QUERY_FLAG(op, FLAG_USE_RANGE))
868  stringbuffer_append_string(buf, "(fires wand/rod/horn)");
870  stringbuffer_append_string(buf, "(skill user)");
871  if (QUERY_FLAG(op, FLAG_CAST_SPELL))
872  stringbuffer_append_string(buf, "(spellcaster)");
873  if (QUERY_FLAG(op, FLAG_FRIENDLY))
874  stringbuffer_append_string(buf, "(friendly)");
875  if (QUERY_FLAG(op, FLAG_UNAGGRESSIVE))
876  stringbuffer_append_string(buf, "(unaggressive)");
877  if (QUERY_FLAG(op, FLAG_HITBACK))
878  stringbuffer_append_string(buf, "(hitback)");
879  if (QUERY_FLAG(op, FLAG_STEALTH))
880  stringbuffer_append_string(buf, "(stealthy)");
881  if (op->randomitems != NULL) {
882  treasure *t;
883  int first = 1;
884 
885  for (t = op->randomitems->items; t != NULL; t = t->next)
886  if (t->item && (t->item->clone.type == SPELL)) {
887  if (first) {
888  first = 0;
889  stringbuffer_append_string(buf, "(Spell abilities:)");
890  }
891  stringbuffer_append_printf(buf, "(%s)", t->item->clone.name);
892  }
893  }
894  if (op->type == PLAYER) {
895  if (op->contr->digestion) {
896  if (op->contr->digestion != 0)
897  stringbuffer_append_printf(buf, "(sustenance%+d)", op->contr->digestion);
898  }
899  if (op->contr->gen_grace) {
900  stringbuffer_append_printf(buf, "(grace%+d)", op->contr->gen_grace);
901  }
902  if (op->contr->gen_sp) {
903  stringbuffer_append_printf(buf, "(magic%+d)", op->contr->gen_sp);
904  }
905  if (op->contr->gen_hp) {
906  stringbuffer_append_printf(buf, "(regeneration%+d)", op->contr->gen_hp);
907  }
908  if (op->stats.luck) {
909  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
910  }
911  }
912 
913  /* describe attacktypes */
914  if (is_dragon_pl(op)) {
915  /* for dragon players display the attacktypes from clawing skill
916  * Break apart the for loop - move the comparison checking down -
917  * this makes it more readable.
918  */
919  object *tmp;
920 
921  tmp = object_find_by_type_and_name(op, SKILL, "clawing");
922  if (tmp && tmp->attacktype != 0) {
923  describe_attacktype("Claws", tmp->attacktype, buf);
924  } else {
925  describe_attacktype("Attacks", op->attacktype, buf);
926  }
927  } else {
928  describe_attacktype("Attacks", op->attacktype, buf);
929  }
930  describe_spellpath_attenuation("Attuned", op->path_attuned &~ op->path_denied, buf);
931  describe_spellpath_attenuation("Repelled", op->path_repelled &~ op->path_denied, buf );
932  describe_spellpath_attenuation("Denied", op->path_denied, buf);
933  describe_resistance(op, 0, use_media_tags, buf);
934 
935  return buf;
936 }
937 
980 StringBuffer *describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf) {
981  int identified, i;
982 
983  if (buf == NULL)
984  buf = stringbuffer_new();
985 
986  if (QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER) {
987  return describe_monster(op, use_media_tags, buf);
988  }
989 
990  /* figure this out once, instead of making multiple calls to need_identify.
991  * also makes the code easier to read.
992  */
993  if (!need_identify(op) || QUERY_FLAG(op, FLAG_IDENTIFIED))
994  identified = 1;
995  else {
996  stringbuffer_append_string(buf, "(unidentified)");
997  identified = 0;
998  }
999  switch (op->type) {
1000  case BOW:
1001  case ARROW:
1002  case WAND:
1003  case ROD:
1004  case WEAPON:
1005  case ARMOUR:
1006  case HELMET:
1007  case SHIELD:
1008  case BOOTS:
1009  case GLOVES:
1010  case GIRDLE:
1011  case BRACERS:
1012  case CLOAK:
1013  case SKILL_TOOL:
1014  break; /* We have more information to do below this switch */
1015 
1016  case LAMP:
1017  break; /* just so we get the "glowing" part. */
1018 
1019  case FOOD:
1020  case FLESH:
1021  case DRINK:
1022  if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) {
1023  stringbuffer_append_printf(buf, "(food+%d)", op->stats.food);
1024 
1025  if (op->type == FLESH && op->last_eat > 0 && atnr_is_dragon_enabled(op->last_eat)) {
1026  stringbuffer_append_printf(buf, "(%s metabolism)", change_resist_msg[op->last_eat]);
1027  }
1028 
1029  if (!QUERY_FLAG(op, FLAG_CURSED)) {
1030  if (op->stats.hp)
1031  stringbuffer_append_string(buf, "(heals)");
1032  if (op->stats.sp)
1033  stringbuffer_append_string(buf, "(spellpoint regen)");
1034  } else {
1035  if (op->stats.hp)
1036  stringbuffer_append_string(buf, "(damages)");
1037  if (op->stats.sp)
1038  stringbuffer_append_string(buf, "(spellpoint depletion)");
1039  }
1040  }
1041  break;
1042 
1043  case SKILL:
1044  case RING:
1045  case AMULET:
1046  if (op->item_power) {
1047  stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power);
1048  }
1049  if (op->title) {
1050  ring_desc(op, buf);
1051  }
1052  return buf;
1053 
1054  default:
1055  return buf;
1056  }
1057 
1058  /* Down here, we more further describe equipment type items.
1059  * only describe them if they have been identified or the like.
1060  */
1061  if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) {
1062  int attr, val;
1063 
1064  for (attr = 0; attr < NUM_STATS; attr++) {
1065  if ((val = get_attr_value(&(op->stats), attr)) != 0) {
1066  stringbuffer_append_printf(buf, "(%s%+d)", short_stat_name[attr], val);
1067  }
1068  }
1069  if (op->glow_radius)
1070  stringbuffer_append_string(buf, "(glowing)");
1071 
1072  switch (op->type) {
1073  case FLESH:
1074  break;
1075 
1076  default:
1077  if (op->stats.exp) {
1078  stringbuffer_append_printf(buf, "(speed %+"FMT64")", op->stats.exp);
1079  }
1080  break;
1081  }
1082  switch (op->type) {
1083  case BOW:
1084  case ARROW:
1085  case GIRDLE:
1086  case HELMET:
1087  case SHIELD:
1088  case BOOTS:
1089  case GLOVES:
1090  case WEAPON:
1091  case SKILL:
1092  case RING:
1093  case AMULET:
1094  case ARMOUR:
1095  case BRACERS:
1096  case FORCE:
1097  case CLOAK:
1098  if (op->stats.wc) {
1099  stringbuffer_append_printf(buf, "(wc%+d)", op->stats.wc);
1100  }
1101  if (op->stats.dam) {
1102  stringbuffer_append_printf(buf, "(dam%+d)", op->stats.dam);
1103  }
1104  if (op->stats.ac) {
1105  stringbuffer_append_printf(buf, "(ac%+d)", op->stats.ac);
1106  }
1107  if ((op->type == WEAPON || op->type == BOW) && op->level > 0) {
1108  stringbuffer_append_printf(buf, "(improved %d/%d)", op->last_eat, op->level);
1109  }
1110  break;
1111 
1112  default:
1113  break;
1114  }
1115  if (QUERY_FLAG(op, FLAG_XRAYS))
1116  stringbuffer_append_string(buf, "(xray-vision)");
1117  if (QUERY_FLAG(op, FLAG_SEE_IN_DARK))
1118  stringbuffer_append_string(buf, "(infravision)");
1119 
1120  /* levitate was what is was before, so we'll keep it */
1121  if (op->move_type&MOVE_FLY_LOW)
1122  stringbuffer_append_string(buf, "(levitate)");
1123 
1124  if (op->move_type&MOVE_FLY_HIGH)
1125  stringbuffer_append_string(buf, "(fly)");
1126 
1127  if (op->move_type&MOVE_SWIM)
1128  stringbuffer_append_string(buf, "(swim)");
1129 
1130  /* walking is presumed as 'normal', so doesn't need mentioning */
1131 
1132  if (op->item_power) {
1133  stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power);
1134  }
1135  } /* End if identified or applied */
1136 
1137  /* This blocks only deals with fully identified object.
1138  * it is intentional that this is not an 'else' from a above -
1139  * in this way, information is added.
1140  */
1141  if (identified) {
1142  int more_info = 0;
1143 
1144  switch (op->type) {
1145  case ROD: /* These use stats.sp for spell selection and stats.food */
1146  case BOW: /* and stats.hp for spell-point regeneration... */
1147  case ARROW:
1148  case WAND:
1149  case FOOD:
1150  case FLESH:
1151  case DRINK:
1152  more_info = 0;
1153  break;
1154 
1155  /* Armor type objects */
1156  case ARMOUR:
1157  case HELMET:
1158  case SHIELD:
1159  case BOOTS:
1160  case GLOVES:
1161  case GIRDLE:
1162  case BRACERS:
1163  case CLOAK:
1164  if (ARMOUR_SPEED(op)) {
1165  stringbuffer_append_printf(buf, "(Max speed %1.2f)", ARMOUR_SPEED(op)/10.0);
1166  }
1167  if (ARMOUR_SPELLS(op)) {
1168  stringbuffer_append_printf(buf, "(Spell regen penalty %d)", ARMOUR_SPELLS(op));
1169  }
1170  more_info = 1;
1171  break;
1172 
1173  case WEAPON:
1174  /* Calculate it the same way fix_object does so the results
1175  * make sense.
1176  */
1177  i = (WEAPON_SPEED(op)*2-op->magic)/2;
1178  if (i < 0)
1179  i = 0;
1180 
1181  stringbuffer_append_printf(buf, "(weapon speed %d)", i);
1182  more_info = 1;
1183  break;
1184  }
1185  if (more_info) {
1186  if (op->stats.food) {
1187  if (op->stats.food != 0)
1188  stringbuffer_append_printf(buf, "(sustenance%+d)", op->stats.food);
1189  }
1190  if (op->stats.grace) {
1191  stringbuffer_append_printf(buf, "(grace%+d)", op->stats.grace);
1192  }
1193  if (op->stats.sp) {
1194  stringbuffer_append_printf(buf, "(magic%+d)", op->stats.sp);
1195  }
1196  if (op->stats.hp) {
1197  stringbuffer_append_printf(buf, "(regeneration%+d)", op->stats.hp);
1198  }
1199  }
1200 
1201  if (op->stats.luck) {
1202  stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck);
1203  }
1204  if (QUERY_FLAG(op, FLAG_LIFESAVE))
1205  stringbuffer_append_string(buf, "(lifesaving)");
1206  if (QUERY_FLAG(op, FLAG_REFL_SPELL))
1207  stringbuffer_append_string(buf, "(reflect spells)");
1208  if (QUERY_FLAG(op, FLAG_REFL_MISSILE))
1209  stringbuffer_append_string(buf, "(reflect missiles)");
1210  if (QUERY_FLAG(op, FLAG_STEALTH))
1211  stringbuffer_append_string(buf, "(stealth)");
1212  if (op->slaying != NULL && op->type != FOOD) {
1213  stringbuffer_append_printf(buf, "(slay %s)", op->slaying);
1214  }
1215  describe_attacktype("Attacks", op->attacktype, buf);
1216  /* resistance on flesh is only visible for dragons. If
1217  * non flesh, everyone can see its resistances
1218  */
1219  if (op->type != FLESH || (owner && is_dragon_pl(owner))) {
1220  describe_resistance(op, 0, 1, buf);
1221  }
1222  describe_spellpath_attenuation("Attuned", op->path_attuned &~ op->path_denied, buf);
1223  describe_spellpath_attenuation("Repelled", op->path_repelled &~ op->path_denied, buf);
1224  describe_spellpath_attenuation("Denied", op->path_denied, buf);
1225  }
1226 
1227  return buf;
1228 }
1229 
1242 int is_magical(const object *op) {
1243  int i;
1244 
1245  /* living creatures are considered non magical */
1246  if (QUERY_FLAG(op, FLAG_ALIVE))
1247  return 0;
1248 
1249  /* This is a test for it being an artifact, as artifacts have titles */
1250  if (op->title != NULL)
1251  return 1;
1252 
1253  /* Handle rings and amulets specially. If they change any of these
1254  * values, it means they are magical.
1255  */
1256  if ((op->type == AMULET || op->type == RING)
1257  && (op->stats.ac || op->stats.food || op->stats.exp || op->stats.dam || op->stats.wc || op->stats.sp || op->stats.hp || op->stats.luck))
1258  return 1;
1259 
1260  /* Check for stealty, speed, flying, or just plain magic in the boots */
1261  /* Presume any boots that have a move_type are special. */
1262  if (op->type == BOOTS
1263  && ((QUERY_FLAG(op, FLAG_STEALTH) || op->move_type || op->stats.exp)))
1264  return 1;
1265 
1266  /* Take care of amulet/shield that reflects spells/missiles */
1267  if ((op->type == AMULET || op->type == SHIELD)
1269  return 1;
1270 
1271  /* Take care of helmet of xrays */
1272  if (op->type == HELMET
1273  && QUERY_FLAG(op, FLAG_XRAYS))
1274  return 1;
1275 
1276  /* Potions & rods are always magical. Wands/staves are also magical,
1277  * assuming they still have any charges left.
1278  */
1279  if (op->type == POTION || op->type == ROD || (op->type == WAND && op->stats.food))
1280  return 1;
1281 
1282  /* if something gives a protection, either positive or negative, its magical */
1283  /* This is really a pretty bad hack - as of now, ATNR_PHYSICAL is 0,
1284  * so this always works out fine.
1285  */
1286  for (i = ATNR_PHYSICAL+1; i < NROFATTACKS; i++)
1287  if (op->resist[i])
1288  return 1;
1289 
1290  /* Physical protection is expected on some item types, so they should
1291  * not be considered magical.
1292  */
1293  if (op->resist[ATNR_PHYSICAL]
1294  && op->type != HELMET
1295  && op->type != SHIELD
1296  && op->type != BOOTS
1297  && op->type != GLOVES
1298  && op->type != ARMOUR)
1299  return 1;
1300 
1301  /* power crystal, spellbooks, and scrolls are always magical. */
1302  if (op->magic
1303  || op->type == POWER_CRYSTAL
1304  || op->type == SPELLBOOK
1305  || op->type == SCROLL
1306  || op->type == GIRDLE)
1307  return 1;
1308 
1309  /* Check to see if it increases/decreases any stats */
1310  for (i = 0; i < NUM_STATS; i++)
1311  if (get_attr_value(&(op->stats), i) != 0)
1312  return 1;
1313 
1314  /* If it doesn't fall into any of the above categories, must
1315  * be non magical.
1316  */
1317  return 0;
1318 }
1319 
1331 int need_identify(const object *op) {
1332  switch (op->type) {
1333  case RING:
1334  case WAND:
1335  case ROD:
1336  case SCROLL:
1337  case SKILL:
1338  case SKILLSCROLL:
1339  case SPELLBOOK:
1340  case FOOD:
1341  case POTION:
1342  case BOW:
1343  case ARROW:
1344  case WEAPON:
1345  case ARMOUR:
1346  case SHIELD:
1347  case HELMET:
1348  case AMULET:
1349  case BOOTS:
1350  case GLOVES:
1351  case BRACERS:
1352  case GIRDLE:
1353  case CONTAINER:
1354  case DRINK:
1355  case FLESH:
1356  case INORGANIC:
1357  case CLOSE_CON:
1358  case CLOAK:
1359  case GEM:
1360  case POWER_CRYSTAL:
1361  case POISON:
1362  case BOOK:
1363  case SKILL_TOOL:
1364  case ARMOUR_IMPROVER:
1365  case WEAPON_IMPROVER:
1366  return 1;
1367  }
1368  return 0;
1369 }
1370 
1376  sstring key;
1377 
1378  key = object_get_value(op, "identified_face");
1379  if (key != NULL) {
1380  op->face = &new_faces[find_face(key, op->face->number)];
1381  /* if the face is defined, clean the animation, because else
1382  * the face can be lost ; if an animation is defined, it'll be
1383  * processed later on */
1386  op->anim_speed = 0;
1387  op->animation_id = 0;
1388  object_set_value(op, "identified_face", NULL, 0);
1389  }
1390 
1391  if (object_get_value(op, "identified_anim_random") != NULL) {
1393  object_set_value(op, "identified_anim_random", NULL, 0);
1394  }
1395 
1396  key = object_get_value(op, "identified_anim_speed");
1397  if (key != NULL) {
1398  op->anim_speed = atoi(key);
1399  op->last_anim = 1;
1400  object_set_value(op, "identified_anim_speed", NULL, 0);
1401  }
1402 
1403  key = object_get_value(op, "identified_animation");
1404  if (key != NULL) {
1405  op->animation_id = atoi(key);
1406  if (!QUERY_FLAG(op, FLAG_IS_TURNABLE))
1407  SET_FLAG(op, FLAG_ANIMATE);
1408  animate_object(op, op->facing);
1409  object_set_value(op, "identified_animation", NULL, 0);
1410  }
1411 
1412  key = object_get_value(op, "identified_name");
1413  if (key != NULL) {
1414  FREE_AND_COPY(op->name, key);
1415  object_set_value(op, "identified_name", NULL, 0);
1416  }
1417  key = object_get_value(op, "identified_name_pl");
1418  if (key != NULL) {
1419  FREE_AND_COPY(op->name_pl, key);
1420  object_set_value(op, "identified_name_pl", NULL, 0);
1421  }
1422 }
1423 
1437 object *identify(object *op) {
1438  object *pl, *op1;
1439 
1443 
1445 
1446  /*
1447  * We want autojoining of equal objects:
1448  */
1449  if (QUERY_FLAG(op, FLAG_CURSED) || QUERY_FLAG(op, FLAG_DAMNED))
1451 
1452  if (QUERY_FLAG(op, FLAG_BLESSED))
1454 
1455  if (op->type == POTION) {
1456  if (op->inv && op->randomitems) {
1457  if (op->title)
1458  free_string(op->title);
1459  op->title = add_refcount(op->inv->name);
1460  } else if (op->arch) {
1461  free_string(op->name);
1462  op->name = add_refcount(op->arch->clone.name);
1463  free_string(op->name_pl);
1464  op->name_pl = add_refcount(op->arch->clone.name_pl);
1465  }
1466  }
1467 
1468  if (op->map) {
1469  /* If the object is on a map, make sure we update its face.
1470  * Also send name and such information to a player standing on it.
1471  */
1472  object *player = map_find_by_type(op->map, op->x, op->y, PLAYER);
1473 
1475  op1 = object_merge(op, GET_MAP_TOP(op->map, op->x, op->y));
1476  if (op1) op = op1;
1477 
1478  if (player)
1479  esrv_update_item(UPD_FACE | UPD_NAME | UPD_FLAGS, player, op);
1480 
1481  } else {
1482  pl = object_get_player_container(op->env);
1483  op1 = object_merge(op, op->env->inv);
1484  if (op1) op = op1;
1485 
1486  if (pl)
1487  /* A lot of the values can change from an update - might as well send
1488  * it all.
1489  */
1490  esrv_update_item(UPD_ALL, pl, op);
1491  }
1492  return op;
1493 }
See Pedestal.
Definition: object.h:121
Error, serious thing.
Definition: logger.h:11
object * object_find_by_type_and_name(const object *who, int type, const char *name)
Find object in inventory by type and name.
Definition: object.c:3999
#define FLAG_KNOWN_BLESSED
Item is known to be blessed.
Definition: define.h:379
#define NUM_BODY_LOCATIONS
Number of body locations.
Definition: object.h:13
One player.
Definition: player.h:92
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:338
#define WEAPON_SPEED(xyz)
Definition: define.h:482
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:318
#define FLAG_UNPAID
Object hasn&#39;t been paid for yet.
Definition: define.h:236
int8_t ac
Armour Class, how hard to hit, the lower the better.
Definition: living.h:37
#define UP_OBJ_FACE
Only thing that changed was the face.
Definition: object.h:519
MoveType move_type
Type of movement this object uses.
Definition: object.h:424
Spell-related defines: spellpath, subtypes, ...
int16_t gen_hp
Bonuses to regeneration speed of hp.
Definition: player.h:113
See Key.
Definition: object.h:127
Information.
Definition: logger.h:12
See Ring.
Definition: object.h:185
Definition: object.h:125
Thaumaturgy.
Definition: skills.h:48
int is_magical(const object *op)
Checks whether object is magical.
Definition: item.c:1242
#define FLAG_HITBACK
Object will hit back when hit.
Definition: define.h:267
Eneq((at)csd.uu.se): Id for close_container archetype.
Definition: object.h:229
#define FLAG_USE_SCROLL
(Monster) can read scroll
Definition: define.h:292
void object_give_identified_properties(object *op)
Ensure op has all its "identified" properties set.
Definition: item.c:1375
#define SET_FLAG(xyz, p)
Definition: define.h:223
sstring add_refcount(sstring str)
This will increase the refcount of the string str.
Definition: shstr.c:210
#define ARMOUR_SPELLS(xyz)
Definition: define.h:481
See Bracers.
Definition: object.h:217
int get_power_from_ench(int ench)
Definition: item.c:228
#define FABS(x)
Decstations have trouble with fabs()...
Definition: define.h:22
See Scroll.
Definition: object.h:221
New_Face * new_faces
Contains face information, with names, numbers, magicmap color and such.
Definition: image.c:33
uint16_t animation_id
An index into the animation array.
Definition: object.h:416
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
Definition: define.h:296
void get_levelnumber(int i, char *buf, size_t size)
Formats a level.
Definition: item.c:446
uint8_t anim_speed
Ticks between animation-frames.
Definition: object.h:417
See Cloak.
Definition: object.h:204
See Food.
Definition: object.h:112
struct obj * container
Current container being used.
Definition: object.h:291
uint8_t last_anim
Last sequence used to draw face.
Definition: object.h:418
See Projectile.
Definition: object.h:117
#define FLAG_FRIENDLY
Will help players.
Definition: define.h:246
int16_t gen_grace
Bonuses to regeneration speed of grace.
Definition: player.h:116
See Holy Altar.
Definition: object.h:161
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
Definition: stringbuffer.c:57
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.c:280
See Spellbook.
Definition: object.h:203
const char * object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.c:4246
See Money.
Definition: object.h:137
struct treasureliststruct * randomitems
Items to be generated.
Definition: object.h:385
void query_base_name(const object *op, int plural, char *buf, size_t size)
Query a short name for the item.
Definition: item.c:722
static const char *const numbers_10[]
Tens.
Definition: item.c:72
object clone
An object from which to do object_copy()
Definition: object.h:470
See Rune.
Definition: object.h:240
See Creator.
Definition: object.h:142
void query_weight(const object *op, char *buf, size_t size)
Formats the item&#39;s weight.
Definition: item.c:426
See Weapon.
Definition: object.h:119
See Helmet.
Definition: object.h:136
const char * slaying
Which race to do double damage to.
Definition: object.h:319
Object for applying character class modifications to someone.
Definition: object.h:138
#define FLAG_STEALTH
Will wake monsters with less range.
Definition: define.h:313
Bowyer.
Definition: skills.h:23
See Altar Trigger.
Definition: object.h:133
See Rod.
Definition: object.h:109
#define FLAG_USE_WEAPON
(Monster) can wield weapons
Definition: define.h:297
int64_t exp
Experience.
Definition: living.h:46
#define FLAG_BLESSED
Item has a blessing, opposite of cursed/damned.
Definition: define.h:378
See Power Crystal.
Definition: object.h:242
static const char *const levelnumbers_10[]
Tens for levels.
Definition: item.c:86
See Button Trigger.
Definition: object.h:132
See Drink.
Definition: object.h:157
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
See Girdle.
Definition: object.h:223
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
The ordering of this is actually doesn&#39;t make a difference However, for ease of use, new entries should go at the end so those people that debug the code that get used to something being in the location 4 don&#39;t get confused.
Definition: item.c:54
static const typedata item_types[]
The following is a large table of item types, the fields are: item number, item name, item name (plural), and two numbers that are the skills used to identify them.
Definition: item.c:98
See Amulet.
Definition: object.h:139
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
Definition: living.c:313
Wall.
Definition: object.h:191
Duplicator/multiplier object.
Definition: object.h:202
uint32_t path_attuned
Paths the object is attuned to.
Definition: object.h:343
void object_update(object *op, int action)
object_update() updates the array which represents the map.
Definition: object.c:1239
const typedata * get_typedata_by_name(const char *name)
Definition: item.c:354
int16_t sp
Spell points.
Definition: living.h:41
animal &#39;body parts&#39; -b.t.
Definition: object.h:187
Global type definitions and header inclusions.
Link an object type with skill needed to identify, and general name.
Definition: define.h:89
uint32_t path_repelled
Paths the object is repelled from.
Definition: object.h:344
See Boots.
Definition: object.h:212
#define FLAG_USE_RING
(Monster) can use rings, boots, gauntlets, etc
Definition: define.h:298
peterm: detector is an object which notices the presense of another object and is triggered like butt...
Definition: object.h:149
static const int enc_to_item_power[]
This curve may be too steep.
Definition: item.c:221
See Mover.
Definition: object.h:140
See Wand & Staff.
Definition: object.h:220
struct archt * item
Which item this link can be.
Definition: treasure.h:64
Smithery.
Definition: skills.h:22
int16_t hp
Hit Points.
Definition: living.h:39
#define FLAG_KNOWN_MAGICAL
The object is known to be magical.
Definition: define.h:320
Woodsman.
Definition: skills.h:40
uint16_t number
This is the image id.
Definition: face.h:15
See Magic Ear.
Definition: object.h:131
#define UPD_ALL
Definition: newclient.h:297
const typedata * get_typedata(int itemtype)
Definition: item.c:334
#define FLAG_SEE_INVISIBLE
Will see invisible player.
Definition: define.h:253
Allows the use of a skill.
Definition: object.h:189
#define FLAG_UNDEAD
Monster is undead.
Definition: define.h:270
Generic item builder, see subtypes below.
Definition: object.h:246
See Trap.
Definition: object.h:241
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
Definition: object.c:4375
const char * title
Of foo, etc.
Definition: object.h:317
int16_t y
Position in the map for this object.
Definition: object.h:326
Floor tile -> native layer 0.
Definition: object.h:186
See Shooting Weapon.
Definition: object.h:118
#define FLAG_CLIENT_ANIM_RANDOM
Client animate this, randomized.
Definition: define.h:241
static const int item_types_size
Number of items in item_types array.
Definition: item.c:210
uint32_t path_denied
Paths the object is denied access to.
Definition: object.h:345
See Sign & Magic Mouth.
Definition: object.h:211
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:230
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
Definition: define.h:275
See Book.
Definition: object.h:114
See Exit.
Definition: object.h:181
const char * name_pl
The plural name of the object.
Definition: object.h:315
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
Definition: stringbuffer.c:95
battleground, by Andreas Vogl
Definition: object.h:163
inserts an invisible, weightless force into a player with a specified string.
Definition: object.h:158
int16_t gen_sp
Bonuses to regeneration speed of sp.
Definition: player.h:114
#define MOVE_SWIM
Swimming object.
Definition: define.h:411
See Treasure.
Definition: object.h:110
See Special Key.
Definition: object.h:124
int32_t weight
Attributes of the object.
Definition: object.h:365
#define FLAG_CAN_USE_SKILL
The monster can use skills.
Definition: define.h:322
#define MOVE_FLY_LOW
Low flying object.
Definition: define.h:408
A real, living creature.
Definition: object.h:200
#define FLAG_UNAGGRESSIVE
Monster doesn&#39;t attack players.
Definition: define.h:272
inserts an invisible, weightless force into a player with a specified string WHEN TRIGGERED...
Definition: object.h:153
See Clock.
Definition: object.h:115
#define FLAG_USE_RANGE
(Monster) can apply and use range items
Definition: define.h:293
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
int is_dragon_pl(const object *op)
Checks if player is a dragon.
Definition: player.c:114
#define snprintf
Definition: win32.h:46
#define FLAG_CLIENT_ANIM_SYNC
Let client animate this, synchronized.
Definition: define.h:240
#define FLAG_IDENTIFIED
Player knows full info about item.
Definition: define.h:261
#define FMT64
Definition: compat.h:12
int16_t dam
How much damage this object does when hitting.
Definition: living.h:45
Definition: object.h:145
int32_t carrying
How much weight this object contains.
Definition: object.h:367
const char * name
The name of the object, obviously...
Definition: object.h:311
Alchemy.
Definition: skills.h:25
struct obj * env
Pointer to the object which is the environment.
Definition: object.h:293
#define ARMOUR_SPEED(xyz)
Definition: define.h:480
static StringBuffer * ring_desc(const object *op, StringBuffer *buf)
Describes a ring or amulet, or a skill.
Definition: item.c:472
size_t stringbuffer_length(StringBuffer *sb)
Return the current length of the buffer.
Definition: stringbuffer.c:154
#define GET_MAP_TOP(M, X, Y)
Gets the top object on a map.
Definition: map.h:174
uint32_t nrof
How many of the objects.
Definition: object.h:333
EXTERN const char *const change_resist_msg[NROFATTACKS]
Definition: attack.h:135
#define UPD_FLAGS
Definition: newclient.h:290
Number of statistics.
Definition: living.h:18
See Trapdoor.
Definition: object.h:210
See Potion.
Definition: object.h:111
struct pl * contr
Pointer to the player which control this object.
Definition: object.h:276
int8_t item_power
Power rating of the object.
Definition: object.h:362
See Shop Mat.
Definition: object.h:184
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:301
#define ATNR_PHYSICAL
Definition: attack.h:49
int8_t luck
Affects thaco and ac from time to time.
Definition: living.h:38
float speed
The overall speed of this object.
Definition: object.h:328
See Spell.
Definition: object.h:214
static const char *const levelnumbers[]
Levels as a full name and not a number.
Definition: item.c:78
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
See Handle Trigger.
Definition: object.h:129
#define FLAG_BEEN_APPLIED
The object has been applied.
Definition: define.h:324
See Locked Door.
Definition: object.h:123
#define NRSPELLPATHS
Number of spell paths.
Definition: spells.h:40
See Spinner.
Definition: object.h:205
See Door.
Definition: object.h:126
#define FLAG_CAST_SPELL
(Monster) can learn and cast spells
Definition: define.h:291
See Magic Wall.
Definition: object.h:168
Object owned by a player which can convert a monster into a peaceful being incapable of attack...
Definition: object.h:164
See Converter.
Definition: object.h:216
int16_t x
Definition: object.h:326
StringBuffer * describe_attacktype(const char *attack, int value, StringBuffer *buf)
Describe the specified attack type.
Definition: utils.c:561
Literacy.
Definition: skills.h:27
can add a skill to player&#39;s inventory -bt.
Definition: object.h:234
struct treasurestruct * items
Items in this list, linked.
Definition: treasure.h:90
int32_t last_eat
How long since we last ate.
Definition: object.h:356
int calc_item_power(const object *op)
This takes an object &#39;op&#39; and figures out what its item_power rating should be.
Definition: item.c:246
Lamp.
Definition: object.h:201
int8_t wc
Weapon Class, how skilled, the lower the better.
Definition: living.h:36
See Container.
Definition: object.h:231
void animate_object(object *op, int dir)
Updates the face-variable of an object.
Definition: anim.c:186
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:341
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
Definition: define.h:321
const char * sstring
Strings that should be manipulated through add_string() and free_string().
Definition: global.h:40
int need_identify(const object *op)
This function really should not exist - by default, any item not identified should need it...
Definition: item.c:1331
#define FLAG_CURSED
The object is cursed.
Definition: define.h:317
See Player.
Definition: object.h:107
See Poison Food.
Definition: object.h:113
void safe_strcat(char *dest, const char *orig, size_t *curlen, size_t maxlen)
Simple function we use below to keep adding to the same string but also make sure we don&#39;t overwrite ...
Definition: porting.c:346
See Shield.
Definition: object.h:135
See Floor (Encounter).
Definition: object.h:182
#define FLAG_ANIMATE
The object looks at archetype for faces.
Definition: define.h:242
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
Definition: item.c:405
Jeweler.
Definition: skills.h:24
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:342
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Describes an item, in all its details.
Definition: item.c:980
Mark Wedel (mark@pyramid.com) Shop inventories.
Definition: object.h:238
See Altar.
Definition: object.h:122
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
Definition: global.h:213
int16_t grace
Grace.
Definition: living.h:43
Definition: object.h:243
Also see SKILL_TOOL (74) below.
Definition: object.h:143
StringBuffer * describe_monster(const object *op, int use_media_tags, StringBuffer *buf)
Describes a monster.
Definition: item.c:806
living stats
Str, Con, Dex, etc.
Definition: object.h:368
struct archt * arch
Pointer to archetype.
Definition: object.h:412
See Shop Floor.
Definition: object.h:183
#define UPD_FACE
Definition: newclient.h:292
See Button.
Definition: object.h:207
See Gate.
Definition: object.h:206
misc.
Definition: object.h:193
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:338
Material for building.
Definition: object.h:248
See Handle.
Definition: object.h:208
#define FLAG_APPLIED
Object is ready for use by living.
Definition: define.h:235
#define NROFATTACKS
Definition: attack.h:17
object * object_merge(object *op, object *top)
This function goes through all objects below and including top, and merges op to the first matching o...
Definition: object.c:1869
EXTERN const char *const resist_plus[NROFATTACKS]
Definition: attack.h:136
void query_short_name(const object *op, char *buf, size_t size)
query_short_name(object) is similar to query_name(), but doesn&#39;t contain any information about object...
Definition: item.c:547
See Timed Gate.
Definition: object.h:128
object * object_get_player_container(object *op)
Finds the player carrying an object.
Definition: object.c:353
#define FLAG_LIFESAVE
Saves a players&#39; life once, then destr.
Definition: define.h:306
signed int int32_t
Definition: win32.h:159
#define UPD_NAME
Definition: newclient.h:293
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
Definition: define.h:329
StringBuffer * describe_resistance(const object *op, int newline, int use_media_tags, StringBuffer *buf)
Generates the visible naming for resistances.
Definition: item.c:383
object * identify(object *op)
Identifies an item.
Definition: item.c:1437
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
Definition: stringbuffer.c:104
#define MIN_ACTIVE_SPEED
Cut off point of when an object is put on the active list or not.
Definition: define.h:674
StringBuffer * describe_spellpath_attenuation(const char *attenuation, int value, StringBuffer *buf)
Describe the specified path attenuation.
Definition: utils.c:533
int8_t glow_radius
indicates the glow radius of the object
Definition: object.h:364
#define FLAG_MONSTER
Will attack players.
Definition: define.h:245
See Monster (Grimreaper).
Definition: object.h:130
struct obj * inv
Pointer to the first object in the inventory.
Definition: object.h:290
See Gloves.
Definition: object.h:213
One body location.
Definition: object.h:20
#define MOVE_FLY_HIGH
High flying object.
Definition: define.h:409
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.c:51
A force, holding the effect of a resistance potion.
Definition: object.h:225
metals, minerals, dragon scales
Definition: object.h:188
Structure containing object statistics.
See Pit.
Definition: object.h:209
A buffer that will be expanded as content is added to it.
Definition: stringbuffer.c:25
void query_name(const object *op, char *buf, size_t size)
Describes an item.
Definition: item.c:625
See Swamp.
Definition: object.h:236
const New_Face * face
Face with colors.
Definition: object.h:332
See Jewel.
Definition: object.h:167
#define FLAG_NO_SKILL_IDENT
If set, item cannot be identified w/ a skill.
Definition: define.h:336
const char *const short_stat_name[NUM_STATS]
Short name of stats.
Definition: living.c:194
See Breastplate Armor.
Definition: object.h:120
struct treasurestruct * next
Next treasure-item in a linked list.
Definition: treasure.h:66
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:273
int16_t level
Level of creature or object.
Definition: object.h:351
int8_t facing
Object is oriented/facing that way.
Definition: object.h:335
#define FLAG_INV_LOCKED
Item will not be dropped from inventory.
Definition: define.h:330
unsigned find_face(const char *name, unsigned error)
This returns an the face number of face &#39;name&#39;.
Definition: image.c:303
Definition: object.h:148
See Disease.
Definition: object.h:244
int8_t magic
Any magical bonuses to this item.
Definition: object.h:348
See Director.
Definition: object.h:222
See Teleporter.
Definition: object.h:141
int16_t digestion
Any bonuses/penalties to digestion.
Definition: player.h:112
#define FLAG_USE_BOW
(Monster) can apply and fire bows
Definition: define.h:294
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
Definition: stringbuffer.c:76
EXTERN const char *const resist_color[NROFATTACKS]
Definition: attack.h:137
b.t.
Definition: object.h:170
object * map_find_by_type(mapstruct *m, int x, int y, uint8_t type)
Searches for any objects with a matching type variable at the given map and coordinates.
Definition: object.c:2974
See Savebed.
Definition: object.h:219
int atnr_is_dragon_enabled(int attacknr)
Determine if the attacktype represented by the specified attack-number is enabled for dragon players...
Definition: player.c:95
int32_t food
How much food in stomach.
Definition: living.h:47
b.t.
Definition: object.h:169
Definition: object.h:224
#define FLAG_IS_TURNABLE
Object can change face with direction.
Definition: define.h:256