… | |
… | |
267 | if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && is_player_inv (tmp) != pl) |
267 | if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && is_player_inv (tmp) != pl) |
268 | { |
268 | { |
269 | new_draw_info (NDI_UNIQUE, 0, pl, "You are levitating, you can't reach the ground!"); |
269 | new_draw_info (NDI_UNIQUE, 0, pl, "You are levitating, you can't reach the ground!"); |
270 | return; |
270 | return; |
271 | } |
271 | } |
|
|
272 | |
272 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
273 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
273 | return; |
274 | return; |
|
|
275 | |
274 | if (QUERY_FLAG (tmp, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
276 | if (QUERY_FLAG (tmp, FLAG_WAS_WIZ) && !QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
275 | { |
277 | { |
276 | new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff of smoke!"); |
278 | new_draw_info (NDI_UNIQUE, 0, pl, "The object disappears in a puff of smoke!"); |
277 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
279 | new_draw_info (NDI_UNIQUE, 0, pl, "It must have been an illusion."); |
|
|
280 | |
278 | if (pl->type == PLAYER) |
281 | if (pl->type == PLAYER) |
279 | esrv_del_item (pl->contr, tmp->count); |
282 | esrv_del_item (pl->contr, tmp->count); |
|
|
283 | |
280 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
284 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
281 | remove_ob (tmp); |
285 | remove_ob (tmp); |
|
|
286 | |
282 | free_object (tmp); |
287 | free_object (tmp); |
283 | return; |
288 | return; |
284 | } |
289 | } |
285 | |
290 | |
286 | if (nrof > tmp_nrof || nrof == 0) |
291 | if (nrof > tmp_nrof || nrof == 0) |
287 | nrof = tmp_nrof; |
292 | nrof = tmp_nrof; |
|
|
293 | |
288 | /* Figure out how much weight this object will add to the player */ |
294 | /* Figure out how much weight this object will add to the player */ |
289 | weight = tmp->weight * nrof; |
295 | weight = tmp->weight * nrof; |
290 | if (tmp->inv) |
296 | if (tmp->inv) |
291 | weight += tmp->carrying * (100 - tmp->stats.Str) / 100; |
297 | weight += tmp->carrying * (100 - tmp->stats.Str) / 100; |
|
|
298 | |
292 | if (pl->stats.Str <= MAX_STAT) |
299 | if (pl->stats.Str <= MAX_STAT) |
293 | effective_weight_limit = weight_limit[pl->stats.Str]; |
300 | effective_weight_limit = weight_limit[pl->stats.Str]; |
294 | else |
301 | else |
295 | effective_weight_limit = weight_limit[MAX_STAT]; |
302 | effective_weight_limit = weight_limit[MAX_STAT]; |
|
|
303 | |
296 | if ((pl->weight + pl->carrying + weight) > effective_weight_limit) |
304 | if ((pl->weight + pl->carrying + weight) > effective_weight_limit) |
297 | { |
305 | { |
298 | new_draw_info (0, 0, pl, "That item is too heavy for you to pick up."); |
306 | new_draw_info (0, 0, pl, "That item is too heavy for you to pick up."); |
299 | return; |
307 | return; |
300 | } |
308 | } |
|
|
309 | |
301 | if (settings.real_wiz == FALSE && QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
310 | if (settings.real_wiz == FALSE && QUERY_FLAG (pl, FLAG_WAS_WIZ)) |
302 | SET_FLAG (tmp, FLAG_WAS_WIZ); |
311 | SET_FLAG (tmp, FLAG_WAS_WIZ); |
|
|
312 | |
303 | if (nrof != tmp_nrof) |
313 | if (nrof != tmp_nrof) |
304 | { |
314 | { |
305 | object *tmp2 = tmp; |
315 | object *tmp2 = tmp; |
306 | tag_t tmp2_tag = tmp2->count; |
|
|
307 | |
316 | |
308 | tmp = get_split_ob (tmp, nrof); |
317 | tmp = get_split_ob (tmp, nrof); |
309 | if (!tmp) |
318 | if (!tmp) |
310 | { |
319 | { |
311 | new_draw_info (NDI_UNIQUE, 0, pl, errmsg); |
320 | new_draw_info (NDI_UNIQUE, 0, pl, errmsg); |
312 | return; |
321 | return; |
313 | } |
322 | } |
|
|
323 | |
314 | /* Tell a client what happened rest of objects */ |
324 | /* Tell a client what happened rest of objects */ |
315 | if (pl->type == PLAYER) |
325 | if (pl->type == PLAYER) |
316 | { |
326 | { |
317 | if (was_destroyed (tmp2, tmp2_tag)) |
327 | if (tmp2->destroyed ()) |
318 | esrv_del_item (pl->contr, tmp2_tag); |
328 | esrv_del_item (pl->contr, tmp2->count); |
319 | else |
329 | else |
320 | esrv_send_item (pl, tmp2); |
330 | esrv_send_item (pl, tmp2); |
321 | } |
331 | } |
322 | } |
332 | } |
323 | else |
333 | else |
… | |
… | |
360 | /* Update the container the object was in */ |
370 | /* Update the container the object was in */ |
361 | if (env && env != pl && env != op) |
371 | if (env && env != pl && env != op) |
362 | esrv_update_item (UPD_WEIGHT, pl, env); |
372 | esrv_update_item (UPD_WEIGHT, pl, env); |
363 | } |
373 | } |
364 | |
374 | |
365 | |
375 | /* modified slightly to allow monsters use this -b.t. 5-31-95 */ |
366 | void |
376 | void |
367 | pick_up (object *op, object *alt) |
377 | pick_up (object *op, object *alt) |
368 | |
|
|
369 | /* modified slightly to allow monsters use this -b.t. 5-31-95 */ |
|
|
370 | { |
378 | { |
371 | int need_fix_tmp = 0; |
379 | int need_fix_tmp = 0; |
372 | object *tmp = NULL; |
380 | object *tmp = NULL; |
373 | mapstruct *tmp_map = NULL; |
381 | mapstruct *tmp_map = NULL; |
374 | int count; |
382 | int count; |
375 | tag_t tag; |
|
|
376 | |
383 | |
377 | /* Decide which object to pick. */ |
384 | /* Decide which object to pick. */ |
378 | if (alt) |
385 | if (alt) |
379 | { |
386 | { |
380 | if (!can_pick (op, alt)) |
387 | if (!can_pick (op, alt)) |
… | |
… | |
389 | if (op->below == NULL || !can_pick (op, op->below)) |
396 | if (op->below == NULL || !can_pick (op, op->below)) |
390 | { |
397 | { |
391 | new_draw_info (NDI_UNIQUE, 0, op, "There is nothing to pick up here."); |
398 | new_draw_info (NDI_UNIQUE, 0, op, "There is nothing to pick up here."); |
392 | goto leave; |
399 | goto leave; |
393 | } |
400 | } |
|
|
401 | |
394 | tmp = op->below; |
402 | tmp = op->below; |
395 | } |
403 | } |
396 | |
404 | |
397 | /* Try to catch it. */ |
405 | /* Try to catch it. */ |
398 | tmp_map = tmp->map; |
406 | tmp_map = tmp->map; |
… | |
… | |
449 | { |
457 | { |
450 | new_draw_info (NDI_UNIQUE, 0, op, "This object cannot be put into containers!"); |
458 | new_draw_info (NDI_UNIQUE, 0, op, "This object cannot be put into containers!"); |
451 | goto leave; |
459 | goto leave; |
452 | } |
460 | } |
453 | |
461 | |
454 | tag = tmp->count; |
|
|
455 | pick_up_object (op, alt, tmp, count); |
462 | pick_up_object (op, alt, tmp, count); |
|
|
463 | |
456 | if (was_destroyed (tmp, tag) || tmp->env) |
464 | if (tmp->destroyed () || tmp->env) |
457 | need_fix_tmp = 0; |
465 | need_fix_tmp = 0; |
|
|
466 | |
458 | if (op->type == PLAYER) |
467 | if (op->type == PLAYER) |
459 | op->contr->count = 0; |
468 | op->contr->count = 0; |
|
|
469 | |
460 | goto leave; |
470 | goto leave; |
461 | |
471 | |
462 | leave: |
472 | leave: |
463 | if (need_fix_tmp) |
473 | if (need_fix_tmp) |
464 | fix_stopped_item (tmp, tmp_map, op); |
474 | fix_stopped_item (tmp, tmp_map, op); |
… | |
… | |
554 | * so this function isn't named very good anymore. |
564 | * so this function isn't named very good anymore. |
555 | */ |
565 | */ |
556 | void |
566 | void |
557 | put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) |
567 | put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) |
558 | { |
568 | { |
559 | tag_t tmp_tag, tmp2_tag; |
|
|
560 | object *tmp2, *sack2; |
569 | object *tmp2, *sack2; |
561 | char buf[MAX_BUF]; |
570 | char buf[MAX_BUF]; |
562 | |
571 | |
563 | if (sack == tmp) |
572 | if (sack == tmp) |
564 | return; /* Can't put an object in itself */ |
573 | return; /* Can't put an object in itself */ |
|
|
574 | |
565 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
575 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
566 | { |
576 | { |
567 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cannot put the %s in the %s.", query_name (tmp), query_name (sack)); |
577 | new_draw_info_format (NDI_UNIQUE, 0, op, "You cannot put the %s in the %s.", query_name (tmp), query_name (sack)); |
568 | return; |
578 | return; |
569 | } |
579 | } |
|
|
580 | |
570 | if (tmp->type == CONTAINER && tmp->inv) |
581 | if (tmp->type == CONTAINER && tmp->inv) |
571 | { |
582 | { |
572 | |
583 | |
573 | /* Eneq(@csd.uu.se): If the object to be dropped is a container |
584 | /* Eneq(@csd.uu.se): If the object to be dropped is a container |
574 | * we instead move the contents of that container into the active |
585 | * we instead move the contents of that container into the active |
575 | * container, this is only done if the object has something in it. |
586 | * container, this is only done if the object has something in it. |
576 | */ |
587 | */ |
577 | sack2 = tmp; |
588 | sack2 = tmp; |
578 | new_draw_info_format (NDI_UNIQUE, 0, op, "You move the items from %s into %s.", query_name (tmp), query_name (sack)); |
589 | new_draw_info_format (NDI_UNIQUE, 0, op, "You move the items from %s into %s.", query_name (tmp), query_name (sack)); |
|
|
590 | |
579 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
591 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) |
580 | { |
592 | { |
581 | tmp = tmp2->below; |
593 | tmp = tmp2->below; |
|
|
594 | |
582 | if ((sack->type == CONTAINER && sack_can_hold (op, op->container, tmp2, tmp2->nrof))) |
595 | if ((sack->type == CONTAINER && sack_can_hold (op, op->container, tmp2, tmp2->nrof))) |
583 | { |
596 | { |
584 | put_object_in_sack (op, sack, tmp2, 0); |
597 | put_object_in_sack (op, sack, tmp2, 0); |
585 | } |
598 | } |
586 | else |
599 | else |
… | |
… | |
588 | sprintf (buf, "Your %s fills up.", query_name (sack)); |
601 | sprintf (buf, "Your %s fills up.", query_name (sack)); |
589 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
602 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
590 | break; |
603 | break; |
591 | } |
604 | } |
592 | } |
605 | } |
|
|
606 | |
593 | esrv_update_item (UPD_WEIGHT, op, sack2); |
607 | esrv_update_item (UPD_WEIGHT, op, sack2); |
594 | return; |
608 | return; |
595 | } |
609 | } |
596 | |
610 | |
597 | /* Don't worry about this for containers - our caller should have |
611 | /* Don't worry about this for containers - our caller should have |
… | |
… | |
599 | */ |
613 | */ |
600 | if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp, (nrof ? nrof : tmp->nrof))) |
614 | if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp, (nrof ? nrof : tmp->nrof))) |
601 | return; |
615 | return; |
602 | |
616 | |
603 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
617 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
604 | { |
|
|
605 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
618 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
606 | return; |
619 | return; |
607 | } |
|
|
608 | |
620 | |
609 | /* we want to put some portion of the item into the container */ |
621 | /* we want to put some portion of the item into the container */ |
610 | if (nrof && tmp->nrof != nrof) |
622 | if (nrof && tmp->nrof != nrof) |
611 | { |
623 | { |
612 | object *tmp2 = tmp; |
624 | object *tmp2 = tmp; |
613 | |
625 | |
614 | tmp2_tag = tmp2->count; |
|
|
615 | tmp = get_split_ob (tmp, nrof); |
626 | tmp = get_split_ob (tmp, nrof); |
616 | |
627 | |
617 | if (!tmp) |
628 | if (!tmp) |
618 | { |
629 | { |
619 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
630 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
620 | return; |
631 | return; |
621 | } |
632 | } |
622 | /* Tell a client what happened other objects */ |
633 | /* Tell a client what happened other objects */ |
623 | if (was_destroyed (tmp2, tmp2_tag)) |
634 | if (tmp2->destroyed ()) |
624 | esrv_del_item (op->contr, tmp2_tag); |
635 | esrv_del_item (op->contr, tmp2->count); |
625 | else /* this can proably be replaced with an update */ |
636 | else /* this can proably be replaced with an update */ |
626 | esrv_send_item (op, tmp2); |
637 | esrv_send_item (op, tmp2); |
627 | } |
638 | } |
628 | else |
639 | else |
629 | remove_ob (tmp); |
640 | remove_ob (tmp); |
630 | |
641 | |
631 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
642 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
632 | tmp_tag = tmp->count; |
|
|
633 | tmp2 = insert_ob_in_ob (tmp, sack); |
643 | tmp2 = insert_ob_in_ob (tmp, sack); |
634 | fix_player (op); /* This is overkill, fix_player() is called somewhere */ |
644 | fix_player (op); /* This is overkill, fix_player() is called somewhere */ |
635 | /* in object.c */ |
645 | /* in object.c */ |
636 | |
646 | |
637 | /* If an object merged (and thus, different object), we need to |
647 | /* If an object merged (and thus, different object), we need to |
638 | * delete the original. |
648 | * delete the original. |
639 | */ |
649 | */ |
640 | if (tmp2 != tmp) |
650 | if (tmp2 != tmp) |
641 | esrv_del_item (op->contr, tmp_tag); |
651 | esrv_del_item (op->contr, tmp->count); |
642 | |
652 | |
643 | esrv_send_item (op, tmp2); |
653 | esrv_send_item (op, tmp2); |
644 | |
654 | |
645 | /* update the sacks weight */ |
655 | /* update the sacks weight */ |
646 | esrv_update_item (UPD_WEIGHT, op, sack); |
656 | esrv_update_item (UPD_WEIGHT, op, sack); |
… | |
… | |
669 | * off |
679 | * off |
670 | */ |
680 | */ |
671 | if (nrof && tmp->nrof != nrof) |
681 | if (nrof && tmp->nrof != nrof) |
672 | { |
682 | { |
673 | object *tmp2 = tmp; |
683 | object *tmp2 = tmp; |
674 | tag_t tmp2_tag = tmp2->count; |
|
|
675 | |
684 | |
676 | tmp = get_split_ob (tmp, nrof); |
685 | tmp = get_split_ob (tmp, nrof); |
677 | if (!tmp) |
686 | if (!tmp) |
678 | { |
687 | { |
679 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
688 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
… | |
… | |
682 | /* Tell a client what happened rest of objects. tmp2 is now the |
691 | /* Tell a client what happened rest of objects. tmp2 is now the |
683 | * original object |
692 | * original object |
684 | */ |
693 | */ |
685 | if (op->type == PLAYER) |
694 | if (op->type == PLAYER) |
686 | { |
695 | { |
687 | if (was_destroyed (tmp2, tmp2_tag)) |
696 | if (tmp2->destroyed ()) |
688 | esrv_del_item (op->contr, tmp2_tag); |
697 | esrv_del_item (op->contr, tmp2->count); |
689 | else |
698 | else |
690 | esrv_send_item (op, tmp2); |
699 | esrv_send_item (op, tmp2); |
691 | } |
700 | } |
692 | } |
701 | } |
693 | else |
702 | else |