private void UpdatePlayerMask(int mask, int index, JagexBuffer b, Player p) { if ((mask & 0x400) != 0) { p.MoveStartX = b.ReadUByteS(); p.MoveStartY = b.ReadUByteS(); p.MoveEndX = b.ReadUByteS(); p.MoveEndY = b.ReadUByteS(); p.MoveCycleEnd = b.ReadLEUShortA() + (int)GameContext.LoopCycle; p.MoveCycleStart = b.ReadUShortA() + (int)GameContext.LoopCycle; p.MoveDirection = b.ReadUByteS(); p.ResetQueuedMovements(); } if ((mask & 0x100) != 0) { p.SpotAnimIndex = b.ReadLEUShort(); var info = b.ReadInt(); p.GraphicOffsetY = info >> 16; p.SpotAnimCycleEnd = (int)GameContext.LoopCycle + (info & 0xffff); p.SpotAnimFrame = 0; p.SpotAnimCycle = 0; if (p.SpotAnimCycleEnd > GameContext.LoopCycle) { p.SpotAnimFrame = -1; } if (p.SpotAnimIndex == 65535) { p.SpotAnimIndex = -1; } } if ((mask & 8) != 0) { var seqIndex = b.ReadLEUShort(); var delay = b.ReadUByteC(); if (seqIndex == 65535) { seqIndex = -1; } var seq = GameContext.Cache.GetSeq(seqIndex); if (seq != null) { if (seqIndex == p.SeqIndex && seqIndex != -1) { var type = seq.Type; if (type == 1) { p.SeqFrame = 0; p.SeqCycle = 0; p.SeqDelayCycle = delay; p.SeqResetCycle = 0; } else if (type == 2) { p.SeqResetCycle = 0; } } else if (seqIndex == -1 || p.SeqIndex == -1 || (GameContext.Cache.GetSeq(p.SeqIndex) != null && seq.Priority >= GameContext.Cache.GetSeq(p.SeqIndex).Priority)) { p.SeqIndex = seqIndex; p.SeqFrame = 0; p.SeqCycle = 0; p.SeqDelayCycle = delay; p.SeqResetCycle = 0; p.StillPathPosition = p.PathPosition; } } } if ((mask & 4) != 0) { p.SpokenMessage = b.ReadString(10); if (p.SpokenMessage.ToCharArray()[0] == '~') { p.SpokenMessage = p.SpokenMessage.Substring(1); GameContext.Chat.Add(new ChatMessage(MessageType.Player, p.Name, p.SpokenMessage)); } else if (p == GameContext.Self) { GameContext.Chat.Add(new ChatMessage(MessageType.Player, p.Name, p.SpokenMessage)); } p.SpokenColor = 0; p.SpokenEffect = 0; p.SpokenLife = 150; } if ((mask & 0x80) != 0) { var settings = b.ReadShort(); var rights = b.ReadByte(); b.ReadByte(); var length = b.ReadUByteC(); var startOff = b.Position(); if (p.Name != null) { var buf = new DefaultJagexBuffer(new byte[5000]); b.ReadBytesReversed(buf.Array(), 0, length); p.SpokenMessage = StringUtils.GetFormatted(length, buf); p.SpokenEffect = settings & 0xFF; p.SpokenColor = settings >> 8; p.SpokenLife = 150; var sb = new StringBuilder(); sb.Append(p.Name); var msg = new ChatMessage(MessageType.Player, sb.ToString(), p.SpokenMessage); if (rights > 0) { msg.CrownIndex = rights; } GameContext.Chat.Add(msg); } b.Position(startOff + length); } if ((mask & 1) != 0) { p.FaceEntity = b.ReadLEUShort(); if (p.FaceEntity == 65535) { p.FaceEntity = -1; } } if ((mask & 0x10) != 0) { var payload = new byte[b.ReadUByteC()]; b.ReadBytes(payload, 0, payload.Length); var pb = new DefaultJagexBuffer(payload); GameContext.PlayerBuffers[index] = pb; p.Update(pb); } if ((mask & 2) != 0) { p.FaceX = b.ReadLEUShortA(); p.FaceY = b.ReadLEUShort(); } if ((mask & 0x20) != 0) { var damage = b.ReadUShortA(); var type = b.ReadUByte(); var icon = b.ReadUByte(); var soak = b.ReadUShortA(); p.QueueHit(type, damage, (int)GameContext.LoopCycle); p.CurrentHealth = b.ReadUShortA(); p.MaxHealth = b.ReadUShortA(); p.EndCombatCycle = (int)GameContext.LoopCycle + 300; } if ((mask & 0x200) != 0) { var damage = b.ReadUShortA(); var type = b.ReadUByte(); var icon = b.ReadUByte(); var soak = b.ReadUShortA(); p.QueueHit(type, damage, (int)GameContext.LoopCycle); p.CurrentHealth = b.ReadUShortA(); p.MaxHealth = b.ReadUShortA(); p.EndCombatCycle = (int)GameContext.LoopCycle + 300; } }