From 5a51afdf3ff9743ba21cc77fdaffdee4ca6a4b15 Mon Sep 17 00:00:00 2001 From: zilav Date: Wed, 22 Mar 2017 09:54:03 +0300 Subject: [PATCH] [FO4] Updated TERM COCT serves as a flag, must be conflict resolved. New FO4 script to create a patch disabling PreVis in exterior cells. --- Edit Scripts/Fallout4 - Disable PreVis.pas | 73 +++++++++++++++++++ ...lout4 - Filter for precombined statics.pas | 8 +- wbDefinitionsFO4.pas | 9 ++- wbHelpers.pas | 18 ++--- 4 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 Edit Scripts/Fallout4 - Disable PreVis.pas diff --git a/Edit Scripts/Fallout4 - Disable PreVis.pas b/Edit Scripts/Fallout4 - Disable PreVis.pas new file mode 100644 index 000000000..097bc82c1 --- /dev/null +++ b/Edit Scripts/Fallout4 - Disable PreVis.pas @@ -0,0 +1,73 @@ +{ + Disable PreVis in selected exterior worldspaces/cells. + Supports Fallout 4 only. +} +unit FO4DisableExteriorPreVis; + +var + plugin: IInterface; + +function Process(e: IInterface): Integer; +var + r: IInterface; +begin + if Signature(e) <> 'CELL' then + Exit; + + // exterior cells only (comment out to work on interiors too) + if GetElementEditValues(e, 'DATA\Is Interior Cell') = '1' then + Exit; + + // operate on the last override + e := WinningOverride(e); + + // skip cells without precombination + if not ElementExists(e, 'PCMB') then + Exit; + + // create new plugin + if not Assigned(plugin) then begin + if MessageDlg('Create new plugin [YES] or use the last one [NO]?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then + plugin := AddNewFile + else + plugin := FileByIndex(Pred(FileCount)); + if not Assigned(plugin) then begin + Result := 1; + Exit; + end; + end; + + // skip already copied + if GetFileName(e) = GetFileName(plugin) then + Exit; + + // add masters + AddRequiredElementMasters(e, plugin, False); + + try + // copy cell as override + r := wbCopyElementToFile(e, plugin, False, True); + + // setting No PreVis flag and removing PreVis data + SetElementNativeValues(r, 'Record Header\Record Flags', GetElementNativeValues(r, 'Record Header\Record Flags') or $80); + RemoveElement(r, 'VISI'); + RemoveElement(r, 'RVIS'); + RemoveElement(r, 'PCMB'); + RemoveElement(r, 'XCRI'); + + except + on Ex: Exception do begin + AddMessage('Failed to copy: ' + FullPath(e)); + AddMessage(' reason: ' + Ex.Message); + end + end; + +end; + +function Finalize: integer; +begin + if Assigned(plugin) then + SortMasters(plugin); +end; + +end. diff --git a/Edit Scripts/Fallout4 - Filter for precombined statics.pas b/Edit Scripts/Fallout4 - Filter for precombined statics.pas index 67797f26d..829828365 100644 --- a/Edit Scripts/Fallout4 - Filter for precombined statics.pas +++ b/Edit Scripts/Fallout4 - Filter for precombined statics.pas @@ -56,11 +56,11 @@ function Initialize: Integer; // check if any reference is precombined and add to the list if so for k := 0 to Pred(ReferencedByCount(e)) do - if HasPrecombinedMesh(ReferencedByIndex(e, k)) then - if slStatics.IndexOf(GetLoadOrderFormID(e)) = -1 then begin + if HasPrecombinedMesh(ReferencedByIndex(e, k)) then begin + if slStatics.IndexOf(GetLoadOrderFormID(e)) = -1 then slStatics.Add(GetLoadOrderFormID(e)); - Break; - end; + Break; + end; end; end; diff --git a/wbDefinitionsFO4.pas b/wbDefinitionsFO4.pas index 740b47aef..af27837fd 100644 --- a/wbDefinitionsFO4.pas +++ b/wbDefinitionsFO4.pas @@ -4797,6 +4797,11 @@ procedure wbCNTOsAfterSet(const aElement: IwbElement; const aOldValue, aNewValue wbCounterAfterSet('COCT - Count', aElement); end; +procedure wbTERMCNTOsAfterSet(const aElement: IwbElement; const aOldValue, aNewValue: Variant); +begin + wbCounterAfterSet('COCT - Holds Holotape (Count)', aElement); +end; + procedure wbContainerAfterSet(const aElement: IwbElement; const aOldValue, aNewValue: Variant); begin wbCounterContainerAfterSet('COCT - Count', 'Items', aElement); @@ -16158,8 +16163,8 @@ procedure DefineFO4t; wbUnknown(PNAM), wbFormIDCk(SNAM, 'Looping Sound', [SNDR]), wbUnknown(FNAM), - wbCOCT, - wbCNTOs, + wbInteger(COCT, 'Holds Holotape (Count)', itU32), + wbRArrayS('Holotape', wbCNTO, cpNormal, False, nil, wbTERMCNTOsAfterSet), wbMNAMFurnitureMarker, wbByteArray(WBDT, 'Workbench Data (unused)', 0), wbString(XMRK, 'Marker Model'), diff --git a/wbHelpers.pas b/wbHelpers.pas index 3e55ddcfe..c6aedf1b9 100644 --- a/wbHelpers.pas +++ b/wbHelpers.pas @@ -886,7 +886,7 @@ procedure TnxFastStringListCS.AfterConstruction; function wbExtractNameFromPath(aPathName: String): String; begin Result := aPathName; - while Pos('\', Result)>0 do + while Pos('\', Result) > 0 do Delete(Result, 1, Pos('\', Result)) end; @@ -898,13 +898,13 @@ function wbCounterAfterSet(aCounterName: String; const aElement: IwbElement): Bo begin Result := False; if wbBeginInternalEdit then try - if (Length(aCounterName)>=4) and Supports(aElement.Container, IwbContainer, Container) and - Supports(aElement, IwbContainer, SelfAsContainer) then begin + if (Length(aCounterName) >= 4) and Supports(aElement.Container, IwbContainer, Container) and + Supports(aElement, IwbContainer, SelfAsContainer) then begin Element := Container.ElementByName[aCounterName]; if not Assigned(Element) then // Signatures not listed in mrDef cannot be added Element := Container.Add(Copy(aCounterName, 1, 4)); if Assigned(Element) and (SameText(Element.Name, aCounterName)) then try - if (Element.GetNativeValue<>SelfAsContainer.GetElementCount) then + if (Element.GetNativeValue <> SelfAsContainer.GetElementCount) then Element.SetNativeValue(SelfAsContainer.GetElementCount); Result := True; except @@ -924,13 +924,13 @@ function wbCounterByPathAfterSet(aCounterName: String; const aElement: IwbElemen begin Result := False; if wbBeginInternalEdit then try - if (Length(aCounterName)>=4) and Supports(aElement.Container, IwbContainer, Container) and - Supports(aElement, IwbContainer, SelfAsContainer) then begin + if (Length(aCounterName) >= 4) and Supports(aElement.Container, IwbContainer, Container) and + Supports(aElement, IwbContainer, SelfAsContainer) then begin Element := Container.ElementByPath[aCounterName]; // if not Assigned(Element) then // Signatures not listed in mrDef cannot be added // Element := Container.Add(Copy(aCounterName, 1, 4)); if Assigned(Element) and (SameText(Element.Name, wbExtractNameFromPath(aCounterName))) then try - if (Element.GetNativeValue<>SelfAsContainer.GetElementCount) then + if (Element.GetNativeValue <> SelfAsContainer.GetElementCount) then Element.SetNativeValue(SelfAsContainer.GetElementCount); Result := True; except @@ -955,7 +955,7 @@ function wbCounterContainerAfterSet(aCounterName: String; anArrayName: String; c Elems := Container.ElementByName[anArrayName]; if Assigned(Element) then begin if not Assigned(Elems) then - if Element.GetNativeValue<>0 then + if Element.GetNativeValue <> 0 then Element.SetNativeValue(0) else if DeleteOnEmpty then Container.RemoveElement(aCounterName); @@ -980,7 +980,7 @@ function wbCounterContainerByPathAfterSet(aCounterName: String; anArrayName: Str Elems := Container.ElementByName[anArrayName]; if Assigned(Element) then begin if not Assigned(Elems) then - if Element.GetNativeValue<>0 then + if Element.GetNativeValue <> 0 then Element.SetNativeValue(0); Result := True; // Counter member exists end;