Useful Scripting Libraries

Discussion in 'Fallout General Modding' started by phobos2077, Feb 24, 2014.

  1. phobos2077

    phobos2077 Mildly Dipped
    Modder

    Apr 24, 2010
    Useful SSL Libraries and Modding Tools

    I created this thread to share and discuss SSL scripting libraries (headers) and functions that could be used between scripters and different mods.

    Benefits that I see from such effort:
    • a lot of very useful high-level procedures, constants and macros, especially useful for beginners
    • you could quickly see how different features are made in other mods
    • this should inspire scripters to write good code, with more-or-less single style, little repetitions, re-inventions of the wheel

    I see there are several people in this forum currently in active modding, I hope they'll participate :)

    My library: v1.1
    • lib.arrays.h - procedures that will help you use arrays in their full:
      - use them as stacks, sets
      - easily compare, copy, slice, cut, add arrays
      - display array contents (for debugging)
      - save/load two-dimensional arrays to savegame in one command (eg. arrays of objects)
    • lib.inven.h - fallout items manipulation functions
    • lib.math.h - a few simple functions for calculations
    • lib.strings.h - search in strings, join, repeat, etc.
    • lib.misc.h - misc stuff

    Other stuff:

    • Sfall 3.5 r315 (VS2010 build, debug version)
    • Script Editor with compiler and decompiler (VS2013) with new syntax and opcodes support (sources: sslc, int2ssl) - UPDATED at 2016.10.14
    • SSL UDL definition for Notepad++ (syntax highlighting).
    • C++ tool that allows to easily apply armor changes to all appropriate critters (.bat file has all the mapping for latest RP version). This allows to quickly rebalance defense parameters of all humanoid critters, without editing them all by hand. I know it's not first of it's kind, but I couldn't find other ones :smile:
    • PRO file Template for Sweetscape 010 Editor View attachment fallout_pro.zip (it's very useful when you need to edit single prototype without opening f2wedit or critter editor, or when you need to edit scenery) - not complete, but common values are there.
    • sfallgv.sav file Template for 010 Editor: link (this file contains stuff like fake perks, traits, sfall globals and sfall arrays; may be useful for save editor developers or modders)
    • Interactive map of random encounters, for analysis: http://yadi.sk/d/DJ2iHGTyJZ6dp
     
    Last edited: Oct 14, 2016
    • [Like] [Like] x 1
  2. JimTheDinosaur

    JimTheDinosaur Vault Dweller
    Modder

    Mar 17, 2013
  3. phobos2077

    phobos2077 Mildly Dipped
    Modder

    Apr 24, 2010
    Updated OP with some new stuff.
     
  4. phobos2077

    phobos2077 Mildly Dipped
    Modder

    Apr 24, 2010
    Mr. Fixit expanded

    Might be useful to someone who uses Mr. Fixit in their mods.

    So, as some already knows, I expanded Mr. Fixit somewhat for my Rebalance mod. But all that can also be used in any other mod.
    Here is a (not full) list of changes compared to standalone v1.1 of Mr. Fixit:
    1) Added categories of items. You have to define category names and category numbers for each section. There are 3 configurable modes.
    First one works exactly like before, all items are in one list.
    Second one shows list of categories first (only categories that have at least 1 item) and then you can browse different categories.
    Third mode at first shows items in one list, but if the list gets bigger, it automatically switches to category mode.
    Mode can be selected withing test0.msg
    2) Replaced GVAR checks with sfall global variables. Nothing fancy about it, but it was useful in my case. There is no config option to switch back to normal GVARs, but changing code should be simple.
    3) Implemented alternative ingredients. This allows for ingredient formulas like: Item1 AND (Item2 OR Item3).
    4) Implemented variable number of items from one batch (for example, create 2 bigger apples from 3 small apples).
    5) Implemented proper display of number of items for batch or ingredients required, when using ammo (it will show amount of actual ammo, not ammo packs).
    6) Party member skills are used in craft requirements check (can be turned OFF in MSG).
    7) Number of items per page was increased from 6 (or 7) to 10 (line spacing reduced).
    8) Craft window is centered when using higher resolutions (was always in top-left corner), doesn't work properly in some configurations though.
    9) Starting index for sections is now 1000 instead of 500 and step is 100 instead of 25.
    10) (not really a part of the script, but still...)
    I created two Python scripts that greatly helped me to rearrange my crafting schematics in TEST0.MSG.
    One takes your TEST0.msg and creates a plain text file from it like so:
    Code:
    [ITEM]
    627                              # Fish Soup
    pcx/items/stew1.pcx
    69060
    CRFT_FOD                                 # 
    18000                            # 0 h 30 m
    NO
    1                                # food
    [TOOLS]
    4                                # PID_KNIFE
    [SKILLS]
    SKILL_FIRST_AID:25
    SKILL_OUTDOORSMAN:50
    [COMPONENTS]
    535:1|536:1                      # Fish or Scaly Fish
    71:1                             # Fruit
    
    You can edit, rearrange your schematics without worrying about message IDs. Then use the second script to generate this:
    Code:
    {1000}{}{[ITEM]}
    {1001}{}{627}                              # Fish Soup
    {1002}{}{pcx/items/stew1.pcx}
    {1003}{}{69060}
    {1004}{}{CRFT_FOD}                                 # 
    {1005}{}{18000}                            # 0 h 30 m
    {1006}{}{NO}
    {1007}{}{1}                                # food
    {1008}{}{[TOOLS]}
    {1009}{}{4}                                # PID_KNIFE
    {1010}{}{[SKILLS]}
    {1011}{}{SKILL_FIRST_AID:25}
    {1012}{}{SKILL_OUTDOORSMAN:50}
    {1013}{}{[COMPONENTS]}
    {1014}{}{535:1|536:1}                      # Fish or Scaly Fish
    {1015}{}{71:1}                             # Fruit
    
    It works for all items at once.

    Download here: https://yadi.sk/d/h7Z2EAFlZF5Nz
    You might need to adjust some include paths and there may be some left over code, but otherwise it should be usable.
     
  5. phobos2077

    phobos2077 Mildly Dipped
    Modder

    Apr 24, 2010
    Added some new software and library in OP.

    Edit:
    Didn't want to create another thread for this: just realized how exactly exported/imported variables work. They are awesome when you want to pass some variables between scripts without cluttering your savegame, BUT there is catch. DON'T USE them in sfall global scripts or hook scripts in their current state. When you leave map, for some reason, exported variables disappear, but scripts themselves (because they are "global") don't and they continue to reference exported values which doesn't exist... which leads to errors and crashes.
     
    Last edited: Dec 9, 2014
  6. Sduibek

    Sduibek Creator of Fallout Fixt Moderator Modder

    Oct 27, 2010
    This is excellent, I was just wishing yesterday I could use arrays in scripts.

    Something I'd be curious to know is why Tim Cain didn't use object oriented programming for Fallout. Maybe to save memory I guess?
     
  7. darkf

    darkf Caller of the Void Modder

    Jul 12, 2014
    For the engine? It kind of does, entites are modeled as structural objects of varying kinds (critters, items, weapons, etc.) where all of the specific subtypes hierarchially inherit from base objects, and have overridable prototypes providing properties acting as sort of object prefabs. So there's some OOP and data driven design concepts there.

    It was also written in the early 90s when the dominant language at the time was mostly C (and some variants of C++), but C has always been more predictable and he probably knew that best, so why change for no benefit? :)

    All I can say is the compiler they chose at the time (Watcom) is completely horrible by today's standards and it did an absolutely awful job at optimizing code. One question I've had is what framerate the game ran at on the average PC at the time. Animations don't seem to run at above what, 12 FPS?