-
Notifications
You must be signed in to change notification settings - Fork 0
/
rwarningslib.lua
130 lines (119 loc) · 4.13 KB
/
rwarningslib.lua
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
-- Author: https://github.com/ShiyoKozuki
local function GetShortFlags(entityIndex)
local fullFlags = AshitaCore:GetMemoryManager():GetEntity():GetSpawnFlags(entityIndex);
return bit.band(fullFlags, 0xFF);
end
function IsMonster(entityIndex)
if (GetShortFlags(entityIndex) == 0x10) then
return true
end
return false
end
function GetIndexFromId(serverId)
local index = bit.band(serverId, 0x7FF);
local entMgr = AshitaCore:GetMemoryManager():GetEntity();
if (entMgr:GetServerId(index) == serverId) then
return index;
end
for i = 1,2303 do
if entMgr:GetServerId(i) == serverId then
return i;
end
end
return 0;
end
local bitData;
local bitOffset;
local function UnpackBits(length)
local value = ashita.bits.unpack_be(bitData, 0, bitOffset, length);
bitOffset = bitOffset + length;
return value;
end
function ParseActionPacket(e)
local actionPacket = T{};
bitData = e.data_raw;
bitOffset = 40;
actionPacket.UserId = UnpackBits(32);
actionPacket.UserIndex = GetIndexFromId(actionPacket.UserId);
local targetCount = UnpackBits(6);
--Unknown 4 bits
bitOffset = bitOffset + 4;
actionPacket.Type = UnpackBits(4);
actionPacket.Id = UnpackBits(32);
--Unknown 32 bits
bitOffset = bitOffset + 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
function GetEvent(e)
local eventId, eventParams, eventType;
if (e.id == 0x32) or (e.id == 0x33) then
eventId = struct.unpack('H', e.data, 0x0C + 1);
eventType = 'Start'
if (e.id == 0x33) then
eventParams = T{};
for i = 1,8 do
eventParams[i] = struct.unpack('L', e.data, 0x4C + (i * 4) + 1);
end
end
elseif (e.id == 0x34) then
eventId = struct.unpack('H', e.data, 0x2C + 1);
eventType = 'Start'
eventParams = T{};
for i = 1,8 do
eventParams[i] = struct.unpack('L', e.data, 0x04 + (i * 4) + 1);
end
elseif (e.id == 0x00A) and (struct.unpack('H', e.data, 0x64 + 1) ~= 0) then
eventId = struct.unpack('H', e.data, 0x64 + 1);
eventType = 'Start'
elseif (e.id == 0x5C) then -- Event update
eventId = 0
eventType = 'Update'
eventParams = T{};
for i = 1,8 do
eventParams[i] = struct.unpack('I', e.data, (0x04 * i) + 1);
end
elseif (e.id == 0x2A) then -- Zone text msgID
eventId = bit.band(struct.unpack('H', e.data, 0x1A + 1), 0x7FFF);
eventType = 'MsgID'
eventParams = T{};
for i = 1,4 do
eventParams[i] = struct.unpack('L', e.data, (i * 4) + 0x04 + 0x01);
end
end
return eventId, eventParams, eventType;
end