Skip to content

Instantly share code, notes, and snippets.

@jfmherokiller
Created January 14, 2019 00:48
Show Gist options
  • Save jfmherokiller/db2187f57bccf502e1fa22739a709b90 to your computer and use it in GitHub Desktop.
Save jfmherokiller/db2187f57bccf502e1fa22739a709b90 to your computer and use it in GitHub Desktop.
Renaton Possible POC script for xedit
unit Unit3;
interface
implementation
{
New script template, only shows processed records
Assigning any nonzero value to Result will terminate script
}
//uses xEditAPI, Classes, SysUtils, StrUtils, Windows;
uses 'mteFunctions';
var
NewFile: IwbFile;
indexer: Integer;
//procedure seev(cool1: Iinterface; cool2: String; cool3: String);
//begin
//end;
procedure SetFlag(elem: Iinterface; flagName: string; flagValue: boolean);
var
sl: TStringList;
i: Integer;
f, f2: Cardinal;
begin
sl := TStringList.Create;
sl.Text := FlagValues(elem);
f := GetNativeValue(elem);
for i := 0 to Pred(sl.Count) do
if SameText(sl[i], flagName) then
begin
if flagValue then
f2 := f or (1 shl i)
else
f2 := f and not(1 shl i);
if f <> f2 then
SetNativeValue(elem, f2);
Break;
end;
sl.Free;
end;
function Initialize: Integer;
begin
NewFile := AddNewFileName('RenaVegasNPC.esp');
for indexer := 0 to FileCount - 1 do
begin
if pos('.exe', GetFileName(FileByIndex(indexer))) = 0 then
begin
AddMasterIfMissing(NewFile, GetFileName(FileByIndex(indexer)), True)
end;
end;
AddMasterIfMissing(NewFile, 'FalloutNV.esm');
Add(NewFile, 'NPC_', True);
Result := 0;
end;
// called for every record selected in xEdit
function Process(e: Iinterface): Integer;
var
flo: Iinterface;
i: Integer;
NewFile: IwbFile;
CopiedPart: IwbElement;
entry, list: Iinterface;
inum: Integer;
begin
Result := 0;
if signature(e) = 'NPC_' then
begin
if GetElementEditValues(e, 'EDID') <> 'Player' then
begin
AddMessage('Processing: ' + FullPath(e));
CopiedPart := wbCopyElementToFile(e, NewFile, False, True);
if not Assigned(CopiedPart) then
begin
AddMessage('Can''t copy base record as new');
Result := 1;
Exit;
end;
// comment this out if you don't want those messages
flo := ElementAssign(ElementByPath(CopiedPart, 'Items'), HighInteger,
nil, True);
seev(flo, 'CNTO\Count', '1');
seev(flo, 'CNTO\Item',
'RenamonsArmorGlovess "Renamon''s Gloves and Armor" [ARMO:1200E508]');
SetFlag(ElementByPath(CopiedPart, 'ACBS - Configuration\Flags'),
'Female', True);
list := ElementByPath(CopiedPart, 'Head Parts');
inum := ElementCount(list);
for i := inum - 1 downto 0 do
Begin
entry := ElementByIndex(list, i);
// AddMessage('Removing ' + name);
RemoveByIndex(list, i, True);
end;
list := ElementByPath(CopiedPart, 'FaceGen Data');
inum := ElementCount(list);
for i := inum - 1 downto 0 do
Begin
entry := ElementByIndex(list, i);
SetEditValue(entry,
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
+ '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
+ '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
+ ' 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00');
// AddMessage('Removing ' + name);
end;
SetElementEditValues(CopiedPart, 'HNAM', '');
SetElementEditValues(CopiedPart, 'ENAM', '');
// processing code goes here
end;
end;
end;
// Called after processing
// You can remove it if script doesn't require finalization code
function Finalize: Integer;
begin
CleanMasters(NewFile);
Result := 0;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment