-
Notifications
You must be signed in to change notification settings - Fork 2
/
log_execute.go
83 lines (69 loc) · 1.91 KB
/
log_execute.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
package spell
import (
"fmt"
"github.com/Gophercraft/core/guid"
"github.com/Gophercraft/core/packet"
"github.com/Gophercraft/core/vsn"
)
const ()
type LogEffectApplication struct {
Target guid.GUID
PowerTaken uint32
PowerType uint32
Multiplier float32
Amount uint32
InterruptedSpell uint32
Item uint32
Slot uint32
}
type LoggedEffect struct {
Kind Effect
Applications []LogEffectApplication
}
func (eff *LoggedEffect) Encode(build vsn.Build, out *packet.WorldPacket) error {
out.WriteInt32(int32(eff.Kind))
out.WriteUint32(uint32(len(eff.Applications)))
for _, app := range eff.Applications {
switch eff.Kind {
case EffectPowerDrain, EffectPowerBurn:
app.Target.EncodePacked(build, out)
out.WriteUint32(app.PowerTaken)
out.WriteUint32(app.PowerType)
out.WriteFloat32(app.Multiplier)
case EffectAddExtraAttacks:
app.Target.EncodePacked(build, out)
out.WriteUint32(app.Amount)
case EffectInterruptCast:
app.Target.EncodePacked(build, out)
out.WriteUint32(app.InterruptedSpell)
case EffectDurabilityDamage:
app.Target.EncodePacked(build, out)
out.WriteUint32(app.Item)
out.WriteUint32(app.Slot)
case EffectOpenLock:
app.Target.EncodePacked(build, out)
case EffectCreateItem, EffectCreateRandomItem, EffectCreateItem2:
out.WriteUint32(app.Item)
default:
return fmt.Errorf("spell: cannot encode unknown effect kind %d", eff.Kind)
}
}
return nil
}
type LogExecute struct {
Caster guid.GUID
Spell uint32
Effects []LoggedEffect
}
func (exe *LogExecute) Encode(build vsn.Build, out *packet.WorldPacket) error {
out.Type = packet.SMSG_SPELLLOGEXECUTE
exe.Caster.EncodePacked(build, out)
out.WriteUint32(uint32(exe.Spell))
out.WriteUint32(uint32(len(exe.Effects)))
for _, effect := range exe.Effects {
if err := effect.Encode(build, out); err != nil {
return err
}
}
return nil
}