fix: Codegens potions and fixes a few minor bugs (#1347)

This commit is contained in:
Kamron Batman 2023-02-24 18:06:59 -08:00 • committed by GitHub
parent 42bcf3c95a
commit 8c4aaeeda6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
76 changed files with 1644 additions and 2095 deletions

View file

@ -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.
}
}
}

View file

@ -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;
}

View file

@ -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();
}
}

View file

@ -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;
}