1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra 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 |
… | |
… | |
252 | }; |
252 | }; |
253 | |
253 | |
254 | int |
254 | int |
255 | get_power_from_ench (int ench) |
255 | get_power_from_ench (int ench) |
256 | { |
256 | { |
257 | if (ench < 0) ench = 0; |
|
|
258 | if (ench > 20) ench = 20; |
|
|
259 | |
|
|
260 | return enc_to_item_power[ench]; |
257 | return enc_to_item_power [clamp (ench, 0, 20)]; |
261 | } |
258 | } |
262 | |
259 | |
263 | /* This takes an object 'op' and figures out what its item_power |
260 | /* This takes an object 'op' and figures out what its item_power |
264 | * rating should be. This should only really be used by the treasure |
261 | * rating should be. This should only really be used by the treasure |
265 | * generation code, and when loading legacy objects. It returns |
262 | * generation code, and when loading legacy objects. It returns |
… | |
… | |
576 | if (op->type != SPELLBOOK) |
573 | if (op->type != SPELLBOOK) |
577 | buf.printf (" (lvl %d)", op->level); |
574 | buf.printf (" (lvl %d)", op->level); |
578 | } |
575 | } |
579 | break; |
576 | break; |
580 | |
577 | |
581 | case ALTAR: |
578 | case ALTAR: |
582 | case TRIGGER_ALTAR: |
579 | case TRIGGER_ALTAR: |
583 | case IDENTIFY_ALTAR: |
580 | case IDENTIFY_ALTAR: |
584 | case CONVERTER: |
581 | case CONVERTER: |
585 | if (op->slaying == shstr_money) |
582 | if (op->slaying == shstr_money) |
586 | { |
583 | { |
587 | bool wrap = !!buf.size (); |
584 | bool wrap = !!buf.size (); |
588 | |
585 | |
589 | if (wrap) buf << " ["; |
586 | if (wrap) buf << " ["; |
590 | |
587 | |
591 | archetype *coin = 0; |
588 | archetype *coin = 0; |
592 | |
589 | |
593 | for (char const *const *c = coins; *coins; ++c) |
590 | for (char const *const *c = coins; *coins; ++c) |
594 | if ((coin = archetype::find (*c))) |
591 | if ((coin = archetype::find (*c))) |
595 | if (op->stats.food % coin->value == 0) |
592 | if (op->stats.food % coin->value == 0) |
596 | break; |
593 | break; |
597 | |
594 | |
598 | sint32 coins = op->stats.food / coin->value; |
595 | sint32 coins = op->stats.food / coin->value; |
599 | |
596 | |
600 | buf.printf ("drop %d %s (or equivalent)", coins, coins == 1 ? &coin->name : &coin->name_pl); |
597 | buf.printf ("drop %d %s (or equivalent)", coins, coins == 1 ? &coin->name : &coin->name_pl); |
601 | |
598 | |
602 | if (wrap) buf << ']'; |
599 | if (wrap) buf << ']'; |
603 | } |
600 | } |
604 | break; |
601 | break; |
605 | |
602 | |
606 | case SKILL: |
603 | case SKILL: |
607 | case AMULET: |
604 | case AMULET: |
608 | case RING: |
605 | case RING: |
609 | if (!op->title) |
606 | if (!op->title) |
… | |
… | |
718 | break; |
715 | break; |
719 | case SKILL: |
716 | case SKILL: |
720 | default: |
717 | default: |
721 | buf << " (applied)"; |
718 | buf << " (applied)"; |
722 | } |
719 | } |
|
|
720 | } |
|
|
721 | |
|
|
722 | switch (op->type) |
|
|
723 | { |
|
|
724 | case LAMP: |
|
|
725 | if (op->glow_radius) |
|
|
726 | buf << " (on)"; |
|
|
727 | else if (op->stats.food <= 0) |
|
|
728 | buf << " (empty)"; |
|
|
729 | else |
|
|
730 | buf << " (off)"; |
|
|
731 | break; |
|
|
732 | |
|
|
733 | case TORCH: |
|
|
734 | if (op->glow_radius) |
|
|
735 | buf << " (burning)"; |
|
|
736 | else if (op->stats.food <= 0) |
|
|
737 | buf << " (burned out)"; |
|
|
738 | break; |
723 | } |
739 | } |
724 | |
740 | |
725 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
741 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
726 | buf << " (unpaid)"; |
742 | buf << " (unpaid)"; |
727 | |
743 | |
… | |
… | |
1012 | buf << "fully charged."; |
1028 | buf << "fully charged."; |
1013 | else |
1029 | else |
1014 | buf << "almost full."; |
1030 | buf << "almost full."; |
1015 | break; |
1031 | break; |
1016 | |
1032 | |
|
|
1033 | case LAMP: |
|
|
1034 | { |
|
|
1035 | int percent = ((double) 100 / op->arch->stats.food) * op->stats.food; |
|
|
1036 | buf << "(fuel: "; |
|
|
1037 | if (percent == 0) |
|
|
1038 | buf << "empty"; |
|
|
1039 | else if (percent < 10) |
|
|
1040 | buf << "very low"; |
|
|
1041 | else if (percent < 25) |
|
|
1042 | buf << "low"; |
|
|
1043 | else if (percent < 50) |
|
|
1044 | buf << "half empty"; |
|
|
1045 | else if (percent < 75) |
|
|
1046 | buf << "half full"; |
|
|
1047 | else if (percent < 95) |
|
|
1048 | buf << "well filled"; |
|
|
1049 | else if (percent <= 100) |
|
|
1050 | buf << "full"; |
|
|
1051 | buf << ")"; |
|
|
1052 | } |
|
|
1053 | break; |
|
|
1054 | |
1017 | case FOOD: |
1055 | case FOOD: |
1018 | case FLESH: |
1056 | case FLESH: |
1019 | case DRINK: |
1057 | case DRINK: |
1020 | if (identified || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) |
1058 | if (identified || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) |
1021 | { |
1059 | { |
… | |
… | |
1215 | { |
1253 | { |
1216 | static dynbuf_text buf; buf.clear (); |
1254 | static dynbuf_text buf; buf.clear (); |
1217 | |
1255 | |
1218 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1256 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1219 | if (who && QUERY_FLAG (who, FLAG_WIZ)) |
1257 | if (who && QUERY_FLAG (who, FLAG_WIZ)) |
1220 | buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, query_name (tmp), tmp->count, query_weight (tmp)); |
1258 | buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, tmp->query_name (), tmp->count, tmp->query_weight ()); |
1221 | else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) |
1259 | else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) |
1222 | buf.printf ("%s- %-36.36s %-8s\n", indent, query_name (tmp), query_weight (tmp)); |
1260 | buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ()); |
1223 | |
1261 | |
1224 | if (buf.size ()) |
1262 | if (buf.size ()) |
1225 | buf.printf ("%s(total weight: %s)\n", indent, query_weight (this)); |
1263 | buf.printf ("%s(total weight: %s)\n", indent, query_weight ()); |
1226 | else |
1264 | else |
1227 | buf.printf ("%s(empty)\n", indent); |
1265 | buf.printf ("%s(empty)\n", indent); |
1228 | |
1266 | |
1229 | return buf; |
1267 | return buf; |
1230 | } |
1268 | } |