示例#1
0
        public static bool CheckAlreadyExistsInArray(ref VariableObject vo, object array, object o)
        {
            ArrayList objectList = new ArrayList();

            if (array is List<MonthPropsObject>)
            {
                List<MonthPropsObject> mpos = (List<MonthPropsObject>)array;

                for (int i = 0; i < mpos.Count; i++)
                {
                    objectList.Add(mpos[i]);
                }
            }

            if (array is List<MoonPropsObject>)
            {
                List<MoonPropsObject> mpos = (List<MoonPropsObject>)array;

                for (int i = 0; i < mpos.Count; i++)
                {
                    objectList.Add(mpos[i]);
                }
            }

            return CheckAlreadyExistsInList(ref vo, objectList, o, false);
        }
示例#2
0
        public static bool CheckAlreadyExistsInList(ref VariableObject vo, ArrayList list, object o, bool caseSensitive)
        {
            string value = null;

            CheckAlreadyExistsInList(ref vo, list, o, caseSensitive, ref value);

            if (!vo.Success)
            {
                vo.Message = String.Format("[{0}] already exists!", value);
            }

            return !vo.Success;
        }
示例#3
0
        public static VariableObject AddEemo(Mobile mobile)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Add EffectsExclusionMapObject"))
            {
                return vo;
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            bool success = false;
            string message = null;

            EffectsExclusionMapObject eemo = null;

            int index = -1;

            lock (Data.EffectsExclusionMapArray)
            {
                eemo = Config.SetDefaultEffectsExclusionValues(new EffectsExclusionMapObject(mobile.Map, -1, -1, -1, -1));

                index = Data.EffectsExclusionMapArray.Count;

                eemo.Index = index;

                Data.EffectsExclusionMapArray.Add(eemo);

                success = true;
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(String.Format("EEMO #{0} has been added!\n", index));

            message = sb.ToString();

            vo.Success = success;
            vo.Message = message;

            return vo;
        }
示例#4
0
        public static VariableObject RemoveMoon(string index)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Custom Moons"))
            {
                return vo;
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            if (Data.MoonsArray.Count == 0)
            {
                vo.Success = false;
                vo.Message = "There are no custom moons!";

                return vo;
            }

            object o = Support.GetValue(index);

            lock (Data.MoonsArray)
            {
                bool success = false;
                string message = null;

                if (o is string)
                {
                    for (int i = 0; i < Data.MoonsArray.Count; i++)
                    {
                        MoonPropsObject mpo = Data.MoonsArray[i];

                        if (mpo.Name.ToLower() == index.ToLower())
                        {
                            o = Support.GetValue((i + 1).ToString());

                            break;
                        }
                    }
                }

                if (Config.CheckVariable(o, "Number", 1, Data.MoonsArray.Count, typeof(int), ref success, ref message))
                {
                    int value = (int)o;

                    MoonPropsObject mpo = Data.MoonsArray[value - 1];

                    Data.MoonsArray.RemoveAt(value - 1);
                    Data.MoonsArray.TrimExcess();

                    message = String.Format("Moon #{0} '{1}' has been removed.  All succeeding moons indexes have moved up.", value, mpo.Name);

                    Engine.Restart();
                }
                else
                {
                    StringBuilder sb = new StringBuilder();

                    sb.Append(message);
                    sb.Append("\r\nYou may also specify the moon name instead of the number.");

                    message = sb.ToString();
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#5
0
        public static VariableObject GetMoon(string index)
        {
            VariableObject vo = new VariableObject();

            if (Data.MoonsArray.Count == 0)
            {
                vo.Success = false;
                vo.Message = "There are no custom moons!";

                return vo;
            }

            object o = Support.GetValue(index);

            lock (Data.MoonsArray)
            {
                bool success = false;
                string message = null;

                if (Config.CheckVariable(o, "Number", 1, Data.MoonsArray.Count, typeof(int), ref success, ref message))
                {
                    int value = (int)o;

                    MoonPropsObject mpo = Data.MoonsArray[value - 1];

                    message = String.Format("Moon #{0} '{1}' has '{2}' total phase day{3} and current phase day is '{4}'.", value, mpo.Name, mpo.TotalDays, mpo.TotalDays == 1 ? "" : "s", mpo.CurrentDay);
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#6
0
        private static VariableObject SetMoon(CommandType ct, string index, string setMoonName, string setMoonTotalDays, string setMoonCurrentDay)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Custom Moons"))
            {
                return vo;
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            if (Data.MoonsArray.Count == 0)
            {
                if (ct != CommandType.Add)
                {
                    vo.Success = false;
                    vo.Message = "There are no custom moons!";

                    return vo;
                }
            }

            if (Support.CheckAlreadyExistsInArray(ref vo, Data.MoonsArray, setMoonName))
            {
                return vo;
            }

            lock (Data.MoonsArray)
            {
                int moonIndex = 0;

                int newMoonTotalDays = 0;
                int newMoonCurrentDay = 1;

                bool success = false;
                string message = null;

                if (ct != CommandType.Add) // If not adding, check index number.
                {
                    object o = Support.GetValue(index);

                    if (Config.CheckVariable(o, "Number", 1, Data.MoonsArray.Count, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        moonIndex = value - 1;
                    }
                }
                else // Adding, so increment index by 1.
                {
                    success = true;

                    index = (Data.MoonsArray.Count + 1).ToString();
                }

                if (success) // Check total phase days.
                {
                    object o = Support.GetValue(setMoonTotalDays);

                    if (Config.CheckVariable(o, "Total Phase Days", Enum.GetNames(typeof(MoonPhase)).Length, int.MaxValue, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        newMoonTotalDays = value;
                    }
                }

                if (success) // Check current phase day.
                {
                    if (setMoonCurrentDay != null)
                    {
                        object o = Support.GetValue(setMoonCurrentDay);

                        if (Config.CheckVariable(o, "Current Phase Day", 1, newMoonTotalDays, typeof(int), ref success, ref message))
                        {
                            int value = (int)o;

                            newMoonCurrentDay = value;
                        }
                    }
                }

                if (success) // If successful then finalize.
                {
                    MoonPropsObject mpo = new MoonPropsObject(setMoonName, newMoonTotalDays, newMoonCurrentDay);

                    switch (ct)
                    {
                        case CommandType.Add:
                            {
                                Data.MoonsArray.Add(mpo);

                                message = String.Format("Moon #{0} '{1}' has been added with '{2}' total phase day{3} and current phase day is '{4}'.", index, setMoonName, newMoonTotalDays, newMoonTotalDays == 1 ? "" : "s", newMoonCurrentDay);

                                break;
                            }
                        case CommandType.Insert:
                            {
                                Data.MoonsArray.Insert(moonIndex, mpo);

                                message = String.Format("Moon #{0} '{1}' has been inserted with '{2}' total phase day{3} and current phase day is '{4}'.  All succeeding moons indexes have moved down.", index, setMoonName, newMoonTotalDays, newMoonTotalDays == 1 ? "" : "s", newMoonCurrentDay);

                                break;
                            }
                        case CommandType.Set:
                            {
                                Data.MoonsArray[moonIndex] = mpo;

                                message = String.Format("Moon #{0} '{1}' has been set with '{2}' total phase day{3} and current phase day is '{4}'.", index, setMoonName, newMoonTotalDays, newMoonTotalDays == 1 ? "" : "s", newMoonCurrentDay);

                                break;
                            }
                    }

                    Engine.Restart();
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#7
0
        public static VariableObject GetVariable(string variableName)
        {
            Variable variable = Support.GetVariableFromName(variableName);

            VariableObject vo = new VariableObject();

            bool success = false;
            string message = null;

            switch (variable)
            {
                case Variable.TimerSpeed:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.TimerSpeed.ToString());

                        success = true;

                        break;
                    }
                case Variable.MinutesPerTick:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.MinutesPerTick.ToString());

                        success = true;

                        break;
                    }
                case Variable.LightsEngineTimerSpeed:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.LightsEngineTimerSpeed.ToString());

                        success = true;

                        break;
                    }
                case Variable.UpdateInterval:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UpdateInterval.ToString());

                        success = true;

                        break;
                    }
                case Variable.DayLevel:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.DayLevel.ToString());

                        success = true;

                        break;
                    }
                case Variable.NightLevel:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.NightLevel.ToString());

                        success = true;

                        break;
                    }
                case Variable.DarkestHourLevel:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.DarkestHourLevel.ToString());

                        success = true;

                        break;
                    }
                case Variable.LightsOnLevel:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.LightsOnLevel.ToString());

                        success = true;

                        break;
                    }
                case Variable.MoonLevelAdjust:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.MoonLevelAdjust.ToString());

                        success = true;

                        break;
                    }
                case Variable.MinutesPerHour:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.MinutesPerHour.ToString());

                        success = true;

                        break;
                    }
                case Variable.HoursPerDay:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.HoursPerDay.ToString());

                        success = true;

                        break;
                    }
                case Variable.NightStartHour:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.NightStartHour.ToString());

                        success = true;

                        break;
                    }
                case Variable.NightStartMinute:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.NightStartMinute.ToString());

                        success = true;

                        break;
                    }
                case Variable.DayStartHour:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.DayStartHour.ToString());

                        success = true;

                        break;
                    }
                case Variable.DayStartMinute:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.DayStartMinute.ToString());

                        success = true;

                        break;
                    }
                case Variable.ScaleTimeMinutes:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.ScaleTimeMinutes.ToString());

                        success = true;

                        break;
                    }
                case Variable.Minute:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.Minute.ToString());

                        success = true;

                        break;
                    }
                case Variable.Hour:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.Hour.ToString());

                        success = true;

                        break;
                    }
                case Variable.Day:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.Day.ToString());

                        success = true;

                        break;
                    }
                case Variable.Month:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.Month.ToString());

                        success = true;

                        break;
                    }
                case Variable.Year:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.Year.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseDarkestHour:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseDarkestHour.ToString());

                        success = true;

                        break;
                    }
                case Variable.DarkestHourMinutesAfterNight:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.DarkestHourMinutesAfterNight.ToString());

                        success = true;

                        break;
                    }
                case Variable.DarkestHourScaleTimeMinutes:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.DarkestHourScaleTimeMinutes.ToString());

                        success = true;

                        break;
                    }
                case Variable.DarkestHourLength:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.DarkestHourLength.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseRealTime:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseRealTime.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseTimeZones:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseTimeZones.ToString());

                        success = true;

                        break;
                    }
                case Variable.TimeZoneXDivisor:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.TimeZoneXDivisor.ToString());

                        success = true;

                        break;
                    }
                case Variable.TimeZoneScaleMinutes:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.TimeZoneScaleMinutes.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseAutoLighting:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseAutoLighting.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseRandomLightOutage:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseRandomLightOutage.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseSeasons:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseSeasons.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseNightSightDarkestHourOverride:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseNightSightDarkestHourOverride.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseNightSightOverride:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseNightSightOverride.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseLightLevelOverride:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseLightLevelOverride.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseMurdererDarkestHourBonus:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseMurdererDarkestHourBonus.ToString());

                        success = true;

                        break;
                    }
                case Variable.UseEvilSpawners:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.UseEvilSpawners.ToString());

                        success = true;

                        break;
                    }
                case Variable.TimeFormat:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.TimeFormat);

                        success = true;

                        break;
                    }
                case Variable.ClockTimeFormat:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.ClockTimeFormat);

                        success = true;

                        break;
                    }
                case Variable.SpyglassFormat:
                    {
                        message = Formatting.VariableMessageFormatter(variable.ToString(), Data.SpyglassFormat);

                        success = true;

                        break;
                    }
                default:
                    {
                        message = "That variable type does not exist!";

                        break;
                    }
            }

            vo.Success = success;
            vo.Message = message;

            return vo;
        }
示例#8
0
        public static VariableObject SetEmo(string index, string type, string valueOne, string valueTwo)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Set EffectsMapObject"))
            {
                return vo;
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            lock (Data.EffectsMapArray)
            {
                bool success = false;
                string message = null;

                EffectsMapObject emo = null;

                {
                    object o = Support.GetValue(index);

                    if (Config.CheckVariable(o, "Number", 0, Data.EffectsMapArray.Count - 1, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        emo = Data.EffectsMapArray[value];
                    }
                }

                if (emo == null)
                {
                    vo.Success = false;
                    vo.Message = message;

                    return vo;
                }

                EffectsMapType emoType = Support.GetEmoTypeFromName(type);

                switch (emoType)
                {
                    default:
                        {
                            success = false;
                            message = "That EMO type does not exist!";

                            break;
                        }
                    case EffectsMapType.Priority:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), 0, int.MaxValue, typeof(int), ref success, ref message))
                            {
                                int value = (int)o;

                                emo.Priority = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.Map:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            Map map = Support.GetMapFromName(valueOne, false);

                            if (map == null)
                            {
                                message = Formatting.ErrorMessageFormatter(emoType.ToString(), valueOne, Support.GetMapList(false));

                                break;
                            }

                            success = true;

                            emo.Map = map;

                            message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), map.Name);

                            break;
                        }
                    case EffectsMapType.X1Y1:
                        {
                            bool overallSuccess = true;

                            if (valueTwo == null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            int x1 = -1, y1 = -1;

                            {
                                object o = Support.GetValue(valueOne);

                                if (Config.CheckVariable(o, "X1", 0, emo.X2 - 1, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    x1 = value;
                                }
                                else
                                {
                                    overallSuccess = false;
                                }
                            }

                            {
                                object o = Support.GetValue(valueTwo);

                                StringBuilder sb = new StringBuilder();

                                if (message != null)
                                {
                                    sb.Append(message);
                                    sb.Append("\n");
                                }

                                if (Config.CheckVariable(o, "Y1", 0, emo.Y2 - 1, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    y1 = value;
                                }
                                else
                                {
                                    overallSuccess = false;

                                    sb.Append(message);
                                }

                                message = sb.ToString();
                            }

                            if (overallSuccess)
                            {
                                emo.X1 = x1;
                                emo.Y1 = y1;

                                string value = String.Format("{0}, {1}", x1, y1);

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value);
                            }

                            break;
                        }
                    case EffectsMapType.X2Y2:
                        {
                            bool overallSuccess = true;

                            if (valueTwo == null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            int x2 = -1, y2 = -1;

                            {
                                object o = Support.GetValue(valueOne);

                                if (Config.CheckVariable(o, "X2", emo.X1 + 1, emo.Map.Width, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    x2 = value;
                                }
                                else
                                {
                                    overallSuccess = false;
                                }
                            }

                            {
                                object o = Support.GetValue(valueTwo);

                                StringBuilder sb = new StringBuilder();

                                if (message != null)
                                {
                                    sb.Append(message);
                                    sb.Append("\n");
                                }

                                if (Config.CheckVariable(o, "Y2", emo.Y1 + 1, emo.Map.Height, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    y2 = value;
                                }
                                else
                                {
                                    overallSuccess = false;

                                    sb.Append(message);
                                }

                                message = sb.ToString();
                            }

                            if (overallSuccess)
                            {
                                emo.X2 = x2;
                                emo.Y2 = y2;

                                string value = String.Format("{0}, {1}", x2, y2);

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value);
                            }

                            break;
                        }
                    case EffectsMapType.UseLatitude:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseLatitude = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.OuterInnerLatitude:
                        {
                            if (valueTwo == null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            {
                                object o = Support.GetValue(valueOne);

                                if (Config.CheckVariable(o, "OuterLatitudePercent", 0, 100, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.OuterLatitudePercent = value / 100;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "OuterLatitudePercent", String.Format("{0}%", value));
                                }
                            }

                            {
                                object o = Support.GetValue(valueTwo);

                                StringBuilder sb = new StringBuilder();

                                if (message != null)
                                {
                                    sb.Append(message);
                                    sb.Append("\n");
                                }

                                if (Config.CheckVariable(o, "InnerLatitudePercent", 0, 100, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.InnerLatitudePercent = value / 100;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "InnerLatitudePercent", String.Format("{0}%", value));
                                }

                                sb.Append(message);

                                message = sb.ToString();
                            }

                            break;
                        }
                    case EffectsMapType.UseSeasons:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseSeasons = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.StaticSeason:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            Season season = Support.GetSeasonFromName(valueOne);

                            if (season == Season.None && valueOne.ToUpper() != season.ToString().ToUpper())
                            {
                                message = Formatting.ErrorMessageFormatter(emoType.ToString(), valueOne, Support.GetSeasonList());

                                break;
                            }

                            success = true;

                            emo.StaticSeason = season;

                            message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), season.ToString());

                            break;
                        }
                    case EffectsMapType.SpringDate:
                        {
                            if (valueTwo == null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            {
                                object o = Support.GetValue(valueOne);

                                if (Config.CheckVariable(o, "Spring Date Month", 1, Data.MonthsArray.Count, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.SpringDate.Month = value;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "Spring Date Month", value.ToString());
                                }
                            }

                            if (success)
                            {
                                object o = Support.GetValue(valueTwo);

                                StringBuilder sb = new StringBuilder();

                                if (message != null)
                                {
                                    sb.Append(message);
                                    sb.Append("\n");
                                }

                                if (Config.CheckVariable(o, "Spring Date Day", 1, Data.MonthsArray[emo.SpringDate.Month - 1].TotalDays, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.SpringDate.Day = value;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "Spring Date Day", value.ToString());
                                }

                                sb.Append(message);

                                message = sb.ToString();
                            }

                            break;
                        }
                    case EffectsMapType.SummerDate:
                        {
                            if (valueTwo == null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            {
                                object o = Support.GetValue(valueOne);

                                if (Config.CheckVariable(o, "Summer Date Month", 1, Data.MonthsArray.Count, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.SummerDate.Month = value;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "Summer Date Month", value.ToString());
                                }
                            }

                            if (success)
                            {
                                object o = Support.GetValue(valueTwo);

                                StringBuilder sb = new StringBuilder();

                                if (message != null)
                                {
                                    sb.Append(message);
                                    sb.Append("\n");
                                }

                                if (Config.CheckVariable(o, "Summer Date Day", 1, Data.MonthsArray[emo.SpringDate.Month - 1].TotalDays, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.SummerDate.Day = value;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "Summer Date Day", value.ToString());
                                }

                                sb.Append(message);

                                message = sb.ToString();
                            }

                            break;
                        }
                    case EffectsMapType.FallDate:
                        {
                            if (valueTwo == null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            {
                                object o = Support.GetValue(valueOne);

                                if (Config.CheckVariable(o, "Fall Date Month", 1, Data.MonthsArray.Count, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.FallDate.Month = value;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "Fall Date Month", value.ToString());
                                }
                            }

                            if (success)
                            {
                                object o = Support.GetValue(valueTwo);

                                StringBuilder sb = new StringBuilder();

                                if (message != null)
                                {
                                    sb.Append(message);
                                    sb.Append("\n");
                                }

                                if (Config.CheckVariable(o, "Fall Date Day", 1, Data.MonthsArray[emo.SpringDate.Month - 1].TotalDays, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.FallDate.Day = value;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "Fall Date Day", value.ToString());
                                }

                                sb.Append(message);

                                message = sb.ToString();
                            }

                            break;
                        }
                    case EffectsMapType.WinterDate:
                        {
                            if (valueTwo == null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            {
                                object o = Support.GetValue(valueOne);

                                if (Config.CheckVariable(o, "Winter Date Month", 1, Data.MonthsArray.Count, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.WinterDate.Month = value;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "Winter Date Month", value.ToString());
                                }
                            }

                            if (success)
                            {
                                object o = Support.GetValue(valueTwo);

                                StringBuilder sb = new StringBuilder();

                                if (message != null)
                                {
                                    sb.Append(message);
                                    sb.Append("\n");
                                }

                                if (Config.CheckVariable(o, "Winter Date Day", 1, Data.MonthsArray[emo.SpringDate.Month - 1].TotalDays, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    emo.WinterDate.Day = value;

                                    message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), "Winter Date Day", value.ToString());
                                }

                                sb.Append(message);

                                message = sb.ToString();
                            }

                            break;
                        }
                    case EffectsMapType.UseDarkestHour:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseDarkestHour = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.UseAutoLighting:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseAutoLighting = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.UseRandomLightOutage:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseRandomLightOutage = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.LightOutageChancePerTick:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), 0, 100, typeof(int), ref success, ref message))
                            {
                                int value = (int)o;

                                emo.LightOutageChancePerTick = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), String.Format("{0}%", value));
                            }

                            break;
                        }
                    case EffectsMapType.UseNightSightDarkestHourOverride:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseNightSightDarkestHourOverride = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.NightSightDarkestHourReduction:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), 0, 100, typeof(int), ref success, ref message))
                            {
                                int value = (int)o;

                                emo.NightSightDarkestHourReduction = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), String.Format("{0}%", value));
                            }

                            break;
                        }
                    case EffectsMapType.UseNightSightOverride:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseNightSightOverride = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.NightSightLevelReduction:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), 0, 100, typeof(int), ref success, ref message))
                            {
                                int value = (int)o;

                                emo.NightSightLevelReduction = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), String.Format("{0}%", value));
                            }

                            break;
                        }
                    case EffectsMapType.UseLightLevelOverride:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseLightLevelOverride = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.LightLevelOverrideAdjust:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), Data.MinLightLevel, Data.MaxLightLevel, typeof(int), ref success, ref message))
                            {
                                int value = (int)o;

                                emo.LightLevelOverrideAdjust = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.UseMurdererDarkestHourBonus:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseMurdererDarkestHourBonus = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.MurdererDarkestHourLevelBonus:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), Data.MinLightLevel, Data.MaxLightLevel, typeof(int), ref success, ref message))
                            {
                                int value = (int)o;

                                emo.MurdererDarkestHourLevelBonus = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsMapType.UseEvilSpawners:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEmo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, emoType.ToString(), false, true, typeof(bool), ref success, ref message))
                            {
                                bool value = (bool)o;

                                emo.UseEvilSpawners = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EMO #{0}", emo.Index), emoType.ToString(), value.ToString());
                            }

                            break;
                        }
                }

                if (success)
                {
                    Data.EffectsMapArray[emo.Index] = emo;
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#9
0
        public static VariableObject GetFacetAdjust(string index)
        {
            VariableObject vo = new VariableObject();

            object o = Support.GetValue(index);

            lock (Data.FacetArray)
            {
                bool success = false;
                string message = null;

                if (Config.CheckVariable(o, "Number", 0, Data.NumberOfFacets - 1, typeof(int), ref success, ref message))
                {
                    int value = (int)o;

                    string name = Map.Maps[value].Name;

                    FacetPropsObject fpo = Data.FacetArray[value];

                    int adjustment = fpo.Adjustment;

                    message = String.Format("Facet #{0} '{1}' has an adjustment of '{2}' minute{3} ahead of base time.", value, name, adjustment, adjustment == 1 ? "" : "s");
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#10
0
        public static VariableObject RemoveEmo(string index)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Remove EffectsMapObject"))
            {
                return vo;
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            if (Data.EffectsMapArray.Count == 0)
            {
                vo.Success = false;
                vo.Message = "There are no EffectsMapObjects!";

                return vo;
            }

            lock (Data.EffectsMapArray)
            {
                bool success = false;
                string message = null;

                object o = Support.GetValue(index);

                Type typeExpected = typeof(int);

                int lowValue = 0;
                int highValue = Data.EffectsMapArray.Count - 1;

                string minValue = Convert.ToString(lowValue);
                string maxValue = Convert.ToString(highValue);

                if (o is int)
                {
                    int value = (int)o;

                    if (value >= lowValue && value <= highValue)
                    {
                        Data.EffectsMapArray.RemoveAt(value);
                        Data.EffectsMapArray.TrimExcess();

                        Support.ReIndexArray(Data.EffectsMapArray);

                        message = String.Format("EMO #{0} has been removed.  All succeeding EMO indexes have moved up.", value);
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();

                        sb.Append(Formatting.ErrorMessageFormatter("EMO Number", o, minValue, maxValue));

                        message = sb.ToString();
                    }
                }
                else
                {
                    StringBuilder sb = new StringBuilder();

                    sb.Append(Formatting.ErrorMessageFormatter("EMO Number", o, minValue, maxValue, typeExpected));

                    message = sb.ToString();
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#11
0
        public static VariableObject GetEmo(Mobile mobile, string index)
        {
            VariableObject vo = new VariableObject();

            if (Data.EffectsMapArray.Count == 0)
            {
                vo.Success = false;
                vo.Message = "There are no EffectsMapObjects!";

                return vo;
            }

            lock (Data.EffectsMapArray)
            {
                bool success = false;
                string message = null;

                EffectsMapObject emo = null;

                if (index == null)
                {
                    success = true;

                    List<EffectsMapObject> emoArray = EffectsEngine.GetEffectsMapArray(mobile.Map, mobile.X, mobile.Y, true);
                    List<EffectsExclusionMapObject> eemoArray = EffectsEngine.GetEffectsExclusionMapArray(mobile.Map, mobile.X, mobile.Y, true);

                    if (emoArray.Count > 0)
                    {
                        EffectsMapObject emoParentSeason = null;

                        for (int i = 0; i < emoArray.Count; i++)
                        {
                            EffectsMapObject effectsMap = emoArray[i];

                            if (effectsMap.Enabled && effectsMap.UseSeasons)
                            {
                                emoParentSeason = effectsMap;

                                break;
                            }
                        }

                        StringBuilder sb = new StringBuilder();

                        sb.Append("Legend:\n* - EMO with highest priority\n@ - EMO with season priority\n! - Disabled EMO\n\n");
                        sb.Append("You are in the following EMO bounds in priortized order:\n");

                        if (emoArray.Count > 1)
                        {
                            for (int i = 0; i < emoArray.Count; i++)
                            {
                                if (i + 1 < emoArray.Count)
                                {
                                    sb.Append(String.Format("{0}{1}{2}{3}, ", emoArray[i].Index, i == 0 ? "*" : "", emoArray[i] == emoParentSeason ? "@" : "", !emoArray[i].Enabled ? "!" : ""));
                                }
                                else
                                {
                                    sb.Append(String.Format("{0}{1}{2}{3}", emoArray[i].Index, i == 0 ? "*" : "", emoArray[i] == emoParentSeason ? "@" : "", !emoArray[i].Enabled ? "!" : ""));
                                }
                            }
                        }
                        else
                        {
                            sb.Append(String.Format("{0}*{1}{2}", emoArray[0].Index, emoArray[0].UseSeasons ? "@" : "", !emoArray[0].Enabled ? "!" : ""));
                        }

                        if (eemoArray.Count > 0 && emoArray.Count > 0 && eemoArray[0].Priority >= emoArray[0].Priority)
                        {
                            sb.Append(String.Format("\n\nEEMO #{0} has priority over EMO #{1}.", eemoArray[0].Index, emoArray[0].Index));
                        }

                        message = sb.ToString();
                    }
                    else
                    {
                        message = "You are not in an area that is under any effects!";
                    }
                }
                else
                {
                    object o = Support.GetValue(index);

                    Type typeExpected = typeof(int);

                    int lowValue = 0;
                    int highValue = Data.EffectsMapArray.Count - 1;

                    string minValue = Convert.ToString(lowValue);
                    string maxValue = Convert.ToString(highValue);

                    if (o is int)
                    {
                        int value = (int)o;

                        if (value >= lowValue && value <= highValue)
                        {
                            success = true;

                            emo = Data.EffectsMapArray[value];

                            int height = emo.Y2 - emo.Y1;

                            int outerLatitudeHeight = (int)(height * emo.OuterLatitudePercent);
                            int innerLatitudeHeight = (int)(height * emo.InnerLatitudePercent);
                            int middleLatitude = emo.Y1 + (int)(height / 2);

                            int upperOuterLowRange = emo.Y1;
                            int upperOuterHighRange = emo.Y1 + outerLatitudeHeight;

                            int lowerOuterLowRange = emo.Y1 + (height - outerLatitudeHeight);
                            int lowerOuterHighRange = emo.Y1 + height;

                            int innerLowRange = middleLatitude - innerLatitudeHeight;
                            int innerHighRange = middleLatitude + innerLatitudeHeight;

                            StringBuilder sb = new StringBuilder();

                            sb.Append(String.Format("EMO #{0} [Priority: {1}]: Bounds: ({2}, {3}) to ({4}, {5}) on map '{6}'.\n", emo.Index, emo.Priority, emo.X1, emo.Y1, emo.X2, emo.Y2, emo.Map));
                            sb.Append(String.Format("Enabled: {0}\n", emo.Enabled));
                            sb.Append(String.Format("UseLatitude: {0}\nOuter Percent: {1}%\nInner Percent: {2}%\n", emo.UseLatitude, emo.OuterLatitudePercent * 100, emo.InnerLatitudePercent * 100));
                            sb.Append(String.Format("Middle Latitude: {0}\n", middleLatitude));
                            sb.Append(String.Format("Upper Outer Range: {0} - {1}\n", upperOuterLowRange, upperOuterHighRange));
                            sb.Append(String.Format("Lower Outer Range: {0} - {1}\n", lowerOuterLowRange, lowerOuterHighRange));
                            sb.Append(String.Format("Inner Range: {0} - {1}\n", innerLowRange, innerHighRange));
                            sb.Append(String.Format("UseSeasons: {0}\nStatic Season: {1}\n", emo.UseSeasons, emo.StaticSeason));
                            sb.Append(String.Format("Spring Date: {0}/{1}\n", emo.SpringDate.Month, emo.SpringDate.Day));
                            sb.Append(String.Format("Summer Date: {0}/{1}\n", emo.SummerDate.Month, emo.SummerDate.Day));
                            sb.Append(String.Format("Fall Date: {0}/{1}\n", emo.FallDate.Month, emo.FallDate.Day));
                            sb.Append(String.Format("Winter Date: {0}/{1}\n", emo.WinterDate.Month, emo.WinterDate.Day));
                            sb.Append(String.Format("UseDarkestHour: {0}\n", emo.UseDarkestHour));
                            sb.Append(String.Format("UseAutoLighting: {0}\n", emo.UseAutoLighting));
                            sb.Append(String.Format("UseRandomLightOutage: {0}\n", emo.UseRandomLightOutage));
                            sb.Append(String.Format("LightOutageChancePerTick: {0}%\n", emo.LightOutageChancePerTick));
                            sb.Append(String.Format("UseNightSightDarkestHourOverride: {0}\n", emo.UseNightSightDarkestHourOverride));
                            sb.Append(String.Format("NightSightDarkestHourReduction: {0}%\n", emo.NightSightDarkestHourReduction));
                            sb.Append(String.Format("UseNightSightOverride: {0}\n", emo.UseNightSightOverride));
                            sb.Append(String.Format("NightSightLevelReduction: {0}%\n", emo.NightSightLevelReduction));
                            sb.Append(String.Format("UseLightLevelOverride: {0}\n", emo.UseLightLevelOverride));
                            sb.Append(String.Format("LightLevelOverrideAdjust: {0}%\n", emo.LightLevelOverrideAdjust));
                            sb.Append(String.Format("UseMurdererDarkestHourBonus: {0}\n", emo.UseMurdererDarkestHourBonus));
                            sb.Append(String.Format("MurdererDarkestHourLevelBonus: {0}%\n", emo.MurdererDarkestHourLevelBonus));
                            sb.Append(String.Format("UseEvilSpawners: {0}\n", emo.UseEvilSpawners));

                            message = sb.ToString();
                        }
                        else
                        {
                            StringBuilder sb = new StringBuilder();

                            sb.Append(Formatting.ErrorMessageFormatter("EMO Number", o, minValue, maxValue));

                            message = sb.ToString();
                        }
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();

                        sb.Append(Formatting.ErrorMessageFormatter("EMO Number", o, minValue, maxValue, typeExpected));

                        message = sb.ToString();
                    }
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#12
0
        private static bool CheckAlreadyExistsInList(ref VariableObject vo, ArrayList list, object o, bool caseSensitive, ref string value)
        {
            vo.Success = true;

            if (list == null)
            {
                return false;
            }

            for (int i = 0; i < list.Count; i++)
            {
                object lo = list[i];

                if (o == lo)
                {
                    vo.Success = false;

                    value = lo.ToString();

                    break;
                }

                if (lo is ArrayList)
                {
                    if (CheckAlreadyExistsInList(ref vo, (ArrayList)lo, o, caseSensitive, ref value))
                    {
                        vo.Success = false;
                    }
                }

                if (lo is MonthPropsObject && o is string)
                {
                    string oValue = (string)o;
                    MonthPropsObject loValue = (MonthPropsObject)lo;

                    if ((!caseSensitive && oValue.ToLower() == loValue.Name.ToLower()) || (caseSensitive && oValue == loValue.Name))
                    {
                        vo.Success = false;

                        value = loValue.Name;

                        break;
                    }
                }

                if (lo is MoonPropsObject && o is string)
                {
                    string oValue = (string)o;
                    MoonPropsObject loValue = (MoonPropsObject)lo;

                    if ((!caseSensitive && oValue.ToLower() == loValue.Name.ToLower()) || (caseSensitive && oValue == loValue.Name))
                    {
                        vo.Success = false;

                        value = loValue.Name;

                        break;
                    }
                }
            }

            return !vo.Success;
        }
示例#13
0
 public static bool CheckAlreadyExistsInList(ref VariableObject vo, ArrayList list, object o)
 {
     return CheckAlreadyExistsInList(ref vo, list, o, false);
 }
示例#14
0
        public static bool CheckForceScriptSettings(ref VariableObject vo, string reference)
        {
            bool forceScriptSettings = Config.ForceScriptSettings;

            if (forceScriptSettings)
            {
                vo.Success = false;
                vo.Message = String.Format("ForceScriptSettings is set to true.  You are unable to make changes to [{0}] in-game.", reference);
            }

            return Config.ForceScriptSettings;
        }
示例#15
0
        public static VariableObject SetMoonProps(string index, string setMoonCurrentDay, string setMoonTotalDays)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Custom Moons") && setMoonTotalDays != null)
            {
                return vo;
            }

            if (Data.MoonsArray.Count == 0)
            {
                vo.Success = false;
                vo.Message = "There are no custom moons!";

                return vo;
            }

            lock (Data.MoonsArray)
            {
                int moonIndex = 0;

                string moonName = null;
                int oldMoonTotalDays = 0;
                int newMoonTotalDays = 0;
                int newMoonCurrentDay = 0;

                bool success = false;
                string message = null;

                {
                    object o = Support.GetValue(index);

                    if (o is string)
                    {
                        for (int i = 0; i < Data.MoonsArray.Count; i++)
                        {
                            MoonPropsObject mpo = Data.MoonsArray[i];

                            if (mpo.Name.ToLower() == index.ToLower())
                            {
                                o = Support.GetValue((i + 1).ToString());

                                break;
                            }
                        }
                    }

                    if (Config.CheckVariable(o, "Number", 1, Data.MoonsArray.Count, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        moonIndex = value - 1;

                        index = value.ToString();

                        MoonPropsObject mpo = Data.MoonsArray[moonIndex];

                        moonName = mpo.Name;
                        oldMoonTotalDays = mpo.TotalDays;
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();

                        sb.Append(message);
                        sb.Append("\r\nYou may also specify the moon name instead of the number.");

                        message = sb.ToString();
                    }
                }

                if (success)
                {
                    if (setMoonTotalDays != null)
                    {
                        object o = Support.GetValue(setMoonTotalDays);

                        if (Config.CheckVariable(o, "Total Phase Days", Enum.GetNames(typeof(MoonPhase)).Length, int.MaxValue, typeof(int), ref success, ref message))
                        {
                            int value = (int)o;

                            newMoonTotalDays = value;
                        }
                    }
                    else
                    {
                        newMoonTotalDays = oldMoonTotalDays;
                    }
                }

                if (success)
                {
                    object o = Support.GetValue(setMoonCurrentDay);

                    if (Config.CheckVariable(o, "Current Phase Day", 1, newMoonTotalDays, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        newMoonCurrentDay = value;
                    }
                }

                if (success)
                {
                    MoonPropsObject mpo = new MoonPropsObject(moonName, newMoonTotalDays, newMoonCurrentDay);

                    Data.MoonsArray[moonIndex] = mpo;

                    message = String.Format("Moon #{0} '{1}' has been set to {2} total phase day{3} and current phase day is '{4}'.", index, moonName, newMoonTotalDays, newMoonTotalDays == 1 ? "" : "s", newMoonCurrentDay);

                    Engine.Restart();
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#16
0
        public static VariableObject SetFacetAdjust(string index, string setAdjustment)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Facet Adjustment"))
            {
                return vo;
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            lock (Data.FacetArray)
            {
                int mapIndex = 0;

                bool success = false;
                string message = null;

                {
                    object o = Support.GetValue(index);

                    if (o is string)
                    {
                        Map map = Support.GetMapFromName(index, false);

                        if (map != null)
                        {
                            o = Support.GetValue(map.MapIndex.ToString());
                        }
                    }

                    if (Config.CheckVariable(o, "Number", 0, Data.NumberOfFacets - 1, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        mapIndex = value;
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();

                        sb.Append(message);
                        sb.Append("\r\nYou may also specify the facet name instead of the number.");

                        message = sb.ToString();
                    }
                }

                if (success)
                {
                    object o = Support.GetValue(setAdjustment);

                    if (Config.CheckVariable(o, "Adjustment", 0, int.MaxValue - 1440, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        Data.FacetArray[mapIndex] = new FacetPropsObject(Map.Maps[mapIndex], value);

                        string name = Map.Maps[mapIndex].Name;

                        message = String.Format("Facet #{0} '{1}' has been adjusted to be '{2}' minute{3} ahead of base time.", mapIndex, name, value, value == 1 ? "" : "s");

                        Engine.Restart();

                    }
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#17
0
        public static VariableObject SetEemo(string index, string type, string valueOne, string valueTwo)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Set EffectsExclusionMapObject"))
            {
                return vo;
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            lock (Data.EffectsExclusionMapArray)
            {
                bool success = false;
                string message = null;

                EffectsExclusionMapObject eemo = null;

                {
                    object o = Support.GetValue(index);

                    if (Config.CheckVariable(o, "Number", 0, Data.EffectsExclusionMapArray.Count - 1, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        eemo = Data.EffectsExclusionMapArray[value];
                    }
                }

                if (eemo == null)
                {
                    vo.Success = false;
                    vo.Message = message;

                    return vo;
                }

                EffectsExclusionMapType eemoType = Support.GetEemoTypeFromName(type);

                switch (eemoType)
                {
                    default:
                        {
                            success = false;
                            message = "That EEMO type does not exist!";

                            break;
                        }
                    case EffectsExclusionMapType.Priority:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEemo);

                                break;
                            }

                            object o = Support.GetValue(valueOne);

                            if (Config.CheckVariable(o, eemoType.ToString(), 0, int.MaxValue, typeof(int), ref success, ref message))
                            {
                                int value = (int)o;

                                eemo.Priority = value;

                                message = Formatting.VariableMessageFormatter(String.Format("EEMO #{0}", eemo.Index), eemoType.ToString(), value.ToString());
                            }

                            break;
                        }
                    case EffectsExclusionMapType.Map:
                        {
                            if (valueTwo != null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEemo);

                                break;
                            }

                            Map map = Support.GetMapFromName(valueOne, false);

                            if (map == null)
                            {
                                message = Formatting.ErrorMessageFormatter(eemoType.ToString(), valueOne, Support.GetMapList(false));

                                break;
                            }

                            success = true;

                            eemo.Map = map;

                            message = Formatting.VariableMessageFormatter(String.Format("EEMO #{0}", eemo.Index), eemoType.ToString(), map.Name);

                            break;
                        }
                    case EffectsExclusionMapType.X1Y1:
                        {
                            bool overallSuccess = true;

                            if (valueTwo == null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEemo);

                                break;
                            }

                            int x1 = -1, y1 = -1;

                            {
                                object o = Support.GetValue(valueOne);

                                if (Config.CheckVariable(o, "X1", 0, eemo.X2 - 1, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    x1 = value;
                                }
                                else
                                {
                                    overallSuccess = false;
                                }
                            }

                            {
                                object o = Support.GetValue(valueTwo);

                                StringBuilder sb = new StringBuilder();

                                if (message != null)
                                {
                                    sb.Append(message);
                                    sb.Append("\n");
                                }

                                if (Config.CheckVariable(o, "Y1", 0, eemo.Y2 - 1, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    y1 = value;
                                }
                                else
                                {
                                    overallSuccess = false;

                                    sb.Append(message);
                                }

                                message = sb.ToString();
                            }

                            if (overallSuccess)
                            {
                                eemo.X1 = x1;
                                eemo.Y1 = y1;

                                string value = String.Format("{0}, {1}", x1, y1);

                                message = Formatting.VariableMessageFormatter(String.Format("EEMO #{0}", eemo.Index), eemoType.ToString(), value);
                            }

                            break;
                        }
                    case EffectsExclusionMapType.X2Y2:
                        {
                            bool overallSuccess = true;

                            if (valueTwo == null)
                            {
                                success = false;
                                message = Syntax.GetSyntax(true, Command.SetEemo);

                                break;
                            }

                            int x2 = -1, y2 = -1;

                            {
                                object o = Support.GetValue(valueOne);

                                if (Config.CheckVariable(o, "X2", eemo.X1 + 1, eemo.Map.Width, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    x2 = value;
                                }
                                else
                                {
                                    overallSuccess = false;
                                }
                            }

                            {
                                object o = Support.GetValue(valueTwo);

                                StringBuilder sb = new StringBuilder();

                                if (message != null)
                                {
                                    sb.Append(message);
                                    sb.Append("\n");
                                }

                                if (Config.CheckVariable(o, "Y2", eemo.Y1 + 1, eemo.Map.Height, typeof(int), ref success, ref message))
                                {
                                    int value = (int)o;

                                    y2 = value;
                                }
                                else
                                {
                                    overallSuccess = false;

                                    sb.Append(message);
                                }

                                message = sb.ToString();
                            }

                            if (overallSuccess)
                            {
                                eemo.X2 = x2;
                                eemo.Y2 = y2;

                                string value = String.Format("{0}, {1}", x2, y2);

                                message = Formatting.VariableMessageFormatter(String.Format("EEMO #{0}", eemo.Index), eemoType.ToString(), value);
                            }

                            break;
                        }
                }

                if (success)
                {
                    Data.EffectsExclusionMapArray[eemo.Index] = eemo;
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#18
0
        public static VariableObject AddEmo(Mobile mobile)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Add EffectsMapObject"))
            {
                return vo;
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            bool success = false;
            string message = null;

            EffectsMapObject emo = null;

            int index = -1;

            lock (Data.EffectsMapArray)
            {
                emo = Config.SetDefaultEffectsValues(new EffectsMapObject(mobile.Map, -1, -1, -1, -1));

                index = Data.EffectsMapArray.Count;

                emo.Index = index;

                Data.EffectsMapArray.Add(emo);

                success = true;
            }

            int height = emo.Y2 - emo.Y1;

            int outerLatitudeHeight = (int)(height * emo.OuterLatitudePercent);
            int innerLatitudeHeight = (int)(height * emo.InnerLatitudePercent);
            int middleLatitude = emo.Y1 + (int)(height / 2);

            int upperOuterLowRange = emo.Y1;
            int upperOuterHighRange = emo.Y1 + outerLatitudeHeight;

            int lowerOuterLowRange = emo.Y1 + (height - outerLatitudeHeight);
            int lowerOuterHighRange = emo.Y1 + height;

            int innerLowRange = middleLatitude - innerLatitudeHeight;
            int innerHighRange = middleLatitude + innerLatitudeHeight;

            StringBuilder sb = new StringBuilder();

            sb.Append(String.Format("EMO #{0} has been added!\n", index));

            message = sb.ToString();

            vo.Success = success;
            vo.Message = message;

            return vo;
        }
示例#19
0
        public static VariableObject GetEemo(Mobile mobile, string index)
        {
            VariableObject vo = new VariableObject();

            if (Data.EffectsExclusionMapArray.Count == 0)
            {
                vo.Success = false;
                vo.Message = "There are no EffectsExclusionMapObjects!";

                return vo;
            }

            lock (Data.EffectsExclusionMapArray)
            {
                bool success = false;
                string message = null;

                EffectsExclusionMapObject eemo = null;

                if (index == null)
                {
                    success = true;

                    List<EffectsExclusionMapObject> eemoArray = EffectsEngine.GetEffectsExclusionMapArray(mobile.Map, mobile.X, mobile.Y, true);
                    List<EffectsMapObject> emoArray = EffectsEngine.GetEffectsMapArray(mobile.Map, mobile.X, mobile.Y, true);

                    if (eemoArray.Count > 0)
                    {
                        StringBuilder sb = new StringBuilder();

                        sb.Append("Legend:\n* - EEMO with highest priority\n! - Disabled EEMO\n\n");
                        sb.Append("You are in the following EEMO bounds in priortized order:\n");

                        if (eemoArray.Count > 1)
                        {
                            for (int i = 0; i < eemoArray.Count; i++)
                            {
                                if (i + 1 < eemoArray.Count)
                                {
                                    sb.Append(String.Format("{0}{1}{2}, ", eemoArray[i].Index, i == 0 ? "*" : "", !eemoArray[i].Enabled ? "!" : ""));
                                }
                                else
                                {
                                    sb.Append(String.Format("{0}{1}{2}", eemoArray[i].Index, i == 0 ? "*" : "", !eemoArray[i].Enabled ? "!" : ""));
                                }
                            }
                        }
                        else
                        {
                            sb.Append(String.Format("{0}*{1}", eemoArray[0].Index, !eemoArray[0].Enabled ? "!" : ""));
                        }

                        if (emoArray.Count > 0 && eemoArray.Count > 0 && emoArray[0].Priority > eemoArray[0].Priority)
                        {
                            sb.Append(String.Format("\n\nEMO #{0} has priority over EEMO #{1}.", emoArray[0].Index, eemoArray[0].Index));
                        }

                        message = sb.ToString();
                    }
                    else
                    {
                        message = "You are not in an area that is under any effect exclusions!";
                    }
                }
                else
                {
                    object o = Support.GetValue(index);

                    Type typeExpected = typeof(int);

                    int lowValue = 0;
                    int highValue = Data.EffectsExclusionMapArray.Count - 1;

                    string minValue = Convert.ToString(lowValue);
                    string maxValue = Convert.ToString(highValue);

                    if (o is int)
                    {
                        int value = (int)o;

                        if (value >= lowValue && value <= highValue)
                        {
                            success = true;

                            eemo = Data.EffectsExclusionMapArray[value];

                            StringBuilder sb = new StringBuilder();

                            sb.Append(String.Format("EEMO #{0} [Priority: {1}]: Bounds: ({2}, {3}) to ({4}, {5}) on map '{6}'.\n", eemo.Index, eemo.Priority, eemo.X1, eemo.Y1, eemo.X2, eemo.Y2, eemo.Map));
                            sb.Append(String.Format("Enabled: {0}\n", eemo.Enabled));

                            message = sb.ToString();

                        }
                        else
                        {
                            StringBuilder sb = new StringBuilder();

                            sb.Append(Formatting.ErrorMessageFormatter("EEMO Number", o, minValue, maxValue));

                            message = sb.ToString();
                        }
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();

                        sb.Append(Formatting.ErrorMessageFormatter("EEMO Number", o, minValue, maxValue, typeExpected));

                        message = sb.ToString();
                    }
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#20
0
        private static void TimeSystem_OnCommand(CommandEventArgs e)
        {
            Mobile mobile = e.Mobile;

            VariableObject vo = null;

            Support.WriteToLogFile(e);

            if (e.Length >= 1)
            {
                Command command = Support.GetCommandFromName(e.GetString(0));

                if (e.Length == 2 && e.GetString(1) == "?")
                {
                    mobile.SendMessage(Syntax.GetSyntax(false, command));

                    return;
                }

                switch (command)
                {
                    case Command.Set:
                        {
                            Config.SetVariable(mobile, e, false);

                            break;
                        }
                    case Command.Get:
                        {
                            if (e.Length == 1)
                            {
                                Support.SendVariableNames(mobile);
                            }
                            else if (e.Length == 2)
                            {
                                string variableName = e.GetString(1).ToUpper();

                                vo = Config.GetVariable(variableName);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.Append:
                        {
                            Config.SetVariable(mobile, e, true);

                            break;
                        }
                    case Command.RepopLightsList:
                        {
                            if (e.Length == 1)
                            {
                                LightsEngine.PopulateLightsList();

                                mobile.SendMessage("The managed lights list has been repopulated.");
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.Stop:
                        {
                            if (e.Length == 1)
                            {
                                Engine.Stop();

                                mobile.SendMessage("The time system has been stopped.");
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.Start:
                        {
                            if (e.Length == 1)
                            {
                                Engine.Start();

                                mobile.SendMessage("The time system has been started.");
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.Restart:
                        {
                            if (e.Length == 1)
                            {
                                if (Data.Enabled)
                                {
                                    Engine.Restart();

                                    mobile.SendMessage("The time system has been restarted.");
                                }
                                else
                                {
                                    mobile.SendMessage(String.Format("The time system has been stopped.  To start it again, please type {0}{1} {2}", CommandSystem.Prefix, TSCommand, Command.Start.ToString().ToUpper()));
                                }
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.Load:
                        {
                            if (e.Length == 1)
                            {
                                if (Data.Load())
                                {
                                    mobile.SendMessage("The time system has been successfully loaded from file.");

                                    Engine.Restart();
                                }
                                else
                                {
                                    mobile.SendMessage("The time system has failed to load from file!");
                                }
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.Save:
                        {
                            if (e.Length == 1)
                            {
                                if (Data.Save())
                                {
                                    mobile.SendMessage("The time system has been successfully saved to file.");
                                }
                                else
                                {
                                    mobile.SendMessage("The time system has failed to save to file!");
                                }
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.SetTime:
                        {
                            bool success = false;

                            if (e.Length == 2)
                            {
                                string value = e.GetString(1);

                                string[] timeSplit = value.Split(':');

                                if (timeSplit.Length == 2)
                                {
                                    VariableObject hourObject = new VariableObject();
                                    VariableObject minuteObject = new VariableObject();

                                    string hour = timeSplit[0];
                                    string minute = timeSplit[1];

                                    hourObject = Config.SetVariable("hour", hour, false, false);
                                    minuteObject = Config.SetVariable("minute", minute, false, false);

                                    mobile.SendMessage(hourObject.Message);
                                    mobile.SendMessage(minuteObject.Message);

                                    if (hourObject.Success || minuteObject.Success)
                                    {
                                        success = true;

                                        Engine.Restart();
                                    }
                                }
                            }

                            if (!success)
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.Query:
                        {
                            if (e.Length == 1)
                            {
                                if (Data.Enabled)
                                {
                                    int gameMinutes = Data.MinutesPerTick;
                                    double perSeconds = Data.TimerSpeed;

                                    mobile.SendMessage(String.Format("The time system is running at {0} game minute{1} every {2} real second{3}.", gameMinutes, gameMinutes == 1 ? "" : "s", perSeconds, perSeconds == 1.0 ? "" : "s"));
                                }
                                else
                                {
                                    mobile.SendMessage("The time system is not running.");
                                }
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.Version:
                        {
                            if (e.Length == 1)
                            {
                                mobile.SendMessage(String.Format("The time system version is {0}.", Data.Version));
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.ConvertLampPosts:
                        {
                            if (e.Length == 2)
                            {
                                string cmd = e.GetString(1).ToLower();

                                switch (cmd)
                                {
                                    case "all": { Support.ConvertLampPosts(mobile); break; }
                                    case "area": { BoundingBoxPicker.Begin(mobile, new BoundingBoxCallback(Support.ConvertLampPosts_Callback), null); break; }
                                    default: { mobile.SendMessage(Syntax.GetSyntax(true, command)); break; }
                                }
                            }
                            else if (e.Length == 1)
                            {
                                Support.ConvertLampPost(mobile);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.AddMonth:
                        {
                            if (e.Length == 3)
                            {
                                string monthName = e.GetString(1);
                                string monthDays = e.GetString(2);

                                vo = Custom.AddMonth(monthName, monthDays);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.InsertMonth:
                        {
                            if (e.Length == 4)
                            {
                                string index = e.GetString(1);
                                string monthName = e.GetString(2);
                                string monthDays = e.GetString(3);

                                vo = Custom.InsertMonth(index, monthName, monthDays);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.SetMonth:
                        {
                            if (e.Length == 4)
                            {
                                string index = e.GetString(1);
                                string monthName = e.GetString(2);
                                string monthDays = e.GetString(3);

                                vo = Custom.SetMonth(index, monthName, monthDays);

                                mobile.SendMessage(vo.Message);
                            }
                            else if (e.Length == 2)
                            {
                                string arg = e.GetString(1).ToLower();

                                if (arg == "defaults")
                                {
                                    Config.SetDefaultMonths();

                                    mobile.SendMessage("All custom month's have been set to defaults.");
                                }
                                else
                                {
                                    mobile.SendMessage(Syntax.GetSyntax(true, command));
                                }
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.GetMonth:
                        {
                            if (e.Length == 2)
                            {
                                string index = e.GetString(1);

                                vo = Custom.GetMonth(index);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.RemoveMonth:
                        {
                            if (e.Length == 2)
                            {
                                string index = e.GetString(1);

                                vo = Custom.RemoveMonth(index);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.SetMonthProps:
                        {
                            if (e.Length == 3)
                            {
                                string index = e.GetString(1);
                                string monthDays = e.GetString(2);

                                vo = Custom.SetMonthProps(index, monthDays);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.ClearMonths:
                        {
                            if (e.Length == 1)
                            {
                                Custom.ClearMonths();

                                mobile.SendMessage("All custom months have been cleared.");
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.AddMoon:
                        {
                            if (e.Length == 3 || e.Length == 4)
                            {
                                string moonName = e.GetString(1);
                                string moonTotalDays = e.GetString(2);
                                string moonCurrentDay = null;

                                if (e.Length == 4)
                                {
                                    moonCurrentDay = e.GetString(3);
                                }

                                vo = Custom.AddMoon(moonName, moonTotalDays, moonCurrentDay);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.InsertMoon:
                        {
                            if (e.Length == 4 || e.Length == 5)
                            {
                                string index = e.GetString(1);
                                string moonName = e.GetString(2);
                                string moonTotalDays = e.GetString(3);
                                string moonCurrentDay = null;

                                if (e.Length == 5)
                                {
                                    moonCurrentDay = e.GetString(4);
                                }

                                vo = Custom.InsertMoon(index, moonName, moonTotalDays, moonCurrentDay);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.SetMoon:
                        {
                            if (e.Length == 4 || e.Length == 5)
                            {
                                string index = e.GetString(1);
                                string moonName = e.GetString(2);
                                string moonTotalDays = e.GetString(3);
                                string moonCurrentDay = null;

                                if (e.Length == 5)
                                {
                                    moonCurrentDay = e.GetString(4);
                                }

                                vo = Custom.SetMoon(index, moonName, moonTotalDays, moonCurrentDay);

                                mobile.SendMessage(vo.Message);
                            }
                            else if (e.Length == 2)
                            {
                                string arg = e.GetString(1).ToLower();

                                if (arg == "defaults")
                                {
                                    Config.SetDefaultMoons();

                                    mobile.SendMessage("All custom moon's have been set to defaults.");
                                }
                                else
                                {
                                    mobile.SendMessage(Syntax.GetSyntax(true, command));
                                }
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.GetMoon:
                        {
                            if (e.Length == 2)
                            {
                                string index = e.GetString(1);

                                vo = Custom.GetMoon(index);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.RemoveMoon:
                        {
                            if (e.Length == 2)
                            {
                                string index = e.GetString(1);

                                vo = Custom.RemoveMoon(index);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.SetMoonProps:
                        {
                            if (e.Length == 3 || e.Length == 4)
                            {
                                string index = e.GetString(1);
                                string moonCurrentDay = e.GetString(2);
                                string moonTotalDays = null;

                                if (e.Length == 4)
                                {
                                    moonTotalDays = e.GetString(3);
                                }

                                vo = Custom.SetMoonProps(index, moonCurrentDay, moonTotalDays);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.ClearMoons:
                        {
                            if (e.Length == 1)
                            {
                                Data.MoonsArray = new List<MoonPropsObject>();

                                mobile.SendMessage("All custom moons have been cleared.");
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.SetFacetAdjust:
                        {
                            if (e.Length == 2)
                            {
                                string arg = e.GetString(1).ToLower();

                                if (arg == "defaults")
                                {
                                    Config.SetDefaultFacetAdjustments();

                                    mobile.SendMessage("All facet adjustments have been set to defaults.");
                                }
                                else
                                {
                                    mobile.SendMessage(Syntax.GetSyntax(true, command));
                                }
                            }
                            else if (e.Length == 3)
                            {
                                string index = e.GetString(1);
                                string adjustment = e.GetString(2);

                                vo = Custom.SetFacetAdjust(index, adjustment);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.GetFacetAdjust:
                        {
                            if (e.Length == 2)
                            {
                                string index = e.GetString(1);

                                vo = Custom.GetFacetAdjust(index);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.AddEmo:
                        {
                            if (e.Length == 1)
                            {
                                vo = Custom.AddEmo(mobile);

                                Support.SendStream(mobile, vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.SetEmo:
                        {
                            if (e.Length == 2 && e.GetString(1) == "??")
                            {
                                StringBuilder sb = new StringBuilder();

                                sb.Append("List of EMO types:\n");

                                sb.Append(Support.GetEmoTypeNames());

                                Support.SendStream(mobile, sb.ToString());
                            }
                            else if (e.Length == 4 || e.Length == 5)
                            {
                                string index = e.GetString(1);
                                string type = e.GetString(2);
                                string valueOne = e.GetString(3);
                                string valueTwo = e.Length == 5 ? e.GetString(4) : null;

                                if (!Support.CheckEmoType(type))
                                {
                                    mobile.SendMessage("That EMO type does not exist!");
                                }
                                else
                                {
                                    vo = Custom.SetEmo(index, type, valueOne, valueTwo);

                                    mobile.SendMessage(vo.Message);
                                }
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.GetEmo:
                        {
                            string index = null;
                            
                            if (e.Length == 1 || e.Length == 2)
                            {
                                if (e.Length == 2)
                                {
                                    index = e.GetString(1);

                                    if (index.ToLower() == "total")
                                    {
                                        mobile.SendMessage("Total EMOs: {0}", Data.EffectsMapArray.Count);

                                        break;
                                    }
                                }

                                vo = Custom.GetEmo(mobile, index);

                                Support.SendStream(mobile, vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.RemoveEmo:
                        {
                            if (e.Length == 2)
                            {
                                string index = e.GetString(1);

                                vo = Custom.RemoveEmo(index);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.ToggleEmo:
                        {
                            if (e.Length == 2)
                            {
                                string index = e.GetString(1);

                                vo = Custom.ToggleEmo(index);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.AddEemo:
                        {
                            if (e.Length == 1)
                            {
                                vo = Custom.AddEemo(mobile);

                                Support.SendStream(mobile, vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.SetEemo:
                        {
                            if (e.Length == 2 && e.GetString(1) == "??")
                            {
                                StringBuilder sb = new StringBuilder();

                                sb.Append("List of EEMO types:\n");

                                sb.Append(Support.GetEemoTypeNames());

                                Support.SendStream(mobile, sb.ToString());
                            }
                            else if (e.Length == 4 || e.Length == 5)
                            {
                                string index = e.GetString(1);
                                string type = e.GetString(2);
                                string valueOne = e.GetString(3);
                                string valueTwo = e.Length == 5 ? e.GetString(4) : null;

                                if (!Support.CheckEemoType(type))
                                {
                                    mobile.SendMessage("That EEMO type does not exist!");
                                }
                                else
                                {
                                    vo = Custom.SetEemo(index, type, valueOne, valueTwo);

                                    mobile.SendMessage(vo.Message);
                                }
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.GetEemo:
                        {
                            string index = null;

                            if (e.Length == 1 || e.Length == 2)
                            {
                                if (e.Length == 2)
                                {
                                    index = e.GetString(1);

                                    if (index.ToLower() == "total")
                                    {
                                        mobile.SendMessage("Total EEMOs: {0}", Data.EffectsExclusionMapArray.Count);

                                        break;
                                    }
                                }

                                vo = Custom.GetEemo(mobile, index);

                                Support.SendStream(mobile, vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.RemoveEemo:
                        {
                            if (e.Length == 2)
                            {
                                string index = e.GetString(1);

                                vo = Custom.RemoveEemo(index);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    case Command.ToggleEemo:
                        {
                            if (e.Length == 2)
                            {
                                string index = e.GetString(1);

                                vo = Custom.ToggleEemo(index);

                                mobile.SendMessage(vo.Message);
                            }
                            else
                            {
                                mobile.SendMessage(Syntax.GetSyntax(true, command));
                            }

                            break;
                        }
                    default:
                        {
                            mobile.SendMessage("That command does not exist!");

                            break;
                        }
                }
            }
            else
            {
                Support.SendCommandNames(mobile);
            }
        }
示例#21
0
        public static VariableObject SetMonthProps(string index, string setMonthDays)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Custom Months"))
            {
                return vo;
            }

            if (Data.MonthsArray.Count == 0)
            {
                vo.Success = false;
                vo.Message = "There are no custom months!";

                return vo;
            }

            lock (Data.MonthsArray)
            {
                int monthIndex = 0;

                string monthName = null;
                int newMonthDays = 0;

                bool success = false;
                string message = null;

                {
                    object o = Support.GetValue(index);

                    if (o is string)
                    {
                        for (int i = 0; i < Data.MonthsArray.Count; i++)
                        {
                            MonthPropsObject mpo = Data.MonthsArray[i];

                            if (mpo.Name.ToLower() == index.ToLower())
                            {
                                o = Support.GetValue((i + 1).ToString());

                                break;
                            }
                        }
                    }

                    if (Config.CheckVariable(o, "Number", 1, Data.MonthsArray.Count, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        monthIndex = value - 1;

                        index = value.ToString();

                        MonthPropsObject mpo = Data.MonthsArray[monthIndex];

                        monthName = mpo.Name;
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();

                        sb.Append(message);
                        sb.Append("\r\nYou may also specify the month name instead of the number.");

                        message = sb.ToString();
                    }
                }

                if (success)
                {
                    object o = Support.GetValue(setMonthDays);

                    if (Config.CheckVariable(o, "Days", 1, int.MaxValue, typeof(int), ref success, ref message))
                    {
                        int value = (int)o;

                        newMonthDays = value;
                    }
                }

                if (success)
                {
                    MonthPropsObject mpo = new MonthPropsObject(monthName, newMonthDays);

                    Data.MonthsArray[monthIndex] = mpo;

                    message = String.Format("Month #{0} '{1}' has been set with '{2}' day{3}.", index, monthName, newMonthDays, newMonthDays == 1 ? "" : "s");

                    Engine.Restart();
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }
示例#22
0
        public static VariableObject SetVariable(string variableName, string variableValue, bool restart, bool append)
        {
            VariableObject vo = new VariableObject();
            Variable variable = Support.GetVariableFromName(variableName);

            if (Data.ForceScriptSettings)
            {
                bool allowed = true;

                switch (variable)
                {
                    case Variable.Defaults: { break; }
                    case Variable.Year: { break; }
                    case Variable.Month: { break; }
                    case Variable.Day: { break; }
                    case Variable.Hour: { break; }
                    case Variable.Minute: { break; }
                    default: { allowed = false; break; }
                }

                if (!allowed && Support.CheckForceScriptSettings(ref vo, variable.ToString()))
                {
                    return vo;
                }
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            object o = Support.GetValue(variableValue);

            bool success = false;
            string minValue = null;
            string maxValue = null;
            string message = null;

            switch (variable)
            {
                case Variable.Defaults:
                    {
                        SetDefaults(true);

                        vo.Success = true;
                        vo.Message = "The time system has been reset to its default configuration.";

                        return vo;
                    }
                case Variable.Logging:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.Logging = (bool)o;
                        }

                        break;
                    }
                case Variable.TimerSpeed:
                    {
                        if (o is int)
                        {
                            o = Convert.ToDouble(o);
                        }

                        if (CheckVariable(o, variable, (double)Data.MinTimerValue, (double)Data.MinutesPerHour, typeof(double), ref success, ref message))
                        {
                            Data.TimerSpeed = (double)o;
                        }

                        break;
                    }
                case Variable.MinutesPerTick:
                    {
                        if (CheckVariable(o, variable, 1, Data.MinutesPerHour, typeof(int), ref success, ref message))
                        {
                            Data.MinutesPerTick = (int)o;
                        }

                        break;
                    }
                case Variable.LightsEngineTimerSpeed:
                    {
                        if (o is int)
                        {
                            o = Convert.ToDouble(o);
                        }

                        if (CheckVariable(o, variable, (double)Data.MinTimerValue, (double)Data.MinutesPerHour, typeof(double), ref success, ref message))
                        {
                            Data.LightsEngineTimerSpeed = (double)o;
                        }

                        break;
                    }
                case Variable.UpdateInterval:
                    {
                        if (CheckVariable(o, variable, Data.MinUpdateInterval, Data.MaxUpdateInterval, typeof(int), ref success, ref message))
                        {
                            Data.UpdateInterval = (int)o;
                        }

                        break;
                    }
                case Variable.DayLevel:
                    {
                        if (CheckVariable(o, variable, Data.MinLightLevel, Data.NightLevel - Data.MinLightLevelDifference, typeof(int), ref success, ref message))
                        {
                            Data.DayLevel = (int)o;
                        }

                        break;
                    }
                case Variable.NightLevel:
                    {
                        int highValue = Data.MaxLightLevel;

                        if (Data.UseDarkestHour)
                        {
                            highValue = Data.DarkestHourLevel - Data.MinDarkestHourNightLevelDifference;
                        }

                        if (CheckVariable(o, variable, Data.DayLevel + Data.MinLightLevelDifference, highValue, typeof(int), ref success, ref message))
                        {
                            Data.NightLevel = (int)o;
                        }

                        break;
                    }
                case Variable.DarkestHourLevel:
                    {
                        if (CheckVariable(o, variable, Data.NightLevel + Data.MinDarkestHourNightLevelDifference, Data.MaxLightLevel, typeof(int), ref success, ref message))
                        {
                            Data.DarkestHourLevel = (int)o;
                        }

                        break;
                    }
                case Variable.LightsOnLevel:
                    {
                        if (CheckVariable(o, variable, Data.MinLightLevel, Data.MaxLightLevel, typeof(int), ref success, ref message))
                        {
                            Data.LightsOnLevel = (int)o;
                        }

                        break;
                    }
                case Variable.MoonLevelAdjust:
                    {
                        if (CheckVariable(o, variable, Data.MinLightLevel, Data.NightLevel, typeof(int), ref success, ref message))
                        {
                            Data.MoonLevelAdjust = (int)o;
                        }

                        break;
                    }
                case Variable.MinutesPerHour:
                    {
                        if (CheckVariable(o, variable, Data.MinMinutesPerHour, Data.MaxMinutesPerHour, typeof(int), ref success, ref message))
                        {
                            Data.MinutesPerHour = (int)o;
                        }

                        break;
                    }
                case Variable.HoursPerDay:
                    {
                        if (CheckVariable(o, variable, Data.MinHoursPerDay, Data.MaxHoursPerDay, typeof(int), ref success, ref message))
                        {
                            Data.HoursPerDay = (int)o;

                            if (Data.NightStartHour > Data.HoursPerDay)
                            {
                                Data.NightStartHour = 0;
                            }

                            if (Data.DayStartHour > Data.HoursPerDay)
                            {
                                Data.DayStartHour = 4;
                            }
                        }

                        break;
                    }
                case Variable.NightStartHour:
                    {
                        Type typeExpected = typeof(int);

                        int lowValue = 0;
                        int highValue = Data.HoursPerDay - 1;

                        minValue = Convert.ToString(lowValue);
                        maxValue = Convert.ToString(highValue);

                        if (o is int)
                        {
                            int value = (int)o;

                            if (value >= lowValue && value <= highValue)
                            {
                                bool overNight = false;

                                int beforeDayStartHour = Data.DayStartHour - Data.MinDayNightHoursDifference;
                                int afterDayStartHour = Data.DayStartHour + Data.MinDayNightHoursDifference;

                                if (Data.NightStartMinute < Data.DayStartMinute)
                                {
                                    afterDayStartHour++;
                                }
                                else if (Data.DayStartMinute < Data.NightStartMinute)
                                {
                                    beforeDayStartHour--;
                                }

                                if (beforeDayStartHour < 0)
                                {
                                    overNight = true;

                                    beforeDayStartHour += Data.HoursPerDay;
                                }

                                if (afterDayStartHour >= Data.HoursPerDay)
                                {
                                    overNight = true;

                                    afterDayStartHour -= Data.HoursPerDay;
                                }

                                if (overNight)
                                {
                                    if (beforeDayStartHour > afterDayStartHour)
                                    {
                                        lowValue = afterDayStartHour;
                                        highValue = beforeDayStartHour;
                                    }
                                    else
                                    {
                                        lowValue = beforeDayStartHour;
                                        highValue = afterDayStartHour;
                                    }

                                    if (value >= lowValue && value <= highValue)
                                    {
                                        success = true;

                                        Data.NightStartHour = value;
                                    }
                                    else
                                    {
                                        message = Formatting.ErrorMessageFormatter(variable.ToString(), value, lowValue.ToString(), highValue.ToString());
                                    }
                                }
                                else
                                {
                                    if (value <= beforeDayStartHour || value >= afterDayStartHour)
                                    {
                                        success = true;

                                        Data.NightStartHour = value;
                                    }
                                    else
                                    {
                                        message = Formatting.ErrorMessageFormatter(variable.ToString(), value, "0", beforeDayStartHour.ToString(), afterDayStartHour.ToString(), Data.HoursPerDay.ToString());
                                    }
                                }
                            }
                            else
                            {
                                message = Formatting.ErrorMessageFormatter(variable.ToString(), value, minValue, maxValue);
                            }
                        }
                        else
                        {
                            message = Formatting.ErrorMessageFormatter(variable.ToString(), o, minValue, maxValue, typeExpected);
                        }

                        break;
                    }
                case Variable.NightStartMinute:
                    {
                        int lowValue = 0;
                        int highValue = Data.MinutesPerHour - 1;

                        if (Data.NightHours == Data.MinDayNightHoursDifference)
                        {
                            highValue = Data.DayStartMinute;
                        }
                        else if (Data.DayHours == Data.MinDayNightHoursDifference)
                        {
                            lowValue = Data.DayStartMinute;
                        }

                        int nightMinutesMinusDarkestHour = Data.NightMinutes - (Data.DarkestHourStartMinutes + Data.DarkestHourTotalMinutes);

                        if (highValue > nightMinutesMinusDarkestHour)
                        {
                            highValue = nightMinutesMinusDarkestHour;
                        }

                        if (CheckVariable(o, variable, lowValue, highValue, typeof(int), ref success, ref message))
                        {
                            Data.NightStartMinute = (int)o;
                        }

                        break;
                    }
                case Variable.DayStartHour:
                    {
                        Type typeExpected = typeof(int);

                        int lowValue = 0;
                        int highValue = Data.HoursPerDay - 1;

                        minValue = Convert.ToString(lowValue);
                        maxValue = Convert.ToString(highValue);

                        if (o is int)
                        {
                            int value = (int)o;

                            if (value >= lowValue && value <= highValue)
                            {
                                bool overNight = false;

                                int beforeNightStartHour = Data.NightStartHour - Data.MinDayNightHoursDifference;
                                int afterNightStartHour = Data.NightStartHour + Data.MinDayNightHoursDifference;

                                if (Data.DayStartMinute < Data.NightStartMinute)
                                {
                                    afterNightStartHour++;
                                }
                                else if (Data.NightStartMinute < Data.DayStartMinute)
                                {
                                    beforeNightStartHour--;
                                }

                                if (beforeNightStartHour < 0)
                                {
                                    overNight = true;

                                    beforeNightStartHour += Data.HoursPerDay;
                                }

                                if (afterNightStartHour >= Data.HoursPerDay)
                                {
                                    overNight = true;

                                    afterNightStartHour -= Data.HoursPerDay;
                                }

                                if (overNight)
                                {
                                    if (beforeNightStartHour > afterNightStartHour)
                                    {
                                        lowValue = afterNightStartHour;
                                        highValue = beforeNightStartHour;
                                    }
                                    else
                                    {
                                        lowValue = beforeNightStartHour;
                                        highValue = afterNightStartHour;
                                    }

                                    if (value >= lowValue && value <= highValue)
                                    {
                                        success = true;

                                        Data.DayStartHour = value;
                                    }
                                    else
                                    {
                                        message = Formatting.ErrorMessageFormatter(variable.ToString(), value, lowValue.ToString(), highValue.ToString());
                                    }
                                }
                                else
                                {
                                    if (value <= beforeNightStartHour || value >= afterNightStartHour)
                                    {
                                        success = true;

                                        Data.DayStartHour = value;
                                    }
                                    else
                                    {
                                        message = Formatting.ErrorMessageFormatter(variable.ToString(), value, "0", beforeNightStartHour.ToString(), afterNightStartHour.ToString(), Data.HoursPerDay.ToString());
                                    }
                                }
                            }
                            else
                            {
                                message = Formatting.ErrorMessageFormatter(variable.ToString(), value, minValue, maxValue);
                            }
                        }
                        else
                        {
                            message = Formatting.ErrorMessageFormatter(variable.ToString(), o, minValue, maxValue, typeExpected);
                        }

                        break;
                    }
                case Variable.DayStartMinute:
                    {
                        int lowValue = 0;
                        int highValue = Data.MinutesPerHour - 1;

                        if (Data.NightHours == Data.MinDayNightHoursDifference)
                        {
                            lowValue = Data.NightStartMinute;
                        }
                        else if (Data.DayHours == Data.MinDayNightHoursDifference)
                        {
                            highValue = Data.NightStartMinute;
                        }

                        if (CheckVariable(o, variable, lowValue, highValue, typeof(int), ref success, ref message))
                        {
                            Data.DayStartMinute = (int)o;
                        }

                        break;
                    }
                case Variable.ScaleTimeMinutes:
                    {
                        int highValue = Data.MinutesPerHour * Data.HoursPerDay;

                        if (Data.NightMinutes <= Data.DayMinutes)
                        {
                            highValue = Data.DayMinutes - Data.NightMinutes;
                        }
                        else
                        {
                            highValue = Data.NightMinutes - Data.DayMinutes;
                        }

                        if (CheckVariable(o, variable, 0, highValue, typeof(int), ref success, ref message))
                        {
                            Data.ScaleTimeMinutes = (int)o;
                        }

                        break;
                    }
                case Variable.Minute:
                    {
                        if (CheckVariable(o, variable, 0, Data.MinutesPerHour - 1, typeof(int), ref success, ref message))
                        {
                            Data.Minute = (int)o;
                        }

                        break;
                    }
                case Variable.Hour:
                    {
                        if (CheckVariable(o, variable, 0, Data.HoursPerDay - 1, typeof(int), ref success, ref message))
                        {
                            Data.Hour = (int)o;
                        }

                        break;
                    }
                case Variable.Day:
                    {
                        MonthPropsObject mpo = Data.MonthsArray[Data.Month - 1];

                        if (CheckVariable(o, variable, 1, mpo.TotalDays, typeof(int), ref success, ref message))
                        {
                            Data.Day = (int)o;
                        }

                        break;
                    }
                case Variable.Month:
                    {
                        if (CheckVariable(o, variable, 1, Data.MonthsArray.Count, typeof(int), ref success, ref message))
                        {
                            Data.Month = (int)o;
                        }

                        break;
                    }
                case Variable.Year:
                    {
                        if (CheckVariable(o, variable, 0, int.MaxValue, typeof(int), ref success, ref message))
                        {
                            Data.Year = (int)o;
                        }

                        break;
                    }
                case Variable.UseDarkestHour:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseDarkestHour = (bool)o;
                        }

                        break;
                    }
                case Variable.DarkestHourMinutesAfterNight:
                    {
                        if (CheckVariable(o, variable, 0, Data.NightMinutes - Data.DarkestHourTotalMinutes, typeof(int), ref success, ref message))
                        {
                            Data.DarkestHourMinutesAfterNight = (int)o;
                        }

                        break;
                    }
                case Variable.DarkestHourScaleTimeMinutes:
                    {
                        int highValue = Convert.ToInt32((((double)Data.NightMinutes - Data.DarkestHourLength) / 2.0) - Data.DarkestHourMinutesAfterNight);

                        if (CheckVariable(o, variable, 0, highValue, typeof(int), ref success, ref message))
                        {
                            Data.DarkestHourScaleTimeMinutes = (int)o;
                        }

                        break;
                    }
                case Variable.DarkestHourLength:
                    {
                        int highValue = Data.NightMinutes - (Data.ScaleTimeMinutes * 2) - Data.DarkestHourMinutesAfterNight;

                        if (CheckVariable(o, variable, 0, highValue, typeof(int), ref success, ref message))
                        {
                            Data.DarkestHourLength = (int)o;
                        }

                        break;
                    }
                case Variable.UseRealTime:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseRealTime = (bool)o;
                        }

                        break;
                    }
                case Variable.UseTimeZones:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseTimeZones = (bool)o;
                        }

                        break;
                    }
                case Variable.TimeZoneXDivisor:
                    {
                        if (CheckVariable(o, variable, Data.MinTimeZoneXDivisor, Data.MaxTimeZoneXDivisor, typeof(int), ref success, ref message))
                        {
                            Data.TimeZoneXDivisor = (int)o;
                        }

                        break;
                    }
                case Variable.TimeZoneScaleMinutes:
                    {
                        if (CheckVariable(o, variable, Data.MinTimeZoneScaleMinutes, Data.MaxTimeZoneScaleMinutes, typeof(int), ref success, ref message))
                        {
                            Data.TimeZoneScaleMinutes = (int)o;
                        }

                        break;
                    }
                case Variable.UseAutoLighting:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseAutoLighting = (bool)o;
                        }

                        break;
                    }
                case Variable.UseRandomLightOutage:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseRandomLightOutage = (bool)o;
                        }

                        break;
                    }
                case Variable.UseSeasons:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseSeasons = (bool)o;
                        }

                        break;
                    }
                case Variable.UseNightSightDarkestHourOverride:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseNightSightDarkestHourOverride = (bool)o;
                        }

                        break;
                    }
                case Variable.UseNightSightOverride:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseNightSightOverride = (bool)o;
                        }

                        break;
                    }
                case Variable.UseLightLevelOverride:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseLightLevelOverride = (bool)o;
                        }

                        break;
                    }
                case Variable.UseMurdererDarkestHourBonus:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            Data.UseMurdererDarkestHourBonus = (bool)o;
                        }

                        break;
                    }
                case Variable.UseEvilSpawners:
                    {
                        if (CheckVariable(o, variable, false, true, typeof(bool), ref success, ref message))
                        {
                            bool enabled = (bool)o;

                            if (!enabled && Data.UseEvilSpawners)
                            {
                                EffectsEngine.TurnOffAllEvilSpawners();
                            }

                            Data.UseEvilSpawners = enabled;
                        }

                        break;
                    }
                case Variable.TimeFormat:
                    {
                        Type typeExpected = typeof(string);

                        if (variableValue != null)
                        {
                            switch (variableValue.ToLower())
                            {
                                case "preset1": { variableValue = String.Format("{0} {1}", Data.TimeFormatPreset1, Data.TimeFormatMoonPhase); break; }
                                case "preset2": { variableValue = String.Format("{0} {1}", Data.TimeFormatPreset2, Data.TimeFormatMoonPhase); break; }
                                case "preset3": { variableValue = String.Format("{0} {1}", Data.TimeFormatPreset3, Data.TimeFormatMoonPhase); break; }
                                case "preset4": { variableValue = String.Format("{0} {1}", Data.TimeFormatPreset4, Data.TimeFormatMoonPhase); break; }
                                case "preset5": { variableValue = String.Format("{0} {1}", Data.TimeFormatPreset5, Data.TimeFormatMoonPhase); break; }
                                case "preset6": { variableValue = String.Format("{0} {1}", Data.TimeFormatPreset6, Data.TimeFormatMoonPhase); break; }
                            }

                            variableValue = variableValue.Replace('$', Formatting.CodeChar);

                            if (append)
                            {
                                Data.TimeFormat = String.Format("{0}{1}", Data.TimeFormat, variableValue);
                            }
                            else
                            {
                                Data.TimeFormat = variableValue;
                            }

                            success = true;
                        }
                        else
                        {
                            message = Formatting.ErrorMessageFormatter(variable.ToString().ToString(), o, typeExpected);
                        }

                        break;
                    }
                case Variable.ClockTimeFormat:
                    {
                        Type typeExpected = typeof(string);

                        if (variableValue != null)
                        {
                            switch (variableValue.ToLower())
                            {
                                case "preset1": { variableValue = Data.TimeFormatPreset1; break; }
                                case "preset2": { variableValue = Data.TimeFormatPreset2; break; }
                                case "preset3": { variableValue = Data.TimeFormatPreset3; break; }
                                case "preset4": { variableValue = Data.TimeFormatPreset4; break; }
                                case "preset5": { variableValue = Data.TimeFormatPreset5; break; }
                                case "preset6": { variableValue = Data.TimeFormatPreset6; break; }
                            }

                            variableValue = variableValue.Replace('$', Formatting.CodeChar);

                            if (append)
                            {
                                Data.ClockTimeFormat = String.Format("{0}{1}", Data.ClockTimeFormat, variableValue);
                            }
                            else
                            {
                                Data.ClockTimeFormat = variableValue;
                            }

                            success = true;
                        }
                        else
                        {
                            message = Formatting.ErrorMessageFormatter(variable.ToString().ToString(), o, typeExpected);
                        }

                        break;
                    }
                case Variable.SpyglassFormat:
                    {
                        Type typeExpected = typeof(string);

                        if (variableValue != null)
                        {
                            switch (variableValue.ToLower())
                            {
                                case "preset1": { variableValue = Data.SpyglassFormatPreset1; break; }
                            }

                            variableValue = variableValue.Replace('$', Formatting.CodeChar);

                            if (append)
                            {
                                Data.SpyglassFormat = String.Format("{0}{1}", Data.SpyglassFormat, variableValue);
                            }
                            else
                            {
                                Data.SpyglassFormat = variableValue;
                            }

                            success = true;
                        }
                        else
                        {
                            message = Formatting.ErrorMessageFormatter(variable.ToString().ToString(), o, typeExpected);
                        }

                        break;
                    }
                default:
                    {
                        message = "That variable type does not exist!";

                        break;
                    }
            }

            if (success)
            {
                message = Formatting.VariableMessageFormatter(variable.ToString(), variableValue, append);

                if (restart)
                {
                    Engine.Restart();
                }
            }

            vo.Success = success;
            vo.Message = message;

            return vo;
        }
示例#23
0
        public static VariableObject ToggleEemo(string index)
        {
            VariableObject vo = new VariableObject();

            if (Support.CheckForceScriptSettings(ref vo, "Toggle EffectsExclusionMapObject"))
            {
                return vo;
            }

            if (Data.DataFileInUse)
            {
                vo.Success = false;
                vo.Message = Data.DataFileInUseMessage;

                return vo;
            }

            if (Data.EffectsExclusionMapArray.Count == 0)
            {
                vo.Success = false;
                vo.Message = "There are no EffectsExclusionMapObjects!";

                return vo;
            }

            lock (Data.EffectsExclusionMapArray)
            {
                bool success = false;
                string message = null;

                object o = Support.GetValue(index);

                Type typeExpected = typeof(int);

                int lowValue = 0;
                int highValue = Data.EffectsExclusionMapArray.Count - 1;

                string minValue = Convert.ToString(lowValue);
                string maxValue = Convert.ToString(highValue);

                if (o is int)
                {
                    int value = (int)o;

                    if (value >= lowValue && value <= highValue)
                    {
                        bool enabled = Data.EffectsExclusionMapArray[value].Enabled;

                        Data.EffectsExclusionMapArray[value].Enabled = !enabled;

                        message = String.Format("EEMO #{0} has been {1}.", value, !enabled ? "enabled" : "disabled");
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();

                        sb.Append(Formatting.ErrorMessageFormatter("EEMO Number", o, minValue, maxValue));

                        message = sb.ToString();
                    }
                }
                else
                {
                    StringBuilder sb = new StringBuilder();

                    sb.Append(Formatting.ErrorMessageFormatter("EEMO Number", o, minValue, maxValue, typeExpected));

                    message = sb.ToString();
                }

                vo.Success = success;
                vo.Message = message;
            }

            return vo;
        }