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