Item weight and inventory stats - Wants to make item weigh less than 1 lbs.

Discussion in 'Fallout General Modding' started by Zorchar, Oct 11, 2020.

  1. Zorchar

    Zorchar Still Mildly Glowing

    236
    Jun 18, 2018
    Thanks Mr. Stalin and Cyrus for explaining.

    It works!

    One more question, and this is entirely for the sake of understanding for the future:

    How come this code works?
    Code:
    procedure delete_extra_weights(variable weight_amount) begin
       hook_stop := true;
       if (weight_amount<1) then begin
         return;
       end
    
        while(weight_amount!= 0) do begin
           if obj_carrying_pid_obj(dude_obj, PID_EXTRA_WEIGHT) >0  then begin
              if weight_amount == 1 then
                 destroy_object(obj_carrying_pid_obj(dude_obj, PID_EXTRA_WEIGHT));
              display_msg("" + weight_amount);
               weight_amount:=weight_amount-1;
            end
        end
        hook_stop := false;
    end
    
    But if I change the line "if weight_amount == 1" to "if weight_amount == 2, or anything other then "==1", then it crashes... WTF?
    according to the debugger, it crashes when weight_amount==2. (displayed massage is "2")

    I know it has something to do with the "destroy_object" function, because if u replace the line, it works.
     
    Last edited: Oct 18, 2020
  2. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    384
    Oct 29, 2015
    destroy_object - it is wrong to immediately destroy an item in the inventory, right from the beginning you need to "remove" then you can destroy it.
     
    • [Rad] [Rad] x 1
  3. Zorchar

    Zorchar Still Mildly Glowing

    236
    Jun 18, 2018
    Please do. That would be awesome.

    I'm starting to work on ini integration for the script.
     
  4. Cyrus

    Cyrus It Wandered In From the Wastes

    116
    Nov 5, 2015
    There you go.

    Now be careful, this is not technically finished. The mod script is essentially finished though and does work. But weapon and ammo data is incomplete in ini, but you can take it for a cruise.

    If you don't have the extra header, try remming it out, might work fine, I don't think I've used it, but do check.
     

    Attached Files:

  5. Zorchar

    Zorchar Still Mildly Glowing

    236
    Jun 18, 2018
    Awesome Cyrus, thanks.

    At first glance, I'm very impressed with what you did. I think I will look into the your script and try to learn better ways to code.

    Can you explain "remming"?
    Meanwhile, I got the mod to work! My brains is all mushy now, but it feels awesome.
    I will fix the code a bit, and make beta setting for my .ini file (:smug:) and publish.
    Maybe I will wait for publishing until I will learn how to add a new proto file through script, because currently it requires you to manually add a proto file to the game, which obviously makes this mod suck. But I guess a few days at the most.
     
  6. Zorchar

    Zorchar Still Mildly Glowing

    236
    Jun 18, 2018
    What's the code to prevent an item to be moved from one inventory to another? Let's say I want to prevent all stimpaks to be moved between inventories.

    Code:
          orig_owner := get_sfall_arg;
          the_item := get_sfall_arg;
          num_removed_objects := get_sfall_arg;
          reason_removed := get_sfall_arg;
          dest_obj := get_sfall_arg;
          if obj_pid(the_item) == PID_STIMPAK then
    ??????
    
    Is there a simple continuation? script_overrides didn't help.
     
  7. Cyrus

    Cyrus It Wandered In From the Wastes

    116
    Nov 5, 2015
    Well you are the first to see it, so give me feedback if you have any.



    by "remming" I mean "remarking". when you put a // or /* in front of a line that line becomes a "remark" (a note text). "Rem" ing is lazy talk for "remark ing". So remark it out.



    Unfortunately I can't advise on usage of inventory related things, I have zero knowledge and experience with it.
     
  8. burn

    burn Mildly Dipped
    Modder

    564
    Apr 22, 2012
    Destroy them and create new ones back at the owner, I guess.
     
  9. Zorchar

    Zorchar Still Mildly Glowing

    236
    Jun 18, 2018
    Thanks burn. I tried doing that, but I couldn't get the item to be removed and added properly. Mr. Stalin suggested using a delay: "call <procedure> in <seconds>", so I did this to separate calculations, and it worked.

    Thanks!