this works,but sometimes crashes,i donno why
edit : destroying box and resetting loop variable is the cause,in case you care
Code:
procedure Restack_Items begin
variable track, item_pointer, worn_armor,temp_box,loop_init,count,invenArr,item,item_ptr,Ammo,ammoPID,ammoCount,ammoPacks,ammoObj,left_hand_weap, right_hand_weap,count_removed;
if (critter_inven_obj2(dude_obj, INVEN_TYPE_RIGHT_HAND) > 0) then begin
right_hand_weap := critter_inven_obj2(dude_obj, INVEN_TYPE_RIGHT_HAND);
end
if (critter_inven_obj2(dude_obj, INVEN_TYPE_LEFT_HAND) > 0) then begin
left_hand_weap := critter_inven_obj2(dude_obj, INVEN_TYPE_LEFT_HAND);
end
if (critter_inven_obj2(dude_obj, INVEN_TYPE_WORN) > 0) then begin
worn_armor := critter_inven_obj2(dude_obj, INVEN_TYPE_WORN);
end
count := inven_count(dude_obj);
temp_box := create_object_sid(128, 0, 0, -1);
invenArr := temp_array_list(count);
for (loop_init := 0; loop_init < count; loop_init++) begin
invenArr[loop_init] := inven_ptr(dude_obj, loop_init);
end
foreach (item in invenArr) begin
//display_msg("Inv: " + obj_name(item));
if (Is_Valid_Drop(item)) and (temp_box) and (right_hand_weap != item) and (left_hand_weap != item) and (worn_armor != item) then begin
//item := obj_is_carrying_obj_pid(dude_obj, obj_pid(item));
if (item) then begin
count := obj_is_carrying_obj_pid(dude_obj, obj_pid(item));
if (obj_pid(item) == obj_pid(right_hand_weap)) then begin
count := count -1;
end
if (obj_pid(item) == obj_pid(left_hand_weap)) then begin
count := count - 1;
end
if (obj_pid(item) == obj_pid(worn_armor)) then begin
count := count -1;
end
//count := obj_is_carrying_obj_pid(dude_obj, obj_pid(item));
if (count > 99999) then begin
while (count > 99999) do begin
//count := obj_is_carrying_obj_pid(dude_obj, obj_pid(item));
track := rm_mult_objs_from_inven(dude_obj, item, 99999);
add_mult_objs_to_inven(temp_box, item, 99999);
count := count - 99999;
end
count := obj_is_carrying_obj_pid(dude_obj, obj_pid(item));
if (count > 0) then begin
track := rm_mult_objs_from_inven(dude_obj, item, count);
add_mult_objs_to_inven(temp_box, item, count);
end
end
else begin
add_mult_objs_to_inven(temp_box, item, count);
end
//display_msg(obj_name(item) + " after count : " + obj_is_carrying_obj_pid(dude_obj, obj_pid(item)));
end
end
move_obj_inven_to_obj(temp_box, dude_obj);
//display_msg(obj_name(PID_NUKA_COLA) + " after count : " + obj_is_carrying_obj_pid(dude_obj, PID_NUKA_COLA));
destroy_object(temp_box);
end
end
edit : destroying box and resetting loop variable is the cause,in case you care
Last edited: