Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. {
  2. Create patch plugin with "No Respawn" flag on references of ore veins.
  3. }
  4. unit SkyrimOreVeinsDontRespawnPatch;
  5.  
  6. var
  7. plugin: IInterface;
  8.  
  9. function Process(e: IInterface): Integer;
  10. var
  11. ore, r: IInterface;
  12. begin
  13. // process only references
  14. if Signature(e) <> 'REFR' then
  15. Exit;
  16.  
  17. // only master references
  18. if not IsMaster(e) then
  19. Exit;
  20.  
  21. // but work with the current winning override
  22. e := WinningOverride(e);
  23.  
  24. // getting base object of a reference (record linked in the NAME - 'Base Object' field)
  25. ore := BaseRecord(e);
  26.  
  27. // references of activator only
  28. if Signature(ore) <> 'ACTI' then
  29. Exit;
  30.  
  31. // detect if activator is an ore vein
  32. // check the presense of mining script
  33. if GetElementEditValues(ore, 'VMAD\Scripts\Script\scriptName') <> 'MineOreScript' then
  34. Exit;
  35.  
  36. // create a new plugin if not created yet or use the last loaded
  37. if not Assigned(plugin) then begin
  38. if MessageDlg('Create a new plugin [YES] or append to the last loaded one [NO]?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
  39. plugin := AddNewFile
  40. else
  41. plugin := FileByIndex(Pred(FileCount));
  42. if not Assigned(plugin) then begin
  43. Result := 1;
  44. Exit;
  45. end;
  46. end;
  47.  
  48. // add masters before copying as override for parent CELL
  49. AddRequiredElementMasters(LinksTo(ElementByIndex(e, 0)), plugin, False);
  50. // and REFR itself
  51. AddRequiredElementMasters(e, plugin, False);
  52.  
  53. try
  54. // copy reference as override
  55. r := wbCopyElementToFile(e, plugin, False, True);
  56.  
  57. // set No Respawn flag (bit 30)
  58. SetElementNativeValues(r, 'Record Header\Record Flags', GetElementNativeValues(r, 'Record Header\Record Flags') or (1 shl 30));
  59. except
  60. on Ex: Exception do begin
  61. AddMessage('Failed to copy: ' + FullPath(e));
  62. AddMessage(' reason: ' + Ex.Message);
  63. end;
  64. end;
  65. end;
  66.  
  67. function Finalize: integer;
  68. begin
  69. if Assigned(plugin) then
  70. SortMasters(plugin);
  71. end;
  72.  
  73. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement