-
Notifications
You must be signed in to change notification settings - Fork 2
/
Action.go
102 lines (82 loc) · 2.04 KB
/
Action.go
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
package eqStruct
import (
"github.com/nomoresecretz/ghoeq-common/proto/eqstruct"
"google.golang.org/protobuf/proto"
)
type Action struct {
Target uint16 // 00
Source uint16 // 02
Level uint16 // 04
TargetLevel uint16 // 06
InstrumentMod int32 // 08
Force float32
Sequence float32
PushupAngle float32
Type uint8
TapAmount int16
Spell uint16
BuffUnknown uint8
bPointer int
}
func (p *Action) EQType() EQType { return EQT_Action }
func (p *Action) bp() *int { return &p.bPointer }
func (p *Action) Unmarshal(b []byte) (int, error) {
p.bPointer = 0
if err := EQRead(b, p, &p.Target, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.Source, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.Level, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.TargetLevel, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.InstrumentMod, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.Force, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.Sequence, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.PushupAngle, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.Type, 0); err != nil {
return 0, err
}
p.bPointer = 28
if err := EQRead(b, p, &p.TapAmount, 0); err != nil {
return 0, err
}
if err := EQRead(b, p, &p.Spell, 0); err != nil {
return 0, err
}
p.bPointer = 33
if err := EQRead(b, p, &p.BuffUnknown, 0); err != nil {
return 0, err
}
return p.bPointer, nil
}
func (p *Action) Proto() *eqstruct.Action {
return &eqstruct.Action{
Target: uint32(p.Target),
Source: uint32(p.Source),
Level: uint32(p.Level),
InstrumentMod: p.InstrumentMod,
Force: p.Force,
Sequence: p.Sequence,
PushupAngle: p.PushupAngle,
Type: uint32(p.Type),
TapAmount: int32(p.TapAmount),
Spell: uint32(p.Spell),
BuffUnknown: uint32(p.BuffUnknown),
}
}
func (p *Action) ProtoMess() proto.Message {
return p.Proto()
}