game_wings.lua

main 166 lines · 4.6 KB Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1local typesWingedOffSet = {
2 [0] = { -- Is for clone
3 [North] = {x = 0, y = 0},
4 [East] = {x = 0, y = 0},
5 [South] = {x = 0, y = 0},
6 [West] = {x = 0, y = 0},
7 },
8 [1] = { --Jouster
9 [North] = {x = 0, y = -2},
10 [East] = {x = -4, y = 1},
11 [South] = {x = 1, y = -4},
12 [West] = {x = -2, y = 0},
13 },
14 [2] = { --Moth Cape
15 [North] = {x = -9, y = -5},
16 [East] = {x = -5, y = -5},
17 [South] = {x = -5, y = -6},
18 [West] = {x = -5, y = -9},
19 },
20 [3] = {
21 [North] = {x = -10, y = 10},
22 [East] = {x = 0, y = 0},
23 [South] = {x = 0, y = 0},
24 [West] = {x = 0, y = 0},
25 },
26}
27
28local typesWingedMountedOffSet = {
29 [0] = {
30 [North] = {x = 0, y = 0},
31 [East] = {x = 0, y = 0},
32 [South] = {x = 0, y = 0},
33 [West] = {x = 0, y = 0},
34 },
35 [1] = {
36 [North] = {x = -11, y = -8},
37 [East] = {x = -9, y = 0},
38 [South] = {x = 0, y = -8},
39 [West] = {x = -6, y = -13},
40 },
41 [2] = {
42 [North] = {x = -11, y = -8},
43 [East] = {x = -9, y = 0},
44 [South] = {x = 0, y = -9},
45 [West] = {x = -6, y = -13},
46 },
47}
48
49local WingsOffsets = {
50 [1592] = {
51 [1331] = typesWingedOffSet[1],
52 [1338] = typesWingedOffSet[2],
53 },
54 [1593] = {
55 [1331] = typesWingedOffSet[1],
56 [1338] = typesWingedOffSet[2],
57 },
58 [1594] = {
59 [1331] = typesWingedOffSet[1],
60 [1338] = typesWingedOffSet[2],
61 },
62}
63
64local WingsMountedOffsets = {
65 [1592] = {
66 [1331] = typesWingedMountedOffSet[1],
67 [1338] = typesWingedMountedOffSet[2],
68 },
69 [1593] = {
70 [1331] = typesWingedMountedOffSet[1],
71 [1338] = typesWingedMountedOffSet[1],
72 },
73 [1594] = {
74 [1331] = typesWingedMountedOffSet[1],
75 [1338] = typesWingedMountedOffSet[1],
76 },
77}
78
79local function translateDir(dir)
80 if dir == NorthEast or dir == SouthEast then
81 return East
82 elseif dir == NorthWest or dir == SouthWest then
83 return West
84 end
85 return dir
86end
87
88local function getWingsInformationOffset(wing, outfit, dir, isMounted)
89 local offsetType = isMounted and WingsMountedOffsets[wing][outfit] or WingsOffsets[wing][outfit]
90
91 if not offsetType then
92 return {x = 0, y = 0}
93 end
94
95 local translatedDir = translateDir(dir)
96
97 if not translatedDir then
98 return {x = 0, y = 0}
99 end
100
101 local offset = offsetType[translatedDir]
102
103 if not offset then
104 return {x = 0, y = 0}
105 end
106
107 -- Manage auras
108 if type(offset) == "table" and #offset > 0 then
109 -- Here you can manipulate auras as needed
110 -- For example, you can return a specific offset for auras
111 return {x = offset[1], y = offset[2]}
112 end
113
114 return offset
115end
116
117local function setWingsOffset(creature)
118 local outfit = creature:getOutfit()
119 if outfit.wings and outfit.wings > 1 then
120 local wings = creature:getWings()
121 local direction = creature:getDirection()
122
123 if wings and direction then
124 local Offset = getWingsInformationOffset(wings, outfit.type, direction, outfit.mount and outfit.mount > 0)
125 local scale = 0.5 -- factor de escala para el widget en la lista
126 creature:setWingsOffset(Offset.x * scale, Offset.y * scale)
127 else
128 creature:setWingsOffset(0, 0)
129 end
130 else
131 creature:setWingsOffset(0, 0)
132 end
133end
134
135local function onDirectionChange(creature, oldDirection, newDirection)
136 setWingsOffset(creature)
137end
138
139local function onPositionChange(player, newPos, oldPos)
140 setWingsOffset(player)
141end
142
143function init()
144 connect(LocalPlayer, {onOutfitChange = setWingsOffset, onWalk = setWingsOffset, onDirectionChange = onDirectionChange, onPositionChange = onPositionChange})
145 connect(Creature, {
146 onAppear = setWingsOffset,
147 onWalk = setWingsOffset,
148 onOutfitChange = setWingsOffset,
149 onDirectionChange = onDirectionChange,
150 onPositionChange = onPositionChange
151 })
152end
153
154function terminate()
155 disconnect(LocalPlayer, {onOutfitChange = setWingsOffset, onWalk = setWingsOffset, onDirectionChange = onDirectionChange, onPositionChange = onPositionChange})
156 disconnect(Creature, {
157 onAppear = setWingsOffset,
158 onWalk = setWingsOffset,
159 onOutfitChange = setWingsOffset,
160 onDirectionChange = onDirectionChange,
161 onPositionChange = onPositionChange
162 })
163end
164
165game_wings = { setWingsOffset = setWingsOffset }
166
Top