| | 532 | /* |
|---|
| | 533 | * Try to wield everything wieldable in the inventory. |
|---|
| | 534 | */ |
|---|
| | 535 | static void wield_all(void) |
|---|
| | 536 | { |
|---|
| | 537 | object_type *o_ptr; |
|---|
| | 538 | object_type *i_ptr; |
|---|
| | 539 | object_type object_type_body; |
|---|
| | 540 | |
|---|
| | 541 | int slot; |
|---|
| | 542 | int item; |
|---|
| | 543 | |
|---|
| | 544 | /* Scan through the slots backwards */ |
|---|
| | 545 | for (item = INVEN_PACK - 1; item >= 0; item--) |
|---|
| | 546 | { |
|---|
| | 547 | o_ptr = &inventory[item]; |
|---|
| | 548 | |
|---|
| | 549 | /* Skip non-objects */ |
|---|
| | 550 | if (!o_ptr->k_idx) continue; |
|---|
| | 551 | |
|---|
| | 552 | /* Make sure we can wield it and that there's nothing else in that slot */ |
|---|
| | 553 | slot = wield_slot(o_ptr); |
|---|
| | 554 | if (slot < INVEN_WIELD) continue; |
|---|
| | 555 | if (inventory[slot].k_idx) continue; |
|---|
| | 556 | |
|---|
| | 557 | /* Get local object */ |
|---|
| | 558 | i_ptr = &object_type_body; |
|---|
| | 559 | object_copy(i_ptr, o_ptr); |
|---|
| | 560 | |
|---|
| | 561 | /* Modify quantity */ |
|---|
| | 562 | i_ptr->number = 1; |
|---|
| | 563 | |
|---|
| | 564 | /* Decrease the item (from the pack) */ |
|---|
| | 565 | if (item >= 0) |
|---|
| | 566 | { |
|---|
| | 567 | inven_item_increase(item, -1); |
|---|
| | 568 | inven_item_optimize(item); |
|---|
| | 569 | } |
|---|
| | 570 | |
|---|
| | 571 | /* Decrease the item (from the floor) */ |
|---|
| | 572 | else |
|---|
| | 573 | { |
|---|
| | 574 | floor_item_increase(0 - item, -1); |
|---|
| | 575 | floor_item_optimize(0 - item); |
|---|
| | 576 | } |
|---|
| | 577 | |
|---|
| | 578 | /* Get the wield slot */ |
|---|
| | 579 | o_ptr = &inventory[slot]; |
|---|
| | 580 | |
|---|
| | 581 | /* Wear the new stuff */ |
|---|
| | 582 | object_copy(o_ptr, i_ptr); |
|---|
| | 583 | |
|---|
| | 584 | /* Increase the weight */ |
|---|
| | 585 | p_ptr->total_weight += i_ptr->weight; |
|---|
| | 586 | |
|---|
| | 587 | /* Increment the equip counter by hand */ |
|---|
| | 588 | p_ptr->equip_cnt++; |
|---|
| | 589 | } |
|---|
| | 590 | |
|---|
| | 591 | return; |
|---|
| | 592 | } |
|---|