OSDN Git Service

Angband3.1.0の、キャラ生成時に装備を自動装備するコードを取り込んだ。ただし、光源は自動装備しないようにした。
authoriks <iks@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 16 Mar 2009 07:46:39 +0000 (07:46 +0000)
committeriks <iks@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 16 Mar 2009 07:46:39 +0000 (07:46 +0000)
src/birth.c

index 3f7b56f..eb1ec79 100644 (file)
@@ -3530,6 +3530,72 @@ static void init_turn(void)
        dungeon_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
 }
 
+
+/* 
+ * Try to wield everything wieldable in the inventory. 
+ * Code taken from Angband 3.1.0 under Angband license
+ */ 
+static void wield_all(void) 
+{ 
+       object_type *o_ptr; 
+       object_type *i_ptr; 
+       object_type object_type_body; 
+       int slot; 
+       int item; 
+       /* Scan through the slots backwards */ 
+       for (item = INVEN_PACK - 1; item >= 0; item--) 
+       { 
+               o_ptr = &inventory[item]; 
+               /* Skip non-objects */ 
+               if (!o_ptr->k_idx) continue; 
+               /* Make sure we can wield it and that there's nothing else in that slot */ 
+               slot = wield_slot(o_ptr); 
+               if (slot < INVEN_RARM) continue; 
+               if (slot == INVEN_LITE) continue; /* Does not wield toaches because buys a lantern soon */
+               if (inventory[slot].k_idx) continue; 
+               /* Get local object */ 
+               i_ptr = &object_type_body; 
+               object_copy(i_ptr, o_ptr); 
+               /* Modify quantity */ 
+               i_ptr->number = 1; 
+               /* Decrease the item (from the pack) */ 
+               if (item >= 0) 
+               { 
+                       inven_item_increase(item, -1); 
+                       inven_item_optimize(item); 
+               } 
+               /* Decrease the item (from the floor) */ 
+               else 
+               { 
+                       floor_item_increase(0 - item, -1); 
+                       floor_item_optimize(0 - item); 
+               } 
+               /* Get the wield slot */ 
+               o_ptr = &inventory[slot]; 
+               /* Wear the new stuff */ 
+               object_copy(o_ptr, i_ptr); 
+               /* Increase the weight */ 
+               p_ptr->total_weight += i_ptr->weight; 
+               /* Increment the equip counter by hand */ 
+               equip_cnt++;
+
+       } 
+       return; 
+} 
+
+
 /*
  * Each player starts out with a few items, given as tval/sval pairs.
  * In addition, he always has some food and a few torches.
@@ -3753,6 +3819,9 @@ static void add_outfit(object_type *o_ptr)
 
        /* Auto-inscription */
        autopick_alter_item(slot, FALSE);
+
+       /* Now try wielding everything */ 
+       wield_all(); 
 }