Advertisement
Mator

[Pascal] [xEdit] Test MXPF

Aug 9th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.62 KB | None | 0 0
  1. {
  2.   Test mxpf
  3. }
  4.  
  5. unit UserScript;
  6.  
  7. uses mxpf, mteFunctions;
  8.  
  9. function Initialize: Integer;
  10. var
  11.   i: integer;
  12.   armorRating, newArmorRating: real;
  13.   rec: IInterface;
  14. begin
  15.   // set MXPF options and initialize it
  16.   DefaultOptionsMXPF;
  17.   InitializeMXPF;
  18.  
  19.   // select/create a new patch file that will be identified by its author field
  20.   PatchFileByAuthor('TestMXPF');
  21.   SetExclusions(mxBethesdaFiles); // excludes bethesda files from record loading
  22.   LoadRecords('ARMO'); // loads all Armor records
  23.  
  24.   // you can filter the loaded records like this
  25.   // it's important that the loop starts at MaxRecordIndex and goes down to 0
  26.   // because we're removing records
  27.   for i := MaxRecordIndex downto 0 do begin
  28.     rec := GetRecord(i);
  29.     // remove records that don't have the ArmorLight keyword
  30.     if not HasKeyword(rec, 'ArmorLight') then
  31.       RemoveRecord(i)
  32.     // remove records with DNAM - Armor Rating = 0
  33.     else if (genv(rec, 'DNAM - Armor Rating') = 0) then
  34.       RemoveRecord(i);
  35.   end;
  36.  
  37.   // then copy records to the patch file
  38.   CopyRecordsToPatch;
  39.  
  40.   // and set values on them
  41.   for i := 0 to MaxPatchRecordIndex do begin
  42.     rec := GetPatchRecord(i);
  43.     armorRating := StrToFloat(geev(rec, 'DNAM'));
  44.     newArmorRating := Int(armorRating * 1.25);
  45.     AddMessage(Format('Changed armor rating from %0.2f to %0.2f on %s', [armorRating, newArmorRating, Name(rec)]));
  46.     seev(rec, 'DNAM', FloatToStr(newArmorRating));
  47.   end;
  48.  
  49.   // call PrintMXPFReport for a report on successes and failures
  50.   PrintMXPFReport;
  51.  
  52.   // always call FinalizeMXPF when done
  53.   FinalizeMXPF;
  54. end;
  55.  
  56. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement