public static void SetNightSightOff(MobileObject mo)
 {
     if (mo != null)
     {
         mo.IsNightSightOn = false;
         mo.OldLightLevel = 0;
     }
 }
Example #2
0
        public static void OnLogin(LoginEventArgs args)
        {
            Mobile mobile = args.Mobile;

            MobileObject mo = new MobileObject();

            mo.Mobile = mobile;

            mo.IsNightSightOn = !mobile.CanBeginAction(typeof(LightCycle));

            m_LoginQueue.Enqueue(mo);
        }
        public static void CheckEffects(MobileObject mo, EffectsObject eo, bool checkSeason, bool checkNightSight)
        {
            Mobile mobile = mo.Mobile;

            if (eo != null && eo.EffectsMap != null)
            {
                if (checkSeason && Data.UseSeasons && eo.EffectsMap.UseSeasons)
                {
                    if (mo.Season != eo.Season)
                    {
                        mo.Season = eo.Season;

                        if (eo.Season == Season.Winter)
                        {
                            mobile.Send(new SeasonChange(4)); // Send Desolation packet for Winter instead of Winter due to Winter adding blocky snow tiles which don't look right.
                        }
                        else
                        {
                            mobile.Send(new SeasonChange((int)eo.Season - 1));
                        }

                        Support.SendLightLevelUpdate(mo);
                    }
                }

                if (checkNightSight)
                {
                    if (mo.IsNightSightOn)
                    {
                        if (Data.UseNightSightDarkestHourOverride && eo.EffectsMap.UseNightSightDarkestHourOverride)
                        {
                            if (mo.IsDarkestHour)
                            {
                                if (eo.EffectsMap.NightSightDarkestHourReduction < 100)
                                {
                                    int adjustment = (int)((double)mo.OldLightLevel * ((double)(100 - eo.EffectsMap.NightSightDarkestHourReduction) / 100));

                                    if (adjustment >= 0 && mobile.LightLevel != adjustment)
                                    {
                                        mobile.LightLevel = adjustment;
                                    }
                                }
                                else
                                {
                                    mobile.EndAction(typeof(LightCycle));
                                    mobile.LightLevel = 0;
                                    BuffInfo.RemoveBuff(mobile, BuffIcon.NightSight);

                                    SetNightSightOff(mo);

                                    mobile.SendMessage("The evil in the air draws energy from your nightsight effect!");
                                }
                            }
                        }

                        if (Data.UseNightSightOverride && !mo.IsDarkestHour && mo.IsNightSightOn)
                        {
                            if (eo.EffectsMap.UseNightSightOverride)
                            {
                                if (eo.EffectsMap.NightSightLevelReduction < 100)
                                {
                                    int adjustment = (int)((double)mo.OldLightLevel * ((double)(100 - eo.EffectsMap.NightSightLevelReduction) / 100));

                                    if (adjustment >= 0 && mobile.LightLevel != adjustment)
                                    {
                                        mobile.LightLevel = adjustment;
                                    }
                                }
                                else
                                {
                                    mobile.EndAction(typeof(LightCycle));
                                    mobile.LightLevel = 0;
                                    BuffInfo.RemoveBuff(mobile, BuffIcon.NightSight);

                                    SetNightSightOff(mo);

                                    mobile.SendMessage("An unknown magical disturbance has consumed your nightsight effect!");
                                }
                            }
                            else
                            {
                                if (mobile.LightLevel < mo.OldLightLevel)
                                {
                                    mobile.LightLevel = mo.OldLightLevel;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (checkNightSight && mo.IsNightSightOn && mobile.LightLevel != mo.OldLightLevel)
                {
                    mobile.LightLevel = mo.OldLightLevel;
                }
            }
        }
Example #4
0
        public static void SendLightLevelUpdate(MobileObject mo)
        {
            Mobile mobile = mo.Mobile;

            mobile.NetState.Send(GlobalLightLevel.Instantiate(mo.LightLevel));
            mobile.NetState.Send(new PersonalLightLevel(mobile, mobile.LightLevel));
        }