-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathMovementNetwork.py
95 lines (85 loc) · 3.34 KB
/
MovementNetwork.py
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
from ctypes import *
from FFxivPythonTrigger import api, PluginBase
from FFxivPythonTrigger.memory.StructFactory import OffsetStruct
command = "@Move"
Vector3 = OffsetStruct({
'x': c_float,
'z': c_float,
'y': c_float,
})
PositionSetPack = OffsetStruct({
'r': (c_float, 0),
'unk0': (c_ushort, 0x4),
'unk1': (c_ushort, 0x6),
'pos': (Vector3, 0x8),
'unk2': (c_uint, 0x14),
}, 24)
PositionAdjustPack = OffsetStruct({
'old_r': (c_float, 0x0),
'new_r': (c_float, 0x4),
'unk0': (c_ushort, 0x8),
'unk1': (c_ushort, 0xA),
'old_pos': (Vector3, 0xC),
'new_pos': (Vector3, 0x18),
'unk2': (c_uint, 0x24),
}, 40)
class MovementNetwork(PluginBase):
name = "MovementNetwork"
git_repo = 'nyouoG/fpt_plugins'
repo_path = 'MovementNetwork.py'
hash_path = __file__
def __init__(self):
super().__init__()
self.floating = 0
self.no_fall = False
# self.register_event(f"*", self.search)
api.XivNetwork.register_makeup("UpdatePositionHandler", self.makeup_set)
api.XivNetwork.register_makeup("UpdatePositionInstance", self.makeup_adjust)
api.command.register(command, self.process_command)
def _onunload(self):
api.XivNetwork.unregister_makeup("UpdatePositionHandler", self.makeup_set)
api.XivNetwork.unregister_makeup("UpdatePositionInstance", self.makeup_adjust)
api.command.unregister(command)
def search(self, event):
if event.id.startswith("network/send/"):
for struct in [PositionSetPack, PositionAdjustPack]:
if len(event.raw_msg) == sizeof(struct):
self.logger(struct.__name__, hex(event.header.msg_type), struct.from_buffer(event.raw_msg))
def makeup_set(self, header, raw):
data = PositionSetPack.from_buffer(raw)
data.pos.z += self.floating
if self.no_fall: data.unk0 &= 0xf000
return header, bytearray(data)
def makeup_adjust(self, header, raw):
data = PositionAdjustPack.from_buffer(raw)
data.new_pos.z += self.floating
data.old_pos.z += self.floating
if self.no_fall: data.unk0 &= 0xf000
return header, bytearray(data)
def process_command(self, args):
if args:
if args[0] == 'fall':
if len(args) < 2:
self.no_fall = not self.no_fall
elif args[1] == 'on':
self.no_fall = True
elif args[1] == 'off':
self.no_fall = False
else:
api.Magic.echo_msg("unknown args: %s" % args[1])
return
api.Magic.echo_msg("FeatherFall: [%s]" % ('enable' if self.no_fall else 'disable'))
elif args[0] == 'float':
if len(args) < 2:
self.floating = 0
else:
try:
self.floating = float(args[1])
except ValueError:
api.Magic.echo_msg("a number is required")
api.Magic.echo_msg("Floating: [%s]" % self.floating)
else:
api.Magic.echo_msg("unknown args: %s" % args[0])
else:
api.Magic.echo_msg("FeatherFall: [%s]" % ('enable' if self.no_fall else 'disable'))
api.Magic.echo_msg("Floating: [%s]" % self.floating)