forked from ThornyFFXI/tTimers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactionpacket.lua
More file actions
69 lines (60 loc) · 2.14 KB
/
actionpacket.lua
File metadata and controls
69 lines (60 loc) · 2.14 KB
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
local function ParseActionPacket(e)
local bitData;
local bitOffset;
local function UnpackBits(length)
local value = ashita.bits.unpack_be(bitData, 0, bitOffset, length);
bitOffset = bitOffset + length;
return value;
end
local actionPacket = T{};
bitData = e.data_raw;
bitOffset = 40;
actionPacket.UserId = UnpackBits(32);
local targetCount = UnpackBits(6);
bitOffset = bitOffset + 4;
actionPacket.Type = UnpackBits(4);
actionPacket.Id = UnpackBits(17);
bitOffset = bitOffset + 15;
actionPacket.Recast = UnpackBits(32);
actionPacket.Targets = T{};
for i = 1,targetCount do
local target = T{};
target.Id = UnpackBits(32);
local actionCount = UnpackBits(4);
target.Actions = T{};
for j = 1,actionCount do
local action = {};
action.Reaction = UnpackBits(5);
action.Animation = UnpackBits(12);
action.SpecialEffect = UnpackBits(7);
action.Knockback = UnpackBits(3);
action.Param = UnpackBits(17);
action.Message = UnpackBits(10);
action.Flags = UnpackBits(31);
local hasAdditionalEffect = (UnpackBits(1) == 1);
if hasAdditionalEffect then
local additionalEffect = {};
additionalEffect.Damage = UnpackBits(10);
additionalEffect.Param = UnpackBits(17);
additionalEffect.Message = UnpackBits(10);
action.AdditionalEffect = additionalEffect;
end
local hasSpikesEffect = (UnpackBits(1) == 1);
if hasSpikesEffect then
local spikesEffect = {};
spikesEffect.Damage = UnpackBits(10);
spikesEffect.Param = UnpackBits(14);
spikesEffect.Message = UnpackBits(10);
action.SpikesEffect = spikesEffect;
end
target.Actions:append(action);
end
actionPacket.Targets:append(target);
end
return actionPacket;
end
local exports = {};
function exports:parse(e)
return ParseActionPacket(e);
end
return exports;