Changing karma kills without mass recompiling scripts?

FDO

Still Mildly Glowing
Hey,

For all I currently know, there are 2 ways of changing the karma point for killing critters, either modyfing the inc_good\evil\neutral in critters scripts, or more ergonomic, changing the associated values in the reppoint header then recompile critters scripts.

Anyways, it makes a load of files to recompile, and it isn't a problem on my main project which is it's own thing, and doesn't depend on a other mod.
but I have this smaller project I coudn't help to start on Fallout et tu, being able to mod Fallout 1 on F2 engine is too tempting, thanks you, Lexx, and I wanted to import the reputation system of my main project on it.

You must guess my problem, Fallout et tu can get updated in ways I can't predict, and having to chase which scripts have been updated could get, possibly annoying, or recompiling everything too for that matter.

So, is there a method, new sfall functions maybe, to change karma kills points in one script or such ergonomic way?
 
you can use a sfall global to detect when karma changes,then modifiy it to ur specs,similar to this :
Code:
procedure start;

procedure start begin
   if(game_loaded) then begin
      set_global_script_repeat(60); //tells sfal to repeat every 60 frames,so once per second
      set_global_script_type(1); //
      set_sfall_global("Karma__01", global_var(0));
   end
         if(global_var(0) != get_sfall_global_int("Karma__01")) not(game_loaded) then begin
            /// alter karma here
         end
end
 
Thanks, I didn't think sfall functions could be that much convenient. Definitely need to study the documentation better.

If I follow correctly, hook scripts are defined and we can't name them up, i.e, 'HS_whatever_I_Want', but it is possible with global scripts, they just need to start by 'gl_'?
 
Et Tu uses newer sfall 4.x, so you have the more convenient SETGLOBALVAR hook than running the check global script repeatedly. Also the repeating global script method doesn't work too well with DisplayKarmaChanges=1, as there will be two messages for each karma change (first the original, second the changed).
Code:
// gl_karmachange
#include ".\headers\define.h"
#include ".\headers\sfall\sfall.h"

procedure start;
procedure hook_setkarma;

variable karmaBak;

procedure start begin
   if game_loaded then begin
      karmaBak := global_var(GVAR_PLAYER_REPUTATION); // save the karma value on game start
      register_hook_proc(HOOK_SETGLOBALVAR, hook_setkarma);
   end
end

procedure hook_setkarma begin
   variable
      glbVar := get_sfall_arg,
      setVal := get_sfall_arg,
      karmaChg;

   if (glbVar == GVAR_PLAYER_REPUTATION) then begin
      karmaChg := setVal - karmaBak;
      karmaChg := karmaChg / 2; // or do whatever the calculation you want
      // or you might want to add checks to see if the karma change is only from killing critters
      karmaBak += karmaChg;
      set_sfall_return(karmaBak);
   end
end
Code:
// repeating global script method, for reference
#include ".\headers\define.h"

procedure start;

variable karmaBak;

procedure start begin
   variable karmaChg;

   if game_loaded then begin
      karmaBak = global_var(GVAR_PLAYER_REPUTATION); // save the karma value on game start
      set_global_script_type(1);
      set_global_script_repeat(60);
   end else begin
      karmaChg := global_var(GVAR_PLAYER_REPUTATION) - karmaBak;
      karmaChg := karmaChg / 2; // or do whatever the calculation you want
      karmaBak += karmaChg;
      set_global_var(GVAR_PLAYER_REPUTATION, karmaBak);
   end
end
 
Last edited:
My next order of business for tomorow then. Thanks for the model, NovaRain, and for sfall of course.
 
Thanks, I didn't think sfall functions could be that much convenient. Definitely need to study the documentation better.

If I follow correctly, hook scripts are defined and we can't name them up, i.e, 'HS_whatever_I_Want', but it is possible with global scripts, they just need to start by 'gl_'?

yes this is correct(globals need GL, _ is not needed)
 
Back
Top