Adding multiple perks to weapons

fortyseven

First time out of the vault
I have been looking for a way to add more than one perk to a weapon. For example I would like to have different types of sniper rifles. However, instead of just tinkering with damage ranges and ammo types I would like to add perks in addition to the long range ability as without that baseline perk you can't have a sniper weapon. If a further perk could be added I could combine the long range perk with for example better criticals or weapon penetrate or weapon accuracy. This could help specialise weapons in a lot of interesting ways.

From what I understand it is impossible do to this by simple proto editing as the perk slot has a hard cap of 1. Therefore the only way to do this is through scripting. Does anyone here have an idea if that is possible and how that could be done? If so would you be able to give a basic example for maybe a 2 perk script on a weapon?

I realise that this might be outside of the engine's capabilities as I have never seen a weapon mod where you get more than one perk per weapon. But it would be nice to know from someone who has some real knowlege of the scripting possibilities.
 
You can emulate additional perk effects with various hook scripts. Here's an example to add the effect of "Weapon Fast Reload" (reloading takes only 1 AP) to the assault rifle:
Code:
procedure start;

#include ".\HEADERS\DEFINE.H"
#include ".\HEADERS\sfall.h"

#define wielding_item(who_obj, pid)  ((obj_pid(critter_inven_obj(who_obj, INVEN_TYPE_RIGHT_HAND)) == pid) or \
                                      (obj_pid(critter_inven_obj(who_obj, INVEN_TYPE_LEFT_HAND)) == pid))

procedure start begin
   if game_loaded then begin
      register_hook(HOOK_CALCAPCOST);
   end else begin
      variable
         critter := get_sfall_arg,
         atkType := get_sfall_arg,
         aimed := get_sfall_arg,
         i := -1;

      if (atkType == hit_left_weapon_reload) or (atkType == hit_right_weapon_reload) then begin
         if wielding_item(critter, PID_ASSAULT_RIFLE) then i := 1;
      end

      if (i != -1) then begin
         if aimed then i++;
         set_sfall_return(i);
      end
   end
end
 
Thanks Nova for the fast reply! Your input is always highly welcome! From what I understand from your script you are not acutally adding the actual perk but simulating the effect of the perk. So in order to script the behaviour of other perks say weapon penetrate you would have to understand how that perk works from the bottum up?
 
Looking at the scripting headers (define_extra.h) from sfall there seem to be definitions for all the hidden perks and the regular perks are defined anyway as far as I understand numbering from 0 to 118. Does that mean it would be possible to associate them with an equiped weapon in a hookscript or is that too simplistic?
 
Back
Top