Guest User

Untitled

a guest
Sep 15th, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. {
  2. Displace worldspace cells and references by ShiftX, ShiftY (measured in cells).
  3. Should be applied to desired regions and wordspaces separately.
  4. Teleport data on doors is not updated.
  5. }
  6. unit userscript;
  7.  
  8. const
  9. ShiftX = 32;
  10. ShiftY = 0;
  11. CellSize = 4096;
  12.  
  13. function Process(e: IInterface): integer;
  14. var
  15. Sig: string;
  16. ent, ents, point: IInterface;
  17. i, j: integer;
  18. begin
  19. Sig := Signature(e);
  20.  
  21. // update regions
  22. if Sig = 'REGN' then begin
  23. ents := ElementByName(e, 'Region Areas');
  24. for i := 0 to ElementCount(ents) - 1 do begin
  25. ent := ElementByIndex(ents, i); // get Region Area
  26. ent := ElementBySignature(ent, 'RPLD'); // points list
  27. for j := 0 to ElementCount(ent) - 1 do begin
  28. point := ElementByIndex(ent, j);
  29. SetElementNativeValues(point, 'X', GetElementNativeValues(point, 'X') + ShiftX*CellSize);
  30. SetElementNativeValues(point, 'Y', GetElementNativeValues(point, 'Y') + ShiftY*CellSize);
  31. end;
  32. end;
  33. end else
  34.  
  35. // update worldspace bounds
  36. if Sig = 'WRLD' then begin
  37. SetElementNativeValues(e, 'Object Bounds\NAM0\X', GetElementNativeValues(e, 'Object Bounds\NAM0\X') + ShiftX);
  38. SetElementNativeValues(e, 'Object Bounds\NAM0\Y', GetElementNativeValues(e, 'Object Bounds\NAM0\Y') + ShiftY);
  39. SetElementNativeValues(e, 'Object Bounds\NAM9\X', GetElementNativeValues(e, 'Object Bounds\NAM9\X') + ShiftX);
  40. SetElementNativeValues(e, 'Object Bounds\NAM9\Y', GetElementNativeValues(e, 'Object Bounds\NAM9\Y') + ShiftY);
  41. end else
  42.  
  43. // update CELL grid coords except persistent cell
  44. if (Sig = 'CELL') and not GetIsPersistent(e) then begin
  45. if (GetElementNativeValues(e, 'XCLC\X') >= -10) and
  46. (GetElementNativeValues(e, 'XCLC\X') <= 10) and
  47. (GetElementNativeValues(e, 'XCLC\Y') >= -10) and
  48. (GetElementNativeValues(e, 'XCLC\Y') <= 10)
  49. then begin
  50. SetElementNativeValues(e, 'XCLC\X', GetElementNativeValues(e, 'XCLC\X') + ShiftX);
  51. SetElementNativeValues(e, 'XCLC\Y', GetElementNativeValues(e, 'XCLC\Y') + ShiftY);
  52. end;
  53. end else
  54.  
  55. // delete pathgrids and navmeshes, must be recreated
  56. if (Sig = 'NAVM') or (Sig = 'PGRD') then begin
  57. RemoveNode(e);
  58. end else
  59.  
  60. // skip other records (should be the LAND only for worldspace group)
  61. if (Sig <> 'REFR') and (Sig <> 'PGRE') and (Sig <> 'PMIS') and (Sig <> 'ACHR') and (Sig <> 'ACRE') and
  62. (Sig <> 'PARW') and (Sig <> 'PBAR') and (Sig <> 'PBEA') and (Sig <> 'PCON') and (Sig <> 'PFLA') and
  63. (Sig <> 'PHZD')
  64. then
  65. Exit;
  66.  
  67. // update position of references
  68. if (GetElementNativeValues(e, 'DATA\Position\X')/CellSize >= -10) and
  69. (GetElementNativeValues(e, 'DATA\Position\X')/CellSize <= 10) and
  70. (GetElementNativeValues(e, 'DATA\Position\Y')/CellSize >= -10) and
  71. (GetElementNativeValues(e, 'DATA\Position\Y')/CellSize <= 10)
  72. then begin
  73. SetElementNativeValues(e, 'DATA\Position\X', GetElementNativeValues(e, 'DATA\Position\X') + ShiftX*CellSize);
  74. SetElementNativeValues(e, 'DATA\Position\Y', GetElementNativeValues(e, 'DATA\Position\Y') + ShiftY*CellSize);
  75. end;
  76. end;
  77.  
  78. end.
Advertisement
Add Comment
Please, Sign In to add comment