… | |
… | |
250 | * pick up (0 means all of them) |
250 | * pick up (0 means all of them) |
251 | */ |
251 | */ |
252 | static void |
252 | static void |
253 | pick_up_object (object *pl, object *op, object *tmp, int nrof) |
253 | pick_up_object (object *pl, object *op, object *tmp, int nrof) |
254 | { |
254 | { |
255 | /* buf needs to be big (more than 256 chars) because you can get |
|
|
256 | * very long item names. |
|
|
257 | */ |
|
|
258 | char buf[HUGE_BUF]; |
|
|
259 | object *env = tmp->env; |
255 | object *env = tmp->env; |
260 | uint32 weight, effective_weight_limit; |
256 | uint32 weight, effective_weight_limit; |
261 | int tmp_nrof = tmp->nrof ? tmp->nrof : 1; |
257 | int tmp_nrof = tmp->nrof ? tmp->nrof : 1; |
262 | |
258 | |
263 | /* IF the player is flying & trying to take the item out of a container |
259 | /* IF the player is flying & trying to take the item out of a container |
… | |
… | |
280 | /* Figure out how much weight this object will add to the player */ |
276 | /* Figure out how much weight this object will add to the player */ |
281 | weight = tmp->weight * nrof; |
277 | weight = tmp->weight * nrof; |
282 | if (tmp->inv) |
278 | if (tmp->inv) |
283 | weight += tmp->carrying * (100 - tmp->stats.Str) / 100; |
279 | weight += tmp->carrying * (100 - tmp->stats.Str) / 100; |
284 | |
280 | |
285 | if (pl->stats.Str <= MAX_STAT) |
|
|
286 | effective_weight_limit = weight_limit[pl->stats.Str]; |
281 | effective_weight_limit = weight_limit [min (MAX_STAT, pl->stats.Str)]; |
287 | else |
|
|
288 | effective_weight_limit = weight_limit[MAX_STAT]; |
|
|
289 | |
282 | |
290 | if ((pl->weight + pl->carrying + weight) > effective_weight_limit) |
283 | if ((pl->weight + pl->carrying + weight) > effective_weight_limit) |
291 | { |
284 | { |
292 | new_draw_info (0, 0, pl, "That item is too heavy for you to pick up."); |
285 | new_draw_info (0, 0, pl, "That item is too heavy for you to pick up."); |
293 | return; |
286 | return; |
… | |
… | |
325 | tmp->remove (); /* Unlink it */ |
318 | tmp->remove (); /* Unlink it */ |
326 | } |
319 | } |
327 | } |
320 | } |
328 | |
321 | |
329 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
322 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
330 | sprintf (buf, "%s will cost you %s.", query_name (tmp), query_cost_string (tmp, pl, F_BUY | F_SHOP)); |
323 | 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)); |
331 | else |
324 | else |
332 | sprintf (buf, "You pick up the %s.", query_name (tmp)); |
325 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You pick up the %s.", query_name (tmp)); |
333 | |
|
|
334 | new_draw_info (NDI_UNIQUE, 0, pl, buf); |
|
|
335 | |
326 | |
336 | tmp = insert_ob_in_ob (tmp, op); |
327 | tmp = insert_ob_in_ob (tmp, op); |
337 | |
328 | |
338 | /* All the stuff below deals with client/server code, and is only |
329 | /* All the stuff below deals with client/server code, and is only |
339 | * usable by players |
330 | * usable by players |
… | |
… | |
372 | if (!can_pick (op, alt)) |
363 | if (!can_pick (op, alt)) |
373 | { |
364 | { |
374 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't pick up the %s.", &alt->name); |
365 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't pick up the %s.", &alt->name); |
375 | goto leave; |
366 | goto leave; |
376 | } |
367 | } |
|
|
368 | |
377 | tmp = alt; |
369 | tmp = alt; |
378 | } |
370 | } |
379 | else |
371 | else |
380 | { |
372 | { |
381 | if (op->below == NULL || !can_pick (op, op->below)) |
373 | if (op->below == NULL || !can_pick (op, op->below)) |
… | |
… | |
390 | /* Try to catch it. */ |
382 | /* Try to catch it. */ |
391 | tmp_map = tmp->map; |
383 | tmp_map = tmp->map; |
392 | tmp = stop_item (tmp); |
384 | tmp = stop_item (tmp); |
393 | if (tmp == NULL) |
385 | if (tmp == NULL) |
394 | goto leave; |
386 | goto leave; |
|
|
387 | |
395 | need_fix_tmp = 1; |
388 | need_fix_tmp = 1; |
396 | if (!can_pick (op, tmp)) |
389 | if (!can_pick (op, tmp)) |
397 | goto leave; |
390 | goto leave; |
398 | |
391 | |
399 | if (op->type == PLAYER) |
392 | if (op->type == PLAYER) |
… | |
… | |
404 | } |
397 | } |
405 | else |
398 | else |
406 | count = tmp->nrof; |
399 | count = tmp->nrof; |
407 | |
400 | |
408 | /* container is open, so use it */ |
401 | /* container is open, so use it */ |
|
|
402 | if (tmp->flag [FLAG_STARTEQUIP]) |
|
|
403 | alt = op; |
409 | if (op->container) |
404 | else if (op->container) |
410 | { |
405 | { |
411 | alt = op->container; |
406 | alt = op->container; |
412 | if (alt != tmp->env && !sack_can_hold (op, alt, tmp, count)) |
407 | if (alt != tmp->env && !sack_can_hold (op, alt, tmp, count)) |
413 | goto leave; |
408 | goto leave; |
414 | } |
409 | } |
… | |
… | |
433 | /* here it could be possible to check rent, |
428 | /* here it could be possible to check rent, |
434 | * if someone wants to implement it |
429 | * if someone wants to implement it |
435 | */ |
430 | */ |
436 | alt = op; |
431 | alt = op; |
437 | } |
432 | } |
|
|
433 | |
438 | #ifdef PICKUP_DEBUG |
434 | #ifdef PICKUP_DEBUG |
439 | LOG (llevDebug, "Pick_up(): %s picks %s (%d) and inserts it %s.\n", op->name, tmp->name, op->contr->count, alt->name); |
435 | LOG (llevDebug, "Pick_up(): %s picks %s (%d) and inserts it %s.\n", op->name, tmp->name, op->contr->count, alt->name); |
440 | #endif |
436 | #endif |
441 | |
437 | |
442 | /* startequip items are not allowed to be put into containers: */ |
438 | /* startequip items are not allowed to be put into containers: */ |
… | |
… | |
533 | if (!params && !tmp) |
529 | if (!params && !tmp) |
534 | { |
530 | { |
535 | for (tmp = op->below; tmp; tmp = tmp->below) |
531 | for (tmp = op->below; tmp; tmp = tmp->below) |
536 | if (!tmp->invisible) |
532 | if (!tmp->invisible) |
537 | { |
533 | { |
538 | char buf[MAX_BUF]; |
|
|
539 | |
|
|
540 | sprintf (buf, "You can't pick up a %s.", &tmp->name); |
534 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't pick up a %s.", &tmp->name); |
541 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
542 | break; |
535 | break; |
543 | } |
536 | } |
544 | |
537 | |
545 | if (!tmp) |
538 | if (!tmp) |
546 | new_draw_info (NDI_UNIQUE, 0, op, "There is nothing to pick up."); |
539 | new_draw_info (NDI_UNIQUE, 0, op, "There is nothing to pick up."); |