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,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 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 |
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. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* |
25 | /* |
26 | * Object (handling) commands |
26 | * Object (handling) commands |
… | |
… | |
233 | { |
233 | { |
234 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't put the key into %s.", query_name (sack)); |
234 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't put the key into %s.", query_name (sack)); |
235 | return 0; |
235 | return 0; |
236 | } |
236 | } |
237 | |
237 | |
238 | if (sack->weight_limit && (sint32) (sack->carrying + (nrof ? nrof : 1) * |
238 | if (sack->weight_limit |
|
|
239 | && weight_t (sack->carrying |
|
|
240 | + sack->number_of () |
239 | (op->weight + (op->type == CONTAINER ? (op->carrying * op->stats.Str) : 0)) |
241 | * (op->weight + (op->type == CONTAINER ? (op->carrying * op->stats.Str) : 0)) |
240 | * (100 - sack->stats.Str) / 100) > sack->weight_limit) |
242 | * (100 - sack->stats.Str) / 100) |
|
|
243 | > sack->weight_limit) |
241 | { |
244 | { |
242 | new_draw_info_format (NDI_UNIQUE, 0, pl, "That won't fit in the %s!", query_name (sack)); |
245 | new_draw_info_format (NDI_UNIQUE, 0, pl, "That won't fit in the %s!", query_name (sack)); |
243 | return 0; |
246 | return 0; |
244 | } |
247 | } |
245 | |
248 | |
… | |
… | |
248 | } |
251 | } |
249 | |
252 | |
250 | /* Pick up commands follow */ |
253 | /* Pick up commands follow */ |
251 | |
254 | |
252 | /* pl = player (not always - monsters can use this now) |
255 | /* pl = player (not always - monsters can use this now) |
253 | * op is the object to put tmp into, |
256 | * op is the object to put tmp into, |
254 | * tmp is the object to pick up, nrof is the number to |
257 | * tmp is the object to pick up, nrof is the number to |
255 | * pick up (0 means all of them) |
258 | * pick up (0 means all of them) |
256 | */ |
259 | */ |
257 | static void |
260 | static void |
258 | pick_up_object (object *pl, object *op, object *tmp, int nrof) |
261 | pick_up_object (object *pl, object *op, object *tmp, int nrof) |
259 | { |
262 | { |
260 | object *env = tmp->env; |
|
|
261 | uint32 weight, effective_weight_limit; |
263 | weight_t weight, effective_weight_limit; |
262 | int tmp_nrof = tmp->number_of (); |
264 | int tmp_nrof = tmp->number_of (); |
263 | |
265 | |
264 | /* IF the player is flying & trying to take the item out of a container |
266 | /* 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 |
267 | * 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 |
268 | * (sack, luggage, etc), tmp->env->env then points to the player (nested |
267 | * containers not allowed as of now) |
269 | * containers not allowed as of now) |
268 | */ |
270 | */ |
269 | if ((pl->move_type & MOVE_FLYING) && !pl->flag [FLAG_WIZ] && tmp->in_player () != pl) |
271 | if ((pl->move_type & MOVE_FLYING) && !pl->flag [FLAG_WIZ] && tmp->in_player () != pl) |
270 | { |
272 | { |
271 | pl->failmsg ("You are levitating, you can't reach the ground! " |
273 | pl->failmsg ("You are levitating, you can't reach the ground! " |
… | |
… | |
501 | |
503 | |
502 | return 0; |
504 | return 0; |
503 | } |
505 | } |
504 | |
506 | |
505 | /* |
507 | /* |
506 | * This function was part of drop, now is own function. |
508 | * This function was part of drop, now is own function. |
507 | * Player 'op' tries to put object 'tmp' into sack 'sack', |
509 | * Player 'op' tries to put object 'tmp' into sack 'sack', |
508 | * if nrof is non zero, then nrof objects is tried to put into sack. |
510 | * if nrof is non zero, then nrof objects is tried to put into sack. |
509 | * |
511 | * |
510 | * Note that the 'sack' in question can now be a transport, |
512 | * Note that the 'sack' in question can now be a transport, |
511 | * so this function isn't named very good anymore. |
513 | * so this function isn't named very good anymore. |
512 | */ |
514 | */ |
513 | void |
515 | void |
514 | put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) |
516 | put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) |
515 | { |
517 | { |
516 | object *tmp2, *sack2; |
518 | object *tmp2; |
517 | char buf[MAX_BUF]; |
519 | char buf[MAX_BUF]; |
518 | |
520 | |
519 | if (sack == tmp) |
521 | if (sack == tmp) |
520 | return; /* Can't put an object in itself */ |
522 | return; /* Can't put an object in itself */ |
521 | |
523 | |
… | |
… | |
529 | { |
531 | { |
530 | /* Eneq(@csd.uu.se): If the object to be dropped is a container |
532 | /* 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 |
533 | * we instead move the contents of that container into the active |
532 | * container, this is only done if the object has something in it. |
534 | * container, this is only done if the object has something in it. |
533 | */ |
535 | */ |
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)); |
536 | new_draw_info_format (NDI_UNIQUE, 0, op, "You move the items from %s into %s.", query_name (tmp), query_name (sack)); |
536 | |
537 | |
537 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
538 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
538 | { |
539 | { |
539 | tmp = tmp2->below; |
540 | tmp = tmp2->below; |
… | |
… | |
607 | if (obj->destroyed () || obj->is_inserted ()) |
608 | if (obj->destroyed () || obj->is_inserted ()) |
608 | return; |
609 | return; |
609 | |
610 | |
610 | if (dropper->is_in_shop () && !obj->flag [FLAG_UNPAID] && obj->type != MONEY) |
611 | if (dropper->is_in_shop () && !obj->flag [FLAG_UNPAID] && obj->type != MONEY) |
611 | if (!sell_item (obj, dropper)) |
612 | if (!sell_item (obj, dropper)) |
612 | return; |
613 | return; |
613 | |
614 | |
614 | if (!obj->can_drop_at (dropper->map, dropper->x, dropper->y, dropper)) |
615 | if (!obj->can_drop_at (dropper->map, dropper->x, dropper->y, dropper)) |
615 | return; |
616 | return; |
616 | |
617 | |
617 | /* If nothing special happened with this object, the default action is to |
618 | /* If nothing special happened with this object, the default action is to |
… | |
… | |
736 | } |
737 | } |
737 | |
738 | |
738 | object *curinv = op->inv; |
739 | object *curinv = op->inv; |
739 | object *nextinv; |
740 | object *nextinv; |
740 | |
741 | |
741 | /* |
742 | /* |
742 | This is the default. Drops everything not locked or considered |
743 | This is the default. Drops everything not locked or considered |
743 | not something that should be dropped. |
744 | not something that should be dropped. |
744 | */ |
745 | */ |
745 | /* |
746 | /* |
746 | Care must be taken that the next item pointer is not to money as |
747 | Care must be taken that the next item pointer is not to money as |
… | |
… | |
891 | */ |
892 | */ |
892 | int |
893 | int |
893 | command_drop (object *op, char *params) |
894 | command_drop (object *op, char *params) |
894 | { |
895 | { |
895 | object *tmp, *next; |
896 | object *tmp, *next; |
896 | int did_one = 0; |
|
|
897 | |
897 | |
898 | if (!params) |
898 | if (!params) |
899 | { |
899 | { |
900 | new_draw_info (NDI_UNIQUE, 0, op, "Drop what?"); |
900 | new_draw_info (NDI_UNIQUE, 0, op, "Drop what?"); |
901 | return 0; |
901 | return 0; |