1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | * |
7 | * |
… | |
… | |
250 | }; |
250 | }; |
251 | |
251 | |
252 | int |
252 | int |
253 | get_power_from_ench (int ench) |
253 | get_power_from_ench (int ench) |
254 | { |
254 | { |
255 | if (ench < 0) |
255 | if (ench < 0) ench = 0; |
256 | ench = 0; |
256 | if (ench > 20) ench = 20; |
257 | if (ench > 20) |
257 | |
258 | ench = 20; |
|
|
259 | return enc_to_item_power[ench]; |
258 | return enc_to_item_power[ench]; |
260 | } |
259 | } |
261 | |
260 | |
262 | /* This takes an object 'op' and figures out what its item_power |
261 | /* This takes an object 'op' and figures out what its item_power |
263 | * rating should be. This should only really be used by the treasure |
262 | * rating should be. This should only really be used by the treasure |
… | |
… | |
342 | enc += 1; |
341 | enc += 1; |
343 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
342 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
344 | enc += 1; |
343 | enc += 1; |
345 | |
344 | |
346 | return get_power_from_ench (enc); |
345 | return get_power_from_ench (enc); |
347 | |
|
|
348 | } |
346 | } |
349 | |
347 | |
350 | /* returns the typedata that has a number equal to itemtype, if there |
348 | /* returns the typedata that has a number equal to itemtype, if there |
351 | * isn't one, returns NULL */ |
349 | * isn't one, returns NULL */ |
352 | |
|
|
353 | const typedata * |
350 | const typedata * |
354 | get_typedata (int itemtype) |
351 | get_typedata (int itemtype) |
355 | { |
352 | { |
356 | int i; |
353 | int i; |
357 | |
354 | |
… | |
… | |
362 | } |
359 | } |
363 | |
360 | |
364 | /* returns the typedata that has a name equal to itemtype, if there |
361 | /* returns the typedata that has a name equal to itemtype, if there |
365 | * isn't one, return the plural name that matches, if there still isn't |
362 | * isn't one, return the plural name that matches, if there still isn't |
366 | * one return NULL */ |
363 | * one return NULL */ |
367 | |
|
|
368 | const typedata * |
364 | const typedata * |
369 | get_typedata_by_name (const char *name) |
365 | get_typedata_by_name (const char *name) |
370 | { |
366 | { |
371 | int i; |
367 | int i; |
372 | |
368 | |
… | |
… | |
509 | if ((val = get_attr_value (&(op->stats), attr)) != 0) |
505 | if ((val = get_attr_value (&(op->stats), attr)) != 0) |
510 | { |
506 | { |
511 | sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); |
507 | sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); |
512 | } |
508 | } |
513 | } |
509 | } |
|
|
510 | |
514 | if (op->stats.exp) |
511 | if (op->stats.exp) |
515 | sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); |
512 | sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); |
516 | if (op->stats.wc) |
513 | if (op->stats.wc) |
517 | sprintf (buf + strlen (buf), "(wc%+d)", op->stats.wc); |
514 | sprintf (buf + strlen (buf), "(wc%+d)", op->stats.wc); |
518 | if (op->stats.dam) |
515 | if (op->stats.dam) |
… | |
… | |
540 | strcat (buf, "(reflect spells)"); |
537 | strcat (buf, "(reflect spells)"); |
541 | if (QUERY_FLAG (op, FLAG_REFL_MISSILE)) |
538 | if (QUERY_FLAG (op, FLAG_REFL_MISSILE)) |
542 | strcat (buf, "(reflect missiles)"); |
539 | strcat (buf, "(reflect missiles)"); |
543 | if (QUERY_FLAG (op, FLAG_STEALTH)) |
540 | if (QUERY_FLAG (op, FLAG_STEALTH)) |
544 | strcat (buf, "(stealth)"); |
541 | strcat (buf, "(stealth)"); |
|
|
542 | |
545 | /* Shorten some of the names, so they appear better in the windows */ |
543 | /* Shorten some of the names, so they appear better in the windows */ |
546 | len = strlen (buf); |
544 | len = strlen (buf); |
547 | DESCRIBE_PATH_SAFE (buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); |
545 | DESCRIBE_PATH_SAFE (buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); |
548 | DESCRIBE_PATH_SAFE (buf, op->path_repelled, "Repelled", &len, VERY_BIG_BUF); |
546 | DESCRIBE_PATH_SAFE (buf, op->path_repelled, "Repelled", &len, VERY_BIG_BUF); |
549 | DESCRIBE_PATH_SAFE (buf, op->path_denied, "Denied", &len, VERY_BIG_BUF); |
547 | DESCRIBE_PATH_SAFE (buf, op->path_denied, "Denied", &len, VERY_BIG_BUF); |
… | |
… | |
714 | { |
712 | { |
715 | case BOW: |
713 | case BOW: |
716 | case WAND: |
714 | case WAND: |
717 | case ROD: |
715 | case ROD: |
718 | case HORN: |
716 | case HORN: |
719 | safe_strcat (buf[use_buf], " (readied)", &len, HUGE_BUF); |
717 | safe_strcat (buf[use_buf], op->env && op->env->current_weapon == op ? " (readied)" : " (applied)", &len, HUGE_BUF); |
720 | break; |
718 | break; |
721 | case WEAPON: |
719 | case WEAPON: |
722 | safe_strcat (buf[use_buf], " (wielded)", &len, HUGE_BUF); |
720 | safe_strcat (buf[use_buf], op->env && op->env->current_weapon == op ? " (wielded)" : " (applied)", &len, HUGE_BUF); |
723 | break; |
721 | break; |
724 | case ARMOUR: |
722 | case ARMOUR: |
725 | case HELMET: |
723 | case HELMET: |
726 | case SHIELD: |
724 | case SHIELD: |
727 | case RING: |
725 | case RING: |
… | |
… | |
842 | safe_strcat (buf, " ", &len, MAX_BUF); |
840 | safe_strcat (buf, " ", &len, MAX_BUF); |
843 | safe_strcat (buf, s, &len, MAX_BUF); |
841 | safe_strcat (buf, s, &len, MAX_BUF); |
844 | } |
842 | } |
845 | } |
843 | } |
846 | break; |
844 | break; |
|
|
845 | |
847 | default: |
846 | default: |
848 | if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) |
847 | if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) |
849 | { |
|
|
850 | sprintf (buf + strlen (buf), " %+d", op->magic); |
848 | sprintf (buf + strlen (buf), " %+d", op->magic); |
851 | } |
|
|
852 | } |
849 | } |
853 | |
850 | |
854 | return buf; |
851 | return buf; |
855 | } |
852 | } |
856 | |
853 | |
… | |
… | |
1361 | } |
1358 | } |
1362 | |
1359 | |
1363 | return retbuf; |
1360 | return retbuf; |
1364 | } |
1361 | } |
1365 | |
1362 | |
|
|
1363 | std::string |
|
|
1364 | object::describe_item (object *who) |
|
|
1365 | { |
|
|
1366 | return std::string (::describe_item (this, who)); |
|
|
1367 | } |
|
|
1368 | |
1366 | /* Return true if the item is magical. A magical item is one that |
1369 | /* Return true if the item is magical. A magical item is one that |
1367 | * increases/decreases any abilities, provides a resistance, |
1370 | * increases/decreases any abilities, provides a resistance, |
1368 | * has a generic magical bonus, or is an artifact. |
1371 | * has a generic magical bonus, or is an artifact. |
1369 | * This function is used by detect_magic to determine if an item |
1372 | * This function is used by detect_magic to determine if an item |
1370 | * should be marked as magical. |
1373 | * should be marked as magical. |