Auto-editing .msg files

Discussion in 'Fallout General Modding' started by vsirin, Nov 25, 2021 at 8:49 AM.

  1. vsirin

    vsirin First time out of the vault

    32
    Nov 21, 2021
    So I'm making (have made, really) a mod for the Mauser to make it less of a useless collector's item, and everything's going swimmingly - except for the part where I turned it into a whole other gun, which necessitates editing the description in the pro_item.msg file. I know the easy way to ensure compatibility is to simply make versions that replace the base Fallout 2 pro_item.msg, the RPU one, and the Megamod one, but I'm a masochist and would like to distribute a package that actually goes in, looks for the file, then changes the strings in it. One thing going for me is that msg files appear just to be plain text, but on the other hand I've read stuff about everything in /data having to be set to read-only, so that could be an issue.

    So, at long last, here's my question: how the hell do I do this? Or should I just make 3 versions?
     
  2. Lexx

    Lexx Testament to the ghoul lifespan
    Moderator Modder

    Apr 24, 2005
  3. vsirin

    vsirin First time out of the vault

    32
    Nov 21, 2021
    Ooo. Simple, elegant, completely inaccessible to me. Excuse me while I slink away and learn to script.

    (Thank you!)
     
  4. vsirin

    vsirin First time out of the vault

    32
    Nov 21, 2021
    Okaaaaay, so 8ish hours later and some Frankensteining later:

    Code:
    procedure start;
    #include "sfall.h"
    #include "DEFINE.H"
    #include "itempid.h"
    
    
    procedure walkercolt_desc begin
    variable
          item := obj_pid(get_sfall_arg),
          description;
    
       if (item == PID_9MM_MAUSER) then begin
             description := get_string_pointer(message_str(gl_walker, 101));
             set_sfall_return(description);
    
       if(game_loaded) then begin
         register_hook_proc(HOOK_DESCRIPTIONOBJ, walkercolt_desc);
       end
    end
    end
    - won't compile, throwing up the following errors:
    gl_walker is the name of the script and the name of the .msg (with the strings I need) that lives in data/text/english/dialog

    What am I doing wrong?

    Thanks in advance!
     
  5. Zorchar

    Zorchar Look, Ma! Two Heads!

    312
    Jun 18, 2018
    The function expects an int (whole number).
    I think it's a vanilla function, which is meant to be used with a msg file with a number corresponding with the script number (index) in script.lst.
     
  6. vsirin

    vsirin First time out of the vault

    32
    Nov 21, 2021
    I'm working off this post, but am also seeing on Google that most results do, indeed, show (number, number). Does this mean that I have to edit the script.lst, then?
     
  7. Zorchar

    Zorchar Look, Ma! Two Heads!

    312
    Jun 18, 2018
    SCRIPT_FARMPART is almost definitely defined as a number. check out other scripts for #DEFINE.
    you can use an ini file (i think) and read information from there. or just manually copy the text from the msg to the script.
     
  8. Lexx

    Lexx Testament to the ghoul lifespan
    Moderator Modder

    Apr 24, 2005
    The message string is taken from SCRIPT_FARMPART which is tied to its own .msg file, yes. You just need to add your own .msg file thing ... or just write plain text with "" .. but then it can't be translated anymore, which would be not so good.
     
  9. vsirin

    vsirin First time out of the vault

    32
    Nov 21, 2021
    I'm a relative noob, as y'all have no doubt noticed...so I'll try the plain text first.
    Code:
    procedure start;
    #include "sfall.h"
    #include "DEFINE.H"
    #include "itempid.h"
    
    procedure walkercolt_desc begin
       variable item := obj_pid(get_sfall_arg),
          description;
    
       if (item == PID_9MM_MAUSER) then begin
             description := get_string_pointer("An 1847 Walker Colt, forged by the Devil from his own sword. Much of the gun's power has been lost since the Almighty was usurped upon His throne, but the small vestige that remains still makes for a terrifying weapon. Min ST: 10.");
             set_sfall_return(description);
    
       if(game_loaded) then begin
         register_hook_proc(HOOK_DESCRIPTIONOBJ, walkercolt_desc);
          end
       end
    end
    end
    It's still "expecting top-level statement" at line 21, which is the last end. Any ideas?
     
  10. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    "begin ... end" should be a pair (Pascal syntax), and the last "end" in your script doesn't have a corresponding "begin".
    You didn't check some existing scripts for examples in your 8hr research?
     
  11. vsirin

    vsirin First time out of the vault

    32
    Nov 21, 2021
    I promise I did, but being a complete noob with experience only in RPGMaker XP doesn't get me very far.

    I watched Quantum's setup videos, read most of this page, got the bulk of the above script from here, but also had to work out that PIDs aren't just the number of the proto file (from an old thread of yours, Nova), then looked through Nirran's source code folders from all his mods to realize that the ellipses and this:

    Code:
    procedure start begin
       variable who, cur_dmg_thresh, cur_dmg_resist, color, msg, m;
    probably weren't necessary. Then spent an hour or two figuring out the message_str part (there's a French site - and my French is not perfect - that also does a file name or string or something instead of a number afterward).

    Tried to do my homework is what I mean. I'm just not great at it. Sorry. :-(
     
  12. vsirin

    vsirin First time out of the vault

    32
    Nov 21, 2021
    IT WORKS! I don't know why, but I stuck this back into the middle

    Code:
    procedure start begin
       variable who, cur_dmg_thresh, cur_dmg_resist, color, msg, m;
    and it compiled and it works!

    @Zorchar, @NovaRain, @Lexx - thank you for your time and patience. :drunk:
     
  13. vsirin

    vsirin First time out of the vault

    32
    Nov 21, 2021
    Okay, so I need another clue - the sfall bgforge and Google are giving me nothing. How do I use this hook to change the weapon name as well?