Exemple #1
0
        /// <summary>
        ///     Adds the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        public static void Add(NetworkMessage message, ICharacterSpawn characterSpawn)
        {
            message.AddPacketType(GamePacketType.SelfStats);
            message.AddUInt16((ushort)characterSpawn.Health.Current);
            message.AddUInt16((ushort)characterSpawn.Health.Maximum);
            message.AddUInt32(characterSpawn.FreeCapacity);
            message.AddUInt32(characterSpawn.Capacity);
            message.AddUInt64(characterSpawn.Level.Experience);
            message.AddUInt16((ushort)characterSpawn.Level.Current);
            message.AddPercent(characterSpawn.Level.ToPercent());

            // TODO: Experience bonus
            message.AddDouble(0, 3);

            message.AddUInt16((ushort)characterSpawn.Mana.Current);
            message.AddUInt16((ushort)characterSpawn.Mana.Maximum);

            message.AddByte(characterSpawn.MagicLevel.Base);
            message.AddByte(characterSpawn.MagicLevel.Current);
            message.AddPercent(characterSpawn.MagicLevel.ToPercent());

            message.AddByte(characterSpawn.Soul);
            message.AddUInt16(characterSpawn.Stamina);

            // TODO: Improve protocol to provide BonusSpeed in this packet
            message.AddUInt16(characterSpawn.Speed.WalkSpeed);

            // TODO: var condition = characterSpawn.getCondition(ConditionType.CONDITION_REGENERATION);
            message.AddUInt16(/*(ushort)(condition != null ? condition.getTicks() / 1000 : */ 0x00 /*)*/);

            message.AddUInt16((ushort)(characterSpawn.OfflineTraining.Elapsed.Ticks / 60 / 1000));
        }
Exemple #2
0
        /// <summary>
        ///     Adds the creature.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="creatureSpawn">The creature spawn.</param>
        /// <param name="known">if set to <c>true</c> [known].</param>
        /// <param name="removeKnown">The remove known.</param>
        public static void AddCreature(NetworkMessage message, ICharacterSpawn characterSpawn, ICreatureSpawn creatureSpawn, bool known, uint removeKnown)
        {
            // TODO: This method MUST be called "Add" for consistency
            if (known)
            {
                // TODO: MAGIC NUMBER DETECTED!
                message.AddUInt16(0x62); // known
                message.AddUInt32(creatureSpawn.Id);
            }
            else
            {
                // TODO: MAGIC NUMBER DETECTED!
                message.AddUInt16(0x61); // unknown
                message.AddUInt32(removeKnown);
                message.AddUInt32(creatureSpawn.Id);
                message.AddCreatureType(creatureSpawn.Creature.CreatureType);
                message.AddString(creatureSpawn.Creature.Name);
            }

            message.AddPercent(creatureSpawn.Health.ToPercent());
            message.AddDirection(creatureSpawn.Direction);
            message.AddAppearance(creatureSpawn.Outfit, creatureSpawn.Mount);
            message.AddByte(creatureSpawn.LightInfo.Level);
            message.AddByte(creatureSpawn.LightInfo.Color);
            message.AddUInt16(creatureSpawn.Speed.WalkSpeed);
            message.AddSkullType(creatureSpawn.Skull.Type);
            message.AddPartyShield(characterSpawn.GetPartyShield(creatureSpawn as CharacterSpawn));

            if (!known)
            {
                message.AddWarIcon(creatureSpawn.WarIcon);
            }

            CreatureType creatureType = creatureSpawn.Creature.CreatureType;

            if (creatureType == CreatureType.Monster && creatureSpawn is ISummon summon)
            {
                creatureType = summon.Master == characterSpawn ? CreatureType.SummonOwn : CreatureType.SummonOthers;
            }

            message.AddCreatureType(creatureType);
            message.AddSpeechBubble(creatureSpawn.Creature.SpeechBubble);

            // TODO: Implement marked/unmarked??
            message.AddByte(0xFF);

            // TODO: Implement helpers
            //if (otherPlayer)
            //{
            //    msg.add<uint16_t>(otherPlayer->getHelpers());
            //}
            //else
            //{
            // TODO: MAGIC NUMBER DETECTED!
            message.AddUInt16(0x00);
            //}
            message.AddBoolean(creatureSpawn is ISolidBlock);
        }
Exemple #3
0
        /// <summary>
        ///     Adds the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        public static void Add(NetworkMessage message, ICharacterSpawn characterSpawn)
        {
            message.AddPacketType(GamePacketType.SelfSkills);

            // Fist
            // TODO: message.AddUInt16(characterSpawn.FistSkill.Current);
            message.AddUInt16(characterSpawn.FistSkill.Base);
            message.AddUInt16(characterSpawn.FistSkill.Base);
            message.AddPercent(characterSpawn.FistSkill.ToPercent());

            // Club
            // TODO: message.AddUInt16(characterSpawn.ClubSkill.Current);
            message.AddUInt16(characterSpawn.ClubSkill.Base);
            message.AddUInt16(characterSpawn.ClubSkill.Base);
            message.AddPercent(characterSpawn.ClubSkill.ToPercent());

            // Sword
            // TODO: message.AddUInt16(characterSpawn.SwordSkill.Current);
            message.AddUInt16(characterSpawn.SwordSkill.Base);
            message.AddUInt16(characterSpawn.SwordSkill.Base);
            message.AddPercent(characterSpawn.SwordSkill.ToPercent());

            // Axe
            // TODO: message.AddUInt16(characterSpawn.AxeSkill.Current);
            message.AddUInt16(characterSpawn.AxeSkill.Base);
            message.AddUInt16(characterSpawn.AxeSkill.Base);
            message.AddPercent(characterSpawn.AxeSkill.ToPercent());

            // Distance
            // TODO: message.AddUInt16(characterSpawn.DistanceSkill.Current);
            message.AddUInt16(characterSpawn.DistanceSkill.Base);
            message.AddUInt16(characterSpawn.DistanceSkill.Base);
            message.AddPercent(characterSpawn.DistanceSkill.ToPercent());

            // Shield
            // TODO: message.AddUInt16(characterSpawn.ShieldSkill.Current);
            message.AddUInt16(characterSpawn.ShieldSkill.Base);
            message.AddUInt16(characterSpawn.ShieldSkill.Base);
            message.AddPercent(characterSpawn.ShieldSkill.ToPercent());

            // Fishing
            // TODO: message.AddUInt16(characterSpawn.FishingSkill.Current);
            message.AddUInt16(characterSpawn.FishingSkill.Base);
            message.AddUInt16(characterSpawn.FishingSkill.Base);
            message.AddPercent(characterSpawn.FishingSkill.ToPercent());
        }
Exemple #4
0
 /// <summary>
 ///     Adds the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="creatureSpawn">The creature spawn.</param>
 public static void Add(NetworkMessage message, CreatureSpawn creatureSpawn)
 {
     message.AddPacketType(GamePacketType.CreatureHealth);
     message.AddUInt32(creatureSpawn.Id);
     message.AddPercent(creatureSpawn.Health.ToPercent());
 }