Fallout 2 mod FO2 Engine Tweaks (Sfall)

So I've been busy adding new stuff to sfall recently. Want to make a brief introduction.

1) Arrays as described in this thread are fully working. You will need new sslc version of course. Hopefully, NovaRain will provide it in coming 3.4 release.

2) Changed previous (optional) combat lighting fix. Now there should be less permanent light artifacts on the ground. However, some other side effect are in place (light stays while people getting knocked back by explosions). Other than that - should be no pitch black explosions (and flying rockets, plasma balls, molotovs) anymore! Need to adjust light radiuses for projectiles for better effect.
Also made it so burning guy animation also emit light. Will try to add light to flamer attack in future.

3) Added a bunch of new functions in "reg_anim_" family. There are a lot of them now, but I made it this way because it fits original set and uses exactly the same family of engine functions (I basically made more of the reg_anim functions exposed to scripting). Also there is an option to remove combat check for all of this functions, which will allow to use them during combat.
If some boring animation functions doesn't sound exciting, here's a short video example of how you can use reg_anim_animate_and_hide function:
Code:
      obj := create_object(PID_EXPLOSION_EMP_1, tile_under_cursor, elevation(dude_obj));
      reg_anim_begin();
      reg_anim_animate_and_hide(obj, 0, -1);
      reg_anim_destroy(obj);
      reg_anim_end();
This is exactly the same mechanism the engine uses for hard-coded explosions (grenades, dynamite, etc). It allows to make effects that disappear exactly at the moment when their animation is finished, allowing for some nice effects.
reg_anim_light allows, for example, to make strobing light.
reg_anim_take_out plays "take out weapon" animation by given weapon holding frame ID (even if there is no such weapon in inventory).
Others should be obvious.

4) Added new hook script hs_ammocost which allows to change how much ammo is reduced when firing weapon.
Also added INI option MISC.CheckWeaponAmmoCost which will add proper checks if there is enough ammo to use weapon (originally it checked if at least 1 round left) and also when calculating burst size (for example, if you set ammo cost to 2, have 7 bullets in your magazine and burst size is 4: it requires 4*2 = 8 bullets, but you only have 7, so you will get 7/2 = 3 shots which will spend 3*2=6 bullets with 1 left in chamber).

5) More control over vanilla critter_dmg function:
- it is now affected by set_target_knockback and remove_target_knockback functions
- hs_deathanim2 hook script is now called for deaths caused by this operator



This allows for some important features (basically did this for my traps system, like most of the other stuff).

6) Added new "metarule" function (yes, I know, it's bad design, but the underlying code is too complex to make a proper hookscript and adding 4 functions for this seemed like an overkill) to change various aspects of explosions in combat:
- force explosion for any damage type (for example, put DMG_fire here before using molotov: it will create explosion effect and inflict fire damage to primary and all secondary targets - wanamingos are in trouble!)
- change radius (limited to something like 8-10, should be enough unless you are making portable nuke :D)
- change explosions art FID (allows to add new explosion graphics)
- change explosion effects pattern (allows to change how many effects are created - originally there are 7 of them; right now it just leaves only 1, but it doesn't look right yet)

All changed parameters are effective until current "attack" action is finished. This is useful in conjunction with itemdamage hook script:
- use global script to attach to HOOK_ITEMDAMAGE
- calculate explosion parameters based on weapon used, etc.
- all of them will be reset after attack is finished, so you don't need to worry about resetting
 
phobos2077 , is it possible to change damage radius and explosion effect for different ammo types? (for example, if dude will launch nuclear rocket from Bazooka, radius and effect should be differ from ordinary high explosive rocket)
 
Ghoul [BB];4026364 said:
phobos2077 , is it possible to change damage radius and explosion effect for different ammo types? (for example, if dude will launch nuclear rocket from Bazooka, radius and effect should be differ from ordinary high explosive rocket)

Yes.

Changed "single" explosion pattern to 3 "splashes" (one in the middle and two to the bottom), which looks ok now. I will use it for everything weaker than rocket launcher in my mod.
 
A couple of changes in sslc compiler:

1) Fixed FOR loops crashing compiler (not 100% sure this bug is gone for good)

2) Last semicolon in FOR is not required when you are using parentheses. This allows for more conventional C-like syntax:
Code:
for (i:=0; i<45; i++)
      ar[i] := 1;
When you are not using parentheses, you will still be required to add semicolon at the end:
Code:
for i:=0; i<45; i++;
      ar[i] := 1;

3) Improved FOREACH loop more by introducing "while" condition. The problem is, there is no "break" operator in SSL, which is very useful sometimes. With FOR and WHILE loops you could at least add some additional condition to break out of the loop when you want, but you couldn't do such thing for FOREACH (it would always iterate for every array element).
So now you can add additional condition like this:
Code:
   foreach k: v in [1,2,3] while (i < 0) begin
      // some code
   end

Which will be translated into this:
Code:
    LVar4 := temp_array(0, 0) + arrayexpr(0, 1) + arrayexpr(1, 2) + arrayexpr(2, 3);
    LVar6 := 0;
    LVar5 := len_array(LVar4);
    while((LVar6 < LVar5) and (LVar1 < 0)) do begin
        LVar2 := get_array_key(LVar4, LVar6);
        LVar3 := get_array(LVar4, LVar2);
        // some code
        LVar6 := LVar6 + 1;
    end

So now you can break from FOREACH loop when you want it.
 
;Set to 1 to make explosions and projectiles emit light
ExplosionsEmitLight=1

Looks great, but... Some light does not dissapear after explosion:
scr00000 copy.gif
 
Ghoul [BB];4026479 said:
;Set to 1 to make explosions and projectiles emit light
ExplosionsEmitLight=1

Looks great, but... Some light does not dissapear after explosion:

Read previous post, I already mentioned this bug. Check again when 3.4 build will come out.

Edit: more features:
1) Changed how sfall accesses global scripts. Now it can execute specific procedure by ID or by name.
Using this I've made changes:
a) "start" proc now can be anywhere in the script and still work (previously it was required to be first procedure in script).
b) "map_enter_p_proc", "map_exit_p_proc" and "map_update_p_proc" will all be executed for all global scripts, which have them.

2) Fixed negate, multiply and divide SSL operators working incorrectly with float values (this was vanilla bug!).
Code:
display_msg("" + (-1.0));
was previously given something like "1085738973", now it will be correct float.
Code:
display_msg("" + ((-2)*1.0));
was also returning some crazy number. Should work as expected now.

If some code was depending on incorrect behavior of this functions, it might not work. But still this is an obvious bug.

3) now you can access individual characters in a string using array syntax:
Code:
str := "Hello";
display_msg(str[4]);  // will print "o"
 
Last edited:
Timeslip

KLIMaka corrected the error with the imported procedures with arguments.

http://teamx.ru/smf/index.php?topic=398.0

You can make these corrections in sfall?

Исправление проблем с временным стеком
5В75А : 89 АС 24 28 01 00 00 -> 89 60 1С 90 90 90 90

Отключение предупреждений
5DFF1 : 74 -> EB
5E1C4 : 74 -> EB

предотвращение слета при повторном экспорте
319СС : 01 -> 00

This actually broken imported procedures... Game crashes if this patch is enabled (tried almost every sfall version starting from 2.1). This patch must be at least optional..

Ok, figured it out. That patch is correct but Timeslip applied at the wrong offset. I corrected it and now imported procedures with 0, 1 & 2 arguments work. Nice. We can make library with all kind of useful functions and place it inside one global script, to be used in all other scripts :)
 
Last edited:
sfall 3.4 is released on SourceForge, along with the modders pack and win2k version.

changelog said:
v3.4
>Added a fix for the obj_can_see_obj script function (From Mash)
>Readded win 2000 support
>Code refactoring, and all the rest of changes are from phobos2077
>Added options to modify bullet distribution in burst attacks
>Added an option to make explosions and projectiles emit light
>Added options to change explosives damage
>Fixed unstable problems with the string_split script function
>Added options to change Hakunin movie timers
>New script functions: substr, strlen, sprintf, typeof
>atoi can now parse hex and octal strings properly into integers
>Rewritten sfall arrays to provide more flexible, safe and powerful tools
>Added 7 new reg_anim_* script functions to manipulate animations further
>New hook scripts: hs_ammocost, hs_useobj
>Added an option to add proper checks for weapons that use multiple ammo per shot
>More control over the critter_dmg script function
>Added a new 'metarule' function to change various aspects of explosions in combat
>Added a config file to reassign or add books
>Fixed incorrect key_pressed statuses for most keys
>The map_*_p_proc procedures are now executed for all global scripts containing them
>Fixed incorrect vanilla behaviour of op_negate, op_mult and op_div involving floats and negative integers
>Fixed the imported procedure patch, which was applied at the wrong offsets
 
;Uncomment these lines to change explosives damage. DmgMax can be set to 9999 at max, and DmgMin is capped at DmgMax
Dynamite_DmgMin=30
Dynamite_DmgMax=50
PlasticExplosive_DmgMin=40
PlasticExplosive_DmgMax=80

is this removed in 3.4 ?

I did not find any variables related to projectile explosion radius :(
 
Ghoul [BB];4026758 said:
;Uncomment these lines to change explosives damage. DmgMax can be set to 9999 at max, and DmgMin is capped at DmgMax
<snip>
is this removed in 3.4 ?
The settings are removed from the "player version" of ddraw.ini, but they're still recognised by sfall if you add the lines back.
You can also check the ddraw_adv.ini in the modders pack for more settings.
 
Last edited:
Ghoul [BB];4026758 said:
I did not find any variables related to projectile explosion radius :(

Explosion radius have to be changed using hook scripts for each attack. I see no point having explosion radius changeable through INI.
 
Yeah, congrats @Timeslip! Also for filling one of my requests as one of your last sfall-related activities, makes me feel all warm and fuzzy inside.

@phobos2077, I've decided to finally start back on my mod, lot's of amazing changes your making man. I was wonder though, I have lots of arrays in the "old" style in my mod, are those still compatible with the new sfall?
 
Yeah, congrats @Timeslip! Also for filling one of my requests as one of your last sfall-related activities, makes me feel all warm and fuzzy inside.

@phobos2077, I've decided to finally start back on my mod, lot's of amazing changes your making man. I was wonder though, I have lots of arrays in the "old" style in my mod, are those still compatible with the new sfall?

Yes, read notes at the end of this post.
 
@phobos2077, the burst path options you added are cool, but is there a way to let them be changed through scripts as well? It would be really cool to introduce the option to switch between wide and narrow spread manually.

edit:

I also can't seem to get the molotov fix to work, I've tried adding these to hs_afterhitroll.int:


if weapon == PID_MOLOTOV_COCKTAIL then begin
metarule2_explosions(4, DMG_fire, 0);
end

but that just resulted in the molotov cocktail becoming a regular thrown object without an explosion (or fire damage).

I also couldn't get the shortcut set_attack_is_explosion_fire to compile, so maybe that has to do with the problem.
 
Last edited:
@Jim:
try adding this to hs_itemdamage instead.

In what cases you want to change burst distribution dynamically?
 
Last edited by a moderator:
@Jim:
try adding this to hs_itemdamage instead.

Has the same effect for me (just like hs_tohit as well).

In what cases you want to change burst distribution dynamically?

I was thinking about giving the player a toggle between spreads, but with the option for the narrower ones only being unlocked with higher skill levels, e.g.:

>0% relevant weapon skill: 33,33,33
>60%: 25,50,25
>120%: 17,66,17
>180%: 0,100,0

High skilled players would then be able to use the narrow spreads against tough enemies and the wide ones against packs of rats or whatever.
 
@Jim:
try adding this to hs_itemdamage instead.

Has the same effect for me (just like hs_tohit as well).
Maybe you forgot to change molotov damage type to Fire in proto?

In what cases you want to change burst distribution dynamically?

I was thinking about giving the player a toggle between spreads, but with the option for the narrower ones only being unlocked with higher skill levels, e.g.:

>0% relevant weapon skill: 33,33,33
>60%: 25,50,25
>120%: 17,66,17
>180%: 0,100,0

High skilled players would then be able to use the narrow spreads against tough enemies and the wide ones against packs of rats or whatever.

Sounds strange to me. You can't change weapon spread at will in real life. But maybe tying it to weapon type would make sense for some weapons. I guess you can add some kind of scripting function for that, which will "reset" it's effect after each attack, just like metarule2_explosions. Only this function should not be limited to vanilla spread logic (with this 4 "sprays"), in case someone will implement new burst logic in future. I guess you just need to think about future when defining function arguments (like adding additional arguments with no use.. ). Arrays are useful in cases when you need to configure some complex logic in one function call - too much functions for the same logic is bad.
 
@Jim:
try adding this to hs_itemdamage instead.

Has the same effect for me (just like hs_tohit as well).
Maybe you forgot to change molotov damage type to Fire in proto?

You're right, I'm an idiot, sorry.

In what cases you want to change burst distribution dynamically?

I was thinking about giving the player a toggle between spreads, but with the option for the narrower ones only being unlocked with higher skill levels, e.g.:

>0% relevant weapon skill: 33,33,33
>60%: 25,50,25
>120%: 17,66,17
>180%: 0,100,0

High skilled players would then be able to use the narrow spreads against tough enemies and the wide ones against packs of rats or whatever.

Sounds strange to me. You can't change weapon spread at will in real life. But maybe tying it to weapon type would make sense for some weapons. I guess you can add some kind of scripting function for that, which will "reset" it's effect after each attack, just like metarule2_explosions. Only this function should not be limited to vanilla spread logic (with this 4 "sprays"), in case someone will implement new burst logic in future. I guess you just need to think about future when defining function arguments (like adding additional arguments with no use.. ). Arrays are useful in cases when you need to configure some complex logic in one function call - too much functions for the same logic is bad.

I guess you could view bursts as representing weapon spread, but then how would you explain a skilled shot getting 90% THC on all the targets where an unskilled one gets 50%? I think it's easier to have it represent purposefully fire along a line (thus creating the burst cone). If you were to have it represent weapon spread, you would need to have the THC for extra targets be constant I guess.

I have to admit I don't quite understand the problem with implement a function for scripting burst spread: why would it be a problem for future burst changes?
 
Back
Top