1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
22 | */ |
24 | |
23 | |
25 | #include <global.h> |
24 | #include <global.h> |
26 | #include <funcpoint.h> |
25 | #include <funcpoint.h> |
27 | #include <living.h> |
26 | #include <living.h> |
… | |
… | |
47 | * may be better. |
46 | * may be better. |
48 | * Basically, for the use/nonuse, the code does something like: |
47 | * Basically, for the use/nonuse, the code does something like: |
49 | * "This item goes %s\n", with the use/nonuse values filling in the %s |
48 | * "This item goes %s\n", with the use/nonuse values filling in the %s |
50 | */ |
49 | */ |
51 | Body_Locations body_locations[NUM_BODY_LOCATIONS] = { |
50 | Body_Locations body_locations[NUM_BODY_LOCATIONS] = { |
52 | {"body_range" , "You can use it as your range weapon" , "It is used as a range weapon"}, |
|
|
53 | {"body_shield" , "You can wield it as a shield" , "It is used as a shield"}, |
51 | {KW_body_skill , "You can use it as your skill" , "It is used as a skill"}, |
54 | {"body_combat" , "You can wield it as your weapon" , "It is used as a combat weapon"}, |
52 | {KW_body_combat , "You can wield it as your weapon" , "It is used as a combat weapon"}, |
|
|
53 | {KW_body_range , "You can use it as your range weapon" , "It is used as a range weapon"}, |
|
|
54 | {KW_body_shield , "You can wield it as a shield" , "It is used as a shield"}, |
55 | {"body_arm" , "You can put it on your arm" , "It goes on a human's arm"}, |
55 | {KW_body_arm , "You can put it on your arm" , "It goes on a human's arm"}, |
56 | {"body_torso" , "You can wear it on your body" , "It goes on a human's torso"}, |
56 | {KW_body_torso , "You can wear it on your body" , "It goes on a human's torso"}, |
57 | {"body_head" , "You can wear it on your head" , "It goes on a human's head"}, |
57 | {KW_body_head , "You can wear it on your head" , "It goes on a human's head"}, |
58 | {"body_neck" , "You can wear it around your neck" , "It goes around a human's neck"}, |
58 | {KW_body_neck , "You can wear it around your neck" , "It goes around a human's neck"}, |
59 | {"body_skill" , "You can have it in your skill slot" , "It goes in a human's skill slot"}, |
|
|
60 | {"body_finger" , "You can wear it on your finger" , "It goes on a human's finger"} , |
59 | {KW_body_finger , "You can wear it on your finger" , "It goes on a human's finger"} , |
61 | {"body_shoulder", "You can wear it around your shoulders", "It goes around a human's shoulders"}, |
60 | {KW_body_shoulder, "You can wear it around your shoulders", "It goes around a human's shoulders"}, |
62 | {"body_foot" , "You can put your feets into it" , "It goes on a human's feet"}, |
61 | {KW_body_foot , "You can put it on your foot" , "It goes on a human's foot"}, |
63 | {"body_hand" , "You can put it on your hands" , "It goes on a human's hands"}, |
62 | {KW_body_hand , "You can put it on your hand" , "It goes on a human's hand"}, |
64 | {"body_wrist" , "You can wear it around your wrists" , "It goes around a human's wrist"}, |
63 | {KW_body_wrist , "You can wear it around your wrist" , "It goes around a human's wrist"}, |
65 | {"body_waist" , "You can wear it around your waist" , "It goes around a human's waist"}, |
64 | {KW_body_waist , "You can wear it around your waist" , "It goes around a human's waist"}, |
66 | /*{"body_dragon_torso", "your body", "a dragon's body"} */ |
65 | /*{"body_dragon_torso", "your body", "a dragon's body"} */ |
67 | }; |
66 | }; |
68 | |
67 | |
69 | static char numbers[21][20] = { |
68 | static char numbers[21][20] = { |
70 | "no", "", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", |
69 | "no", "", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", |
… | |
… | |
272 | { |
271 | { |
273 | int i, tmp, enc; |
272 | int i, tmp, enc; |
274 | |
273 | |
275 | enc = 0; |
274 | enc = 0; |
276 | for (i = 0; i < NUM_STATS; i++) |
275 | for (i = 0; i < NUM_STATS; i++) |
277 | enc += get_attr_value (&op->stats, i); |
276 | enc += op->stats.stat (i); |
278 | |
277 | |
279 | /* This protection logic is pretty flawed. 20% fire resistance |
278 | /* This protection logic is pretty flawed. 20% fire resistance |
280 | * is much more valuable than 20% confusion, or 20% slow, or |
279 | * is much more valuable than 20% confusion, or 20% slow, or |
281 | * several others. Start at 1 - ignore physical - all that normal |
280 | * several others. Start at 1 - ignore physical - all that normal |
282 | * armour shouldn't be counted against |
281 | * armour shouldn't be counted against |
… | |
… | |
502 | if (!QUERY_FLAG (op, FLAG_IDENTIFIED)) |
501 | if (!QUERY_FLAG (op, FLAG_IDENTIFIED)) |
503 | return buf; |
502 | return buf; |
504 | |
503 | |
505 | for (attr = 0; attr < NUM_STATS; attr++) |
504 | for (attr = 0; attr < NUM_STATS; attr++) |
506 | { |
505 | { |
507 | if ((val = get_attr_value (&(op->stats), attr)) != 0) |
506 | if ((val = op->stats.stat (attr))) |
508 | { |
|
|
509 | sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); |
507 | sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); |
510 | } |
|
|
511 | } |
508 | } |
512 | |
509 | |
513 | if (op->stats.exp) |
510 | if (op->stats.exp) |
514 | sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); |
511 | sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); |
515 | if (op->stats.wc) |
512 | if (op->stats.wc) |
… | |
… | |
773 | if ((op->is_armor () || op->is_weapon ()) && op->materialname) |
770 | if ((op->is_armor () || op->is_weapon ()) && op->materialname) |
774 | mt = name_to_material (op->materialname); |
771 | mt = name_to_material (op->materialname); |
775 | |
772 | |
776 | #ifdef NEW_MATERIAL_CODE |
773 | #ifdef NEW_MATERIAL_CODE |
777 | if ((op->is_armor () || op->is_weapon ()) && op->materialname && mt && |
774 | if ((op->is_armor () || op->is_weapon ()) && op->materialname && mt && |
778 | op->arch->clone.materialname != mt->name && !(op->material & M_SPECIAL)) |
775 | op->arch->materialname != mt->name && !(op->material & M_SPECIAL)) |
779 | { |
776 | { |
780 | strcpy (buf, mt->description); |
777 | strcpy (buf, mt->description); |
781 | len = strlen (buf); |
778 | len = strlen (buf); |
782 | safe_strcat (buf, " ", &len, MAX_BUF); |
779 | safe_strcat (buf, " ", &len, MAX_BUF); |
783 | if (!plural) |
780 | if (!plural) |
… | |
… | |
936 | { |
933 | { |
937 | treasure *t; |
934 | treasure *t; |
938 | int first = 1; |
935 | int first = 1; |
939 | |
936 | |
940 | for (t = op->randomitems->items; t != NULL; t = t->next) |
937 | for (t = op->randomitems->items; t != NULL; t = t->next) |
941 | if (t->item && t->item->clone.type == SPELL) |
938 | if (t->item && t->item->type == SPELL) |
942 | { |
939 | { |
943 | if (first) |
940 | if (first) |
944 | { |
941 | { |
945 | first = 0; |
942 | first = 0; |
946 | strcat (retbuf, "(Spell abilities:)"); |
943 | strcat (retbuf, "(Spell abilities:)"); |
947 | } |
944 | } |
948 | strcat (retbuf, "("); |
945 | strcat (retbuf, "("); |
949 | strcat (retbuf, t->item->clone.name); |
946 | strcat (retbuf, t->item->object::name); |
950 | strcat (retbuf, ")"); |
947 | strcat (retbuf, ")"); |
951 | } |
948 | } |
952 | } |
949 | } |
953 | if (op->type == PLAYER) |
950 | if (op->type == PLAYER) |
954 | { |
951 | { |
… | |
… | |
1084 | break; /* We have more information to do below this switch */ |
1081 | break; /* We have more information to do below this switch */ |
1085 | |
1082 | |
1086 | case POWER_CRYSTAL: |
1083 | case POWER_CRYSTAL: |
1087 | if (op->stats.maxsp > 1000) |
1084 | if (op->stats.maxsp > 1000) |
1088 | { /*higher capacity crystals */ |
1085 | { /*higher capacity crystals */ |
1089 | i = (op->stats.maxsp % 100) / 10; |
1086 | i = (op->stats.maxsp % 1000) / 100; |
|
|
1087 | |
1090 | if (i) |
1088 | if (i) |
1091 | snprintf (buf, MAX_BUF, "(capacity %d.%dk). It is ", op->stats.maxsp / 100, i); |
1089 | snprintf (buf, MAX_BUF, "(capacity %d.%dk). It is ", op->stats.maxsp / 1000, i); |
1092 | else |
1090 | else |
1093 | snprintf (buf, MAX_BUF, "(capacity %dk). It is ", op->stats.maxsp / 100); |
1091 | snprintf (buf, MAX_BUF, "(capacity %dk). It is ", op->stats.maxsp / 1000); |
1094 | } |
1092 | } |
1095 | else |
1093 | else |
1096 | snprintf (buf, MAX_BUF, "(capacity %d). It is ", op->stats.maxsp); |
1094 | snprintf (buf, MAX_BUF, "(capacity %d). It is ", op->stats.maxsp); |
|
|
1095 | |
1097 | strcat (retbuf, buf); |
1096 | strcat (retbuf, buf); |
1098 | i = (op->stats.sp * 10) / op->stats.maxsp; |
1097 | i = (op->stats.sp * 10) / op->stats.maxsp; |
1099 | if (op->stats.sp == 0) |
1098 | if (op->stats.sp == 0) |
1100 | strcat (retbuf, "empty."); |
1099 | strcat (retbuf, "empty."); |
1101 | else if (i == 0) |
1100 | else if (i == 0) |
… | |
… | |
1166 | { |
1165 | { |
1167 | int attr, val; |
1166 | int attr, val; |
1168 | |
1167 | |
1169 | for (attr = 0; attr < NUM_STATS; attr++) |
1168 | for (attr = 0; attr < NUM_STATS; attr++) |
1170 | { |
1169 | { |
1171 | if ((val = get_attr_value (&(op->stats), attr)) != 0) |
1170 | if ((val = op->stats.stat (attr))) |
1172 | { |
1171 | { |
1173 | sprintf (buf, "(%s%+d)", short_stat_name[attr], val); |
1172 | sprintf (buf, "(%s%+d)", short_stat_name[attr], val); |
1174 | strcat (retbuf, buf); |
1173 | strcat (retbuf, buf); |
1175 | } |
1174 | } |
1176 | } |
1175 | } |
… | |
… | |
1433 | if (op->magic || op->type == POWER_CRYSTAL || op->type == SPELLBOOK || op->type == SCROLL || op->type == GIRDLE) |
1432 | if (op->magic || op->type == POWER_CRYSTAL || op->type == SPELLBOOK || op->type == SCROLL || op->type == GIRDLE) |
1434 | return 1; |
1433 | return 1; |
1435 | |
1434 | |
1436 | /* Check to see if it increases/decreases any stats */ |
1435 | /* Check to see if it increases/decreases any stats */ |
1437 | for (i = 0; i < NUM_STATS; i++) |
1436 | for (i = 0; i < NUM_STATS; i++) |
1438 | if (get_attr_value (&(op->stats), i) != 0) |
1437 | if (op->stats.stat (i)) |
1439 | return 1; |
1438 | return 1; |
1440 | |
1439 | |
1441 | /* If it doesn't fall into any of the above categories, must |
1440 | /* If it doesn't fall into any of the above categories, must |
1442 | * be non magical. |
1441 | * be non magical. |
1443 | */ |
1442 | */ |
… | |
… | |
1452 | int |
1451 | int |
1453 | need_identify (const object *op) |
1452 | need_identify (const object *op) |
1454 | { |
1453 | { |
1455 | switch (op->type) |
1454 | switch (op->type) |
1456 | { |
1455 | { |
1457 | case RING: |
1456 | case RING: |
1458 | case WAND: |
1457 | case WAND: |
1459 | case ROD: |
1458 | case ROD: |
1460 | case HORN: |
1459 | case HORN: |
1461 | case SCROLL: |
1460 | case SCROLL: |
1462 | case SKILL: |
1461 | case SKILL: |
1463 | case SKILLSCROLL: |
1462 | case SKILLSCROLL: |
1464 | case SPELLBOOK: |
1463 | case SPELLBOOK: |
1465 | case FOOD: |
1464 | case FOOD: |
1466 | case POTION: |
1465 | case POTION: |
1467 | case BOW: |
1466 | case BOW: |
1468 | case ARROW: |
1467 | case ARROW: |
1469 | case WEAPON: |
1468 | case WEAPON: |
1470 | case ARMOUR: |
1469 | case ARMOUR: |
1471 | case SHIELD: |
1470 | case SHIELD: |
1472 | case HELMET: |
1471 | case HELMET: |
1473 | case AMULET: |
1472 | case AMULET: |
1474 | case BOOTS: |
1473 | case BOOTS: |
1475 | case GLOVES: |
1474 | case GLOVES: |
1476 | case BRACERS: |
1475 | case BRACERS: |
1477 | case GIRDLE: |
1476 | case GIRDLE: |
1478 | case CONTAINER: |
1477 | case CONTAINER: |
1479 | case DRINK: |
1478 | case DRINK: |
1480 | case FLESH: |
1479 | case FLESH: |
1481 | case INORGANIC: |
1480 | case INORGANIC: |
1482 | case CLOSE_CON: |
1481 | case CLOSE_CON: |
1483 | case CLOAK: |
1482 | case CLOAK: |
1484 | case GEM: |
1483 | case GEM: |
1485 | case POWER_CRYSTAL: |
1484 | case POWER_CRYSTAL: |
1486 | case POISON: |
1485 | case POISON: |
1487 | case BOOK: |
1486 | case BOOK: |
1488 | case SKILL_TOOL: |
1487 | case SKILL_TOOL: |
1489 | return 1; |
1488 | return 1; |
1490 | } |
1489 | } |
|
|
1490 | |
1491 | /* Try to track down some stuff that may show up here. Thus, the |
1491 | /* Try to track down some stuff that may show up here. Thus, the |
1492 | * archetype file can be updated, and this function removed. |
1492 | * archetype file can be updated, and this function removed. |
1493 | */ |
1493 | */ |
1494 | #if 0 |
1494 | #if 0 |
1495 | LOG (llevDebug, "need_identify: %s does not need to be id'd\n", op->name); |
1495 | LOG (llevDebug, "need_identify: %s does not need to be id'd\n", op->name); |
… | |
… | |
1519 | { |
1519 | { |
1520 | if (op->inv && op->randomitems) |
1520 | if (op->inv && op->randomitems) |
1521 | op->title = op->inv->name; |
1521 | op->title = op->inv->name; |
1522 | else if (op->arch) |
1522 | else if (op->arch) |
1523 | { |
1523 | { |
1524 | op->name = op->arch->clone.name; |
1524 | op->name = op->arch->object::name; |
1525 | op->name_pl = op->arch->clone.name_pl; |
1525 | op->name_pl = op->arch->object::name_pl; |
1526 | } |
1526 | } |
1527 | } |
1527 | } |
1528 | |
1528 | |
1529 | /* If the object is on a map, make sure we update its face */ |
1529 | /* If the object is on a map, make sure we update its face */ |
1530 | if (op->map) |
1530 | if (op->map) |