got a crash today, null reference that i dont understand



Code:
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.TimeSystem.EffectsEngine.SetNightSightOn(Mobile mobile, Int32 level) in c:\Users\\TIMESYSTEM \Engines\EffectsEngine.cs:line 19
   at Server.Spells.First.NightSightSpell.OnCast() in c:\Scripts\Spells\First\NightSight.cs:line 56
   at Server.Spells.Spell.OnPlayerCast() in c:\\Scripts\Spells\Base\Spell.cs:line 962
   at Server.Spells.Spell.CastTimer.OnTick() in c:Scripts\Spells\Base\Spell.cs:line 1363
   at Server.Timer.Slice()
   at Server.Core.Main(String[] args)


EffectsEngine.cs line line 19

Code:
        public static void SetNightSightOn(Mobile mobile, int level)
        {
            MobileObject mo = Support.GetMobileObject(mobile);

            new LightCycle.NightSightTimer(mobile).Start();

            mo.IsNightSightOn = true;   <<<<<//line 19
            mo.OldLightLevel = level;
        }

nightshight.cs
Code:
TimeSystem.EffectsEngine.SetNightSightOn(targ, oldLevel);
<<<<<//line 56


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

namespace Server.Spells.First
{
    public class NightSightSpell : MagerySpell
    {
        public override SpellCircle Circle { get { return SpellCircle.First; } }
        public override int Sound { get { return 0x1E3; } }

        private static readonly SpellInfo m_Info = new SpellInfo(
                "Night Sight", "In Lor",
                263,
                9031,
                Reagent.SulfurousAsh,
                Reagent.SpidersSilk
            );

        public NightSightSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
        {
        }

        public override void OnCast()
        {
            if (SphereSpellTarget is BaseWand)
            {
                BaseWand bw = SphereSpellTarget as BaseWand;
                bw.RechargeWand(Caster, this);
            }
            else if (SphereSpellTarget is PlayerMobile && Caster.InLOS(SphereSpellTarget) && CheckSequence())
            {
                Mobile targ = (Mobile)SphereSpellTarget;

               // ** EDIT ** Time System

            //new LightCycle.NightSightTimer( targ ).Start();
            int level = (int)( LightCycle.DungeonLevel * ( (Core.AOS ? targ.Skills[SkillName.Magery].Value : targ.Skills[SkillName.Magery].Value )/ 100 ) );

            if ( level < 0 )
                level = 0;

            int oldLevel = level;

            level = TimeSystem.EffectsEngine.GetNightSightLevel(targ, level);

            if (level > -1)
            {
                targ.LightLevel = level;

                targ.FixedParticles( 0x376A, 9, 32, 5007, EffectLayer.Waist );
                targ.PlaySound( 0x1E3 );

                BuffInfo.AddBuff( targ, new BuffInfo( BuffIcon.NightSight, 1075643 ) );    //Night Sight/You ignore lighting effects

                TimeSystem.EffectsEngine.SetNightSightOn(targ, oldLevel);
            }
            else
            {
                targ.EndAction(typeof(LightCycle));

                targ.SendMessage("Tu hechizo parece no tener efecto.");
            }

// ** END *** Time System

                targ.FixedParticles(0x376A, 10, 15, 5007, EffectLayer.Waist);
                targ.PlaySound(Sound);
            }

            FinishSequence();
        }
    }
}

spell.cs
Code:
        public virtual void OnPlayerCast()
        {
            OnCast();   <//962 line
        }

spell.cs

Code:
 m_Spell.OnPlayerCast();
///line 1363
 
Change it like this:

Code:
        public static void SetNightSightOn(Mobile mobile, int level)
        {
            MobileObject mo = Support.GetMobileObject(mobile);
            new LightCycle.NightSightTimer(mobile).Start();
             if (mo != null) {
                    mo.IsNightSightOn = true;   <<<<<//line 19
                    mo.OldLightLevel = level;
            }
        }
 
Back