Beispiel #1
0
        /// <summary>
        ///   Builds a SpellEffectAnimation packet
        /// </summary>
        /// <returns>byte[] for packetProcessor.Send()</returns>
        public static byte[] SpellEffectAnimationTCP(GameObject spellCaster, GameObject spellTarget, ushort spellid,
                                                     ushort boltTime, bool noSound, byte success)
        {
            var pak = new GSTCPPacketOut((byte)ePackets.SpellEffectAnimation);

            pak.WriteShort((ushort)spellCaster.ObjectID);
            pak.WriteShort(spellid);
            pak.WriteShort((ushort)(spellTarget == null ? 0 : spellTarget.ObjectID));
            pak.WriteShort(boltTime);
            pak.WriteByte((byte)(noSound ? 1 : 0));
            pak.WriteByte(success);

            //Get the packet buffer
            pak.WritePacketLength();
            return(pak.GetBuffer()); //packet.WritePacketLength sets the Capacity
        }
Beispiel #2
0
        /// <summary>
        ///   Builds a combat animation packet for broadcast use.
        ///   TODO: Might not work for attacker==defender -- unsure about this.
        ///   len=14
        /// </summary>
        public static byte[] CombatAnimation(GameObject attacker, GameLiving defender, ushort weaponID, ushort shieldID,
                                             int style, byte stance, byte result)
        {
            var pak = new GSTCPPacketOut((byte)ePackets.CombatAnimation);

            if (attacker != null)
            {
                pak.WriteShort((ushort)(attacker.ObjectState == GameObject.eObjectState.Deleted
          ? attacker.LastObjectID
          : attacker.ObjectID));
            }
            else
            {
                pak.WriteShort(0x00);
            }

            byte health = 0x00;

            if (defender != null)
            {
                pak.WriteShort((ushort)(defender.ObjectState == GameObject.eObjectState.Deleted
          ? defender.LastObjectID
          : defender.ObjectID));
                health = defender.HealthPercent;
            }
            else
            {
                pak.WriteShort(0x00);
            }

            pak.WriteShort(weaponID);
            pak.WriteShort(shieldID);
            pak.WriteShortLowEndian((ushort)style);
            pak.WriteByte(stance);
            pak.WriteByte(result);
            pak.WriteByte(health);

            pak.WriteByte(0x6F); // TODO: Check whether this still needs to be 0x6F for attacker==player / 0x00 otherwise

            pak.WritePacketLength();
            return(pak.GetBuffer());
        }