func packetPlayerEnterGame(plr player, channelID int32) mpacket.Packet {
p := mpacket.CreateWithOpcode(opcode.SendChannelWarpToMap)
p.WriteInt32(channelID)
p.WriteByte(0) // character portal counter
p.WriteByte(1) // Is connecting
randomBytes := make([]byte, 4)
_, err := rand.Read(randomBytes)
if err != nil {
panic(err.Error())
}
p.WriteBytes(randomBytes)
p.WriteBytes(randomBytes)
p.WriteBytes(randomBytes)
p.WriteBytes(randomBytes)
// Are active buffs name encoded in here?
p.WriteByte(0xFF)
p.WriteByte(0xFF)
p.WriteInt32(plr.id)
p.WritePaddedString(plr.name, 13)
p.WriteByte(plr.gender)
p.WriteByte(plr.skin)
p.WriteInt32(plr.face)
p.WriteInt32(plr.hair)
p.WriteInt64(0) // Pet Cash ID
p.WriteByte(plr.level)
p.WriteInt16(plr.job)
p.WriteInt16(plr.str)
p.WriteInt16(plr.dex)
p.WriteInt16(plr.intt)
p.WriteInt16(plr.luk)
p.WriteInt16(plr.hp)
p.WriteInt16(plr.maxHP)
p.WriteInt16(plr.mp)
p.WriteInt16(plr.maxMP)
p.WriteInt16(plr.ap)
p.WriteInt16(plr.sp)
p.WriteInt32(plr.exp)
p.WriteInt16(plr.fame)
p.WriteInt32(plr.mapID)
p.WriteByte(plr.mapPos)
p.WriteByte(20) // budy list size
p.WriteInt32(plr.mesos)
p.WriteByte(plr.equipSlotSize)
p.WriteByte(plr.useSlotSize)
p.WriteByte(plr.setupSlotSize)
p.WriteByte(plr.etcSlotSize)
p.WriteByte(plr.cashSlotSize)
for _, v := range plr.equip {
if v.slotID < 0 && !v.cash {
p.WriteBytes(v.inventoryBytes())
}
}
p.WriteByte(0)
// Equips
for _, v := range plr.equip {
if v.slotID < 0 && v.cash {
p.WriteBytes(v.inventoryBytes())
}
}
p.WriteByte(0)
// Inventory windows starts
for _, v := range plr.equip {
if v.slotID > -1 {
p.WriteBytes(v.inventoryBytes())
}
}
p.WriteByte(0)
for _, v := range plr.use {
p.WriteBytes(v.inventoryBytes())
}
p.WriteByte(0)
for _, v := range plr.setUp {
p.WriteBytes(v.inventoryBytes())
}
p.WriteByte(0)
for _, v := range plr.etc {
p.WriteBytes(v.inventoryBytes())
}
p.WriteByte(0)
for _, v := range plr.cash {
p.WriteBytes(v.inventoryBytes())
}
p.WriteByte(0)
// Skills
p.WriteInt16(int16(len(plr.skills))) // number of skills
skillCooldowns := make(map[int32]int16)
for _, skill := range plr.skills {
p.WriteInt32(skill.ID)
p.WriteInt32(int32(skill.Level))
if skill.Cooldown > 0 {
skillCooldowns[skill.ID] = skill.Cooldown
}
}
p.WriteInt16(int16(len(skillCooldowns))) // number of cooldowns
for id, cooldown := range skillCooldowns {
p.WriteInt32(id)
p.WriteInt16(cooldown)
}
// Quests
p.WriteInt16(3) // Active quest count
p.WriteInt16(2029)
p.WriteString("")
p.WriteInt16(2000)
p.WriteString("")
p.WriteInt16(1000)
p.WriteString("")
p.WriteInt16(0) // Completed quest count?
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt32(0)
p.WriteInt64(time.Now().Unix())
return p
}