Ejemplo n.º 1
0
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            // Fallback to self if no target is selected
            if (target.Instance == 0)
            {
                target.Type     = client.Character.Type;
                target.Instance = client.Character.Id;
            }

            int statId = StatsList.GetStatId(args[1]);

            if (statId == 1234567890)
            {
                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)
                {
                }
            }
            Character tempch = (Character)FindDynel.FindDynelById(target.Type, target.Instance);
            uint      statOldValue;

            try
            {
                statOldValue = tempch.Stats.GetBaseValue(statId);
                tempch.Stats.SetStatValueByName(statId, statNewValue);
                if (tempch.Client != null)
                {
                    tempch.Stats.Send(tempch.Client, statId);
                }
            }
            catch
            {
                client.SendChatText("Unknown StatId " + statId);
                return;
            }

            string response = "Character " + tempch.Name + " (" + target.Instance + "): Stat "
                              + StatsList.GetStatName(statId) + " (" + statId + ") =";

            response += " Old: " + statOldValue;
            response += " New: " + statNewValue;
            client.SendChatText(response);
        }
Ejemplo n.º 2
0
        public override void ExecuteCommand(Client client, Identity target, string[] args)
        {
            // Fallback to self if no target is selected
            if (target.Instance == 0)
            {
                target.Type     = client.Character.Type;
                target.Instance = client.Character.Id;
            }
            if (target.Type != 50000)
            {
                client.SendChatText("Target must be player/monster/NPC");
                return;
            }
            Dynel targetDynel = FindDynel.FindDynelById(target.Type, target.Instance);

            if (targetDynel != null)
            {
                Character targetCharacter = (Character)targetDynel;
                // May be obsolete in the future, let it stay in comment yet
                // ch.CalculateSkills();
                int statId = StatsList.GetStatId(args[1]);
                if (statId == 1234567890)
                {
                    client.SendChatText("Unknown Stat name " + args[1]);
                    return;
                }

                uint statValue;
                int  effectiveValue;
                int  trickle;
                int  mod;
                int  perc;
                try
                {
                    statValue      = targetCharacter.Stats.GetBaseValue(statId);
                    effectiveValue = targetCharacter.Stats.StatValueByName(statId);
                    trickle        = targetCharacter.Stats.GetStatbyNumber(statId).Trickle;
                    mod            = targetCharacter.Stats.GetStatbyNumber(statId).StatModifier;
                    perc           = targetCharacter.Stats.GetStatbyNumber(statId).StatPercentageModifier;
                }
                catch (StatDoesNotExistException)
                {
                    client.SendChatText("Unknown Stat Id " + statId);
                    return;
                }

                string response = "Character " + targetCharacter.Name + " (" + targetCharacter.Id + "): Stat "
                                  + StatsList.GetStatName(statId) + " (" + statId + ") = " + statValue;

                client.SendChatText(response);
                if (statValue != targetCharacter.Stats.StatValueByName(args[1]))
                {
                    response = "Effective value Stat " + StatsList.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.");
            }
        }