ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_object.C
(Generate patch)

Comparing deliantra/server/server/c_object.C (file contents):
Revision 1.120 by root, Sun Apr 11 00:34:06 2010 UTC vs.
Revision 1.133 by root, Sun Jan 29 02:47:05 2017 UTC

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,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
150 * as it includes the object to throw. 150 * as it includes the object to throw.
151 */ 151 */
152int 152int
153command_throw (object *op, char *params) 153command_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;
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 */
257static void 260static void
258pick_up_object (object *pl, object *op, object *tmp, int nrof) 261pick_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 */
513void 515void
514put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) 516put_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
757 758
758 while (nextinv && nextinv->type == MONEY) 759 while (nextinv && nextinv->type == MONEY)
759 nextinv = nextinv->below; 760 nextinv = nextinv->below;
760 761
761 if (!curinv->flag [FLAG_INV_LOCKED] 762 if (!curinv->flag [FLAG_INV_LOCKED]
763 && !curinv->invisible
762 && curinv->type != MONEY 764 && curinv->type != MONEY
763 && curinv->type != FOOD 765 && curinv->type != FOOD
764 && curinv->type != KEY 766 && curinv->type != KEY
765 && curinv->type != SPECIAL_KEY 767 && curinv->type != SPECIAL_KEY
766 && curinv->type != GEM 768 && curinv->type != GEM
767 && !curinv->invisible 769 && curinv->type != CONTAINER)
768 && (curinv->type != CONTAINER || op->container_ () != curinv))
769 { 770 {
770 drop (op, curinv); 771 drop (op, curinv);
771 if (--cnt <= 0) break; 772 if (--cnt <= 0) break;
772 } 773 }
773 774
891 */ 892 */
892int 893int
893command_drop (object *op, char *params) 894command_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;
945 945
946 if (tmp) 946 if (tmp)
947 examine (op, tmp); 947 examine (op, tmp);
948 else 948 else
949 op->contr->infobox (MSG_CHANNEL ("examine"), format ("Could not find an object that matches %s", params)); 949 op->contr->infobox (MSG_CHANNEL ("examine"), format ("Could not find an object that matches %s", params));
950 }
951
952 return 0;
953}
954
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 */
961object *
962find_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 } 950 }
996 951
997 return 0; 952 return 0;
998} 953}
999 954
1069 case SHIELD: 1024 case SHIELD:
1070 case BOOTS: 1025 case BOOTS:
1071 case GLOVES: 1026 case GLOVES:
1072 case AMULET: 1027 case AMULET:
1073 case GIRDLE: 1028 case GIRDLE:
1029 case RANGED:
1074 case BOW: 1030 case BOW:
1075 case ARROW: 1031 case ARROW:
1076 case CLOAK: 1032 case CLOAK:
1077 case FOOD: 1033 case FOOD:
1078 case DRINK: 1034 case DRINK:
1313int 1269int
1314command_mark (object *op, char *params) 1270command_mark (object *op, char *params)
1315{ 1271{
1316 if (!params) 1272 if (!params)
1317 { 1273 {
1318 if (object *mark = find_marked_object (op)) 1274 if (object *mark = op->mark ())
1319 op->statusmsg (format ("%s is marked.", query_name (mark))); 1275 op->statusmsg (format ("%s is marked.", query_name (mark)));
1320 else 1276 else
1321 op->failmsg ("You have no marked object."); 1277 op->failmsg ("You have no marked object.");
1322 } 1278 }
1323 else 1279 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines