Ultima Expansion
Age Of Shadows
I am triyng to change some mage spell with other, but i get this error

Code:
 Errors:
 + Spells/Third/Telekinesis.cs:
    CS0103: Line 47: The name 'm_Table' does not exist in the current context
    CS0103: Line 54: The name 'm_Table' does not exist in the current context
    CS0103: Line 62: The name 'm_Table' does not exist in the current context
    CS0103: Line 64: The name 'm_Table' does not exist in the current context
    CS0103: Line 122: The name 'm_Table' does not exist in the current context
 + Spells/Second/Harm.cs:
    CS0103: Line 31: The name 'm_Table' does not exist in the current context
    CS0103: Line 36: The name 'm_Table' does not exist in the current context
    CS0103: Line 46: The name 'm_Table' does not exist in the current context
    CS0103: Line 97: The name 'm_Table' does not exist in the current context
    CS0103: Line 102: The name 'm_Table' does not exist in the current context
    CS0103: Line 184: The name 'm_Table' does not exist in the current context
    CS0103: Line 213: The name 'm_Table' does not exist in the current context
Scripts: One or more scripts failed to compile or no script files were found.

these are the code of the spells
Code:
 using System;
using Server.Items;
using Server.Targeting;
using System.Collections.Generic;
using Server.Mobiles;
using Server.Spells.SkillMasteries;

namespace Server.Spells.Third
{
    public class TelekinesisSpell : MagerySpell
    {
        private static readonly SpellInfo m_Info = new SpellInfo(
            "Telekinesis", "Ort Por Ylem",
            203,
            9031,
            Reagent.Bloodmoss,
            Reagent.MandrakeRoot);
        public TelekinesisSpell(Mobile caster, Item scroll)
            : base(caster, scroll, m_Info)
        {
        }

        public override SpellCircle Circle
        {
            get
            {
                return SpellCircle.Third;
            }
        }
                public override TimeSpan CastDelayBase
        {
            get
            {
                return TimeSpan.FromSeconds(1.0);
            }
        }

        /*
        * The naming here was confusing. Its a 1-off effect spell.
        * So, we dont actually "checkeffect"; we endeffect with bool
        * return to determine external behaviors.
        *
        * -refactored.
        */
        public static bool UnderEffects(Mobile m)
        {
            return m_Table.ContainsKey(m);
        }

        public static double GetResistMalus(Mobile m)
        {
            if (UnderEffects(m))
            {
                return m_Table[m];
            }

            return 0;
        }

        public static bool TryEndEffect(Mobile m)
        {
            if (m_Table.ContainsKey(m))
            {
                m_Table.Remove(m);
                BuffInfo.RemoveBuff(m, BuffIcon.EvilOmen);

                return true;
            }

            return false;
        }

        public override void OnCast()
        {
            Caster.Target = new InternalTarget(this);
        }

        public void Target(Mobile m)
        {
            if (!(m is BaseCreature || m is PlayerMobile))
            {
                Caster.SendLocalizedMessage(1060508); // You can't curse that.
            }
            else if (UnderEffects(m))
            {
                DoFizzle();
            }
            else if (CheckHSequence(m))
            {
                SpellHelper.Turn(Caster, m);

                ApplyEffects(m);
                ConduitSpell.CheckAffected(Caster, m, ApplyEffects);
            }

            FinishSequence();
        }

        public void ApplyEffects(Mobile m, double strength = 1.0)
        {
            /* Curses the target so that the next harmful event that affects them is magnified.
                * Damage to the target's hit points is increased 25%,
                * the poison level of the attack will be 1 higher
                * and the Resist Magic skill of the target will be fixed on 50.
                *
                * The effect lasts for one harmful event only.
                */

            if (m.Spell != null)
                m.Spell.OnCasterHurt();

            m.PlaySound(0xFC);
            m.FixedParticles(0x3728, 1, 13, 9912, 1150, 7, EffectLayer.Head);
            m.FixedParticles(0x3779, 1, 15, 9502, 67, 7, EffectLayer.Head);

            HarmfulSpell(m);
            double resistMalas = 0;
            
            if(m.Skills[SkillName.MagicResist].Base > 50.0)
                resistMalas = m.Skills[SkillName.MagicResist].Base / 2.0;
            
            m_Table[m] = resistMalas;

            TimeSpan duration = TimeSpan.FromSeconds(((Caster.Skills[SkillName.Magery].Value / 12) + 1.0) * strength);

            Timer.DelayCall(duration, new TimerStateCallback(EffectExpire_Callback), m);

            BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.EvilOmen, 1075647, 1075648, duration, m));
        }

        private static void EffectExpire_Callback(object state)
        {
            TryEndEffect((Mobile)state);
        }

        private class InternalTarget : Target
        {
            private readonly TelekinesisSpell m_Owner;

            public InternalTarget(TelekinesisSpell owner)
                : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful)
            {
                m_Owner = owner;
            }

            protected override void OnTarget(Mobile from, object o)
            {
                if (o is Mobile)
                    m_Owner.Target((Mobile)o);
                else
                    from.SendLocalizedMessage(1060508); // You can't curse that.
            }

            protected override void OnTargetFinish(Mobile from)
            {
                m_Owner.FinishSequence();
            }
        }
    }
}

and this harm

Code:
using System;
using System.Collections;
using Server.Targeting;
using Server.Spells.SkillMasteries;

namespace Server.Spells.Second
{
    public class HarmSpell : MagerySpell
    {
        private static readonly SpellInfo m_Info = new SpellInfo(
            "Harm", "An Mani",
            212,
            Core.AOS ? 9001 : 9041,
            Reagent.Nightshade,
            Reagent.SpidersSilk);
        public HarmSpell(Mobile caster, Item scroll)
            : base(caster, scroll, m_Info)
        {
        }

        public override SpellCircle Circle
        {
            get
            {
                return SpellCircle.Second;
            }
        }

public static bool UnderEffects(Mobile m)
        {
            return m_Table.ContainsKey(m);
        }

        public static bool RemoveCurse(Mobile m)
        {
            Timer t = (Timer)m_Table[m];

            if (t == null)
                return false;

            t.Stop();
            m.SendLocalizedMessage(1061687); // You are no more under harmfull effects.

            BuffInfo.RemoveBuff(m, BuffIcon.Strangle);

            m_Table.Remove(m);
            return true;
        }

        public override void OnCast()
        {
            this.Caster.Target = new InternalTarget(this);
        }

        public void Target(Mobile m)
        {
            if (this.CheckHSequence(m))
            {
                SpellHelper.Turn(this.Caster, m);

                ApplyEffects(m);
                ConduitSpell.CheckAffected(Caster, m, ApplyEffects);
            }

            FinishSequence();
        }

        public void ApplyEffects(Mobile m, double strength = 1.0)
        {
            //SpellHelper.CheckReflect( (int)this.Circle, Caster, ref m );	//Irrelevent after AoS

            /* Temporarily chokes off the air suply of the target with poisonous fumes.
             * The target is inflicted with poison damage over time.
             * The amount of damage dealt each "hit" is based off of the caster's Spirit Speak skill and the Target's current Stamina.
             * The less Stamina the target has, the more damage is done by Strangle.
             * Duration of the effect is Spirit Speak skill level / 10 rounds, with a minimum number of 4 rounds.
             * The first round of damage is dealt after 5 seconds, and every next round after that comes 1 second sooner than the one before, until there is only 1 second between rounds.
             * The base damage of the effect lies between (Spirit Speak skill level / 10) - 2 and (Spirit Speak skill level / 10) + 1.
             * Base damage is multiplied by the following formula: (3 - (target's current Stamina / target's maximum Stamina) * 2).
             * Example:
             * For a target at full Stamina the damage multiplier is 1,
             * for a target at 50% Stamina the damage multiplier is 2 and
             * for a target at 20% Stamina the damage multiplier is 2.6
             */

            if (m.Spell != null)
                m.Spell.OnCasterHurt();

            m.PlaySound(0x22F);
            m.FixedParticles(0x36CB, 1, 9, 9911, 67, 5, EffectLayer.Head);
            m.FixedParticles(0x374A, 1, 17, 9502, 1108, 4, (EffectLayer)255);

            if (Server.Spells.Mysticism.StoneFormSpell.CheckImmunity(m))
            {
                Caster.SendLocalizedMessage(1095250); // Your target resists harm.
            }
            else if (!m_Table.ContainsKey(m))
            {
                Timer t = new InternalTimer(m, Caster, strength);
                t.Start();

                m_Table[m] = t;

                //Calculations for the buff bar
                double spiritlevel = Caster.Skills[SkillName.Magery].Value / 10;
                if (spiritlevel < 4)
                    spiritlevel = 4;
                int d_MinDamage = 2;
                int d_MaxDamage = 4;
                string args = String.Format("{0}\t{1}", d_MinDamage, d_MaxDamage);

                int i_Count = (int)spiritlevel;
                int i_MaxCount = i_Count;
                int i_HitDelay = 5;
                int i_Length = i_HitDelay;

                while (i_Count > 1)
                {
                    --i_Count;
                    if (i_HitDelay > 1)
                    {
                        if (i_MaxCount < 5)
                        {
                            --i_HitDelay;
                        }
                        else
                        {
                            int delay = (int)(Math.Ceiling((1.0 + (5 * i_Count)) / i_MaxCount));

                            if (delay <= 5)
                                i_HitDelay = delay;
                            else
                                i_HitDelay = 5;
                        }
                    }
                    i_Length += i_HitDelay;
                }

                TimeSpan t_Duration = TimeSpan.FromSeconds(i_Length * strength);
                BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Strangle, 1075794, 1075795, t_Duration, m, args.ToString()));
            }

            HarmfulSpell(m);
        }

        private class InternalTimer : Timer
        {
            private Mobile m_Target, m_From;
            private double m_MinBaseDamage, m_MaxBaseDamage;

            private DateTime m_NextHit;
            private int m_HitDelay;

            private int m_Count, m_MaxCount;

            public InternalTimer(Mobile target, Mobile from, double strength)
                : base(TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(0.1))
            {
                Priority = TimerPriority.FiftyMS;

                m_Target = target;
                m_From = from;

                double spiritLevel = from.Skills[SkillName.SpiritSpeak].Value / 10;

                m_MinBaseDamage = 2;
                m_MaxBaseDamage = 4;

                m_HitDelay = 5;
                m_NextHit = DateTime.UtcNow + TimeSpan.FromSeconds(m_HitDelay);

                m_Count = (int)spiritLevel;

                if (m_Count < 4)
                    m_Count = 4;

                m_MaxCount = m_Count;
            }

            protected override void OnTick()
            {
                if (!m_Target.Alive)
                {
                    m_Table.Remove(m_Target);
                    Stop();
                }

                if (!m_Target.Alive || DateTime.UtcNow < m_NextHit)
                    return;

                --m_Count;

                if (m_HitDelay > 1)
                {
                    if (m_MaxCount < 5)
                    {
                        --m_HitDelay;
                    }
                    else
                    {
                        int delay = (int)(Math.Ceiling((1.0 + (5 * m_Count)) / m_MaxCount));

                        if (delay <= 5)
                            m_HitDelay = delay;
                        else
                            m_HitDelay = 5;
                    }
                }

                if (m_Count == 0)
                {
                    m_Target.SendLocalizedMessage(1061687); // Harm effects finished.
                    m_Table.Remove(m_Target);
                    Stop();
                }
                else
                {
                    m_NextHit = DateTime.UtcNow + TimeSpan.FromSeconds(m_HitDelay);

                    double damage = m_MinBaseDamage + (Utility.RandomDouble() * (m_MaxBaseDamage - m_MinBaseDamage));

                    damage *= (3 - (((double)m_Target.Stam / m_Target.StamMax) * 2));

                    if (damage < 1)
                        damage = 1;

                    if (!m_Target.Player)
                        damage *= 1.30;

                    AOS.Damage(m_Target, m_From, (int)damage, 0, 0, 0, 100, 0);

                    if (0.60 <= Utility.RandomDouble()) // OSI: randomly revealed between first and third damage tick, guessing 60% chance
                        m_Target.RevealingAction();
                }
            }
        }

        private class InternalTarget : Target
        {
            private readonly HarmSpell m_Owner;
            public InternalTarget(HarmSpell owner)
                : base(Core.ML ? 10 : 12, false, TargetFlags.Harmful)
            {
                this.m_Owner = owner;
            }

            protected override void OnTarget(Mobile from, object o)
            {
                if (o is Mobile)
                    this.m_Owner.Target((Mobile)o);
            }

            protected override void OnTargetFinish(Mobile from)
            {
                this.m_Owner.FinishSequence();
            }
        }
    }
}

I would like to change more spells in the future, someone can explain me what i'm missing?
Thank yoy
 
WELL! Finally after 2 days I've found the issue :D

over the line
public HarmSpell(Mobile caster, Item scroll)
: base(caster, scroll, m_Info)

I had to definite the m_table
"private static readonly Hashtable m_Table = new Hashtable();"

and call the space
"using Server.Spells.Necromancy;"
where the original spell was taken from.

So, this is my harm spell!
a small delayed damages in a number of ticks based on inscription.
 

Attachments

  • Harm.cs
    7.3 KB · Views: 4
Back