class Game_Party
def lost_half_items
list_all = [@items, @weapons, @armors]
half_num = 0
list_all.each do |list|
list.values.each do |l|
half_num += l
end
end
return if half_num == 0
while half_num > 0
list = list_all[rand(3)]
next if list.size <= 0
rand_items_id = @items.keys[rand(@items.keys.size)]
rand_weapons_id = @weapons.keys[rand(@weapons.keys.size)]
rand_armors_id = @armors.keys[rand(@armors.keys.size)]
if @items[rand_items_id] > 1
lose_num = @items[rand_items_id]
rand_item_number = rand($game_party.item_number(lose_num))
@items[rand_items_id] -= rand_item_number.abs
half_num -= 1
else
@items.delete(rand_items_id)
half_num -= 1
end
if @weapons[rand_weapons_id] > 1
lose_num = @weapons[rand_weapons_id]
rand_item_number = rand($game_party.item_number(lose_num))
@weapons[rand_weapons_id] -= rand_item_number.abs
half_num -= 1
else
@items.delete(rand_items_id)
half_num -= 1
end
if @armors[rand_armors_id] > 1
lose_num = @armors[rand_armors_id]
rand_item_number = rand($game_party.item_number(lose_num))
@armors[rand_armors_id] -= rand_item_number.abs
half_num -= 1
else
@items.delete(rand_items_id)
half_num -= 1
end
end
end
end