-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp3p_field_npc_pck.bt
124 lines (114 loc) · 3.2 KB
/
p3p_field_npc_pck.bt
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
//------------------------------------------------
//--- 010 Editor v11.0.1 Binary Template
//
// File: AtlusFieldNPCPack_P3P.bt
// Authors: moddaman
// Version: 1.0
// Purpose: Parse Field NPC *_pck.dat files.
// Category: Persona 3 Portable
// File Mask:
// ID Bytes:
// History:
//------------------------------------------------
#include "types.h"
LittleEndian();
enum<u8> chID
{
Makoto = 1,
Yukari = 2,
Aigis = 3,
Mitsuru = 4,
Junpei = 5,
Fuuka = 6,
Akihiko = 7,
Ken = 8,
Shinji = 9,
Koromaru = 10,
Ikutsuki = 11,
Ryoji = 13,
Takaya = 17,
Yuko = 21,
Chihiro = 27,
Rio = 29,
Tanaka = 36,
Toriumi = 43,
Kotone = 99,
Kashiwagi = 132,
Margaret = 213,
Vincent = 214,
};
typedef struct packHeader
{
u32 SegmentsLength <format=hex, name = "Size", comment = "Total length of all NPC groups in bytes", bgcolor=0x00BB00>;
u32 TotalSegments <comment = "Increments by 0x10", bgcolor=0xFF0000>;
};
typedef struct chunkSep
{
u32 Field00 <format=hex, comment = "Always 0xFFFF0000?">;
u32 Field04 <format=hex, comment = "Always 0x0000E803?">;
u32 Field08 <format=hex, comment = "Always 0xFFFFFFFF?">;
u32 Field0C <format=hex, comment = "Always 0x00000000?">;
};
typedef struct chunkNPC
{
// Quick fix for files with incorrect Segment counts
// TODO: Better fix + figure out 0x7805 ones
if (ReadUShort(FTell() + 6) != 1000 && ReadUShort(FTell() + 6) != 1400)
{
FSeek(FTell() + 8);
return;
}
u32 PositionID <bgcolor=0x00FF00>;
chID CharacterID <comment = "NPC's character ID, determines nametag and texture (nX_0_0_0.tmx)", bgcolor=0xFF77FF>;
u8 TexVarID <comment = "n0_X_0_0.tmx", bgcolor=0xDD55DD>;
u16 Field06 <format=hex, comment = "Always 0xE803?", bgcolor=0x0000FF>;
u32 ProcedureIndex <comment = "Calls script procedure from corresponding BF file", bgcolor=0xFFFF00>;
u32 ShowOnFlag <comment = "Shows NPC if bitflag is enabled", bgcolor=0x0077FF>;
};
// Check if the next segment of 0x10 bytes is an NPC Chunk Seperator
ubyte isNextStart(int64 fPos)
{
if (ReadUInt() == 65535 && ReadUInt(fPos + 4) == 65536000 && ReadUInt(fPos + 8) == -1 && ReadUInt(fPos + 12) == 0)
{
return 1;
}
return 0;
}
typedef struct npcGroup(u8 atEOF)
{
chunkSep Seperator <name = "Seperator", comment = "Seperates NPC Groups", bgcolor=0x0000FF>;
if (atEOF == 0)
{
while (isNextStart(FTell()) == 0)
{
chunkNPC NPC <name = "NPC">;
}
}
};
typedef struct chunkArr(u32 tot)
{
local u32 endPos = (tot * 16) + 8;
if (FileSize() < endPos)
{
endPos = FileSize();
}
while (FTell() < endPos)
{
if (FTell() + 16 >= endPos)
{
npcGroup GroupNPC(1) <name = "Group">;
}
else
{
npcGroup GroupNPC(0) <name = "Group">;
}
}
};
typedef struct npcPackDAT
{
packHeader Hed <name = "Header">;
chunkArr AllChunks(Hed.TotalSegments) <name = "NPC Groups">;
if (FTell() < FileSize())
u32 HeaderDupe[(FileSize() - FTell()) / 4] <name = "Duplicate Bytes", bgcolor=0x0000FF, comment = "Unused, can be ignored">;
};
npcPackDAT FILE;