magic resist won't gain at 0.0, will at 0.1+
Is there a way to fix it so it will gain at 0.0?
or.. how do I add .1 resist to the custom skills list? I added 1 magic resist to the warrior, mage, and crafter pre-made templates in CharacterCreation.cs
example:
case 1: // Warrior
Code:
				{
					skills = new SkillNameValue[]
						{
							new SkillNameValue( SkillName.Anatomy, 30 ),
							new SkillNameValue( SkillName.Healing, 45 ),
							new SkillNameValue( SkillName.Swords, 35 ),
							new SkillNameValue( SkillName.Tactics, 50 ),
							new SkillNameValue( SkillName.MagicResist, 1 )
						};

					break;

but I cannot figure out how to add that to "advanced" (custom skill pick) creation - looks like the code is here:
the commented out part at the bottom is a few of what I tried-but did not work. Thanks!

Code:
private static bool ValidSkills( SkillNameValue[] skills )
		{
			int total = 0;

			for ( int i = 0; i < skills.Length; ++i )
			{
				if ( skills.Value < 0 || skills.Value > 50 )
					return false;

				total += skills.Value;

				for ( int j = i + 1; j < skills.Length; ++j )
				{
					if ( skills[j].Value > 0 && skills[j].Name == skills.Name )
						return false;
				}
			}

			return ( total == 100 || total == 120 ); //return ( total == 100 || total == 120 );
			
			/*if (SkillName.MagicResist <= 0)
				{
					skills = new SkillNameValue[]	
						{
							new SkillNameValue( SkillName.Tactics, 50 ),
							new SkillNameValue( SkillName.MagicResist, 1 )
						};
				}*/		
			//if (SkillName.MagicResist == 0)
				//new SkillNameValue( SkillName.MagicResist, 1 );
		}
 
I edited your code. Use the "+" symbol on the toolbar and paste your code inside the code box, or just add [ code ] tags without spaces in order to show your code in a well-formatted way.
 
How about this:

Code:
private static bool ValidSkills( SkillNameValue[] skills )
        {
            int total = 0;
            for ( int i = 0; i < skills.Length; ++i )
            {
                if ( skills.Value < 0 || skills.Value > 50 )
                    return false;
                total += skills.Value;
                for ( int j = i + 1; j < skills.Length; ++j )
                {
                    if ( skills[j].Value > 0 && skills[j].Name == skills.Name )
                        return false;
                }
            }
            if ( skills[SkillName.MagicResist].Value < 1)  skills[SkillName.MagicResist].Value = 1;
            return ( total == 100 || total == 120 );

You see, you need to put your update to Resist before the return statement.
 
Wouldn't is be OK to just buy the skill up to 30.0 from an NPC without having to jump through hoops?

The skill validation is there to prevent spoofing of character creation skill values.
 
How about this:

Code:
private static bool ValidSkills( SkillNameValue[] skills )
        {
            int total = 0;
            for ( int i = 0; i < skills.Length; ++i )
            {
                if ( skills.Value < 0 || skills.Value > 50 )
                    return false;
                total += skills.Value;
                for ( int j = i + 1; j < skills.Length; ++j )
                {
                    if ( skills[j].Value > 0 && skills[j].Name == skills.Name )
                        return false;
                }
            }
            if ( skills[SkillName.MagicResist].Value < 1)  skills[SkillName.MagicResist].Value = 1;
            return ( total == 100 || total == 120 );

You see, you need to put your update to Resist before the return statement.

Code:
Warnings:
+ Spells/Base/Spell.cs:
    CS0162: Line 240: Unreachable code detected
+ Misc/Assistants.cs:
    CS0162: Line 158: Unreachable code detected
Errors:
+ Misc/CharacterCreation.cs:
    CS0266: Line 966: Cannot implicitly convert type 'Server.SkillName' to 'int'. An explicit conversion exists (are you missing a cast?)
    CS0266: Line 966: Cannot implicitly convert type 'Server.SkillName' to 'int'. An explicit conversion exists (are you missing a cast?)
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
Okay thanks (tried code box this time).
Ah shoots, before the return, okay thank you.
When I put it before the return, it gave me this error.. (line 966 is "if( skills[SkillName.MagicResist].Value<1) skills[SkillName.MagicResist].Value=1;")
[doublepost=1525642394][/doublepost]
Wouldn't is be OK to just buy the skill up to 30.0 from an NPC without having to jump through hoops?

The skill validation is there to prevent spoofing of character creation skill values.
Preventing skill spoofing is obviously important, and I did not realize that's what that was doing-but one skill point should hopefully still keep that in check.

Yes, you can just buy the skill for 1 gold to .01 or however much it is to 30, but I'd rather give them 1 skill point, then making people (when they finally realize its not gaining) go buy the skill some before they can gain anything in it.
 
Just cast it Explicitly then:

(int)SkillName.MagicResist

So, it would be:

skills[ (int) SkillName.MagicResist ]
So, I think I did it like you said.. "if ( skills[ (int) SkillName.MagicResist ].Value < 1) skills[ (int) SkillName.MagicResist ].Value = 1;"
Code:
private static bool ValidSkills( SkillNameValue[] skills )
        {
            int total = 0;

            for ( int i = 0; i < skills.Length; ++i )
            {
                if ( skills[i].Value < 0 || skills[i].Value > 50 )
                    return false;

                total += skills[i].Value;

                for ( int j = i + 1; j < skills.Length; ++j )
                {
                    if ( skills[j].Value > 0 && skills[j].Name == skills[i].Name )
                        return false;
                }
            }
       
            if ( skills[ (int) SkillName.MagicResist ].Value < 1)  skills[ (int) SkillName.MagicResist ].Value = 1;
       
            return ( total == 100 || total == 120 ); //return ( total == 100 || total == 120 );
        }
It almost seems to work, but says..
Code:
Scripts: Compiling C# scripts...failed (1 errors, 2 warnings)
Warnings:
+ Spells/Base/Spell.cs:
    CS0162: Line 240: Unreachable code detected
+ Misc/Assistants.cs:
    CS0162: Line 158: Unreachable code detected
Errors:
+ Misc/CharacterCreation.cs:
    CS0200: Line 968: Property or indexer 'Server.SkillNameValue.Value' cannot be assigned to -- it is read only
Did I do it wrong? Or is it not possible with -- being read only? Or..?
Code:
if ( skills[ (int) SkillName.MagicResist ].Value < 1)  new SkillNameValue( SkillName.MagicResist, 1 );
this last code ran without errors, however when I make a character with "advanced" skills chosen.. the client hangs and it restarts the server. (I can log in, or create new characters without advanced). Maybe if you are advanced enough to make own skills, u can buy resist if you don't choose to start with it.. :/
 
Last edited:
You know, I was so distracted trying to "fix code" I overlooked that we are doing this in the wrong spot. We don't even have access to the player in this method. If I were you I would remove all the code you added in this section, and do something like this. Below the part where it goes through the professions - switch(prof) - after that whole section, change the loop that follows it like this:

Code:
            for (int i = 0; i < skills.Length; ++i)
            {
                SkillNameValue snv = skills[i];

                if (snv.Value > 0 && (snv.Name != SkillName.Stealth || prof == 7) && snv.Name != SkillName.RemoveTrap && snv.Name != SkillName.Spellweaving)
                {
                    Skill skill = m.Skills[snv.Name];

                    if (skill != null)
                    {
                        skill.BaseFixedPoint = snv.Value * 10;
                      
                        if ( addSkillItems )
                            AddSkillItems(snv.Name, m);
                    }
                }
              
                // Here we check for Magic Resist of 0
                if (snv.Name == SkillName.MagicResist && snv.Value <= 0)
                {
                    Skill skill = m.Skills[snv.Name];
                  
                    if (skill != null)
                    {
                        skill.BaseFixedPoint = 1;
                    }
                }
            }

In my CharacterCreation.cs this is around line 650.
 
Code:
using Server;

public static class SkillFix
{
	public static void Initialize()
	{
		EventSink.CharacterCreated += OnCreated;
	}

	private static void OnCreated(CharacterCreatedEventArgs e)
	{
		if (e.Mobile.Skills.MagicResist.Value < 0.1)
			e.Mobile.Skills.MagicResist.Base = 0.1;
	}
}

Would still be better to fix the actual cause of the issue, whatever that may be...
 
Code:
using Server;

public static class SkillFix
{
	public static void Initialize()
	{
		EventSink.CharacterCreated += OnCreated;
	}

	private static void OnCreated(CharacterCreatedEventArgs e)
	{
		if (e.Mobile.Skills.MagicResist.Value < 0.1)
			e.Mobile.Skills.MagicResist.Base = 0.1;
	}
}

Would still be better to fix the actual cause of the issue, whatever that may be...
Thanks for keeping at it guys! I started to lose hope.
I tried Lokai's fix first, (no error messages) but it didn't work.

-side note, I did notice that Meditation is starting between 1 and 1.5 base skill -odd. idk why.

I then tried adding Voxpire's code (excluding the first line of "using server;" (as CharacterCreation.cs already has that..) -I wasn't sure where to add it. I put it just after the start "public static void Initialize()" and it worked!! new char started with .1 magicresist ")

Thank you Voxpire and Lokai!!

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

namespace Server.Misc
{
    public class CharacterCreation
    {
        public static void Initialize()
        {
            // Register our event handler
            EventSink.CharacterCreated += new CharacterCreatedEventHandler( EventSink_CharacterCreated );
        }
      
        public static class SkillFix
{
    public static void Initialize()
    {
        EventSink.CharacterCreated += OnCreated;
    }
    private static void OnCreated(CharacterCreatedEventArgs e)
    {
        if (e.Mobile.Skills.MagicResist.Value < 0.1)
            e.Mobile.Skills.MagicResist.Base = 0.1;
    }
}
      
        private static void AddBackpack( Mobile m )
        {.....
 
I had a suspicion that was the case. Should I make it a new one? or fine to leave as is yeah? thank you.
 
Back