Restricting metal armor to stealth

Fisher

Well-Known Member
Dec 24, 2014
78
6
42
The Boondocks
dawnuo.net
Shard Name
DawnUO
I want to make it so a player cannot stealth while wearing metal armor. I thought that I could just altered the armor table in stealth.cs but that has not worked. With a value of 100 for all the metal armor, and other various mutilations to the rest of the file, I have yet to find a way to accomplish my goal. Here is the file with the armor table edits.

Code:
using System;
using Server.Items;
using Server.Mobiles;

namespace Server.SkillHandlers
{
    public class Stealth
    {
        private static readonly int[,] m_ArmorTable = new int[,]
        {
            //    Gorget    Gloves    Helmet    Arms    Legs    Chest    Shield
            /* Cloth    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Leather    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Studded    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Bone        */ { 100, 100, 100, 100, 100, 100, 100 },
            /* Spined    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Horned    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Barbed    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Ring        */ { 100, 100, 100, 100, 100, 100, 100 },
            /* Chain    */ { 100, 100, 100, 100, 100, 100, 100 },
            /* Plate    */ { 100, 100, 100, 100, 100, 100, 100 },
            /* Dragon    */ { 100, 100, 100, 100, 100, 100, 100 }
        };
        public static double HidingRequirement
        {
            get
            {
                return (Core.ML ? 30.0 : (Core.SE ? 50.0 : 50.0));
            }
        }
        public static int[,] ArmorTable
        {
            get
            {
                return m_ArmorTable;
            }
        }
        public static void Initialize()
        {
            SkillInfo.Table[(int)SkillName.Stealth].Callback = new SkillUseCallback(OnUse);
        }

        public static int GetArmorRating(Mobile m)
        {
            if (!Core.AOS)
                return (int)m.ArmorRating;

            int ar = 0;

            for (int i = 0; i < m.Items.Count; i++)
            {
                BaseArmor armor = m.Items[i] as BaseArmor;

                if (armor == null)
                    continue;

                int materialType = (int)armor.MaterialType;
                int bodyPosition = (int)armor.BodyPosition;

                if (materialType >= m_ArmorTable.GetLength(0) || bodyPosition >= m_ArmorTable.GetLength(1))
                    continue;

                if (armor.ArmorAttributes.MageArmor == 0)
                    ar += m_ArmorTable[materialType, bodyPosition];
            }

            return ar;
        }

        public static TimeSpan OnUse(Mobile m)
        {
            if (!m.Hidden)
            {
                m.SendLocalizedMessage(502725); // You must hide first
            }
            else if (m.Skills[SkillName.Hiding].Base < HidingRequirement)
            {
                m.SendLocalizedMessage(502726); // You are not hidden well enough.  Become better at hiding.
                m.RevealingAction();
            }
            else if (!m.CanBeginAction(typeof(Stealth)))
            {
                m.SendLocalizedMessage(1063086); // You cannot use this skill right now.
                m.RevealingAction();
            }
            else
            {
                int armorRating = GetArmorRating(m);

                if (armorRating >= (Core.AOS ? 62 : 42)) //I have a hunch '42' was chosen cause someone's a fan of DNA
                {
                    m.SendLocalizedMessage(502727); // You could not hope to move quietly wearing this much armor.
                    m.RevealingAction();
                }
               
           
               
                else if (m.CheckSkill(SkillName.Stealth, -20.0 + (armorRating * 2), (Core.AOS ? 60.0 : 80.0) + (armorRating * 2)))
                {
                    int steps = (int)(m.Skills[SkillName.Stealth].Value / (Core.AOS ? 5.0 : 10.0));

                    if (steps < 1)
                        steps = 1;

                    m.AllowedStealthSteps = steps;

                    PlayerMobile pm = m as PlayerMobile; // IsStealthing should be moved to Server.Mobiles

                    if (pm != null)
                        pm.IsStealthing = true;

                    m.SendLocalizedMessage(502730); // You begin to move quietly.

                    return TimeSpan.FromSeconds(10.0);
                }
                else
                {
                    m.SendLocalizedMessage(502731); // You fail in your attempt to move unnoticed.
                    m.RevealingAction();
                }
            }

            return TimeSpan.FromSeconds(10.0);
        }
    }
}
 

Hank

Well-Known Member
Nov 14, 2013
950
152
Earth
Try testing as a player not a staff member. You can do this by using the StaffOrb that's included with servuo.

I just tested this as a player with a platechest on and this in the code:
C#:
/* Plate    */ { 200, 200, 200, 200, 200, 200, 200 },
Just as the code says here...
C#:
if (armorRating >= (Core.AOS ? 42 : 26)) //I have a hunch '42' was chosen cause someone's a fan of DNA
  {
  m.SendLocalizedMessage(502727); // You could not hope to move quietly wearing this much armor.
  m.RevealingAction();
  }
It sends the message: You could not hope to move quietly wearing this much armor. And makes me visible when I try to stealth.
 

Fisher

Well-Known Member
Dec 24, 2014
78
6
42
The Boondocks
dawnuo.net
Shard Name
DawnUO
Changing the values in the armor table does not change anything for me. I tried using the original file, adding the changes to the table, just in case I had fumbled up something in my past attempts at programming. No matter what value I put in the table, I only get the "You could not hope to move quietly wearing this much armor." message is when my ar is at, or above 42. Is this be because I have expansion set to none? The only other thing I have altered is the hiding requirement.

Here is my current stealth.cs
Code:
using System;
using Server.Items;
using Server.Mobiles;

namespace Server.SkillHandlers
{
    public class Stealth
    {
        private static readonly int[,] m_ArmorTable = new int[,]
        {
           //    Gorget    Gloves    Helmet    Arms    Legs    Chest    Shield
            /* Cloth    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Leather    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Studded    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Bone        */ { 999, 999, 999, 999, 999, 999, 999 },
            /* Spined    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Horned    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Barbed    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Ring        */ { 999, 999, 999, 999, 999, 999, 999 },
            /* Chain    */ { 999, 999, 999, 999, 999, 999, 999 },
            /* Plate    */ { 999, 999, 999, 999, 999, 999, 999 },
            /* Dragon    */ { 999, 999, 999, 999, 999, 999, 999 }
        };
        public static double HidingRequirement
        {
            get
            {
                return (Core.ML ? 30.0 : (Core.SE ? 50.0 : 50.0));
            }
        }
        public static int[,] ArmorTable
        {
            get
            {
                return m_ArmorTable;
            }
        }
        public static void Initialize()
        {
            SkillInfo.Table[(int)SkillName.Stealth].Callback = new SkillUseCallback(OnUse);
        }

        public static int GetArmorRating(Mobile m)
        {
            if (!Core.AOS)
                return (int)m.ArmorRating;

            int ar = 0;

            for (int i = 0; i < m.Items.Count; i++)
            {
                BaseArmor armor = m.Items[i] as BaseArmor;

                if (armor == null)
                    continue;

                int materialType = (int)armor.MaterialType;
                int bodyPosition = (int)armor.BodyPosition;

                if (materialType >= m_ArmorTable.GetLength(0) || bodyPosition >= m_ArmorTable.GetLength(1))
                    continue;

                if (armor.ArmorAttributes.MageArmor == 0)
                    ar += m_ArmorTable[materialType, bodyPosition];
            }

            return ar;
        }

        public static TimeSpan OnUse(Mobile m)
        {
            if (!m.Hidden)
            {
                m.SendLocalizedMessage(502725); // You must hide first
            }
            else if (m.Skills[SkillName.Hiding].Base < HidingRequirement)
            {
                m.SendLocalizedMessage(502726); // You are not hidden well enough.  Become better at hiding.
                m.RevealingAction();
            }
            else if (!m.CanBeginAction(typeof(Stealth)))
            {
                m.SendLocalizedMessage(1063086); // You cannot use this skill right now.
                m.RevealingAction();
            }
            else
            {
                int armorRating = GetArmorRating(m);

                if (armorRating >= (Core.AOS ? 42 : 26)) //I have a hunch '42' was chosen cause someone's a fan of DNA
                {
                    m.SendLocalizedMessage(502727); // You could not hope to move quietly wearing this much armor.
                    m.RevealingAction();
                }
                else if (m.CheckSkill(SkillName.Stealth, -20.0 + (armorRating * 2), (Core.AOS ? 60.0 : 80.0) + (armorRating * 2)))
                {
                    int steps = (int)(m.Skills[SkillName.Stealth].Value / (Core.AOS ? 5.0 : 10.0));

                    if (steps < 1)
                        steps = 1;

                    m.AllowedStealthSteps = steps;

                    PlayerMobile pm = m as PlayerMobile; // IsStealthing should be moved to Server.Mobiles

                    if (pm != null)
                        pm.IsStealthing = true;

                    m.SendLocalizedMessage(502730); // You begin to move quietly.

                    return TimeSpan.FromSeconds(10.0);
                }
                else
                {
                    m.SendLocalizedMessage(502731); // You fail in your attempt to move unnoticed.
                    m.RevealingAction();
                }
            }

            return TimeSpan.FromSeconds(10.0);
        }
    }
}
 

Hank

Well-Known Member
Nov 14, 2013
950
152
Earth
No matter what value I put in the table, I only get the "You could not hope to move quietly wearing this much armor." message is when my ar is at, or above 42. Is this be because I have expansion set to none?
If your expansion is set to none then the max ar for stealth is 26. Which this in it self seems incorrect based on t2a data of it being 18 but maybe someone could chime in on why its set at 26?
C#:
if (armorRating >= (Core.AOS ? 42 : 26))
This is how I read this line of code. If armorRating is greater then or equal to (is core.aos? if true 42 if false 26)

I want to make it so a player cannot stealth while wearing metal armor.
I am a bit confused I thought you wanted to make it so that "players can not stealth while wearing metal armour"? When you recieve the message "You could not hope..." does it still allow your character to stealth?
 

Fisher

Well-Known Member
Dec 24, 2014
78
6
42
The Boondocks
dawnuo.net
Shard Name
DawnUO
I wanted it so players could not stealth while wearing any metal armor. I butchered the file some more and this works. I now get the "you can not hope..." message when I have ANY piece of bone or metal or dragon equipped. Like naked with bone gloves. I did change the 26 to 42 on the line you mentioned to accommodate magic and material bonuses on the "soft" armor. Anyhow, if anyone else ever has the same desire, this is how I did it on a server with expansion set to none.
Code:
using System;
using Server.Items;
using Server.Mobiles;

namespace Server.SkillHandlers
{
    public class Stealth
    {
        private static readonly int[,] m_ArmorTable = new int[,]
        {
           //    Gorget    Gloves    Helmet    Arms    Legs    Chest    Shield
            /* Cloth    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Leather    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Studded    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Bone        */ { 99999, 99999, 99999, 99999, 99999, 99999, 99999 },
            /* Spined    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Horned    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Barbed    */ { 0, 0, 0, 0, 0, 0, 0 },
            /* Ring        */ { 99999, 99999, 99999, 99999, 99999, 99999, 99999 },
            /* Chain    */ { 99999, 99999, 99999, 99999, 99999, 99999, 9999 },
            /* Plate    */ { 99999, 99999, 99999, 99999, 99999, 99999, 99999 },
            /* Dragon    */ { 99999, 99999, 99999, 99999, 99999, 99999, 99999 }
        };
        public static double HidingRequirement
        {
            get
            {
                return (Core.ML ? 30.0 : (Core.SE ? 50.0 : 50.0));
            }
        }
        public static int[,] ArmorTable
        {
            get
            {
                return m_ArmorTable;
            }
        }
        public static void Initialize()
        {
            SkillInfo.Table[(int)SkillName.Stealth].Callback = new SkillUseCallback(OnUse);
        }

        public static int GetArmorRating(Mobile m)
        {
            //if (!Core.AOS)
               // return (int)m.ArmorRating;

            int ar = 0;

            for (int i = 0; i < m.Items.Count; i++)
            {
                BaseArmor armor = m.Items[i] as BaseArmor;

                if (armor == null)
                    continue;

                int materialType = (int)armor.MaterialType;
                int bodyPosition = (int)armor.BodyPosition;

                //if (materialType >= m_ArmorTable.GetLength(0) || bodyPosition >= m_ArmorTable.GetLength(1))
                  //  continue;

                //if (armor.ArmorAttributes.MageArmor == 0)
                    ar += m_ArmorTable[materialType, bodyPosition];
            }

            return ar;
        }

        public static TimeSpan OnUse(Mobile m)
        {
            if (!m.Hidden)
            {
                m.SendLocalizedMessage(502725); // You must hide first
            }
            else if (m.Skills[SkillName.Hiding].Base < HidingRequirement)
            {
                m.SendLocalizedMessage(502726); // You are not hidden well enough.  Become better at hiding.
                m.RevealingAction();
            }
            else if (!m.CanBeginAction(typeof(Stealth)))
            {
                m.SendLocalizedMessage(1063086); // You cannot use this skill right now.
                m.RevealingAction();
            }
            else
            {
                int armorRating = GetArmorRating(m);

                if (armorRating >= (Core.AOS ? 42 : 26)) //I have a hunch '42' was chosen cause someone's a fan of DNA
                {
                    m.SendLocalizedMessage(502727); // You could not hope to move quietly wearing this much armor.
                    m.RevealingAction();
                }
                else if (m.CheckSkill(SkillName.Stealth, -20.0 + (armorRating * 2), (Core.AOS ? 60.0 : 80.0) + (armorRating * 2)))
                {
                    int steps = (int)(m.Skills[SkillName.Stealth].Value / (Core.AOS ? 5.0 : 10.0));

                    if (steps < 1)
                        steps = 1;

                    m.AllowedStealthSteps = steps;

                    PlayerMobile pm = m as PlayerMobile; // IsStealthing should be moved to Server.Mobiles

                    if (pm != null)
                        pm.IsStealthing = true;

                    m.SendLocalizedMessage(502730); // You begin to move quietly.

                    return TimeSpan.FromSeconds(10.0);
                }
                else
                {
                    m.SendLocalizedMessage(502731); // You fail in your attempt to move unnoticed.
                    m.RevealingAction();
                }
            }

            return TimeSpan.FromSeconds(10.0);
        }
    }
}
The "99999" values are probably a severe overkill but I come from the school of "if it works dont fix it". I will post an update if there are any adverse side effects. errors, crashes, player revolts, priapism, narcolepsy, or dry eyes.
Thanks Hank for your patience!
 
Last edited:

Beefcake

Well-Known Member
Jul 30, 2015
61
3
30
you need to add a function for each and every piece of armor, that when this is worn and stealth is trying to be used it'll return. it honestly makes no sense to me why someone can't stealth wearing plategloves, or platelegs, so I wouldn't implement it like that
 

pall

Well-Known Member
Aug 20, 2014
205
6
30
Shard Name
Ultima Iberia / Renegados UO
i trying the same, and for me dont work the 9999 :S but with only 30 for studded this work :S

and another question, how i can do for reveal player when they do actions like talk or another? :S
 

Vorspire

Vita-Nex: Core
Admin
ServUO Developer
Jul 29, 2013
1,107
213
32
United Kingdom
core.vita-nex.com
Shard Name
Ultima Shards: Multiverse
Donate
Donate money to this user
Personally, I would have just made edits in PlayerMobile.OnMove;
PlayerMobile.cs#L4394

Pseudo-code;

C#:
					bool running = (d & Direction.Running) != 0;

					if (running)
					{
						if ((AllowedStealthSteps -= 2) <= 0)
						{
							RevealingAction();
						}
					}
					else if (AllowedStealthSteps-- <= 0)
					{
						Stealth.OnUse(this);
					}

					if( ChestArmor is BaseArmor && ((BaseArmor)ChestArmor).Material == ArmorMaterialType.Plate )
					{
						AllowedStealthSteps = 0;
						RevealingAction();
						SendMessage( "Your armor is too loud, it draws attention to your stealth attempt!" );
					}
 
  • Like
Reactions: pall