public void Update(JagexBuffer b) { b.Position(0); Gender = b.ReadByte(); PrayerIcon = b.ReadUByte(); b.ReadByte(); SkullIcon = b.ReadShort() == 0 ? -1 : 0; for (int i = 0; i < 12; i++) { int lsb = b.ReadUByte(); if (lsb == 0) { EquipmentIndices[i] = 0; continue; } EquipmentIndices[i] = (lsb << 8) + b.ReadUByte(); if (i == 0 && this.EquipmentIndices[0] == 65535) { b.ReadUShort(); break; } } for (int i = 0; i < 5; i++) { colors[i] = b.ReadUByte(); } StandAnimation = 625;//.ReadUShort(); if (StandAnimation == 65535) { StandAnimation = -1; } StandTurnAnimation = b.ReadUShort(); if (StandTurnAnimation == 65535) { StandTurnAnimation = -1; } WalkAnimation = b.ReadUShort(); if (WalkAnimation == 65535) { WalkAnimation = -1; } Turn180Animation = b.ReadUShort(); if (Turn180Animation == 65535) { Turn180Animation = -1; } TurnRightAnimation = b.ReadUShort(); if (TurnRightAnimation == 65535) { TurnRightAnimation = -1; } TurnLeftAnimation = b.ReadUShort(); if (TurnLeftAnimation == 65535) { TurnLeftAnimation = -1; } RunAnimation = b.ReadUShort(); if (RunAnimation == 65535) { RunAnimation = -1; } this.Name = StringUtils.Format(StringUtils.LongToString(b.ReadLong())); this.CombatLevel = (short)b.ReadUByte(); b.ReadUShort(); b.ReadUShort(); this.Visible = true; this.ModelUid = 0L; for (int i = 0; i < 12; i++) { this.ModelUid <<= 4; if (EquipmentIndices[i] >= 256) { this.ModelUid += EquipmentIndices[i] - 256; } } if (EquipmentIndices[0] >= 256) { this.ModelUid += EquipmentIndices[0] - 256 >> 4; } if (EquipmentIndices[1] >= 256) { this.ModelUid += EquipmentIndices[1] - 256 >> 8; } for (int i = 0; i < 5; i++) { this.ModelUid <<= 3; this.ModelUid += colors[i]; } this.ModelUid <<= 1; this.ModelUid += Gender; UnityObject.name = "Player " + Name; Dirty = true; UpdateObjectScenePos(); }
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; } }
private void ParseOpcode(int opcode, JagexBuffer b) { if (opcode == 1) { FrameCount = b.ReadUByte(); FrameIndicesPrimary = new int[FrameCount]; FrameIndicesSecondary = new int[FrameCount]; FrameLengths = new int[FrameCount]; for (var j = 0; j < FrameCount; j++) { FrameIndicesPrimary[j] = b.ReadUShort(); FrameIndicesSecondary[j] = b.ReadUShort(); if (FrameIndicesSecondary[j] == 65535) { FrameIndicesSecondary[j] = -1; } FrameLengths[j] = b.ReadUShort(); } } else if (opcode == 2) { Padding = b.ReadShort(); } else if (opcode == 3) { int k = b.ReadUByte(); Vertices = new int[k + 1]; for (int j = 0; j < k; j++) { Vertices[j] = b.ReadUByte(); } Vertices[k] = 0x98967F; } else if (opcode == 4) { CanRotate = true; } else if (opcode == 5) { Priority = b.ReadUByte(); } else if (opcode == 6) { OverrideShieldIndex = b.ReadShort(); } else if (opcode == 7) { OverrideWeaponIndex = b.ReadShort(); } else if (opcode == 8) { ResetCycle = b.ReadUByte(); } else if (opcode == 9) { SpeedFlag = b.ReadUByte(); } else if (opcode == 10) { WalkFlag = b.ReadUByte(); } else if (opcode == 11) { Type = b.ReadUByte(); } else { Debug.Log("Error unrecognised seq config code: " + opcode); } }