Advertisement
vntf

Set 'Unknown 23' for interior cells

Sep 25th, 2021 (edited)
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.79 KB | None | 0 0
  1. unit SetInteriorCellUnknown23_3;
  2.  
  3. var
  4.   ToFile: IInterface;
  5.  
  6. // Code for SelectFile was borrowed from the "Copy as override.pas" script
  7. function SelectFile(e: IInterface): Boolean;
  8. var
  9.   frm: TForm;
  10.   clb: TCheckListBox;
  11.   m, ovr: IInterface;
  12.   i: integer;
  13. begin
  14.   Result := False;
  15.   if not Assigned(ToFile) then begin
  16.     frm := frmFileSelect;
  17.     try
  18.       frm.Caption := 'Select a plugin';
  19.       clb := TCheckListBox(frm.FindComponent('CheckListBox1'));
  20.       clb.Items.Add('<new file>');
  21.  
  22.       for i := Pred(FileCount) downto 0 do begin
  23.         clb.Items.InsertObject(1, GetFileName(FileByIndex(i)), FileByIndex(i));
  24.         if GetFileName(e) = GetFileName(FileByIndex(i)) then
  25.           Break;
  26.       end;
  27.  
  28.       if frm.ShowModal <> mrOk then
  29.         Exit;
  30.  
  31.       for i := 0 to Pred(clb.Items.Count) do
  32.         if clb.Checked[i] then begin
  33.           if i = 0 then ToFile := AddNewFile else
  34.             ToFile := ObjectToElement(clb.Items.Objects[i]);
  35.           Break;
  36.         end;
  37.  
  38.     finally
  39.       frm.Free;
  40.     end;
  41.     if Assigned(ToFile) then
  42.       Result := True;
  43.   end;
  44. end;
  45.  
  46. function Process(e: IInterface): Integer;
  47. var
  48.   e1: IInterface;
  49. begin
  50.   {B-}
  51.   if (Signature(e) = 'CELL')
  52.      // comment out the following line if you want that the script can modify the flag for Worldspace cells
  53.      and (GetElementNativeValues(e, 'DATA - Flags') and 1 = 1)
  54.   then begin
  55.     if not Assigned(ToFile) and not SelectFile(e) then begin
  56.       Result := 1;
  57.       Exit;
  58.     end;
  59.  
  60.     AddRequiredElementMasters(e, ToFile, false);
  61.     e1 := wbCopyElementToFile(e, ToFile, false, true);
  62.     SetElementNativeValues(e1, 'Record Header\Record Flags\Unknown 23', 1);
  63.   end;
  64. end;
  65.  
  66. function Finalize: Integer;
  67. begin
  68.   SortMasters(ToFile);
  69.   CleanMasters(ToFile);
  70. end;
  71.  
  72. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement