| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 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 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
body_locations_struct body_locations[NUM_BODY_LOCATIONS] = { |
| 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 |
|
| 69 |
}; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
static const typedata item_types[] = { |
| 79 |
{ 0, "none", "none", 0, 0 }, |
| 80 |
{ PLAYER, "player", "players", 0, 0 }, |
| 81 |
{ ROD, "rod", "rods", SK_THAUMATURGY, 0 }, |
| 82 |
{ TREASURE, "treasure", "treasure", 0, 0 }, |
| 83 |
{ POTION, "potion", "potions", SK_ALCHEMY, 0 }, |
| 84 |
{ FOOD, "food", "food", SK_WOODSMAN, 0 }, |
| 85 |
{ POISON, "poison", "poisons", SK_ALCHEMY, 0 }, |
| 86 |
{ BOOK, "book", "books", SK_LITERACY, 0 }, |
| 87 |
{ CLOCK, "clock", "clocks", 0, 0 }, |
| 88 |
{ ARROW, "arrow", "arrows", SK_BOWYER, 0 }, |
| 89 |
{ BOW, "bow", "bows", SK_BOWYER, 0 }, |
| 90 |
{ WEAPON, "weapon", "weapons", SK_SMITHERY, 0 }, |
| 91 |
{ ARMOUR, "armour", "armour", SK_SMITHERY, 0 }, |
| 92 |
{ PEDESTAL, "pedestal", "pedestals", 0, 0 }, |
| 93 |
{ ALTAR, "altar", "altars", 0, 0 }, |
| 94 |
{ LOCKED_DOOR, "locked door", "locked doors", 0, 0 }, |
| 95 |
{ SPECIAL_KEY, "special key", "special keys", 0, 0 }, |
| 96 |
{ MAP, "map", "maps", 0, 0 }, |
| 97 |
{ DOOR, "door", "doors", 0, 0 }, |
| 98 |
{ KEY, "key", "keys", 0, 0 }, |
| 99 |
{ TIMED_GATE, "timed_gate", "timed_gates", 0, 0 }, |
| 100 |
{ TRIGGER, "trigger", "triggers", 0, 0 }, |
| 101 |
{ GRIMREAPER, "grimreaper", "grimreapers", 0, 0 }, |
| 102 |
{ MAGIC_EAR, "magic ear", "magic ears", 0, 0 }, |
| 103 |
{ TRIGGER_BUTTON, "trigger button", "trigger buttons", 0, 0 }, |
| 104 |
{ TRIGGER_ALTAR, "trigger altar", "trigger altars", 0, 0 }, |
| 105 |
{ TRIGGER_PEDESTAL, "trigger pedestal", "trigger pedestals", 0, 0 }, |
| 106 |
{ SHIELD, "shield", "shields", SK_SMITHERY, 0 }, |
| 107 |
{ HELMET, "helmet", "helmets", SK_SMITHERY, 0 }, |
| 108 |
{ MONEY, "money", "money", 0, 0 }, |
| 109 |
{ CLASS, "class", "classes", 0, 0 }, |
| 110 |
{ AMULET, "amulet", "amulets", SK_JEWELER, 0 }, |
| 111 |
{ PLAYERMOVER, "player mover", "player movers", 0, 0 }, |
| 112 |
{ TELEPORTER, "teleporter", "teleporters", 0, 0 }, |
| 113 |
{ CREATOR, "creator", "creators", 0, 0 }, |
| 114 |
{ SKILL, "skill", "skills", 0, 0 }, |
| 115 |
{ EARTHWALL, "earthwall", "earthwalls", 0, 0 }, |
| 116 |
{ GOLEM, "golem", "golems", 0, 0 }, |
| 117 |
{ THROWN_OBJ, "projectile", "projectiles", 0, 0 }, |
| 118 |
{ BLINDNESS, "blindness", "blindness", 0, 0 }, |
| 119 |
{ GOD, "god", "gods", 0, 0 }, |
| 120 |
{ DETECTOR, "detector", "detectors", 0, 0 }, |
| 121 |
{ TRIGGER_MARKER, "trigger marker", "trigger markers", 0, 0 }, |
| 122 |
{ DEAD_OBJECT, "dead object", "dead objects", 0, 0 }, |
| 123 |
{ DRINK, "drink", "drinks", SK_WOODSMAN, SK_ALCHEMY }, |
| 124 |
{ MARKER, "marker", "markers", 0, 0 }, |
| 125 |
{ HOLY_ALTAR, "holy altar", "holy altars", 0, 0 }, |
| 126 |
{ PLAYER_CHANGER, "player changer", "player changers", 0, 0 }, |
| 127 |
{ BATTLEGROUND, "battleground", "battlegrounds", 0, 0 }, |
| 128 |
{ PEACEMAKER, "peacemaker", "peacemakers", 0, 0 }, |
| 129 |
{ GEM, "gem", "gems", SK_JEWELER, 0 }, |
| 130 |
{ FIREWALL, "firewall", "firewalls", 0, 0 }, |
| 131 |
{ CHECK_INV, "inventory checker", "inventory checkers", 0, 0 }, |
| 132 |
{ MOOD_FLOOR, "mood floor", "mood floors", 0, 0 }, |
| 133 |
{ EXIT, "exit", "exits", 0, 0 }, |
| 134 |
{ ENCOUNTER, "encounter", "encounters", 0, 0 }, |
| 135 |
{ SHOP_FLOOR, "shop floor", "shop floors", 0, 0 }, |
| 136 |
{ SHOP_MAT, "shop mat", "shop mats", 0, 0 }, |
| 137 |
{ RING, "ring", "rings", SK_JEWELER, 0 }, |
| 138 |
{ FLOOR, "floor", "floors", 0, 0 }, |
| 139 |
{ FLESH, "flesh", "flesh", SK_WOODSMAN, 0 }, |
| 140 |
{ INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0 }, |
| 141 |
{ SKILL_TOOL, "skill tool", "skill tools", 0, 0 }, |
| 142 |
{ LIGHTER, "lighter", "lighters", 0, 0 }, |
| 143 |
{ WALL, "wall", "walls", 0, 0 }, |
| 144 |
{ MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0 }, |
| 145 |
{ MONSTER, "monster", "monsters", 0, 0 }, |
| 146 |
{ LAMP, "lamp", "lamps", 0, 0 }, |
| 147 |
{ DUPLICATOR, "duplicator", "duplicators", 0, 0 }, |
| 148 |
{ SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0 }, |
| 149 |
{ CLOAK, "cloak", "cloaks", SK_SMITHERY, 0 }, |
| 150 |
{ SPINNER, "spinner", "spinners", 0, 0 }, |
| 151 |
{ GATE, "gate", "gates", 0, 0 }, |
| 152 |
{ BUTTON, "button", "buttons", 0, 0 }, |
| 153 |
{ CF_HANDLE, "cf handle", "cf handles", 0, 0 }, |
| 154 |
{ HOLE, "hole", "holes", 0, 0 }, |
| 155 |
{ TRAPDOOR, "trapdoor", "trapdoors", 0, 0 }, |
| 156 |
{ SIGN, "sign", "signs", 0, 0 }, |
| 157 |
{ BOOTS, "boots", "boots", SK_SMITHERY, 0 }, |
| 158 |
{ GLOVES, "gloves", "gloves", SK_SMITHERY, 0 }, |
| 159 |
{ SPELL, "spell", "spells", 0, 0 }, |
| 160 |
{ SPELL_EFFECT, "spell effect", "spell effects", 0, 0 }, |
| 161 |
{ CONVERTER, "converter", "converters", 0, 0 }, |
| 162 |
{ BRACERS, "bracers", "bracers", SK_SMITHERY, 0 }, |
| 163 |
{ POISONING, "poisoning", "poisonings", 0, 0 }, |
| 164 |
{ SAVEBED, "savebed", "savebeds", 0, 0 }, |
| 165 |
{ WAND, "wand", "wands", SK_THAUMATURGY, 0 }, |
| 166 |
{ SCROLL, "scroll", "scrolls", SK_LITERACY, 0 }, |
| 167 |
{ DIRECTOR, "director", "directors", 0, 0 }, |
| 168 |
{ GIRDLE, "girdle", "girdles", SK_SMITHERY, 0 }, |
| 169 |
{ FORCE, "force", "forces", 0, 0 }, |
| 170 |
{ POTION_RESIST_EFFECT, "potion effect", "potion effects", 0, 0 }, |
| 171 |
{ CLOSE_CON, "closed container", "closed container", SK_ALCHEMY, 0 }, |
| 172 |
{ CONTAINER, "container", "containers", SK_ALCHEMY, 0 }, |
| 173 |
{ ARMOUR_IMPROVER, "armour improver", "armour improvers", SK_LITERACY, 0 }, |
| 174 |
{ WEAPON_IMPROVER, "weapon improver", "weapon improvers", SK_LITERACY, 0 }, |
| 175 |
{ SKILLSCROLL, "skillscroll", "skillscrolls", SK_LITERACY, 0 }, |
| 176 |
{ DEEP_SWAMP, "deep swamp", "deep swamps", 0, 0 }, |
| 177 |
{ IDENTIFY_ALTAR, "identify altar", "identify altars", 0, 0 }, |
| 178 |
{ SHOP_INVENTORY, "inventory list", "inventory lists", 0, 0 }, |
| 179 |
{ RUNE, "rune", "runes", 0, 0 }, |
| 180 |
{ TRAP, "trap", "traps", 0, 0 }, |
| 181 |
{ POWER_CRYSTAL, "power_crystal", "power_crystals", SK_THAUMATURGY, 0 }, |
| 182 |
{ CORPSE, "corpse", "corpses", 0, 0 }, |
| 183 |
{ DISEASE, "disease", "diseases", 0, 0 }, |
| 184 |
{ SYMPTOM, "symptom", "symptoms", 0, 0 }, |
| 185 |
{ BUILDER, "item builder", "item builders", 0, 0 }, |
| 186 |
{ MATERIAL, "building material", "building materials", 0, 0 }, |
| 187 |
{ MIMIC, "mimic", "mimics", SK_ALCHEMY, 0 }, |
| 188 |
}; |
| 189 |
|
| 190 |
|
| 191 |
static const int item_types_size = sizeof(item_types)/sizeof(*item_types); |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
static const int enc_to_item_power[] = { |
| 203 |
0, 0, 1, 2, 3, 4, |
| 204 |
5, 7, 9, 11, 13, |
| 205 |
15, 18, 21, 24, 27, |
| 206 |
30, 35, 40, 45, 50 |
| 207 |
}; |
| 208 |
|
| 209 |
int get_power_from_ench(int ench) { |
| 210 |
if (ench < 0) |
| 211 |
ench = 0; |
| 212 |
if (ench > (int)(sizeof(enc_to_item_power)/sizeof(*enc_to_item_power)-1)) |
| 213 |
ench = sizeof(enc_to_item_power)/sizeof(*enc_to_item_power)-1; |
| 214 |
return enc_to_item_power[ench]; |
| 215 |
} |
| 216 |
|
| 217 |
static int bits_set(uint32_t x, int start, int end) { |
| 218 |
int enc = 0; |
| 219 |
for (int i = start; i < end; i++) { |
| 220 |
if (x&(1<<i)) { |
| 221 |
enc++; |
| 222 |
} |
| 223 |
} |
| 224 |
return enc; |
| 225 |
} |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
int calc_item_power(const object *op) { |
| 238 |
int i, tmp, enc; |
| 239 |
|
| 240 |
enc = 0; |
| 241 |
for (i = 0; i < NUM_STATS; i++) |
| 242 |
enc += get_attr_value(&op->stats, i); |
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
tmp = 0; |
| 250 |
for (i = 1; i < NROFATTACKS; i++) |
| 251 |
tmp += op->resist[i]; |
| 252 |
|
| 253 |
|
| 254 |
if (tmp > 0) |
| 255 |
enc += (tmp+10)/20; |
| 256 |
else if (tmp < 0) |
| 257 |
enc += (tmp-10)/20; |
| 258 |
|
| 259 |
enc += op->magic; |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
if (op->type == WEAPON) { |
| 265 |
enc += bits_set(op->attacktype, 1, NROFATTACKS); |
| 266 |
if (op->slaying) |
| 267 |
enc += 2; |
| 268 |
} |
| 269 |
|
| 270 |
if ((op->type == WEAPON) |
| 271 |
|| (op->type == ARMOUR) |
| 272 |
|| (op->type == HELMET) |
| 273 |
|| (op->type == SHIELD) |
| 274 |
|| (op->type == RING) |
| 275 |
|| (op->type == BOOTS) |
| 276 |
|| (op->type == GLOVES) |
| 277 |
|| (op->type == AMULET) |
| 278 |
|| (op->type == GIRDLE) |
| 279 |
|| (op->type == BRACERS) |
| 280 |
|| (op->type == CLOAK)) { |
| 281 |
enc += op->stats.food; |
| 282 |
enc += op->stats.hp; |
| 283 |
enc += op->stats.sp; |
| 284 |
enc += op->stats.grace; |
| 285 |
enc += op->stats.exp; |
| 286 |
} |
| 287 |
enc += op->stats.luck; |
| 288 |
|
| 289 |
|
| 290 |
enc += bits_set(op->path_attuned, 1, NRSPELLPATHS); |
| 291 |
enc -= bits_set(op->path_repelled, 1, NRSPELLPATHS); |
| 292 |
enc -= 2*bits_set(op->path_denied, 1, NRSPELLPATHS); |
| 293 |
|
| 294 |
if (QUERY_FLAG(op, FLAG_LIFESAVE)) |
| 295 |
enc += 5; |
| 296 |
if (QUERY_FLAG(op, FLAG_REFL_SPELL)) |
| 297 |
enc += 3; |
| 298 |
if (QUERY_FLAG(op, FLAG_REFL_MISSILE)) |
| 299 |
enc += 2; |
| 300 |
if (QUERY_FLAG(op, FLAG_STEALTH)) |
| 301 |
enc += 1; |
| 302 |
if (QUERY_FLAG(op, FLAG_XRAYS)) |
| 303 |
enc += 2; |
| 304 |
if (QUERY_FLAG(op, FLAG_SEE_IN_DARK)) |
| 305 |
enc += 1; |
| 306 |
if (QUERY_FLAG(op, FLAG_MAKE_INVIS)) |
| 307 |
enc += 1; |
| 308 |
|
| 309 |
return get_power_from_ench(enc); |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
const typedata *get_typedata(int itemtype) { |
| 319 |
int i; |
| 320 |
|
| 321 |
for (i = 0; i < item_types_size; i++) |
| 322 |
if (item_types[i].number == itemtype) |
| 323 |
return &item_types[i]; |
| 324 |
return NULL; |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
const typedata *get_typedata_by_name(const char *name) { |
| 339 |
int i; |
| 340 |
|
| 341 |
for (i = 0; i < item_types_size; i++) |
| 342 |
if (!strcmp(item_types[i].name, name)) |
| 343 |
return &item_types[i]; |
| 344 |
for (i = 0; i < item_types_size; i++) |
| 345 |
if (!strcmp(item_types[i].name_pl, name)) { |
| 346 |
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); |
| 347 |
return &item_types[i]; |
| 348 |
} |
| 349 |
return NULL; |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
StringBuffer *describe_resistance(const object *op, int newline, int use_media_tags, StringBuffer *buf) { |
| 368 |
int tmpvar; |
| 369 |
|
| 370 |
if (buf == NULL) |
| 371 |
buf = stringbuffer_new(); |
| 372 |
|
| 373 |
for (tmpvar = 0; tmpvar < NROFATTACKS; tmpvar++) { |
| 374 |
if (op->resist[tmpvar] && (op->type != FLESH || atnr_is_dragon_enabled(tmpvar) == 1)) { |
| 375 |
if (use_media_tags) { |
| 376 |
if (resist_color[tmpvar] != NULL) { |
| 377 |
stringbuffer_append_printf(buf, "[color=%s]", resist_color[tmpvar]); |
| 378 |
} |
| 379 |
if (op->resist[tmpvar] == 100 || op->resist[tmpvar] == -100) { |
| 380 |
stringbuffer_append_string(buf, "[ul]"); |
| 381 |
} |
| 382 |
} |
| 383 |
if (!newline) |
| 384 |
stringbuffer_append_printf(buf, "(%s %+d)", resist_plus[tmpvar], op->resist[tmpvar]); |
| 385 |
else |
| 386 |
stringbuffer_append_printf(buf, "%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]); |
| 387 |
if (use_media_tags) { |
| 388 |
if (op->resist[tmpvar] == 100 || op->resist[tmpvar] == -100) { |
| 389 |
stringbuffer_append_string(buf, "[/ul]"); |
| 390 |
} |
| 391 |
if (resist_color[tmpvar] != NULL) { |
| 392 |
stringbuffer_append_string(buf, "[/color]"); |
| 393 |
} |
| 394 |
} |
| 395 |
} |
| 396 |
} |
| 397 |
|
| 398 |
return buf; |
| 399 |
} |
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
void query_weight(const object *op, char *buf, size_t size) { |
| 411 |
int32_t i = NROF(op)*op->weight+op->carrying; |
| 412 |
|
| 413 |
if (op->weight < 0) |
| 414 |
snprintf(buf, size, " "); |
| 415 |
else if (i%1000) |
| 416 |
snprintf(buf, size, "%6.1f", i/1000.0); |
| 417 |
else |
| 418 |
snprintf(buf, size, "%4d ", i/1000); |
| 419 |
} |
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
static StringBuffer *ring_desc(const object *op, int use_media_tags, StringBuffer *buf) { |
| 434 |
int attr, val; |
| 435 |
size_t len; |
| 436 |
|
| 437 |
assert(op != NULL); |
| 438 |
assert(op->type == RING || op->type == AMULET || op->type == SKILL); |
| 439 |
|
| 440 |
if (buf == NULL) |
| 441 |
buf = stringbuffer_new(); |
| 442 |
len = stringbuffer_length(buf); |
| 443 |
|
| 444 |
if (!QUERY_FLAG(op, FLAG_IDENTIFIED)) |
| 445 |
return buf; |
| 446 |
|
| 447 |
for (attr = 0; attr < NUM_STATS; attr++) { |
| 448 |
if ((val = get_attr_value(&(op->stats), attr)) != 0) { |
| 449 |
stringbuffer_append_printf(buf, "(%s%+d)", short_stat_name[attr], val); |
| 450 |
} |
| 451 |
} |
| 452 |
if (op->stats.exp) |
| 453 |
stringbuffer_append_printf(buf, "(speed %+"FMT64")", op->stats.exp); |
| 454 |
if (op->stats.wc) |
| 455 |
stringbuffer_append_printf(buf, "(wc%+d)", op->stats.wc); |
| 456 |
if (op->stats.dam) |
| 457 |
stringbuffer_append_printf(buf, "(dam%+d)", op->stats.dam); |
| 458 |
if (op->stats.ac) |
| 459 |
stringbuffer_append_printf(buf, "(ac%+d)", op->stats.ac); |
| 460 |
|
| 461 |
describe_resistance(op, 0, use_media_tags, buf); |
| 462 |
|
| 463 |
if (op->stats.food != 0) |
| 464 |
stringbuffer_append_printf(buf, "(sustenance%+d)", op->stats.food); |
| 465 |
if (op->stats.grace) |
| 466 |
stringbuffer_append_printf(buf, "(grace%+d)", op->stats.grace); |
| 467 |
if (op->stats.sp && op->type != SKILL) |
| 468 |
stringbuffer_append_printf(buf, "(magic%+d)", op->stats.sp); |
| 469 |
if (op->stats.hp) |
| 470 |
stringbuffer_append_printf(buf, "(regeneration%+d)", op->stats.hp); |
| 471 |
if (op->stats.luck) |
| 472 |
stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck); |
| 473 |
if (QUERY_FLAG(op, FLAG_LIFESAVE)) |
| 474 |
stringbuffer_append_printf(buf, "(lifesaving)"); |
| 475 |
if (QUERY_FLAG(op, FLAG_REFL_SPELL)) |
| 476 |
stringbuffer_append_printf(buf, "(reflect spells)"); |
| 477 |
if (QUERY_FLAG(op, FLAG_REFL_MISSILE)) |
| 478 |
stringbuffer_append_printf(buf, "(reflect missiles)"); |
| 479 |
if (QUERY_FLAG(op, FLAG_STEALTH)) |
| 480 |
stringbuffer_append_printf(buf, "(stealth)"); |
| 481 |
if (op->glow_radius) |
| 482 |
stringbuffer_append_string(buf, "(glowing)"); |
| 483 |
|
| 484 |
describe_spellpath_attenuation("Attuned", op->path_attuned, buf); |
| 485 |
describe_spellpath_attenuation("Repelled", op->path_repelled, buf); |
| 486 |
describe_spellpath_attenuation("Denied", op->path_denied, buf); |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
if (stringbuffer_length(buf) == len && op->type != SKILL) |
| 492 |
stringbuffer_append_string(buf, "of adornment"); |
| 493 |
|
| 494 |
return buf; |
| 495 |
} |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
void query_short_name(const object *op, char *buf, size_t size) { |
| 509 |
size_t len = 0; |
| 510 |
|
| 511 |
if (op->name == NULL) { |
| 512 |
snprintf(buf, size, "(null)"); |
| 513 |
return; |
| 514 |
} |
| 515 |
if (!op->nrof && !op->weight && !op->title && !is_magical(op)) { |
| 516 |
strlcpy(buf, op->name, size); |
| 517 |
return; |
| 518 |
} |
| 519 |
buf[0] = '\0'; |
| 520 |
|
| 521 |
if (op->nrof <= 1) |
| 522 |
safe_strcat(buf, op->name, &len, size); |
| 523 |
else |
| 524 |
safe_strcat(buf, op->name_pl, &len, size); |
| 525 |
|
| 526 |
if (op->title && QUERY_FLAG(op, FLAG_IDENTIFIED)) { |
| 527 |
safe_strcat(buf, " ", &len, size); |
| 528 |
safe_strcat(buf, op->title, &len, size); |
| 529 |
} |
| 530 |
|
| 531 |
switch (op->type) { |
| 532 |
case SPELLBOOK: |
| 533 |
case SCROLL: |
| 534 |
case WAND: |
| 535 |
case ROD: |
| 536 |
if (QUERY_FLAG(op, FLAG_IDENTIFIED) || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) { |
| 537 |
if (!op->title && (op->inv)) { |
| 538 |
safe_strcat(buf, " of ", &len, size); |
| 539 |
safe_strcat(buf, op->inv->name, &len, size); |
| 540 |
} |
| 541 |
if (op->type != SPELLBOOK) { |
| 542 |
snprintf(buf+len, size-len, " (lvl %d)", op->level); |
| 543 |
len += strlen(buf+len); |
| 544 |
} |
| 545 |
} |
| 546 |
break; |
| 547 |
|
| 548 |
case SKILL: |
| 549 |
case AMULET: |
| 550 |
case RING: |
| 551 |
if (!op->title) { |
| 552 |
|
| 553 |
char* desc; |
| 554 |
|
| 555 |
desc = stringbuffer_finish(ring_desc(op, 0, NULL)); |
| 556 |
if (desc[0]) { |
| 557 |
safe_strcat(buf, " ", &len, size); |
| 558 |
safe_strcat(buf, desc, &len, size); |
| 559 |
} |
| 560 |
free(desc); |
| 561 |
} |
| 562 |
break; |
| 563 |
|
| 564 |
default: |
| 565 |
if (op->magic |
| 566 |
&& (QUERY_FLAG(op, FLAG_BEEN_APPLIED) || is_identified(op))) { |
| 567 |
snprintf(buf+len, size-len, " %+d", op->magic); |
| 568 |
len += strlen(buf+len); |
| 569 |
} |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
void query_name(const object *op, char *buf, size_t size) { |
| 584 |
size_t len = 0; |
| 585 |
|
| 586 |
buf[0] = '\0'; |
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
query_short_name(op, buf, size); |
| 596 |
len = strlen(buf); |
| 597 |
|
| 598 |
if (QUERY_FLAG(op, FLAG_INV_LOCKED)) |
| 599 |
safe_strcat(buf, " *", &len, size); |
| 600 |
if (op->type == CONTAINER |
| 601 |
&& ((op->env && op->env->container == op) || (!op->env && QUERY_FLAG(op, FLAG_APPLIED)))) |
| 602 |
safe_strcat(buf, " (open)", &len, size); |
| 603 |
|
| 604 |
if (QUERY_FLAG(op, FLAG_KNOWN_CURSED)) { |
| 605 |
if (QUERY_FLAG(op, FLAG_DAMNED)) |
| 606 |
safe_strcat(buf, " (damned)", &len, size); |
| 607 |
else if (QUERY_FLAG(op, FLAG_CURSED)) |
| 608 |
safe_strcat(buf, " (cursed)", &len, size); |
| 609 |
} |
| 610 |
if (QUERY_FLAG(op, FLAG_BLESSED) && QUERY_FLAG(op, FLAG_KNOWN_BLESSED)) |
| 611 |
safe_strcat(buf, " (blessed)", &len, size); |
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
if (QUERY_FLAG(op, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG(op, FLAG_IDENTIFIED)) |
| 623 |
safe_strcat(buf, " (magic)", &len, size); |
| 624 |
|
| 625 |
if (QUERY_FLAG(op, FLAG_APPLIED)) { |
| 626 |
switch (op->type) { |
| 627 |
case BOW: |
| 628 |
case WAND: |
| 629 |
case ROD: |
| 630 |
safe_strcat(buf, " (readied)", &len, size); |
| 631 |
break; |
| 632 |
|
| 633 |
case WEAPON: |
| 634 |
safe_strcat(buf, " (wielded)", &len, size); |
| 635 |
break; |
| 636 |
|
| 637 |
case ARMOUR: |
| 638 |
case HELMET: |
| 639 |
case SHIELD: |
| 640 |
case RING: |
| 641 |
case BOOTS: |
| 642 |
case GLOVES: |
| 643 |
case AMULET: |
| 644 |
case GIRDLE: |
| 645 |
case BRACERS: |
| 646 |
case CLOAK: |
| 647 |
safe_strcat(buf, " (worn)", &len, size); |
| 648 |
break; |
| 649 |
|
| 650 |
case CONTAINER: |
| 651 |
safe_strcat(buf, " (active)", &len, size); |
| 652 |
break; |
| 653 |
|
| 654 |
case SKILL: |
| 655 |
default: |
| 656 |
safe_strcat(buf, " (applied)", &len, size); |
| 657 |
} |
| 658 |
} |
| 659 |
if (QUERY_FLAG(op, FLAG_UNPAID)) |
| 660 |
safe_strcat(buf, " (unpaid)", &len, size); |
| 661 |
} |
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
void query_base_name(const object *op, int plural, char *buf, size_t size) { |
| 681 |
size_t len; |
| 682 |
|
| 683 |
if ((!plural && !op->name) |
| 684 |
|| (plural && !op->name_pl)) { |
| 685 |
strncpy(buf, "(null)", size); |
| 686 |
return; |
| 687 |
} |
| 688 |
|
| 689 |
if (!op->nrof && !op->weight && !op->title && !is_magical(op)) { |
| 690 |
strncpy(buf, op->name, size); |
| 691 |
return; |
| 692 |
} |
| 693 |
|
| 694 |
buf[0] = '\0'; |
| 695 |
|
| 696 |
strlcpy(buf, plural ? op->name_pl : op->name, size); |
| 697 |
len = strlen(buf); |
| 698 |
|
| 699 |
if (op->title && QUERY_FLAG(op, FLAG_IDENTIFIED)) { |
| 700 |
safe_strcat(buf, " ", &len, size); |
| 701 |
safe_strcat(buf, op->title, &len, size); |
| 702 |
} |
| 703 |
|
| 704 |
switch (op->type) { |
| 705 |
case SPELLBOOK: |
| 706 |
case SCROLL: |
| 707 |
case WAND: |
| 708 |
case ROD: |
| 709 |
if (QUERY_FLAG(op, FLAG_IDENTIFIED) || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) { |
| 710 |
if (!op->title && (op->inv)) { |
| 711 |
safe_strcat(buf, " of ", &len, size); |
| 712 |
safe_strcat(buf, op->inv->name, &len, size); |
| 713 |
} |
| 714 |
if (op->type != SPELLBOOK) { |
| 715 |
snprintf(buf+len, size-len, " (lvl %d)", op->level); |
| 716 |
len += strlen(buf+len); |
| 717 |
} |
| 718 |
} |
| 719 |
break; |
| 720 |
|
| 721 |
case SKILL: |
| 722 |
case AMULET: |
| 723 |
case RING: |
| 724 |
if (!op->title) { |
| 725 |
|
| 726 |
char* s; |
| 727 |
|
| 728 |
s = stringbuffer_finish(ring_desc(op, 0, NULL)); |
| 729 |
if (s[0]) { |
| 730 |
safe_strcat(buf, " ", &len, size); |
| 731 |
safe_strcat(buf, s, &len, size); |
| 732 |
} |
| 733 |
free(s); |
| 734 |
} |
| 735 |
break; |
| 736 |
|
| 737 |
default: |
| 738 |
if (op->magic |
| 739 |
&& (QUERY_FLAG(op, FLAG_BEEN_APPLIED) || is_identified(op))) { |
| 740 |
snprintf(buf+strlen(buf), size-strlen(buf), " %+d", op->magic); |
| 741 |
} |
| 742 |
} |
| 743 |
} |
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
StringBuffer *describe_monster(const object *op, int use_media_tags, StringBuffer *buf) { |
| 762 |
assert(op != NULL); |
| 763 |
assert(QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER); |
| 764 |
|
| 765 |
if (buf == NULL) |
| 766 |
buf = stringbuffer_new(); |
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
if (FABS(op->speed) > MIN_ACTIVE_SPEED) { |
| 773 |
switch ((int)((FABS(op->speed))*15)) { |
| 774 |
case 0: |
| 775 |
stringbuffer_append_string(buf, "(very slow movement)"); |
| 776 |
break; |
| 777 |
|
| 778 |
case 1: |
| 779 |
stringbuffer_append_string(buf, "(slow movement)"); |
| 780 |
break; |
| 781 |
|
| 782 |
case 2: |
| 783 |
stringbuffer_append_string(buf, "(normal movement)"); |
| 784 |
break; |
| 785 |
|
| 786 |
case 3: |
| 787 |
case 4: |
| 788 |
stringbuffer_append_string(buf, "(fast movement)"); |
| 789 |
break; |
| 790 |
|
| 791 |
case 5: |
| 792 |
case 6: |
| 793 |
stringbuffer_append_string(buf, "(very fast movement)"); |
| 794 |
break; |
| 795 |
|
| 796 |
case 7: |
| 797 |
case 8: |
| 798 |
case 9: |
| 799 |
case 10: |
| 800 |
stringbuffer_append_string(buf, "(extremely fast movement)"); |
| 801 |
break; |
| 802 |
|
| 803 |
default: |
| 804 |
stringbuffer_append_string(buf, "(lightning fast movement)"); |
| 805 |
break; |
| 806 |
} |
| 807 |
} |
| 808 |
if (QUERY_FLAG(op, FLAG_UNDEAD)) |
| 809 |
stringbuffer_append_string(buf, "(undead)"); |
| 810 |
if (QUERY_FLAG(op, FLAG_SEE_INVISIBLE)) |
| 811 |
stringbuffer_append_string(buf, "(see invisible)"); |
| 812 |
if (QUERY_FLAG(op, FLAG_USE_WEAPON)) |
| 813 |
stringbuffer_append_string(buf, "(wield weapon)"); |
| 814 |
if (QUERY_FLAG(op, FLAG_USE_BOW)) |
| 815 |
stringbuffer_append_string(buf, "(archer)"); |
| 816 |
if (QUERY_FLAG(op, FLAG_USE_ARMOUR)) |
| 817 |
stringbuffer_append_string(buf, "(wear armour)"); |
| 818 |
if (QUERY_FLAG(op, FLAG_USE_RING)) |
| 819 |
stringbuffer_append_string(buf, "(wear ring)"); |
| 820 |
if (QUERY_FLAG(op, FLAG_USE_SCROLL)) |
| 821 |
stringbuffer_append_string(buf, "(read scroll)"); |
| 822 |
if (QUERY_FLAG(op, FLAG_USE_RANGE)) |
| 823 |
stringbuffer_append_string(buf, "(fires wand/rod/horn)"); |
| 824 |
if (QUERY_FLAG(op, FLAG_CAN_USE_SKILL)) |
| 825 |
stringbuffer_append_string(buf, "(skill user)"); |
| 826 |
if (QUERY_FLAG(op, FLAG_CAST_SPELL)) |
| 827 |
stringbuffer_append_string(buf, "(spellcaster)"); |
| 828 |
if (QUERY_FLAG(op, FLAG_FRIENDLY)) |
| 829 |
stringbuffer_append_string(buf, "(friendly)"); |
| 830 |
if (QUERY_FLAG(op, FLAG_UNAGGRESSIVE)) |
| 831 |
stringbuffer_append_string(buf, "(unaggressive)"); |
| 832 |
if (QUERY_FLAG(op, FLAG_HITBACK)) |
| 833 |
stringbuffer_append_string(buf, "(hitback)"); |
| 834 |
if (QUERY_FLAG(op, FLAG_STEALTH)) |
| 835 |
stringbuffer_append_string(buf, "(stealthy)"); |
| 836 |
if (op->randomitems != NULL) { |
| 837 |
treasure *t; |
| 838 |
int first = 1; |
| 839 |
|
| 840 |
for (t = op->randomitems->items; t != NULL; t = t->next) |
| 841 |
if (t->item && (t->item->clone.type == SPELL)) { |
| 842 |
if (first) { |
| 843 |
first = 0; |
| 844 |
stringbuffer_append_string(buf, "(Spell abilities:)"); |
| 845 |
} |
| 846 |
stringbuffer_append_printf(buf, "(%s)", t->item->clone.name); |
| 847 |
} |
| 848 |
} |
| 849 |
if (op->type == PLAYER) { |
| 850 |
if (op->contr->digestion) { |
| 851 |
if (op->contr->digestion != 0) |
| 852 |
stringbuffer_append_printf(buf, "(sustenance%+d)", op->contr->digestion); |
| 853 |
} |
| 854 |
if (op->contr->gen_grace) { |
| 855 |
stringbuffer_append_printf(buf, "(grace%+d)", op->contr->gen_grace); |
| 856 |
} |
| 857 |
if (op->contr->gen_sp) { |
| 858 |
stringbuffer_append_printf(buf, "(magic%+d)", op->contr->gen_sp); |
| 859 |
} |
| 860 |
if (op->contr->gen_hp) { |
| 861 |
stringbuffer_append_printf(buf, "(regeneration%+d)", op->contr->gen_hp); |
| 862 |
} |
| 863 |
if (op->stats.luck) { |
| 864 |
stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck); |
| 865 |
} |
| 866 |
} |
| 867 |
|
| 868 |
|
| 869 |
if (is_dragon_pl(op)) { |
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
object *tmp; |
| 875 |
|
| 876 |
tmp = object_find_by_type_and_name(op, SKILL, "clawing"); |
| 877 |
if (tmp && tmp->attacktype != 0) { |
| 878 |
describe_attacktype("Claws", tmp->attacktype, buf); |
| 879 |
} else { |
| 880 |
describe_attacktype("Attacks", op->attacktype, buf); |
| 881 |
} |
| 882 |
} else { |
| 883 |
describe_attacktype("Attacks", op->attacktype, buf); |
| 884 |
} |
| 885 |
describe_spellpath_attenuation("Attuned", op->path_attuned &~ op->path_denied, buf); |
| 886 |
describe_spellpath_attenuation("Repelled", op->path_repelled &~ op->path_denied, buf ); |
| 887 |
describe_spellpath_attenuation("Denied", op->path_denied, buf); |
| 888 |
describe_resistance(op, 0, use_media_tags, buf); |
| 889 |
|
| 890 |
return buf; |
| 891 |
} |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
StringBuffer *describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf) { |
| 936 |
int identified, i; |
| 937 |
|
| 938 |
if (buf == NULL) |
| 939 |
buf = stringbuffer_new(); |
| 940 |
|
| 941 |
if (QUERY_FLAG(op, FLAG_MONSTER) || op->type == PLAYER) { |
| 942 |
return describe_monster(op, use_media_tags, buf); |
| 943 |
} |
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
if (is_identified(op)) { |
| 949 |
identified = 1; |
| 950 |
} else { |
| 951 |
stringbuffer_append_string(buf, "(unidentified)"); |
| 952 |
identified = 0; |
| 953 |
} |
| 954 |
switch (op->type) { |
| 955 |
case BOW: |
| 956 |
case ARROW: |
| 957 |
case WAND: |
| 958 |
case ROD: |
| 959 |
case WEAPON: |
| 960 |
case ARMOUR: |
| 961 |
case HELMET: |
| 962 |
case SHIELD: |
| 963 |
case BOOTS: |
| 964 |
case GLOVES: |
| 965 |
case GIRDLE: |
| 966 |
case BRACERS: |
| 967 |
case CLOAK: |
| 968 |
case SKILL_TOOL: |
| 969 |
break; |
| 970 |
|
| 971 |
case LAMP: |
| 972 |
break; |
| 973 |
|
| 974 |
case FOOD: |
| 975 |
case FLESH: |
| 976 |
case DRINK: |
| 977 |
if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) { |
| 978 |
stringbuffer_append_printf(buf, "(food+%d)", op->stats.food); |
| 979 |
|
| 980 |
if (op->type == FLESH && op->last_eat > 0 && atnr_is_dragon_enabled(op->last_eat)) { |
| 981 |
stringbuffer_append_printf(buf, "(%s metabolism)", change_resist_msg[op->last_eat]); |
| 982 |
} |
| 983 |
|
| 984 |
if (!QUERY_FLAG(op, FLAG_CURSED)) { |
| 985 |
if (op->stats.hp) |
| 986 |
stringbuffer_append_string(buf, "(heals)"); |
| 987 |
if (op->stats.sp) |
| 988 |
stringbuffer_append_string(buf, "(spellpoint regen)"); |
| 989 |
} else { |
| 990 |
if (op->stats.hp) |
| 991 |
stringbuffer_append_string(buf, "(damages)"); |
| 992 |
if (op->stats.sp) |
| 993 |
stringbuffer_append_string(buf, "(spellpoint depletion)"); |
| 994 |
} |
| 995 |
} |
| 996 |
break; |
| 997 |
|
| 998 |
case SKILL: |
| 999 |
case RING: |
| 1000 |
case AMULET: |
| 1001 |
if (op->item_power) { |
| 1002 |
stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power); |
| 1003 |
} |
| 1004 |
ring_desc(op, use_media_tags, buf); |
| 1005 |
return buf; |
| 1006 |
|
| 1007 |
default: |
| 1008 |
return buf; |
| 1009 |
} |
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
if (identified || QUERY_FLAG(op, FLAG_BEEN_APPLIED)) { |
| 1015 |
int attr, val; |
| 1016 |
|
| 1017 |
for (attr = 0; attr < NUM_STATS; attr++) { |
| 1018 |
if ((val = get_attr_value(&(op->stats), attr)) != 0) { |
| 1019 |
stringbuffer_append_printf(buf, "(%s%+d)", short_stat_name[attr], val); |
| 1020 |
} |
| 1021 |
} |
| 1022 |
if (op->glow_radius) |
| 1023 |
stringbuffer_append_string(buf, "(glowing)"); |
| 1024 |
|
| 1025 |
switch (op->type) { |
| 1026 |
case FLESH: |
| 1027 |
break; |
| 1028 |
|
| 1029 |
default: |
| 1030 |
if (op->stats.exp) { |
| 1031 |
stringbuffer_append_printf(buf, "(speed %+"FMT64")", op->stats.exp); |
| 1032 |
} |
| 1033 |
break; |
| 1034 |
} |
| 1035 |
switch (op->type) { |
| 1036 |
case BOW: |
| 1037 |
case ARROW: |
| 1038 |
case GIRDLE: |
| 1039 |
case HELMET: |
| 1040 |
case SHIELD: |
| 1041 |
case BOOTS: |
| 1042 |
case GLOVES: |
| 1043 |
case WEAPON: |
| 1044 |
case SKILL: |
| 1045 |
case RING: |
| 1046 |
case AMULET: |
| 1047 |
case ARMOUR: |
| 1048 |
case BRACERS: |
| 1049 |
case FORCE: |
| 1050 |
case CLOAK: |
| 1051 |
if (op->stats.wc) { |
| 1052 |
stringbuffer_append_printf(buf, "(wc%+d)", op->stats.wc); |
| 1053 |
} |
| 1054 |
if (op->stats.dam) { |
| 1055 |
stringbuffer_append_printf(buf, "(dam%+d)", op->stats.dam); |
| 1056 |
} |
| 1057 |
if (op->stats.ac) { |
| 1058 |
stringbuffer_append_printf(buf, "(ac%+d)", op->stats.ac); |
| 1059 |
} |
| 1060 |
if ((op->type == WEAPON || op->type == BOW) && op->level > 0) { |
| 1061 |
stringbuffer_append_printf(buf, "(improved %d/%d)", op->last_eat, op->level); |
| 1062 |
} |
| 1063 |
break; |
| 1064 |
|
| 1065 |
default: |
| 1066 |
break; |
| 1067 |
} |
| 1068 |
if (QUERY_FLAG(op, FLAG_XRAYS)) |
| 1069 |
stringbuffer_append_string(buf, "(xray-vision)"); |
| 1070 |
if (QUERY_FLAG(op, FLAG_SEE_IN_DARK)) |
| 1071 |
stringbuffer_append_string(buf, "(infravision)"); |
| 1072 |
|
| 1073 |
|
| 1074 |
if (op->move_type&MOVE_FLY_LOW) |
| 1075 |
stringbuffer_append_string(buf, "(levitate)"); |
| 1076 |
|
| 1077 |
if (op->move_type&MOVE_FLY_HIGH) |
| 1078 |
stringbuffer_append_string(buf, "(fly)"); |
| 1079 |
|
| 1080 |
if (op->move_type&MOVE_SWIM) |
| 1081 |
stringbuffer_append_string(buf, "(swim)"); |
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
if (op->item_power) { |
| 1086 |
stringbuffer_append_printf(buf, "(item_power %+d)", op->item_power); |
| 1087 |
} |
| 1088 |
} |
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
if (identified) { |
| 1095 |
int more_info = 0; |
| 1096 |
|
| 1097 |
switch (op->type) { |
| 1098 |
case ROD: |
| 1099 |
case BOW: |
| 1100 |
case ARROW: |
| 1101 |
case WAND: |
| 1102 |
case FOOD: |
| 1103 |
case FLESH: |
| 1104 |
case DRINK: |
| 1105 |
more_info = 0; |
| 1106 |
break; |
| 1107 |
|
| 1108 |
|
| 1109 |
case ARMOUR: |
| 1110 |
case HELMET: |
| 1111 |
case SHIELD: |
| 1112 |
case BOOTS: |
| 1113 |
case GLOVES: |
| 1114 |
case GIRDLE: |
| 1115 |
case BRACERS: |
| 1116 |
case CLOAK: |
| 1117 |
if (ARMOUR_SPEED(op)) { |
| 1118 |
stringbuffer_append_printf(buf, "(Max speed %1.2f)", ARMOUR_SPEED(op)/10.0); |
| 1119 |
} |
| 1120 |
if (ARMOUR_SPELLS(op)) { |
| 1121 |
stringbuffer_append_printf(buf, "(Spell regen penalty %d)", ARMOUR_SPELLS(op)); |
| 1122 |
} |
| 1123 |
more_info = 1; |
| 1124 |
break; |
| 1125 |
|
| 1126 |
case WEAPON: |
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
i = (WEAPON_SPEED(op)*2-op->magic)/2; |
| 1131 |
if (i < 0) |
| 1132 |
i = 0; |
| 1133 |
|
| 1134 |
stringbuffer_append_printf(buf, "(weapon speed %d)", i); |
| 1135 |
more_info = 1; |
| 1136 |
break; |
| 1137 |
} |
| 1138 |
if (more_info) { |
| 1139 |
if (op->stats.food) { |
| 1140 |
if (op->stats.food != 0) |
| 1141 |
stringbuffer_append_printf(buf, "(sustenance%+d)", op->stats.food); |
| 1142 |
} |
| 1143 |
if (op->stats.grace) { |
| 1144 |
stringbuffer_append_printf(buf, "(grace%+d)", op->stats.grace); |
| 1145 |
} |
| 1146 |
if (op->stats.sp) { |
| 1147 |
stringbuffer_append_printf(buf, "(magic%+d)", op->stats.sp); |
| 1148 |
} |
| 1149 |
if (op->stats.hp) { |
| 1150 |
stringbuffer_append_printf(buf, "(regeneration%+d)", op->stats.hp); |
| 1151 |
} |
| 1152 |
} |
| 1153 |
|
| 1154 |
if (op->stats.luck) { |
| 1155 |
stringbuffer_append_printf(buf, "(luck%+d)", op->stats.luck); |
| 1156 |
} |
| 1157 |
if (QUERY_FLAG(op, FLAG_LIFESAVE)) |
| 1158 |
stringbuffer_append_string(buf, "(lifesaving)"); |
| 1159 |
if (QUERY_FLAG(op, FLAG_REFL_SPELL)) |
| 1160 |
stringbuffer_append_string(buf, "(reflect spells)"); |
| 1161 |
if (QUERY_FLAG(op, FLAG_REFL_MISSILE)) |
| 1162 |
stringbuffer_append_string(buf, "(reflect missiles)"); |
| 1163 |
if (QUERY_FLAG(op, FLAG_STEALTH)) |
| 1164 |
stringbuffer_append_string(buf, "(stealth)"); |
| 1165 |
if (op->slaying != NULL && op->type != FOOD) { |
| 1166 |
stringbuffer_append_printf(buf, "(slay %s)", op->slaying); |
| 1167 |
} |
| 1168 |
describe_attacktype("Attacks", op->attacktype, buf); |
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
if (op->type != FLESH || (owner && is_dragon_pl(owner))) { |
| 1173 |
describe_resistance(op, 0, 1, buf); |
| 1174 |
} |
| 1175 |
describe_spellpath_attenuation("Attuned", op->path_attuned &~ op->path_denied, buf); |
| 1176 |
describe_spellpath_attenuation("Repelled", op->path_repelled &~ op->path_denied, buf); |
| 1177 |
describe_spellpath_attenuation("Denied", op->path_denied, buf); |
| 1178 |
} |
| 1179 |
|
| 1180 |
return buf; |
| 1181 |
} |
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
int is_magical(const object *op) { |
| 1196 |
int i; |
| 1197 |
|
| 1198 |
|
| 1199 |
if (QUERY_FLAG(op, FLAG_ALIVE)) |
| 1200 |
return 0; |
| 1201 |
|
| 1202 |
|
| 1203 |
if (op->title != NULL) |
| 1204 |
return 1; |
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
if ((op->type == AMULET || op->type == RING) |
| 1210 |
&& (op->stats.ac || op->stats.food || op->stats.exp || op->stats.dam || op->stats.wc || op->stats.sp || op->stats.hp || op->stats.luck)) |
| 1211 |
return 1; |
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
if (op->type == BOOTS |
| 1216 |
&& ((QUERY_FLAG(op, FLAG_STEALTH) || op->move_type || op->stats.exp))) |
| 1217 |
return 1; |
| 1218 |
|
| 1219 |
|
| 1220 |
if ((op->type == AMULET || op->type == SHIELD) |
| 1221 |
&& (QUERY_FLAG(op, FLAG_REFL_SPELL) || QUERY_FLAG(op, FLAG_REFL_MISSILE))) |
| 1222 |
return 1; |
| 1223 |
|
| 1224 |
|
| 1225 |
if (op->type == HELMET |
| 1226 |
&& QUERY_FLAG(op, FLAG_XRAYS)) |
| 1227 |
return 1; |
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
if (op->type == POTION || op->type == ROD || (op->type == WAND && op->stats.food)) |
| 1233 |
return 1; |
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
for (i = ATNR_PHYSICAL+1; i < NROFATTACKS; i++) |
| 1240 |
if (op->resist[i]) |
| 1241 |
return 1; |
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
if (op->resist[ATNR_PHYSICAL] |
| 1247 |
&& op->type != HELMET |
| 1248 |
&& op->type != SHIELD |
| 1249 |
&& op->type != BOOTS |
| 1250 |
&& op->type != GLOVES |
| 1251 |
&& op->type != ARMOUR) |
| 1252 |
return 1; |
| 1253 |
|
| 1254 |
|
| 1255 |
if (op->magic |
| 1256 |
|| op->type == POWER_CRYSTAL |
| 1257 |
|| op->type == SPELLBOOK |
| 1258 |
|| op->type == SCROLL |
| 1259 |
|| op->type == GIRDLE) |
| 1260 |
return 1; |
| 1261 |
|
| 1262 |
|
| 1263 |
for (i = 0; i < NUM_STATS; i++) |
| 1264 |
if (get_attr_value(&(op->stats), i) != 0) |
| 1265 |
return 1; |
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
return 0; |
| 1271 |
} |
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
|
| 1292 |
int is_identifiable_type(const object *op) { |
| 1293 |
|
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
if (op->type == SKILL_TOOL) return true; |
| 1299 |
|
| 1300 |
|
| 1301 |
const typedata *td = get_typedata(op->type); |
| 1302 |
return td && td->identifyskill; |
| 1303 |
} |
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
int is_identified(const object *op) { |
| 1317 |
return !is_identifiable_type(op) || QUERY_FLAG(op, FLAG_IDENTIFIED); |
| 1318 |
} |
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
void object_give_identified_properties(object *op) { |
| 1325 |
sstring key; |
| 1326 |
|
| 1327 |
key = object_get_value(op, "identified_face"); |
| 1328 |
if (key != NULL) { |
| 1329 |
op->face = find_face(key, op->face); |
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
CLEAR_FLAG(op, FLAG_CLIENT_ANIM_RANDOM); |
| 1334 |
CLEAR_FLAG(op, FLAG_CLIENT_ANIM_SYNC); |
| 1335 |
op->anim_speed = 0; |
| 1336 |
op->animation = 0; |
| 1337 |
object_set_value(op, "identified_face", NULL, 0); |
| 1338 |
} |
| 1339 |
|
| 1340 |
if (object_get_value(op, "identified_anim_random") != NULL) { |
| 1341 |
SET_FLAG(op, FLAG_CLIENT_ANIM_RANDOM); |
| 1342 |
object_set_value(op, "identified_anim_random", NULL, 0); |
| 1343 |
} |
| 1344 |
|
| 1345 |
key = object_get_value(op, "identified_anim_speed"); |
| 1346 |
if (key != NULL) { |
| 1347 |
op->anim_speed = atoi(key); |
| 1348 |
op->last_anim = 1; |
| 1349 |
object_set_value(op, "identified_anim_speed", NULL, 0); |
| 1350 |
} |
| 1351 |
|
| 1352 |
key = object_get_value(op, "identified_animation"); |
| 1353 |
if (key != NULL) { |
| 1354 |
op->animation = find_animation(key); |
| 1355 |
if (!QUERY_FLAG(op, FLAG_IS_TURNABLE)) |
| 1356 |
SET_FLAG(op, FLAG_ANIMATE); |
| 1357 |
animate_object(op, op->facing); |
| 1358 |
object_set_value(op, "identified_animation", NULL, 0); |
| 1359 |
} |
| 1360 |
|
| 1361 |
key = object_get_value(op, "identified_name"); |
| 1362 |
if (key != NULL) { |
| 1363 |
FREE_AND_COPY(op->name, key); |
| 1364 |
object_set_value(op, "identified_name", NULL, 0); |
| 1365 |
} |
| 1366 |
key = object_get_value(op, "identified_name_pl"); |
| 1367 |
if (key != NULL) { |
| 1368 |
FREE_AND_COPY(op->name_pl, key); |
| 1369 |
object_set_value(op, "identified_name_pl", NULL, 0); |
| 1370 |
} |
| 1371 |
} |
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
object *identify(object *op) { |
| 1387 |
object *pl, *op1; |
| 1388 |
|
| 1389 |
SET_FLAG(op, FLAG_IDENTIFIED); |
| 1390 |
CLEAR_FLAG(op, FLAG_KNOWN_MAGICAL); |
| 1391 |
CLEAR_FLAG(op, FLAG_NO_SKILL_IDENT); |
| 1392 |
|
| 1393 |
object_give_identified_properties(op); |
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
if (QUERY_FLAG(op, FLAG_CURSED) || QUERY_FLAG(op, FLAG_DAMNED)) |
| 1399 |
SET_FLAG(op, FLAG_KNOWN_CURSED); |
| 1400 |
|
| 1401 |
if (QUERY_FLAG(op, FLAG_BLESSED)) |
| 1402 |
SET_FLAG(op, FLAG_KNOWN_BLESSED); |
| 1403 |
|
| 1404 |
if (op->type == POTION) { |
| 1405 |
if (op->inv && op->randomitems) { |
| 1406 |
if (op->title) |
| 1407 |
free_string(op->title); |
| 1408 |
op->title = add_refcount(op->inv->name); |
| 1409 |
} else if (op->arch) { |
| 1410 |
free_string(op->name); |
| 1411 |
op->name = add_refcount(op->arch->clone.name); |
| 1412 |
free_string(op->name_pl); |
| 1413 |
op->name_pl = add_refcount(op->arch->clone.name_pl); |
| 1414 |
} |
| 1415 |
} |
| 1416 |
|
| 1417 |
if (op->map) { |
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
object *player = map_find_by_type(op->map, op->x, op->y, PLAYER); |
| 1422 |
|
| 1423 |
object_update(op, UP_OBJ_FACE); |
| 1424 |
op1 = object_merge(op, GET_MAP_TOP(op->map, op->x, op->y)); |
| 1425 |
if (op1) op = op1; |
| 1426 |
|
| 1427 |
if (player) |
| 1428 |
esrv_update_item(UPD_FACE | UPD_NAME | UPD_FLAGS, player, op); |
| 1429 |
|
| 1430 |
} else { |
| 1431 |
pl = object_get_player_container(op->env); |
| 1432 |
op1 = object_merge(op, op->env->inv); |
| 1433 |
if (op1) op = op1; |
| 1434 |
|
| 1435 |
if (pl) |
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
esrv_update_item(UPD_ALL, pl, op); |
| 1440 |
} |
| 1441 |
return op; |
| 1442 |
} |