Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- Ruddy88's VIS-G Auto Patcher
- FALLOUT 4
- Aim: This script utility will automatically add all valid items for DEF_UI's tag system to a single patch ESP.
- The items will attempt to auto categorise themself in line with Gambit's VIS-G categorisation.
- Items that can not be accurately categorised will still be assigned a generic category as close to accurate as it can.
- No valid items will be ignored, so users are free to manually tweak the patch afterward with all valid items in one
- convenient location.
- Requires: FO4Edit, MXPF (for Skyrim, Works in Fallout4).
- Credits:
- MatorTheEternal (For MXPF and helping me throughout my entire modding life so far)
- Valdacil (for VIS)
- Gambit (For his contributions and for VIS-G)
- Many others from many discords, too many to name.
- }
- unit UserScript;
- // Import MXPF functions
- uses 'lib\mxpf';
- var
- UserCancelled, ResetPatch, bVIS, bAWKCR, bSkipPatched, bWeightless: Boolean;
- // Options dialogue form prep
- procedure PrepareDialog(frm: TForm; caption: String; height, width: Integer);
- begin
- frm.BorderStyle := bsDialog;
- frm.Height := height;
- frm.Width := width;
- frm.Position := poScreenCenter;
- frm.Caption := caption;
- end;
- // Sets layout for Options dialogue form
- procedure ShowForm;
- var
- frm: TForm;
- lblPrompt: TLabel;
- cbVIS, cbAWKCR, cbSkipPatched, cbWeightless: TCheckBox;
- btnNewPatch, btnAmend, btnCancel: TButton;
- i: integer;
- begin
- frm := TForm.Create(nil);
- try
- // Create checkboxes
- PrepareDialog(frm, 'R88 VIS-G Patcher Options', 260, 260);
- lblPrompt := ConstructLabel(frm, frm, 16, 14, 40, 260 - 32, 'Please select your preferences', '');
- cbVIS := ConstructCheckbox(frm, frm, lblPrompt.Top + 38, 50, 150, 'Run VIS patcher?', cbChecked, '');
- cbVIS.ShowHint := true;
- cbVIS.Hint := 'This enables the VIS patcher to automatically update item names in line with VIS-G and DEF_UIs icon tags';
- cbAWKCR := ConstructCheckbox(frm, frm, cbVIS.Top + 20, 50, 150, 'Run AWKCR Workbench patcher?', cbChecked, '');
- cbAWKCR.ShowHint := true;
- cbAWKCR.Hint := 'This enables the AWKCR patcher to automatically add item recipes to the AWKCR workbenches where appropriate. Will use existing category or will assign to "Other" category';
- cbSkipPatched := ConstructCheckbox(frm, frm, cbAWKCR.Top + 20, 50, 150, 'Skip already patched records', cbChecked, '');
- cbSkipPatched.ShowHint := true;
- cbSkipPatched.Hint := 'NOT IMPLEMENTED: This gives you the option to skip records that have already been patched or to override all valid records with the scripts categorisation.';
- cbWeightless := ConstructCheckbox(frm, frm, cbSkipPatched.Top + 20, 50, 150, 'Weightless Scrap?', cbChecked, '');
- cbWeightless.ShowHint := true;
- cbWeightless.Hint := 'This makes mod-added junk and scrap weightless';
- btnNewPatch := TButton.Create(frm);
- btnNewPatch.Parent := frm;
- btnNewPatch.Left := frm.Width div 2 - btnNewPatch.Width - 4;
- btnNewPatch.Top := cbWeightless.Top + 35;
- btnNewPatch.Caption := 'New Patch';
- btnNewPatch.ModalResult := mrYes;
- btnNewPatch.ShowHint := true;
- btnNewPatch.Hint := 'Choose this if you are generating a patch for the first time or if you would like to RESET and clear all items in an existing patch.';
- btnCancel := TButton.Create(frm);
- btnCancel.Parent := frm;
- btnCancel.Left := btnNewPatch.Left + btnNewPatch.Width + 8;
- btnCancel.Top := btnNewPatch.Top;
- btnCancel.Caption := 'Cancel';
- btnCancel.ModalResult := mrCancel;
- i := frm.ShowModal;
- UserCancelled := i = 2;
- if not UserCancelled then begin
- bVIS := cbVIS.Checked;
- bAWKCR := cbAWKCR.Checked;
- bSkipPatched := cbSkipPatched.Checked;
- bWeightless := cbWeightless.Checked;
- end;
- finally
- frm.Free;
- end;
- end;
- ////////////////////////////////////////
- // Add any other custom functions here//
- ////////////////////////////////////////
- //Function to write TAG string to beginning of existing string.
- function AddTagString(sTag, sPath: String; newRec: IInterface): IInterface;
- var
- oldString: String;
- begin
- oldString := geev(newRec, sPath);
- seev(newRec, sPath, (sTag + ' ' + oldString));
- end;
- /////////////////
- // Main Script //
- /////////////////
- function Initialize: Integer;
- var
- i: Integer;
- rec, newRec: IInterface;
- sFiles, sTag: String;
- begin
- InitializeMXPF;
- mxLoadMasterRecords := true;
- mxSkipPatchedRecords := true;
- mxLoadWinningOverrides := true;
- PatchFileByAuthor('R88_VIS-G_PatchFile');
- ShowForm;
- if UserCancelled then begin
- AddMessage('User cancelled patching');
- AddMessage('Operation cancelled. No patch generated');
- exit;
- end;
- ShowMessage('Script Initialising. Patching can take some time depending on the size of your mod list. Please be patient.');
- //ALCH Sorting
- LoadRecords('ALCH');
- RemoveNode(GroupBySignature(mxPatchFile, 'ALCH'));
- for i := MaxRecordIndex downto 0 do begin
- rec := GetRecord(i);
- newRec := CopyRecordToPatch(i);
- sTag := '(Tag)';
- AddTagString(sTag, 'FULL - Name', newRec);
- end;
- AddMastersToPatch;
- AddMessage('ALCH records Patched.');
- //AMMO Sorting
- LoadRecords('AMMO');
- RemoveNode(GroupBySignature(mxPatchFile, 'AMMO'));
- for i := MaxRecordIndex downto 0 do begin
- rec := GetRecord(i);
- newRec := CopyRecordToPatch(i);
- sTag := '(Tag)';
- AddTagString(sTag, 'FULL - Name', newRec);
- end;
- AddMastersToPatch;
- AddMessage('AMMO records Patched.');
- //ARMO Sorting
- LoadRecords('ARMO');
- RemoveNode(GroupBySignature(mxPatchFile, 'ARMO'));
- for i := MaxRecordIndex downto 0 do begin
- rec := GetRecord(i);
- newRec := CopyRecordToPatch(i);
- sTag := '(Tag)';
- AddTagString(sTag, 'FULL - Name', newRec);
- end;
- AddMastersToPatch;
- AddMessage('ARMO records Patched.');
- //BOOK Sorting
- LoadRecords('BOOK');
- RemoveNode(GroupBySignature(mxPatchFile, 'BOOK'));
- for i := MaxRecordIndex downto 0 do begin
- rec := GetRecord(i);
- newRec := CopyRecordToPatch(i);
- sTag := '(Tag)';
- AddTagString(sTag, 'FULL - Name', newRec);
- end;
- AddMastersToPatch;
- AddMessage('BOOK records Patched.');
- //KEYM Sorting
- LoadRecords('KEYM');
- RemoveNode(GroupBySignature(mxPatchFile, 'KEYM'));
- for i := MaxRecordIndex downto 0 do begin
- rec := GetRecord(i);
- newRec := CopyRecordToPatch(i);
- sTag := '(Tag)';
- AddTagString(sTag, 'FULL - Name', newRec);
- end;
- AddMastersToPatch;
- AddMessage('KEYM records Patched.');
- //MISC Sorting
- LoadRecords('MISC');
- RemoveNode(GroupBySignature(mxPatchFile, 'MISC'));
- for i := MaxRecordIndex downto 0 do begin
- rec := GetRecord(i);
- newRec := CopyRecordToPatch(i);
- sTag := '(Tag)';
- AddTagString(sTag, 'FULL - Name', newRec);
- end;
- AddMastersToPatch;
- AddMessage('MISC records Patched.');
- //NOTE Sorting
- LoadRecords('NOTE');
- RemoveNode(GroupBySignature(mxPatchFile, 'NOTE'));
- for i := MaxRecordIndex downto 0 do begin
- rec := GetRecord(i);
- newRec := CopyRecordToPatch(i);
- sTag := '(Tag)';
- AddTagString(sTag, 'FULL - Name', newRec);
- end;
- AddMastersToPatch;
- AddMessage('NOTE records Patched.');
- //WEAP Sorting
- LoadRecords('WEAP');
- RemoveNode(GroupBySignature(mxPatchFile, 'WEAP'));
- for i := MaxRecordIndex downto 0 do begin
- rec := GetRecord(i);
- newRec := CopyRecordToPatch(i);
- sTag := '(Tag)';
- AddTagString(sTag, 'FULL - Name', newRec);
- end;
- AddMastersToPatch;
- AddMessage('WEAP records Patched.');
- // Cleanup MXPF
- CleanMasters(mxPatchFile);
- PrintMXPFReport;
- FinalizeMXPF;
- ShowMessage('Patching Complete.');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement