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,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 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 |
… | |
… | |
67 | |
67 | |
68 | int tmpmatch = item_matched_string (pl, tmp, params); |
68 | int tmpmatch = item_matched_string (pl, tmp, params); |
69 | |
69 | |
70 | if (tmpmatch > match_val) |
70 | if (tmpmatch > match_val) |
71 | { |
71 | { |
72 | if ((aflag == AP_APPLY) && (QUERY_FLAG (tmp, FLAG_APPLIED))) |
72 | if ((aflag == AP_APPLY) && (tmp->flag [FLAG_APPLIED])) |
73 | continue; |
73 | continue; |
74 | |
74 | |
75 | if ((aflag == AP_UNAPPLY) && (!QUERY_FLAG (tmp, FLAG_APPLIED))) |
75 | if ((aflag == AP_UNAPPLY) && (!tmp->flag [FLAG_APPLIED])) |
76 | continue; |
76 | continue; |
77 | |
77 | |
78 | match_val = tmpmatch; |
78 | match_val = tmpmatch; |
79 | best = tmp; |
79 | best = tmp; |
80 | } |
80 | } |
… | |
… | |
150 | * as it includes the object to throw. |
150 | * as it includes the object to throw. |
151 | */ |
151 | */ |
152 | int |
152 | int |
153 | command_throw (object *op, char *params) |
153 | command_throw (object *op, char *params) |
154 | { |
154 | { |
155 | if (object *skop = find_skill_by_name (op, skill_names[SK_THROWING])) |
155 | if (object *skop = find_skill_by_name (op, shstr_throwing)) |
156 | return do_skill (op, op, skop, op->facing, params); |
156 | return do_skill (op, op, skop, op->facing, params); |
157 | else |
157 | else |
158 | new_draw_info (NDI_UNIQUE, 0, op, "You have no knowledge of the throwing skill."); |
158 | new_draw_info (NDI_UNIQUE, 0, op, "You have no knowledge of the throwing skill."); |
159 | |
159 | |
160 | return 0; |
160 | return 0; |
… | |
… | |
209 | * not need to use split_ob and stuff. |
209 | * not need to use split_ob and stuff. |
210 | */ |
210 | */ |
211 | int |
211 | int |
212 | sack_can_hold (object *pl, object *sack, object *op, uint32 nrof) |
212 | sack_can_hold (object *pl, object *sack, object *op, uint32 nrof) |
213 | { |
213 | { |
214 | if (!QUERY_FLAG (sack, FLAG_APPLIED)) |
214 | if (!sack->flag [FLAG_APPLIED]) |
215 | { |
215 | { |
216 | new_draw_info_format (NDI_UNIQUE, 0, pl, "The %s is not active.", query_name (sack)); |
216 | new_draw_info_format (NDI_UNIQUE, 0, pl, "The %s is not active.", query_name (sack)); |
217 | return 0; |
217 | return 0; |
218 | } |
218 | } |
219 | |
219 | |
… | |
… | |
255 | * pick up (0 means all of them) |
255 | * pick up (0 means all of them) |
256 | */ |
256 | */ |
257 | static void |
257 | static void |
258 | pick_up_object (object *pl, object *op, object *tmp, int nrof) |
258 | pick_up_object (object *pl, object *op, object *tmp, int nrof) |
259 | { |
259 | { |
260 | object *env = tmp->env; |
|
|
261 | uint32 weight, effective_weight_limit; |
260 | uint32 weight, effective_weight_limit; |
262 | int tmp_nrof = tmp->number_of (); |
261 | int tmp_nrof = tmp->number_of (); |
263 | |
262 | |
264 | /* IF the player is flying & trying to take the item out of a container |
263 | /* IF the player is flying & trying to take the item out of a container |
265 | * that is in his inventory, let him. tmp->env points to the container |
264 | * that is in his inventory, let him. tmp->env points to the container |
266 | * (sack, luggage, etc), tmp->env->env then points to the player (nested |
265 | * (sack, luggage, etc), tmp->env->env then points to the player (nested |
267 | * containers not allowed as of now) |
266 | * containers not allowed as of now) |
268 | */ |
267 | */ |
269 | if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && tmp->in_player () != pl) |
268 | if ((pl->move_type & MOVE_FLYING) && !pl->flag [FLAG_WIZ] && tmp->in_player () != pl) |
270 | { |
269 | { |
271 | pl->failmsg ("You are levitating, you can't reach the ground! " |
270 | pl->failmsg ("You are levitating, you can't reach the ground! " |
272 | "H<You have to stop levitating first, if you can, either by using your levitation skill, " |
271 | "H<You have to stop levitating first, if you can, either by using your levitation skill, " |
273 | "or waiting till the levitation effect wears off.>"); |
272 | "or waiting till the levitation effect wears off.>"); |
274 | return; |
273 | return; |
275 | } |
274 | } |
276 | |
275 | |
277 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
276 | if (tmp->flag [FLAG_NO_DROP]) |
278 | return; |
277 | return; |
279 | |
278 | |
280 | if (nrof > tmp_nrof || nrof <= 0) |
279 | if (nrof > tmp_nrof || nrof <= 0) |
281 | nrof = tmp_nrof; |
280 | nrof = tmp_nrof; |
282 | |
281 | |
… | |
… | |
294 | } |
293 | } |
295 | |
294 | |
296 | if (!can_split (pl, tmp, nrof)) |
295 | if (!can_split (pl, tmp, nrof)) |
297 | return; |
296 | return; |
298 | |
297 | |
299 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
298 | if (tmp->flag [FLAG_UNPAID]) |
300 | { |
299 | { |
301 | tmp->flag.reset (FLAG_UNPAID); |
300 | tmp->flag.reset (FLAG_UNPAID); |
302 | new_draw_info_format (NDI_UNIQUE, 0, pl, "%s will cost you %s.", query_name (tmp), query_cost_string (tmp, pl, F_BUY | F_SHOP)); |
301 | new_draw_info_format (NDI_UNIQUE, 0, pl, "%s will cost you %s.", query_name (tmp), query_cost_string (tmp, pl, F_BUY | F_SHOP)); |
303 | tmp->flag.set (FLAG_UNPAID); |
302 | tmp->flag.set (FLAG_UNPAID); |
304 | } |
303 | } |
… | |
… | |
367 | goto leave; |
366 | goto leave; |
368 | } |
367 | } |
369 | else |
368 | else |
370 | { /* non container pickup */ |
369 | { /* non container pickup */ |
371 | for (alt = op->inv; alt; alt = alt->below) |
370 | for (alt = op->inv; alt; alt = alt->below) |
372 | if (alt->type == CONTAINER && QUERY_FLAG (alt, FLAG_APPLIED) && |
371 | if (alt->type == CONTAINER && alt->flag [FLAG_APPLIED] && |
373 | alt->race && alt->race == tmp->race && sack_can_hold (NULL, alt, tmp, count)) |
372 | alt->race && alt->race == tmp->race && sack_can_hold (NULL, alt, tmp, count)) |
374 | break; /* perfect match */ |
373 | break; /* perfect match */ |
375 | |
374 | |
376 | if (!alt) |
375 | if (!alt) |
377 | for (alt = op->inv; alt; alt = alt->below) |
376 | for (alt = op->inv; alt; alt = alt->below) |
378 | if (alt->type == CONTAINER && QUERY_FLAG (alt, FLAG_APPLIED) && sack_can_hold (NULL, alt, tmp, count)) |
377 | if (alt->type == CONTAINER && alt->flag [FLAG_APPLIED] && sack_can_hold (NULL, alt, tmp, count)) |
379 | break; /* General container comes next */ |
378 | break; /* General container comes next */ |
380 | |
379 | |
381 | if (!alt) |
380 | if (!alt) |
382 | alt = op; /* No free containers */ |
381 | alt = op; /* No free containers */ |
383 | } |
382 | } |
… | |
… | |
393 | #ifdef PICKUP_DEBUG |
392 | #ifdef PICKUP_DEBUG |
394 | LOG (llevDebug, "Pick_up(): %s picks %s (%d) and inserts it %s.\n", op->name, tmp->name, op->contr->count, alt->name); |
393 | LOG (llevDebug, "Pick_up(): %s picks %s (%d) and inserts it %s.\n", op->name, tmp->name, op->contr->count, alt->name); |
395 | #endif |
394 | #endif |
396 | |
395 | |
397 | /* startequip items are not allowed to be put into containers: */ |
396 | /* startequip items are not allowed to be put into containers: */ |
398 | if (op->type == PLAYER && alt->type == CONTAINER && QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
397 | if (op->type == PLAYER && alt->type == CONTAINER && tmp->flag [FLAG_STARTEQUIP]) |
399 | { |
398 | { |
400 | new_draw_info (NDI_UNIQUE, 0, op, "This object cannot be put into containers!"); |
399 | new_draw_info (NDI_UNIQUE, 0, op, "This object cannot be put into containers!"); |
401 | goto leave; |
400 | goto leave; |
402 | } |
401 | } |
403 | |
402 | |
… | |
… | |
511 | * so this function isn't named very good anymore. |
510 | * so this function isn't named very good anymore. |
512 | */ |
511 | */ |
513 | void |
512 | void |
514 | put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) |
513 | put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) |
515 | { |
514 | { |
516 | object *tmp2, *sack2; |
515 | object *tmp2; |
517 | char buf[MAX_BUF]; |
516 | char buf[MAX_BUF]; |
518 | |
517 | |
519 | if (sack == tmp) |
518 | if (sack == tmp) |
520 | return; /* Can't put an object in itself */ |
519 | return; /* Can't put an object in itself */ |
521 | |
520 | |
522 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP)) |
521 | if (tmp->flag [FLAG_STARTEQUIP] || tmp->flag [FLAG_NO_DROP]) |
523 | { |
522 | { |
524 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cannot put the %s in the %s.", query_name (tmp), query_name (sack)); |
523 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cannot put the %s in the %s.", query_name (tmp), query_name (sack)); |
525 | return; |
524 | return; |
526 | } |
525 | } |
527 | |
526 | |
… | |
… | |
529 | { |
528 | { |
530 | /* Eneq(@csd.uu.se): If the object to be dropped is a container |
529 | /* Eneq(@csd.uu.se): If the object to be dropped is a container |
531 | * we instead move the contents of that container into the active |
530 | * we instead move the contents of that container into the active |
532 | * container, this is only done if the object has something in it. |
531 | * container, this is only done if the object has something in it. |
533 | */ |
532 | */ |
534 | sack2 = tmp; |
|
|
535 | new_draw_info_format (NDI_UNIQUE, 0, op, "You move the items from %s into %s.", query_name (tmp), query_name (sack)); |
533 | new_draw_info_format (NDI_UNIQUE, 0, op, "You move the items from %s into %s.", query_name (tmp), query_name (sack)); |
536 | |
534 | |
537 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
535 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
538 | { |
536 | { |
539 | tmp = tmp2->below; |
537 | tmp = tmp2->below; |
… | |
… | |
555 | * already checked this. |
553 | * already checked this. |
556 | */ |
554 | */ |
557 | if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp, (nrof ? nrof : tmp->nrof))) |
555 | if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp, (nrof ? nrof : tmp->nrof))) |
558 | return; |
556 | return; |
559 | |
557 | |
560 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
558 | if (tmp->flag [FLAG_APPLIED]) |
561 | if (!op->apply (tmp, AP_UNAPPLY | AP_NO_MERGE)) |
559 | if (!op->apply (tmp, AP_UNAPPLY | AP_NO_MERGE)) |
562 | return; |
560 | return; |
563 | |
561 | |
564 | /* we want to put some portion of the item into the container */ |
562 | /* we want to put some portion of the item into the container */ |
565 | if (!can_split (op, tmp, nrof)) |
563 | if (!can_split (op, tmp, nrof)) |
… | |
… | |
586 | return; |
584 | return; |
587 | |
585 | |
588 | if (obj->destroyed () || obj->is_inserted ()) |
586 | if (obj->destroyed () || obj->is_inserted ()) |
589 | return; |
587 | return; |
590 | |
588 | |
591 | if (QUERY_FLAG (obj, FLAG_STARTEQUIP)) |
589 | if (obj->flag [FLAG_STARTEQUIP]) |
592 | { |
590 | { |
593 | dropper->statusmsg (format ("You drop the %s.", query_name (obj))); |
591 | dropper->statusmsg (format ("You drop the %s.", query_name (obj))); |
594 | dropper->statusmsg ("The god who lent it to you retrieves it."); |
592 | dropper->statusmsg ("The god who lent it to you retrieves it."); |
595 | |
593 | |
596 | obj->destroy (); |
594 | obj->destroy (); |
… | |
… | |
605 | return; |
603 | return; |
606 | |
604 | |
607 | if (obj->destroyed () || obj->is_inserted ()) |
605 | if (obj->destroyed () || obj->is_inserted ()) |
608 | return; |
606 | return; |
609 | |
607 | |
610 | if (dropper->is_in_shop () && !QUERY_FLAG (obj, FLAG_UNPAID) && obj->type != MONEY) |
608 | if (dropper->is_in_shop () && !obj->flag [FLAG_UNPAID] && obj->type != MONEY) |
611 | if (!sell_item (obj, dropper)) |
609 | if (!sell_item (obj, dropper)) |
612 | return; |
610 | return; |
613 | |
611 | |
614 | if (!obj->can_drop_at (dropper->map, dropper->x, dropper->y, dropper)) |
612 | if (!obj->can_drop_at (dropper->map, dropper->x, dropper->y, dropper)) |
615 | return; |
613 | return; |
… | |
… | |
631 | * This is used when dropping objects onto the floor. |
629 | * This is used when dropping objects onto the floor. |
632 | */ |
630 | */ |
633 | void |
631 | void |
634 | drop_object (object *op, object *tmp, uint32 nrof) |
632 | drop_object (object *op, object *tmp, uint32 nrof) |
635 | { |
633 | { |
636 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
634 | if (tmp->flag [FLAG_NO_DROP]) |
637 | return; |
635 | return; |
638 | |
636 | |
639 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
637 | if (tmp->flag [FLAG_APPLIED]) |
640 | if (!op->apply (tmp, AP_UNAPPLY | AP_NO_MERGE)) |
638 | if (!op->apply (tmp, AP_UNAPPLY | AP_NO_MERGE)) |
641 | return; /* can't unapply it */ |
639 | return; /* can't unapply it */ |
642 | |
640 | |
643 | /* We are only dropping some of the items. We split the current object |
641 | /* We are only dropping some of the items. We split the current object |
644 | * off |
642 | * off |
… | |
… | |
683 | { |
681 | { |
684 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); |
682 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); |
685 | return; |
683 | return; |
686 | } |
684 | } |
687 | |
685 | |
688 | if (QUERY_FLAG (tmp, FLAG_INV_LOCKED)) |
686 | if (tmp->flag [FLAG_INV_LOCKED]) |
689 | { |
687 | { |
690 | new_draw_info (NDI_UNIQUE, 0, op, "This item is locked"); |
688 | new_draw_info (NDI_UNIQUE, 0, op, "This item is locked"); |
691 | return; |
689 | return; |
692 | } |
690 | } |
693 | |
691 | |
694 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
692 | if (tmp->flag [FLAG_NO_DROP]) |
695 | { |
693 | { |
696 | #if 0 |
694 | #if 0 |
697 | /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */ |
695 | /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */ |
698 | new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped."); |
696 | new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped."); |
699 | #endif |
697 | #endif |
… | |
… | |
756 | nextinv = curinv->below; |
754 | nextinv = curinv->below; |
757 | |
755 | |
758 | while (nextinv && nextinv->type == MONEY) |
756 | while (nextinv && nextinv->type == MONEY) |
759 | nextinv = nextinv->below; |
757 | nextinv = nextinv->below; |
760 | |
758 | |
761 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) |
759 | if (!curinv->flag [FLAG_INV_LOCKED] |
|
|
760 | && !curinv->invisible |
762 | && curinv->type != MONEY |
761 | && curinv->type != MONEY |
763 | && curinv->type != FOOD |
762 | && curinv->type != FOOD |
764 | && curinv->type != KEY |
763 | && curinv->type != KEY |
765 | && curinv->type != SPECIAL_KEY |
764 | && curinv->type != SPECIAL_KEY |
766 | && curinv->type != GEM |
765 | && curinv->type != GEM |
767 | && !curinv->invisible |
766 | && curinv->type != CONTAINER) |
768 | && (curinv->type != CONTAINER || op->container_ () != curinv)) |
|
|
769 | { |
767 | { |
770 | drop (op, curinv); |
768 | drop (op, curinv); |
771 | if (--cnt <= 0) break; |
769 | if (--cnt <= 0) break; |
772 | } |
770 | } |
773 | |
771 | |
… | |
… | |
781 | nextinv = curinv->below; |
779 | nextinv = curinv->below; |
782 | |
780 | |
783 | while (nextinv && nextinv->type == MONEY) |
781 | while (nextinv && nextinv->type == MONEY) |
784 | nextinv = nextinv->below; |
782 | nextinv = nextinv->below; |
785 | |
783 | |
786 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW))) |
784 | if (!curinv->flag [FLAG_INV_LOCKED] && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW))) |
787 | { |
785 | { |
788 | drop (op, curinv); |
786 | drop (op, curinv); |
789 | if (--cnt <= 0) break; |
787 | if (--cnt <= 0) break; |
790 | } |
788 | } |
791 | |
789 | |
… | |
… | |
799 | nextinv = curinv->below; |
797 | nextinv = curinv->below; |
800 | |
798 | |
801 | while (nextinv && nextinv->type == MONEY) |
799 | while (nextinv && nextinv->type == MONEY) |
802 | nextinv = nextinv->below; |
800 | nextinv = nextinv->below; |
803 | |
801 | |
804 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET)) |
802 | if (!curinv->flag [FLAG_INV_LOCKED] && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET)) |
805 | { |
803 | { |
806 | drop (op, curinv); |
804 | drop (op, curinv); |
807 | if (--cnt <= 0) break; |
805 | if (--cnt <= 0) break; |
808 | } |
806 | } |
809 | |
807 | |
… | |
… | |
817 | nextinv = curinv->below; |
815 | nextinv = curinv->below; |
818 | |
816 | |
819 | while (nextinv && nextinv->type == MONEY) |
817 | while (nextinv && nextinv->type == MONEY) |
820 | nextinv = nextinv->below; |
818 | nextinv = nextinv->below; |
821 | |
819 | |
822 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && !QUERY_FLAG (curinv, FLAG_APPLIED)) |
820 | if (!curinv->flag [FLAG_INV_LOCKED] && !curinv->flag [FLAG_APPLIED]) |
823 | { |
821 | { |
824 | switch (curinv->type) |
822 | switch (curinv->type) |
825 | { |
823 | { |
826 | case HORN: |
824 | case HORN: |
827 | case BOOK: |
825 | case BOOK: |
… | |
… | |
891 | */ |
889 | */ |
892 | int |
890 | int |
893 | command_drop (object *op, char *params) |
891 | command_drop (object *op, char *params) |
894 | { |
892 | { |
895 | object *tmp, *next; |
893 | object *tmp, *next; |
896 | int did_one = 0; |
|
|
897 | |
894 | |
898 | if (!params) |
895 | if (!params) |
899 | { |
896 | { |
900 | new_draw_info (NDI_UNIQUE, 0, op, "Drop what?"); |
897 | new_draw_info (NDI_UNIQUE, 0, op, "Drop what?"); |
901 | return 0; |
898 | return 0; |
… | |
… | |
905 | vector<object *> matched_objs; |
902 | vector<object *> matched_objs; |
906 | |
903 | |
907 | for (tmp = op->inv; tmp; tmp = next) |
904 | for (tmp = op->inv; tmp; tmp = next) |
908 | { |
905 | { |
909 | next = tmp->below; |
906 | next = tmp->below; |
910 | if (QUERY_FLAG (tmp, FLAG_NO_DROP) || tmp->invisible) |
907 | if (tmp->flag [FLAG_NO_DROP] || tmp->invisible) |
911 | continue; |
908 | continue; |
912 | |
909 | |
913 | if (item_matched_string (op, tmp, params)) |
910 | if (item_matched_string (op, tmp, params)) |
914 | matched_objs.push_back (tmp); |
911 | matched_objs.push_back (tmp); |
915 | } |
912 | } |
… | |
… | |
950 | } |
947 | } |
951 | |
948 | |
952 | return 0; |
949 | return 0; |
953 | } |
950 | } |
954 | |
951 | |
955 | /* op should be a player. |
|
|
956 | * we return the object the player has marked with the 'mark' command |
|
|
957 | * below. If no match is found (or object has changed), we return |
|
|
958 | * NULL. We leave it up to the calling function to print messages if |
|
|
959 | * nothing is found. |
|
|
960 | */ |
|
|
961 | object * |
|
|
962 | find_marked_object (object *op) |
|
|
963 | { |
|
|
964 | object *tmp; |
|
|
965 | |
|
|
966 | if (!op || !op->contr) |
|
|
967 | return NULL; |
|
|
968 | |
|
|
969 | if (!op->contr->mark) |
|
|
970 | { |
|
|
971 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
|
|
972 | return 0; |
|
|
973 | } |
|
|
974 | |
|
|
975 | /* This may seem like overkill, but we need to make sure that they |
|
|
976 | * player hasn't dropped the item. We use count on the off chance that |
|
|
977 | * an item got reincarnated at some point. |
|
|
978 | */ |
|
|
979 | for (tmp = op->inv; tmp; tmp = tmp->below) |
|
|
980 | { |
|
|
981 | if (tmp->invisible) |
|
|
982 | continue; |
|
|
983 | |
|
|
984 | if (tmp == op->contr->mark) |
|
|
985 | { |
|
|
986 | if (!tmp->destroyed ()) |
|
|
987 | return tmp; |
|
|
988 | else |
|
|
989 | { |
|
|
990 | op->contr->mark = 0; |
|
|
991 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
|
|
992 | return 0; |
|
|
993 | } |
|
|
994 | } |
|
|
995 | } |
|
|
996 | |
|
|
997 | return 0; |
|
|
998 | } |
|
|
999 | |
|
|
1000 | std::string |
952 | std::string |
1001 | object::describe_monster (object *who) |
953 | object::describe_monster (object *who) |
1002 | { |
954 | { |
1003 | dynbuf_text buf (512, 512); |
955 | dynbuf_text buf (512, 512); |
1004 | |
956 | |
1005 | object *mon = head ? head : this; |
957 | object *mon = head ? head : this; |
1006 | |
958 | |
1007 | if (QUERY_FLAG (mon, FLAG_UNDEAD)) |
959 | if (mon->flag [FLAG_UNDEAD]) |
1008 | buf << "It is an undead force.\r"; |
960 | buf << "It is an undead force.\r"; |
1009 | |
961 | |
1010 | if (mon->level > who->level) |
962 | if (mon->level > who->level) |
1011 | buf << "It is likely more powerful than you.\r"; |
963 | buf << "It is likely more powerful than you.\r"; |
1012 | else if (mon->level < who->level) |
964 | else if (mon->level < who->level) |
… | |
… | |
1069 | case SHIELD: |
1021 | case SHIELD: |
1070 | case BOOTS: |
1022 | case BOOTS: |
1071 | case GLOVES: |
1023 | case GLOVES: |
1072 | case AMULET: |
1024 | case AMULET: |
1073 | case GIRDLE: |
1025 | case GIRDLE: |
|
|
1026 | case RANGED: |
1074 | case BOW: |
1027 | case BOW: |
1075 | case ARROW: |
1028 | case ARROW: |
1076 | case CLOAK: |
1029 | case CLOAK: |
1077 | case FOOD: |
1030 | case FOOD: |
1078 | case DRINK: |
1031 | case DRINK: |
… | |
… | |
1253 | */ |
1206 | */ |
1254 | if (params == NULL) |
1207 | if (params == NULL) |
1255 | { |
1208 | { |
1256 | for (object *item = op->inv; item; item = item->below) |
1209 | for (object *item = op->inv; item; item = item->below) |
1257 | { |
1210 | { |
1258 | CLEAR_FLAG(item, FLAG_INV_LOCKED); |
1211 | item->clr_flag (FLAG_INV_LOCKED); |
1259 | //d// new_draw_info (NDI_UNIQUE, 0, op, "unlocked items with null param."); |
1212 | //d// new_draw_info (NDI_UNIQUE, 0, op, "unlocked items with null param."); |
1260 | esrv_update_item (UPD_FLAGS, op, item); |
1213 | esrv_update_item (UPD_FLAGS, op, item); |
1261 | } |
1214 | } |
1262 | return 0; |
1215 | return 0; |
1263 | } |
1216 | } |
… | |
… | |
1266 | * unlock what matches. i.e. unlock material, should unlock all the materials |
1219 | * unlock what matches. i.e. unlock material, should unlock all the materials |
1267 | */ |
1220 | */ |
1268 | for (object *item = op->inv; item; item = item->below) |
1221 | for (object *item = op->inv; item; item = item->below) |
1269 | if (item->name.contains (params)) |
1222 | if (item->name.contains (params)) |
1270 | { |
1223 | { |
1271 | CLEAR_FLAG (item, FLAG_INV_LOCKED); |
1224 | item->clr_flag (FLAG_INV_LOCKED); |
1272 | //d// new_draw_info (NDI_UNIQUE, 0, op, "unlocked items with a param."); |
1225 | //d// new_draw_info (NDI_UNIQUE, 0, op, "unlocked items with a param."); |
1273 | esrv_update_item (UPD_FLAGS, op, item); |
1226 | esrv_update_item (UPD_FLAGS, op, item); |
1274 | } |
1227 | } |
1275 | |
1228 | |
1276 | return 0; |
1229 | return 0; |
… | |
… | |
1283 | */ |
1236 | */ |
1284 | if (params == NULL) |
1237 | if (params == NULL) |
1285 | { |
1238 | { |
1286 | for (object *item = op->inv; item; item = item->below) |
1239 | for (object *item = op->inv; item; item = item->below) |
1287 | { |
1240 | { |
1288 | SET_FLAG (item, FLAG_INV_LOCKED); |
1241 | item->set_flag (FLAG_INV_LOCKED); |
1289 | //d// new_draw_info (NDI_UNIQUE, 0, op, "locked items with null param."); |
1242 | //d// new_draw_info (NDI_UNIQUE, 0, op, "locked items with null param."); |
1290 | esrv_update_item (UPD_FLAGS, op, item); |
1243 | esrv_update_item (UPD_FLAGS, op, item); |
1291 | } |
1244 | } |
1292 | return 0; |
1245 | return 0; |
1293 | } |
1246 | } |
… | |
… | |
1296 | * i.e. lock material, should lock all the materials |
1249 | * i.e. lock material, should lock all the materials |
1297 | */ |
1250 | */ |
1298 | for (object *item = op->inv; item; item = item->below) |
1251 | for (object *item = op->inv; item; item = item->below) |
1299 | if (item->name.contains (params)) |
1252 | if (item->name.contains (params)) |
1300 | { |
1253 | { |
1301 | SET_FLAG (item, FLAG_INV_LOCKED); |
1254 | item->set_flag (FLAG_INV_LOCKED); |
1302 | //d// new_draw_info (NDI_UNIQUE, 0, op, "locked items with param."); |
1255 | //d// new_draw_info (NDI_UNIQUE, 0, op, "locked items with param."); |
1303 | esrv_update_item (UPD_FLAGS, op, item); |
1256 | esrv_update_item (UPD_FLAGS, op, item); |
1304 | } |
1257 | } |
1305 | |
1258 | |
1306 | return 0; |
1259 | return 0; |
… | |
… | |
1313 | int |
1266 | int |
1314 | command_mark (object *op, char *params) |
1267 | command_mark (object *op, char *params) |
1315 | { |
1268 | { |
1316 | if (!params) |
1269 | if (!params) |
1317 | { |
1270 | { |
1318 | if (object *mark = find_marked_object (op)) |
1271 | if (object *mark = op->mark ()) |
1319 | op->statusmsg (format ("%s is marked.", query_name (mark))); |
1272 | op->statusmsg (format ("%s is marked.", query_name (mark))); |
1320 | else |
1273 | else |
1321 | op->failmsg ("You have no marked object."); |
1274 | op->failmsg ("You have no marked object."); |
1322 | } |
1275 | } |
1323 | else |
1276 | else |