Пример #1
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <returns>
        /// </returns>
        public override bool AddClient(IClient client)
        {
            Client cl = (Client)client;

            int charLevel =
                StatDao.Instance.GetById(50000, (int)cl.Character.CharacterId, StatNamesDefaults.GetStatNumber("Level"))
                .StatValue;

            if ((charLevel >= this.MinLevel) && (charLevel <= this.MaxLevel))
            {
                return(base.AddClient(client));
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            // Fallback to self if no target is selected
            if (target.Instance == 0)
            {
                target = character.Identity;
            }

            if (target.Type != IdentityType.CanbeAffected)
            {
                character.Playfield.Publish(
                    ChatTextMessageHandler.Default.CreateIM(character, "Target must be player/monster/NPC"));
                return;
            }

            Dynel targetDynel = (Dynel)character.Playfield.FindByIdentity(target);

            if (targetDynel != null)
            {
                Character targetCharacter = (Character)targetDynel;

                // May be obsolete in the future, let it stay in comment yet
                // ch.CalculateSkills();

                // Check for numbers too, not only for names
                int statId;
                if (!int.TryParse(args[1], out statId))
                {
                    try
                    {
                        statId = StatNamesDefaults.GetStatNumber(args[1]);
                    }
                    catch (Exception)
                    {
                        statId = 1234567890;
                    }
                }

                if (statId == 1234567890)
                {
                    character.Playfield.Publish(
                        ChatTextMessageHandler.Default.CreateIM(character, "Unknown Stat name " + args[1]));
                    return;
                }

                uint statValue;
                int  effectiveValue;
                int  trickle;
                int  mod;
                int  perc;
                try
                {
                    statValue      = targetCharacter.Stats[statId].BaseValue;
                    effectiveValue = targetCharacter.Stats[statId].Value;
                    trickle        = targetCharacter.Stats[statId].Trickle;
                    mod            = targetCharacter.Stats[statId].Modifier;
                    perc           = targetCharacter.Stats[statId].PercentageModifier;
                }
                catch (StatDoesNotExistException)
                {
                    character.Playfield.Publish(
                        ChatTextMessageHandler.Default.CreateIM(character, "Unknown Stat Id " + statId));
                    return;
                }

                string response = "Character " + targetCharacter.Name + " (" + targetCharacter.Identity.Instance
                                  + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = "
                                  + statValue;

                if (statValue != targetCharacter.Stats[statId].Value)
                {
                    response += "\r\nEffective value Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId
                                + ") = " + effectiveValue;
                }

                response += "\r\nTrickle: " + trickle + " Modificator: " + mod + " Percentage: " + perc;
                character.Playfield.Publish(ChatTextMessageHandler.Default.CreateIM(character, response));
            }
            else
            {
                // Shouldnt be happen again (fallback to self)
                character.Playfield.Publish(
                    ChatTextMessageHandler.Default.CreateIM(character, "Unable to find target."));
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            // Fallback to self if no target is selected
            if (target.Instance == 0)
            {
                target.Type     = character.Client.Character.Identity.Type;
                target.Instance = character.Client.Character.Identity.Instance;
            }

            int statId = 1234567890;

            if (!int.TryParse(args[1], out statId))
            {
                try
                {
                    statId = StatNamesDefaults.GetStatNumber(args[1].ToLower());
                }
                catch (Exception)
                {
                }
            }

            if (statId == 1234567890)
            {
                character.Playfield.Publish(ChatText.CreateIM(character, "Unknown Stat name " + args[1]));
                return;
            }

            uint statNewValue = 1234567890;

            try
            {
                statNewValue = (uint)int.Parse(args[2]);
            }
            catch
            {
                try
                {
                    // For values >= 2^31
                    statNewValue = uint.Parse(args[2]);
                }
                catch (FormatException)
                {
                }
                catch (OverflowException)
                {
                }
            }

            IInstancedEntity tempch = character.Playfield.FindByIdentity(target);

            uint statOldValue;

            try
            {
                statOldValue = tempch.Stats[statId].BaseValue;
                tempch.Stats[statId].Value = (int)statNewValue;
            }
            catch
            {
                character.Playfield.Publish(ChatText.CreateIM(character, "Unknown StatId " + statId));
                return;
            }

            string name = string.Empty;

            if (tempch is INamedEntity)
            {
                name = ((INamedEntity)tempch).Name + " ";
            }

            string response = "Dynel " + name + "(" + target.Type + ":" + target.Instance + "): Stat "
                              + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") =";

            response += " Old: " + statOldValue;
            response += " New: " + statNewValue;
            character.Playfield.Publish(ChatText.CreateIM(character, response));
        }
Пример #4
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            // Fallback to self if no target is selected
            bool fallback = false;

            if (target.Instance == 0)
            {
                target   = client.Character.Identity;
                fallback = true;
            }

            int statId = 0;

            try
            {
                statId = StatNamesDefaults.GetStatNumber(args[1]);
            }
            catch (Exception)
            {
                client.SendChatText("Unknown Stat name " + args[1]);
                return;
            }

            uint statNewValue = 1234567890;

            try
            {
                statNewValue = uint.Parse(args[2]);
            }
            catch
            {
                try
                {
                    // For values >= 2^31
                    statNewValue = uint.Parse(args[2]);
                }
                catch (FormatException)
                {
                }
                catch (OverflowException)
                {
                }
            }

            IStats tempch = client.Playfield.FindByIdentity(target);

            if (tempch == null)
            {
                client.SendChatText("Target vanished? This should NOT be reached");
            }

            uint statOldValue;

            try
            {
                statOldValue = tempch.Stats[statId].BaseValue;
                var IM =
                    new IMExecuteFunction(
                        new Functions
                {
                    Target       = Constants.ItemtargetSelectedtarget,
                    FunctionType = Constants.FunctiontypeSet,
                    Requirements = new List <Requirements>(),
                    Arguments    =
                        new FunctionArguments
                    {
                        Values =
                            new List <object> {
                            statId, (int)statNewValue
                        }
                    },
                    TickCount    = 1,
                    TickInterval = 1,
                    dolocalstats = true
                },
                        ((INamedEntity)tempch).Identity);
                if (fallback)
                {
                    IM.Function.Target = Constants.ItemtargetSelf;
                }

                if (tempch.CheckRequirements(IM.Function, true))
                {
                    ((IInstancedEntity)tempch).Playfield.Publish(IM);
                }
            }
            catch
            {
                client.SendChatText("Unknown StatId " + statId);
                return;
            }

            INamedEntity namedEntity = tempch as INamedEntity;
            string       response;

            if (namedEntity != null)
            {
                response = "Character " + namedEntity.Name + " (" + target.Instance + "): Stat "
                           + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") =";
            }
            else
            {
                response = "Dynel (" + ((IInstancedEntity)tempch).Identity.Instance + "): Stat "
                           + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") =";
            }

            response += " Old: " + statOldValue;
            response += " New: " + statNewValue;
            client.SendChatText(response);
        }
Пример #5
0
        /// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            // Fallback to self if no target is selected
            if (target.Instance == 0)
            {
                target = client.Character.Identity;
            }

            if (target.Type != IdentityType.CanbeAffected)
            {
                client.SendChatText("Target must be player/monster/NPC");
                return;
            }

            IInstancedEntity targetDynel = client.Playfield.FindByIdentity(target);

            if (targetDynel != null)
            {
                Dynel targetCharacter = (Dynel)targetDynel;

                // May be obsolete in the future, let it stay in comment yet
                // ch.CalculateSkills();
                int statId;
                try
                {
                    statId = StatNamesDefaults.GetStatNumber(args[1]);
                }
                catch (Exception)
                {
                    client.SendChatText("Unknown Stat name " + args[1]);
                    return;
                }

                uint statValue;
                int  effectiveValue;
                int  trickle;
                int  mod;
                int  perc;
                try
                {
                    statValue      = targetCharacter.Stats[statId].BaseValue;
                    effectiveValue = targetCharacter.Stats[statId].Value;
                    trickle        = targetCharacter.Stats[statId].Trickle;
                    mod            = targetCharacter.Stats[statId].Modifier;
                    perc           = targetCharacter.Stats[statId].PercentageModifier;
                }
                catch (StatDoesNotExistException)
                {
                    client.SendChatText("Unknown Stat Id " + statId);
                    return;
                }

                string       response   = string.Empty;
                INamedEntity namedDynel = targetCharacter as INamedEntity;
                if (namedDynel != null)
                {
                    response = "Character " + namedDynel.Name + " (" + targetCharacter.Identity.Instance + "): Stat "
                               + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + statValue;
                }
                else
                {
                    response = "Dynel " + targetCharacter.Identity.Instance + "Stat "
                               + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + statValue;
                }

                client.SendChatText(response);
                if (statValue != targetCharacter.Stats[args[1]].Value)
                {
                    response = "Effective value Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = "
                               + effectiveValue;
                    client.SendChatText(response);
                }

                response = "Trickle: " + trickle + " Modificator: " + mod + " Percentage: " + perc;
                client.SendChatText(response);
            }
            else
            {
                // Shouldnt be happen again (fallback to self)
                client.SendChatText("Unable to find target.");
            }
        }