-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBASH tags autodetection.pas
1428 lines (1153 loc) · 42.4 KB
/
BASH tags autodetection.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
Purpose: Automatic Bash Tag Generation
Games: FO3/FNV/TES4/TES5
Author: fireundubh <[email protected]>
Version: 1.4.1 (based on "BASH tags autodetection.pas" v1.0)
Description: This script detects up to 49 bash tags in FO3, FNV, TES4, and TES5 plugins.
Tags can automatically replace the Description in the File Header. Wrye Bash/Flash can
then use these tags to help you create more intelligent bashed patches.
Requires mteFunctions (by matortheeternal):
https://github.com/matortheeternal/TES5EditScripts/blob/master/trunk/Edit%20Scripts/mteFunctions.pas
Not implemented:
Creatures.Blood, Deactivate, Deflst, Filter, NoMerge, Npc.EyesOnly, Npc.HairOnly,
R.Attributes-F, R.Attributes-M, R.AddSpells, R.ChangeSpells
Future plans:
Support Oblivion (already do?)
}
unit BashTagsDetector;
uses mteFunctions;
const
usesEvalDebugFunction = true;
usesCheckDebugFunction = true;
var
f: IwbFile;
slTags: TStringList;
fn, tag, game: string;
optionSelected: integer;
// ******************************************************************
// FUNCTIONS
// ******************************************************************
// ==================================================================
// Returns True if the flags set are different and False if not
function CompareFlagsEx(x, y: IInterface; p, f: string): boolean;
begin
Result := (HasFlag(GetElement(x, p), f) <> HasFlag(GetElement(y, p), f));
end;
// ==================================================================
// Returns True if the any two flags are set and False if not
function CompareFlagsOr(x, y: IInterface; p, f: string): boolean;
begin
Result := (HasFlag(GetElement(x, p), f) or HasFlag(GetElement(y, p), f));
end;
// ==================================================================
// Returns True if the set flags are different and False if not
function CompareKeys(x, y: IInterface; debug: boolean): boolean;
var
sx, sy: string;
begin
if (ConflictAllString(ContainingMainRecord(x)) = 'caUnknown')
or (ConflictAllString(ContainingMainRecord(x)) = 'caOnlyOne')
or (ConflictAllString(ContainingMainRecord(x)) = 'caNoConflict') then begin
Result := false;
exit;
end;
sx := SortKeyEx(x);
sy := SortKeyEx(y);
if IsEmptyKey(sx) and IsEmptyKey(sy) then exit;
Result := sx <> sy;
// double check with lowercase values
if Lowercase(sx) = Lowercase(sy) then
Result := false;
if Result and debug then begin
PrintDebugE(x, y, '[CompareKeys] ' + tag);
AddMessage('-- [' + Format('%.2u', [GetLoadOrder(GetFile(ContainingMainRecord(x)))]) + '] [' + Signature(ContainingMainRecord(x)) + ':' + HexFormID(ContainingMainRecord(x)) + '] ' + SortKeyEx(x));
AddMessage('-- [' + Format('%.2u', [GetLoadOrder(GetFile(ContainingMainRecord(y)))]) + '] [' + Signature(ContainingMainRecord(y)) + ':' + HexFormID(ContainingMainRecord(y)) + '] ' + SortKeyEx(y));
end;
end;
// ==================================================================
// Returns True if the native values are different and False if not
function CompareNativeValues(x, y: IInterface; s: string): boolean;
begin
Result := (GetNativeValue(GetElement(x, s)) <> GetNativeValue(GetElement(y, s)));
end;
// ==================================================================
// Universal ElementBy
function GetElement(x: IInterface; s: string): IInterface;
begin
if (pos('[', s) > 0) then
Result := ElementByIP(x, s)
else if (pos('\', s) > 0) then
Result := ElementByPath(x, s)
else if IsUppercase(s) then
Result := ElementBySignature(x, s)
else
Result := ElementByName(x, s);
end;
// ==================================================================
// Get element from list by some value
function GetElementByValue(el: IInterface; smth, somevalue: string): IInterface;
var
i: integer;
entry: IInterface;
begin
Result := nil;
for i := 0 to ElementCount(el) - 1 do begin
entry := ElementByIndex(el, i);
if geev(entry, smth) = somevalue then begin
Result := entry;
exit;
end;
end;
end;
// ==================================================================
// Return True if specific flag is set and False if not
function HasFlag(f: IInterface; s: string): boolean;
var
flags, templateFlags, cellFlags, recordFlags: TStringList;
i: integer;
begin
// create flag lists
flags := TStringList.Create;
templateFlags := TStringList.Create;
cellFlags := TStringList.Create;
recordFlags := TStringList.Create;
// assign flag lists
templateFlags.DelimitedText := '"Use Traits=1", "Use Stats=2", "Use Factions=4", "Use Spell List=8", "Use Actor Effect List=8", "Use AI Data=16", "Use AI Packages=32", "Use Model/Animation=64", "Use Base Data=128", "Use Inventory=256", "Use Script=512", "Use Def Pack List=1024", "Use Attack Data=2048", "Use Keywords=4096"';
cellFlags.DelimitedText := '"Is Interior Cell=1", "Has Water=2", "Behave Like Exterior=128"';
recordFlags.DelimitedText := '"ESM=1", "Deleted=32", "Border Region=64", "Turn Off Fire=128", "Casts Shadows=512", "Persistent Reference=1024", "Initially Disabled=2048", "Ignored=4096", "Visible When Distant=32768", "Dangerous=131072", "Compressed=262144", "Cant Wait=524288"';
// merge flag lists
flags.AddStrings(templateFlags);
flags.AddStrings(cellFlags);
flags.AddStrings(recordFlags);
// find index
i := StrToInt(lowercase(flags.Values[s]));
// free flag lists
flags.Free;
templateFlags.Free;
cellFlags.Free;
recordFlags.Free;
// return result
Result := (GetNativeValue(f) and i > 0);
end;
// ==================================================================
// Returns True if the string contains only zeroes and False if not
function IsEmptyKey(s: string): boolean;
var
i: integer;
begin
for i := 1 to length(s) do begin
if s[i] = '1' then begin
Result := false;
exit;
end;
Result := true;
end;
end;
// ==================================================================
// Return true if the loaded game is Fallout 3
function IsFallout3(): boolean;
begin
Result := (GetFileName(FileByLoadOrder(00)) = 'Fallout3.esm');
end;
// ==================================================================
// Return true if the loaded game is Fallout: New Vegas
function IsFalloutNV(): boolean;
begin
Result := (GetFileName(FileByLoadOrder(00)) = 'FalloutNV.esm');
end;
// ==================================================================
// Return true if the loaded game is TES4: Oblivion
function IsOblivion(): boolean;
begin
Result := (GetFileName(FileByLoadOrder(00)) = 'Oblivion.esm');
end;
// ==================================================================
// Return true if the loaded game is TES4: Skyrim
function IsSkyrim(): boolean;
begin
Result := (GetFileName(FileByLoadOrder(00)) = 'Skyrim.esm');
end;
// ==================================================================
// Returns True if the string is uppercase and False if not
function IsUppercase(x: string): boolean;
begin
Result := (x = Uppercase(x));
end;
// ==================================================================
// Returns True if the x FormID is in the y list of FormIDs to ignore
// z is the file that contains the FormIDs to ignore
function InIgnoreList(x, y: string): boolean;
var
formids: TStringList;
i: integer;
begin
formids := TStringList.Create;
formids.DelimitedText := y;
i := formids.IndexOf(x);
formids.Free;
Result := (i > -1);
end;
// ==================================================================
// Returns True if the x signature is in the y list of signatures
function InSignatureList(x, y: string): boolean;
var
signatures: TStringList;
i: integer;
begin
signatures := TStringList.Create;
signatures.DelimitedText := y;
i := signatures.IndexOf(x);
signatures.Free;
Result := (i > -1);
end;
// ==================================================================
// Better SortKey
function SortKeyEx(e: IInterface): string;
var
i: integer;
begin
Result := GetEditValue(e);
// manipulate result for model paths - sometimes the same paths have different cases
if (pos('.nif', Lowercase(Result)) > 0) then
Result := Lowercase(GetEditValue(e));
for i := 0 to ElementCount(e) - 1 do begin
if (pos('unknown', Lowercase(Name(ElementByIndex(e, i)))) > 0)
or (pos('unused', Lowercase(Name(ElementByIndex(e, i)))) > 0) then
exit;
if (Result <> '') then
Result := Result + ';' + gav(ElementByIndex(e, i))
else
Result := gav(ElementByIndex(e, i));
end;
end;
// ==================================================================
// Check if the tag already exists
function TagExists(t: string): boolean;
begin
Result := (slTags.IndexOf(t) <> -1);
end;
// ******************************************************************
// PROCEDURES
// ******************************************************************
// ==================================================================
// Add the tag if the tag does not exist
procedure AddTag(t: string);
begin
if not TagExists(t) then slTags.Add(t);
end;
// ==================================================================
// Evaluate
// Determines whether two elements are different and suggests tags
// Not to be used when you need to know how two elements differ
procedure Evaluate(x, y: IInterface; tag: string; debug: boolean);
var
i, j, k, l, m: integer;
ex, ey: IInterface;
begin
// Exit if the tag already exists
if TagExists(tag) then exit;
// exit if element is unknown or a flags element
if (pos('unknown', Lowercase(Path(x))) > 0)
or (pos('unused', Lowercase(Path(x))) > 0)
or (pos('flags', Lowercase(Path(x))) > 0)
or (pos('unknown', Lowercase(Path(y))) > 0)
or (pos('unused', Lowercase(Path(y))) > 0)
or (pos('flags', Lowercase(Path(y))) > 0) then
exit;
// Suggest tag if one element exists while the other does not
if Assigned(x) <> Assigned(y) then begin
if debug then PrintDebugE(x, y, '[Assigned] ' + tag);
AddTag(tag);
exit;
end;
// exit if the first element does not exist
if not Assigned(x) then
exit;
// Suggest tag if the two elements are different
if ElementCount(x) <> ElementCount(y) then begin
if debug then PrintDebugE(x, y, '[ElementCount] ' + tag);
AddTag(tag);
exit;
end else
// suggest tag if the edit values of the two elements are different
if GetEditValue(x) <> GetEditValue(y) then begin
if debug then PrintDebugE(x, y, '[GetEditValue] ' + tag);
AddTag(tag);
exit;
end else
// compare any number of elements with CompareKeys
if CompareKeys(x, y, debug) <> 0 then AddTag(tag);
end;
// ==================================================================
// EvaluateEx
// Improved Evaluate with GetElement
procedure EvaluateEx(x, y: IInterface; z: string; tag: string; debug: boolean);
begin
Evaluate(GetElement(x, z), GetElement(y, z), tag, debug);
end;
// ==================================================================
// v1.3.3 - Actors.ACBS
procedure CheckActorsACBS(e, m: IInterface; debug: boolean);
var
f, fm: IInterface;
begin
// define tag
tag := 'Actors.ACBS';
// exit if the tag exists
if TagExists(tag) then exit;
// assign ACBS elements
f := GetElement(e, 'ACBS');
fm := GetElement(m, 'ACBS');
// evaluate Flags if the Use Base Data flag is not set
if not CompareFlagsOr(f, fm, 'Template Flags', 'Use Base Data') then begin
if CompareKeys(GetElement(f, 'Flags'), GetElement(fm, 'Flags'), debug) then begin
AddTag(tag);
exit;
end;
end;
// evaluate properties
EvaluateEx(f, fm, 'Fatigue', tag, debug);
EvaluateEx(f, fm, 'Level', tag, debug);
EvaluateEx(f, fm, 'Calc min', tag, debug);
EvaluateEx(f, fm, 'Calc max', tag, debug);
EvaluateEx(f, fm, 'Speed Multiplier', tag, debug);
EvaluateEx(e, m, 'DATA\Base Health', tag, debug);
// evaluate Barter Gold if the Use AI Data flag is not set
if not CompareFlagsOr(f, fm, 'Template Flags', 'Use AI Data') then
EvaluateEx(f, fm, 'Barter gold', tag, debug);
end;
// ==================================================================
// Actors.AIData
procedure CheckActorsAIData(e, m: IInterface; debug: boolean);
var
a, am: IInterface;
begin
// define tag
tag := 'Actors.AIData';
// exit if tag exists
if TagExists(tag) then exit;
// assign AIDT elements
a := GetElement(e, 'AIDT');
am := GetElement(m, 'AIDT');
// evaluate AIDT properties
EvaluateEx(a, am, 'Aggression', tag, debug);
EvaluateEx(a, am, 'Confidence', tag, debug);
EvaluateEx(a, am, 'Energy level', tag, debug);
EvaluateEx(a, am, 'Responsibility', tag, debug);
EvaluateEx(a, am, 'Teaches', tag, debug);
EvaluateEx(a, am, 'Maximum training level', tag, debug);
// v1.3.3: check flags for Buys/Sells and Services
if CompareNativeValues(a, am, 'Buys/Sells and Services') then begin
if debug then PrintDebugS(a, am, 'Buys/Sells and Services', tag);
AddTag(tag);
end;
end;
// ==================================================================
// Actors.AIPackages
procedure CheckActorsAIPackages(e, m: IInterface; debug: boolean);
begin
// define tag
tag := 'Actors.AIPackages';
// exit if tag exists
if TagExists(tag) then exit;
// evaluate Packages property
EvaluateEx(e, m, 'Packages', tag, debug);
end;
// ==================================================================
// Factions
procedure CheckActorsFactions(e, m: IInterface; debug: boolean);
var
f, fm: IInterface;
begin
// define tag
tag := 'Factions';
// exit if tag exists
if TagExists(tag) then exit;
// assign Factions properties
f := GetElement(e, 'Factions');
fm := GetElement(m, 'Factions');
// add tag if the Factions properties differ
if Assigned(f) <> Assigned(fm) then begin
if debug then PrintDebugE(e, m, '[Assigned] ' + tag);
AddTag(tag);
exit;
end;
// exit if the Factions property in the control record does not exist
if not Assigned(f) then exit;
// evaluate Factions properties
if CompareKeys(f, fm, debug) then AddTag(tag);
end;
// ==================================================================
// Actors.Skeleton
procedure CheckActorsSkeleton(e, m: IInterface; debug: boolean);
var
x, y: IInterface;
begin
// define tag
tag := 'Actors.Skeleton';
// exit if tag exists
if TagExists(tag) then exit;
// assign Model elements
x := GetElement(e, 'Model');
y := GetElement(m, 'Model');
// exit if the Model property does not exist in the control record
if not Assigned(x) then exit;
// evaluate properties
EvaluateEx(x, y, 'MODL', tag, debug);
EvaluateEx(x, y, 'MODB', tag, debug);
EvaluateEx(x, y, 'MODT', tag, debug);
end;
// ==================================================================
// Actors.Stats
procedure CheckActorsStats(e, m: IInterface; debug: boolean);
var
d, dm: IInterface;
sig: string;
begin
// define tag
tag := 'Actors.Stats';
// exit if tag exists
if TagExists(tag) then exit;
// get record signature
sig := Signature(e);
// assign DATA elements
d := GetElement(e, 'DATA');
dm := GetElement(m, 'DATA');
// evaluate CREA properties
if (sig = 'CREA') then begin
EvaluateEx(d, dm, 'Health', tag, debug);
EvaluateEx(d, dm, 'Combat Skill', tag, debug);
EvaluateEx(d, dm, 'Magic Skill', tag, debug);
EvaluateEx(d, dm, 'Stealth Skill', tag, debug);
EvaluateEx(d, dm, 'Attributes', tag, debug);
end;
// evaluate NPC_ properties
if (sig = 'NPC_') then begin
EvaluateEx(d, dm, 'Base Health', tag, debug);
EvaluateEx(d, dm, 'Attributes', tag, debug);
EvaluateEx(e, m, 'DNAM\Skill Values', tag, debug);
EvaluateEx(e, m, 'DNAM\Skill Offsets', tag, debug);
end;
end;
// ==================================================================
// C.Climate
procedure CheckCellClimate(e, m: IInterface; debug: boolean);
var
d, dm: IInterface;
begin
// define tag
tag := 'C.Climate';
// exit if tag exists
if TagExists(tag) then exit;
// add tag if the Behave Like Exterior flag is set ine one record but not the other
if CompareFlagsEx(e, m, 'DATA', 'Behave Like Exterior') then begin
if debug then PrintDebugS(e, m, 'DATA', tag);
AddTag(tag);
exit;
end;
// evaluate additional property
EvaluateEx(e, m , 'XCCM', tag, debug);
end;
// ==================================================================
// C.RecordFlags
procedure CheckCellRecordFlags(e, m: IInterface; debug: boolean);
var
sig: string;
f, fm: IInterface;
begin
// define tag
tag := 'C.RecordFlags';
sig := Signature(e);
// exit if tag exists
if TagExists(tag) then exit;
// compare Record Flags elements
if CompareKeys(GetElement(e, 'Record Header\Record Flags'), GetElement(m, 'Record Header\Record Flags'), debug) then
AddTag(tag);
end;
// ==================================================================
// C.Water
procedure CheckCellWater(e, m: IInterface; debug: boolean);
begin
// define tag
tag := 'C.Water';
// exit if tag exists
if TagExists(tag) then exit;
// add tag if Has Water flag is set in one record but not the other
if CompareFlagsEx(e, m, 'DATA', 'Has Water') then begin
if debug then PrintDebugS(e, m, 'DATA', tag);
AddTag(tag);
exit;
end;
// exit if Is Interior Cell is set in either record
if CompareFlagsOr(e, m, 'DATA', 'Is Interior Cell') then exit;
// evaluate properties
EvaluateEx(e, m, 'XCLW', tag, debug);
EvaluateEx(e, m, 'XCWT', tag, debug);
end;
// ==================================================================
// Delev, Relev (written by the xEdit team)
procedure CheckDelevRelev(e, m: IInterface; debug: boolean);
var
i, matched: integer;
entries, entriesmaster: IInterface; // leveled list entries
ent, entm: IInterface; // leveled list entry
coed, coedm: IInterface; // extra data
s1, s2: string; // sortkeys for extra data, sortkey is a compact text representation of element's values
begin
// nothing to do if already tagged
if TagExists('Delev') and TagExists('Relev') then exit;
// get Leveled List Entries
entries := GetElement(e, 'Leveled List Entries');
entriesmaster := GetElement(m, 'Leveled List Entries');
if not Assigned(entries) or not Assigned(entriesmaster) then exit;
// count matched on reference entries
matched := 0;
// iterate through all entries
for i := 0 to ElementCount(entries) - 1 do begin
ent := ElementByIndex(entries, i);
// find the same entry in master
entm := GetElementByValue(entriesmaster, 'LVLO\Reference', geev(ent, 'LVLO\Reference'));
if Assigned(entm) then begin
Inc(matched);
// Relev check for changed level, count, extra data
coed := GetElement(ent, 'COED');
coedm := GetElement(entm, 'COED');
if Assigned(coed) then
s1 := SortKey(coed, True) else s1 := '';
if Assigned(coedm) then
s2 := SortKey(coedm, True) else s2 := '';
if CompareNativeValues(ent, entm, 'LVLO\Level')
or CompareNativeValues(ent, entm, 'LVLO\Count')
or (s1 <> s2) then begin
if debug then PrintDebugE(ent, entm, '[CompareNativeValues] ' + 'Relev');
AddTag('Relev');
exit;
end;
end;
end;
// if number of matched entries less than in master list
if matched < ElementCount(entriesmaster) then begin
if debug then PrintDebugE(entries, entriesmaster, '[ElementCount] ' + 'Delev');
AddTag('Delev');
exit;
end;
end;
// ==================================================================
// Destructible
procedure CheckDestructible(e, m: IInterface; debug: boolean);
var
d, dm, df, dfm: IInterface;
begin
// define tag
tag := 'Destructible';
// exit if tag exists
if TagExists(tag) then exit;
// assign Destructable elements
d := GetElement(e, 'Destructable');
dm := GetElement(m, 'Destructable');
if Assigned(d) <> Assigned (dm) then begin
if debug then PrintDebugE(d, dm, '[Assigned] ' + tag);
AddTag(tag);
exit;
end;
// evaluate Destructable properties
EvaluateEx(d, dm, 'DEST\Health', tag, debug);
EvaluateEx(d, dm, 'DEST\Count', tag, debug);
EvaluateEx(d, dm, 'Stages', tag, debug);
// assign Destructable flags
if not IsSkyrim() then begin
if ElementExists(d, 'DEST\Flags') or ElementExists(dm, 'DEST\Flags') then begin
df := GetElement(d, 'DEST\Flags');
dfm := GetElement(d, 'DEST\Flags');
// add tag if Destructable flags exist in one record
if Assigned(df) <> Assigned(dfm) then begin
if debug then PrintDebugE(df, dfm, '[Assigned] ' + tag);
AddTag(tag);
exit;
end;
// evaluate Destructable flags
if CompareKeys(df, dfm, debug) then AddTag(tag);
end;
end;
end;
// ==================================================================
// Graphics - v1.4: 100% implementation
procedure CheckGraphics(e, m: IInterface; debug: boolean);
var
icon, iconm, modl, modlm, fpf, fpfm, gf, gfm, bpf, bpfm, rf, rfm: IInterface;
sig: string;
i: integer;
begin
// define tag
tag := 'Graphics';
// exit if tag exists
if TagExists(tag) then exit;
// get signature of control record
sig := Signature(e);
// evaluate Icon properties
if InSignatureList(sig, 'ALCH, AMMO, APPA, BOOK, BSGN, CLAS, INGR, KEYM, LIGH, LSCR, LTEX, MGEF, MISC, REGN, SGST, SLGM, TREE, WEAP') then
EvaluateEx(e, m, 'Icon', tag, debug);
// evaluate Model properties
if InSignatureList(sig, 'ACTI, ALCH, AMMO, APPA, BOOK, DOOR, FLOR, FURN, GRAS, INGR, KEYM, LIGH, MGEF, MISC, SGST, SLGM, STAT, TREE, WEAP') then
EvaluateEx(e, m, 'Model', tag, debug);
// evaluate ARMO properties
if (sig = 'ARMO') then begin
// Shared
EvaluateEx(e, m, 'Male world model', tag, debug);
EvaluateEx(e, m, 'Female world model', tag, debug);
// FNV, FO3, Oblivion
if IsSkyrim() then begin
// evaluate Icon properties
EvaluateEx(e, m, 'Icon', tag, debug);
EvaluateEx(e, m, 'Icon 2 (female)', tag, debug);
// assign First Person Flags elements
fpf := GetElement(e, 'BODT\First Person Flags');
if not Assigned(fpf) then exit;
fpfm := GetElement(m, 'BODT\First Person Flags');
// evaluate First Person Flags
if CompareKeys(fpf, fpfm, debug) then begin
AddTag(tag);
exit;
end;
// assign General Flags elements
gf := GetElement(e, 'BODT\General Flags');
if not Assigned(gf) then exit;
gfm := GetElement(m, 'BODT\General Flags');
// evaluate General Flags
if CompareKeys(gf, gfm, debug) then begin
AddTag(tag);
exit;
end;
// Skyrim
end else begin
// evaluate Icon properties
// TODO: check Obl/Sky for paths
EvaluateEx(e, m, 'ICON', tag, debug);
EvaluateEx(e, m, 'ICO2', tag, debug);
// evaluate Biped Model properties
EvaluateEx(e, m, 'Male biped model', tag, debug);
EvaluateEx(e, m, 'Female biped model', tag, debug);
// assign Biped Flags elements
bpf := GetElement(e, 'BODT\Biped Flags');
bpfm := GetElement(m, 'BODT\Biped Flags');
// evaluate Biped Flags
if CompareKeys(bpf, bpfm, debug) then begin
AddTag(tag);
exit;
end;
end;
end;
// evaluate CREA properties
if (sig ='CREA') then begin
EvaluateEx(e, m, 'NIFZ', tag, debug);
EvaluateEx(e, m, 'NIFT', tag, debug);
end;
// evaluate EFSH properties
if (sig = 'EFSH') then begin
// evaluate Record Flags
rf := GetElement(e, 'Record Header\Record Flags');
rfm := GetElement(m, 'Record Header\Record Flags');
if CompareKeys(rf, rfm, debug) then begin
AddTag(tag);
exit;
end;
// evaluate Icon properties
EvaluateEx(e, m, 'ICON', tag, debug);
EvaluateEx(e, m, 'ICO2', tag, debug);
// evaluate other properties
EvaluateEx(e, m, 'NAM7', tag, debug);
if IsSkyrim() then begin
EvaluateEx(e, m, 'NAM8', tag, debug);
EvaluateEx(e, m, 'NAM9', tag, debug);
end;
EvaluateEx(e, m, 'DATA', tag, debug);
end;
// v1.4: evaluate MGEF properties
if (sig = 'MGEF') and IsSkyrim() then begin
EvaluateEx(e, m, 'Magic Effect Data\DATA\Casting Light', tag, debug);
EvaluateEx(e, m, 'Magic Effect Data\DATA\Hit Shader', tag, debug);
EvaluateEx(e, m, 'Magic Effect Data\DATA\Enchant Shader', tag, debug);
end;
// evaluate Material property
if (sig = 'STAT') then
EvaluateEx(e, m, 'DNAM\Material', tag, debug);
end;
// ==================================================================
// Invent (written by the xEdit team)
procedure CheckInvent(e, m: IInterface; debug: boolean);
var
items, itemsmaster: IInterface;
begin
// define tag
tag := 'Invent';
// exit if tag exists
if TagExists(tag) then exit;
// assign Items properties
items := GetElement(e, 'Items');
itemsmaster := GetElement(m, 'Items');
// add tag if Items properties exist in one record but not the other
if Assigned(items) <> Assigned(itemsmaster) then begin
if debug then PrintDebugE(e, m, '[Assigned] ' + tag);
AddTag(tag);
exit;
end;
// exit if Items property does not exist in control record
if not Assigned(items) then exit;
// Items are sorted, so we don't need to compare by individual item
// SortKey combines all the items data
if CompareKeys(items, itemsmaster, debug) then AddTag(tag);
end;
// ==================================================================
// NpcFaces
procedure CheckNPCFaces(e, m: IInterface; debug: boolean);
begin
// define tag
tag := 'NpcFaces';
// exit if tag exists
if TagExists(tag) then exit;
// evaluate properties
EvaluateEx(e, m, 'HNAM', tag, debug);
EvaluateEx(e, m, 'LNAM', tag, debug);
EvaluateEx(e, m, 'ENAM', tag, debug);
EvaluateEx(e, m, 'HCLR', tag, debug);
EvaluateEx(e, m, 'FaceGen Data', tag, debug);
end;
// ==================================================================
// Body-F | Body-M | Body-Size-F | Body-Size-M
procedure CheckRaceBody(e, m: IInterface; tag: string; debug: boolean);
begin
// define tag
if TagExists(tag) then exit;
// evaluate Body-F properties
if (tag = 'Body-F') then
EvaluateEx(e, m, 'Body Data\Female Body Data\Parts', tag, debug);
// evaluate Body-M properties
if (tag = 'Body-M') then
EvaluateEx(e, m, 'Body Data\Male Body Data\Parts', tag, debug);
// evaluate Body-Size-F properties
if (tag = 'Body-Size-F') then begin
EvaluateEx(e, m, 'DATA\Female Height', tag, debug);
EvaluateEx(e, m, 'DATA\Female Weight', tag, debug);
end;
// evaluate Body-Size-M properties
if (tag = 'Body-Size-M') then begin
EvaluateEx(e, m, 'DATA\Male Height', tag, debug);
EvaluateEx(e, m, 'DATA\Male Weight', tag, debug);
end;
end;
// ==================================================================
// R.Ears | R.Head | R.Mouth | R.Teeth
procedure CheckRaceHead(e, m: IInterface; tag: string; debug: boolean);
begin
// exit if tag exists
if TagExists(tag) then exit;
// evaluate R.Head properties
if (tag = 'R.Head') then begin
EvaluateEx(e, m, 'Head Data\Male Head Data\Parts\[0]', tag, debug);
EvaluateEx(e, m, 'Head Data\Female Head Data\Parts\[0]', tag, debug);
EvaluateEx(e, m, 'FaceGen Data', tag, debug);
end;
// evaluate R.Ears properties
if (tag = 'R.Ears') then begin
EvaluateEx(e, m, 'Head Data\Male Head Data\Parts\[1]', tag, debug);
EvaluateEx(e, m, 'Head Data\Female Head Data\Parts\[1]', tag, debug);
end;
// evaluate R.Mouth properties
if (tag = 'R.Mouth') then begin
EvaluateEx(e, m, 'Head Data\Male Head Data\Parts\[2]', tag, debug);
EvaluateEx(e, m, 'Head Data\Female Head Data\Parts\[2]', tag, debug);
end;
// evaluate R.Teeth properties
if (tag = 'R.Teeth') then begin
EvaluateEx(e, m, 'Head Data\Male Head Data\Parts\[3]', tag, debug);
EvaluateEx(e, m, 'Head Data\Female Head Data\Parts\[3]', tag, debug);
// FO3
if IsFallout3() then begin
EvaluateEx(e, m, 'Head Data\Male Head Data\Parts\[4]', tag, debug);
EvaluateEx(e, m, 'Head Data\Female Head Data\Parts\[4]', tag, debug);
end;
end;
end;
// ==================================================================
// Sound - v1.4: 100% implementation
procedure CheckSound(e, m: IInterface; debug: boolean);
var
sig: string;
begin
tag := 'Sound';
if TagExists(tag) then exit;
sig := Signature(e);
// Activators, Containers, Doors, and Lights
if InSignatureList(sig, 'ACTI, CONT, DOOR, LIGH') then
EvaluateEx(e, m, 'SNAM', tag, debug);
// Activators
if (sig = 'ACTI') then
EvaluateEx(e, m, 'VNAM', tag, debug);
// Containers
if (sig = 'CONT') then begin
EvaluateEx(e, m, 'QNAM', tag, debug);
if not IsFallout3() or not IsSkyrim() then
EvaluateEx(e, m, 'RNAM', tag, debug); // FO3 and TESV don't have this element
end;
// Creatures
if (sig = 'CREA') then begin
EvaluateEx(e, m, 'WNAM', tag, debug);
EvaluateEx(e, m, 'CSCR', tag, debug);
EvaluateEx(e, m, 'Sound Types', tag, debug);
end;
// Doors
if (sig = 'DOOR') then begin
EvaluateEx(e, m, 'ANAM', tag, debug);
EvaluateEx(e, m, 'BNAM', tag, debug);
end;
// Lights - this is checked above
// Magic Effects
if (sig = 'MGEF') then begin
// TES5
if IsSkyrim() then
EvaluateEx(e, m, 'SNDD', tag, debug);
// FO3, FNV, TES4
if not IsSkyrim() then begin
EvaluateEx(e, m, 'DATA\Effect sound', tag, debug);
EvaluateEx(e, m, 'DATA\Bolt sound', tag, debug);
EvaluateEx(e, m, 'DATA\Hit sound', tag, debug);
EvaluateEx(e, m, 'DATA\Area sound', tag, debug);
end;
end;
// Weather
if (sig = 'WTHR') then
EvaluateEx(e, m, 'Sounds', tag, debug);
end;
// ==================================================================
// SpellStats
procedure CheckSpellStats(e, m: IInterface; debug: boolean);
begin
// define tag
tag := 'SpellStats';
// exit if tag exists
if TagExists(tag) then exit;
// evaluate properties
EvaluateEx(e, m, 'FULL', tag, debug);
EvaluateEx(e, m, 'SPIT', tag, debug);
end;
// ==================================================================