Fallout 2 mod combat round entered

Discussion in 'Fallout General Modding' started by Nirran, Apr 11, 2019.

  1. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    looking for a scripting return that fires one once per dudes combat turn,does it exist?

    Nirran
     
  2. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    Have you tried HOOK_COMBATTURN?
    Code:
    procedure hook_test begin
       variable
          event := get_sfall_arg,
          critter := get_sfall_arg,
          tmp;
    
       if (event == 1) and (critter == dude_obj) then begin
          display_msg("Player's turn started.");
       end
    end
    
    procedure start begin
       if game_loaded then begin
          register_hook_proc(HOOK_COMBATTURN, hook_test);
       end
    end
    
     
  3. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    no i havent,thnx,how would i use that in apcost hook?trying to have a random chance of free attack checked only once per combat turn
     
  4. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    I would try something like this:
    Code:
    // gl_freeatk
    #include ".\HEADERS\DEFINE.H"
    #include ".\HEADERS\sfall.h"
    
    variable freeAttack := false;
    
    procedure afterhitroll_handler begin
       variable
          willHit := get_sfall_arg,
          attacker := get_sfall_arg;
    
       if (attacker == dude_obj) and freeAttack then begin
          freeAttack := false; // reset
          intface_redraw;
       end
    end
    
    procedure apcost_handler begin
       variable
          critter := get_sfall_arg,
          atkType := get_sfall_arg;
    
       if (critter == dude_obj) and not((atkType == hit_left_weapon_reload) or (atkType == hit_right_weapon_reload)) then begin
          if freeAttack then begin
             set_sfall_return(0);
          end
       end
    end
    
    procedure combatturn_handler begin
       variable
          event := get_sfall_arg,
          critter := get_sfall_arg;
    
       if (event == 1) and (critter == dude_obj) then begin
          if random(0, 1) then begin // 50% chance
             freeAttack := true;
             intface_redraw;
             display_msg("You got a free attack chance!");
          end
       end
    end
    
    procedure start begin
       if game_loaded then begin
          register_hook_proc(HOOK_AFTERHITROLL, afterhitroll_handler);
          register_hook_proc(HOOK_CALCAPCOST, apcost_handler);
          register_hook_proc(HOOK_COMBATTURN, combatturn_handler);
       end
    end
    
     
    • [Rad] [Rad] x 1
  5. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    ok il try that,thxn nova

    edit : got it working,thnx much nova
     
    Last edited: Apr 12, 2019