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,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
47 | * Note that using the term 'human' may not be very accurate, humanoid |
47 | * Note that using the term 'human' may not be very accurate, humanoid |
48 | * may be better. |
48 | * may be better. |
49 | * Basically, for the use/nonuse, the code does something like: |
49 | * Basically, for the use/nonuse, the code does something like: |
50 | * "This item goes %s\n", with the use/nonuse values filling in the %s |
50 | * "This item goes %s\n", with the use/nonuse values filling in the %s |
51 | */ |
51 | */ |
|
|
52 | // see include/object.h |
52 | Body_Locations body_locations[NUM_BODY_LOCATIONS] = { |
53 | Body_Locations body_locations[NUM_BODY_LOCATIONS] = { |
53 | {KW_body_skill , "You can use it as your skill" , "It is used as a skill"}, |
54 | {KW_body_skill , "You can use it as your skill" , "It is used as a skill"}, |
54 | {KW_body_combat , "You can wield it as your weapon" , "It is used as a combat weapon"}, |
55 | {KW_body_combat , "You can wield it as your weapon" , "It is used as a combat weapon"}, |
55 | {KW_body_range , "You can use it as your range weapon" , "It is used as a range weapon"}, |
56 | {KW_body_range , "You can use it as your range weapon" , "It is used as a range weapon"}, |
56 | {KW_body_shield , "You can wield it as a shield" , "It is used as a shield"}, |
57 | {KW_body_shield , "You can wield it as a shield" , "It is used as a shield"}, |
… | |
… | |
203 | {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, |
204 | {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, |
204 | }; |
205 | }; |
205 | |
206 | |
206 | static const int item_types_size = sizeof (item_types) / sizeof (*item_types); |
207 | static const int item_types_size = sizeof (item_types) / sizeof (*item_types); |
207 | |
208 | |
208 | materialtype_t *materialt; |
|
|
209 | |
|
|
210 | /* |
|
|
211 | materialtype material[NROFMATERIALS] = { |
|
|
212 | * P M F E C C A D W G P S P T F C D D C C G H B I * |
|
|
213 | * H A I L O O C R E H O L A U E A E E H O O O L N * |
|
|
214 | * Y G R E L N I A A O I O R R A N P A A U D L I T * |
|
|
215 | * S I E C D F D I P S S W A N R C L T O N Y N R * |
|
|
216 | * I C T U N O T O L E E H S T P D N * |
|
|
217 | {"paper", {15,10,17, 9, 5, 7,13, 0,20,15, 0,0,0,0,0,10,0,0,0,0,0,0,0,0}}, |
|
|
218 | {"metal", { 2,12, 3,12, 2,10, 7, 0,20,15, 0,0,0,0,0,10,0,0,0,0,0,0,0,0}}, |
|
|
219 | {"glass", {14,11, 8, 3,10, 5, 1, 0,20,15, 0,0,0,0,0, 0,0,0,0,0,0,0,0,0}}, |
|
|
220 | {"leather", { 5,10,10, 3, 3,10,10, 0,20,15, 0,0,0,0,0,12,0,0,0,0,0,0,0,0}}, |
|
|
221 | {"wood", {10,11,13, 2, 2,10, 9, 0,20,15, 0,0,0,0,0,12,0,0,0,0,0,0,0,0}}, |
|
|
222 | {"organics", { 3,12, 9,11, 3,10, 9, 0,20,15, 0,0,0,0,0, 0,0,0,0,0,0,0,0,0}}, |
|
|
223 | {"stone", { 2, 5, 2, 2, 2, 2, 1, 0,20,15, 0,0,0,0,0, 5,0,0,0,0,0,0,0,0}}, |
|
|
224 | {"cloth", {14,11,13, 4, 4, 5,10, 0,20,15, 0,0,0,0,0, 5,0,0,0,0,0,0,0,0}}, |
|
|
225 | {"adamant", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0,0, 0,0,0,0,0,0,0,0,0}}, |
|
|
226 | {"liquid", { 0, 8, 9, 6,17, 0,15, 0,20,15,12,0,0,0,0,11,0,0,0,0,0,0,0,0}}, |
|
|
227 | {"soft metal",{ 6,12, 6,14, 2,10, 1, 0,20,15, 0,0,0,0,0,10,0,0,0,0,0,0,0,0}}, |
|
|
228 | {"bone", {10, 9, 4, 5, 3,10,10, 0,20,15, 0,0,0,0,0, 2,0,0,0,0,0,0,0,0}}, |
|
|
229 | {"ice", {14,11,16, 5, 0, 5, 6, 0,20,15, 0,0,0,0,0, 7,0,0,0,0,0,0,0,0}} |
|
|
230 | }; |
|
|
231 | */ |
|
|
232 | |
|
|
233 | /* This curve may be too steep. But the point is that there should |
209 | /* This curve may be too steep. But the point is that there should |
234 | * be tough choices - there is no real point to this if everyone can |
210 | * be tough choices - there is no real point to this if everyone can |
235 | * wear whatever they want with no worries. Perhaps having the steep |
211 | * wear whatever they want with no worries. Perhaps having the steep |
236 | * curve is good (maybe even steeper), but allowing players to |
212 | * curve is good (maybe even steeper), but allowing players to |
237 | * have 2 * level instead. Ideally, top level characters should only be |
213 | * have 2 * level instead. Ideally, top level characters should only be |
… | |
… | |
313 | |
289 | |
314 | enc += op->stats.luck; |
290 | enc += op->stats.luck; |
315 | |
291 | |
316 | /* Do spell paths now */ |
292 | /* Do spell paths now */ |
317 | for (i = 1; i < NRSPELLPATHS; i++) |
293 | for (i = 1; i < NRSPELLPATHS; i++) |
318 | { |
|
|
319 | if (op->path_attuned & (1 << i)) |
294 | if (op->path_attuned & (1 << i)) |
320 | enc++; |
295 | enc++; |
321 | else if (op->path_denied & (1 << i)) |
296 | else if (op->path_denied & (1 << i)) |
322 | enc -= 2; |
297 | enc -= 2; |
323 | else if (op->path_repelled & (1 << i)) |
298 | else if (op->path_repelled & (1 << i)) |
324 | enc--; |
299 | enc--; |
325 | } |
|
|
326 | |
300 | |
327 | if (op->flag [FLAG_LIFESAVE ]) enc += 5; |
301 | if (op->flag [FLAG_LIFESAVE ]) enc += 5; |
328 | if (op->flag [FLAG_REFL_SPELL ]) enc += 3; |
302 | if (op->flag [FLAG_REFL_SPELL ]) enc += 3; |
329 | if (op->flag [FLAG_REFL_MISSILE]) enc += 2; |
303 | if (op->flag [FLAG_REFL_MISSILE]) enc += 2; |
330 | if (op->flag [FLAG_XRAYS ]) enc += 2; |
304 | if (op->flag [FLAG_XRAYS ]) enc += 2; |
… | |
… | |
588 | * returned is good forever.) However, it makes printing statements that |
562 | * returned is good forever.) However, it makes printing statements that |
589 | * use several names much easier (don't need to store them to temp variables.) |
563 | * use several names much easier (don't need to store them to temp variables.) |
590 | * |
564 | * |
591 | * It is used extensively within messages, so should return only a prose |
565 | * It is used extensively within messages, so should return only a prose |
592 | * and short description of the item. |
566 | * and short description of the item. |
|
|
567 | * It is also used by examine/ex and similar functions. |
593 | */ |
568 | */ |
594 | const char * |
569 | const char * |
595 | query_name (const object *op) |
570 | query_name (const object *op) |
596 | { |
571 | { |
597 | int len = 0; |
572 | int len = 0; |
… | |
… | |
602 | use_buf %= 5; |
577 | use_buf %= 5; |
603 | |
578 | |
604 | dynbuf_text &buf = bufs [use_buf]; |
579 | dynbuf_text &buf = bufs [use_buf]; |
605 | buf.clear (); |
580 | buf.clear (); |
606 | |
581 | |
|
|
582 | #if 0 |
607 | if ((op->is_armor () || op->is_weapon ()) && op->materialname) |
583 | if ((op->is_armor () || op->is_weapon ()) && op->material) |
608 | if (materialtype_t *mt = name_to_material (op->materialname)) |
|
|
609 | buf << mt->description << ' '; |
584 | buf << op->material->description << ' '; |
|
|
585 | #endif |
610 | |
586 | |
611 | buf << query_short_name (op); |
587 | buf << query_short_name (op); |
612 | |
588 | |
613 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
589 | if (QUERY_FLAG (op, FLAG_INV_LOCKED)) |
614 | buf << " *"; |
590 | buf << " *"; |
… | |
… | |
650 | { |
626 | { |
651 | case BOW: |
627 | case BOW: |
652 | case WAND: |
628 | case WAND: |
653 | case ROD: |
629 | case ROD: |
654 | case HORN: |
630 | case HORN: |
655 | buf << (op->env && op->env->current_weapon == op ? " (readied)" : " (applied)"); |
631 | buf << " (applied)"; |
656 | break; |
632 | break; |
657 | case WEAPON: |
633 | case WEAPON: |
658 | buf << (op->env && op->env->current_weapon == op ? " (wielded)" : " (applied)"); |
634 | buf << " (applied)"; |
659 | break; |
635 | break; |
660 | case ARMOUR: |
636 | case ARMOUR: |
661 | case HELMET: |
637 | case HELMET: |
662 | case SHIELD: |
638 | case SHIELD: |
663 | case RING: |
639 | case RING: |
… | |
… | |
712 | * and sending to client. |
688 | * and sending to client. |
713 | * If plural is set, we generate the plural name of this. |
689 | * If plural is set, we generate the plural name of this. |
714 | * |
690 | * |
715 | * It is sometimes used to display messages, and usually only used to match stuff, |
691 | * It is sometimes used to display messages, and usually only used to match stuff, |
716 | * so maybe this function should be removed. |
692 | * so maybe this function should be removed. |
|
|
693 | * It is also used for client-side inventory/item descriptions. |
717 | */ |
694 | */ |
718 | const char * |
695 | const char * |
719 | query_base_name (const object *op, int plural) |
696 | query_base_name (const object *op, int plural) |
720 | { |
697 | { |
721 | if ((!plural && !op->name) || (plural && !op->name_pl)) |
698 | if ((!plural && !op->name) || (plural && !op->name_pl)) |
722 | return "(null)"; |
699 | return "(null)"; |
723 | |
700 | |
724 | if (!op->nrof && !op->weight && !op->title && !is_magical (op)) |
701 | if (!op->nrof && !op->weight && !op->title && !is_magical (op) |
|
|
702 | && op->type != EXIT) |
725 | return op->name; /* To speed things up (or make things slower?) */ |
703 | return op->name; /* To speed things up (or make things slower?) */ |
726 | |
704 | |
727 | static dynbuf_text buf; buf.clear (); |
705 | static dynbuf_text buf; buf.clear (); |
728 | |
706 | |
|
|
707 | #if 0 |
729 | if ((op->is_armor () || op->is_weapon ()) && op->materialname) |
708 | if ((op->is_armor () || op->is_weapon ()) && op->material) |
730 | if (materialtype_t *mt = name_to_material (op->materialname)) |
|
|
731 | if (op->arch->materialname != mt->name) |
709 | if (op->arch->material != op->material) |
732 | buf << mt->description << ' '; |
710 | buf << op->material->description << ' '; |
|
|
711 | #endif |
733 | |
712 | |
734 | buf << (plural ? op->name_pl : op->name); |
713 | buf << (plural ? op->name_pl : op->name); |
735 | |
714 | |
736 | if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED)) |
715 | if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED)) |
737 | buf << ' ' << op->title; |
716 | buf << ' ' << op->title; |
… | |
… | |
764 | if (s && *s) |
743 | if (s && *s) |
765 | buf << ' ' << s; |
744 | buf << ' ' << s; |
766 | } |
745 | } |
767 | break; |
746 | break; |
768 | |
747 | |
|
|
748 | case EXIT: |
|
|
749 | // random map exits "unfortunately" get patched, so this only works before entering |
|
|
750 | if (EXIT_PATH (op) == shstr_random_map_exit) |
|
|
751 | buf << " (random map)"; |
|
|
752 | else if (!EXIT_PATH (op)) |
|
|
753 | buf << " (closed)"; |
|
|
754 | break; |
|
|
755 | |
769 | default: |
756 | default: |
770 | if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) |
757 | if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) |
771 | buf.printf (" %+d", op->magic); |
758 | buf.printf (" %+d", op->magic); |
772 | } |
759 | } |
773 | |
760 | |
… | |
… | |
788 | /* Note that the resolution this provides for players really isn't |
775 | /* Note that the resolution this provides for players really isn't |
789 | * very good. Any player with a speed greater than .67 will |
776 | * very good. Any player with a speed greater than .67 will |
790 | * fall into the 'lightning fast movement' category. |
777 | * fall into the 'lightning fast movement' category. |
791 | */ |
778 | */ |
792 | if (op->has_active_speed ()) |
779 | if (op->has_active_speed ()) |
793 | switch ((int)((fabs (op->speed)) * 15.)) |
780 | switch ((int)(op->speed * 15.)) |
794 | { |
781 | { |
795 | case 0: |
782 | case 0: |
796 | buf << "(very slow movement)"; |
783 | buf << "(very slow movement)"; |
797 | break; |
784 | break; |
798 | case 1: |
785 | case 1: |
… | |
… | |
868 | if (op->stats.luck) |
855 | if (op->stats.luck) |
869 | buf.printf ("(luck%+d)", op->stats.luck); |
856 | buf.printf ("(luck%+d)", op->stats.luck); |
870 | } |
857 | } |
871 | |
858 | |
872 | /* describe attacktypes */ |
859 | /* describe attacktypes */ |
873 | if (is_dragon_pl (op)) |
860 | if (op->is_dragon ()) |
874 | { |
861 | { |
875 | /* for dragon players display the attacktypes from clawing skill |
862 | /* for dragon players display the attacktypes from clawing skill |
876 | * Break apart the for loop - move the comparison checking down - |
863 | * Break apart the for loop - move the comparison checking down - |
877 | * this makes it more readable. |
864 | * this makes it more readable. |
878 | */ |
865 | */ |
… | |
… | |
1177 | |
1164 | |
1178 | buf.add_abilities ("Attacks", op->attacktype); |
1165 | buf.add_abilities ("Attacks", op->attacktype); |
1179 | /* resistance on flesh is only visible for quetzals. If |
1166 | /* resistance on flesh is only visible for quetzals. If |
1180 | * non flesh, everyone can see its resistances |
1167 | * non flesh, everyone can see its resistances |
1181 | */ |
1168 | */ |
1182 | if (op->type != FLESH || (owner && is_dragon_pl (owner))) |
1169 | if (op->type != FLESH || (owner && owner->is_dragon ())) |
1183 | buf << describe_resistance (op, 0); |
1170 | buf << describe_resistance (op, 0); |
1184 | |
1171 | |
1185 | buf.add_paths ("Attuned", op->path_attuned); |
1172 | buf.add_paths ("Attuned", op->path_attuned); |
1186 | buf.add_paths ("Repelled", op->path_repelled); |
1173 | buf.add_paths ("Repelled", op->path_repelled); |
1187 | buf.add_paths ("Denied", op->path_denied); |
1174 | buf.add_paths ("Denied", op->path_denied); |
… | |
… | |
1214 | { |
1201 | { |
1215 | static dynbuf_text buf; buf.clear (); |
1202 | static dynbuf_text buf; buf.clear (); |
1216 | |
1203 | |
1217 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1204 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1218 | if (who && QUERY_FLAG (who, FLAG_WIZ)) |
1205 | if (who && QUERY_FLAG (who, FLAG_WIZ)) |
1219 | buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, tmp->query_name (), tmp->count, tmp->query_weight ()); |
1206 | buf.printf ("%s- %-28.28s %-8s (%9d) %s\n", indent, tmp->query_name (), tmp->query_weight (), tmp->count, tmp->uuid.c_str ()); |
1220 | else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) |
1207 | else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) |
1221 | buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ()); |
1208 | buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ()); |
1222 | |
1209 | |
1223 | if (buf.size ()) |
1210 | if (buf.size ()) |
1224 | buf.printf ("%s(total weight: %s)\n", indent, query_weight ()); |
1211 | buf.printf ("%s(total weight: %s)\n", indent, query_weight ()); |