1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Use Best Skill Deed Issues

Discussion in 'Script Support' started by Redsnow, Feb 16, 2014.

  1. Redsnow
    Offline

    Redsnow New Member

    Joined:
    Dec 30, 2013
    Messages:
    14
    Likes Received:
    1
    Publish Number:
    1
    Having a problem a with 2 lines below:

    Code (C#):
    1. Errors:
    2. + Customs/2-15-14/UseBest SkillDeed.cs:
    3.   CS0103: Line 28: The name 'Attributes' does not exist in the current context
    4.   CS0103: Line 36: The name 'Attributes' does not exist in the current context
    5.  

    Code (C#):
    1. using System;
    2. using Server.Network;
    3. using Server.Prompts;
    4. using Server.Items;
    5. using Server.Targeting;
    6.  
    7. namespace Server.Items
    8. {
    9.     public class UseBestSkillTarget : Target // Create our targeting class (which we derive from the base target class)
    10.     {
    11.         private UseBestSkillDeed m_Deed;
    12.  
    13.         public UseBestSkillTarget(UseBestSkillDeed deed)
    14.             : base(1, false, TargetFlags.None)
    15.         {
    16.             m_Deed = deed;
    17.         }
    18.  
    19.         protected override void OnTarget(Mobile from, object target) // Override the protected OnTarget() for our feature
    20.         {
    21.             if (m_Deed.Deleted || m_Deed.RootParent != from)
    22.                 return;
    23.  
    24.             if (target is Item)
    25.             {
    26.                 Item item = (Item)target;
    27.  
    28.                 if ((BaseWeapon)target == WeaponAttributes.UseBestSkill += 1)////PROBLEM
    29.                 {
    30.                     from.SendMessage("Use Best Weapon can not be added to that Item");
    31.                 }
    32.  
    33.             }
    34.             else if (target is BaseWeapon)
    35.             {
    36.                 target == WeaponAttributes.UseBestSkill = 1; //////PROBLEM
    37.  
    38.                 from.SendMessage("you use the deed on that weapon");
    39.  
    40.                 m_Deed.Delete(); // Delete the deed
    41.             }
    42.             else
    43.                 from.SendMessage("Use Best Weapon can not be added to that Item");
    44.         }
    45.     }
    46.  
    47.     public class UseBestSkillDeed : Item
    48.     {
    49.         public override string DefaultName
    50.         {
    51.             get { return "an use best skill deed"; }
    52.         }
    53.  
    54.         [Constructable]
    55.         public UseBestSkillDeed()
    56.             : base(0x14F0)
    57.         {
    58.             Weight = 1.0;
    59.             LootType = LootType.Blessed;
    60.         }
    61.  
    62.         public UseBestSkillDeed(Serial serial)
    63.             : base(serial)
    64.         {
    65.         }
    66.  
    67.         public override void Serialize(GenericWriter writer)
    68.         {
    69.             base.Serialize(writer);
    70.  
    71.             writer.Write((int)0); // version
    72.         }
    73.  
    74.         public override void Deserialize(GenericReader reader)
    75.         {
    76.             base.Deserialize(reader);
    77.             LootType = LootType.Blessed;
    78.  
    79.             int version = reader.ReadInt();
    80.         }
    81.  
    82.         public override bool DisplayLootType { get { return false; } }
    83.  
    84.         public override void OnDoubleClick(Mobile from) // Override double click of the deed to call our target
    85.         {
    86.             if (!IsChildOf(from.Backpack)) // Make sure its in their pack
    87.             {
    88.                 from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
    89.             }
    90.             else
    91.             {
    92.                 from.SendMessage("Which item do you wish to put Best Skill on?");
    93.  
    94.                 from.Target = new UseBestSkillTarget(this); // Call our target
    95.             }
    96.         }
    97.     }
    98. }


    Any Suggestions on how I can fix this? or write it better?
     
  2. dmurphy
    Offline

    Admin ServUO Developer

    Joined:
    Feb 10, 2014
    Messages:
    1,009
    Likes Received:
    191
    You have a few problems in that script.

    Check out this one I just made and compare it with yours.

    I f you're not using vitanexcore then remove .WrapUOHtmlColor(Color.SkyBlue) at line 68

    Code (C#):
    1.  
    2. using System;
    3. using System.Drawing;
    4. using Server.Targeting;
    5.  
    6. namespace Server.Items
    7. {
    8.     public class UseBestSkillTarget : Target
    9.     {
    10.         private readonly UseBestSkillDeed _mDeed;
    11.  
    12.         public UseBestSkillTarget(UseBestSkillDeed deed)
    13.             : base(1, false, TargetFlags.None)
    14.         {
    15.             _mDeed = deed;
    16.         }
    17.  
    18.         protected override void OnTarget(Mobile from, object target)
    19.         {
    20.             var weapon = target as BaseWeapon;
    21.             if (weapon == null)
    22.             {
    23.                 @from.SendMessage("You cannot put Use Best Skill on that");
    24.             }
    25.             else
    26.             {
    27.                 var item = (Item)target;
    28.  
    29.                 if (((BaseWeapon)item).WeaponAttributes.UseBestSkill == 1)
    30.                 {
    31.                     @from.SendMessage("That already has Use Best Skill!");
    32.                 }
    33.                 else
    34.                 {
    35.                     if (item.RootParent != @from)
    36.                     {
    37.                         @from.SendMessage("You cannot put Use Best Skill on that there!");
    38.                     }
    39.                     else
    40.                     {
    41.                         ((BaseWeapon)item).WeaponAttributes.UseBestSkill = 1;
    42.                         @from.SendMessage("You magically add Use Best Skill to your weapon....");
    43.  
    44.                         _mDeed.Delete();
    45.                     }
    46.                 }
    47.             }
    48.         }
    49.     }
    50.  
    51.     public sealed class UseBestSkillDeed : Item
    52.     {
    53.         [Constructable]
    54.         public UseBestSkillDeed()
    55.             : base(0x14F0)
    56.         {
    57.             Weight = 1.0;
    58.             Name = "a Use Best Skill deed";
    59.             LootType = LootType.Blessed;
    60.             Hue = 0x492;
    61.         }
    62.  
    63.         public UseBestSkillDeed(Serial serial)
    64.             : base(serial)
    65.         {
    66.         }
    67.         public override void GetProperties(ObjectPropertyList list)
    68.         {
    69.             var add = String.Format("Makes your weapon use your best combat skill".WrapUOHtmlColor(Color.SkyBlue));
    70.  
    71.             base.GetProperties(list);
    72.             list.Add(add);
    73.         }
    74.  
    75.         public override void Serialize(GenericWriter writer)
    76.         {
    77.             base.Serialize(writer);
    78.  
    79.             writer.Write(0); // version
    80.         }
    81.  
    82.         public override void Deserialize(GenericReader reader)
    83.         {
    84.             base.Deserialize(reader);
    85.             LootType = LootType.Blessed;
    86.  
    87.             reader.ReadInt();
    88.         }
    89.  
    90.         public override bool DisplayLootType { get { return false; } }
    91.  
    92.         public override void OnDoubleClick(Mobile from)
    93.         {
    94.             if (!IsChildOf(from.Backpack))
    95.             {
    96.                 from.SendLocalizedMessage(1042001);
    97.             }
    98.             else
    99.             {
    100.                 from.SendMessage("What item would you like to add Use Best Skill to?");
    101.                 from.Target = new UseBestSkillTarget(this);
    102.             }
    103.         }
    104.     }
    105. }
    106.  
    107.  
     
    #2 dmurphy, Feb 17, 2014
    Last edited: Feb 17, 2014
    • Like Like x 1
  3. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    282
    Likes Received:
    32
    Code (C#):
    1. if ((BaseWeapon)target == WeaponAttributes.UseBestSkill += 1)////PROBLEM
    Couple things wrong with this statement. First it's trying to say 'If BaseWeapon equals WeaponAttributes.UseBestSkill' which aren't two comparable types. Second problem is the += 1 assignment at the end. That's going to keep adding 1 to it everytime it checks instead of checking if it is 1. dmurphys code above has the correct answer for you which should be.
    Code (C#):
    1. if (((BaseWeapon)target).WeaponAttributes.UseBestSkill == 1)
    One other thing you are missing is first checking the item is a BaseWeapon first because if you use that code on say Armor the server will crash when it tries to do the BaseWeapon cast. You can use something simple like this or dmurphy code has a check as well that will work.
    Code (C#):
    1. if (target is BaseWeapon)

    You should be able to fix the second problem you have the same way.
     
    • Like Like x 1
  4. Redsnow
    Offline

    Redsnow New Member

    Joined:
    Dec 30, 2013
    Messages:
    14
    Likes Received:
    1
    Thanks both of you guys for the help!
     
Similar Threads: Best Skill
Forum Title Date
Custom Releases Use Best Skill Deed Feb 18, 2014
3rd Party Discussions Best map making software for ToL Aug 28, 2017
3rd Party Discussions Best way to use Version Control with a UO Shard? Feb 20, 2017
Support What is the best way to add in the advanced vendor to use different currency? Jan 19, 2017
Archived Bug Reports Bestial and Virtuso armor is scripted but needs to be added to Cleean up brit Jan 14, 2017
Windows Support Best way to bypass ServerList >>> services.servuo.com May 10, 2016
Script Support Best vote stone? Feb 25, 2016