-
Notifications
You must be signed in to change notification settings - Fork 2
/
HorizonAwkcr.pas
197 lines (162 loc) · 6.69 KB
/
HorizonAwkcr.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
{
Attempts to copy some of Horizon's recipes to the various AWKCR benches.
As opposed to Horizonifier, this can and should be run on Horizon itself.
}
unit HorizonAwkcr;
uses praUtil;
uses praFunctions;
var
setupDone: boolean;
akcrFile: IwbFile;
// horiFile: IwbFile;
architectFile: IwbFile;
ToFile: IwbFile;
explosiveKeyword: IInterface;
ammoKeyword: IInterface;
weaponKeyword: IInterface;
armorKeyword: IInterface;
weaponLabKeyword : IInterface;
techLabKeyword : IInterface;
ammoKeywords: TStringList;
function getNewCobjEdid(oldEdid: String): string;
begin
result := 'AWKCR_HZ_AUTO_'+oldEdid;
end;
function doSetup(): boolean;
begin
akcrFile := findFile('ArmorKeywords.esm');
// horiFile := findFile('Z_Horizon.esp');
architectFile := findFile('Z_Architect.esm');
if(not assigned(akcrFile)) then begin
AddMessage('ArmorKeywords.esm not found!');
Result := false;
exit;
end;
if(not assigned(architectFile)) then begin
AddMessage('Z_Architect.esm not found!');
Result := false;
exit;
end;
// relevant KWs from Horizon:
// WorkbenchWeaponsLab [KYWD:07122192] = weapon lab
// WorkbenchRoboticsLab [KYWD:07004CEE] = tech lab
weaponLabKeyword := MainRecordByEditorID(GroupBySignature(architectFile, 'KYWD'), 'WorkbenchWeaponsLab_Arc');
techLabKeyword := MainRecordByEditorID(GroupBySignature(architectFile, 'KYWD'), 'WorkbenchTechLab_Arc');
{ weaponLabKeyword := MainRecordByEditorID(GroupBySignature(horiFile, 'KYWD'), 'WorkbenchWeaponsLab'); }
{ techLabKeyword := MainRecordByEditorID(GroupBySignature(horiFile, 'KYWD'), 'WorkbenchRoboticsLab'); }
// relevant KWs from AWKCR
ammoKeyword := MainRecordByEditorID(GroupBySignature(akcrFile, 'KYWD'), 'AEC_ck_AmmunitionCraftingKey');
armorKeyword := MainRecordByEditorID(GroupBySignature(akcrFile, 'KYWD'), 'AEC_ck_ArmorsmithCraftingKey');
explosiveKeyword := MainRecordByEditorID(GroupBySignature(akcrFile, 'KYWD'), 'AEC_ck_ExplosivesCraftingKey');
weaponKeyword := MainRecordByEditorID(GroupBySignature(akcrFile, 'KYWD'), 'AEC_ck_WeaponsmithCraftingKey');
ammoKeywords := TStringList.create;
ammoKeywords.add('RecipeWeaponLab_Ammo_Arc'); //ballistic
ammoKeywords.add('RecipeWeaponLab_AmmoSpecial_Arc');// unused??
ammoKeywords.add('RecipeWeaponLab_AmmoExt_Arc');//special
ammoKeywords.add('RecipeWeaponLab_AmmoEnergy_Arc');//energy
ammoKeywords.add('RecipeWeaponLab_AmmoContracted_Arc');//contract
ammoKeywords.add('RecipeWeaponLab_AmmoHeavy_Arc');//heavy
ammoKeywords.add('RecipeTech_Scrap');//disassembly
setupDone := true;
Result := true;
end;
function getCopy(origCobj: IInterface): IInterface;
var
oldEdid: String;
newEdid: String;
begin
oldEdid := GetElementEditValues(origCobj, 'EDID');
newEdid := getNewCobjEdid(oldEdid);
Result := MainRecordByEditorID(GroupBySignature(ToFile, 'COBJ'), newEdid);
if(not assigned(Result)) then begin
addRequiredMastersSilent(origCobj, ToFile);
Result := wbCopyElementToFile(origCobj, ToFile, True, True);
setElementEditValues(Result, 'EDID', newEdid);
end;
end;
procedure copyToBench(cobj: IInterface; newBnam: IInterface);
var
newCobj: IInterface;
begin
newCobj := getCopy(cobj);
addRequiredMastersSilent(newBnam, ToFile);
setBnam(newCobj, newBnam);
end;
procedure processWeaponlab(e: IInterface);
var
origName: String;
begin
// AddMessage('Weaponlab');
origName := DisplayName(getCraftResult(e));
// mines and grenades go to explosive
// ammo and disassembly go to ammo workbench
// weapons go to weapons
// equpment goes to armor
if(hasKeywordBySignature(e, 'RecipeGrenade', 'FNAM')) then begin
AddMessage('Copying '+origName+' to explosives workbench');
copyToBench(e, explosiveKeyword);
end else if(hasKeywordBySignature(e, 'RecipeMines', 'FNAM')) then begin
AddMessage('Copying '+origName+' to explosives workbench');
copyToBench(e, explosiveKeyword);
end else if(hasAnyKeyword(e, ammoKeywords, 'FNAM')) then begin
AddMessage('Copying '+origName+' to ammo workbench');
copyToBench(e, ammoKeyword);
end else if(hasKeywordBySignature(e, 'RecipeRobotics_Weapons_Arc', 'FNAM')) then begin
AddMessage('Copying '+origName+' to weapon workbench');
copyToBench(e, weaponKeyword);
end else if(hasKeywordBySignature(e, 'RecipeRobotics04_Arc', 'FNAM')) then begin // equipment
AddMessage('Copying '+origName+' to armor workbench');
copyToBench(e, armorKeyword);
end else;
end;
procedure processTechlab(e: IInterface);
begin
//AddMessage('techlab');
end;
procedure processCobj(e: IInterface);
var
bnam: IInterface;
begin
bnam := getBnam(e);
if(isSameForm(bnam, weaponLabKeyword)) then begin
processWeaponlab(e);
exit;
end;
if(isSameForm(bnam, techLabKeyword)) then begin
processTechlab(e);
exit;
end;
end;
function Process(e: IInterface): integer;
var
i: integer;
frm: TForm;
clb: TCheckListBox;
curSig: String;
newName: String;
curName: String;
scrapComponentsString: String;
newElem: IInterface;
curEdid: String;
begin
curSig := signature(e);
if curSig = 'TES4' then
Exit;
if not Assigned(ToFile) then begin
ToFile := showFileSelectionDialog(e);
if not Assigned(ToFile) then begin
Result := 1;
Exit;
end;
end;
if(not setupDone) then begin
if(not doSetup()) then begin
Result := 1;
exit;
end;
end;
if(curSig = 'COBJ') then begin
processCobj(e);
end;
end;
end.