Fallout 2 mod FO2 Engine Tweaks (Sfall)

Discussion in 'Fallout General Modding' started by Dude101, Jul 30, 2007.

  1. Feigenbaum

    Feigenbaum Solitary Traveler

    43
    Aug 16, 2011
    Okay, I apologize for my ignorance but how do I use any of this? I unzipped the mod pack into the Fallout 2 directory... what now?
     
  2. Ardent

    Ardent A Smooth-Skin
    Modder

    681
    Jul 24, 2009
    I have a sfall related question: how would I go about measuring time in a global script? I want the script to subtract some HP from the player character every, say, 30 seconds. Should I use set_global_script_repeat? Or maybe there's some timer function I've missed?
    I don't want to use the timed_event in the player's script, because it causes obscure bugs on saving/loading game.

    Also, I've updated the request wiki with a bug report and a request.
    Thanks in advance!
     
  3. Timeslip

    Timeslip Water Chip? Been There, Done That
    Modder

    921
    Aug 15, 2007
    Same way as any other script; game_time. Or are you trying to measure real time, and don't want it to skip on travel/rest?

    I don't forsee myself working on sfall again any time soon, sorry. But at least it's there if I ever find myself unemployed or something. :)
     
  4. Ardent

    Ardent A Smooth-Skin
    Modder

    681
    Jul 24, 2009
    No, it's only for in-game time. Actually, I have it like this right now; I'm setting a global variable to game_time + 30 in-game seconds, then check in critter_p_proc for the time. If game_time > GVAR, subtract some Hit Points.
    In theory this shouldn't cause any problems, but our tests showed that variable values might somehow get corrupted upon save/load, and instead of losing 1-2 HP, your character loses 150302 HP or something and dies instantly. I was hoping there was some sort of external timer. Nevermind, I think I have an idea anyway :)
    BTW, is it possible to measure real time, instead of in-game time?

    Well, like you said - it's there for future reference.
     
  5. Lexx

    Lexx Background Radiant
    Moderator Modder

    Apr 24, 2005
    In worst case you could add a "security check". If the variable is higher than x you would reset it to a minimum value or 0. Not sure how that would deal with timer variables, though.
     
  6. Timeslip

    Timeslip Water Chip? Been There, Done That
    Modder

    921
    Aug 15, 2007
    Wait, what? If global variables are randomly corrupting themselves on save/load, I would expect there to be rather more issues than just your script. O.o

    Are you sure it's the GVAR going wonky?

    There's a get_uptime() function provided by sfall, which returns the number of milliseconds since computer startup. (It's just a wrapper around the GetTickCount windows api.) It would need some fancy handling to survive save/load, but it's certainly possible.
     
  7. Ardent

    Ardent A Smooth-Skin
    Modder

    681
    Jul 24, 2009
    Well, no, I can't say with 100% certainty that it's the gvar value that gets fucked up - I would need to reproduce the bug with the debug log on and see what it gives. But in casual testing it seemed so - if you load the game where the gvar had a value of game_time + 30 seconds, and the check for the variable came up, you would sometimes, randomly, get a CTD, or get hit by millions of damage, etc.
    Turning that single check off fixed the problem, so since it was a GVAR value check, it must have been something with the GVAR, I reckon.

    Another question, not really related:
    - Is it possible to register two hookscripts in one global script and compare data from both? I have a script that checks when the player has been hit with a critical, but I'd also like to check how much damage he/she got with this attack. From the files, it seems I would need both hs_afterhitroll and hs_combatdamage - one to check if it was critical, and the other to get the damage value.
     
  8. Timeslip

    Timeslip Water Chip? Been There, Done That
    Modder

    921
    Aug 15, 2007
    I suspect you'd have to set a was-critical global from an afterhitroll script, then read it in in the combatdamage script. By that point fallout has used the was-critical flag to calculate the damage and special effects, and then thrown it away again, so it's not available as an input for the damage script.

    iirc, op_set_self applies to the next function call only. On that line, that would be op_dude_obj(), so op_self_obj is going to return null.

    Done. Sorry for the huge delay, and thanks to novarain for stepping in while I've been swanning off. (I've copied novarain, and stuck your code in as #4.)

    Fixed

    Can I have an example script that optimization is breaking please? Different optimization levels sounds like the sort of quick short term fix I'd actually have time for, but if I get a chance later I'd like the fix the actual problem.

    That's... weird. The only thing if(crit) would protect against would be crit being null, but that would have crashed inside sfall while building up the array, because sfall would be accessing each object to check if it's a critter. And even if crit did end up null, debug_msg("crit: "+crit) would just print 'crit: 0' rather than crashing... Maybe crit is ending up with the wrong attached type? :/

    I just did a few tests myself, but I couldn't get any odd behaviour loading up a few saves, killing a few critters, exiting the map, coming back later, waiting for corpses to decay, etc. Do you have a reliable way to reproduce it?
     
    Last edited: Jun 22, 2014
  9. Timeslip

    Timeslip Water Chip? Been There, Done That
    Modder

    921
    Aug 15, 2007
    sfall 3.3, the special didn't-your-mother-ever-tell-you-that-publically-announcing-you'd-retired-from-modding-is-very-very-stupid edition, is up on sourceforge.

     
  10. IYouI

    IYouI First time out of the vault

    42
    Dec 15, 2013
    What is skills ini file, and how did it effect to melee/unarmed damage? Normal gameplay, or some mod that use skills ini file?
     
  11. Timeslip

    Timeslip Water Chip? Been There, Done That
    Modder

    921
    Aug 15, 2007
    It's a tool for modders. If you don't know what it is, it's not something you need to worry about. (Unless you want to make a mod that modifies skill/stat relationships, of course, in which case there's some docs in the modders pack.)
     
    • [Like] [Like] x 1
  12. IYouI

    IYouI First time out of the vault

    42
    Dec 15, 2013
    Alright, thank you for answer!

    I have another question about this:
    There is way to decrease/increase perk freq? What values I need to use to get example perk for every 2 level, instead of default 3?

    Or is it simple to use as this?

    =Values -> effect

    =0 -> default?
    =1 -> perk each level
    =2 -> perk each 2 level
    =3 -> default?
     
    Last edited: Jun 22, 2014
  13. Timeslip

    Timeslip Water Chip? Been There, Done That
    Modder

    921
    Aug 15, 2007
    This global script will give you a perk every two levels:

    Code:
    procedure start begin
        if (game_loaded) then begin
            set_perk_freq(2);
        end
    end
     
    • [Like] [Like] x 1
  14. Continuum

    Continuum Vault Fossil

    Nov 8, 2006
    Are there any chances to override proto's barter "NO" via script? In other words "Barter" button isn't press-able but player may trigger it via dialogue. One of "barter" functions does the trick (don't remember which one), but barter screen is overlapped by player's options window thus it's not really use-able. Would be cool to not display "This person will not barter with you." message when overridden via script - simply clicking on button does nothing, just like in case of Tell-Me-About if local_var(0) <= 25.

    Note: I have no idea if sfall does this, nor if the same happens in Fallout 2.



    --------------------EDIT

    To clarify whole thing: I'd like to have Barter button conditional, controlled via script, not by some Yes/No in critter's proto I can only set in Mapper.
     
    Last edited: Jun 23, 2014
  15. killap

    killap Bear Dude Moderator Modder

    May 16, 2005
    Lulz, good title. I guess I never listened to my mother. ;)

    Good timing too -- I'm putting finishing touches on the next RP release.
     
  16. phobos2077

    phobos2077 Mildly Dipped
    Modder

    596
    Apr 24, 2010
    I need some time to find and identify all problems and then refine them to simplest example functions... I'm sure there was one problem with variable merging (optimizer somehow merged variable that was used later) and maybe something about deleted code after conditional return statement. Too bad I forgot the details and could not reproduce it right now... Fact is, some of my scripts was not working with enabled optimization and work perfectly when disabled (I think Mr.Fixit mod is affected).

    However, I have a suggestion. You already have -O parameter that defines optimization level. Why don't you make it so level 1 optimization will only do DecendUnusedProcedures(prog); and EliminateUnreferencedGlobals(prog); and level 2 enables the complex stuff?

    I did my version of sslc back then, commented out fancy optimization and left only removing unused stuff - that really improved my scripting as I became more confident in creating many procedures in libraries and compiler only include procedures that I actually use (unnecessary stuff removed from my compiled scripts).
    Here is my changed code if you interested:
    View attachment sslc src.zip (it also prints message if optimize or backwardcompat was enabled, in console)

    I also urge you to take a look at script parser in GUI script editor, if you'll have time. It crashes badly in several cases (I think it's compiler crashing causing GUI to show .NET error dialogs), for example if you write function declaration without definition. That really bugged me when I was writing scripts as this parser seem to execute itself once in a while. Expected behavior: ignore such declarations without crashing on parse, only print error on actual compiling.

    Other thing related to parser - when I edit multiple scripts (let's say a.ssl and b.ssl), sometimes when b.ssl is active tab, treeview shows procedures from a.ssl (when I click them - it takes me to other tab), that's really confusing.

    It's related to a specific map you're in. Try EPA maps from latest RP. I'm sure some of them had this problem when I was debugging my traps (I cycle through all critters to do manual explosion). I have a savegame near EPA but it requires my mod to load...

    PS: thank you again for all the great tools and modifications. I'm your fan ;-)
     
  17. Timeslip

    Timeslip Water Chip? Been There, Done That
    Modder

    921
    Aug 15, 2007
    Yup, I will do. :) Will be in the next modders pack release.

    I modified sslc so that -O3 now does what -O2 used to do, (i.e. break absolutely everything...) and -O2 now does what -O1 used to do, (i.e. break only a few things.) -O1 does nothing except for removal of unreferenced procedures and globals, and -O0 (the default) is unchanged.

    The script editor used to only have a checkbox, so I've replaced that with something that lets you pick any of the -O options. If you previously had the checkbox checked, you'll get -O1 rather than -O2 after it reloads your settings.

    Will take a look at fixing the background parser hangs too, while I'm playing with the editor.

    Edit: I can't get any errors. If I write a function declaration without definition, the parser completes successfully. Remove the semi colon, and it fails 'successfully' (It displays 'parser: failed', and stops updating the outline) A begin without end also fails in the expected way. No error dialogs or hangs. Can I have an example script?
     
    Last edited: Jun 24, 2014
  18. phobos2077

    phobos2077 Mildly Dipped
    Modder

    596
    Apr 24, 2010
    I think it has something to do with procedures with arguments. Try adding this line to any script:
    Code:
    procedure wtfqwe(variable a1);
    
    It crashes my parser quite consistently.
     
  19. Timeslip

    Timeslip Water Chip? Been There, Done That
    Modder

    921
    Aug 15, 2007
    ahah! Yes, it was the arguments that did it. It's because the 'name' of the variable you use in the declaration is just a dummy which gets thrown away by the parser as soon as it's encountered, and it's the name in the definition that is interesting. So the editor was trying to extract the real name of the variable, which obviously didn't exist, so bang. Fixed in svn, and thanks for the report. :)

    Edit: Updated the 3.3 modders pack with those two fixes.

    Edit2: And again, because I managed to include the new script editor without the new sslc...
     
    Last edited: Jun 25, 2014
  20. Ardent

    Ardent A Smooth-Skin
    Modder

    681
    Jul 24, 2009
    Thanks for the release, Timeslip! Much appreciated!

    I was wondering about the script editor; how long would it take you to add an auto-fill/hint function? Do you think it's feasible in your current timetable?

    FSE doesn't work well on my computer anymore and I use sfall-specific functions more and more often, so I end up writing scripts in FSE for its auto-fill function, but debug and compile them in your tool, which is pretty annoying in the long run. I would gladly switch 100% to working with your editor, but presently double-checking various functions/arguments takes too much time.

    Maybe the editor could read the function list from an xml/ini file that anyone could customize locally? To save your time, I would gladly prepare the basic template for you, using both the original functions and the ones added in sfall. Such a feature would vastly improve the usability of the tool for regular script grinding, required in big projects like MR.

    I'm pretty sure other modders would appreciate it as well :P
     
    • [Like] [Like] x 1