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;
- sTag: String;
- // 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; rec: IInterface): IInterface;
- var
- oldString: String;
- begin
- oldString := geev(rec, sPath);
- seev(rec, sPath, (sTag + ' ' + oldString));
- end;
- function SetWeightless(rec: IInterface; sPath: String;):IInterface;
- begin
- SetElementEditValues(rec, sPath, 0);
- end;
- ////////////////////////////
- // GROUP Filter Functions //
- ////////////////////////////
- function filterAMMO(i: Integer; rec: IInterface): IInterface;
- begin
- if (GetElementEditValues(rec, 'Record Header\Record Flags\Non-Playable') = '1') then
- RemoveRecord(i);
- end;
- function filterARMO(i: Integer; rec: IInterface): IInterface;
- begin
- end;
- function filterMISC(i: Integer; rec: IInterface): IInterface;
- begin
- end;
- function filterWEAP(i: Integer; rec: IInterface): IInterface;
- begin
- end;
- ///////////////////////////
- // GROUP Patch Functions //
- ///////////////////////////
- function patchALCH(i: Integer; rec: IInterface):IInterface;
- begin
- sTag := '(Alch)';
- end;
- function patchAMMO(i: Integer; rec: IInterface):IInterface;
- begin
- sTag := '(Ammo)';
- end;
- function patchARMO(i: Integer; rec: IInterface):IInterface;
- begin
- sTag := '(Armo)';
- end;
- function patchBOOK(i: Integer; rec: IInterface):IInterface;
- begin
- sTag := '(Book)';
- end;
- function patchKEYM(i: Integer; rec: IInterface):IInterface;
- begin
- sTag := '(Keym)';
- end;
- function patchMISC(i: Integer; rec: IInterface):IInterface;
- begin
- sTag := '(Misc)';
- end;
- function patchNOTE(i: Integer; rec: IInterface):IInterface;
- begin
- sTag := '(Note)';
- end;
- function patchWEAP(i: Integer; rec: IInterface):IInterface;
- begin
- sTag := '(Weap)';
- end;
- /////////////////
- // Main Script //
- /////////////////
- function Initialize: Integer;
- var
- i: Integer;
- rec: IInterface;
- sFiles: String;
- begin
- // Call MXPF init functions and set MXPF prefs
- InitializeMXPF;
- mxLoadMasterRecords := true;
- mxSkipPatchedRecords := false;
- mxLoadWinningOverrides := true;
- PatchFileByAuthor('R88_VIS-G_PatchFile');
- // Call form for user options.
- 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.');
- // Load valid records and remove groups from previous run patch.
- LoadRecords('WEAP');
- LoadRecords('NOTE');
- LoadRecords('MISC');
- LoadRecords('KEYM');
- LoadRecords('BOOK');
- LoadRecords('ARMO');
- LoadRecords('AMMO');
- LoadRecords('ALCH');
- RemoveNode(GroupBySignature(mxPatchFile, 'ALCH'));
- RemoveNode(GroupBySignature(mxPatchFile, 'AMMO'));
- RemoveNode(GroupBySignature(mxPatchFile, 'ARMO'));
- RemoveNode(GroupBySignature(mxPatchFile, 'BOOK'));
- RemoveNode(GroupBySignature(mxPatchFile, 'KEYM'));
- RemoveNode(GroupBySignature(mxPatchFile, 'MISC'));
- RemoveNode(GroupBySignature(mxPatchFile, 'NOTE'));
- RemoveNode(GroupBySignature(mxPatchFile, 'WEAP'));
- // Filter out unnecessary records on groups that may contain invalid records for tagging.
- for i := MaxrecordIndex downto 0 do begin
- rec := GetRecord(i);
- if (geev(rec, 'Record Header\Signature') = 'AMMO') then
- filterAMMO(i, rec)
- else if (geev(rec, 'Record Header\Signature') = 'ARMO') then
- filterARMO(i, rec)
- else if (geev(rec, 'Record Header\Signature') = 'MISC') then
- filterMISC(i, rec)
- else if (geev(rec, 'Record Header\Signature') = 'WEAP') then
- filterWEAP(i, rec);
- end;
- // Copy remaining records to patch file.
- CopyRecordsToPatch;
- // Patch Files
- for i := 0 to MaxrecordIndex do begin
- rec := GetPatchRecord(i);
- if (geev(rec, 'Record Header\Signature') = 'ALCH') then
- begin
- patchALCH(i, rec);
- AddTagString(sTag, 'FULL - Name', rec);
- end
- else if (geev(rec, 'Record Header\Signature') = 'AMMO') then
- begin
- patchAMMO(i, rec);
- AddTagString(sTag, 'FULL - Name', rec);
- end
- else if (geev(rec, 'Record Header\Signature') = 'ARMO') then
- begin
- patchARMO(i, rec);
- AddTagString(sTag, 'FULL - Name', rec);
- end
- else if (geev(rec, 'Record Header\Signature') = 'BOOK') then
- begin
- patchBOOK(i, rec);
- AddTagString(sTag, 'FULL - Name', rec);
- end
- else if (geev(rec, 'Record Header\Signature') = 'KEYM') then
- begin
- patchKEYM(i, rec);
- AddTagString(sTag, 'FULL - Name', rec);
- end
- else if (geev(rec, 'Record Header\Signature') = 'MISC') then
- begin
- patchMISC(i, rec);
- AddTagString(sTag, 'FULL - Name', rec);
- end
- else if (geev(rec, 'Record Header\Signature') = 'NOTE') then
- begin
- patchNOTE(i, rec);
- AddTagString(sTag, 'FULL - Name', rec);
- end
- else if (geev(rec, 'Record Header\Signature') = 'WEAP') then
- begin
- patchWEAP(i, rec);
- AddTagString(sTag, 'FULL - Name', rec);
- end;
- end;
- // Cleanup MXPF
- CleanMasters(mxPatchFile);
- PrintMXPFReport;
- FinalizeMXPF;
- ShowMessage('Patching Complete.');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement