Changeset 333

Show
Ignore:
Timestamp:
07/13/07 12:47:13 (1 year ago)
Author:
takkaria
Message:

Auto-wield birth items. (closes #24)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/birth.c

    r304 r333  
    530530} 
    531531 
     532/* 
     533 * Try to wield everything wieldable in the inventory. 
     534 */ 
     535static 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} 
    532593 
    533594 
     
    597658        object_known(i_ptr); 
    598659        (void)inven_carry(i_ptr); 
     660 
     661 
     662        /* Now try wielding everything */ 
     663        wield_all(); 
    599664} 
    600665 
  • trunk/src/cmd3.c

    r291 r333  
    299299        } 
    300300 
    301         /* Recalculate bonuses */ 
    302         p_ptr->update |= (PU_BONUS); 
    303  
    304         /* Recalculate torch */ 
    305         p_ptr->update |= (PU_TORCH); 
    306  
    307         /* Recalculate mana */ 
    308         p_ptr->update |= (PU_MANA); 
     301        /* Recalculate bonuses, torch, mana */ 
     302        p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA); 
    309303 
    310304        /* Window stuff */