From 8c4aaeeda61ba3a998eaeefb1c1dd2e43227dd3c Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 24 Feb 2023 18:06:59 -0800 Subject: [PATCH] fix: Codegens potions and fixes a few minor bugs (#1347) --- .../Potions/Agility Potions/AgilityPotion.cs | 37 +- .../Agility Potions/BaseAgilityPotion.cs | 73 +-- .../Agility Potions/GreaterAgilityPotion.cs | 37 +- .../Skill Items/Magical/Potions/BasePotion.cs | 459 +++++++--------- .../BaseConflagrationPotion.cs | 474 ++++++++--------- .../ConflagrationPotion.cs | 42 +- .../GreaterConflagrationPotion.cs | 42 +- .../BaseConfusionBlastPotion.cs | 292 +++++----- .../ConfusionBlastPotion.cs | 40 +- .../GreaterConfusionBlastPotion.cs | 40 +- .../Potions/Cure Potions/BaseCurePotion.cs | 139 +++-- .../Potions/Cure Potions/CurePotion.cs | 66 +-- .../Potions/Cure Potions/GreaterCurePotion.cs | 85 ++- .../Potions/Cure Potions/LesserCurePotion.cs | 60 +-- .../Magical/Potions/DarkglowPotion.cs | 33 -- .../Explosion Potions/BaseExplosionPotion.cs | 499 +++++++++--------- .../Explosion Potions/ExplosionPotion.cs | 38 +- .../GreaterExplosionPotion.cs | 38 +- .../LesserExplosionPotion.cs | 38 +- .../Potions/Heal Potions/BaseHealPotion.cs | 103 ++-- .../Potions/Heal Potions/GreaterHealPotion.cs | 40 +- .../Potions/Heal Potions/HealPotion.cs | 40 +- .../Potions/Heal Potions/LesserHealPotion.cs | 40 +- .../Magical/Potions/InvisibilityPotion.cs | 144 +++-- .../Skill Items/Magical/Potions/NightSight.cs | 63 +-- .../Magical/Potions/ParasiticPotion.cs | 34 -- .../Poison Potions/BasePoisonPotion.cs | 73 ++- .../Potions/Poison Potions/DarkglowPotion.cs | 18 + .../Poison Potions/DeadlyPoisonPotion.cs | 42 +- .../Poison Potions/GreaterPoisonPotion.cs | 42 +- .../Poison Potions/LesserPoisonPotion.cs | 42 +- .../Potions/Poison Potions/ParasiticPotion.cs | 16 + .../Potions/Poison Potions/PoisonPotion.cs | 42 +- .../Refresh Potions/BaseRefreshPotion.cs | 59 +-- .../Potions/Refresh Potions/RefreshPotion.cs | 36 +- .../Refresh Potions/TotalRefreshPotion.cs | 36 +- .../Strength Potions/BaseStrengthPotion.cs | 73 +-- .../Strength Potions/GreaterStrengthPotion.cs | 37 +- .../Strength Potions/StrengthPotion.cs | 41 +- .../Server.Items.AgilityPotion.v0.json | 4 + .../Server.Items.BaseAgilityPotion.v0.json | 4 + ...seConflagrationPotion.InternalItem.v0.json | 35 ++ ...rver.Items.BaseConflagrationPotion.v0.json | 4 + ...ver.Items.BaseConfusionBlastPotion.v0.json | 4 + .../Server.Items.BaseCurePotion.v0.json | 4 + .../Server.Items.BaseExplosionPotion.v0.json | 4 + .../Server.Items.BaseHealPotion.v0.json | 4 + .../Server.Items.BasePoisonPotion.v0.json | 4 + .../Server.Items.BasePotion.v2.json | 11 + .../Server.Items.BaseRefreshPotion.v0.json | 4 + .../Server.Items.BaseStrengthPotion.v0.json | 4 + .../Server.Items.ConflagrationPotion.v0.json | 4 + .../Server.Items.ConfusionBlastPotion.v0.json | 4 + .../Server.Items.CurePotion.v0.json | 4 + .../Server.Items.DarkglowPotion.v0.json | 4 + .../Server.Items.DeadlyPoisonPotion.v0.json | 4 + .../Server.Items.ExplosionPotion.v0.json | 4 + .../Server.Items.GreaterAgilityPotion.v0.json | 4 + ...r.Items.GreaterConflagrationPotion.v0.json | 4 + ....Items.GreaterConfusionBlastPotion.v0.json | 4 + ...erver.Items.GreaterExplosionPotion.v0.json | 4 + .../Server.Items.GreaterHealPotion.v0.json | 4 + .../Server.Items.GreaterPoisonPotion.v0.json | 4 + ...Server.Items.GreaterStrengthPotion.v0.json | 4 + .../Server.Items.HealPotion.v0.json | 4 + .../Server.Items.InvisibilityPotion.v0.json | 4 + .../Server.Items.LesserCurePotion.v0.json | 4 + ...Server.Items.LesserExplosionPotion.v0.json | 4 + .../Server.Items.LesserHealPotion.v0.json | 4 + .../Server.Items.LesserPoisonPotion.v0.json | 4 + .../Server.Items.NightSightPotion.v0.json | 4 + .../Server.Items.ParasiticPotion.v0.json | 4 + .../Server.Items.PoisonPotion.v0.json | 4 + .../Server.Items.RefreshPotion.v0.json | 4 + .../Server.Items.StrengthPotion.v0.json | 4 + .../Server.Items.TotalRefreshPotion.v0.json | 4 + 76 files changed, 1644 insertions(+), 2095 deletions(-) delete mode 100644 Projects/UOContent/Items/Skill Items/Magical/Potions/DarkglowPotion.cs delete mode 100644 Projects/UOContent/Items/Skill Items/Magical/Potions/ParasiticPotion.cs create mode 100644 Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/DarkglowPotion.cs create mode 100644 Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/ParasiticPotion.cs create mode 100644 Projects/UOContent/Migrations/Server.Items.AgilityPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseAgilityPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseConflagrationPotion.InternalItem.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseConflagrationPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseConfusionBlastPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseCurePotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseExplosionPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseHealPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BasePoisonPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BasePotion.v2.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseRefreshPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.BaseStrengthPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.ConflagrationPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.ConfusionBlastPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.CurePotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.DarkglowPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.DeadlyPoisonPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.ExplosionPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.GreaterAgilityPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.GreaterConflagrationPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.GreaterConfusionBlastPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.GreaterExplosionPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.GreaterHealPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.GreaterPoisonPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.GreaterStrengthPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.HealPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.InvisibilityPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.LesserCurePotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.LesserExplosionPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.LesserHealPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.LesserPoisonPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.NightSightPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.ParasiticPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.PoisonPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.RefreshPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.StrengthPotion.v0.json create mode 100644 Projects/UOContent/Migrations/Server.Items.TotalRefreshPotion.v0.json diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/AgilityPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/AgilityPotion.cs index ba30bb8ee..57dcab581 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/AgilityPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/AgilityPotion.cs @@ -1,33 +1,16 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class AgilityPotion : BaseAgilityPotion { - public class AgilityPotion : BaseAgilityPotion + [Constructible] + public AgilityPotion() : base(PotionEffect.Agility) { - [Constructible] - public AgilityPotion() : base(PotionEffect.Agility) - { - } - - public AgilityPotion(Serial serial) : base(serial) - { - } - - public override int DexOffset => 10; - public override TimeSpan Duration => TimeSpan.FromMinutes(2.0); - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int DexOffset => 10; + public override TimeSpan Duration => TimeSpan.FromMinutes(2.0); } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs index d60fb1d83..bc8d9f773 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs @@ -1,60 +1,43 @@ using System; +using ModernUO.Serialization; using Server.Engines.ConPVP; using Server.Spells; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public abstract partial class BaseAgilityPotion : BasePotion { - public abstract class BaseAgilityPotion : BasePotion + public BaseAgilityPotion(PotionEffect effect) : base(0xF08, effect) { - public BaseAgilityPotion(PotionEffect effect) : base(0xF08, effect) + } + + public abstract int DexOffset { get; } + public abstract TimeSpan Duration { get; } + + public bool DoAgility(Mobile from) + { + // TODO: Verify scaled; is it offset, duration, or both? + if (SpellHelper.AddStatOffset(from, StatType.Dex, Scale(from, DexOffset), Duration)) { + from.FixedEffect(0x375A, 10, 15); + from.PlaySound(0x1E7); + return true; } - public BaseAgilityPotion(Serial serial) : base(serial) + from.SendLocalizedMessage(502173); // You are already under a similar effect. + return false; + } + + public override void Drink(Mobile from) + { + if (DoAgility(from)) { - } + PlayDrinkEffect(from); - public abstract int DexOffset { get; } - public abstract TimeSpan Duration { get; } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } - - public bool DoAgility(Mobile from) - { - // TODO: Verify scaled; is it offset, duration, or both? - if (SpellHelper.AddStatOffset(from, StatType.Dex, Scale(from, DexOffset), Duration)) + if (!DuelContext.IsFreeConsume(from)) { - from.FixedEffect(0x375A, 10, 15); - from.PlaySound(0x1E7); - return true; - } - - from.SendLocalizedMessage(502173); // You are already under a similar effect. - return false; - } - - public override void Drink(Mobile from) - { - if (DoAgility(from)) - { - PlayDrinkEffect(from); - - if (!DuelContext.IsFreeConsume(from)) - { - Consume(); - } + Consume(); } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/GreaterAgilityPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/GreaterAgilityPotion.cs index ea47617dc..44fd8fb9e 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/GreaterAgilityPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Agility Potions/GreaterAgilityPotion.cs @@ -1,33 +1,16 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class GreaterAgilityPotion : BaseAgilityPotion { - public class GreaterAgilityPotion : BaseAgilityPotion + [Constructible] + public GreaterAgilityPotion() : base(PotionEffect.AgilityGreater) { - [Constructible] - public GreaterAgilityPotion() : base(PotionEffect.AgilityGreater) - { - } - - public GreaterAgilityPotion(Serial serial) : base(serial) - { - } - - public override int DexOffset => 20; - public override TimeSpan Duration => TimeSpan.FromMinutes(2.0); - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int DexOffset => 20; + public override TimeSpan Duration => TimeSpan.FromMinutes(2.0); } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs index e6f2bb93a..aca343865 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs @@ -1,292 +1,241 @@ using System; +using ModernUO.Serialization; using Server.Engines.ConPVP; using Server.Engines.Craft; using Server.Utilities; -namespace Server.Items +namespace Server.Items; + +public enum PotionEffect { - public enum PotionEffect + Nightsight, + CureLesser, + Cure, + CureGreater, + Agility, + AgilityGreater, + Strength, + StrengthGreater, + PoisonLesser, + Poison, + PoisonGreater, + PoisonDeadly, + Refresh, + RefreshTotal, + HealLesser, + Heal, + HealGreater, + ExplosionLesser, + Explosion, + ExplosionGreater, + Conflagration, + ConflagrationGreater, + MaskOfDeath, // Mask of Death is not available in OSI but does exist in cliloc files + MaskOfDeathGreater, // included in enumeration for compatibility if later enabled by OSI + ConfusionBlast, + ConfusionBlastGreater, + Invisibility, + Parasitic, + Darkglow +} + +[SerializationGenerator(2, false)] +public abstract partial class BasePotion : Item, ICraftable, ICommodity +{ + [InvalidateProperties] + [SerializableField(0)] + private PotionEffect _potionEffect; + + public BasePotion(int itemID, PotionEffect effect) : base(itemID) { - Nightsight, - CureLesser, - Cure, - CureGreater, - Agility, - AgilityGreater, - Strength, - StrengthGreater, - PoisonLesser, - Poison, - PoisonGreater, - PoisonDeadly, - Refresh, - RefreshTotal, - HealLesser, - Heal, - HealGreater, - ExplosionLesser, - Explosion, - ExplosionGreater, - Conflagration, - ConflagrationGreater, - MaskOfDeath, // Mask of Death is not available in OSI but does exist in cliloc files - MaskOfDeathGreater, // included in enumeration for compatibility if later enabled by OSI - ConfusionBlast, - ConfusionBlastGreater, - Invisibility, - Parasitic, - Darkglow + _potionEffect = effect; + + Stackable = Core.ML; + Weight = 1.0; } - public abstract class BasePotion : Item, ICraftable, ICommodity + public override int LabelNumber => 1041314 + (int)_potionEffect; + + public virtual bool RequireFreeHand => true; + + int ICommodity.DescriptionNumber => LabelNumber; + bool ICommodity.IsDeedable => Core.ML; + + public int OnCraft( + int quality, + bool makersMark, + Mobile from, + CraftSystem craftSystem, + Type typeRes, + BaseTool tool, + CraftItem craftItem, + int resHue + ) { - private PotionEffect m_PotionEffect; - - public BasePotion(int itemID, PotionEffect effect) : base(itemID) + if (craftSystem is DefAlchemy) { - m_PotionEffect = effect; + var pack = from.Backpack; - Stackable = Core.ML; - Weight = 1.0; - } - - public BasePotion(Serial serial) : base(serial) - { - } - - public PotionEffect PotionEffect - { - get => m_PotionEffect; - set + if (pack != null) { - m_PotionEffect = value; - InvalidateProperties(); - } - } - - public override int LabelNumber => 1041314 + (int)m_PotionEffect; - - public virtual bool RequireFreeHand => true; - - int ICommodity.DescriptionNumber => LabelNumber; - bool ICommodity.IsDeedable => Core.ML; - - public int OnCraft( - int quality, - bool makersMark, - Mobile from, - CraftSystem craftSystem, - Type typeRes, - BaseTool tool, - CraftItem craftItem, - int resHue - ) - { - if (craftSystem is DefAlchemy) - { - var pack = from.Backpack; - - if (pack != null) + if ((int)PotionEffect >= (int)PotionEffect.Invisibility) { - if ((int)PotionEffect >= (int)PotionEffect.Invisibility) + return 1; + } + + var kegs = pack.FindItemsByType(); + + for (var i = 0; i < kegs.Count; ++i) + { + var keg = kegs[i]; + + if (keg.Held is <= 0 or >= 100) { - return 1; + continue; } - var kegs = pack.FindItemsByType(); - - for (var i = 0; i < kegs.Count; ++i) + if (keg.Type != PotionEffect) { - var keg = kegs[i]; - - // Should never happen - // if (keg == null) - // continue; - - if (keg.Held is <= 0 or >= 100) - { - continue; - } - - if (keg.Type != PotionEffect) - { - continue; - } - - ++keg.Held; - - Consume(); - from.AddToBackpack(new Bottle()); - - return -1; // signal placed in keg + continue; } + + ++keg.Held; + + Consume(); + from.AddToBackpack(new Bottle()); + + return -1; // signal placed in keg } } - - return 1; } - public static bool HasFreeHand(Mobile m) + return 1; + } + + public static bool HasFreeHand(Mobile m) + { + var handOne = m.FindItemOnLayer(Layer.OneHanded); + var handTwo = m.FindItemOnLayer(Layer.TwoHanded); + + if (handTwo is BaseWeapon) { - var handOne = m.FindItemOnLayer(Layer.OneHanded); - var handTwo = m.FindItemOnLayer(Layer.TwoHanded); - - if (handTwo is BaseWeapon) - { - handOne = handTwo; - } - - if (handTwo is BaseRanged ranged && ranged.Balanced) - { - return true; - } - - return handOne == null || handTwo == null; + handOne = handTwo; } - public override void OnDoubleClick(Mobile from) + if (handTwo is BaseRanged ranged && ranged.Balanced) { - if (!Movable) + return true; + } + + return handOne == null || handTwo == null; + } + + public override void OnDoubleClick(Mobile from) + { + if (!Movable) + { + return; + } + + if (!from.InRange(GetWorldLocation(), 1)) + { + from.SendLocalizedMessage(502138); // That is too far away for you to use + return; + } + + if (RequireFreeHand && !HasFreeHand(from)) + { + from.SendLocalizedMessage(502172); // You must have a free hand to drink a potion. + return; + } + + if (this is BaseExplosionPotion && Amount > 1) + { + var pot = GetType().CreateInstance(); + + Amount--; + + if (from.Backpack?.Deleted == false) { - return; - } - - if (from.InRange(GetWorldLocation(), 1)) - { - if (!RequireFreeHand || HasFreeHand(from)) - { - if (this is BaseExplosionPotion && Amount > 1) - { - var pot = GetType().CreateInstance(); - - Amount--; - - if (from.Backpack?.Deleted == false) - { - from.Backpack.DropItem(pot); - } - else - { - pot.MoveToWorld(from.Location, from.Map); - } - - pot.Drink(from); - } - else - { - Drink(from); - } - } - else - { - from.SendLocalizedMessage(502172); // You must have a free hand to drink a potion. - } + from.Backpack.DropItem(pot); } else { - from.SendLocalizedMessage(502138); // That is too far away for you to use + pot.MoveToWorld(from.Location, from.Map); } - } - public override void Serialize(IGenericWriter writer) + pot.Drink(from); + } + else { - base.Serialize(writer); - - writer.Write(1); // version - - writer.Write((int)m_PotionEffect); + Drink(from); } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - switch (version) - { - case 1: - case 0: - { - m_PotionEffect = (PotionEffect)reader.ReadInt(); - break; - } - } - - if (version == 0) - { - Stackable = Core.ML; - } - } - - public abstract void Drink(Mobile from); - - public static void PlayDrinkEffect(Mobile m) - { - m.RevealingAction(); - - m.PlaySound(0x2D6); - - if (!DuelContext.IsFreeConsume(m)) - { - m.AddToBackpack(new Bottle()); - } - - if (m.Body.IsHuman && !m.Mounted) - { - m.Animate(34, 5, 1, true, false, 0); - } - } - - public static int EnhancePotions(Mobile m) - { - var EP = AosAttributes.GetValue(m, AosAttribute.EnhancePotions); - var skillBonus = m.Skills.Alchemy.Fixed / 330 * 10; - - if (Core.ML && EP > 50 && m.AccessLevel <= AccessLevel.Player) - { - EP = 50; - } - - return EP + skillBonus; - } - - public static TimeSpan Scale(Mobile m, TimeSpan v) - { - if (!Core.AOS) - { - return v; - } - - var scalar = 1.0 + 0.01 * EnhancePotions(m); - - return TimeSpan.FromSeconds(v.TotalSeconds * scalar); - } - - public static double Scale(Mobile m, double v) - { - if (!Core.AOS) - { - return v; - } - - var scalar = 1.0 + 0.01 * EnhancePotions(m); - - return v * scalar; - } - - public static int Scale(Mobile m, int v) - { - if (!Core.AOS) - { - return v; - } - - return AOS.Scale(v, 100 + EnhancePotions(m)); - } - - public override bool StackWith(Mobile from, Item dropped, bool playSound) => - dropped is BasePotion potion && potion.m_PotionEffect == m_PotionEffect && - base.StackWith(from, potion, playSound); } + + private void Deserialize(IGenericReader reader, int version) + { + _potionEffect = (PotionEffect)reader.ReadInt(); + } + + public abstract void Drink(Mobile from); + + public static void PlayDrinkEffect(Mobile m) + { + m.RevealingAction(); + + m.PlaySound(0x2D6); + + if (!DuelContext.IsFreeConsume(m)) + { + m.AddToBackpack(new Bottle()); + } + + if (m.Body.IsHuman && !m.Mounted) + { + m.Animate(34, 5, 1, true, false, 0); + } + } + + public static int EnhancePotions(Mobile m) + { + var EP = AosAttributes.GetValue(m, AosAttribute.EnhancePotions); + var skillBonus = m.Skills.Alchemy.Fixed / 330 * 10; + + if (Core.ML && EP > 50 && m.AccessLevel <= AccessLevel.Player) + { + EP = 50; + } + + return EP + skillBonus; + } + + public static TimeSpan Scale(Mobile m, TimeSpan v) + { + if (!Core.AOS) + { + return v; + } + + var scalar = 1.0 + 0.01 * EnhancePotions(m); + + return TimeSpan.FromSeconds(v.TotalSeconds * scalar); + } + + public static double Scale(Mobile m, double v) + { + if (!Core.AOS) + { + return v; + } + + var scalar = 1.0 + 0.01 * EnhancePotions(m); + + return v * scalar; + } + + public static int Scale(Mobile m, int v) => !Core.AOS ? v : AOS.Scale(v, 100 + EnhancePotions(m)); + + public override bool StackWith(Mobile from, Item dropped, bool playSound) => + dropped is BasePotion potion && potion._potionEffect == _potionEffect && + base.StackWith(from, potion, playSound); } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs index b18cd8da9..ceead34c0 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs @@ -1,323 +1,289 @@ using System; using System.Collections.Generic; +using ModernUO.Serialization; using Server.Spells; using Server.Targeting; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public abstract partial class BaseConflagrationPotion : BasePotion { - public abstract class BaseConflagrationPotion : BasePotion + private static readonly Dictionary m_Delay = new(); + private readonly List m_Users = new(); + + public BaseConflagrationPotion(PotionEffect effect) : base(0xF06, effect) => Hue = 0x489; + + public abstract int MinDamage { get; } + public abstract int MaxDamage { get; } + + public override bool RequireFreeHand => false; + + public override void Drink(Mobile from) { - private static readonly Dictionary m_Delay = new(); - private readonly List m_Users = new(); - - public BaseConflagrationPotion(PotionEffect effect) : base(0xF06, effect) => Hue = 0x489; - - public BaseConflagrationPotion(Serial serial) : base(serial) + if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true)) { + from.SendLocalizedMessage(1062725); // You can not use that potion while paralyzed. + return; } - public abstract int MinDamage { get; } - public abstract int MaxDamage { get; } + var delay = GetDelay(from); - public override bool RequireFreeHand => false; - - public override void Drink(Mobile from) + if (delay > 0) { - if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true)) + // You cannot use that for another ~1_NUM~ ~2_TIMEUNITS~ + from.SendLocalizedMessage(1072529, $"{delay}\t{(delay > 1 ? "seconds." : "second.")}"); + return; + } + + if (from.Target is ThrowTarget targ && targ.Potion == this) + { + return; + } + + from.RevealingAction(); + + if (!m_Users.Contains(from)) + { + m_Users.Add(from); + } + + from.Target = new ThrowTarget(this); + } + + public virtual void Explode(Mobile from, Point3D loc, Map map) + { + if (Deleted || map == null) + { + return; + } + + Consume(); + + // Check if any other players are using this potion + for (var i = 0; i < m_Users.Count; i++) + { + if (m_Users[i].Target is ThrowTarget targ && targ.Potion == this) { - from.SendLocalizedMessage(1062725); // You can not use that potion while paralyzed. - return; + Target.Cancel(from); } + } - var delay = GetDelay(from); + // Effects + Effects.PlaySound(loc, map, 0x20C); - if (delay > 0) + for (var i = -2; i <= 2; i++) + { + for (var j = -2; j <= 2; j++) { - from.SendLocalizedMessage( - 1072529, - $"{delay}\t{(delay > 1 ? "seconds." : "second.")}" - ); // You cannot use that for another ~1_NUM~ ~2_TIMEUNITS~ - return; - } + var p = new Point3D(loc.X + i, loc.Y + j, loc.Z); - if (from.Target is ThrowTarget targ && targ.Potion == this) + if (map.CanFit(p, 12, true, false) && from.InLOS(p)) + { + new InternalItem(from, p, map, MinDamage, MaxDamage); + } + } + } + } + + public static void AddDelay(Mobile m) + { + m_Delay.TryGetValue(m, out var timer); + timer.Cancel(); + + Timer.StartTimer(TimeSpan.FromSeconds(30), () => EndDelay(m), out timer); + m_Delay[m] = timer; + } + + public static int GetDelay(Mobile m) + { + if (m_Delay.TryGetValue(m, out var timer) && timer.Next > Core.Now) + { + return (int)(timer.Next - Core.Now).TotalSeconds; + } + + return 0; + } + + public static void EndDelay(Mobile m) + { + if (m_Delay.Remove(m, out var timer)) + { + timer.Cancel(); + } + } + + private class ThrowTarget : Target + { + public ThrowTarget(BaseConflagrationPotion potion) : base(12, true, TargetFlags.None) => Potion = potion; + + public BaseConflagrationPotion Potion { get; } + + protected override void OnTarget(Mobile from, object targeted) + { + if (Potion.Deleted || Potion.Map == Map.Internal) { return; } + if (targeted is not IPoint3D p || from.Map == null) + { + return; + } + + // Add delay + AddDelay(from); + + SpellHelper.GetSurfaceTop(ref p); + var loc = new Point3D(p); + var map = from.Map; + from.RevealingAction(); - if (!m_Users.Contains(from)) + IEntity to; + + if (p is Mobile mobile) { - m_Users.Add(from); + to = mobile; + } + else + { + to = new Entity(Serial.Zero, loc, map); } - from.Target = new ThrowTarget(this); + Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue); + Timer.StartTimer(TimeSpan.FromSeconds(1.5), () => Potion.Explode(from, loc, map)); + } + } + + [SerializationGenerator(0, false)] + public partial class InternalItem : Item + { + [SerializableField(0, setter: "private")] + private Mobile _from; + + [SerializableField(1, getter: "private", setter: "private")] + private DateTime _end; + + [SerializableField(2, getter: "private", setter: "private")] + private int _minDamage; + + [SerializableField(3, getter: "private", setter: "private")] + private int _maxDamage; + + private Timer _timer; + + public InternalItem(Mobile from, Point3D loc, Map map, int min, int max) : base(0x398C) + { + Movable = false; + Light = LightType.Circle300; + + MoveToWorld(loc, map); + + From = from; + _end = Core.Now + TimeSpan.FromSeconds(10); + + SetDamage(min, max); + + _timer = new InternalTimer(this, _end); + _timer.Start(); } - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); + public override bool BlocksFit => true; - writer.Write(0); // version + public override void OnAfterDelete() + { + base.OnAfterDelete(); + + _timer?.Stop(); } - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); + public int GetDamage() => Utility.RandomMinMax(_minDamage, _maxDamage); - var version = reader.ReadInt(); - } - - public virtual void Explode(Mobile from, Point3D loc, Map map) + private void SetDamage(int min, int max) { - if (Deleted || map == null) + /** + * new way to apply alchemy bonus according to Stratics' calculator. + * this gives a mean to values 25, 50, 75 and 100. Stratics' calculator is outdated. + * Those goals will give 2 to alchemy bonus. It's not really OSI-like but it's an approximation. + */ + _minDamage = min; + _maxDamage = max; + + if (From == null) { return; } - Consume(); + var alchemySkill = From.Skills.Alchemy.Fixed; + var alchemyBonus = alchemySkill / 125 + alchemySkill / 250; - // Check if any other players are using this potion - for (var i = 0; i < m_Users.Count; i++) - { - if (m_Users[i].Target is ThrowTarget targ && targ.Potion == this) - { - Target.Cancel(from); - } - } - - // Effects - Effects.PlaySound(loc, map, 0x20C); - - for (var i = -2; i <= 2; i++) - { - for (var j = -2; j <= 2; j++) - { - var p = new Point3D(loc.X + i, loc.Y + j, loc.Z); - - if (map.CanFit(p, 12, true, false) && from.InLOS(p)) - { - new InternalItem(from, p, map, MinDamage, MaxDamage); - } - } - } + _minDamage = Scale(From, _minDamage + alchemyBonus); + _maxDamage = Scale(From, _maxDamage + alchemyBonus); } - public static void AddDelay(Mobile m) + [AfterDeserialization] + private void AfterDeserialization() { - m_Delay.TryGetValue(m, out var timer); - timer.Cancel(); - - Timer.StartTimer(TimeSpan.FromSeconds(30), () => EndDelay(m), out timer); - m_Delay[m] = timer; + _timer = new InternalTimer(this, _end); + _timer.Start(); } - public static int GetDelay(Mobile m) + public override bool OnMoveOver(Mobile m) { - if (m_Delay.TryGetValue(m, out var timer) && timer.Next > Core.Now) + if (Visible && From != null && (!Core.AOS || m != From) && SpellHelper.ValidIndirectTarget(From, m) && + From.CanBeHarmful(m, false)) { - return (int)(timer.Next - Core.Now).TotalSeconds; + From.DoHarmful(m); + + AOS.Damage(m, From, GetDamage(), 0, 100, 0, 0, 0); + m.PlaySound(0x208); } - return 0; + return true; } - public static void EndDelay(Mobile m) + private class InternalTimer : Timer { - if (m_Delay.Remove(m, out var timer)) + private readonly DateTime _end; + private readonly InternalItem _item; + + public InternalTimer(InternalItem item, DateTime end) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) { - timer.Cancel(); + _item = item; + _end = end; } - } - private class ThrowTarget : Target - { - public ThrowTarget(BaseConflagrationPotion potion) : base(12, true, TargetFlags.None) => Potion = potion; - - public BaseConflagrationPotion Potion { get; } - - protected override void OnTarget(Mobile from, object targeted) + protected override void OnTick() { - if (Potion.Deleted || Potion.Map == Map.Internal) + if (_item.Deleted) { return; } - if (targeted is not IPoint3D p || from.Map == null) + if (Core.Now > _end) + { + _item.Delete(); + Stop(); + return; + } + + var from = _item.From; + + if (_item.Map == null || from == null) { return; } - // Add delay - AddDelay(from); - - SpellHelper.GetSurfaceTop(ref p); - var loc = new Point3D(p); - var map = from.Map; - - from.RevealingAction(); - - IEntity to; - - if (p is Mobile mobile) + foreach (var m in _item.GetMobilesInRange(0)) { - to = mobile; - } - else - { - to = new Entity(Serial.Zero, loc, map); - } - - Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue); - Timer.StartTimer(TimeSpan.FromSeconds(1.5), () => Potion.Explode(from, loc, map)); - } - } - - public class InternalItem : Item - { - private DateTime m_End; - private int m_MaxDamage; - private int m_MinDamage; - private Timer m_Timer; - - public InternalItem(Mobile from, Point3D loc, Map map, int min, int max) : base(0x398C) - { - Movable = false; - Light = LightType.Circle300; - - MoveToWorld(loc, map); - - From = from; - m_End = Core.Now + TimeSpan.FromSeconds(10); - - SetDamage(min, max); - - m_Timer = new InternalTimer(this, m_End); - m_Timer.Start(); - } - - public InternalItem(Serial serial) : base(serial) - { - } - - public Mobile From { get; private set; } - - public override bool BlocksFit => true; - - public override void OnAfterDelete() - { - base.OnAfterDelete(); - - m_Timer?.Stop(); - } - - public int GetDamage() => Utility.RandomMinMax(m_MinDamage, m_MaxDamage); - - private void SetDamage(int min, int max) - { - /* new way to apply alchemy bonus according to Stratics' calculator. - this gives a mean to values 25, 50, 75 and 100. Stratics' calculator is outdated. - Those goals will give 2 to alchemy bonus. It's not really OSI-like but it's an approximation. */ - - m_MinDamage = min; - m_MaxDamage = max; - - if (From == null) - { - return; - } - - var alchemySkill = From.Skills.Alchemy.Fixed; - var alchemyBonus = alchemySkill / 125 + alchemySkill / 250; - - m_MinDamage = Scale(From, m_MinDamage + alchemyBonus); - m_MaxDamage = Scale(From, m_MaxDamage + alchemyBonus); - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - - writer.Write(From); - writer.Write(m_End); - writer.Write(m_MinDamage); - writer.Write(m_MaxDamage); - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - - From = reader.ReadEntity(); - m_End = reader.ReadDateTime(); - m_MinDamage = reader.ReadInt(); - m_MaxDamage = reader.ReadInt(); - - m_Timer = new InternalTimer(this, m_End); - m_Timer.Start(); - } - - public override bool OnMoveOver(Mobile m) - { - if (Visible && From != null && (!Core.AOS || m != From) && SpellHelper.ValidIndirectTarget(From, m) && - From.CanBeHarmful(m, false)) - { - From.DoHarmful(m); - - AOS.Damage(m, From, GetDamage(), 0, 100, 0, 0, 0); - m.PlaySound(0x208); - } - - return true; - } - - private class InternalTimer : Timer - { - private readonly DateTime m_End; - private readonly InternalItem m_Item; - - public InternalTimer(InternalItem item, DateTime end) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) - { - m_Item = item; - m_End = end; - } - - protected override void OnTick() - { - if (m_Item.Deleted) + if (m.Z + 16 > _item.Z && _item.Z + 12 > m.Z && (!Core.AOS || m != from) && + SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false)) { - return; - } + from.DoHarmful(m); - if (Core.Now > m_End) - { - m_Item.Delete(); - Stop(); - return; - } - - var from = m_Item.From; - - if (m_Item.Map == null || from == null) - { - return; - } - - foreach (var m in m_Item.GetMobilesInRange(0)) - { - if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != from) && - SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false)) - { - from.DoHarmful(m); - - AOS.Damage(m, from, m_Item.GetDamage(), 0, 100, 0, 0, 0); - m.PlaySound(0x208); - } + AOS.Damage(m, from, _item.GetDamage(), 0, 100, 0, 0, 0); + m.PlaySound(0x208); } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/ConflagrationPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/ConflagrationPotion.cs index aafa1bfd1..f8e4cbedc 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/ConflagrationPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/ConflagrationPotion.cs @@ -1,33 +1,17 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class ConflagrationPotion : BaseConflagrationPotion { - public class ConflagrationPotion : BaseConflagrationPotion + [Constructible] + public ConflagrationPotion() : base(PotionEffect.Conflagration) { - [Constructible] - public ConflagrationPotion() : base(PotionEffect.Conflagration) - { - } - - public ConflagrationPotion(Serial serial) : base(serial) - { - } - - public override int MinDamage => 2; - public override int MaxDamage => 4; - - public override int LabelNumber => 1072095; // a Conflagration potion - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int MinDamage => 2; + public override int MaxDamage => 4; + + public override int LabelNumber => 1072095; // a Conflagration potion } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/GreaterConflagrationPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/GreaterConflagrationPotion.cs index 3bea53f11..ab01b0a36 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/GreaterConflagrationPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Conflagration Potions/GreaterConflagrationPotion.cs @@ -1,33 +1,17 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class GreaterConflagrationPotion : BaseConflagrationPotion { - public class GreaterConflagrationPotion : BaseConflagrationPotion + [Constructible] + public GreaterConflagrationPotion() : base(PotionEffect.ConflagrationGreater) { - [Constructible] - public GreaterConflagrationPotion() : base(PotionEffect.ConflagrationGreater) - { - } - - public GreaterConflagrationPotion(Serial serial) : base(serial) - { - } - - public override int MinDamage => 4; - public override int MaxDamage => 8; - - public override int LabelNumber => 1072098; // a Greater Conflagration potion - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int MinDamage => 4; + public override int MaxDamage => 8; + + public override int LabelNumber => 1072098; // a Greater Conflagration potion } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs index f65db4499..7b6934be4 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs @@ -1,195 +1,179 @@ using System; using System.Collections.Generic; +using ModernUO.Serialization; using Server.Misc; using Server.Mobiles; using Server.Spells; using Server.Targeting; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public abstract partial class BaseConfusionBlastPotion : BasePotion { - public abstract class BaseConfusionBlastPotion : BasePotion + private static readonly Dictionary _delay = new(); + private HashSet _users; + + public BaseConfusionBlastPotion(PotionEffect effect) : base(0xF06, effect) => Hue = 0x48D; + + public abstract int Radius { get; } + + public override bool RequireFreeHand => false; + + public override void Drink(Mobile from) { - private static readonly Dictionary m_Delay = new(); - private readonly List m_Users = new(); - - public BaseConfusionBlastPotion(PotionEffect effect) : base(0xF06, effect) => Hue = 0x48D; - - public BaseConfusionBlastPotion(Serial serial) : base(serial) + if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true)) { + from.SendLocalizedMessage(1062725); // You can not use that potion while paralyzed. + return; } - public abstract int Radius { get; } + var delay = GetDelay(from); - public override bool RequireFreeHand => false; - - public override void Drink(Mobile from) + if (delay > 0) { - if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true)) - { - from.SendLocalizedMessage(1062725); // You can not use that potion while paralyzed. - return; - } - - var delay = GetDelay(from); - - if (delay > 0) - { - from.SendLocalizedMessage( - 1072529, - $"{delay}\t{(delay > 1 ? "seconds." : "second.")}" - ); // You cannot use that for another ~1_NUM~ ~2_TIMEUNITS~ - return; - } - - if (from.Target is ThrowTarget targ && targ.Potion == this) - { - return; - } - - from.RevealingAction(); - - if (!m_Users.Contains(from)) - { - m_Users.Add(from); - } - - from.Target = new ThrowTarget(this); + // You cannot use that for another ~1_NUM~ ~2_TIMEUNITS~ + from.SendLocalizedMessage(1072529, $"{delay}\t{(delay > 1 ? "seconds." : "second.")}"); + return; } - public override void Serialize(IGenericWriter writer) + if (from.Target is ThrowTarget targ && targ.Potion == this) { - base.Serialize(writer); - - writer.Write(0); // version + return; } - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); + from.RevealingAction(); - var version = reader.ReadInt(); + _users ??= new HashSet(); + _users.Add(from); + + from.Target = new ThrowTarget(this); + } + + public virtual void Explode(Mobile from, Point3D loc, Map map) + { + if (Deleted || map == null) + { + return; } - public virtual void Explode(Mobile from, Point3D loc, Map map) + Consume(); + + if (_users != null) { - if (Deleted || map == null) - { - return; - } - - Consume(); - // Check if any other players are using this potion - for (var i = 0; i < m_Users.Count; i++) + foreach (var user in _users) { - if (m_Users[i].Target is ThrowTarget targ && targ.Potion == this) + if ((user.Target as ThrowTarget)?.Potion == this) { Target.Cancel(from); } } - // Effects - Effects.PlaySound(loc, map, 0x207); + _users.Clear(); + } - Geometry.Circle2D(loc, map, Radius, BlastEffect, 270, 90); + // Effects + Effects.PlaySound(loc, map, 0x207); - Timer.StartTimer(TimeSpan.FromSeconds(0.3), () => CircleEffect2(loc, map)); + Geometry.Circle2D(loc, map, Radius, BlastEffect, 270, 90); - foreach (var mobile in map.GetMobilesInRange(loc, Radius)) + Timer.StartTimer(TimeSpan.FromSeconds(0.3), () => CircleEffect2(loc, map)); + + foreach (var mobile in map.GetMobilesInRange(loc, Radius)) + { + if (mobile is BaseCreature mon) { - if (mobile is BaseCreature mon) + if (mon.Controlled || mon.Summoned) { - if (mon.Controlled || mon.Summoned) - { - continue; - } - - mon.Pacify(from, Core.Now + TimeSpan.FromSeconds(5.0)); // TODO check - } - } - } - - public virtual void BlastEffect(Point3D p, Map map) - { - if (map.CanFit(p, 12, true, false)) - { - Effects.SendLocationEffect(p, map, 0x376A, 4, 9); - } - } - - public void CircleEffect2(Point3D p, Map m) - { - Geometry.Circle2D(p, m, Radius, BlastEffect, 90, 270); - } - - public static void AddDelay(Mobile m) - { - m_Delay.TryGetValue(m, out var timer); - timer.Cancel(); - - Timer.StartTimer(TimeSpan.FromSeconds(60), () => EndDelay(m), out timer); - m_Delay[m] = timer; - } - - public static int GetDelay(Mobile m) - { - if (m_Delay.TryGetValue(m, out var timer) && timer.Next > Core.Now) - { - return (int)(timer.Next - Core.Now).TotalSeconds; - } - - return 0; - } - - public static void EndDelay(Mobile m) - { - if (m_Delay.Remove(m, out var timer)) - { - timer.Cancel(); - } - } - - private class ThrowTarget : Target - { - public ThrowTarget(BaseConfusionBlastPotion potion) : base(12, true, TargetFlags.None) => Potion = potion; - - public BaseConfusionBlastPotion Potion { get; } - - protected override void OnTarget(Mobile from, object targeted) - { - if (Potion.Deleted || Potion.Map == Map.Internal) - { - return; + continue; } - if (targeted is not IPoint3D p || from.Map == null) - { - return; - } - - // Add delay - AddDelay(from); - - SpellHelper.GetSurfaceTop(ref p); - var loc = new Point3D(p); - var map = from.Map; - - from.RevealingAction(); - - IEntity to; - - if (p is Mobile mobile) - { - to = mobile; - } - else - { - to = new Entity(Serial.Zero, loc, map); - } - - Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue); - Timer.StartTimer(TimeSpan.FromSeconds(1.0), () => Potion.Explode(from, loc, map)); + mon.Pacify(from, Core.Now + TimeSpan.FromSeconds(5.0)); // TODO check } } } + + public virtual void BlastEffect(Point3D p, Map map) + { + if (map.CanFit(p, 12, true, false)) + { + Effects.SendLocationEffect(p, map, 0x376A, 4, 9); + } + } + + public void CircleEffect2(Point3D p, Map m) + { + Geometry.Circle2D(p, m, Radius, BlastEffect, 90, 270); + } + + public static void AddDelay(Mobile m) + { + _delay.TryGetValue(m, out var timer); + timer.Cancel(); + + Timer.StartTimer(TimeSpan.FromSeconds(60), () => EndDelay(m), out timer); + _delay[m] = timer; + } + + public static int GetDelay(Mobile m) + { + if (_delay.TryGetValue(m, out var timer) && timer.Next > Core.Now) + { + return (int)(timer.Next - Core.Now).TotalSeconds; + } + + return 0; + } + + public static void EndDelay(Mobile m) + { + if (_delay.Remove(m, out var timer)) + { + timer.Cancel(); + } + } + + private class ThrowTarget : Target + { + public ThrowTarget(BaseConfusionBlastPotion potion) : base(12, true, TargetFlags.None) => Potion = potion; + + public BaseConfusionBlastPotion Potion { get; } + + protected override void OnTarget(Mobile from, object targeted) + { + if (Potion.Deleted || Potion.Map == Map.Internal) + { + return; + } + + if (targeted is not IPoint3D p || from.Map == null) + { + return; + } + + // Add delay + AddDelay(from); + + SpellHelper.GetSurfaceTop(ref p); + var loc = new Point3D(p); + var map = from.Map; + + from.RevealingAction(); + + IEntity to; + + if (p is Mobile mobile) + { + to = mobile; + } + else + { + to = new Entity(Serial.Zero, loc, map); + } + + Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue); + Timer.StartTimer(TimeSpan.FromSeconds(1.0), () => Potion.Explode(from, loc, map)); + } + } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/ConfusionBlastPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/ConfusionBlastPotion.cs index 42b3da6a8..8de347e7c 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/ConfusionBlastPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/ConfusionBlastPotion.cs @@ -1,32 +1,16 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class ConfusionBlastPotion : BaseConfusionBlastPotion { - public class ConfusionBlastPotion : BaseConfusionBlastPotion + [Constructible] + public ConfusionBlastPotion() : base(PotionEffect.ConfusionBlast) { - [Constructible] - public ConfusionBlastPotion() : base(PotionEffect.ConfusionBlast) - { - } - - public ConfusionBlastPotion(Serial serial) : base(serial) - { - } - - public override int Radius => 5; - - public override int LabelNumber => 1072105; // a Confusion Blast potion - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int Radius => 5; + + public override int LabelNumber => 1072105; // a Confusion Blast potion } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/GreaterConfusionBlastPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/GreaterConfusionBlastPotion.cs index 01ca7d629..1739f5cf0 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/GreaterConfusionBlastPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/GreaterConfusionBlastPotion.cs @@ -1,32 +1,16 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class GreaterConfusionBlastPotion : BaseConfusionBlastPotion { - public class GreaterConfusionBlastPotion : BaseConfusionBlastPotion + [Constructible] + public GreaterConfusionBlastPotion() : base(PotionEffect.ConfusionBlastGreater) { - [Constructible] - public GreaterConfusionBlastPotion() : base(PotionEffect.ConfusionBlastGreater) - { - } - - public GreaterConfusionBlastPotion(Serial serial) : base(serial) - { - } - - public override int Radius => 7; - - public override int LabelNumber => 1072108; // a Greater Confusion Blast potion - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int Radius => 7; + + public override int LabelNumber => 1072108; // a Greater Confusion Blast potion } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs index 6f98a1b6c..0b14f0f77 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs @@ -1,102 +1,85 @@ +using ModernUO.Serialization; using Server.Engines.ConPVP; using Server.Spells; using Server.Spells.Necromancy; -namespace Server.Items +namespace Server.Items; + +public class CureLevelInfo { - public class CureLevelInfo + public CureLevelInfo(Poison poison, double chance) { - public CureLevelInfo(Poison poison, double chance) - { - Poison = poison; - Chance = chance; - } - - public Poison Poison { get; } - - public double Chance { get; } + Poison = poison; + Chance = chance; } - public abstract class BaseCurePotion : BasePotion + public Poison Poison { get; } + + public double Chance { get; } +} + +[SerializationGenerator(0, false)] +public abstract partial class BaseCurePotion : BasePotion +{ + public BaseCurePotion(PotionEffect effect) : base(0xF07, effect) { - public BaseCurePotion(PotionEffect effect) : base(0xF07, effect) + } + + public abstract CureLevelInfo[] LevelInfo { get; } + + public void DoCure(Mobile from) + { + var cure = false; + + var info = LevelInfo; + + for (var i = 0; i < info.Length; ++i) { - } + var li = info[i]; - public BaseCurePotion(Serial serial) : base(serial) - { - } - - public abstract CureLevelInfo[] LevelInfo { get; } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } - - public void DoCure(Mobile from) - { - var cure = false; - - var info = LevelInfo; - - for (var i = 0; i < info.Length; ++i) + if (li.Poison == from.Poison && Scale(from, li.Chance) > Utility.RandomDouble()) { - var li = info[i]; - - if (li.Poison == from.Poison && Scale(from, li.Chance) > Utility.RandomDouble()) - { - cure = true; - break; - } - } - - if (cure && from.CurePoison(from)) - { - from.SendLocalizedMessage(500231); // You feel cured of poison! - - from.FixedEffect(0x373A, 10, 15); - from.PlaySound(0x1E0); - } - else if (!cure) - { - from.SendLocalizedMessage(500232); // That potion was not strong enough to cure your ailment! + cure = true; + break; } } - public override void Drink(Mobile from) + if (cure && from.CurePoison(from)) { - if (TransformationSpellHelper.UnderTransformation(from, typeof(VampiricEmbraceSpell))) - { - from.SendLocalizedMessage(1061652); // The garlic in the potion would surely kill you. - } - else if (from.Poisoned) - { - DoCure(from); + from.SendLocalizedMessage(500231); // You feel cured of poison! - PlayDrinkEffect(from); + from.FixedEffect(0x373A, 10, 15); + from.PlaySound(0x1E0); + } + else if (!cure) + { + from.SendLocalizedMessage(500232); // That potion was not strong enough to cure your ailment! + } + } - from.FixedParticles(0x373A, 10, 15, 5012, EffectLayer.Waist); - from.PlaySound(0x1E0); + public override void Drink(Mobile from) + { + if (TransformationSpellHelper.UnderTransformation(from, typeof(VampiricEmbraceSpell))) + { + from.SendLocalizedMessage(1061652); // The garlic in the potion would surely kill you. + } + else if (from.Poisoned) + { + DoCure(from); - if (!DuelContext.IsFreeConsume(from)) - { - Consume(); - } - } - else + PlayDrinkEffect(from); + + from.FixedParticles(0x373A, 10, 15, 5012, EffectLayer.Waist); + from.PlaySound(0x1E0); + + if (!DuelContext.IsFreeConsume(from)) { - from.SendLocalizedMessage(1042000); // You are not poisoned. + Consume(); } } + else + { + from.SendLocalizedMessage(1042000); // You are not poisoned. + } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/CurePotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/CurePotion.cs index e1b408134..aa686ceeb 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/CurePotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/CurePotion.cs @@ -1,47 +1,31 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class CurePotion : BaseCurePotion { - public class CurePotion : BaseCurePotion + private static readonly CureLevelInfo[] _oldLevelInfo = { - private static readonly CureLevelInfo[] m_OldLevelInfo = - { - new(Poison.Lesser, 1.00), // 100% chance to cure lesser poison - new(Poison.Regular, 0.75), // 75% chance to cure regular poison - new(Poison.Greater, 0.50), // 50% chance to cure greater poison - new(Poison.Deadly, 0.15) // 15% chance to cure deadly poison - }; + new(Poison.Lesser, 1.00), // 100% chance to cure lesser poison + new(Poison.Regular, 0.75), // 75% chance to cure regular poison + new(Poison.Greater, 0.50), // 50% chance to cure greater poison + new(Poison.Deadly, 0.15) // 15% chance to cure deadly poison + }; - private static readonly CureLevelInfo[] m_AosLevelInfo = - { - new(Poison.Lesser, 1.00), - new(Poison.Regular, 0.95), - new(Poison.Greater, 0.75), - new(Poison.Deadly, 0.50), - new(Poison.Lethal, 0.25) - }; + private static readonly CureLevelInfo[] _aosLevelInfo = + { + new(Poison.Lesser, 1.00), + new(Poison.Regular, 0.95), + new(Poison.Greater, 0.75), + new(Poison.Deadly, 0.50), + new(Poison.Lethal, 0.25) + }; - [Constructible] - public CurePotion() : base(PotionEffect.Cure) - { - } - - public CurePotion(Serial serial) : base(serial) - { - } - - public override CureLevelInfo[] LevelInfo => Core.AOS ? m_AosLevelInfo : m_OldLevelInfo; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } + [Constructible] + public CurePotion() : base(PotionEffect.Cure) + { } + + public override CureLevelInfo[] LevelInfo => Core.AOS ? _aosLevelInfo : _oldLevelInfo; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/GreaterCurePotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/GreaterCurePotion.cs index 1c1b6ca8c..4130f5b30 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/GreaterCurePotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/GreaterCurePotion.cs @@ -1,48 +1,47 @@ -namespace Server.Items +namespace Server.Items; + +public class GreaterCurePotion : BaseCurePotion { - public class GreaterCurePotion : BaseCurePotion + private static readonly CureLevelInfo[] m_OldLevelInfo = { - private static readonly CureLevelInfo[] m_OldLevelInfo = - { - new(Poison.Lesser, 1.00), // 100% chance to cure lesser poison - new(Poison.Regular, 1.00), // 100% chance to cure regular poison - new(Poison.Greater, 1.00), // 100% chance to cure greater poison - new(Poison.Deadly, 0.75), // 75% chance to cure deadly poison - new(Poison.Lethal, 0.25) // 25% chance to cure lethal poison - }; + new(Poison.Lesser, 1.00), // 100% chance to cure lesser poison + new(Poison.Regular, 1.00), // 100% chance to cure regular poison + new(Poison.Greater, 1.00), // 100% chance to cure greater poison + new(Poison.Deadly, 0.75), // 75% chance to cure deadly poison + new(Poison.Lethal, 0.25) // 25% chance to cure lethal poison + }; - private static readonly CureLevelInfo[] m_AosLevelInfo = - { - new(Poison.Lesser, 1.00), - new(Poison.Regular, 1.00), - new(Poison.Greater, 1.00), - new(Poison.Deadly, 0.95), - new(Poison.Lethal, 0.75) - }; + private static readonly CureLevelInfo[] m_AosLevelInfo = + { + new(Poison.Lesser, 1.00), + new(Poison.Regular, 1.00), + new(Poison.Greater, 1.00), + new(Poison.Deadly, 0.95), + new(Poison.Lethal, 0.75) + }; - [Constructible] - public GreaterCurePotion() : base(PotionEffect.CureGreater) - { - } - - public GreaterCurePotion(Serial serial) : base(serial) - { - } - - public override CureLevelInfo[] LevelInfo => Core.AOS ? m_AosLevelInfo : m_OldLevelInfo; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } + [Constructible] + public GreaterCurePotion() : base(PotionEffect.CureGreater) + { } -} + + public GreaterCurePotion(Serial serial) : base(serial) + { + } + + public override CureLevelInfo[] LevelInfo => Core.AOS ? m_AosLevelInfo : m_OldLevelInfo; + + public override void Serialize(IGenericWriter writer) + { + base.Serialize(writer); + + writer.Write(0); // version + } + + public override void Deserialize(IGenericReader reader) + { + base.Deserialize(reader); + + var version = reader.ReadInt(); + } +} \ No newline at end of file diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/LesserCurePotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/LesserCurePotion.cs index 288d98933..b887bb51f 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/LesserCurePotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Cure Potions/LesserCurePotion.cs @@ -1,44 +1,28 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class LesserCurePotion : BaseCurePotion { - public class LesserCurePotion : BaseCurePotion + private static readonly CureLevelInfo[] _oldLevelInfo = { - private static readonly CureLevelInfo[] m_OldLevelInfo = - { - new(Poison.Lesser, 0.75), // 75% chance to cure lesser poison - new(Poison.Regular, 0.50), // 50% chance to cure regular poison - new(Poison.Greater, 0.15) // 15% chance to cure greater poison - }; + new(Poison.Lesser, 0.75), // 75% chance to cure lesser poison + new(Poison.Regular, 0.50), // 50% chance to cure regular poison + new(Poison.Greater, 0.15) // 15% chance to cure greater poison + }; - private static readonly CureLevelInfo[] m_AosLevelInfo = - { - new(Poison.Lesser, 0.75), - new(Poison.Regular, 0.50), - new(Poison.Greater, 0.25) - }; + private static readonly CureLevelInfo[] _aosLevelInfo = + { + new(Poison.Lesser, 0.75), + new(Poison.Regular, 0.50), + new(Poison.Greater, 0.25) + }; - [Constructible] - public LesserCurePotion() : base(PotionEffect.CureLesser) - { - } - - public LesserCurePotion(Serial serial) : base(serial) - { - } - - public override CureLevelInfo[] LevelInfo => Core.AOS ? m_AosLevelInfo : m_OldLevelInfo; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } + [Constructible] + public LesserCurePotion() : base(PotionEffect.CureLesser) + { } + + public override CureLevelInfo[] LevelInfo => Core.AOS ? _aosLevelInfo : _oldLevelInfo; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/DarkglowPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/DarkglowPotion.cs deleted file mode 100644 index de576f4c2..000000000 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/DarkglowPotion.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Server.Items -{ - public class DarkglowPotion : BasePoisonPotion - { - [Constructible] - public DarkglowPotion() : base(PotionEffect.Darkglow) => Hue = 0x96; - - public DarkglowPotion(Serial serial) : base(serial) - { - } - - public override Poison Poison => Poison.Greater; /* MUST be restored when prerequisites are done */ - - public override double MinPoisoningSkill => 95.0; - public override double MaxPoisoningSkill => 100.0; - - public override int LabelNumber => 1072849; // Darkglow Poison - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } - } -} diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs index acee1342c..46bea6a2d 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs @@ -1,336 +1,321 @@ using System; using System.Collections.Generic; +using ModernUO.Serialization; using Server.Collections; -using Server.Network; using Server.Spells; using Server.Targeting; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public abstract partial class BaseExplosionPotion : BasePotion { - public abstract class BaseExplosionPotion : BasePotion + private const int ExplosionRange = 2; // How long is the blast radius? + + private const bool LeveledExplosion = false; // Should explosion potions explode other nearby potions? + private const bool InstantExplosion = false; // Should explosion potions explode on impact? + private const bool RelativeLocation = false; // Is the explosion target location relative for mobiles? + + private Timer _timer; + + public BaseExplosionPotion(PotionEffect effect) : base(0xF0D, effect) { - private const int ExplosionRange = 2; // How long is the blast radius? + } - private const bool LeveledExplosion = false; // Should explosion potions explode other nearby potions? - private const bool InstantExplosion = false; // Should explosion potions explode on impact? - private const bool RelativeLocation = false; // Is the explosion target location relative for mobiles? + public abstract int MinDamage { get; } + public abstract int MaxDamage { get; } - private Timer _timer; + public override bool RequireFreeHand => false; - public BaseExplosionPotion(PotionEffect effect) : base(0xF0D, effect) + private HashSet _users; + + public virtual IEntity FindParent(Mobile from) + { + if (HeldBy?.Holding == this) { + return HeldBy; } - public BaseExplosionPotion(Serial serial) : base(serial) + if (RootParent != null) { + return RootParent; } - public abstract int MinDamage { get; } - public abstract int MaxDamage { get; } - - public override bool RequireFreeHand => false; - - private HashSet _users; - - public override void Serialize(IGenericWriter writer) + if (Map == Map.Internal) { - base.Serialize(writer); - - writer.Write(0); // version + return from; } - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); + return this; + } - var version = reader.ReadInt(); + public override void Drink(Mobile from) + { + if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true)) + { + from.SendLocalizedMessage(1062725); // You can not use a purple potion while paralyzed. + return; } - public virtual IEntity FindParent(Mobile from) + var targ = from.Target as ThrowTarget; + Stackable = false; // Scavenged explosion potions won't stack with those ones in backpack, and still will explode. + + if (targ?.Potion == this) { - if (HeldBy?.Holding == this) - { - return HeldBy; - } - - if (RootParent != null) - { - return RootParent; - } - - if (Map == Map.Internal) - { - return from; - } - - return this; + return; } - public override void Drink(Mobile from) + from.RevealingAction(); + + _users ??= new HashSet(); + _users.Add(from); + + from.Target = new ThrowTarget(this); + + if (_timer?.Running != true) { - if (Core.AOS && (from.Paralyzed || from.Frozen || from.Spell?.IsCasting == true)) + from.SendLocalizedMessage(500236); // You should throw it now! + + if (Core.ML) { - from.SendLocalizedMessage(1062725); // You can not use a purple potion while paralyzed. - return; - } - - var targ = from.Target as ThrowTarget; - Stackable = false; // Scavenged explosion potions won't stack with those ones in backpack, and still will explode. - - if (targ?.Potion == this) - { - return; - } - - from.RevealingAction(); - - _users ??= new HashSet(); - _users.Add(from); - - from.Target = new ThrowTarget(this); - - if (_timer?.Running != true) - { - from.SendLocalizedMessage(500236); // You should throw it now! - - if (Core.ML) - { - _timer = new DetonateTimer(this, from, TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.25), 5); - } - else - { - _timer = new DetonateTimer(this, from, TimeSpan.FromSeconds(0.75), TimeSpan.FromSeconds(1.0), 4); - } - - _timer.Start(); - } - } - - private void Reposition_OnTick(Mobile from, Point3D loc, Map map) - { - if (Deleted) - { - return; - } - - if (InstantExplosion || _timer?.Running != true) - { - Explode(from, true, loc, map); + _timer = new DetonateTimer(this, from, TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.25), 5); } else { - MoveToWorld(loc, map); + _timer = new DetonateTimer(this, from, TimeSpan.FromSeconds(0.75), TimeSpan.FromSeconds(1.0), 4); } + + _timer.Start(); + } + } + + private void Reposition_OnTick(Mobile from, Point3D loc, Map map) + { + if (Deleted) + { + return; } - public void Explode(Mobile from, bool direct, Point3D loc, Map map) + if (InstantExplosion || _timer?.Running != true) { - if (Deleted) - { - return; - } + Explode(from, true, loc, map); + } + else + { + MoveToWorld(loc, map); + } + } - Consume(); + public void Explode(Mobile from, bool direct, Point3D loc, Map map) + { + if (Deleted) + { + return; + } + Consume(); + + if (_users != null) + { foreach (var user in _users) { - if (user.Target is ThrowTarget targ && targ.Potion == this) + if ((user.Target as ThrowTarget)?.Potion == this) { Target.Cancel(user); } } _users.Clear(); + } + + if (map == null) + { + return; + } + + Effects.PlaySound(loc, map, 0x307); + Effects.SendLocationEffect(loc, map, 0x36B0, 9); + + var alchemyBonus = 0; + if (direct) + { + alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10)); + } + + var eable = map.GetObjectsInRange(loc, ExplosionRange); + using var queue = PooledRefQueue.Create(); + + var toDamage = 0; + foreach (var entity in eable) + { + if (entity == this) + { + continue; + } + + if (entity is Mobile mobile) + { + if (from == null || SpellHelper.ValidIndirectTarget(from, mobile) && from.CanBeHarmful(mobile, false)) + { + ++toDamage; + queue.Enqueue(entity); + } + } + else if (LeveledExplosion && entity is BaseExplosionPotion) + { + queue.Enqueue(entity); + } + } + + eable.Free(); + + var min = Scale(from, MinDamage); + var max = Scale(from, MaxDamage); + + while (queue.Count > 0) + { + var entity = queue.Dequeue(); + + if (entity is Mobile m) + { + from?.DoHarmful(m); + + var damage = Utility.RandomMinMax(min, max) + alchemyBonus; + + if (!Core.AOS && damage > 40) + { + damage = 40; + } + else if (Core.AOS && toDamage > 2) + { + damage /= toDamage - 1; + } + + AOS.Damage(m, from, damage, 0, 100, 0, 0, 0); + } + else if (entity is BaseExplosionPotion pot) + { + pot.Explode(from, false, pot.GetWorldLocation(), pot.Map); + } + } + } + + private class ThrowTarget : Target + { + public ThrowTarget(BaseExplosionPotion potion) : base(Core.ML ? 12 : 10, true, TargetFlags.None) => Potion = potion; + + public BaseExplosionPotion Potion { get; } + + protected override void OnTarget(Mobile from, object targeted) + { + if (Potion.Deleted || Potion.Map == Map.Internal) + { + return; + } + + if (targeted is not IPoint3D p) + { + return; + } + + var map = from.Map; if (map == null) { return; } - Effects.PlaySound(loc, map, 0x307); - Effects.SendLocationEffect(loc, map, 0x36B0, 9); + SpellHelper.GetSurfaceTop(ref p); + var loc = new Point3D(p); - var alchemyBonus = 0; - if (direct) + from.RevealingAction(); + + IEntity to = new Entity(Serial.Zero, loc, map); + + if (p is Mobile m) { - alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10)); - } - - var eable = map.GetObjectsInRange(loc, ExplosionRange); - using var queue = PooledRefQueue.Create(); - - var toDamage = 0; - foreach (var entity in eable) - { - if (entity == this) + if (!RelativeLocation) // explosion location = current mob location. { - continue; + loc = m.Location; } - - if (entity is Mobile mobile) + else { - if (from == null || SpellHelper.ValidIndirectTarget(from, mobile) && from.CanBeHarmful(mobile, false)) - { - ++toDamage; - queue.Enqueue(entity); - } - } - else if (LeveledExplosion && entity is BaseExplosionPotion) - { - queue.Enqueue(entity); + to = m; } } - eable.Free(); + Effects.SendMovingEffect(from, to, Potion.ItemID, 7, 0, false, false, Potion.Hue); - var min = Scale(from, MinDamage); - var max = Scale(from, MaxDamage); - - while (queue.Count > 0) + if (Potion.Amount > 1) { - var entity = queue.Dequeue(); - - if (entity is Mobile m) - { - from?.DoHarmful(m); - - var damage = Utility.RandomMinMax(min, max) + alchemyBonus; - - if (!Core.AOS && damage > 40) - { - damage = 40; - } - else if (Core.AOS && toDamage > 2) - { - damage /= toDamage - 1; - } - - AOS.Damage(m, from, damage, 0, 100, 0, 0, 0); - } - else if (entity is BaseExplosionPotion pot) - { - pot.Explode(from, false, pot.GetWorldLocation(), pot.Map); - } + Mobile.LiftItemDupe(Potion, 1); } + + Potion.Internalize(); + + var delay = TimeSpan.FromSeconds(0.1 * from.GetDistanceToSqrt(loc)); + + // If the potion is about to explode, stop the timer so it doesn't explode on you, while it is mid-air + if (Potion._timer.RemainingCount <= 1 && Potion._timer.Next <= Core.Now + delay) + { + Potion._timer.Stop(); + } + + Timer.StartTimer(delay, () => Potion.Reposition_OnTick(from, loc, map)); + } + } + + private class DetonateTimer : Timer + { + private BaseExplosionPotion _potion; + private Mobile _from; + + public DetonateTimer(BaseExplosionPotion potion, Mobile from, TimeSpan delay, TimeSpan interval, int count) : base(delay, interval, count) + { + _from = from; + _potion = potion; } - private class ThrowTarget : Target + protected override void OnTick() { - public ThrowTarget(BaseExplosionPotion potion) : base(Core.ML ? 12 : 10, true, TargetFlags.None) => Potion = potion; - - public BaseExplosionPotion Potion { get; } - - protected override void OnTarget(Mobile from, object targeted) + if (_potion.Deleted) { - if (Potion.Deleted || Potion.Map == Map.Internal) - { - return; - } - - if (targeted is not IPoint3D p) - { - return; - } - - var map = from.Map; - - if (map == null) - { - return; - } - - SpellHelper.GetSurfaceTop(ref p); - var loc = new Point3D(p); - - from.RevealingAction(); - - IEntity to = new Entity(Serial.Zero, loc, map); - - if (p is Mobile m) - { - if (!RelativeLocation) // explosion location = current mob location. - { - loc = m.Location; - } - else - { - to = m; - } - } - - Effects.SendMovingEffect(from, to, Potion.ItemID, 7, 0, false, false, Potion.Hue); - - if (Potion.Amount > 1) - { - Mobile.LiftItemDupe(Potion, 1); - } - - Potion.Internalize(); - - var delay = TimeSpan.FromSeconds(0.1 * from.GetDistanceToSqrt(loc)); - - // If the potion is about to explode, stop the timer so it doesn't explode on you, while it is mid-air - if (Potion._timer.RemainingCount <= 1 && Potion._timer.Next <= Core.Now + delay) - { - Potion._timer.Stop(); - } - - Timer.StartTimer(delay, () => Potion.Reposition_OnTick(from, loc, map)); - } - } - - private class DetonateTimer : Timer - { - private BaseExplosionPotion _potion; - private Mobile _from; - - public DetonateTimer(BaseExplosionPotion potion, Mobile from, TimeSpan delay, TimeSpan interval, int count) : base(delay, interval, count) - { - _from = from; - _potion = potion; + return; } - protected override void OnTick() + var parent = _potion.FindParent(_from); + + if (RemainingCount == 0) { - if (_potion.Deleted) + Point3D loc; + Map map; + + if (parent is Item item) + { + loc = item.GetWorldLocation(); + map = item.Map; + } + else if (parent is Mobile m) + { + loc = m.Location; + map = m.Map; + } + else { return; } - var parent = _potion.FindParent(_from); - - if (RemainingCount == 0) + _potion.Explode(_from, true, loc, map); + } + else if (RemainingCount <= 3) + { + if (parent is Item item) { - Point3D loc; - Map map; - - if (parent is Item item) - { - loc = item.GetWorldLocation(); - map = item.Map; - } - else if (parent is Mobile m) - { - loc = m.Location; - map = m.Map; - } - else - { - return; - } - - _potion.Explode(_from, true, loc, map); + item.PublicOverheadMessage(MessageType.Regular, 0x22, false, RemainingCount.ToString()); } - else if (RemainingCount <= 3) + else if (parent is Mobile mobile) { - if (parent is Item item) - { - item.PublicOverheadMessage(MessageType.Regular, 0x22, false, RemainingCount.ToString()); - } - else if (parent is Mobile mobile) - { - mobile.PublicOverheadMessage(MessageType.Regular, 0x22, false, RemainingCount.ToString()); - } + mobile.PublicOverheadMessage(MessageType.Regular, 0x22, false, RemainingCount.ToString()); } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/ExplosionPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/ExplosionPotion.cs index c11fd7d1f..eda66c7ff 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/ExplosionPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/ExplosionPotion.cs @@ -1,31 +1,15 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class ExplosionPotion : BaseExplosionPotion { - public class ExplosionPotion : BaseExplosionPotion + [Constructible] + public ExplosionPotion() : base(PotionEffect.Explosion) { - [Constructible] - public ExplosionPotion() : base(PotionEffect.Explosion) - { - } - - public ExplosionPotion(Serial serial) : base(serial) - { - } - - public override int MinDamage => 10; - public override int MaxDamage => 20; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int MinDamage => 10; + public override int MaxDamage => 20; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/GreaterExplosionPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/GreaterExplosionPotion.cs index 1f3a2b392..a3d32b94b 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/GreaterExplosionPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/GreaterExplosionPotion.cs @@ -1,31 +1,15 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class GreaterExplosionPotion : BaseExplosionPotion { - public class GreaterExplosionPotion : BaseExplosionPotion + [Constructible] + public GreaterExplosionPotion() : base(PotionEffect.ExplosionGreater) { - [Constructible] - public GreaterExplosionPotion() : base(PotionEffect.ExplosionGreater) - { - } - - public GreaterExplosionPotion(Serial serial) : base(serial) - { - } - - public override int MinDamage => Core.AOS ? 20 : 15; - public override int MaxDamage => Core.AOS ? 40 : 30; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int MinDamage => Core.AOS ? 20 : 15; + public override int MaxDamage => Core.AOS ? 40 : 30; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/LesserExplosionPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/LesserExplosionPotion.cs index 865aa23f1..24f4114cf 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/LesserExplosionPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/LesserExplosionPotion.cs @@ -1,31 +1,15 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class LesserExplosionPotion : BaseExplosionPotion { - public class LesserExplosionPotion : BaseExplosionPotion + [Constructible] + public LesserExplosionPotion() : base(PotionEffect.ExplosionLesser) { - [Constructible] - public LesserExplosionPotion() : base(PotionEffect.ExplosionLesser) - { - } - - public LesserExplosionPotion(Serial serial) : base(serial) - { - } - - public override int MinDamage => 5; - public override int MaxDamage => 10; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int MinDamage => 5; + public override int MaxDamage => 10; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs index d4eec3842..7828ac647 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs @@ -1,81 +1,60 @@ using System; +using ModernUO.Serialization; using Server.Engines.ConPVP; -using Server.Network; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public abstract partial class BaseHealPotion : BasePotion { - public abstract class BaseHealPotion : BasePotion + public BaseHealPotion(PotionEffect effect) : base(0xF0C, effect) { - public BaseHealPotion(PotionEffect effect) : base(0xF0C, effect) + } + + public abstract int MinHeal { get; } + public abstract int MaxHeal { get; } + public abstract double Delay { get; } + + public void DoHeal(Mobile from) + { + var min = Scale(from, MinHeal); + var max = Scale(from, MaxHeal); + + from.Heal(Utility.RandomMinMax(min, max)); + } + + public override void Drink(Mobile from) + { + if (from.Hits >= from.HitsMax) { + // You decide against drinking this potion, as you are already at full health. + from.SendLocalizedMessage(1049547); + return; } - public BaseHealPotion(Serial serial) : base(serial) + if (from.Poisoned || MortalStrike.IsWounded(from)) { + // You can not heal yourself in your current state. + from.LocalOverheadMessage(MessageType.Regular, 0x22, 1005000); + return; } - public abstract int MinHeal { get; } - public abstract int MaxHeal { get; } - public abstract double Delay { get; } - - public override void Serialize(IGenericWriter writer) + if (!from.BeginAction()) { - base.Serialize(writer); - - writer.Write(0); // version + // You must wait 10 seconds before using another healing potion. + from.LocalOverheadMessage(MessageType.Regular, 0x22, 500235); + return; } - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); + DoHeal(from); - var version = reader.ReadInt(); + PlayDrinkEffect(from); + + if (!DuelContext.IsFreeConsume(from)) + { + Consume(); } - public void DoHeal(Mobile from) - { - var min = Scale(from, MinHeal); - var max = Scale(from, MaxHeal); - - from.Heal(Utility.RandomMinMax(min, max)); - } - - public override void Drink(Mobile from) - { - if (from.Hits < from.HitsMax) - { - if (from.Poisoned || MortalStrike.IsWounded(from)) - { - // You can not heal yourself in your current state. - from.LocalOverheadMessage(MessageType.Regular, 0x22, 1005000); - } - else - { - if (from.BeginAction()) - { - DoHeal(from); - - PlayDrinkEffect(from); - - if (!DuelContext.IsFreeConsume(from)) - { - Consume(); - } - - Timer.StartTimer(TimeSpan.FromSeconds(Delay), from.EndAction); - } - else - { - // You must wait 10 seconds before using another healing potion. - from.LocalOverheadMessage(MessageType.Regular, 0x22, 500235); - } - } - } - else - { - // You decide against drinking this potion, as you are already at full health. - from.SendLocalizedMessage(1049547); - } - } + Timer.StartTimer(TimeSpan.FromSeconds(Delay), from.EndAction); } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/GreaterHealPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/GreaterHealPotion.cs index d10cd3b54..c7cf515df 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/GreaterHealPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/GreaterHealPotion.cs @@ -1,32 +1,16 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class GreaterHealPotion : BaseHealPotion { - public class GreaterHealPotion : BaseHealPotion + [Constructible] + public GreaterHealPotion() : base(PotionEffect.HealGreater) { - [Constructible] - public GreaterHealPotion() : base(PotionEffect.HealGreater) - { - } - - public GreaterHealPotion(Serial serial) : base(serial) - { - } - - public override int MinHeal => Core.AOS ? 20 : 9; - public override int MaxHeal => Core.AOS ? 25 : 30; - public override double Delay => 10.0; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int MinHeal => Core.AOS ? 20 : 9; + public override int MaxHeal => Core.AOS ? 25 : 30; + public override double Delay => 10.0; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/HealPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/HealPotion.cs index c0a84fc02..231275e94 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/HealPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/HealPotion.cs @@ -1,32 +1,16 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class HealPotion : BaseHealPotion { - public class HealPotion : BaseHealPotion + [Constructible] + public HealPotion() : base(PotionEffect.Heal) { - [Constructible] - public HealPotion() : base(PotionEffect.Heal) - { - } - - public HealPotion(Serial serial) : base(serial) - { - } - - public override int MinHeal => Core.AOS ? 13 : 6; - public override int MaxHeal => Core.AOS ? 16 : 20; - public override double Delay => Core.AOS ? 8.0 : 10.0; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int MinHeal => Core.AOS ? 13 : 6; + public override int MaxHeal => Core.AOS ? 16 : 20; + public override double Delay => Core.AOS ? 8.0 : 10.0; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/LesserHealPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/LesserHealPotion.cs index fa0df768a..c27676e20 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/LesserHealPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Heal Potions/LesserHealPotion.cs @@ -1,32 +1,16 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class LesserHealPotion : BaseHealPotion { - public class LesserHealPotion : BaseHealPotion + [Constructible] + public LesserHealPotion() : base(PotionEffect.HealLesser) { - [Constructible] - public LesserHealPotion() : base(PotionEffect.HealLesser) - { - } - - public LesserHealPotion(Serial serial) : base(serial) - { - } - - public override int MinHeal => Core.AOS ? 6 : 3; - public override int MaxHeal => Core.AOS ? 8 : 10; - public override double Delay => Core.AOS ? 3.0 : 10.0; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int MinHeal => Core.AOS ? 6 : 3; + public override int MaxHeal => Core.AOS ? 8 : 10; + public override double Delay => Core.AOS ? 3.0 : 10.0; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs index 7c16e3243..31d655978 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs @@ -1,95 +1,79 @@ using System; using System.Collections.Generic; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class InvisibilityPotion : BasePotion { - public class InvisibilityPotion : BasePotion + private static readonly Dictionary m_Table = new(); + + [Constructible] + public InvisibilityPotion() : base(0xF0A, PotionEffect.Invisibility) => Hue = 0x48D; + + public override int LabelNumber => 1072941; // Potion of Invisibility + + public override void Drink(Mobile from) { - private static readonly Dictionary m_Table = new(); - - [Constructible] - public InvisibilityPotion() : base(0xF0A, PotionEffect.Invisibility) => Hue = 0x48D; - - public InvisibilityPotion(Serial serial) : base(serial) + if (from.Hidden) { + from.SendLocalizedMessage(1073185); // You are already unseen. + return; } - public override int LabelNumber => 1072941; // Potion of Invisibility - - public override void Drink(Mobile from) + if (HasTimer(from)) { - if (from.Hidden) + from.SendLocalizedMessage(1073186); // An invisibility potion is already taking effect on your person. + return; + } + + Consume(); + Timer.StartTimer(TimeSpan.FromSeconds(2), () => Hide(from), out var timerToken); + m_Table[from] = timerToken; + PlayDrinkEffect(from); + } + + public static void Hide(Mobile m) + { + Effects.SendLocationParticles( + EffectItem.Create(new Point3D(m.X, m.Y, m.Z + 16), m.Map, EffectItem.DefaultDuration), + 0x376A, + 10, + 15, + 5045 + ); + + m.PlaySound(0x3C4); + + m.Hidden = true; + + BuffInfo.RemoveBuff(m, BuffIcon.HidingAndOrStealth); + BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Invisibility, 1075825)); // Invisibility/Invisible + + RemoveTimer(m); + + Timer.StartTimer(TimeSpan.FromSeconds(30), () => EndHide(m)); + } + + public static void EndHide(Mobile m) + { + m.RevealingAction(); + RemoveTimer(m); + } + + public static bool HasTimer(Mobile m) => m_Table.ContainsKey(m); + + public static void RemoveTimer(Mobile m, bool interrupted = false) + { + if (m_Table.Remove(m, out var timer)) + { + if (interrupted) { - from.SendLocalizedMessage(1073185); // You are already unseen. - return; + m.SendLocalizedMessage(1073187); // The invisibility effect is interrupted. } - if (HasTimer(from)) - { - from.SendLocalizedMessage(1073186); // An invisibility potion is already taking effect on your person. - return; - } - - Consume(); - Timer.StartTimer(TimeSpan.FromSeconds(2), () => Hide(from), out var timerToken); - m_Table[from] = timerToken; - PlayDrinkEffect(from); - } - - public static void Hide(Mobile m) - { - Effects.SendLocationParticles( - EffectItem.Create(new Point3D(m.X, m.Y, m.Z + 16), m.Map, EffectItem.DefaultDuration), - 0x376A, - 10, - 15, - 5045 - ); - m.PlaySound(0x3C4); - - m.Hidden = true; - - BuffInfo.RemoveBuff(m, BuffIcon.HidingAndOrStealth); - BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Invisibility, 1075825)); // Invisibility/Invisible - - RemoveTimer(m); - - Timer.StartTimer(TimeSpan.FromSeconds(30), () => EndHide(m)); - } - - public static void EndHide(Mobile m) - { - m.RevealingAction(); - RemoveTimer(m); - } - - public static bool HasTimer(Mobile m) => m_Table.ContainsKey(m); - - public static void RemoveTimer(Mobile m, bool interrupted = false) - { - if (m_Table.Remove(m, out var timer)) - { - if (interrupted) - { - m.SendLocalizedMessage(1073187); // The invisibility effect is interrupted. - } - - timer.Cancel(); - } - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); + timer.Cancel(); } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/NightSight.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/NightSight.cs index 2170db7c7..1711a7ecf 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/NightSight.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/NightSight.cs @@ -1,53 +1,36 @@ +using ModernUO.Serialization; using Server.Engines.ConPVP; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class NightSightPotion : BasePotion { - public class NightSightPotion : BasePotion + [Constructible] + public NightSightPotion() : base(0xF06, PotionEffect.Nightsight) { - [Constructible] - public NightSightPotion() : base(0xF06, PotionEffect.Nightsight) + } + + public override void Drink(Mobile from) + { + if (from.BeginAction()) { - } + new LightCycle.NightSightTimer(from).Start(); + from.LightLevel = LightCycle.DungeonLevel / 2; - public NightSightPotion(Serial serial) : base(serial) - { - } + from.FixedParticles(0x376A, 9, 32, 5007, EffectLayer.Waist); + from.PlaySound(0x1E3); - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); + PlayDrinkEffect(from); - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } - - public override void Drink(Mobile from) - { - if (from.BeginAction()) + if (!DuelContext.IsFreeConsume(from)) { - new LightCycle.NightSightTimer(from).Start(); - from.LightLevel = LightCycle.DungeonLevel / 2; - - from.FixedParticles(0x376A, 9, 32, 5007, EffectLayer.Waist); - from.PlaySound(0x1E3); - - PlayDrinkEffect(from); - - if (!DuelContext.IsFreeConsume(from)) - { - Consume(); - } - } - else - { - from.SendMessage("You already have nightsight."); + Consume(); } } + else + { + from.SendMessage("You already have nightsight."); + } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/ParasiticPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/ParasiticPotion.cs deleted file mode 100644 index 455ea3eaf..000000000 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/ParasiticPotion.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Server.Items -{ - public class ParasiticPotion : BasePoisonPotion - { - [Constructible] - public ParasiticPotion() : base(PotionEffect.Parasitic) => Hue = 0x17C; - - public ParasiticPotion(Serial serial) : base(serial) - { - } - - /* public override Poison Poison => Poison.Darkglow; MUST be restored when prerequisites are done */ - public override Poison Poison => Poison.Greater; - - public override double MinPoisoningSkill => 95.0; - public override double MaxPoisoningSkill => 100.0; - - public override int LabelNumber => 1072848; // Parasitic Poison - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } - } -} diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs index d2cafee0f..8c5275b00 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs @@ -1,51 +1,38 @@ +using ModernUO.Serialization; using Server.Engines.ConPVP; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public abstract partial class BasePoisonPotion : BasePotion { - public abstract class BasePoisonPotion : BasePotion + public BasePoisonPotion(PotionEffect effect) : base(0xF0A, effect) { - public BasePoisonPotion(PotionEffect effect) : base(0xF0A, effect) + } + + public BasePoisonPotion(Serial serial) : base(serial) + { + } + + public abstract Poison Poison { get; } + + public abstract double MinPoisoningSkill { get; } + public abstract double MaxPoisoningSkill { get; } + + public void DoPoison(Mobile from) + { + from.ApplyPoison(from, Poison); + } + + public override void Drink(Mobile from) + { + DoPoison(from); + + PlayDrinkEffect(from); + + if (!DuelContext.IsFreeConsume(from)) { - } - - public BasePoisonPotion(Serial serial) : base(serial) - { - } - - public abstract Poison Poison { get; } - - public abstract double MinPoisoningSkill { get; } - public abstract double MaxPoisoningSkill { get; } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } - - public void DoPoison(Mobile from) - { - from.ApplyPoison(from, Poison); - } - - public override void Drink(Mobile from) - { - DoPoison(from); - - PlayDrinkEffect(from); - - if (!DuelContext.IsFreeConsume(from)) - { - Consume(); - } + Consume(); } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/DarkglowPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/DarkglowPotion.cs new file mode 100644 index 000000000..03cc56966 --- /dev/null +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/DarkglowPotion.cs @@ -0,0 +1,18 @@ +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class DarkglowPotion : BasePoisonPotion +{ + [Constructible] + public DarkglowPotion() : base(PotionEffect.Darkglow) => Hue = 0x96; + + /* public override Poison Poison => Poison.DarkGlow; // MUST be restored when prerequisites are done */ + public override Poison Poison => Poison.Greater; + + public override double MinPoisoningSkill => 95.0; + public override double MaxPoisoningSkill => 100.0; + + public override int LabelNumber => 1072849; // Darkglow Poison +} diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/DeadlyPoisonPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/DeadlyPoisonPotion.cs index 3ebfc356c..8ecb1990d 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/DeadlyPoisonPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/DeadlyPoisonPotion.cs @@ -1,33 +1,17 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class DeadlyPoisonPotion : BasePoisonPotion { - public class DeadlyPoisonPotion : BasePoisonPotion + [Constructible] + public DeadlyPoisonPotion() : base(PotionEffect.PoisonDeadly) { - [Constructible] - public DeadlyPoisonPotion() : base(PotionEffect.PoisonDeadly) - { - } - - public DeadlyPoisonPotion(Serial serial) : base(serial) - { - } - - public override Poison Poison => Poison.Deadly; - - public override double MinPoisoningSkill => 95.0; - public override double MaxPoisoningSkill => 100.0; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override Poison Poison => Poison.Deadly; + + public override double MinPoisoningSkill => 95.0; + public override double MaxPoisoningSkill => 100.0; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/GreaterPoisonPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/GreaterPoisonPotion.cs index ac7eca634..66999b693 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/GreaterPoisonPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/GreaterPoisonPotion.cs @@ -1,33 +1,17 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class GreaterPoisonPotion : BasePoisonPotion { - public class GreaterPoisonPotion : BasePoisonPotion + [Constructible] + public GreaterPoisonPotion() : base(PotionEffect.PoisonGreater) { - [Constructible] - public GreaterPoisonPotion() : base(PotionEffect.PoisonGreater) - { - } - - public GreaterPoisonPotion(Serial serial) : base(serial) - { - } - - public override Poison Poison => Poison.Greater; - - public override double MinPoisoningSkill => 60.0; - public override double MaxPoisoningSkill => 100.0; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override Poison Poison => Poison.Greater; + + public override double MinPoisoningSkill => 60.0; + public override double MaxPoisoningSkill => 100.0; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/LesserPoisonPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/LesserPoisonPotion.cs index 63df6f97c..a0b2f997a 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/LesserPoisonPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/LesserPoisonPotion.cs @@ -1,33 +1,17 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class LesserPoisonPotion : BasePoisonPotion { - public class LesserPoisonPotion : BasePoisonPotion + [Constructible] + public LesserPoisonPotion() : base(PotionEffect.PoisonLesser) { - [Constructible] - public LesserPoisonPotion() : base(PotionEffect.PoisonLesser) - { - } - - public LesserPoisonPotion(Serial serial) : base(serial) - { - } - - public override Poison Poison => Poison.Lesser; - - public override double MinPoisoningSkill => 0.0; - public override double MaxPoisoningSkill => 60.0; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override Poison Poison => Poison.Lesser; + + public override double MinPoisoningSkill => 0.0; + public override double MaxPoisoningSkill => 60.0; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/ParasiticPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/ParasiticPotion.cs new file mode 100644 index 000000000..460531c9e --- /dev/null +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/ParasiticPotion.cs @@ -0,0 +1,16 @@ +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class ParasiticPotion : BasePoisonPotion +{ + [Constructible] + public ParasiticPotion() : base(PotionEffect.Parasitic) => Hue = 0x17C; + + /* public override Poison Poison => Poison.Parasitic; // MUST be restored when prerequisites are done */ + public override Poison Poison => Poison.Greater; + + public override double MinPoisoningSkill => 95.0; + public override double MaxPoisoningSkill => 100.0; +} diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/PoisonPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/PoisonPotion.cs index 6643b05a3..3c25c20df 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/PoisonPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Poison Potions/PoisonPotion.cs @@ -1,33 +1,17 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class PoisonPotion : BasePoisonPotion { - public class PoisonPotion : BasePoisonPotion + [Constructible] + public PoisonPotion() : base(PotionEffect.Poison) { - [Constructible] - public PoisonPotion() : base(PotionEffect.Poison) - { - } - - public PoisonPotion(Serial serial) : base(serial) - { - } - - public override Poison Poison => Poison.Regular; - - public override double MinPoisoningSkill => 30.0; - public override double MaxPoisoningSkill => 70.0; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override Poison Poison => Poison.Regular; + + public override double MinPoisoningSkill => 30.0; + public override double MaxPoisoningSkill => 70.0; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs index 0ccddaf94..410f8d9e4 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs @@ -1,50 +1,33 @@ +using ModernUO.Serialization; using Server.Engines.ConPVP; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public abstract partial class BaseRefreshPotion : BasePotion { - public abstract class BaseRefreshPotion : BasePotion + public BaseRefreshPotion(PotionEffect effect) : base(0xF0B, effect) { - public BaseRefreshPotion(PotionEffect effect) : base(0xF0B, effect) + } + + public abstract double Refresh { get; } + + public override void Drink(Mobile from) + { + if (from.Stam < from.StamMax) { - } + from.Stam += Scale(from, (int)(Refresh * from.StamMax)); - public BaseRefreshPotion(Serial serial) : base(serial) - { - } + PlayDrinkEffect(from); - public abstract double Refresh { get; } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } - - public override void Drink(Mobile from) - { - if (from.Stam < from.StamMax) + if (!DuelContext.IsFreeConsume(from)) { - from.Stam += Scale(from, (int)(Refresh * from.StamMax)); - - PlayDrinkEffect(from); - - if (!DuelContext.IsFreeConsume(from)) - { - Consume(); - } - } - else - { - from.SendMessage("You decide against drinking this potion, as you are already at full stamina."); + Consume(); } } + else + { + from.SendMessage("You decide against drinking this potion, as you are already at full stamina."); + } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/RefreshPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/RefreshPotion.cs index 69045a167..3ca4a719a 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/RefreshPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/RefreshPotion.cs @@ -1,30 +1,14 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class RefreshPotion : BaseRefreshPotion { - public class RefreshPotion : BaseRefreshPotion + [Constructible] + public RefreshPotion() : base(PotionEffect.Refresh) { - [Constructible] - public RefreshPotion() : base(PotionEffect.Refresh) - { - } - - public RefreshPotion(Serial serial) : base(serial) - { - } - - public override double Refresh => 0.25; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override double Refresh => 0.25; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/TotalRefreshPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/TotalRefreshPotion.cs index b87b124f5..8642666ae 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/TotalRefreshPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Refresh Potions/TotalRefreshPotion.cs @@ -1,30 +1,14 @@ -namespace Server.Items +using ModernUO.Serialization; + +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class TotalRefreshPotion : BaseRefreshPotion { - public class TotalRefreshPotion : BaseRefreshPotion + [Constructible] + public TotalRefreshPotion() : base(PotionEffect.RefreshTotal) { - [Constructible] - public TotalRefreshPotion() : base(PotionEffect.RefreshTotal) - { - } - - public TotalRefreshPotion(Serial serial) : base(serial) - { - } - - public override double Refresh => 1.0; - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override double Refresh => 1.0; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs index 08cc28f82..10b49f679 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs @@ -1,60 +1,43 @@ using System; +using ModernUO.Serialization; using Server.Engines.ConPVP; using Server.Spells; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public abstract partial class BaseStrengthPotion : BasePotion { - public abstract class BaseStrengthPotion : BasePotion + public BaseStrengthPotion(PotionEffect effect) : base(0xF09, effect) { - public BaseStrengthPotion(PotionEffect effect) : base(0xF09, effect) + } + + public abstract int StrOffset { get; } + public abstract TimeSpan Duration { get; } + + public bool DoStrength(Mobile from) + { + // TODO: Verify scaled; is it offset, duration, or both? + if (SpellHelper.AddStatOffset(from, StatType.Str, Scale(from, StrOffset), Duration)) { + from.FixedEffect(0x375A, 10, 15); + from.PlaySound(0x1E7); + return true; } - public BaseStrengthPotion(Serial serial) : base(serial) + from.SendLocalizedMessage(502173); // You are already under a similar effect. + return false; + } + + public override void Drink(Mobile from) + { + if (DoStrength(from)) { - } + PlayDrinkEffect(from); - public abstract int StrOffset { get; } - public abstract TimeSpan Duration { get; } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } - - public bool DoStrength(Mobile from) - { - // TODO: Verify scaled; is it offset, duration, or both? - if (SpellHelper.AddStatOffset(from, StatType.Str, Scale(from, StrOffset), Duration)) + if (!DuelContext.IsFreeConsume(from)) { - from.FixedEffect(0x375A, 10, 15); - from.PlaySound(0x1E7); - return true; - } - - from.SendLocalizedMessage(502173); // You are already under a similar effect. - return false; - } - - public override void Drink(Mobile from) - { - if (DoStrength(from)) - { - PlayDrinkEffect(from); - - if (!DuelContext.IsFreeConsume(from)) - { - Consume(); - } + Consume(); } } } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/GreaterStrengthPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/GreaterStrengthPotion.cs index 2dc250429..c338252b9 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/GreaterStrengthPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/GreaterStrengthPotion.cs @@ -1,33 +1,16 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class GreaterStrengthPotion : BaseStrengthPotion { - public class GreaterStrengthPotion : BaseStrengthPotion + [Constructible] + public GreaterStrengthPotion() : base(PotionEffect.StrengthGreater) { - [Constructible] - public GreaterStrengthPotion() : base(PotionEffect.StrengthGreater) - { - } - - public GreaterStrengthPotion(Serial serial) : base(serial) - { - } - - public override int StrOffset => 20; - public override TimeSpan Duration => TimeSpan.FromMinutes(2.0); - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public override int StrOffset => 20; + public override TimeSpan Duration => TimeSpan.FromMinutes(2.0); } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/StrengthPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/StrengthPotion.cs index 50ba010a5..833a0b5d0 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/StrengthPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Strength Potions/StrengthPotion.cs @@ -1,33 +1,20 @@ using System; +using ModernUO.Serialization; -namespace Server.Items +namespace Server.Items; + +[SerializationGenerator(0, false)] +public partial class StrengthPotion : BaseStrengthPotion { - public class StrengthPotion : BaseStrengthPotion + [Constructible] + public StrengthPotion() : base(PotionEffect.Strength) { - [Constructible] - public StrengthPotion() : base(PotionEffect.Strength) - { - } - - public StrengthPotion(Serial serial) : base(serial) - { - } - - public override int StrOffset => 10; - public override TimeSpan Duration => TimeSpan.FromMinutes(2.0); - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); // version - } - - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); - - var version = reader.ReadInt(); - } } + + public StrengthPotion(Serial serial) : base(serial) + { + } + + public override int StrOffset => 10; + public override TimeSpan Duration => TimeSpan.FromMinutes(2.0); } diff --git a/Projects/UOContent/Migrations/Server.Items.AgilityPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.AgilityPotion.v0.json new file mode 100644 index 000000000..4f8294455 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.AgilityPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.AgilityPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseAgilityPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseAgilityPotion.v0.json new file mode 100644 index 000000000..703b35666 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseAgilityPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BaseAgilityPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseConflagrationPotion.InternalItem.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseConflagrationPotion.InternalItem.v0.json new file mode 100644 index 000000000..33528bc0f --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseConflagrationPotion.InternalItem.v0.json @@ -0,0 +1,35 @@ +{ + "version": 0, + "type": "Server.Items.BaseConflagrationPotion.InternalItem", + "properties": [ + { + "name": "From", + "type": "Server.Mobile", + "rule": "SerializableInterfaceMigrationRule" + }, + { + "name": "End", + "type": "System.DateTime", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "MinDamage", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + }, + { + "name": "MaxDamage", + "type": "int", + "rule": "PrimitiveTypeMigrationRule", + "ruleArguments": [ + "" + ] + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseConflagrationPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseConflagrationPotion.v0.json new file mode 100644 index 000000000..7e08d4046 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseConflagrationPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BaseConflagrationPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseConfusionBlastPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseConfusionBlastPotion.v0.json new file mode 100644 index 000000000..92e74c69b --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseConfusionBlastPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BaseConfusionBlastPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseCurePotion.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseCurePotion.v0.json new file mode 100644 index 000000000..92daa81dd --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseCurePotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BaseCurePotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseExplosionPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseExplosionPotion.v0.json new file mode 100644 index 000000000..363e16f7c --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseExplosionPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BaseExplosionPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseHealPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseHealPotion.v0.json new file mode 100644 index 000000000..71364a603 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseHealPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BaseHealPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BasePoisonPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.BasePoisonPotion.v0.json new file mode 100644 index 000000000..d9fc0b271 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BasePoisonPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BasePoisonPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BasePotion.v2.json b/Projects/UOContent/Migrations/Server.Items.BasePotion.v2.json new file mode 100644 index 000000000..40f50ef8a --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BasePotion.v2.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "type": "Server.Items.BasePotion", + "properties": [ + { + "name": "PotionEffect", + "type": "Server.Items.PotionEffect", + "rule": "EnumMigrationRule" + } + ] +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseRefreshPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseRefreshPotion.v0.json new file mode 100644 index 000000000..89ff02345 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseRefreshPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BaseRefreshPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.BaseStrengthPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.BaseStrengthPotion.v0.json new file mode 100644 index 000000000..e90900642 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.BaseStrengthPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.BaseStrengthPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.ConflagrationPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.ConflagrationPotion.v0.json new file mode 100644 index 000000000..4c3712b87 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.ConflagrationPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.ConflagrationPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.ConfusionBlastPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.ConfusionBlastPotion.v0.json new file mode 100644 index 000000000..73041b4be --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.ConfusionBlastPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.ConfusionBlastPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.CurePotion.v0.json b/Projects/UOContent/Migrations/Server.Items.CurePotion.v0.json new file mode 100644 index 000000000..6c2624593 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.CurePotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.CurePotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.DarkglowPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.DarkglowPotion.v0.json new file mode 100644 index 000000000..12313091d --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.DarkglowPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.DarkglowPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.DeadlyPoisonPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.DeadlyPoisonPotion.v0.json new file mode 100644 index 000000000..e1ad5a55a --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.DeadlyPoisonPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.DeadlyPoisonPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.ExplosionPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.ExplosionPotion.v0.json new file mode 100644 index 000000000..97b2dbfb2 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.ExplosionPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.ExplosionPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.GreaterAgilityPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.GreaterAgilityPotion.v0.json new file mode 100644 index 000000000..3f39b86bb --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.GreaterAgilityPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.GreaterAgilityPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.GreaterConflagrationPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.GreaterConflagrationPotion.v0.json new file mode 100644 index 000000000..fa40ede65 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.GreaterConflagrationPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.GreaterConflagrationPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.GreaterConfusionBlastPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.GreaterConfusionBlastPotion.v0.json new file mode 100644 index 000000000..3360bd3f4 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.GreaterConfusionBlastPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.GreaterConfusionBlastPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.GreaterExplosionPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.GreaterExplosionPotion.v0.json new file mode 100644 index 000000000..68d92d7d6 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.GreaterExplosionPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.GreaterExplosionPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.GreaterHealPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.GreaterHealPotion.v0.json new file mode 100644 index 000000000..6e6ac80ad --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.GreaterHealPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.GreaterHealPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.GreaterPoisonPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.GreaterPoisonPotion.v0.json new file mode 100644 index 000000000..a24d3a758 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.GreaterPoisonPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.GreaterPoisonPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.GreaterStrengthPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.GreaterStrengthPotion.v0.json new file mode 100644 index 000000000..e76f7ac8a --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.GreaterStrengthPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.GreaterStrengthPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.HealPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.HealPotion.v0.json new file mode 100644 index 000000000..c1fbca455 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.HealPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.HealPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.InvisibilityPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.InvisibilityPotion.v0.json new file mode 100644 index 000000000..c3909e2f9 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.InvisibilityPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.InvisibilityPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.LesserCurePotion.v0.json b/Projects/UOContent/Migrations/Server.Items.LesserCurePotion.v0.json new file mode 100644 index 000000000..dfcdaefd8 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.LesserCurePotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.LesserCurePotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.LesserExplosionPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.LesserExplosionPotion.v0.json new file mode 100644 index 000000000..11a79a37a --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.LesserExplosionPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.LesserExplosionPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.LesserHealPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.LesserHealPotion.v0.json new file mode 100644 index 000000000..d4d8f0cf1 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.LesserHealPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.LesserHealPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.LesserPoisonPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.LesserPoisonPotion.v0.json new file mode 100644 index 000000000..f39321f5c --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.LesserPoisonPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.LesserPoisonPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.NightSightPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.NightSightPotion.v0.json new file mode 100644 index 000000000..c28809b96 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.NightSightPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.NightSightPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.ParasiticPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.ParasiticPotion.v0.json new file mode 100644 index 000000000..b4602aac8 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.ParasiticPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.ParasiticPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.PoisonPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.PoisonPotion.v0.json new file mode 100644 index 000000000..1ddb9c4d3 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.PoisonPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.PoisonPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.RefreshPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.RefreshPotion.v0.json new file mode 100644 index 000000000..525b2e3d9 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.RefreshPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.RefreshPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.StrengthPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.StrengthPotion.v0.json new file mode 100644 index 000000000..9cee488c7 --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.StrengthPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.StrengthPotion" +} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Items.TotalRefreshPotion.v0.json b/Projects/UOContent/Migrations/Server.Items.TotalRefreshPotion.v0.json new file mode 100644 index 000000000..df3380d6d --- /dev/null +++ b/Projects/UOContent/Migrations/Server.Items.TotalRefreshPotion.v0.json @@ -0,0 +1,4 @@ +{ + "version": 0, + "type": "Server.Items.TotalRefreshPotion" +} \ No newline at end of file