예제 #1
0
 /// <summary>
 ///     Sends the message.
 /// </summary>
 /// <param name="characterSpawn">The character spawn.</param>
 /// <param name="text">The text.</param>
 /// <param name="type">The type.</param>
 protected virtual void SendMessage(ICharacterSpawn characterSpawn, string text, SpeechType type)
 {
     foreach (ICharacterSpawn member in Members.Values)
     {
         member.Connection.SendChannelMessage(characterSpawn, Id, type, text);
     }
 }
예제 #2
0
 /// <inheritdoc />
 /// <summary>
 ///     Sends the message.
 /// </summary>
 /// <param name="characterSpawn">The character spawn.</param>
 /// <param name="text">The text.</param>
 /// <param name="type">The type.</param>
 protected override void SendMessage(ICharacterSpawn characterSpawn, string text, SpeechType type)
 {
     foreach (ICharacterSpawn member in Members.Values)
     {
         member.Connection.SendCreatureSpeech(characterSpawn, type, text, characterSpawn.Tile.Position);
     }
 }
예제 #3
0
        /// <summary>
        ///     Adds the floor description.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="position">The position.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="creatureSpawnService">The creature spawn service.</param>
        /// <param name="tileService">The tile service.</param>
        /// <param name="skip">The skip.</param>
        public static void AddFloorDescription(NetworkMessage message, ICharacterSpawn characterSpawn, Vector3 position, int width, int height, int offset, CreatureSpawnService creatureSpawnService, TileService tileService, ref int skip)
        {
            // TODO: These magic numbers should not be hard-coded!!!!!
            for (int nx = 0; nx < width; nx++)
            {
                for (int ny = 0; ny < height; ny++)
                {
                    Vector3 tilePosition = new Vector3(position.X + nx + offset, position.Y + ny + offset, position.Z);
                    ITile   tile         = tileService.GetTileByPosition(tilePosition);
                    if (tile != null)
                    {
                        if (skip >= 0)
                        {
                            message.AddByte((byte)skip);
                            message.AddByte(0xFF);
                        }
                        skip = 0;

                        AddTileDescription(message, characterSpawn, tile, tileService, creatureSpawnService);
                    }
                    else
                    {
                        skip++;
                        if (skip == 0xFF)
                        {
                            message.AddByte(0xFF);
                            message.AddByte(0xFF);
                            skip = -1;
                        }
                    }
                }
            }
        }
예제 #4
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));
        }
예제 #5
0
        /// <summary>
        ///     Executes the specified text and returns whether it can be posted in the channel.
        /// </summary>
        /// <param name="caster">The caster.</param>
        /// <param name="text">The text.</param>
        /// <returns>
        ///     <see langword="true" /> if [post in channel]; otherwise, <see langword="false" />
        /// </returns>
        public bool Execute(ICharacterSpawn caster, string text)
        {
            text = text.Trim().ToLower();
            List <string> parameters = text.Split(' ').ToList();
            string        keyword    = parameters.FirstOrDefault();

            if (string.IsNullOrWhiteSpace(keyword) || !_commandsByKeyword.ContainsKey(keyword))
            {
                return(false);
            }

            if (!_commandsByKeyword.TryGetValue(keyword, out ICommand command))
            {
                return(false);
            }

            string[] args          = parameters.Skip(1).ToArray();
            bool     postInChannel = command.PostInChannel(caster, args);

            if (!command.CanExecute(caster, args))
            {
                return(postInChannel);
            }

            command.Execute(caster, args);
            return(postInChannel);
        }
예제 #6
0
 /// <summary>
 ///     Adds the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="character">The character.</param>
 /// <param name="position">The position.</param>
 /// <param name="stackPosition">The stack position.</param>
 /// <param name="creature">The creature.</param>
 /// <param name="known">if set to <c>true</c> [known].</param>
 /// <param name="removeKnown">The remove known.</param>
 public static void Add(NetworkMessage message, ICharacterSpawn character, IVector3 position, byte stackPosition, ICreatureSpawn creature, bool known, uint removeKnown)
 {
     message.AddPacketType(GamePacketType.TileAddArtifact);
     message.AddVector3(position);
     message.AddByte(stackPosition);
     AddCreature(message, character, creature, known, removeKnown);
 }
예제 #7
0
        /// <summary>
        ///     Adds the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="sourcePosition">The source position.</param>
        /// <param name="targetPosition">The target position.</param>
        /// <param name="creatureSpawnService">The creature spawn service.</param>
        /// <param name="tileService">The tile service.</param>
        public static void Add(NetworkMessage message, ICharacterSpawn characterSpawn, IVector3 sourcePosition, IVector3 targetPosition, CreatureSpawnService creatureSpawnService, TileService tileService)
        {
            if (sourcePosition.Y > targetPosition.Y)
            {
                // North, for old X
                message.AddPacketType(GamePacketType.MapSliceNorth);
                AddMapDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, targetPosition.Y - 6, targetPosition.Z), 18, 1, creatureSpawnService, tileService);
            }
            else if (sourcePosition.Y < targetPosition.Y)
            {
                // South, for old X
                message.AddPacketType(GamePacketType.MapSliceSouth);
                AddMapDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, targetPosition.Y + 7, targetPosition.Z), 18, 1, creatureSpawnService, tileService);
            }

            if (sourcePosition.X < targetPosition.X)
            {
                // East, with new Y
                message.AddPacketType(GamePacketType.MapSliceEast);
                AddMapDescription(message, characterSpawn, new Vector3(targetPosition.X + 9, targetPosition.Y - 6, targetPosition.Z), 1, 14, creatureSpawnService, tileService);
            }
            else if (sourcePosition.X > targetPosition.X)
            {
                // West, with new Y
                message.AddPacketType(GamePacketType.MapSliceWest);
                AddMapDescription(message, characterSpawn, new Vector3(targetPosition.X - 8, targetPosition.Y - 6, targetPosition.Z), 1, 14, creatureSpawnService, tileService);
            }
        }
예제 #8
0
        /// <summary>
        ///     Adds the map description.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="position">The position.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="creatureSpawnService">The creature spawn service.</param>
        /// <param name="tileService">The tile service.</param>
        public static void AddMapDescription(NetworkMessage message, ICharacterSpawn characterSpawn, Vector3 position, ushort width, ushort height, CreatureSpawnService creatureSpawnService, TileService tileService)
        {
            // TODO: These magic numbers should not be hard-coded
            int skip = -1;
            int startZ;
            int endZ;
            int zStep;

            if (position.Z > 7)
            {
                startZ = position.Z - 2;
                // TODO: endZ = Math.Min(WorldMap.MaxLayers - 1, position.Z + 2);
                endZ  = Math.Min(15, position.Z + 2);
                zStep = 1;
            }
            else
            {
                startZ = 7;
                endZ   = 0;
                zStep  = -1;
            }

            for (int nz = startZ; nz != endZ + zStep; nz += zStep)
            {
                AddFloorDescription(message, characterSpawn, new Vector3(position.X, position.Y, nz), width, height, position.Z - nz, creatureSpawnService, tileService, ref skip);
            }

            if (skip >= 0)
            {
                message.AddByte((byte)skip);
                message.AddByte(0xFF);
            }
        }
예제 #9
0
        /// <summary>
        ///     Unregisters the specified character spawn from all channels.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        public void UnregisterFromAllChannels(ICharacterSpawn characterSpawn)
        {
            foreach (IChannel channel in _channelByType.Values)
            {
                channel.Unregister(characterSpawn);
            }

            foreach (IPartyChannel channel in _channelByPartyId.Values)
            {
                channel.Unregister(characterSpawn);
            }

            foreach (IGuildChannel channel in _channelByGuildId.Values)
            {
                channel.Unregister(characterSpawn);
            }

            List <IPrivateChannel> privateChannels = _privateChannelByOwnerId.Values.ToList();

            foreach (IPrivateChannel channel in privateChannels)
            {
                channel.Uninvite(characterSpawn);
                channel.Unregister(characterSpawn);

                if (channel.Owner == characterSpawn)
                {
                    ClosePrivateChannel(characterSpawn.Id);
                }
            }
        }
예제 #10
0
        /// <summary>
        ///     Adds the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="position">The position.</param>
        /// <param name="creatureSpawnService">The creature spawn service.</param>
        /// <param name="tileService">The tile service.</param>
        public static void Add(NetworkMessage message, ICharacterSpawn characterSpawn, IVector3 position, CreatureSpawnService creatureSpawnService, TileService tileService)
        {
            message.AddPacketType(GamePacketType.MapDescription);
            message.AddVector3(position);

            // TODO: These magic numbers should not be hard-coded
            AddMapDescription(message, characterSpawn, new Vector3(position.X - 8, position.Y - 6, position.Z), 18, 14, creatureSpawnService, tileService);
        }
예제 #11
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);
        }
예제 #12
0
        /// <inheritdoc />
        /// <summary>
        ///     Invites the specified character spawn.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <exception cref="T:System.NotImplementedException"></exception>
        public void Invite(ICharacterSpawn characterSpawn)
        {
            if (Invitations.Contains(characterSpawn))
            {
                return;
            }

            Invitations.Add(characterSpawn);
        }
예제 #13
0
        /// <inheritdoc />
        /// <summary>
        ///     Uninvites the specified character spawn.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        public void Uninvite(ICharacterSpawn characterSpawn)
        {
            if (!Invitations.Contains(characterSpawn))
            {
                return;
            }

            Invitations.Remove(characterSpawn);
        }
예제 #14
0
        /// <summary>
        ///     Registers the character spawn to a specific channel.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="channel">The channel.</param>
        public void RegisterCharacterSpawn(ICharacterSpawn characterSpawn, IChannel channel)
        {
            if (!_channelsByCharacterSpawnId.ContainsKey(characterSpawn.Id))
            {
                _channelsByCharacterSpawnId.Add(characterSpawn.Id, new HashSet <IChannel>());
            }

            _channelsByCharacterSpawnId[characterSpawn.Id].Add(channel);
            channel.Register(characterSpawn);
        }
예제 #15
0
        /// <inheritdoc />
        /// <summary>
        ///     Gets a value indicating whether the text should be posted in the channel.
        /// </summary>
        /// <param name="caster">The caster.</param>
        /// <param name="args">The arguments.</param>
        /// <returns>
        ///     <see langword="true" /> if [post in channel]; otherwise, <see langword="false" />
        /// </returns>
        public override bool PostInChannel(ICharacterSpawn caster, params string[] args)
        {
            if (!caster.Creature.Settings.CanSeeDiagnostics)
            {
                return(false);
            }

            ITile currentTile = caster.Tile;

            return(currentTile?.Position != null && currentTile.Ground?.Item != null);
        }
예제 #16
0
        /// <summary>
        ///     Creates the private channel.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <returns>The channel.</returns>
        public IChannel CreatePrivateChannel(ICharacterSpawn characterSpawn)
        {
            if (!_privateChannelByOwnerId.ContainsKey(characterSpawn.Id))
            {
                PrivateChannel channel = new PrivateChannel();
                channel.Id    = characterSpawn.Id;
                channel.Owner = characterSpawn;
                _privateChannelByOwnerId.Add(characterSpawn.Id, channel);
            }

            return(_privateChannelByOwnerId[characterSpawn.Id]);
        }
예제 #17
0
        /// <inheritdoc />
        /// <summary>
        ///     Executes the command.
        /// </summary>
        /// <param name="caster">The caster.</param>
        /// <param name="args">The arguments.</param>
        protected override void ExecuteCommand(ICharacterSpawn caster, string[] args)
        {
            ITile         currentTile   = caster.Tile;
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("\n========== POSITION INFO ==========\n");
            stringBuilder.Append($"Position: {currentTile.Position.X}, {currentTile.Position.Y}, {currentTile.Position.Z}\n");
            stringBuilder.Append($"Ground: {(!string.IsNullOrWhiteSpace(currentTile.Ground.Item.Name) ? currentTile.Ground.Item.Name : "Undefined")}, Speed: {currentTile.Ground.Item.Speed ?? 0}\n");
            stringBuilder.Append($"Flags: {currentTile.Flags}");

            caster.Connection.SendTextMessage(TextMessageType.InformationDescription, stringBuilder.ToString());
        }
예제 #18
0
        /// <inheritdoc />
        /// <summary>
        ///     Executes the command.
        /// </summary>
        /// <param name="caster">The caster.</param>
        /// <param name="args">The arguments.</param>
        protected override void ExecuteCommand(ICharacterSpawn caster, string[] args)
        {
            if (args.Length == 0)
            {
                return;
            }

            foreach (ICharacterSpawn characterSpawn in _creatureSpawnService.CharacterSpawns)
            {
                characterSpawn.Connection.SendTextMessage(TextMessageType.StatusWarning, string.Join(" ", args));
            }
        }
예제 #19
0
        /// <inheritdoc />
        /// <summary>
        ///     Queries the channel with the specified character spawn.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        public void Query(ICharacterSpawn characterSpawn)
        {
            QueryingChannelEventArgs queryingChannelEventArgs = new QueryingChannelEventArgs(characterSpawn);

            Querying?.Invoke(this, queryingChannelEventArgs);
            if (queryingChannelEventArgs.Cancel)
            {
                return;
            }

            QueriedChannelEventArgs queriedChannelEventArgs = new QueriedChannelEventArgs(characterSpawn);

            Queried?.Invoke(this, queriedChannelEventArgs);
        }
예제 #20
0
        /// <summary>
        ///     Determines whether this instance can see the specified creature spawn.
        /// </summary>
        /// <param name="self">The self.</param>
        /// <param name="creatureSpawn">The creature spawn.</param>
        /// <returns>
        ///     <c>true</c> if this instance can see the specified creature spawn; otherwise, <c>false</c>.
        /// </returns>
        public static bool CanSee(this ICharacterSpawn self, ICreatureSpawn creatureSpawn)
        {
            if (self == creatureSpawn)
            {
                return(true);
            }

            // TODO: Ghost Mode
            //if (creature.isInGhostMode() && !Group.UnrestrictedAccess)
            //    return false;

            // TODO: Implement invisibility immunity
            return(!creatureSpawn.IsInvisible && ((ICreatureSpawn)self).CanSee(creatureSpawn));
        }
예제 #21
0
        /// <inheritdoc />
        /// <summary>
        ///     Posts the specified message.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="text">The text.</param>
        /// <param name="type">The type.</param>
        public void Post(ICharacterSpawn characterSpawn, string text, SpeechType type)
        {
            ChannelPostingEventArgs channelPostingEventArgs = new ChannelPostingEventArgs(characterSpawn, type, text);

            Posting?.Invoke(this, channelPostingEventArgs);
            if (channelPostingEventArgs.Cancel)
            {
                return;
            }

            SendMessage(characterSpawn, channelPostingEventArgs.Text, channelPostingEventArgs.Type);

            ChannelPostedEventArgs channelPostedEventArgs = new ChannelPostedEventArgs(characterSpawn, channelPostingEventArgs.Type, channelPostingEventArgs.Text);

            Posted?.Invoke(this, channelPostedEventArgs);
        }
예제 #22
0
        /// <inheritdoc />
        /// <summary>
        ///     Executes the command from the specified caster.
        /// </summary>
        /// <param name="caster">The caster.</param>
        /// <param name="args">The arguments.</param>
        public void Execute(ICharacterSpawn caster, params string[] args)
        {
            ExecutingCommandEventArgs executingCommandEventArgs = new ExecutingCommandEventArgs(caster, args);

            Executing?.Invoke(this, executingCommandEventArgs);
            if (executingCommandEventArgs.Cancel)
            {
                return;
            }

            ExecuteCommand(executingCommandEventArgs.Caster, executingCommandEventArgs.Args);

            ExecutedCommandEventArgs executedCommandEventArgs = new ExecutedCommandEventArgs(executingCommandEventArgs.Caster, executingCommandEventArgs.Args);

            Executed?.Invoke(this, executedCommandEventArgs);
        }
예제 #23
0
        /// <summary>
        ///     Adds the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="sourcePosition">The source position.</param>
        /// <param name="sourceStackPosition">The source stack position.</param>
        /// <param name="targetPosition">The target position.</param>
        /// <param name="creatureSpawnService">The creature spawn service.</param>
        /// <param name="tileService">The tile service.</param>
        public static void Add(NetworkMessage message, ICharacterSpawn characterSpawn, IVector3 sourcePosition, byte sourceStackPosition, IVector3 targetPosition, CreatureSpawnService creatureSpawnService, TileService tileService)
        {
            // Floor change up
            message.AddPacketType(GamePacketType.FloorChangeUp);

            // Going to surface
            if (targetPosition.Z == 7)
            {
                int skip = -1;

                // Floor 7 and 6 already set
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, 5), 18, 14, 3, creatureSpawnService, tileService, ref skip);
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, 4), 18, 14, 4, creatureSpawnService, tileService, ref skip);
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, 3), 18, 14, 5, creatureSpawnService, tileService, ref skip);
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, 2), 18, 14, 6, creatureSpawnService, tileService, ref skip);
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, 1), 18, 14, 7, creatureSpawnService, tileService, ref skip);
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, 0), 18, 14, 8, creatureSpawnService, tileService, ref skip);

                if (skip >= 0)
                {
                    message.AddByte((byte)skip);
                    message.AddByte(0xFF);
                }
            }

            // Underground, going one floor up (still underground)
            else if (targetPosition.Z > 7)
            {
                int skip = -1;
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, sourcePosition.Z - 3), 18, 14, 3, creatureSpawnService, tileService, ref skip);

                if (skip >= 0)
                {
                    message.AddByte((byte)skip);
                    message.AddByte(0xFF);
                }
            }

            // Moving up a floor up makes us out of sync
            // Eest
            message.AddPacketType(GamePacketType.MapSliceWest);
            AddMapDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y + 1 - 6, targetPosition.Z), 1, 14, creatureSpawnService, tileService);

            // North
            message.AddPacketType(GamePacketType.MapSliceNorth);
            AddMapDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, targetPosition.Z), 18, 1, creatureSpawnService, tileService);
        }
예제 #24
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());
        }
예제 #25
0
        /// <summary>
        ///     Adds the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="sourcePosition">The source position.</param>
        /// <param name="sourceStackPosition">The source stack position.</param>
        /// <param name="targetPosition">The target position.</param>
        /// <param name="creatureSpawnService">The creature spawn service.</param>
        /// <param name="tileService">The tile service.</param>
        public static void Add(NetworkMessage message, ICharacterSpawn characterSpawn, IVector3 sourcePosition, byte sourceStackPosition, IVector3 targetPosition, CreatureSpawnService creatureSpawnService, TileService tileService)
        {
            message.AddPacketType(GamePacketType.FloorChangeDown);
            if (targetPosition.Z == 8)
            {
                // Going from surface to underground
                // TODO: These magic numbers should not be hard-coded
                int skip = -1;
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, targetPosition.Z), 18, 14, -1, creatureSpawnService, tileService, ref skip);
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, targetPosition.Z + 1), 18, 14, -2, creatureSpawnService, tileService, ref skip);
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, targetPosition.Z + 2), 18, 14, -3, creatureSpawnService, tileService, ref skip);

                if (skip >= 0)
                {
                    message.AddByte((byte)skip);
                    message.AddByte(0xFF);
                }
            }
            else if (targetPosition.Z > sourcePosition.Z && targetPosition.Z > 8 && targetPosition.Z < 14)
            {
                // Going further down
                // TODO: These magic numbers should not be hard-coded
                int skip = -1;
                AddFloorDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y - 6, targetPosition.Z + 2), 18, 14, -3, creatureSpawnService, tileService, ref skip);

                if (skip >= 0)
                {
                    message.AddByte((byte)skip);
                    message.AddByte(0xFF);
                }
            }

            // Moving down a floor makes us out of sync
            // East
            // TODO: These magic numbers should not be hard-coded
            message.AddPacketType(GamePacketType.MapSliceEast);
            AddMapDescription(message, characterSpawn, new Vector3(sourcePosition.X + 9, sourcePosition.Y - 1 - 6, targetPosition.Z), 1, 14, creatureSpawnService, tileService);

            // South
            // TODO: These magic numbers should not be hard-coded
            message.AddPacketType(GamePacketType.MapSliceSouth);
            AddMapDescription(message, characterSpawn, new Vector3(sourcePosition.X - 8, sourcePosition.Y + 7, targetPosition.Z), 18, 1, creatureSpawnService, tileService);
        }
예제 #26
0
        /// <summary>
        ///     Adds the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="characterSpawn">The character spawn.</param>
        /// <param name="canReportBugs">if set to <c>true</c> [can report bugs].</param>
        public static void Add(NetworkMessage message, ICharacterSpawn characterSpawn, bool canReportBugs)
        {
            message.AddPacketType(GamePacketType.SelfAppear);
            message.AddUInt32(characterSpawn.Id);

            // TODO: Beat duration (50)
            message.AddUInt16(0x32);

            // TODO: Remove base speeds
            message.AddDouble(857.36, 3);
            message.AddDouble(261.29, 3);
            message.AddDouble(-4795.01, 3);
            message.AddBoolean(canReportBugs);

            // TODO: Can change pvp framing option
            message.AddByte(0x00);

            // TODO: Expert mode button enabled
            message.AddByte(0x00);
        }
예제 #27
0
        /// <inheritdoc />
        /// <summary>
        ///     Registers the specified character spawn.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        public void Register(ICharacterSpawn characterSpawn)
        {
            if (Members.ContainsKey(characterSpawn.Id))
            {
                return;
            }

            ChannelRegisteringEventArgs channelRegisteringEventArgs = new ChannelRegisteringEventArgs(characterSpawn);

            Registering?.Invoke(this, channelRegisteringEventArgs);
            if (channelRegisteringEventArgs.Cancel)
            {
                return;
            }

            Members.Add(characterSpawn.Id, characterSpawn);

            ChannelRegisteredEventArgs channelRegisteredEventArgs = new ChannelRegisteredEventArgs(characterSpawn);

            Registered?.Invoke(this, channelRegisteredEventArgs);
        }
예제 #28
0
        /// <inheritdoc />
        /// <summary>
        ///     Unregisters the specified character spawn.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        public void Unregister(ICharacterSpawn characterSpawn)
        {
            if (!Members.ContainsKey(characterSpawn.Id))
            {
                return;
            }

            ChannelUnregisteringEventArgs channelUnregisteringEventArgs = new ChannelUnregisteringEventArgs(characterSpawn);

            Unregistering?.Invoke(this, channelUnregisteringEventArgs);
            if (channelUnregisteringEventArgs.Cancel)
            {
                return;
            }

            Members.Remove(characterSpawn.Id);

            ChannelUnregisteredEventArgs channelUnregisteredEventArgs = new ChannelUnregisteredEventArgs(characterSpawn);

            Unregistered?.Invoke(this, channelUnregisteredEventArgs);
        }
예제 #29
0
 /// <inheritdoc />
 /// <summary>
 ///     Determines whether this instance can be executed by the caster.
 /// </summary>
 /// <param name="caster">The caster.</param>
 /// <param name="args">The arguments.</param>
 /// <returns>
 ///     <see langword="true" /> if this instance can be executed by the specified caster; otherwise,
 ///     <see langword="false" />.
 /// </returns>
 public override bool CanExecute(ICharacterSpawn caster, params string[] args)
 {
     return(!caster.Creature.Settings.CanSeeDiagnostics);
 }
예제 #30
0
 /// <summary>
 ///     Executes the query.
 /// </summary>
 /// <param name="characterSpawn">The character spawn.</param>
 protected virtual void ExecuteQuery(ICharacterSpawn characterSpawn)
 {
 }