-
Notifications
You must be signed in to change notification settings - Fork 5
/
object_npcs.cpp
1531 lines (1393 loc) · 67.4 KB
/
object_npcs.cpp
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
#include "object_npcs.h"
namespace NPCS
{
struct patch_instruction create_patch_instruction(const std::string& line)
{
patch_instruction l;
// extract npcs
// extract objects
std::regex objects_regex("filterByNpcs\\s*=([^:]+)", regex::icase);
std::smatch objects_match;
std::regex_search(line, objects_match, objects_regex);
std::vector<std::string> objects;
if (objects_match.empty() || objects_match[1].str().empty()) {
//empty
} else {
std::string objects_str = objects_match[1];
std::regex objects_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator objects_iterator(objects_str.begin(), objects_str.end(), objects_list_regex);
std::sregex_iterator objects_end;
while (objects_iterator != objects_end) {
std::string tempVar = (*objects_iterator)[0].str();
tempVar.erase(tempVar.begin(), std::find_if_not(tempVar.begin(), tempVar.end(), ::isspace));
tempVar.erase(std::find_if_not(tempVar.rbegin(), tempVar.rend(), ::isspace).base(), tempVar.end());
//logger::info(FMT_STRING("Race: {}"), race);
if (tempVar != "none") {
objects.push_back(tempVar);
}
++objects_iterator;
}
l.object = objects;
}
// extract objectsExcluded
std::regex objectsExcluded_regex("filterByNpcsExcluded\\s*=([^:]+)", regex::icase);
std::smatch objectsExcluded_match;
std::regex_search(line, objectsExcluded_match, objectsExcluded_regex);
std::vector<std::string> objectsExcluded;
if (objectsExcluded_match.empty() || objectsExcluded_match[1].str().empty()) {
//empty
} else {
std::string objectsExcluded_str = objectsExcluded_match[1];
std::regex objectsExcluded_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator objectsExcluded_iterator(objectsExcluded_str.begin(), objectsExcluded_str.end(), objectsExcluded_list_regex);
std::sregex_iterator objectsExcluded_end;
while (objectsExcluded_iterator != objectsExcluded_end) {
std::string tempVar = (*objectsExcluded_iterator)[0].str();
tempVar.erase(tempVar.begin(), std::find_if_not(tempVar.begin(), tempVar.end(), ::isspace));
tempVar.erase(std::find_if_not(tempVar.rbegin(), tempVar.rend(), ::isspace).base(), tempVar.end());
//logger::info(FMT_STRING("Race: {}"), race);
if (tempVar != "none") {
objectsExcluded.push_back(tempVar);
}
++objectsExcluded_iterator;
}
l.objectExcluded = objectsExcluded;
}
// extract keywords
std::regex keywords_regex("filterByKeywords\\s*=([^:]+)", regex::icase);
std::smatch keywords_match;
std::regex_search(line, keywords_match, keywords_regex);
std::vector<std::string> keywords;
if (keywords_match.empty() || keywords_match[1].str().empty()) {
//empty
} else {
std::string keywords_str = keywords_match[1];
std::regex keywords_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator keywords_iterator(keywords_str.begin(), keywords_str.end(), keywords_list_regex);
std::sregex_iterator keywords_end;
while (keywords_iterator != keywords_end) {
std::string keyword = (*keywords_iterator)[0].str();
keyword.erase(keyword.begin(), std::find_if_not(keyword.begin(), keyword.end(), ::isspace));
keyword.erase(std::find_if_not(keyword.rbegin(), keyword.rend(), ::isspace).base(), keyword.end());
if (keyword != "none") {
keywords.push_back(keyword);
}
++keywords_iterator;
}
l.keywords = keywords;
}
// extract keywords
std::regex keywordsOr_regex("filterByKeywordsOr\\s*=([^:]+)", regex::icase);
std::smatch keywordsOr_match;
std::regex_search(line, keywordsOr_match, keywordsOr_regex);
std::vector<std::string> keywordsOr;
if (keywordsOr_match.empty() || keywordsOr_match[1].str().empty()) {
//empty
} else {
std::string keywordsOr_str = keywordsOr_match[1];
std::regex keywordsOr_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator keywordsOr_iterator(keywordsOr_str.begin(), keywordsOr_str.end(), keywordsOr_list_regex);
std::sregex_iterator keywordsOr_end;
while (keywordsOr_iterator != keywordsOr_end) {
std::string keyword = (*keywordsOr_iterator)[0].str();
keyword.erase(keyword.begin(), std::find_if_not(keyword.begin(), keyword.end(), ::isspace));
keyword.erase(std::find_if_not(keyword.rbegin(), keyword.rend(), ::isspace).base(), keyword.end());
if (keyword != "none") {
keywordsOr.push_back(keyword);
}
++keywordsOr_iterator;
}
l.keywordsOr = keywordsOr;
}
// extract keywords
std::regex keywordsExcluded_regex("filterByKeywordsExcluded\\s*=([^:]+)", regex::icase);
std::smatch keywordsExcluded_match;
std::regex_search(line, keywordsExcluded_match, keywordsExcluded_regex);
std::vector<std::string> keywordsExcluded;
if (keywordsExcluded_match.empty() || keywordsExcluded_match[1].str().empty()) {
//empty
} else {
std::string keywordsExcluded_str = keywordsExcluded_match[1];
std::regex keywordsExcluded_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator keywordsExcluded_iterator(keywordsExcluded_str.begin(), keywordsExcluded_str.end(), keywordsExcluded_list_regex);
std::sregex_iterator keywordsExcluded_end;
while (keywordsExcluded_iterator != keywordsExcluded_end) {
std::string keyword = (*keywordsExcluded_iterator)[0].str();
keyword.erase(keyword.begin(), std::find_if_not(keyword.begin(), keyword.end(), ::isspace));
keyword.erase(std::find_if_not(keyword.rbegin(), keyword.rend(), ::isspace).base(), keyword.end());
if (keyword != "none") {
keywordsExcluded.push_back(keyword);
}
++keywordsExcluded_iterator;
}
l.keywordsExcluded = keywordsExcluded;
}
// extract races
std::regex races_regex("filterByRaces\\s*=([^:]+)", regex::icase);
std::smatch races_match;
std::regex_search(line, races_match, races_regex);
std::vector<std::string> races;
if (races_match.empty() || races_match[1].str().empty()) {
//empty
} else {
std::string races_str = races_match[1];
std::regex races_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator races_iterator(races_str.begin(), races_str.end(), races_list_regex);
std::sregex_iterator races_end;
while (races_iterator != races_end) {
std::string race = (*races_iterator)[0].str();
race.erase(race.begin(), std::find_if_not(race.begin(), race.end(), ::isspace));
race.erase(std::find_if_not(race.rbegin(), race.rend(), ::isspace).base(), race.end());
//logger::info(FMT_STRING("Race: {}"), race);
if (race != "none") {
races.push_back(race);
}
++races_iterator;
}
l.races = races;
}
// extract Class
std::regex filterClass_regex("filterByClass\\s*=([^:]+)", regex::icase);
std::smatch filterClass_match;
std::regex_search(line, filterClass_match, filterClass_regex);
std::vector<std::string> Class;
if (filterClass_match.empty() || filterClass_match[1].str().empty()) {
//empty
} else {
std::string Class_str = filterClass_match[1];
std::regex Class_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator Class_iterator(Class_str.begin(), Class_str.end(), Class_list_regex);
std::sregex_iterator Class_end;
while (Class_iterator != Class_end) {
std::string race = (*Class_iterator)[0].str();
race.erase(race.begin(), std::find_if_not(race.begin(), race.end(), ::isspace));
race.erase(std::find_if_not(race.rbegin(), race.rend(), ::isspace).base(), race.end());
//logger::info(FMT_STRING("Race: {}"), race);
if (race != "none") {
Class.push_back(race);
}
++Class_iterator;
}
l.filterClass = Class;
}
// extract Faction
std::regex FactionAnd_regex("filterByFactions\\s*=([^:]+)", regex::icase);
std::smatch FactionAnd_match;
std::regex_search(line, FactionAnd_match, FactionAnd_regex);
std::vector<std::string> Faction;
if (FactionAnd_match.empty() || FactionAnd_match[1].str().empty()) {
//empty
} else {
std::string Faction_str = FactionAnd_match[1];
std::regex Faction_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator Faction_iterator(Faction_str.begin(), Faction_str.end(), Faction_list_regex);
std::sregex_iterator Faction_end;
while (Faction_iterator != Faction_end) {
std::string keyword = (*Faction_iterator)[0].str();
keyword.erase(keyword.begin(), std::find_if_not(keyword.begin(), keyword.end(), ::isspace));
keyword.erase(std::find_if_not(keyword.rbegin(), keyword.rend(), ::isspace).base(), keyword.end());
if (keyword != "none") {
Faction.push_back(keyword);
}
++Faction_iterator;
}
l.filterFactions = Faction;
}
// extract Faction
std::regex FactionOr_regex("filterByFactionsOr\\s*=([^:]+)", regex::icase);
std::smatch FactionOr_match;
std::regex_search(line, FactionOr_match, FactionOr_regex);
std::vector<std::string> FactionOr;
if (FactionOr_match.empty() || FactionOr_match[1].str().empty()) {
//empty
} else {
std::string FactionOr_str = FactionOr_match[1];
std::regex FactionOr_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator FactionOr_iterator(FactionOr_str.begin(), FactionOr_str.end(), FactionOr_list_regex);
std::sregex_iterator FactionOr_end;
while (FactionOr_iterator != FactionOr_end) {
std::string keyword = (*FactionOr_iterator)[0].str();
keyword.erase(keyword.begin(), std::find_if_not(keyword.begin(), keyword.end(), ::isspace));
keyword.erase(std::find_if_not(keyword.rbegin(), keyword.rend(), ::isspace).base(), keyword.end());
if (keyword != "none") {
FactionOr.push_back(keyword);
}
++FactionOr_iterator;
}
l.filterFactionsOr = FactionOr;
}
// extract Faction
std::regex FactionExcluded_regex("filterByFactionsExcluded\\s*=([^:]+)", regex::icase);
std::smatch FactionExcluded_match;
std::regex_search(line, FactionExcluded_match, FactionExcluded_regex);
std::vector<std::string> FactionExcluded;
if (FactionExcluded_match.empty() || FactionExcluded_match[1].str().empty()) {
//empty
} else {
std::string FactionExcluded_str = FactionExcluded_match[1];
std::regex FactionExcluded_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator FactionExcluded_iterator(FactionExcluded_str.begin(), FactionExcluded_str.end(), FactionExcluded_list_regex);
std::sregex_iterator FactionExcluded_end;
while (FactionExcluded_iterator != FactionExcluded_end) {
std::string keyword = (*FactionExcluded_iterator)[0].str();
keyword.erase(keyword.begin(), std::find_if_not(keyword.begin(), keyword.end(), ::isspace));
keyword.erase(std::find_if_not(keyword.rbegin(), keyword.rend(), ::isspace).base(), keyword.end());
if (keyword != "none") {
FactionExcluded.push_back(keyword);
}
++FactionExcluded_iterator;
}
l.filterFactionsExcluded = FactionExcluded;
}
// extract autoCalcStats
std::regex list_regex("setAutoCalcStats\\s*=([^:]+)", regex::icase);
std::smatch listmatch;
std::regex_search(line, listmatch, list_regex);
// extract the value after the equals sign
if (listmatch.empty() || listmatch[1].str().empty()) {
l.calcStats = "none";
} else {
std::string tempString = listmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.calcStats = tempString;
}
// extract pclevelmult
std::regex pclevelmultlist_regex("setPcLevelMult\\s*=([^:]+)", regex::icase);
std::smatch pclevelmultlistmatch;
std::regex_search(line, pclevelmultlistmatch, pclevelmultlist_regex);
// extract the value after the equals sign
if (pclevelmultlistmatch.empty() || pclevelmultlistmatch[1].str().empty()) {
l.kPCLevelMult = "none";
} else {
std::string tempString = pclevelmultlistmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.kPCLevelMult = tempString;
}
// extract Essential
std::regex essentiallist_regex("setEssential\\s*=([^:]+)", regex::icase);
std::smatch essentiallistmatch;
std::regex_search(line, essentiallistmatch, essentiallist_regex);
// extract the value after the equals sign
if (essentiallistmatch.empty() || essentiallistmatch[1].str().empty()) {
l.kEssential = "none";
} else {
std::string tempString = essentiallistmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.kEssential = tempString;
}
// extract Protected
std::regex Protectedlist_regex("setProtected\\s*=([^:]+)", regex::icase);
std::smatch Protectedlistmatch;
std::regex_search(line, Protectedlistmatch, Protectedlist_regex);
// extract the value after the equals sign
if (Protectedlistmatch.empty() || Protectedlistmatch[1].str().empty()) {
l.kProtected = "none";
} else {
std::string tempString = Protectedlistmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.kProtected = tempString;
}
// extract getLevelRange
std::regex levelRange_regex("levelRange\\s*=\\s*(\\d+)\\s*~\\s*(\\d+)", regex::icase);
std::smatch levelRange;
std::regex_search(line, levelRange, levelRange_regex);
if (levelRange.empty() || levelRange.size() < 3) {
l.level_min = "none";
l.level_max = "none";
} else {
l.level_min = levelRange[1].str();
l.level_max = levelRange[2].str();
}
// extract avifs
std::regex avifs_regex("changeAVIFS\\s*=([^:]+)", regex::icase);
std::smatch avifs_match;
std::regex_search(line, avifs_match, avifs_regex);
std::vector<std::string> avifs_before_eq;
std::vector<float> avifs_min_values;
std::vector<float> avifs_max_values;
if (avifs_match.empty() || avifs_match[1].str().empty()) {
//empty
} else {
std::string avifs_str = avifs_match[1];
std::regex avifs_list_regex("([^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8})\\s*=\\s*([\\d.]+)(?:\\s*~\\s*([\\d.]+))?", regex::icase);
std::sregex_iterator avifs_iterator(avifs_str.begin(), avifs_str.end(), avifs_list_regex);
std::sregex_iterator avifs_end;
while (avifs_iterator != avifs_end) {
std::string avif = (*avifs_iterator)[1].str();
avif.erase(avif.begin(), std::find_if_not(avif.begin(), avif.end(), ::isspace));
avif.erase(std::find_if_not(avif.rbegin(), avif.rend(), ::isspace).base(), avif.end());
if (avif == "none") {
break;
}
avifs_before_eq.push_back(avif);
avifs_min_values.push_back(std::stof((*avifs_iterator)[2]));
if ((*avifs_iterator)[3] != "") {
avifs_max_values.push_back(std::stof((*avifs_iterator)[3]));
} else {
avifs_max_values.push_back(std::stof((*avifs_iterator)[2]));
}
std::string val1 = ((*avifs_iterator)[2]);
std::string val2 = ((*avifs_iterator)[3] != "") ? ((*avifs_iterator)[3]) : ((*avifs_iterator)[2]);
//logger::info(FMT_STRING("avif: {}"), avif);
//logger::info(FMT_STRING("value1: {}"), val1);
//logger::info(FMT_STRING("value2: {}"), val2);
++avifs_iterator;
}
l.avifs = avifs_before_eq;
l.values1 = avifs_min_values;
l.values2 = avifs_max_values;
}
// extract Faction
std::regex Faction_regex("factionsToAdd\\s*=([^:]+)", regex::icase);
std::smatch Faction_match;
std::regex_search(line, Faction_match, Faction_regex);
std::vector<std::string> Faction_before_eq;
std::vector<float> Faction_min_values;
std::vector<float> Faction_max_values;
if (Faction_match.empty() || Faction_match[1].str().empty()) {
//empty
} else {
std::string Faction_str = Faction_match[1];
std::regex Faction_list_regex("([^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8})\\s*=\\s*([\\d.]+)(?:\\s*~\\s*([\\d.]+))?", regex::icase);
std::sregex_iterator Faction_iterator(Faction_str.begin(), Faction_str.end(), Faction_list_regex);
std::sregex_iterator Faction_end;
while (Faction_iterator != Faction_end) {
std::string avif = (*Faction_iterator)[1].str();
avif.erase(avif.begin(), std::find_if_not(avif.begin(), avif.end(), ::isspace));
avif.erase(std::find_if_not(avif.rbegin(), avif.rend(), ::isspace).base(), avif.end());
if (avif == "none") {
break;
}
Faction_before_eq.push_back(avif);
Faction_min_values.push_back(std::stof((*Faction_iterator)[2]));
if ((*Faction_iterator)[3] != "") {
Faction_max_values.push_back(std::stof((*Faction_iterator)[3]));
} else {
Faction_max_values.push_back(std::stof((*Faction_iterator)[2]));
}
std::string val1 = ((*Faction_iterator)[2]);
std::string val2 = ((*Faction_iterator)[3] != "") ? ((*Faction_iterator)[3]) : ((*Faction_iterator)[2]);
//logger::info(FMT_STRING("avif: {}"), avif);
//logger::info(FMT_STRING("value1: {}"), val1);
//logger::info(FMT_STRING("value2: {}"), val2);
++Faction_iterator;
}
l.factionsToAdd = Faction_before_eq;
l.factionsToAddRank1 = Faction_min_values;
l.factionsToAddRank2 = Faction_max_values;
}
// extract keywordsToAdd
std::regex keywordsToAdd_regex("keywordsToAdd\\s*=([^:]+)", regex::icase);
std::smatch keywordsToAdd_match;
std::regex_search(line, keywordsToAdd_match, keywordsToAdd_regex);
std::vector<std::string> keywordsToAdd;
if (keywordsToAdd_match.empty() || keywordsToAdd_match[1].str().empty()) {
//empty
} else {
std::string keywordsToAdd_str = keywordsToAdd_match[1];
std::regex keywordsToAdd_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator keywordsToAdd_iterator(keywordsToAdd_str.begin(), keywordsToAdd_str.end(), keywordsToAdd_list_regex);
std::sregex_iterator keywordsToAdd_end;
while (keywordsToAdd_iterator != keywordsToAdd_end) {
std::string keywordToAdd = (*keywordsToAdd_iterator)[0].str();
keywordToAdd.erase(keywordToAdd.begin(), std::find_if_not(keywordToAdd.begin(), keywordToAdd.end(), ::isspace));
keywordToAdd.erase(std::find_if_not(keywordToAdd.rbegin(), keywordToAdd.rend(), ::isspace).base(), keywordToAdd.end());
if (keywordToAdd != "none") {
//logger::info(FMT_STRING("keywordsToAdd: {}"), keywordToAdd);
keywordsToAdd.push_back(keywordToAdd);
}
++keywordsToAdd_iterator;
}
l.keywordsToAdd = keywordsToAdd;
}
// extract keywordsToRemove
std::regex keywordsToRemove_regex("keywordsToRemove\\s*=([^:]+)", regex::icase);
std::smatch keywordsToRemove_match;
std::regex_search(line, keywordsToRemove_match, keywordsToRemove_regex);
std::vector<std::string> keywordsToRemove;
if (keywordsToRemove_match.empty() || keywordsToRemove_match[1].str().empty()) {
//empty
} else {
std::string keywordsToRemove_str = keywordsToRemove_match[1];
std::regex keywordsToRemove_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator keywordsToRemove_iterator(keywordsToRemove_str.begin(), keywordsToRemove_str.end(), keywordsToRemove_list_regex);
std::sregex_iterator keywordsToRemove_end;
while (keywordsToRemove_iterator != keywordsToRemove_end) {
std::string keywordToRemove = (*keywordsToRemove_iterator)[0].str();
keywordToRemove.erase(keywordToRemove.begin(), std::find_if_not(keywordToRemove.begin(), keywordToRemove.end(), ::isspace));
keywordToRemove.erase(std::find_if_not(keywordToRemove.rbegin(), keywordToRemove.rend(), ::isspace).base(), keywordToRemove.end());
if (keywordToRemove != "none") {
//logger::info(FMT_STRING("keywordsToRemove: {}"), keywordToRemove);
keywordsToRemove.push_back(keywordToRemove);
}
++keywordsToRemove_iterator;
}
l.keywordsToRemove = keywordsToRemove;
}
// extract factionsToRemove
std::regex factionsToRemove_regex("factionsToRemove\\s*=([^:]+)", regex::icase);
std::smatch factionsToRemove_match;
std::regex_search(line, factionsToRemove_match, factionsToRemove_regex);
std::vector<std::string> factionsToRemove;
if (factionsToRemove_match.empty() || factionsToRemove_match[1].str().empty()) {
//empty
} else {
std::string factionsToRemove_str = factionsToRemove_match[1];
std::regex factionsToRemove_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator factionsToRemove_iterator(factionsToRemove_str.begin(), factionsToRemove_str.end(), factionsToRemove_list_regex);
std::sregex_iterator factionsToRemove_end;
while (factionsToRemove_iterator != factionsToRemove_end) {
std::string keywordToRemove = (*factionsToRemove_iterator)[0].str();
keywordToRemove.erase(keywordToRemove.begin(), std::find_if_not(keywordToRemove.begin(), keywordToRemove.end(), ::isspace));
keywordToRemove.erase(std::find_if_not(keywordToRemove.rbegin(), keywordToRemove.rend(), ::isspace).base(), keywordToRemove.end());
if (keywordToRemove != "none") {
//logger::info(FMT_STRING("factionsToRemove: {}"), keywordToRemove);
factionsToRemove.push_back(keywordToRemove);
}
++factionsToRemove_iterator;
}
l.factionsToRemove = factionsToRemove;
}
// extract perksToAdd
std::regex perksToAdd_regex("perksToAdd\\s*=([^:]+)", regex::icase);
std::smatch perksToAdd_match;
std::regex_search(line, perksToAdd_match, perksToAdd_regex);
std::vector<std::string> perksToAdd;
if (perksToAdd_match.empty() || perksToAdd_match[1].str().empty()) {
//empty
} else {
std::string perksToAdd_str = perksToAdd_match[1];
std::regex perksToAdd_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator perksToAdd_iterator(perksToAdd_str.begin(), perksToAdd_str.end(), perksToAdd_list_regex);
std::sregex_iterator perksToAdd_end;
while (perksToAdd_iterator != perksToAdd_end) {
std::string perkToAdd = (*perksToAdd_iterator)[0].str();
perkToAdd.erase(perkToAdd.begin(), std::find_if_not(perkToAdd.begin(), perkToAdd.end(), ::isspace));
perkToAdd.erase(std::find_if_not(perkToAdd.rbegin(), perkToAdd.rend(), ::isspace).base(), perkToAdd.end());
if ((*perksToAdd_iterator)[0].str() != "none") {
//logger::info(FMT_STRING("perksToAdd: {}"), perkToAdd);
perksToAdd.push_back(perkToAdd);
}
++perksToAdd_iterator;
}
l.perksToAdd = perksToAdd;
}
std::regex objectsToAdd_regex("objectsToAdd\\s*=([^:]+)", regex::icase);
std::smatch objectsToAdd_match;
std::regex_search(line, objectsToAdd_match, objectsToAdd_regex);
std::vector<std::string> objectsToAdd;
if (objectsToAdd_match.empty() || objectsToAdd_match[1].str().empty()) {
//empty
} else {
std::string objectsToAdd_str = objectsToAdd_match[1];
std::regex pattern("([^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8})\\s*=\\s*([^,]+)", regex::icase);
std::smatch match;
auto begin = std::sregex_iterator(objectsToAdd_str.begin(), objectsToAdd_str.end(), pattern);
auto end = std::sregex_iterator();
for (std::sregex_iterator i = begin; i != end; ++i) {
std::smatch match = *i;
l.objectsToAdd.push_back(match[1]);
l.objectsToAddValue.push_back(match[2]);
//logger::debug(FMT_STRING("Match: {} {}"), match[1].str(), match[2].str());
}
}
// extract ObjectsToRemove
std::regex ObjectsToRemove_regex("ObjectsToRemove\\s*=([^:]+)", regex::icase);
std::smatch ObjectsToRemove_match;
std::regex_search(line, ObjectsToRemove_match, ObjectsToRemove_regex);
std::vector<std::string> ObjectsToRemove;
if (ObjectsToRemove_match.empty() || ObjectsToRemove_match[1].str().empty()) {
//empty
} else {
std::string ObjectsToRemove_str = ObjectsToRemove_match[1];
std::regex ObjectsToRemove_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator ObjectsToRemove_iterator(ObjectsToRemove_str.begin(), ObjectsToRemove_str.end(), ObjectsToRemove_list_regex);
std::sregex_iterator ObjectsToRemove_end;
while (ObjectsToRemove_iterator != ObjectsToRemove_end) {
std::string keywordToRemove = (*ObjectsToRemove_iterator)[0].str();
keywordToRemove.erase(keywordToRemove.begin(), std::find_if_not(keywordToRemove.begin(), keywordToRemove.end(), ::isspace));
keywordToRemove.erase(std::find_if_not(keywordToRemove.rbegin(), keywordToRemove.rend(), ::isspace).base(), keywordToRemove.end());
if (keywordToRemove != "none") {
//logger::info(FMT_STRING("ObjectsToRemove: {}"), keywordToRemove);
ObjectsToRemove.push_back(keywordToRemove);
}
++ObjectsToRemove_iterator;
}
l.objectsToRemove = ObjectsToRemove;
}
// extract Outfit
std::regex Outfit_regex("outfitDefault\\s*=([^:]+)", regex::icase);
std::smatch outfitDefaultmatch;
std::regex_search(line, outfitDefaultmatch, Outfit_regex);
// extract the value after the equals sign
if (outfitDefaultmatch.empty() || outfitDefaultmatch[1].str().empty()) {
l.outfitDefault = "none";
} else {
std::string tempString = outfitDefaultmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.outfitDefault = tempString;
}
// extract Outfit
std::regex OutfitSleep_regex("outfitSleep\\s*=([^:]+)", regex::icase);
std::smatch outfitSleepmatch;
std::regex_search(line, outfitSleepmatch, OutfitSleep_regex);
// extract the value after the equals sign
if (outfitSleepmatch.empty() || outfitSleepmatch[1].str().empty()) {
l.outfitSleep = "none";
} else {
std::string tempString = outfitSleepmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.outfitSleep = tempString;
}
// extract deathItem
std::regex DeathItem_regex("deathItem\\s*=([^:]+)", regex::icase);
std::smatch DeathItemmatch;
std::regex_search(line, DeathItemmatch, DeathItem_regex);
// extract the value after the equals sign
if (DeathItemmatch.empty() || DeathItemmatch[1].str().empty()) {
l.deathItem = "none";
} else {
std::string tempString = DeathItemmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.deathItem = tempString;
}
// extract Skin
std::regex skin_regex("skin\\s*=([^:]+)", regex::icase);
std::smatch skinmatch;
std::regex_search(line, skinmatch, skin_regex);
// extract the value after the equals sign
if (skinmatch.empty() || skinmatch[1].str().empty()) {
l.skin = "none";
} else {
std::string tempString = skinmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.skin = tempString;
}
// extract Race
std::regex Race_regex("race\\s*=([^:]+)", regex::icase);
std::smatch Racematch;
std::regex_search(line, Racematch, Race_regex);
// extract the value after the equals sign
if (Racematch.empty() || Racematch[1].str().empty()) {
l.race = "none";
} else {
std::string tempString = Racematch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.race = tempString;
}
// extract powerArmorStand
std::regex powerArmorStand_regex("powerArmorStand\\s*=([^:]+)", regex::icase);
std::smatch powerArmorStandmatch;
std::regex_search(line, powerArmorStandmatch, powerArmorStand_regex);
// extract the value after the equals sign
if (powerArmorStandmatch.empty() || powerArmorStandmatch[1].str().empty()) {
l.powerArmorStand = "none";
} else {
std::string tempString = powerArmorStandmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.powerArmorStand = tempString;
}
// extract Class
std::regex Class_regex("class\\s*=([^:]+)", regex::icase);
std::smatch Classmatch;
std::regex_search(line, Classmatch, Class_regex);
// extract the value after the equals sign
if (Classmatch.empty() || Classmatch[1].str().empty()) {
l.Class = "none";
} else {
std::string tempString = Classmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.Class = tempString;
}
// extract xpOffsetValue
std::regex xpOffsetValue_regex("xpValueOffset\\s*=([^:]+)", regex::icase);
std::smatch xpmatch;
std::regex_search(line, xpmatch, xpOffsetValue_regex);
// extract the value after the equals sign
if (xpmatch.empty() || xpmatch[1].str().empty()) {
l.xpValueOffset = "none";
} else {
std::string tempString = xpmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.xpValueOffset = tempString;
}
// extract level
std::regex level_regex("level\\s*=([^:]+)", regex::icase);
std::smatch lvlmatch;
std::regex_search(line, lvlmatch, level_regex);
// extract the value after the equals sign
if (lvlmatch.empty() || lvlmatch[1].str().empty()) {
l.level = "none";
} else {
std::string tempString = lvlmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.level = tempString;
}
// extract calcLevelMin
std::regex calcLevelMin_regex("calcLevelMin\\s*=([^:]+)", regex::icase);
std::smatch lminmatch;
std::regex_search(line, lminmatch, calcLevelMin_regex);
// extract the value after the equals sign
if (lminmatch.empty() || lminmatch[1].str().empty()) {
l.calcLevelMin = "none";
} else {
std::string tempString = lminmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.calcLevelMin = tempString;
}
// extract calcLevelMax
std::regex calcLevelMax_regex("calcLevelMax\\s*=([^:]+)", regex::icase);
std::smatch lmaxmatch;
std::regex_search(line, lmaxmatch, calcLevelMax_regex);
// extract the value after the equals sign
if (lmaxmatch.empty() || lmaxmatch[1].str().empty()) {
l.calcLevelMax = "none";
} else {
std::string tempString = lmaxmatch[1].str();
tempString.erase(tempString.begin(), std::find_if_not(tempString.begin(), tempString.end(), ::isspace));
tempString.erase(std::find_if_not(tempString.rbegin(), tempString.rend(), ::isspace).base(), tempString.end());
l.calcLevelMax = tempString;
}
// extract spellsToAdd
std::regex spellsToAdd_regex("spellsToAdd\\s*=([^:]+)", regex::icase);
std::smatch spellsToAdd_match;
std::regex_search(line, spellsToAdd_match, spellsToAdd_regex);
std::vector<std::string> spellsToAdd;
if (spellsToAdd_match.empty() || spellsToAdd_match[1].str().empty()) {
//empty
} else {
std::string spellsToAdd_str = spellsToAdd_match[1];
std::regex spellsToAdd_list_regex("[^,]+[ ]*[|][ ]*[a-zA-Z0-9]{1,8}", regex::icase);
std::sregex_iterator spellsToAdd_iterator(spellsToAdd_str.begin(), spellsToAdd_str.end(), spellsToAdd_list_regex);
std::sregex_iterator spellsToAdd_end;
while (spellsToAdd_iterator != spellsToAdd_end) {
std::string spellToAdd = (*spellsToAdd_iterator)[0].str();
spellToAdd.erase(spellToAdd.begin(), std::find_if_not(spellToAdd.begin(), spellToAdd.end(), ::isspace));
spellToAdd.erase(std::find_if_not(spellToAdd.rbegin(), spellToAdd.rend(), ::isspace).base(), spellToAdd.end());
if ((*spellsToAdd_iterator)[0].str() != "none") {
//logger::info(FMT_STRING("spellsToAdd: {}"), spellToAdd);
spellsToAdd.push_back(spellToAdd);
}
++spellsToAdd_iterator;
}
l.spellsToAdd = spellsToAdd;
}
// extract isFemale
std::regex isFemale_regex("filterByGender\\s*=([^:]+)", regex::icase);
std::smatch isfemalematch;
std::regex_search(line, isfemalematch, isFemale_regex);
// extract the value after the equals sign
if (isfemalematch.empty() || isfemalematch[1].str().empty()) {
l.isFemale = "none";
} else {
std::string isfemalevalue = isfemalematch[1].str();
isfemalevalue.erase(isfemalevalue.begin(), std::find_if_not(isfemalevalue.begin(), isfemalevalue.end(), ::isspace));
isfemalevalue.erase(std::find_if_not(isfemalevalue.rbegin(), isfemalevalue.rend(), ::isspace).base(), isfemalevalue.end());
l.isFemale = isfemalevalue;
}
// extract fullName
std::regex fullName_regex("fullName\\s*=\\s*~([^~]+?)\\s*~");
std::smatch namematch;
std::regex_search(line, namematch, fullName_regex);
// extract the value after the equals sign
if (namematch.empty() || namematch[1].str().empty()) {
l.fullName = "none";
} else {
std::string namevalue = namematch[1].str();
namevalue.erase(namevalue.begin(), std::find_if_not(namevalue.begin(), namevalue.end(), ::isspace));
namevalue.erase(std::find_if_not(namevalue.rbegin(), namevalue.rend(), ::isspace).base(), namevalue.end());
l.fullName = namevalue;
}
logger::debug(FMT_STRING("npcs: {} races: {} keywords: {} avifs: {} keywordsToAdd: {} perksToAdd {}"), l.object.size(), l.races.size(), l.keywords.size(), l.avifs.size(), l.keywordsToAdd.size(), l.perksToAdd.size());
//logger::info("returning patch instructions");
return l;
}
void process_patch_instructions(const std::list<patch_instruction>& tokens)
{
logger::debug("processing patch instructions");
const auto dataHandler = RE::TESDataHandler::GetSingleton();
RE::BSTArray<RE::TESNPC*> NPCArray = dataHandler->GetFormArray<RE::TESNPC>();
for (const auto& line : tokens) {
//logger::info("processing config line");
for (const auto& curobj : NPCArray) {
bool found = false;
bool keywordAnd = false;
bool keywordOr = false;
bool factionAnd = false;
bool factionOr = false;
//curobj.
if (!line.object.empty()) {
//logger::info("npc not empty");
for (const auto& npcstring : line.object) {
RE::TESForm* currentform = nullptr;
RE::TESNPC* npc = nullptr;
std::string string_form = npcstring;
currentform = GetFormFromIdentifier(string_form);
if (currentform && currentform->formType == RE::ENUM_FORM_ID::kNPC_) {
npc = (RE::TESNPC*)currentform;
if (curobj->formID == npc->formID) {
found = true;
//logger::info("NPC found.");
break;
}
}
}
}
if (!line.filterClass.empty()) {
//logger::info("npc not empty");
for (const auto& npcstring : line.filterClass) {
RE::TESForm* currentform = nullptr;
RE::TESClass* npc = nullptr;
std::string string_form = npcstring;
currentform = GetFormFromIdentifier(string_form);
if (currentform && currentform->formType == RE::ENUM_FORM_ID::kCLAS) {
npc = (RE::TESClass*)currentform;
if (curobj->cl->formID == npc->formID) {
found = true;
//logger::info("NPC found.");
break;
}
}
}
}
if (!found && !line.races.empty() && curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::info("race not empty");
for (const auto& racestring : line.races) {
RE::TESForm* currentform = nullptr;
RE::TESRace* race = nullptr;
std::string string_form = racestring;
currentform = GetFormFromIdentifier(string_form);
if (currentform && currentform->formType == RE::ENUM_FORM_ID::kRACE) {
race = (RE::TESRace*)currentform;
if (curobj->formRace == race) {
found = true;
//logger::debug(FMT_STRING("Found a matching npc by race({:08X} {}). {:08X} {}"), race->formID, race->fullName, curobj->formID, curobj->fullName );
break;
}
}
}
}
if (!line.keywords.empty() && curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::info("keywords not empty");
for (const auto& keywordstring : line.keywords) {
RE::TESForm* currentform = nullptr;
RE::BGSKeyword* keyword = nullptr;
std::string string_form = keywordstring;
currentform = GetFormFromIdentifier(string_form);
if (currentform && currentform->formType == RE::ENUM_FORM_ID::kKYWD) {
keyword = (RE::BGSKeyword*)currentform;
if (curobj->HasKeyword(keyword) || curobj->baseTemplateForm == nullptr && curobj->formRace->HasKeyword(keyword)) {
keywordAnd = true;
} else {
keywordAnd = false;
//logger::debug(FMT_STRING("KeywordAnd npc does not have all keywords"));
break;
}
//logger::debug(FMT_STRING("KeywordAnd npc true"));
}
}
} else if (curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::debug(FMT_STRING("KeywordAnd is empty, we pass true."));
keywordAnd = true;
}
if (!line.keywordsOr.empty() && curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::info("keywords not empty");
for (const auto& keywordstring : line.keywordsOr) {
RE::TESForm* currentform = nullptr;
RE::BGSKeyword* keyword = nullptr;
std::string string_form = keywordstring;
currentform = GetFormFromIdentifier(string_form);
if (currentform && currentform->formType == RE::ENUM_FORM_ID::kKYWD) {
keyword = (RE::BGSKeyword*)currentform;
if (curobj->HasKeyword(keyword) || curobj->baseTemplateForm == nullptr && curobj->formRace->HasKeyword(keyword) ) {
keywordOr = true;
//logger::debug(FMT_STRING("KeywordOr has at least one keyword true {:08X} {:08X} race {:08X}"), curobj->formID, keyword->formID, curobj->formRace->formID);
//logger::info("Keyword found.");
break;
}
}
}
} else if (curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::debug(FMT_STRING("KeywordOr is empty, we pass true."));
keywordOr = true;
}
if (!line.filterFactions.empty() && curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::info("filterByFaction not empty");
for (const auto& filterByFactiontring : line.filterFactions) {
RE::TESForm* currentform = nullptr;
RE::TESFaction* keyword = nullptr;
std::string string_form = filterByFactiontring;
currentform = GetFormFromIdentifier(string_form);
if (currentform && currentform->formType == RE::ENUM_FORM_ID::kFACT) {
keyword = (RE::TESFaction*)currentform;
if (curobj->hasFaction(keyword)) {
factionAnd = true;
} else {
factionAnd = false;
//logger::debug(FMT_STRING("KeywordAnd npc does not have all filterByFaction"));
break;
}
//logger::debug(FMT_STRING("KeywordAnd npc true"));
}
}
} else if (curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::debug(FMT_STRING("KeywordAnd is empty, we pass true."));
factionAnd = true;
}
if (!line.filterFactionsOr.empty() && curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::info("keywords not empty");
for (const auto& keywordstring : line.filterFactionsOr) {
RE::TESForm* currentform = nullptr;
RE::TESFaction* keyword = nullptr;
std::string string_form = keywordstring;
currentform = GetFormFromIdentifier(string_form);
if (currentform && currentform->formType == RE::ENUM_FORM_ID::kFACT) {
keyword = (RE::TESFaction*)currentform;
if (curobj->hasFaction(keyword) ) {
factionOr = true;
//logger::debug(FMT_STRING("NPC has faction {:08X}"), curobj->formID, curobj->fullName);
//logger::info("Keyword found.");
break;
}
}
}
} else if (curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::debug(FMT_STRING("KeywordAnd is empty, we pass true."));
factionOr = true;
}
if ((!line.keywords.empty() || !line.keywordsOr.empty()) && keywordAnd && keywordOr) {
logger::debug(FMT_STRING("Found a matching npc by keywords. {:08X} {}"), curobj->formID, curobj->fullName);
found = true;
}
if ((!line.filterFactions.empty() || !line.filterFactionsOr.empty()) && factionAnd && factionOr) {
//logger::debug(FMT_STRING("Found a matching npc by keywords. {:08X} {}"), curobj->formID, curobj->fullName);
found = true;
}
if (!found && line.object.empty() && line.races.empty() && line.keywords.empty() && line.keywordsOr.empty() && line.filterClass.empty() && line.filterFactions.empty() && line.filterFactionsOr.empty() && curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
found = true;
//logger::debug(FMT_STRING("Patch Everything but skip Player {:08X}"), curobj->formID);
}
if (found && !line.isFemale.empty() && line.isFemale != "none") {
std::string lowercaseIsFemale = line.isFemale;
std::transform(lowercaseIsFemale.begin(), lowercaseIsFemale.end(), lowercaseIsFemale.begin(), [](unsigned char c) { return std::tolower(c); });
if ((lowercaseIsFemale == "female")) {
if (curobj->actorData.actorBaseFlags & RE::ACTOR_BASE_DATA::Flag::kFemale) {
found = true;
//logger::debug(FMT_STRING("is female {:08X} {}"), curobj->formID, curobj->fullName);
} else {
found = false;
//logger::debug(FMT_STRING("is not female {:08X} {}"), curobj->formID, curobj->fullName);
}
} else if ((lowercaseIsFemale == "male")) {
if (!(curobj->actorData.actorBaseFlags & RE::ACTOR_BASE_DATA::Flag::kFemale)) {
//logger::debug(FMT_STRING("is male {:08X} {}"), curobj->formID, curobj->fullName);
found = true;
} else {
//logger::debug(FMT_STRING("is not male {:08X} {}"), curobj->formID, curobj->fullName);
found = false;
}
}
}
if (!line.keywordsExcluded.empty() && curobj->formID != 0x000007 && !curobj->HasKeyword(PlayerKeyword)) {
//logger::info("keywords not empty");
for (const auto& keywordstring : line.keywordsExcluded) {
RE::TESForm* currentform = nullptr;
RE::BGSKeyword* keyword = nullptr;
std::string string_form = keywordstring;
currentform = GetFormFromIdentifier(string_form);
if (currentform && currentform->formType == RE::ENUM_FORM_ID::kKYWD) {
keyword = (RE::BGSKeyword*)currentform;
if (curobj->HasKeyword(keyword) || curobj->baseTemplateForm == nullptr && curobj->formRace->HasKeyword(keyword)) {
found = false;
//logger::debug(FMT_STRING("KeywordExcluded has a keyword that is excluded.{:08X}"), keyword->formID);
//logger::info("Keyword found.");
break;
}