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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 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 |
… | |
… | |
94 | } |
94 | } |
95 | |
95 | |
96 | static bool |
96 | static bool |
97 | can_split (object *pl, object *&op, sint32 nrof) |
97 | can_split (object *pl, object *&op, sint32 nrof) |
98 | { |
98 | { |
99 | if (object *tmp = op->split (nrof)) |
99 | if (object *tmp = op->split (nrof ? nrof : op->number_of ())) |
100 | { |
100 | { |
101 | op = tmp; |
101 | op = tmp; |
102 | return true; |
102 | return true; |
103 | } |
103 | } |
104 | else |
104 | else |
… | |
… | |
284 | * (sack, luggage, etc), tmp->env->env then points to the player (nested |
284 | * (sack, luggage, etc), tmp->env->env then points to the player (nested |
285 | * containers not allowed as of now) |
285 | * containers not allowed as of now) |
286 | */ |
286 | */ |
287 | if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && tmp->in_player () != pl) |
287 | if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && tmp->in_player () != pl) |
288 | { |
288 | { |
289 | new_draw_info (NDI_UNIQUE, 0, pl, "You are levitating, you can't reach the ground!"); |
289 | pl->failmsg ("You are levitating, you can't reach the ground! " |
|
|
290 | "H<You have to stop levitating first, if you can, either by using your levitation skill, " |
|
|
291 | "or waiting till the levitation effect wears off.>"); |
290 | return; |
292 | return; |
291 | } |
293 | } |
292 | |
294 | |
293 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
295 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
294 | return; |
296 | return; |
… | |
… | |
311 | |
313 | |
312 | if (!can_split (pl, tmp, nrof)) |
314 | if (!can_split (pl, tmp, nrof)) |
313 | return; |
315 | return; |
314 | |
316 | |
315 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
317 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
|
|
318 | { |
|
|
319 | tmp->flag.reset (FLAG_UNPAID); |
316 | 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)); |
320 | 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)); |
|
|
321 | tmp->flag.set (FLAG_UNPAID); |
|
|
322 | } |
317 | else |
323 | else |
318 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You pick up the %s.", query_name (tmp)); |
324 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You pick up the %s.", query_name (tmp)); |
319 | |
325 | |
320 | tmp = insert_ob_in_ob (tmp, op); |
326 | op->insert (tmp); |
321 | |
|
|
322 | /* All the stuff below deals with client/server code, and is only |
|
|
323 | * usable by players |
|
|
324 | */ |
|
|
325 | if (pl->contr) |
|
|
326 | { |
|
|
327 | esrv_send_item (pl, tmp); |
|
|
328 | |
|
|
329 | /* These are needed to update the weight for the container we |
|
|
330 | * are putting the object in. |
|
|
331 | */ |
|
|
332 | if (op != pl) |
|
|
333 | { |
|
|
334 | esrv_update_item (UPD_WEIGHT, pl, op); |
|
|
335 | esrv_send_item (pl, pl); |
|
|
336 | } |
|
|
337 | |
|
|
338 | /* Update the container the object was in */ |
|
|
339 | if (env && env != pl && env != op) |
|
|
340 | esrv_update_item (UPD_WEIGHT, pl, env); |
|
|
341 | } |
|
|
342 | } |
327 | } |
343 | |
328 | |
344 | /* modified slightly to allow monsters use this -b.t. 5-31-95 */ |
329 | /* modified slightly to allow monsters use this -b.t. 5-31-95 */ |
345 | void |
330 | void |
346 | pick_up (object *op, object *alt) |
331 | pick_up (object *op, object *alt) |
… | |
… | |
499 | * but that probably will make it more difficult to read, and |
484 | * but that probably will make it more difficult to read, and |
500 | * not make it any more efficient |
485 | * not make it any more efficient |
501 | */ |
486 | */ |
502 | if (params && item_matched_string (op, tmp, params)) |
487 | if (params && item_matched_string (op, tmp, params)) |
503 | { |
488 | { |
|
|
489 | if (--cnt < 0) break; |
504 | pick_up (op, tmp); |
490 | pick_up (op, tmp); |
505 | if (--cnt <= 0) break; |
|
|
506 | } |
491 | } |
507 | else if (can_pick (op, tmp) && !params) |
492 | else if (can_pick (op, tmp) && !params) |
508 | { |
493 | { |
|
|
494 | if (--cnt < 0) break; |
509 | pick_up (op, tmp); |
495 | pick_up (op, tmp); |
510 | break; |
496 | break; |
511 | } |
497 | } |
512 | |
498 | |
513 | tmp = next; |
499 | tmp = next; |
514 | } |
500 | } |
515 | |
501 | |
516 | if (cnt <= 0) |
502 | if (cnt < 0) |
517 | { |
503 | { |
518 | op->failmsg ("Couldn't pick up so many items at once."); |
504 | op->failmsg ("Couldn't pick up so many items at once."); |
519 | return 0; |
505 | return 0; |
520 | } |
506 | } |
521 | |
507 | |
… | |
… | |
569 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
555 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
570 | { |
556 | { |
571 | tmp = tmp2->below; |
557 | tmp = tmp2->below; |
572 | |
558 | |
573 | if ((sack->type == CONTAINER && sack_can_hold (op, op->container, tmp2, tmp2->nrof))) |
559 | if ((sack->type == CONTAINER && sack_can_hold (op, op->container, tmp2, tmp2->nrof))) |
574 | { |
|
|
575 | put_object_in_sack (op, sack, tmp2, 0); |
560 | put_object_in_sack (op, sack, tmp2, 0); |
576 | } |
|
|
577 | else |
561 | else |
578 | { |
562 | { |
579 | sprintf (buf, "Your %s fills up.", query_name (sack)); |
563 | sprintf (buf, "Your %s fills up.", query_name (sack)); |
580 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
564 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
581 | break; |
565 | break; |
582 | } |
566 | } |
583 | } |
567 | } |
584 | |
568 | |
585 | esrv_update_item (UPD_WEIGHT, op, sack2); |
|
|
586 | return; |
569 | return; |
587 | } |
570 | } |
588 | |
571 | |
589 | /* Don't worry about this for containers - our caller should have |
572 | /* Don't worry about this for containers - our caller should have |
590 | * already checked this. |
573 | * already checked this. |
… | |
… | |
595 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
578 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
596 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
579 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
597 | return; |
580 | return; |
598 | |
581 | |
599 | /* we want to put some portion of the item into the container */ |
582 | /* we want to put some portion of the item into the container */ |
600 | if (nrof && tmp->nrof != nrof) |
|
|
601 | { |
|
|
602 | if (!can_split (op, tmp, nrof)) |
583 | if (!can_split (op, tmp, nrof)) |
603 | return; |
584 | return; |
604 | } |
|
|
605 | else |
|
|
606 | tmp->remove (); |
|
|
607 | |
585 | |
608 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
586 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
609 | tmp2 = insert_ob_in_ob (tmp, sack); |
587 | sack->insert (tmp); |
610 | |
|
|
611 | // elmex: 2007-11-26: removed update_stats and replaced |
|
|
612 | // it by update_after_inventory_change () in the caller |
|
|
613 | // of this function |
|
|
614 | |
|
|
615 | /* If an object merged (and thus, different object), we need to |
|
|
616 | * delete the original. |
|
|
617 | */ |
|
|
618 | if (tmp2 != tmp) |
|
|
619 | esrv_del_item (op->contr, tmp->count); |
|
|
620 | |
|
|
621 | esrv_send_item (op, tmp2); |
|
|
622 | |
|
|
623 | /* update the sacks weight */ |
|
|
624 | esrv_update_item (UPD_WEIGHT, op, sack); |
|
|
625 | } |
588 | } |
626 | |
589 | |
627 | /* |
590 | /* |
628 | * This function was part of drop, now is own function. |
591 | * This function was part of drop, now is own function. |
629 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |
592 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |
… | |
… | |
631 | * This is used when dropping objects onto the floor. |
594 | * This is used when dropping objects onto the floor. |
632 | */ |
595 | */ |
633 | void |
596 | void |
634 | drop_object (object *op, object *tmp, uint32 nrof) |
597 | drop_object (object *op, object *tmp, uint32 nrof) |
635 | { |
598 | { |
636 | object *floor; |
|
|
637 | |
|
|
638 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
599 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
639 | return; |
600 | return; |
640 | |
601 | |
641 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
602 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
642 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
603 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
… | |
… | |
645 | //fprintf (stderr, "ui, on space is %ld\n", op->ms ().volume ());//D |
606 | //fprintf (stderr, "ui, on space is %ld\n", op->ms ().volume ());//D |
646 | |
607 | |
647 | /* We are only dropping some of the items. We split the current object |
608 | /* We are only dropping some of the items. We split the current object |
648 | * off |
609 | * off |
649 | */ |
610 | */ |
650 | if (nrof && tmp->nrof != nrof) |
|
|
651 | { |
|
|
652 | if (!can_split (op, tmp, nrof)) |
611 | if (!can_split (op, tmp, nrof)) |
653 | return; |
612 | return; |
654 | } |
|
|
655 | else |
|
|
656 | tmp->remove (); |
|
|
657 | |
613 | |
658 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
614 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
659 | return; |
615 | return; |
660 | |
616 | |
661 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
617 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
662 | { |
618 | { |
663 | op->statusmsg (format ("You drop the %s.", query_name (tmp))); |
619 | op->statusmsg (format ("You drop the %s.", query_name (tmp))); |
664 | op->statusmsg ("The gods who lent it to you retrieves it."); |
620 | op->statusmsg ("The god who lent it to you retrieves it."); |
665 | |
|
|
666 | if (op->type == PLAYER) |
|
|
667 | esrv_del_item (op->contr, tmp->count); |
|
|
668 | |
621 | |
669 | tmp->destroy (); |
622 | tmp->destroy (); |
670 | op->update_stats (); |
623 | op->update_stats (); |
671 | return; |
624 | return; |
672 | } |
625 | } |
673 | |
|
|
674 | if (op->type == PLAYER) |
|
|
675 | esrv_del_item (op->contr, tmp->count); |
|
|
676 | |
626 | |
677 | /* Call this before we update the various windows/players. At least |
627 | /* Call this before we update the various windows/players. At least |
678 | * that we, we know the weight is correct. |
628 | * that we, we know the weight is correct. |
679 | */ |
629 | */ |
680 | // 2007-11-26: moved op->update_stats away and calling it later after |
630 | // 2007-11-26: moved op->update_stats away and calling it later after |
681 | // all items of a drop command have been processed. |
631 | // all items of a drop command have been processed. |
682 | |
632 | |
683 | for (floor = GET_MAP_OB (op->map, op->x, op->y); floor; floor = floor->above) |
633 | for (object *floor = GET_MAP_OB (op->map, op->x, op->y); floor; floor = floor->above) |
684 | if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op))) |
634 | if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op))) |
685 | return; |
635 | return; |
686 | |
636 | |
687 | if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) |
637 | if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) |
|
|
638 | { |
688 | sell_item (tmp, op); |
639 | if (!sell_item (tmp, op)) |
|
|
640 | { |
|
|
641 | // if we can't sell it we don't drop it, so give it back to the seller |
|
|
642 | op->insert (tmp); |
|
|
643 | return; |
|
|
644 | } |
|
|
645 | } |
689 | |
646 | |
690 | tmp->x = op->x; |
647 | tmp->x = op->x; |
691 | tmp->y = op->y; |
648 | tmp->y = op->y; |
692 | |
649 | |
693 | insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); |
650 | insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); |
694 | } |
|
|
695 | |
|
|
696 | void update_after_inventory_change (object *op) |
|
|
697 | { |
|
|
698 | /* Call this before we update the various windows/players. At least |
|
|
699 | * that we, we know the weight is correct. |
|
|
700 | */ |
|
|
701 | op->update_stats (); |
|
|
702 | |
|
|
703 | // elmex: kept this for now, i have no idea what happens when i remove it: |
|
|
704 | if (op->type == PLAYER) |
|
|
705 | { |
|
|
706 | /* Need to update the weight for the player */ |
|
|
707 | esrv_send_item (op, op); |
|
|
708 | op->contr->ns->floorbox_update (); |
|
|
709 | } |
|
|
710 | } |
651 | } |
711 | |
652 | |
712 | void |
653 | void |
713 | drop (object *op, object *tmp) |
654 | drop (object *op, object *tmp) |
714 | { |
655 | { |
… | |
… | |
723 | if (tmp->env && tmp->env->type != PLAYER) |
664 | if (tmp->env && tmp->env->type != PLAYER) |
724 | { |
665 | { |
725 | /* Just toss the object - probably shouldn't be hanging |
666 | /* Just toss the object - probably shouldn't be hanging |
726 | * around anyways |
667 | * around anyways |
727 | */ |
668 | */ |
728 | tmp->remove (); |
|
|
729 | tmp->destroy (); |
669 | tmp->destroy (); |
730 | return; |
670 | return; |
731 | } |
671 | } |
732 | else |
672 | else |
733 | { |
673 | { |
734 | while (tmp != NULL && tmp->invisible) |
674 | while (tmp && tmp->invisible) |
735 | tmp = tmp->below; |
675 | tmp = tmp->below; |
736 | } |
676 | } |
737 | } |
677 | } |
738 | |
678 | |
739 | if (tmp == NULL) |
679 | if (tmp == NULL) |
740 | { |
680 | { |
741 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); |
681 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); |
742 | return; |
682 | return; |
743 | } |
683 | } |
|
|
684 | |
744 | if (QUERY_FLAG (tmp, FLAG_INV_LOCKED)) |
685 | if (QUERY_FLAG (tmp, FLAG_INV_LOCKED)) |
745 | { |
686 | { |
746 | new_draw_info (NDI_UNIQUE, 0, op, "This item is locked"); |
687 | new_draw_info (NDI_UNIQUE, 0, op, "This item is locked"); |
747 | return; |
688 | return; |
748 | } |
689 | } |
|
|
690 | |
749 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
691 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
750 | { |
692 | { |
751 | #if 0 |
693 | #if 0 |
752 | /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */ |
694 | /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */ |
753 | new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped."); |
695 | new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped."); |
… | |
… | |
777 | |
719 | |
778 | if (op->type == PLAYER) |
720 | if (op->type == PLAYER) |
779 | op->contr->count = 0; |
721 | op->contr->count = 0; |
780 | } |
722 | } |
781 | |
723 | |
782 | |
|
|
783 | |
|
|
784 | /* Command will drop all items that have not been locked */ |
724 | /* Command will drop all items that have not been locked */ |
785 | int |
725 | int |
786 | command_dropall (object *op, char *params) |
726 | command_dropall (object *op, char *params) |
787 | { |
727 | { |
788 | |
728 | |
789 | object *curinv, *nextinv; |
|
|
790 | |
|
|
791 | if (op->inv == NULL) |
729 | if (op->inv == NULL) |
792 | { |
730 | { |
793 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop!"); |
731 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop!"); |
794 | return 0; |
732 | return 0; |
795 | } |
733 | } |
796 | |
734 | |
797 | curinv = op->inv; |
735 | object *curinv = op->inv; |
|
|
736 | object *nextinv; |
798 | |
737 | |
799 | /* |
738 | /* |
800 | This is the default. Drops everything not locked or considered |
739 | This is the default. Drops everything not locked or considered |
801 | not something that should be dropped. |
740 | not something that should be dropped. |
802 | */ |
741 | */ |
… | |
… | |
806 | in a shop. --Tero.Pelander@utu.fi |
745 | in a shop. --Tero.Pelander@utu.fi |
807 | */ |
746 | */ |
808 | |
747 | |
809 | int cnt = MAX_ITEM_PER_DROP; |
748 | int cnt = MAX_ITEM_PER_DROP; |
810 | |
749 | |
811 | if (params == NULL) |
750 | if (!params) |
812 | { |
751 | { |
813 | while (curinv != NULL) |
752 | while (curinv) |
814 | { |
753 | { |
815 | nextinv = curinv->below; |
754 | nextinv = curinv->below; |
|
|
755 | |
816 | while (nextinv && nextinv->type == MONEY) |
756 | while (nextinv && nextinv->type == MONEY) |
817 | nextinv = nextinv->below; |
757 | nextinv = nextinv->below; |
|
|
758 | |
818 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && curinv->type != MONEY && |
759 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && curinv->type != MONEY && |
819 | curinv->type != FOOD && curinv->type != KEY && |
760 | curinv->type != FOOD && curinv->type != KEY && |
820 | curinv->type != SPECIAL_KEY && curinv->type != GEM && |
761 | curinv->type != SPECIAL_KEY && curinv->type != GEM && |
821 | !curinv->invisible && (curinv->type != CONTAINER || op->container != curinv)) |
762 | !curinv->invisible && (curinv->type != CONTAINER || op->container != curinv)) |
822 | { |
763 | { |
823 | drop (op, curinv); |
764 | drop (op, curinv); |
824 | if (--cnt <= 0) break; |
765 | if (--cnt <= 0) break; |
825 | } |
766 | } |
|
|
767 | |
826 | curinv = nextinv; |
768 | curinv = nextinv; |
827 | } |
769 | } |
828 | } |
770 | } |
829 | |
|
|
830 | else if (strcmp (params, "weapons") == 0) |
771 | else if (strcmp (params, "weapons") == 0) |
831 | { |
772 | { |
832 | while (curinv != NULL) |
773 | while (curinv) |
833 | { |
774 | { |
834 | nextinv = curinv->below; |
775 | nextinv = curinv->below; |
|
|
776 | |
835 | while (nextinv && nextinv->type == MONEY) |
777 | while (nextinv && nextinv->type == MONEY) |
836 | nextinv = nextinv->below; |
778 | nextinv = nextinv->below; |
|
|
779 | |
837 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW))) |
780 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW))) |
838 | { |
781 | { |
839 | drop (op, curinv); |
782 | drop (op, curinv); |
840 | if (--cnt <= 0) break; |
783 | if (--cnt <= 0) break; |
841 | } |
784 | } |
|
|
785 | |
842 | curinv = nextinv; |
786 | curinv = nextinv; |
843 | } |
787 | } |
844 | } |
788 | } |
845 | |
|
|
846 | else if (strcmp (params, "armor") == 0 || strcmp (params, "armour") == 0) |
789 | else if (strcmp (params, "armor") == 0 || strcmp (params, "armour") == 0) |
847 | { |
790 | { |
848 | while (curinv != NULL) |
791 | while (curinv) |
849 | { |
792 | { |
850 | nextinv = curinv->below; |
793 | nextinv = curinv->below; |
|
|
794 | |
851 | while (nextinv && nextinv->type == MONEY) |
795 | while (nextinv && nextinv->type == MONEY) |
852 | nextinv = nextinv->below; |
796 | nextinv = nextinv->below; |
|
|
797 | |
853 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET)) |
798 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET)) |
854 | { |
799 | { |
855 | drop (op, curinv); |
800 | drop (op, curinv); |
856 | if (--cnt <= 0) break; |
801 | if (--cnt <= 0) break; |
857 | } |
802 | } |
|
|
803 | |
858 | curinv = nextinv; |
804 | curinv = nextinv; |
859 | } |
805 | } |
860 | } |
806 | } |
861 | |
|
|
862 | else if (strcmp (params, "misc") == 0) |
807 | else if (strcmp (params, "misc") == 0) |
863 | { |
808 | { |
864 | while (curinv != NULL) |
809 | while (curinv) |
865 | { |
810 | { |
866 | nextinv = curinv->below; |
811 | nextinv = curinv->below; |
|
|
812 | |
867 | while (nextinv && nextinv->type == MONEY) |
813 | while (nextinv && nextinv->type == MONEY) |
868 | nextinv = nextinv->below; |
814 | nextinv = nextinv->below; |
|
|
815 | |
869 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && !QUERY_FLAG (curinv, FLAG_APPLIED)) |
816 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && !QUERY_FLAG (curinv, FLAG_APPLIED)) |
870 | { |
817 | { |
871 | switch (curinv->type) |
818 | switch (curinv->type) |
872 | { |
819 | { |
873 | case HORN: |
820 | case HORN: |
… | |
… | |
891 | break; |
838 | break; |
892 | default: |
839 | default: |
893 | curinv = nextinv; |
840 | curinv = nextinv; |
894 | break; |
841 | break; |
895 | } |
842 | } |
|
|
843 | |
896 | if (--cnt <= 0) break; |
844 | if (--cnt <= 0) break; |
897 | } |
845 | } |
|
|
846 | |
898 | curinv = nextinv; |
847 | curinv = nextinv; |
899 | } |
848 | } |
900 | } |
849 | } |
901 | |
850 | |
902 | if (cnt <= 0) |
851 | if (cnt <= 0) |
903 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
852 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
904 | |
|
|
905 | update_after_inventory_change (op); |
|
|
906 | |
853 | |
907 | /* draw_look(op);*/ |
854 | /* draw_look(op);*/ |
908 | return 0; |
855 | return 0; |
909 | } |
856 | } |
910 | |
857 | |
911 | /* Object op wants to drop object(s) params. params can be a |
858 | /* Object op wants to drop object(s) params. params can be a |
912 | * comma seperated list. |
859 | * comma seperated list. |
913 | */ |
860 | */ |
914 | |
|
|
915 | int |
861 | int |
916 | command_drop (object *op, char *params) |
862 | command_drop (object *op, char *params) |
917 | { |
863 | { |
918 | object *tmp, *next; |
864 | object *tmp, *next; |
919 | int did_one = 0; |
865 | int did_one = 0; |
… | |
… | |
944 | if (!did_one) |
890 | if (!did_one) |
945 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); |
891 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); |
946 | |
892 | |
947 | if (cnt <= 0) |
893 | if (cnt <= 0) |
948 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
894 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
949 | |
|
|
950 | update_after_inventory_change (op); |
|
|
951 | } |
895 | } |
952 | |
896 | |
953 | return 0; |
897 | return 0; |
954 | } |
898 | } |
955 | |
899 | |
… | |
… | |
1030 | dynbuf_text buf (512, 512); |
974 | dynbuf_text buf (512, 512); |
1031 | |
975 | |
1032 | object *mon = head ? head : this; |
976 | object *mon = head ? head : this; |
1033 | |
977 | |
1034 | if (QUERY_FLAG (mon, FLAG_UNDEAD)) |
978 | if (QUERY_FLAG (mon, FLAG_UNDEAD)) |
1035 | buf << "It is an undead force.\n"; |
979 | buf << "It is an undead force.\r"; |
1036 | |
980 | |
1037 | if (mon->level > who->level) |
981 | if (mon->level > who->level) |
1038 | buf << "It is likely more powerful than you.\n"; |
982 | buf << "It is likely more powerful than you.\r"; |
1039 | else if (mon->level < who->level) |
983 | else if (mon->level < who->level) |
1040 | buf << "It is likely less powerful than you.\n"; |
984 | buf << "It is likely less powerful than you.\r"; |
1041 | else |
985 | else |
1042 | buf << "It is probably as powerful as you.\n"; |
986 | buf << "It is probably as powerful as you.\r"; |
1043 | |
987 | |
1044 | if (mon->attacktype & AT_ACID) |
988 | if (mon->attacktype & AT_ACID) |
1045 | buf << "You seem to smell an acrid odor.\n"; |
989 | buf << "You seem to smell an acrid odor.\r"; |
1046 | |
990 | |
1047 | /* Anyone know why this used to use the clone value instead of the |
991 | /* Anyone know why this used to use the clone value instead of the |
1048 | * maxhp field? This seems that it should give more accurate results. |
992 | * maxhp field? This seems that it should give more accurate results. |
1049 | */ |
993 | */ |
1050 | switch ((mon->stats.hp + 1) * 4 / (mon->stats.maxhp + 1)) |
994 | switch ((mon->stats.hp + 1) * 4 / (mon->stats.maxhp + 1)) |
1051 | { /* From 1-4 */ |
995 | { /* From 1-4 */ |
1052 | case 1: |
996 | case 1: |
1053 | buf << "It is in a bad shape.\n"; |
997 | buf << "It is in a bad shape.\r"; |
1054 | break; |
998 | break; |
1055 | case 2: |
999 | case 2: |
1056 | buf << "It is hurt.\n"; |
1000 | buf << "It is hurt.\r"; |
1057 | break; |
1001 | break; |
1058 | case 3: |
1002 | case 3: |
1059 | buf << "It is somewhat hurt.\n"; |
1003 | buf << "It is somewhat hurt.\r"; |
1060 | break; |
1004 | break; |
1061 | case 4: |
1005 | case 4: |
1062 | buf << "It is in excellent shape.\n"; |
1006 | buf << "It is in excellent shape.\r"; |
1063 | break; |
1007 | break; |
1064 | } |
1008 | } |
1065 | |
1009 | |
1066 | if (present_in_ob (POISONING, mon)) |
1010 | if (present_in_ob (POISONING, mon)) |
1067 | buf << "It looks very ill.\n"; |
1011 | buf << "It looks very ill.\r"; |
|
|
1012 | |
|
|
1013 | buf << '\n'; |
1068 | |
1014 | |
1069 | return buf; |
1015 | return buf; |
1070 | } |
1016 | } |
1071 | |
1017 | |
1072 | /* tmp is the object being described, pl is who is examing it. */ |
1018 | /* tmp is the object being described, pl is who is examing it. */ |
… | |
… | |
1130 | std::string |
1076 | std::string |
1131 | object::describe (object *who) |
1077 | object::describe (object *who) |
1132 | { |
1078 | { |
1133 | dynbuf_text buf (1024, 1024); |
1079 | dynbuf_text buf (1024, 1024); |
1134 | |
1080 | |
1135 | buf.printf ("That is: %s.\n", long_desc (who).c_str ()); |
1081 | buf.printf ("That is: %s.\r", long_desc (who).c_str ()); |
1136 | |
1082 | |
1137 | if (custom_name) |
1083 | if (custom_name) |
1138 | buf.printf ("You call it %s\n", &custom_name); |
1084 | buf.printf ("You call it %s.\r", &custom_name); |
1139 | |
1085 | |
1140 | switch (type) |
1086 | switch (type) |
1141 | { |
1087 | { |
1142 | case SPELLBOOK: |
1088 | case SPELLBOOK: |
1143 | if (flag [FLAG_IDENTIFIED] && inv) |
1089 | if (flag [FLAG_IDENTIFIED] && inv) |
1144 | buf.printf ("%s is a %s %s spell\n", &inv->name, get_levelnumber (inv->level), &inv->skill); |
1090 | buf.printf ("%s is a %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill); |
1145 | break; |
1091 | break; |
1146 | |
1092 | |
1147 | case BOOK: |
1093 | case BOOK: |
1148 | if (msg) |
1094 | if (msg) |
1149 | buf << "Something is written in it.\n"; |
1095 | buf << "Something is written in it.\r"; |
1150 | break; |
1096 | break; |
1151 | |
1097 | |
1152 | case CONTAINER: |
1098 | case CONTAINER: |
1153 | if (race != NULL) |
1099 | if (race) |
1154 | { |
1100 | { |
1155 | if (weight_limit && stats.Str < 100) |
1101 | if (weight_limit && stats.Str < 100) |
1156 | buf.printf ("It can hold only %s and its weight limit is %.1f kg.\n", |
1102 | buf.printf ("It can hold only %s and its weight limit is %.1f kg.\r", |
1157 | &race, weight_limit / (10.0 * (100 - stats.Str))); |
1103 | &race, weight_limit / (10.0 * (100 - stats.Str))); |
1158 | else |
1104 | else |
1159 | buf.printf ("It can hold only %s.\n", &race); |
1105 | buf.printf ("It can hold only %s.\r", &race); |
1160 | } |
1106 | } |
1161 | else if (weight_limit && stats.Str < 100) |
1107 | else if (weight_limit && stats.Str < 100) |
1162 | buf.printf ("Its weight limit is %.1f kg.\n", weight_limit / (10.0 * (100 - stats.Str))); |
1108 | buf.printf ("Its weight limit is %.1f kg.\r", weight_limit / (10.0 * (100 - stats.Str))); |
1163 | break; |
1109 | break; |
1164 | |
1110 | |
1165 | case WAND: |
1111 | case WAND: |
1166 | if (flag [FLAG_IDENTIFIED]) |
1112 | if (flag [FLAG_IDENTIFIED]) |
1167 | buf.printf ("It has %d charges left.\n", stats.food); |
1113 | buf.printf ("It has %d charges left.\r", stats.food); |
1168 | break; |
1114 | break; |
1169 | } |
1115 | } |
1170 | |
1116 | |
1171 | if (materialname && !msg) |
1117 | if (materialname && !msg) |
1172 | buf.printf ("It is made of: %s.\n", &materialname); |
1118 | buf.printf ("It is made of: %s.\r", &materialname); |
1173 | |
1119 | |
1174 | if (who) |
1120 | if (who) |
1175 | /* Where to wear this item */ |
1121 | /* Where to wear this item */ |
1176 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1122 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1177 | if (slot[i].info) |
1123 | if (slot[i].info) |
… | |
… | |
1179 | buf << (who->slot[i].info ? body_locations[i].use_name : body_locations[i].nonuse_name); |
1125 | buf << (who->slot[i].info ? body_locations[i].use_name : body_locations[i].nonuse_name); |
1180 | |
1126 | |
1181 | if (slot[i].info < -1 && who->slot[i].info) |
1127 | if (slot[i].info < -1 && who->slot[i].info) |
1182 | buf.printf ("(%d)", -slot[i].info); |
1128 | buf.printf ("(%d)", -slot[i].info); |
1183 | |
1129 | |
1184 | buf << ".\n"; |
1130 | buf << ".\r"; |
1185 | } |
1131 | } |
1186 | |
1132 | |
1187 | if (weight) |
1133 | if (weight) |
1188 | buf.printf (nrof > 1 ? "They weigh %3.3f kg.\n" : "It weighs %3.3f kg.\n", weight * (nrof ? nrof : 1) / 1000.0); |
1134 | buf.printf ("%s %3.3f kg.\r", nrof > 1 ? "They weigh" : "It weighs", weight * (nrof ? nrof : 1) / 1000.0); |
1189 | |
1135 | |
1190 | if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who) |
1136 | if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who) |
1191 | { |
1137 | { |
1192 | buf.printf ("You reckon %s worth %s.\n", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX)); |
1138 | buf.printf ("You reckon %s worth %s.\r", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX)); |
1193 | |
1139 | |
1194 | if (is_in_shop (who)) |
1140 | if (is_in_shop (who)) |
1195 | { |
1141 | { |
1196 | if (flag [FLAG_UNPAID]) |
1142 | if (flag [FLAG_UNPAID]) |
1197 | buf.printf ("%s would cost you %s.\n", nrof > 1 ? "They" : "It", query_cost_string (this, who, F_BUY | F_SHOP)); |
1143 | buf.printf ("%s would cost you %s.\r", nrof > 1 ? "They" : "It", query_cost_string (this, who, F_BUY | F_SHOP)); |
1198 | else |
1144 | else |
1199 | buf.printf ("You are offered %s for %s.\n", query_cost_string (this, who, F_SELL + F_SHOP), nrof > 1 ? "them" : "it"); |
1145 | buf.printf ("You are offered %s for %s.\r", query_cost_string (this, who, F_SELL + F_SHOP), nrof > 1 ? "them" : "it"); |
1200 | } |
1146 | } |
1201 | } |
1147 | } |
1202 | |
1148 | |
1203 | if (flag [FLAG_MONSTER]) |
1149 | if (flag [FLAG_MONSTER]) |
1204 | buf << describe_monster (who); |
1150 | buf << describe_monster (who); |
1205 | |
1151 | |
1206 | /* Is this item buildable? */ |
1152 | /* Is this item buildable? */ |
1207 | if (flag [FLAG_IS_BUILDABLE]) |
1153 | if (flag [FLAG_IS_BUILDABLE]) |
1208 | buf << "This is a buildable item.\n"; |
1154 | buf << "This is a buildable item.\r"; |
1209 | |
1155 | |
1210 | /* Does the object have a message? Don't show message for all object |
1156 | /* Does the object have a message? Don't show message for all object |
1211 | * types - especially if the first entry is a match |
1157 | * types - especially if the first entry is a match |
1212 | */ |
1158 | */ |
1213 | if (msg && type != EXIT && type != BOOK && type != CORPSE && !move_on && *msg != '@') |
1159 | if (msg && type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) |
1214 | { |
1160 | { |
1215 | /* This is just a hack so when identifying the items, we print |
1161 | /* This is just a hack so when identifying the items, we print |
1216 | * out the extra message |
1162 | * out the extra message |
1217 | */ |
1163 | */ |
1218 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
1164 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
1219 | buf << "The object has a story:\n"; |
1165 | buf << "The object has a story:\r"; |
1220 | |
1166 | |
1221 | buf << msg << '\n'; |
1167 | buf << msg << '\n'; |
1222 | } |
1168 | } |
1223 | |
1169 | |
1224 | buf << '\n'; |
1170 | buf << '\n'; |