Skip to content

Commit

Permalink
[FO4] Updated TERM
Browse files Browse the repository at this point in the history
COCT serves as a flag, must be conflict resolved.
New FO4 script to create a patch disabling PreVis in exterior cells.
  • Loading branch information
zilav committed Mar 22, 2017
1 parent 218950f commit 5a51afd
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 15 deletions.
73 changes: 73 additions & 0 deletions 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.
8 changes: 4 additions & 4 deletions Edit Scripts/Fallout4 - Filter for precombined statics.pas
Expand Up @@ -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;

Expand Down
9 changes: 7 additions & 2 deletions wbDefinitionsFO4.pas
Expand Up @@ -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);
Expand Down Expand Up @@ -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'),
Expand Down
18 changes: 9 additions & 9 deletions wbHelpers.pas
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 5a51afd

Please sign in to comment.