Fallout 2 mod FO2 Engine Tweaks (Sfall)

I have a sfall related question: how would I go about measuring time in a global script?
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?

Also, I've updated the request wiki with a bug report and a request.
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. :)
 
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?

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?

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. :)

Well, like you said - it's there for future reference.
 
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.
 
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.
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?

BTW, is it possible to measure real time, instead of in-game time?
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.
 
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?

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.
 
- 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.
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.

Hi Timeslip. Something seems wrong with the set_self sfall scripting function. I made a global variable (let's call it 800) and elsewhere stored a critter pid in it (let's say 16777311 for a random encounter trapper). Let's say I also added a text line 1500 ("I'm thinking of ") to obj_dude.msg. Then in obj_dude.int I wrote (as part of a larger clause of course):

op_set_self(op_global_var(800));
op_float_msg(op_dude_obj(), op_message_str(1, 1500) + op_obj_name(op_self_obj()), 5);
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.

@Timeslip, sorry, but I inconsiderately added my own version of the ddraw.dll (not the .ini) to my mod. If you want me to take it down I will of course. Is there a chance you could add the following as a separate ammo formula (it has a couple of small changes from the previous one)? I'm overriding Haen's formula currently...
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.)

@Timeslip, there seems to be a bug in the afterhitroll hookscript, the third return argument doesn't change the target, but the attacker strangely enough. If you use it in the intended way, the intended target simply attacks himself.
Fixed

The optimization in sslc is broken. Crazy side effects are observed like merging variables when they shouldn't be merged... It would be cool to be able to set optimize level in Script editor and inside sslc itself, don't merge variables or other crazy unstable stuff at optimize level 1 for example... I don't want to remove optimization altogether, there are useful features like removing unused procedures.
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.

I think I've found a serious problem with list_as_array(LIST_CRITTERS) function.
<snip>
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:
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.

changelog said:
>A new ammo patch (From JimTheDinosaur)
>Added new script functions gdialog_get_barter_mod, tile_under_cursor, set_inven_ap_cost
>Added an option to restrict inventory weight limit to active items only
>Added an option to modify inventory ap cost
>Fixes to Glovz ammo patch (From Glovz)
>Fixed melee/unarmed losing their str depedance when using a skills ini file
>Fixed the set_perk_freq function, which I seem to have broken at some point
>Fixed the broken third return value for the afterhitroll script
 
changelog said:
>Fixed melee/unarmed losing their str depedance when using a skills ini file

What is skills ini file, and how did it effect to melee/unarmed damage? Normal gameplay, or some mod that use skills ini file?
 
changelog said:
>Fixed melee/unarmed losing their str depedance when using a skills ini file

What is skills ini file, and how did it effect to melee/unarmed damage? Normal gameplay, or some mod that use skills ini file?
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.)
 
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.)

Alright, thank you for answer!

I have another question about this:
>Fixed the set_perk_freq function

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:
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?
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
 
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:
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
Lulz, good title. I guess I never listened to my mother. ;)

Good timing too -- I'm putting finishing touches on the next RP release.
 
The optimization in sslc is broken. Crazy side effects are observed like merging variables when they shouldn't be merged... It would be cool to be able to set optimize level in Script editor and inside sslc itself, don't merge variables or other crazy unstable stuff at optimize level 1 for example... I don't want to remove optimization altogether, there are useful features like removing unused procedures.
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.

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.

I think I've found a serious problem with list_as_array(LIST_CRITTERS) function.
<snip>
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?
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 ;-)
 
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?
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:
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?
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.
 
I think it has something to do with procedures with arguments.
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:
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
 
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?
I'm pretty sure the text edit control I'm using doesn't have built in support for autocomplete, in which case it's probably not going to happen. Will doublecheck though.

Also, anyone who downloaded the new modders pack before the second edit of my last post, you might want to redownload.
 
Looks like compile.exe not longer runs under XP SP3. I'm getting a "Invalid Win32 application" error. I guess you're compiling it with the latest Visual Studio like you do with ddraw.dll?
 
Back
Top