using Server.MirEnvir; using Server.MirObjects; namespace Server.MirDatabase { public class BuffInfo { public BuffType Type { get; set; } public BuffStackType StackType { get; set; } public BuffProperty Properties { get; set; } public int Icon { get; set; } public bool Visible { get; set; } public static List Load() { List info = new List { //Magics new BuffInfo { Type = BuffType.TemporalFlux, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.Hiding, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.Haste, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.SwiftFeet, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.Fury, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.SoulShield, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.BlessedArmour, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.LightBody, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.UltimateEnhancer, Properties = BuffProperty.None, StackType = BuffStackType.ResetStatAndDuration }, new BuffInfo { Type = BuffType.ProtectionField, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.Rage, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.Curse, Properties = BuffProperty.RemoveOnDeath | BuffProperty.Debuff, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.MoonLight, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.DarkBody, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.Concentration, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.VampireShot, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.PoisonShot, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.CounterAttack, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.MentalState, Properties = BuffProperty.None, StackType = BuffStackType.Infinite }, new BuffInfo { Type = BuffType.EnergyShield, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.MagicBooster, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.PetEnhancer, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.ImmortalSkin, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.MagicShield, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.ElementalBarrier, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, //Monsters new BuffInfo { Type = BuffType.HornedArcherBuff, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.ColdArcherBuff, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.GeneralMeowMeowShield, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.RhinoPriestDebuff, Properties = BuffProperty.Debuff, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.PowerBeadBuff, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.HornedWarriorShield, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.HornedCommanderShield, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration, Visible = true }, new BuffInfo { Type = BuffType.Blindness, Properties = BuffProperty.RemoveOnDeath | BuffProperty.Debuff, StackType = BuffStackType.ResetDuration }, //Special new BuffInfo { Type = BuffType.GameMaster, Properties = BuffProperty.None, StackType = BuffStackType.Infinite, Visible = Settings.GameMasterEffect }, new BuffInfo { Type = BuffType.Mentee, Properties = BuffProperty.None, StackType = BuffStackType.Infinite }, new BuffInfo { Type = BuffType.Mentor, Properties = BuffProperty.None, StackType = BuffStackType.Infinite }, new BuffInfo { Type = BuffType.Guild, Properties = BuffProperty.None, StackType = BuffStackType.Infinite }, new BuffInfo { Type = BuffType.Skill, Properties = BuffProperty.None, StackType = BuffStackType.Infinite }, new BuffInfo { Type = BuffType.ClearRing, Properties = BuffProperty.None, StackType = BuffStackType.Infinite }, new BuffInfo { Type = BuffType.Transform, Properties = BuffProperty.None, StackType = BuffStackType.None }, new BuffInfo { Type = BuffType.Lover, Properties = BuffProperty.RemoveOnExit, StackType = BuffStackType.Infinite }, new BuffInfo { Type = BuffType.Rested, Properties = BuffProperty.None, StackType = BuffStackType.ResetDuration }, new BuffInfo { Type = BuffType.Prison, Properties = BuffProperty.None, StackType = BuffStackType.None }, //??? new BuffInfo { Type = BuffType.General, Properties = BuffProperty.None, StackType = BuffStackType.None }, //??? new BuffInfo { Type = BuffType.Newbie, Properties = BuffProperty.RemoveOnExit, StackType = BuffStackType.Infinite }, //??? //Stats new BuffInfo { Type = BuffType.Exp, Properties = BuffProperty.PauseInSafeZone, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.Drop, Properties = BuffProperty.PauseInSafeZone, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.Gold, Properties = BuffProperty.PauseInSafeZone, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.BagWeight, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.Impact, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.Magic, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.Taoist, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.Storm, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.HealthAid, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.ManaAid, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.Defence, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.MagicDefence, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.WonderDrug, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration }, new BuffInfo { Type = BuffType.Knapsack, Properties = BuffProperty.None, StackType = BuffStackType.StackDuration } }; return info; } } public class Buff { protected static Envir Envir { get { return Envir.Main; } } private Dictionary Data { get; set; } = new Dictionary(); public BuffInfo Info; public MapObject Caster; public uint ObjectID; public long ExpireTime; public long LastTime, NextTime; public Stats Stats; public int[] Values; public bool FlagForRemoval; public bool Paused; public BuffType Type { get { return Info.Type; } } public BuffStackType StackType { get { return Info.StackType; } } public BuffProperty Properties { get { return Info.Properties; } } public Buff(BuffType type) { Info = Envir.GetBuffInfo(type); Stats = new Stats(); Data = new Dictionary(); } public Buff(BinaryReader reader, int version, int customVersion) { var type = (BuffType)reader.ReadByte(); Info = Envir.GetBuffInfo(type); Caster = null; if (version < 88) { var visible = reader.ReadBoolean(); } ObjectID = reader.ReadUInt32(); ExpireTime = reader.ReadInt64(); if (version <= 84) { Values = new int[reader.ReadInt32()]; for (int i = 0; i < Values.Length; i++) { Values[i] = reader.ReadInt32(); } if (version < 88) { var infinite = reader.ReadBoolean(); } Stats = new Stats(); Data = new Dictionary(); } else { if (version < 88) { var stackable = reader.ReadBoolean(); } Values = new int[0]; Stats = new Stats(reader, version, customVersion); Data = new Dictionary(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { var key = reader.ReadString(); var length = reader.ReadInt32(); var array = new byte[length]; for (int j = 0; j < array.Length; j++) { array[j] = reader.ReadByte(); } Data[key] = Functions.DeserializeFromBytes(array); } if (version > 86) { count = reader.ReadInt32(); Values = new int[count]; for (int i = 0; i < count; i++) { Values[i] = reader.ReadInt32(); } } } } public void Save(BinaryWriter writer) { writer.Write((byte)Type); writer.Write(ObjectID); writer.Write(ExpireTime); Stats.Save(writer); writer.Write(Data.Count); foreach (KeyValuePair pair in Data) { var bytes = Functions.SerializeToBytes(pair.Value); writer.Write(pair.Key); writer.Write(bytes.Length); for (int i = 0; i < bytes.Length; i++) { writer.Write(bytes[i]); } } writer.Write(Values.Length); for (int i = 0; i < Values.Length; i++) { writer.Write(Values[i]); } } public T Get(string key) { if (!Data.TryGetValue(key, out object result)) { return default; } return (T)result; } public void Set(string key, object val) { Data[key] = val; } public ClientBuff ToClientBuff() { return new ClientBuff { Type = Type, Caster = Caster?.Name ?? "", ObjectID = ObjectID, Visible = Info.Visible, Infinite = StackType == BuffStackType.Infinite, Paused = Paused, ExpireTime = ExpireTime, Stats = new Stats(Stats), Values = Values }; } } }