Advertisement
Guest User

Untitled

a guest
Nov 8th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.52 KB | None | 0 0
  1. {
  2.   Build a list of interior cells in csv format
  3. }
  4. unit SkyrimListInteriorCells;
  5.  
  6. var
  7.   CountRef, CountRefPersistent, CountRefDeleted, CountRefDisabled: integer;
  8.   CountNAVM, CountSpawn, CountLight, CountSound: integer;
  9.   CountFurniture, CountContainer: integer;
  10.   slCells: TStringList;
  11.   slSpawns: TStringList;
  12.  
  13. procedure ClearCellData;
  14. begin
  15.   CountRef := 0;
  16.   CountRefPersistent := 0;
  17.   CountRefDeleted := 0;
  18.   CountRefDisabled := 0;
  19.   CountNAVM := 0;
  20.   CountSpawn := 0;
  21.   slSpawns.Clear;
  22.   CountLight := 0;
  23.   CountSound := 0;
  24.   CountFurniture := 0;
  25.   CountContainer := 0;
  26. end;
  27.  
  28. function Initialize: integer;
  29. begin
  30.   slCells := TStringList.Create;
  31.   slCells.Add('FormID;Block;Sub-Block;EditorID;Name;Ownership;Location;LightingTemplate;ImageSpace;AcousticSpace;Music;Navmeshes;References;Persistent;Deleted;Disabled;Spawns;SpawnsList;Lights;Sounds;Furnitures;Containers');
  32.   slSpawns := TStringList.Create; slSpawns.Sorted := True; slSpawns.Duplicates := dupIgnore;
  33.  
  34.   ClearCellData;
  35. end;
  36.  
  37. function Process(e: IInterface): integer;
  38. var
  39.   sig, sigbase, s: string;
  40.   block, subblock: integer;
  41.   r: IInterface;
  42. begin
  43.   sig := Signature(e);
  44.  
  45.   if (sig = 'REFR')
  46.   or (sig = 'ACHR')
  47.   or (sig = 'PARW')
  48.   or (sig = 'PBAR')
  49.   or (sig = 'PBEA')
  50.   or (sig = 'PCON')
  51.   or (sig = 'PFLA')
  52.   or (sig = 'PHZD')
  53.   or (sig = 'PMIS') then begin
  54.     Inc(CountRef);
  55.     if GetIsPersistent(e) then Inc(CountRefPersistent);
  56.     if GetIsDeleted(e) then Inc(CountRefDeleted);
  57.     if GetIsinitiallyDisabled(e) then Inc(CountRefDisabled);
  58.     r := BaseRecord(e);
  59.     sigbase := Signature(r);
  60.     if sig = 'ACHR' then begin
  61.       Inc(CountSpawn);
  62.       slSpawns.Add(EditorID(r));
  63.     end;
  64.     if sigbase = 'LIGH' then Inc(CountLight)
  65.     else if sigbase = 'SOUN' then Inc(CountSound)
  66.     else if sigbase = 'FURN' then Inc(CountFurniture)
  67.     else if sigbase = 'CONT' then Inc(CountContainer);
  68.   end
  69.   else if sig = 'NAVM' then begin
  70.     if not GetIsDeleted(e) then Inc(CountNAVM);
  71.   end
  72.   else if sig = 'CELL' then begin
  73.     // only for interior cells
  74.     if GetElementNativeValues(e, 'DATA') and 1 > 0 then begin
  75.       s := IntToStr(FormID(e) and $FFFFFF);
  76.       block := StrToInt(s[length(s)]);
  77.       subblock := StrToInt(s[length(s)-1]);
  78.       slCells.Add(Format('%s;%d;%d;%s;%s;%s;%s;%s;%s;%s;%s;%d;%d;%d;%d;%d;%d;%s;%d;%d;%d;%d', [
  79.         '[' + IntToHex(FormID(e), 8) + ']',  // add [] to prevent Excel from treating FormID as a number
  80.         block,
  81.         subblock,
  82.         EditorID(e),
  83.         GetElementEditValues(e, 'FULL'),
  84.         EditorID(LinksTo(ElementByPath(e, 'Ownership\XOWN'))),
  85.         EditorID(LinksTo(ElementBySignature(e, 'XLCN'))),
  86.         EditorID(LinksTo(ElementBySignature(e, 'LTMP'))),
  87.         EditorID(LinksTo(ElementBySignature(e, 'XCIM'))),
  88.         EditorID(LinksTo(ElementBySignature(e, 'XCAS'))),
  89.         EditorID(LinksTo(ElementBySignature(e, 'XCMO'))),
  90.         CountNAVM,
  91.         CountRef,
  92.         CountRefPersistent,
  93.         CountRefDeleted,
  94.         CountRefDisabled,
  95.         CountSpawn,
  96.         slSpawns.CommaText,
  97.         CountLight,
  98.         CountSound,
  99.         CountFurniture,
  100.         CountContainer
  101.       ]));
  102.     end;
  103.     ClearCellData;
  104.   end;
  105. end;
  106.  
  107. function Finalize: integer;
  108. var
  109.   fname: string;
  110. begin
  111.   if slCells.Count > 1 then begin
  112.     fname := ScriptsPath + 'Cells.csv';
  113.     AddMessage('Saving report to ' + fname);
  114.     slCells.SaveToFile(fname);
  115.   end else
  116.     AddMessage('No cells found in selection.');
  117.  
  118.   slSpawns.Free;
  119.   slCells.Free;
  120. end;
  121.  
  122. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement