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,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<BaseHealPotion>())
{
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<BaseHealPotion>())
{
DoHeal(from);
PlayDrinkEffect(from);
if (!DuelContext.IsFreeConsume(from))
{
Consume();
}
Timer.StartTimer(TimeSpan.FromSeconds(Delay), from.EndAction<BaseHealPotion>);
}
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<BaseHealPotion>);
}
}

View file

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

View file

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

View file

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