sfall icon indicating copy to clipboard operation
sfall copied to clipboard

Burst Control

Open VonZorch opened this issue 10 years ago • 4 comments

Could you make the burst behavior settings in ddraw.ini controllable from scripts?

VonZorch avatar Mar 02 '16 21:03 VonZorch

Seems like an interesting idea for making weapons behavior more diverse.

phobos2077 avatar Aug 10 '16 16:08 phobos2077

I think it would be much cooler to add hook script that will allow to completely customize bursts - where each bullet will fly.

phobos2077 avatar Nov 06 '16 11:11 phobos2077

Yes, it would. And it would still do what I want with G11s.

On Sun, Nov 6, 2016 at 5:52 AM, Vlad [email protected] wrote:

I think it would be much cooler to add hook script that will allow to completely customize bursts - where each bullet will fly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/phobos2077/sfall/issues/36#issuecomment-258676054, or mute the thread https://github.com/notifications/unsubscribe-auth/AQI9qSPmtIBDzANNn6W4t7HpyWFmCb7Vks5q7b-FgaJpZM4Hn3_x .

VonZorch avatar Nov 06 '16 22:11 VonZorch

While the original request is fairly easy to implement, I still think it would be amazing to customize the whole attack result calculations. This is not trivial though. Right now we can customize attack calculations via several lower-level hook scripts:

  • TOHIT - may be called many times, for main and additional targets
  • COMBATDAMAGE - called for each target that got hit - but only allows to change the outcome for this particular target.

What I think we can do is to hook the whole compute_attack_ function and allow to customize the whole ctd struct from script (it contains the full outcome of attack for primary and all secondary targets, as well as the attacker himself). The easiest way is to make simple hook and let user rewrite the whole attack logic as he want, but the problem is that this way you will have to re-do damage calculation and hit probability calculation logic inside this "super hook". Possible solution would be to add scripting functions for calling compute_damage_ (COMBATDAMAGE) and determine_to_hit_func_ (TOHIT). Also we will need to add hooks for the AI and other functions that use stuff from compute_attack like compute_explosion_on_extras (also called when timed explosives detonate). The fully-featured solution gets really complicated fast...

Alternative: hook only compute_spray function. PROs:

  • The "super hook" issue will be avoided this way.
  • At least we have full control over bursts behavior for every attack.

CONs:

  • For this we still need to be able to call TOHIT and COMBATDAMAGE functions somehow.
  • Need to figure out how to pass the calculation result to the game. We can have up to 6 additional targets for each burst, each with their own flags, damage amount, etc.

phobos2077 avatar Mar 18 '17 17:03 phobos2077

Kinda want to get back to this. The easiest solution is to just allow changing ComputeSpray values from script, in style of explosion functions. @NovaRain already did this internally. It's probably "the most bang for your buck" solution. But the issue is when someone decides to hook the bigger function, for more control over bursts, this feature will become redundant. Not sure where to draw a line and if we can realistically avoid such redundancy with sfall script features.

phobos2077 avatar May 11 '23 11:05 phobos2077

Here's a basic example of how to use set_spray_settings for script-based burst control:

// gl_burstctrl.ssl
#include ".\headers\define.h"
#include ".\headers\sfall\define_extra.h"
#include ".\headers\sfall\sfall.h"

procedure start;
procedure ammocost_handler;

procedure start begin
   if game_loaded then begin
      register_hook_proc(HOOK_AMMOCOST, ammocost_handler);
   end
end

procedure ammocost_handler begin
   variable
      weapon   := get_sfall_arg,
      bullets  := get_sfall_arg,
      cost     := get_sfall_arg,
      event    := get_sfall_arg;

   if (event == 2 and weapon > 0) then begin // when calculating number of burst rounds
      if (obj_pid(weapon) == PID_ASSAULT_RIFLE) then begin
         set_spray_settings(1, 1, 1, 1); // dead accurate burst
      end
   end
end

NovaRain avatar May 19 '23 02:05 NovaRain