[REDACTED 8811]

Hello,

So I'd like the function to set skills up to the normal 100.0 cap, and if you eat a 120 scroll, you can set it further.

Testcenter comes with undername stats and weird stuff. I tried the simple way by removing everything from TC but it just didnt work.

Any ideas, hints?
 
It would be better to make special command based on TestCenter speech keywords.
If you only need skills it might look like:
C#:
using System;

namespace Server.Commands
{
    public class SetSkillCommand
    {
        public static void Initialize()
        {
            CommandSystem.Register("SetSkill", AccessLevel.Player, new CommandEventHandler(SetPlayerSkills_OnCommand));
        }

        private static void SetPlayerSkills_OnCommand(CommandEventArgs e)
        {
            if (!String.IsNullOrEmpty(e.ArgString))
            {
                Mobile from = e.Mobile;

                if (e.Arguments.Length == 2)
                {
                    try
                    {
                        string name = e.Arguments[0];
                        double value = Convert.ToDouble(e.Arguments[1]);

                        ChangeSkill(from, name, value);
                    }
                    catch (Exception exc)
                    {
                        Diagnostics.ExceptionLogging.LogException(exc);
                    }
                }
                else
                    from.SendMessage("Use the next signature to set skills: [SetSkill Anatomy 100");
            }
        }

        private static void ChangeSkill(Mobile from, string name, double value)
        {
            SkillName index;

            if (!Enum.TryParse(name, true, out index))
            {
                from.SendLocalizedMessage(1005631); // You have specified an invalid skill to set.
                return;
            }

            Skill skill = from.Skills[index];

            if (skill != null)
            {
                if (value < 0 || value > skill.Cap)
                {
                    from.SendMessage(string.Format("Your skill in {0} is capped at {1:F1}.", skill.Info.Name, skill.Cap));
                }
                else
                {
                    int newFixedPoint = (int)(value * 10.0);
                    int oldFixedPoint = skill.BaseFixedPoint;

                    if (((skill.Owner.Total - oldFixedPoint) + newFixedPoint) > skill.Owner.Cap)
                    {
                        from.SendMessage("You can not exceed the skill cap.  Try setting another skill lower first.");
                    }
                    else
                    {
                        skill.BaseFixedPoint = newFixedPoint;
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(1005631); // You have specified an invalid skill to set.
            }
        }
    }
}
Post automatically merged:

Usage examples:
[setskill tactics 100
[setskill evalint 100
etc
 
Post automatically merged:

It would be better to make special command based on TestCenter speech keywords.
If you only need skills it might look like:
C#:
using System;

namespace Server.Commands
{
    public class SetSkillCommand
    {
        public static void Initialize()
        {
            CommandSystem.Register("SetSkill", AccessLevel.Player, new CommandEventHandler(SetPlayerSkills_OnCommand));
        }

        private static void SetPlayerSkills_OnCommand(CommandEventArgs e)
        {
            if (!String.IsNullOrEmpty(e.ArgString))
            {
                Mobile from = e.Mobile;

                if (e.Arguments.Length == 2)
                {
                    try
                    {
                        string name = e.Arguments[0];
                        double value = Convert.ToDouble(e.Arguments[1]);

                        ChangeSkill(from, name, value);
                    }
                    catch (Exception exc)
                    {
                        Diagnostics.ExceptionLogging.LogException(exc);
                    }
                }
                else
                    from.SendMessage("Use the next signature to set skills: [SetSkill Anatomy 100");
            }
        }

        private static void ChangeSkill(Mobile from, string name, double value)
        {
            SkillName index;

            if (!Enum.TryParse(name, true, out index))
            {
                from.SendLocalizedMessage(1005631); // You have specified an invalid skill to set.
                return;
            }

            Skill skill = from.Skills[index];

            if (skill != null)
            {
                if (value < 0 || value > skill.Cap)
                {
                    from.SendMessage(string.Format("Your skill in {0} is capped at {1:F1}.", skill.Info.Name, skill.Cap));
                }
                else
                {
                    int newFixedPoint = (int)(value * 10.0);
                    int oldFixedPoint = skill.BaseFixedPoint;

                    if (((skill.Owner.Total - oldFixedPoint) + newFixedPoint) > skill.Owner.Cap)
                    {
                        from.SendMessage("You can not exceed the skill cap.  Try setting another skill lower first.");
                    }
                    else
                    {
                        skill.BaseFixedPoint = newFixedPoint;
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(1005631); // You have specified an invalid skill to set.
            }
        }
    }
}
Post automatically merged:

Usage examples:
Would I add this to the PlayerMobile?
Sorry, I havent really fiddled with core scripts yet
 
Would I add this to the PlayerMobile?
If you want, but will need to remove namespaces and usings for it.
It's already fully worked script, so you can just copy and create file with that code, then put it anywhere in Scripts folder and it will work.
 
If you want, but will need to remove namespaces and usings for it.
It's already fully worked script, so you can just copy and create file with that code, then put it anywhere in Scripts folder and it will work.
Youre a true gem. I will try this out today. Thank you so much
 
If you want, but will need to remove namespaces and usings for it.
It's already fully worked script, so you can just copy and create file with that code, then put it anywhere in Scripts folder and it will work.
Hey, I could not get this to work, am I doing something wrong?
 
Thanks! I tried it, but it doesnt seem to let players access that command for whatever reason
 
It should work, because there's set player access. I tested and works fine.
C#:
 CommandSystem.Register("SetSkill", AccessLevel.Player, new CommandEventHandler(SetPlayerSkills_OnCommand));
Make sure that players are using command like (with brakets): [SetSkill Anatomy 100
 
It should work, because there's set player access. I tested and works fine.
C#:
 CommandSystem.Register("SetSkill", AccessLevel.Player, new CommandEventHandler(SetPlayerSkills_OnCommand));
Make sure that players are using command like (with brakets): [SetSkill Anatomy 100
I got this to work, I cannot thank you enough! :)

I have one more question,
I tried this:
SetStats:
 public static void Initialize()
        {
            CommandSystem.Register("SetStats", AccessLevel.Player, new CommandEventHandler(SetPlayerSkills_OnCommand));
        }

        private static void SetPlayerStats_OnCommand(CommandEventArgs e)
        {
            if (!String.IsNullOrEmpty(e.ArgString))
            {
                Mobile from = e.Mobile;

                if (e.Arguments.Length == 2)
                {
                    try
                    {
                        string name = e.Arguments[0];
                        double value = Convert.ToDouble(e.Arguments[1]);

                        ChangeStats(from, name, value);
                    }
                    catch (Exception exc)
                    {
                      //  Diagnostics.ExceptionLogging.LogException(exc);
                    }
                }
                else
                    from.SendMessage("Use the next signature to set stats: [SetStats Str 100");
            }
        }

       private static void ChangeStrength(Mobile from, int value)
        {
            if (value < 10 || value > 125)
            {
                from.SendLocalizedMessage(1005628); // Stats range between 10 and 125.
            }
            else
            {
                if ((value + from.RawDex + from.RawInt) > from.StatCap)
                {
                    from.SendLocalizedMessage(1005629); // You can not exceed the stat cap.  Try setting another stat lower first.
                }
                else
                {
                    from.RawStr = value;
                    from.SendLocalizedMessage(1005630); // Your stats have been adjusted.
                }
            }
        

        private static void ChangeDexterity(Mobile from, int value)
        {
            if (value < 10 || value > 125)
            {
                from.SendLocalizedMessage(1005628); // Stats range between 10 and 125.
            }
            else
            {
                if ((from.RawStr + value + from.RawInt) > from.StatCap)
                {
                    from.SendLocalizedMessage(1005629); // You can not exceed the stat cap.  Try setting another stat lower first.
                }
                else
                {
                    from.RawDex = value;
                    from.SendLocalizedMessage(1005630); // Your stats have been adjusted.
                }
            }
        

        private static void ChangeIntelligence(Mobile from, int value)
        {
            if (value < 10 || value > 125)
            {
                from.SendLocalizedMessage(1005628); // Stats range between 10 and 125.
            }
            else
            {
                if ((from.RawStr + from.RawDex + value) > from.StatCap)
                {
                    from.SendLocalizedMessage(1005629); // You can not exceed the stat cap.  Try setting another stat lower first.
                }
                else
                {
                    from.RawInt = value;
                    from.SendLocalizedMessage(1005630); // Your stats have been adjusted.

But it somehow Im missing something.
Do I need to add some off this in?


C#:
 public static void Initialize()
        {
            if (Enabled)
                EventSink.Speech += EventSink_Speech;
        }

        private static void EventSink_Speech(SpeechEventArgs args)
        {
            if (!args.Handled)
            {
                if (Insensitive.StartsWith(args.Speech, "set"))
                {
                    Mobile from = args.Mobile;

                    string[] split = args.Speech.Split(' ');

                    if (split.Length == 3)
                    {
                        try
                        {
                            string name = split[1];
                            double value = Convert.ToDouble(split[2]);

                            if (Insensitive.Equals(name, "str"))
                                ChangeStrength(from, (int)value);
                            else if (Insensitive.Equals(name, "dex"))
                                ChangeDexterity(from, (int)value);
                            else if (Insensitive.Equals(name, "int"))
                                ChangeIntelligence(from, (int)value);
                            else
                                ChangeSkill(from, name, value);
                        }
                        catch (Exception e)
                        {
                            Diagnostics.ExceptionLogging.LogException(e);
                        }
                    }
                }

Not actually sure what im doing wrong here, copying what you did but for stats.
 
Back