forked from Hucaru/Valhalla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packet.go
48 lines (38 loc) · 1.13 KB
/
packet.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
package mob
import (
"github.com/albertojnk/Valhalla/constant/opcode"
"github.com/albertojnk/Valhalla/mpacket"
)
func packetMobControl(m Data, chase bool) mpacket.Packet {
p := mpacket.CreateWithOpcode(opcode.SendChannelControlMob)
if chase {
p.WriteByte(0x02) // 2 chase, 1 no chase, 0 no control
} else {
p.WriteByte(0x01)
}
p.Append(m.DisplayBytes())
return p
}
func packetMobControlAcknowledge(mobID int32, moveID int16, allowedToUseSkill bool, mp int16, skill byte, level byte) mpacket.Packet {
p := mpacket.CreateWithOpcode(opcode.SendChannelControlMobAck)
p.WriteInt32(mobID)
p.WriteInt16(moveID)
p.WriteBool(allowedToUseSkill)
p.WriteInt16(mp) // check this shouldn't be int32 or uint16 as Zakum has 60,000 mp
p.WriteByte(skill)
p.WriteByte(level)
return p
}
func packetMobEndControl(m Data) mpacket.Packet {
p := mpacket.CreateWithOpcode(opcode.SendChannelControlMob)
p.WriteByte(0)
p.WriteInt32(m.spawnID)
return p
}
func packetMobShowHpChange(spawnID int32, dmg int32) mpacket.Packet {
p := mpacket.CreateWithOpcode(opcode.SendChannelMobDamage)
p.WriteInt32(spawnID)
p.WriteByte(0)
p.WriteInt32(dmg)
return p
}