Fallout 2 mod Proto editing in-game via scripting

Discussion in 'Fallout General Modding' started by banjo_oz, May 2, 2021 at 3:49 PM.

  1. banjo_oz

    banjo_oz First time out of the vault

    42
    Mar 3, 2007
    If I wanted to edit the "Robot Parts" item proto in-game (rather than via a proto editor), can I use code like:
    Code:
    set_proto_data(obj_pid(PID_ROBOT_PARTS), PROTO_IT_COST, 20);
    If so, where should I run it? I was trying a global script that does:
    Code:
    procedure start begin
       if (game_loaded) then begin
          set_proto_data(obj_pid(PID_ROBOT_PARTS), PROTO_IT_COST, 20);
       end
    end
    
    ... but this crashes the game (even though no errors in the editor/compiler).

    Am I using it in the wrong place or is my "set_proto_data" code just plain wrong?
     
  2. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    Why you use obj_pid function while PID_ROBOT_PARTS is already the PID you want to edit?
    You're trying to tell obj_pid to access the memory area it shouldn't.
     
  3. banjo_oz

    banjo_oz First time out of the vault

    42
    Mar 3, 2007
    Doh! Because I didn't know any better and made a stupid mistake. I'm still learning all this stuff from scratch. :)

    So...
    set_proto_data(PID_ROBOT_PARTS, PROTO_IT_COST, 20);
    ... is the correct usage and can be run on game load/start?
     
  4. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    Yes, you should check the document for the arguments of the function.
    Code:
    void set_proto_data(int pid, int offset, int value)