The spell enhance a weapon but it doesnt let me target other peoples weapons (on their paperdoll)

it says Thats is not Accesible.

it has something to do with item.cs in the core right?

is there an easy way to fix it? would it be better to target the player then check for weapon layer?

Thanks


Code:
using System;
using System.Collections;
using Server;
using Server.Spells;
using Server.Items;
using Server.Gumps;
using Server.Spells;
using Server.Targeting;
using Server.Network;
using Server.Regions;
using System.Collections.Generic;
using Server.Gumps;
using Server.Multis;
using Server.Mobiles;
using Server.Engines.XmlSpawner2;

namespace Server.ACC.CSS.Systems.Ranger
{
    public class AncientEnchantSpell : RangerSpell
    {
        private static SpellInfo m_Info = new SpellInfo(
                                                        "Enhance", "Enhance",
                                                        218,
                                                        9002
                                                        //Reagent.BlackPearl,
                                                       // Reagent.MandrakeRoot
                                                       );

        private int m_Hue;
        private string m_Name;

        public override SpellCircle Circle
        {
            get { return SpellCircle.First; }
        }
       // public override TimeSpan CastDelayBase { get { return TimeSpan.FromSeconds( 3.6 ); } }
        //public override bool BlocksMovement{ get{ return true; } }
        public override double CastDelay{ get{ return 1.0; } }
        public override double RequiredSkill{ get{ return 00.0; } }
        public override int RequiredMana{ get{ return 20; } }
        public override bool HasNoTarget { get { return true; } }
      
        public AncientEnchantSpell(Mobile caster, Item scroll)
            : base(caster, scroll, m_Info)
        {
        }
 
   public override bool CheckCast( )
        {
            {
        if(Caster.Region.Name == "Tr")
        {
                Caster.SendAsciiMessage("You cannot cast that there!");
                return false;
            }
            else
            {
                return base.CheckCast();
            }
        }
        }
      
        public override void OnCast()
        {
            Caster.Target = new InternalTarget( this );
        }


        public void Target(BaseWeapon weapon)
        {

            if (!Caster.CanSee(weapon))
            {
             //   Caster.SendMessage("No logras alcanzar ver eso"); // Target can not be seen.
              Caster.SendMessage("Target can not be seen."); // Target can not be seen.
            }
            else if (!Caster.CanBeginAction(typeof(AncientEnchantSpell)))
            {
              //  Caster.SendMessage("Ese arma ya esta encantada"); // This spell is already in effect.
                Caster.SendMessage("This spell is already in effect.");

            }


            else if (CheckSequence( ))
            {
                #region holder
                if ( weapon is BaseWeapon && weapon.RootParent is Mobile )
                    {
                        ////////
                    Mobile holder = (Mobile)weapon.RootParent;
                        /////
            Item unoseisd = Caster.Backpack.FindItemByType(typeof(obj6));
            Item unocerod = holder.Backpack.FindItemByType(typeof(obj0));
            Item unoseis = holder.Backpack.FindItemByType(typeof(obj6));
            Item unocero = Caster.Backpack.FindItemByType(typeof(obj0));
        if (unocero != null && unoseis != null)
                        {
                             Caster.SendMessage("You cannot enhance enemy weapons!."); // Target can not be seen.
                            //return;
                        }
                        if (unocerod != null && unoseisd != null)
                        {
                             Caster.SendMessage("You cannot enhance enemy weapons!.");
                            //return;
                        }
                        #endregion
                if (Caster.BeginAction(typeof(AncientEnchantSpell)))
                {
                    //if (this.Scroll != null)
                       // Scroll.Consume();
                    //weapon.Slayer2 = SlayerName.DaemonDismissal;
                    //weapon.Slayer = SlayerName.Silver;
                    //weapon.Slayer = SlayerName.DragonSlaying;
                    m_Name = weapon.Name;
                     m_Hue = weapon.Hue;
                  
                    weapon.Name = "" + m_Name + "[Enhanced]";
                    weapon.Hue = 2514;
                    weapon.MinDamage += 7;
                    weapon.Speed -=90;
                    //weapon.Attributes.AttackChance += 1000;

                    Caster.PlaySound(0x20C);
                    Caster.PlaySound(0x145);
                    Caster.FixedParticles(0x3779, 1, 30, 9964, 3, 3, EffectLayer.Waist);

                    IEntity from = new Entity(Serial.Zero, new Point3D(Caster.X, Caster.Y, Caster.Z), Caster.Map);
                    IEntity to = new Entity(Serial.Zero, new Point3D(Caster.X, Caster.Y, Caster.Z + 50), Caster.Map);
                    Effects.SendMovingParticles(from, to, 0x13B1, 1, 0, false, false, 33, 3, 9501, 1, 0, EffectLayer.Head, 0x100);
                    StopTimer(Caster);

                    Timer t = new InternalTimer(Caster, weapon, m_Hue, m_Name);

                    m_Timers[Caster] = t;

                    t.Start();
                }
                else if (!Caster.CanBeginAction(typeof(AncientEnchantSpell)))
                {
                    DoFizzle();
              
                    Caster.SendMessage ("That weapon is already enhanced");
                }
            }
                    }
            FinishSequence();
      
        }
      
      

        private class InternalTarget : Target
        {
            private AncientEnchantSpell m_Owner;

            public InternalTarget(AncientEnchantSpell owner)
                : base(12, false, TargetFlags.Beneficial)
            {
                m_Owner = owner;
            }

            protected override void OnTarget(Mobile from, object o)
            {
                if (o is BaseWeapon)
                {
                    m_Owner.Target((BaseWeapon)o);
                }
                else
                {
                  
                    from.SendMessage("Incorrect target");
                }
            }

            protected override void OnTargetFinish(Mobile from)
            {
                m_Owner.FinishSequence();
            }
        }
        private static Hashtable m_Timers = new Hashtable();

        public static bool StopTimer(Mobile m)
        {
            Timer t = (Timer)m_Timers[m];

            if (t != null)
            {
                t.Stop();
                m_Timers.Remove(m);
            }

            return (t != null);
        }

        private class InternalTimer : Timer
        {
            private Mobile m_Owner;
            private BaseWeapon m_Weapon;
            private int m_weaponhue;
            private string m_Name;

            public InternalTimer(Mobile owner, BaseWeapon weapon, int m_Hue, string m_WeaponName)
                : base(TimeSpan.FromSeconds(0))
            {
                m_Owner = owner;
                m_Weapon = weapon;
                m_weaponhue = m_Hue;
                m_Name = m_WeaponName;

                int val = (int)owner.Skills[SkillName.Magery].Value;

                if (val > 100)
                    val = 100;

                Delay = TimeSpan.FromSeconds(val);
                Priority = TimerPriority.TwoFiftyMS;
            }

            protected override void OnTick()
            {
                if (!m_Owner.CanBeginAction(typeof(AncientEnchantSpell)))
                {
                    m_Weapon.Hue = m_weaponhue;
                  
                    m_Weapon.Name = m_Name;
                    //m_weapon.Slayer2 -= SlayerName.DaemonDismissal;
                    //m_Weapon.Slayer2 = ;
                    //m_Weapon.Slayer = ;
                    m_Weapon.MinDamage -= 7;
                    m_Weapon.Speed +=90;
                  //  m_Weapon.Attributes.AttackChance -= 1000;
                    m_Owner.EndAction(typeof(AncientEnchantSpell));
                }
            }
        }
    }
}
 
No, but it's an example of how to find the weapon on a player. So all you need to do it tie it in with targeting a mobile
 
Back