sfall-team / sfall

sfall - Engine modifications for Fallout 2
https://sfall-team.github.io/sfall/
GNU General Public License v3.0
348 stars 41 forks source link

Function explosion() doesn't run properly while in combat #551

Closed blackpaulillyria closed 2 months ago

blackpaulillyria commented 5 months ago

If function explosion() is ran while outside of combat, then the damage, VFX and SFX run normally. However, if combat is started, then they do not. I can't get hurt, the VFX and SFX do not run either.

It seems that the developers were aware of this issue since they created this workaround throughout the code. For example:

explosion( tile_num( self_obj ), elevation( self_obj ), 1 );
critter_dmg(source_obj,random(MIN_DMG,MAX_DMG),(DMG_normal_dam BWOR DMG_BYPASS_ARMOR BWOR DMG_NOANIMATE));

Can this be fixed?

phobos2077 commented 5 months ago

Well if you fix it you will break existing scripts. Could make a new opcode for that, but really just write a procedure that branches out if you're in combat. That's how my explosive traps work.

blackpaulillyria commented 5 months ago

I’ll create a scripting workaround for explosions based on C code behaviour in the meantime. The main issue with the combat workaround they made is that there is no radius damage. Also, use of this is somewhat weird and unfair: DMG_BYPASS_ARMOR

phobos2077 commented 5 months ago

Well, I'd argue it's not unfair if you stepped on a mine and it explodes below you - your armor probably isn't well protected from below, unless it's a PA. Radius damage you can implement just as well. Take a look at my implementation:

https://github.com/phobos2077/fo2_ecco/blob/ea84ce234d8361a6dba7b479bf212584a429294e/scripts_src/_pbs_headers/traps.h#L276

blackpaulillyria commented 5 months ago

Thanks for sharing your implementation, I’ll check it out!

About the armor, it worries me that there’s a certain condition that ignores Explosive damage DT/DR and that isn’t communicated to the player. It also raises questions should other damage types also have such conditions too?

Definitively a good topic for roundtable discussion and how much we want to gamify/simulate real world inside Fallout? My rule of thumb, if it makes it more fun while staying true to the game world’s internal laws, go for it!

blackpaulillyria commented 2 months ago

Hi, I resolved the issue with a simple and satisfying fix.

If a critter triggers an explosion while in combat, I run terminate_combat followed by add_timer_event(self_obj, 1, 1);

Then inside timed_event_p_proc I run this

   if (fixed_param == 1) then begin
    explosion( self_tile, self_elevation, random(MIN_DMG, MAX_DMG));
   end

Otherwise, if the combat is not initialized, I run explosion() immediately.

P.S. The timed delay of 1 tick seems to be necessary because running explosion() immediately after terminate_combat doesn't work.

phobos2077 commented 2 months ago

Or you could've just followed my example that doesn't involve terminating the combat..

blackpaulillyria commented 2 months ago

Thanks, I don’t mind temporarily ending combat. Any survivors will resume their hostilities if they survive the explosion 😂