-
Notifications
You must be signed in to change notification settings - Fork 2
/
Cat Export.pas
75 lines (67 loc) · 2.21 KB
/
Cat Export.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
{
Exports Cat Spawn data to JSON
Intended for Fallout 76
}
unit userscript;
var
sl: TStringList;
procedure GetMarkers;
var
wrld, wrldgrup, block, subblock, cell, e: IInterface;
i,w,x,y,z,counter: integer;
row, Name: string;
begin
//Let's try to filter to the specific worldspace so we don't have to search through more stuff...
if wbGameMode = gmFNV then
wrld := RecordByFormID(FileByIndex(0), $000DA726, False)
else if wbGameMode = gmFO76 then
wrld := RecordByFormID(FileByIndex(0), 2480661, False)
else
wrld := RecordByFormID(FileByIndex(0), $0000003C, False);
wrldgrup := ChildGroup(wrld);
for i := 0 to ElementCount(wrldgrup) - 1 do begin
block := ElementByIndex(wrldgrup,i);
//AddMessage('Block '+BaseName(Block));
for x := 0 to ElementCount(block) -1 do begin
subblock := ElementByIndex(block,x);
//AddMessage('Block '+BaseName(block) +' SubBlock '+BaseName(subblock));
for y := 0 to ElementCount(subblock) -1 do begin
//We only want to look through Temp items
cell := FindChildGroup(ChildGroup(ElementByIndex(subblock,y)),9,ElementByIndex(subblock,y));
for z := 0 to ElementCount(cell) -1 do begin
e := ElementByIndex(cell,z);
Name := GetEditValue(ElementByName(e,'NAME - Base'));
if (pos('LvlCritterCat',Name) > 0) then begin
Row := '{"id":"'+IntToHex(FixedFormID(e), 8)+'","name":"'+Name+'",';
Row := Row + '"type":"CatMarker",';
Row := Row + '"x":'+GetEditValue(ElementByName(ElementByName(ElementByName(e,'DATA - Position/Rotation'),'Position'),'X'))+',';
Row := Row + '"y":'+GetEditValue(ElementByName(ElementByName(ElementByName(e,'DATA - Position/Rotation'),'Position'),'Y'))+'},';
sl.Add(row);
end;
end;
end;
end;
end;
end;
// Called before processing
// You can remove it if script doesn't require initialization code
function Initialize: integer;
begin
sl := TStringList.Create;
sl.Add('[');
GetMarkers;
Result := 0;
end;
function Finalize: integer;
var
fname: string;
begin
fname := ProgramPath + 'Cat.json';
//Dummy record for trailing comma
sl.Add('{"id":9999999,"name":"","type":"","x":0,"y":0}');
sl.Add(']');
sl.SaveToFile(fname);
sl.Free;
Result := 1;
end;
end.