-
-
Notifications
You must be signed in to change notification settings - Fork 664
/
Copy pathhireling_module.lua
56 lines (47 loc) · 1.34 KB
/
hireling_module.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
HirelingModule = {}
HirelingModule.Credits = {
Developer = 'Leonardo "Leu" Pereira (jlcvp)',
Version = "1.0",
Date = "30/04/2020 ",
}
HirelingModule.S_Packets = { SendOutfitWindow = 0xC8 }
HirelingModule.C_Packets = { RequestChangeOutfit = 0xD2, ConfirmOutfitChange = 0xD3 }
local function getOutfit(msg)
local outfitType = 0
outfitType = msg:getByte()
local outfit = {}
outfit.lookType = msg:getU16()
outfit.lookHead = msg:getByte()
outfit.lookBody = msg:getByte()
outfit.lookLegs = msg:getByte()
outfit.lookFeet = msg:getByte()
outfit.lookAddons = msg:getByte()
if outfitType == 0 then
outfit.lookMount = msg:getU16()
else
outfit.lookMount = 0x00
msg:getU32() --discard this for some reason maybe it's the hireling id
end
return outfit
end
local function parseChangeOutfit(player, msg)
local hireling = player:getHirelingChangingOutfit()
local outfit
if not hireling then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
-- deplete msg to avoid setting an hireling outfit to player
getOutfit(msg)
else
outfit = getOutfit(msg)
hireling:changeOutfit(outfit)
end
end
function onRecvbyte(player, msg, byte)
if byte == HirelingModule.C_Packets.ConfirmOutfitChange then
if not player:isChangingHirelingOutfit() then
return
end
parseChangeOutfit(player, msg)
end
end