BLD Patching Utility Script: Created by zilav & Zzyxzz

ALL CREDIT TO zilav & Zzyxzz

unit userscript;

//##############//##############
//Created by zilav & Zzyxzz
//##############//##############
//Instructions (READ FIRST!)
//
// This patcher is in an unfinished state. It does only work for ballistic weapons and their modifications.
// If you want to create a patch and want to know the values, to verify, it patched correctly, refer to http://www.nexusmods.com/fallout4/articles/398/?
// IT DOES NOT PATCH LEVELED LISTS!
// It can patch weapons, that stick to the vanilla modifications style, naming and keywording.
// There are weapon mods that can't be patched. As example, Modern Firearms, P90 (which has no real receivers and is completely off from vanilla.)
// If you want to patch a weapon, try to look at the modifications it has. I they are similar to the vanilla ones (Light Receiver, Hardened Receiver, Heavy Receiver, Advanced Receiver etc.)
// you are good to go.
//
// Options: Always try Name Patching first! Its the most reliable way to patch weapons.
// Name Patching; Patches receivers by finding their names.
// Keyword Patching; Patches receivers by finding keywords.
// Value Patching; This searches for values and patches them accordingly. IE, converts: 0.75 => 0.4; 0.5 0 => 0.3 etc
//
// Weapon Patching:
//
// When patching a weapon, the options you can tick are ignored/have no effect. The selected weapon will automatically patched, when hitting ok.
//
//

var
bNamePatcher, bKeywordPatcher, bValuePatcher, bArmorPenPatcher: Boolean;
armorPenValueS : string;

// multi-purpose function for changing, adding and deleting properties
function SetOMODProperty(
aOMOD: IInterface; // OMOD record
aProperty: string; // Property name
aFunctionType: string; // Function Type, if empty then delete the property
aValueType: string; // Value Type
aValue1: string; // Value 1
aValue2: string; // Value 2
aAddIfMissing: boolean // flag to add a new property if doesn't exist already
): IInterface; // returns modified or added property
var
props, prop: IInterface;
i: integer;
bFound: boolean;
begin
// getting Properties array inside DATA subrecord
props := ElementByPath(aOMOD, 'DATA\Properties');

// iterating over properties, indexed starting from 0
for i := 0 to Pred(ElementCount(props)) do begin
// getting Nth property
prop := ElementByIndex(props, i);

// compare Property field and skip to the next property if doesn't match
if GetElementEditValues(prop, 'Property') <> aProperty then
Continue;

// if empty Faction Type is passed then just delete this property and exit
if aFunctionType = '' then begin
Remove(prop);
Exit;
end;

// compare Value Type and skip to the next property if doesn't match
// this is optional and Value Type can be just set instead to ensure proper calculation
// SetElementEditValues(prop, 'Value Type', aValueType);
if GetElementEditValues(prop, 'Value Type') <> aValueType then
Continue;

// setting values if they are defined
// Value1 and Value2 fields change their name depeding on Value Type field so we can't access them by names
// so instead we will use their indexes inside Property struct which are constant and don't change
if aValue1 <> '' then
SetEditValue(ElementByIndex(prop, 6), aValue1);

if aValue2 <> '' then
SetEditValue(ElementByIndex(prop, 7), aValue2);

// we already found and changed the property, no need to check the rest
// set the flag and break out of loop
bFound := True;
Break;
end;

// if property was not found and we want to add a new one
if not bFound and aAddIfMissing then begin
// appending new property
prop := ElementAssign(props, HighInteger, False, nil);
SetElementEditValues(prop, 'Property', aProperty);
SetElementEditValues(prop, 'Function Type', aFunctionType);
SetElementEditValues(prop, 'Value Type', aValueType);
SetEditValue(ElementByIndex(prop, 6), aValue1);
SetEditValue(ElementByIndex(prop, 7), aValue2);
end;

// return property
Result := prop;
end;

function Initialize: integer;
var
frm: TForm;
btnOk, btnCancel: TButton;
chkNamePatcher, chkKeywordPatcher, chkValuePatcher, chkPenPatcher: TCheckBox;
label1 : TLabel;

begin
frm := TForm.Create(nil);
try
frm.Caption := 'BLD - Patcher';
frm.Width := 250;
frm.Height := 190;
frm.Position := poScreenCenter;
frm.BorderStyle := bsDialog;

label1 := TLabel.Create(frm);
label1.Caption := 'Choose one option:';
label1.Parent := frm;
label1.Top := 16;
label1.Left := 12; 

btnOk := TButton.Create(frm);
btnOk.Parent := frm;
btnOk.Caption := 'OK';
btnOk.ModalResult := mrOk;
btnOk.Left := frm.Width - 180;
btnOk.Top := frm.Height - 64;

btnCancel := TButton.Create(frm);
btnCancel.Parent := frm;
btnCancel.Caption := 'Cancel';
btnCancel.ModalResult := mrCancel;
btnCancel.Left := btnOk.Left + btnOk.Width + 12;
btnCancel.Top := btnOk.Top;

chkNamePatcher := TCheckBox.Create(frm);
chkNamePatcher.Parent := frm;
chkNamePatcher.Top := Label1.Top+24;
chkNamePatcher.Left := 12;
chkNamePatcher.Width := 150;
chkNamePatcher.Caption := 'Name patcher';
chkNamePatcher.Checked := True;

chkPenPatcher := TCheckBox.Create(frm);
chkPenPatcher.Parent := frm;
chkPenPatcher.Top := Label1.Top+24;
chkPenPatcher.Left := 140;
chkPenPatcher.Width := 150;
chkPenPatcher.Caption := 'ArmorPen Patcher';
chkPenPatcher.Checked := False;

chkKeywordPatcher := TCheckBox.Create(frm);
chkKeywordPatcher.Parent := frm;
chkKeywordPatcher.Top := chkNamePatcher.Top + 24;
chkKeywordPatcher.Left := chkNamePatcher.Left;
chkKeywordPatcher.Width := 150;
chkKeywordPatcher.Caption := 'Keyword patcher';

chkValuePatcher := TCheckBox.Create(frm);
chkValuePatcher.Parent := frm;
chkValuePatcher.Top := chkKeywordPatcher.Top + 24;
chkValuePatcher.Left := chkKeywordPatcher.Left;
chkValuePatcher.Width := 150;
chkValuePatcher.Caption := 'Value patcher';

// abort script if OK button was not pressed
if frm.ShowModal <> mrOk then begin
  Result := 1;
  Exit;
end;

bNamePatcher := chkNamePatcher.Checked;
bKeywordPatcher := chkKeywordPatcher.Checked;
bValuePatcher := chkValuePatcher.Checked;
bArmorPenPatcher := chkPenPatcher.Checked;

if bArmorPenPatcher then 
begin
    if not InputQuery('Enter', 'Armor Penetration Value', armorPenValueS) then begin
    Exit;
    end;
end;//end bArmorPenPatcher

finally
frm.Free;
end;
end;

function Process(e: IInterface): Integer;
var
temp:string;
tempint, j, i, weaponType: integer;
kwda: IInterface;
pistol, rifle, ballistic, rec0, rec1, rec2, rec3, recL, recAut, ammoFound: boolean;
props, prop: IInterface;
tempD : double;

begin

//##############//##############
//Start Weapon patching
//##############//##############
//


  if Signature(e) = 'WEAP' then
  begin
    kwda := ElementBySignature(e, 'KWDA');
    weaponType := 0;
    for j := 0 to ElementCount(kwda) - 1 do
    begin  
          // if (IntToHex(GetNativeValue(ElementByIndex(kwda, j)), 8) = '0004A0A0') then 
          // begin
          //   pistol := true;
          //   rifle := false;
          // end;
          if (IntToHex(GetNativeValue(ElementByIndex(kwda, j)), 8) = '0004A0A1') 
      OR (IntToHex(GetNativeValue(ElementByIndex(kwda, j)), 8) = '001E325D')
      OR (IntToHex(GetNativeValue(ElementByIndex(kwda, j)), 8) = '00226455') then // WeaponTypeRifle
          
      begin
            weaponType := 0;
          end;
          if (IntToHex(GetNativeValue(ElementByIndex(kwda, j)), 8) = '00092A86') then // WeaponTypeBallistic
          begin
            ballistic := true;
          end;      
    end;

  if ballistic then //Patches only weapons with the keyword WeaponTypeBallistic. {FORMID: 00092A86} 
  begin
      SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - OutOfRange Mult'), '0.75');
      SetEditValue(ElementByPath(e, 'DNAM - Data\On Hit'), 'No dismember/explode');

      if weaponType>0 then
      SetEditValue(ElementByPath(e, 'DNAM - Data\Reload Speed'), '0.75')
      else
      SetEditValue(ElementByPath(e, 'DNAM - Data\Reload Speed'), '0.83');


      if (IntToHex(GetNativeValue(ElementByPath(e, 'DNAM - Data\Ammo')), 8) = '0001F66C' ) then //5mm
      begin
        tempint := random(3)+37+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
      ammoFound := true;
      end;

      if (IntToHex(GetNativeValue(ElementByPath(e, 'DNAM - Data\Ammo')), 8) = '0004CE87' ) then //.38
      begin
        tempint := random(4)+38+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
      ammoFound := true;
      end;
     
      if (IntToHex(GetNativeValue(ElementByPath(e, 'DNAM - Data\Ammo')), 8) = '0001F276' ) then //10mm
      begin
        tempint := random(4)+40+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
      ammoFound := true;
      end;
      
      if (IntToHex(GetNativeValue(ElementByPath(e, 'DNAM - Data\Ammo')), 8) = '0009221C' ) then //.44
      begin
        tempint := random(4)+61+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
      ammoFound := true;
      end;
      
      if (IntToHex(GetNativeValue(ElementByPath(e, 'DNAM - Data\Ammo')), 8) = '0001F66A' ) then //.45
      begin
        tempint := random(4)+42+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
      end;
      if (IntToHex(GetNativeValue(ElementByPath(e, 'DNAM - Data\Ammo')), 8) = '0001F673' ) then //Shells
      begin
        tempint := random(6)+85+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
        SetEditValue(ElementByPath(e, 'DNAM - Data\On Hit'), 'Explode only');
      ammoFound := true;
      end;
      if (IntToHex(GetNativeValue(ElementByPath(e, 'DNAM - Data\Ammo')), 8) = '0001F278' ) then //5.56
      begin
        tempint := random(4)+44+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
      ammoFound := true;
      end;
      if (IntToHex(GetNativeValue(ElementByPath(e, 'DNAM - Data\Ammo')), 8) = '0001F66B' ) then //.308
      begin
        tempint := random(7)+75+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
      ammoFound := true;
      end;
      if (pos('DLC04_Ammo_HandmadeRound',GetEditValue(ElementByPath(e, 'DNAM - Data\Ammo'))) > 0) then //7.62
      begin
        tempint := random(4)+52+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
      ammoFound := true;
      AddMessage('Add an armor penetration value of 20 for an OMOD(all Barrels or all Grips) of your choice with the Armor Penetration Patcher.'+ GetEditValue(ElementBySignature(e, 'FULL')));
      end;
      if not ammoFound then 
      begin
        tempint := random(4)+40+weaponType;
        SetEditValue(ElementByPath(e, 'DNAM - Data\Damage - Base'), IntToStr(tempint) );
        AddMessage('Custom Ammo('+GetEditValue(ElementByPath(e, 'DNAM - Data\Ammo'))+') in Weapon: '+ GetEditValue(ElementBySignature(e, 'FULL'))+' please adjust to your liking. Standard values have been set.');
      end;
  AddMessage('Ballistic Weapon Updated: '+ GetEditValue(ElementBySignature(e, 'FULL')));
  end; //end Ballistic

  end; //end Signature WEAP

//##############//##############
//Start OMOD patching
//##############//##############
//

  if Signature(e) = 'OMOD' then
  begin


//##############//##############
//Start automatic receivers
//##############//##############
//


  // getting Properties array inside DATA subrecord

props := ElementByPath(e, 'DATA\Properties');

// iterating over properties, indexed starting from 0
for i := 0 to Pred(ElementCount(props)) do
begin
// getting Nth property
prop := ElementByIndex(props, i);
if GetElementEditValues(prop, 'Value Type') = 'FormID,Int' then
begin
if( (IntToHex(GetNativeValue(ElementByIndex(prop, 6)), 8) = '00163038' ) ) then begin //StandardReceiverKeyword
rec0:=true; end;
if( (IntToHex(GetNativeValue(ElementByIndex(prop, 6)), 8) = '0016303D' ) ) then begin //More1ReceiverKeyword
rec1:=true; end;
if( (IntToHex(GetNativeValue(ElementByIndex(prop, 6)), 8) = '00163040' ) ) then begin //More2ReceiverKeyword
rec2:=true; end;
if( (IntToHex(GetNativeValue(ElementByIndex(prop, 6)), 8) = '00163042' ) ) then begin //More3ReceiverKeyword
rec3:=true; end;
if( (IntToHex(GetNativeValue(ElementByIndex(prop, 6)), 8) = '0002C874' ) OR (IntToHex(GetNativeValue(ElementByIndex(prop, 6)), 8) = '0023844D' ) ) then begin //AutomaticReceiverKeyword
recAut:=true; end;
if( (IntToHex(GetNativeValue(ElementByIndex(prop, 6)), 8) = '00163039' ) OR (IntToHex(GetNativeValue(ElementByIndex(prop, 6)), 8) = '0023844D' ) ) then begin //LightReceiverKeyword
recL:=true; end;
end;
if GetElementEditValues(prop, 'Property') = 'AttackDamage' then
begin

    tempD := strtofloat(GetEditValue(ElementByIndex(prop, 6)));
    if( tempD > 0.10 ) then begin //StandardReceiverKeyword
        temp:='0.20'; end;
    if( tempD > 0.25  ) then begin //StandardReceiverKeyword
        temp:='0.30'; end;
    if( tempD > 0.50  ) then begin //StandardReceiverKeyword
        temp:='0.40'; end;
    if( tempD = (-0.10) ) then begin //StandardReceiverKeyword
        temp:='0.05'; end;
    if( tempD < (-0.10) ) then begin //StandardReceiverKeyword
        temp:='0.00'; end;
    if( tempD > 0.75  ) then begin //StandardReceiverKeyword
        temp:='0.45'; end;                                                          
end;

end;

if bNamePatcher then 
begin

    if(((pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND (pos('utomatic',GetEditValue(ElementBySignature(e, 'EDID'))) > 0)) OR recAut)  then   
    begin
      if((pos('utomatic1',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) OR (pos('Automatic Receiver',GetEditValue(ElementBySignature(e, 'FULL'))) > 0) OR (pos('Armor Piercing Automatic Receiver',GetEditValue(ElementBySignature(e, 'FULL'))) > 0))  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Improved rate of fire.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-3.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.00', '', true);

      end;

      if(((pos('utomatic1',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND (pos('amage1',GetEditValue(ElementBySignature(e, 'EDID'))) > 0)) OR (pos('Hardened',GetEditValue(ElementBySignature(e, 'FULL'))) > 0) OR (pos('Hardened Piercing Auto Receiver',GetEditValue(ElementBySignature(e, 'FULL'))) > 0) )  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Improved rate of fire and damage.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-3.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.15', '', true);

      end;

      if(((pos('utomatic1',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND (pos('amage2',GetEditValue(ElementBySignature(e, 'EDID'))) > 0)) OR (pos('Powerful',GetEditValue(ElementBySignature(e, 'FULL'))) > 0) )  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Superior damage and rate of fire.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-3.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.30', '', true);

      end;

      if((pos('utomatic2',GetEditValue(ElementBySignature(e, 'EDID'))) > 0 ) OR (pos('apid',GetEditValue(ElementBySignature(e, 'FULL'))) > 0) )  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Superior damage, rate of fire and range.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-1.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.15', '', true);

      end;
     // AddMessage('Found Automatic Receiver!' + GetEditValue(ElementBySignature(e, 'EDID')));
    end;//end automatic receiver


//##############//##############
//Start non automatic receivers
//##############//##############
//

    if((pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND not(pos('utomatic',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) OR ((pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND  not recAut))  then   
    begin
      if(pos('Light Frame Receiver',GetEditValue(ElementBySignature(e, 'FULL'))) > 0 OR (pos('ighter',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) OR (pos('Light Frame Receiver',GetEditValue(ElementBySignature(e, 'FULL'))) > 0))  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Lighter weight. Better damage.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.05', '', true);

      end;
      if(pos('ardened',GetEditValue(ElementBySignature(e, 'FULL'))) > 0 OR (pos('oreDamage1',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) OR (pos('Hardened Receiver',GetEditValue(ElementBySignature(e, 'FULL'))) > 0))  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Better damage.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.20', '', true);

      end;

      if((pos('owerful',GetEditValue(ElementBySignature(e, 'FULL'))) > 0) OR (pos('oreDamage2',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) OR (pos('Powerful Receiver',GetEditValue(ElementBySignature(e, 'FULL'))) > 0))  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Superior damage.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.30', '', true);

      end;

      if((pos('Calibrated Powerful Receiver',GetEditValue(ElementBySignature(e, 'FULL'))) > 0) OR (pos('oreDamage2_and_BetterCriticals',GetEditValue(ElementBySignature(e, 'EDID'))) > 0)  )  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Superior damage. Better critical shot damage and accuracy.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.30', '', true);

      end;

      if((pos('dvanced',GetEditValue(ElementBySignature(e, 'FULL'))) > 0) OR (pos('oreDamage3',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) )  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Exceptional damage. More sensitive trigger. Better rate of fire.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.40', '', true);

      end;
      //AddMessage('Found Normal Receiver! ' + GetEditValue(ElementBySignature(e, 'EDID')));
    end;//end NOT automatic receiver
  end;//end NamePatcher



if bKeywordPatcher then 
begin

    if(((pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND (pos('utomatic',GetEditValue(ElementBySignature(e, 'EDID'))) > 0)) OR recAut)  then   
    begin
      if recAut  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Improved rate of fire.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-3.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.00', '', true);

      end;
      if rec0  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Improved rate of fire.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-3.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.00', '', true);

      end;

      if rec1  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Improved rate of fire and damage.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-3.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.15', '', true);

      end;

      if rec2  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Superior damage and rate of fire.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-3.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.30', '', true);

      end;

      if rec3  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Superior damage, rate of fire and range.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-1.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.15', '', true);

      end;
     // AddMessage('Found Automatic Receiver!' + GetEditValue(ElementBySignature(e, 'EDID')));
    end;//end automatic receiver


//##############//##############
//Start non automatic receivers
//##############//##############
//

    if((pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND not(pos('utomatic',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) OR ((pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND  not recAut))  then   
    begin
      if recL  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Lighter weight. Better damage.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.05', '', true);

      end;
      if rec1  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Better damage.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.20', '', true);

      end;

      if rec2  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Superior damage.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.30', '', true);

      end;

      if rec2  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Superior damage. Better critical shot damage and accuracy.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.30', '', true);

      end;

      if rec3  then   
      begin
      SetEditValue(ElementByName(e, 'DESC - Description'), 'Exceptional damage. More sensitive trigger. Better rate of fire.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', '0.40', '', true);

      end;
      //AddMessage('Found Normal Receiver! ' + GetEditValue(ElementBySignature(e, 'EDID')));
    end;//end NOT automatic receiver
  end;//end KeywordPatcher



if bValuePatcher then 
begin

    if(((pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND (pos('utomatic',GetEditValue(ElementBySignature(e, 'EDID'))) > 0)) OR recAut)  then   
    begin

      //SetEditValue(ElementByName(e, 'DESC - Description'), 'Improved rate of fire.');
      SetOMODProperty(e, 'MaxRange', 'MUL+ADD', 'Float', '-3.5', '', True);
      SetOMODProperty(e, 'MinRange', 'MUL+ADD', 'Float', '-1.0', '', True);
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', temp, '', true);
    end;//end automatic receiver


//##############//##############
//Start non automatic receivers
//##############//##############
//

    if((pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND not(pos('utomatic',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) OR ((pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) > 0) AND  not recAut))  then   
    begin

      //SetEditValue(ElementByName(e, 'DESC - Description'), 'Better damage.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', temp, '', false);
    
    end;//end NOT automatic receiver

    if(pos('eceiver',GetEditValue(ElementBySignature(e, 'EDID'))) = 0 )  then   
    begin
      //SetEditValue(ElementByName(e, 'DESC - Description'), 'Better damage.');
      SetOMODProperty(e, 'AttackDamage', 'MUL+ADD', 'Float', temp, '', false);
    end;

  end;//end ValuePatcher

if bArmorPenPatcher then 
begin
  SetOMODProperty(e, 'ActorValues', 'ADD', 'FormID,Float', '00097341', armorPenValueS, True);
  SetOMODProperty(e, 'Enchantments', 'ADD', 'FormID,Int', '001F4425', '1', True);

end;//end armorPenPatcher

  end;

end;

end.

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center