Jump to content

[Request] Xedit script for adding additional races to ARMA Records


Recommended Posts

I'm wondering if anybody could make an XEdit script that will patch any selected Armor Addon records to include a specified "Additional Race" entry.

I just want a script that will apply this override (see image) to all selected ARMA records so that i don't have to do it manually for all of them.

 

 

Link to comment
Share on other sites

Try this. If you need to change the RACE FormID it's in the top of the script in the Initialize function. Change line 15, with slAddRACE.Add. If you want more than one RACE added, then add another line just like it with the proper FormID of the race you want added. Note that the file you run this on needs to have access to the form. So if it's not provided by that file it needs to have a master pointing to it. Also there is no checking to see if the base MNAM race points to the race you want to add, it will just add it to the MODL additional races list regardless. I borrowed this from another script and made some changes, I don't remember which one though.

 

 

{
  This script will add an additional race to the list of selected armor addons.
}
unit UserScript;

var
    slAddRACE: TStringList;

function Initialize: integer;
begin
    // races to add. needs to reflect currently loaded order.
    slAddRACE := TStringList.Create;
    slAddRACE.Add('01000F99'); // IKAROSRace
      
    // instead can also load keywords from a text file (one keyword per line)
    // ProgramPath - path were xEdit exe file is
    // DataPath    - path to game's Data folder
    // slAddRACE.LoadFromFile(ProgramPath + 'keywords.txt');
end;
    
function Process(e: IInterface): integer;
var
    race, k: IInterface;
    i, j: integer;
    exists: boolean;
begin
    Result := 0;

    // apply only to armor addons
    if Signature(e) <> 'ARMA' then
        Exit;


    race := ElementBySignature(e, 'MODL');
    if not Assigned(race) then
        race := Add(e, 'MODL', True);

    if not Assigned(race) then begin
        AddMessage('No modl keywords subrecord in ' + Name(e));
        Result := 1;
        Exit;
    end;

    // iterate through additional races
    for i := 0 to slAddRACE.Count - 1 do begin

        exists := false;
        for j := 0 to ElementCount(race) - 1 do
            if IntToHex(GetNativeValue(ElementByIndex(race, j)), 8) = slAddRACE[i] then begin
                exists := true;
                Break;
            end;

        // skip the rest of code in loop if race exists
        if exists then Continue;

        if (ElementCount(race) = 1) and (GetNativeValue(ElementByIndex(race, 0)) = 0) then
            SetEditValue(ElementByIndex(race, 0), slAddRACE[i])
        else begin
            // add a new race at the end of list
            // container, index, element, aOnlySK
            k := ElementAssign(race, HighInteger, nil, False);
            if not Assigned(k) then begin
                AddMessage('Can''t add race to ' + Name(e));
                Exit;
            end;
            SetEditValue(k, slAddRACE[i]);
        end;
    end;
  
    AddMessage('Processed: ' + Name(e));

end;

function Finalize: integer;
begin
  slAddRACE.Free;
end;

end.

 

Edited by BigAndFlabby
Link to comment
Share on other sites

  • 3 weeks later...

Try this. If you need to change the RACE FormID it's in the top of the script in the Initialize function. Change line 15, with slAddRACE.Add. If you want more than one RACE added, then add another line just like it with the proper FormID of the race you want added. Note that the file you run this on needs to have access to the form. So if it's not provided by that file it needs to have a master pointing to it. Also there is no checking to see if the base MNAM race points to the race you want to add, it will just add it to the MODL additional races list regardless. I borrowed this from another script and made some changes, I don't remember which one though.

 

 

{
  This script will add an additional race to the list of selected armor addons.
}
unit UserScript;

var
    slAddRACE: TStringList;

function Initialize: integer;
begin
    // races to add. needs to reflect currently loaded order.
    slAddRACE := TStringList.Create;
    slAddRACE.Add('01000F99'); // IKAROSRace
      
    // instead can also load keywords from a text file (one keyword per line)
    // ProgramPath - path were xEdit exe file is
    // DataPath    - path to game's Data folder
    // slAddRACE.LoadFromFile(ProgramPath + 'keywords.txt');
end;
    
function Process(e: IInterface): integer;
var
    race, k: IInterface;
    i, j: integer;
    exists: boolean;
begin
    Result := 0;

    // apply only to armor addons
    if Signature(e) <> 'ARMA' then
        Exit;


    race := ElementBySignature(e, 'MODL');
    if not Assigned(race) then
        race := Add(e, 'MODL', True);

    if not Assigned(race) then begin
        AddMessage('No modl keywords subrecord in ' + Name(e));
        Result := 1;
        Exit;
    end;

    // iterate through additional races
    for i := 0 to slAddRACE.Count - 1 do begin

        exists := false;
        for j := 0 to ElementCount(race) - 1 do
            if IntToHex(GetNativeValue(ElementByIndex(race, j)), 8) = slAddRACE[i] then begin
                exists := true;
                Break;
            end;

        // skip the rest of code in loop if race exists
        if exists then Continue;

        if (ElementCount(race) = 1) and (GetNativeValue(ElementByIndex(race, 0)) = 0) then
            SetEditValue(ElementByIndex(race, 0), slAddRACE[i])
        else begin
            // add a new race at the end of list
            // container, index, element, aOnlySK
            k := ElementAssign(race, HighInteger, nil, False);
            if not Assigned(k) then begin
                AddMessage('Can''t add race to ' + Name(e));
                Exit;
            end;
            SetEditValue(k, slAddRACE[i]);
        end;
    end;
  
    AddMessage('Processed: ' + Name(e));

end;

function Finalize: integer;
begin
  slAddRACE.Free;
end;

end.

 

Thank you! this worked exactly how i need it to :)

Link to comment
Share on other sites

  • 1 year later...
  • 5 months later...

I'm wondering if anybody could make an XEdit script that will patch any selected Armor Addon records to include a specified "Additional Race" entry.

I just want a script that will apply this override (see image) to all selected ARMA records so that i don't have to do it manually for all of them.

 

attachicon.gif Capture.JPG

i have absolutely no idea how to use this coding stuff. i followed someone's instructions to get armor to work with the IKAROS race in FO4, but it made changing my character's face unresponsive/completely broken, and the armor is still invisible on the new race's body.

Link to comment
Share on other sites

Try this. If you need to change the RACE FormID it's in the top of the script in the Initialize function. Change line 15, with slAddRACE.Add. If you want more than one RACE added, then add another line just like it with the proper FormID of the race you want added. Note that the file you run this on needs to have access to the form. So if it's not provided by that file it needs to have a master pointing to it. Also there is no checking to see if the base MNAM race points to the race you want to add, it will just add it to the MODL additional races list regardless. I borrowed this from another script and made some changes, I don't remember which one though.

 

 

{
  This script will add an additional race to the list of selected armor addons.
}
unit UserScript;

var
    slAddRACE: TStringList;

function Initialize: integer;
begin
    // races to add. needs to reflect currently loaded order.
    slAddRACE := TStringList.Create;
    slAddRACE.Add('01000F99'); // IKAROSRace
      
    // instead can also load keywords from a text file (one keyword per line)
    // ProgramPath - path were xEdit exe file is
    // DataPath    - path to game's Data folder
    // slAddRACE.LoadFromFile(ProgramPath + 'keywords.txt');
end;
    
function Process(e: IInterface): integer;
var
    race, k: IInterface;
    i, j: integer;
    exists: boolean;
begin
    Result := 0;

    // apply only to armor addons
    if Signature(e) <> 'ARMA' then
        Exit;


    race := ElementBySignature(e, 'MODL');
    if not Assigned(race) then
        race := Add(e, 'MODL', True);

    if not Assigned(race) then begin
        AddMessage('No modl keywords subrecord in ' + Name(e));
        Result := 1;
        Exit;
    end;

    // iterate through additional races
    for i := 0 to slAddRACE.Count - 1 do begin

        exists := false;
        for j := 0 to ElementCount(race) - 1 do
            if IntToHex(GetNativeValue(ElementByIndex(race, j)), 8) = slAddRACE[i] then begin
                exists := true;
                Break;
            end;

        // skip the rest of code in loop if race exists
        if exists then Continue;

        if (ElementCount(race) = 1) and (GetNativeValue(ElementByIndex(race, 0)) = 0) then
            SetEditValue(ElementByIndex(race, 0), slAddRACE[i])
        else begin
            // add a new race at the end of list
            // container, index, element, aOnlySK
            k := ElementAssign(race, HighInteger, nil, False);
            if not Assigned(k) then begin
                AddMessage('Can''t add race to ' + Name(e));
                Exit;
            end;
            SetEditValue(k, slAddRACE[i]);
        end;
    end;
  
    AddMessage('Processed: ' + Name(e));

end;

function Finalize: integer;
begin
  slAddRACE.Free;
end;

end.

 

Okay, pretend that i have absolutely NO experience with coding/scripting.

Link to comment
Share on other sites

Try this. If you need to change the RACE FormID it's in the top of the script in the Initialize function. Change line 15, with slAddRACE.Add. If you want more than one RACE added, then add another line just like it with the proper FormID of the race you want added. Note that the file you run this on needs to have access to the form. So if it's not provided by that file it needs to have a master pointing to it. Also there is no checking to see if the base MNAM race points to the race you want to add, it will just add it to the MODL additional races list regardless. I borrowed this from another script and made some changes, I don't remember which one though.

 

 

{
  This script will add an additional race to the list of selected armor addons.
}
unit UserScript;

var
    slAddRACE: TStringList;

function Initialize: integer;
begin
    // races to add. needs to reflect currently loaded order.
    slAddRACE := TStringList.Create;
    slAddRACE.Add('01000F99'); // IKAROSRace
      
    // instead can also load keywords from a text file (one keyword per line)
    // ProgramPath - path were xEdit exe file is
    // DataPath    - path to game's Data folder
    // slAddRACE.LoadFromFile(ProgramPath + 'keywords.txt');
end;
    
function Process(e: IInterface): integer;
var
    race, k: IInterface;
    i, j: integer;
    exists: boolean;
begin
    Result := 0;

    // apply only to armor addons
    if Signature(e) <> 'ARMA' then
        Exit;


    race := ElementBySignature(e, 'MODL');
    if not Assigned(race) then
        race := Add(e, 'MODL', True);

    if not Assigned(race) then begin
        AddMessage('No modl keywords subrecord in ' + Name(e));
        Result := 1;
        Exit;
    end;

    // iterate through additional races
    for i := 0 to slAddRACE.Count - 1 do begin

        exists := false;
        for j := 0 to ElementCount(race) - 1 do
            if IntToHex(GetNativeValue(ElementByIndex(race, j)), 8) = slAddRACE[i] then begin
                exists := true;
                Break;
            end;

        // skip the rest of code in loop if race exists
        if exists then Continue;

        if (ElementCount(race) = 1) and (GetNativeValue(ElementByIndex(race, 0)) = 0) then
            SetEditValue(ElementByIndex(race, 0), slAddRACE[i])
        else begin
            // add a new race at the end of list
            // container, index, element, aOnlySK
            k := ElementAssign(race, HighInteger, nil, False);
            if not Assigned(k) then begin
                AddMessage('Can''t add race to ' + Name(e));
                Exit;
            end;
            SetEditValue(k, slAddRACE[i]);
        end;
    end;
  
    AddMessage('Processed: ' + Name(e));

end;

function Finalize: integer;
begin
  slAddRACE.Free;
end;

end.

 

Okay, pretend that i have absolutely NO experience with coding/scripting.

Link to comment
Share on other sites

I think you only need to set the Armor Race of your custom race to the race from which you want to use the armor, so you wouldn't need to change the armor records.

If your custom race should use human armor then you should set Armor Race to Human.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...