diff --git a/Projects/UOContent/Mobiles/Abilities/BloodBathAttack.cs b/Projects/UOContent/Mobiles/Abilities/BloodBathAttack.cs new file mode 100644 index 0000000000..578a6bb0ac --- /dev/null +++ b/Projects/UOContent/Mobiles/Abilities/BloodBathAttack.cs @@ -0,0 +1,49 @@ +using System; + +namespace Server.Mobiles; + +public class BloodBathAttack : MonsterAbilitySingleTargetDoT +{ + public override MonsterAbilityType AbilityType => MonsterAbilityType.BloodBath; + public override MonsterAbilityTrigger AbilityTrigger => MonsterAbilityTrigger.GiveMeleeDamage; + + public override TimeSpan MinDelay => TimeSpan.FromSeconds(1.0); + public override TimeSpan MaxDelay => TimeSpan.FromSeconds(1.0); + + protected override int GetCount(BaseCreature source, Mobile defender) => 5; + + protected override void EffectTick(BaseCreature source, Mobile defender, ref TimeSpan nextDelay) + { + if (defender.Alive) + { + defender.Damage(2, source); + } + else + { + RemoveEffect(source, defender); + } + } + + public override double ChanceToTrigger => 0.1; + + protected override void OnBeforeTarget(MonsterAbilityTrigger trigger, BaseCreature source, Mobile defender) + { + if (RemoveEffect(source, defender)) + { + defender.SendLocalizedMessage(1070825); // The creature continues to rage! + } + else + { + defender.SendLocalizedMessage(1070826); // The creature goes into a rage, inflicting heavy damage! + } + } + + protected override void EndEffect(BaseCreature source, Mobile defender) + { + } + + protected override void OnEffectExpired(BaseCreature source, Mobile defender) + { + defender.SendLocalizedMessage(1070824); // The creature's rage subsides. + } +} diff --git a/Projects/UOContent/Mobiles/Abilities/DrainLifeAttack.cs b/Projects/UOContent/Mobiles/Abilities/DrainLifeAttack.cs index a4b1bb3092..3bf07ce596 100644 --- a/Projects/UOContent/Mobiles/Abilities/DrainLifeAttack.cs +++ b/Projects/UOContent/Mobiles/Abilities/DrainLifeAttack.cs @@ -14,8 +14,25 @@ public class DrainLifeAttack : MonsterAbilitySingleTargetDoT public override double ChanceToTrigger => 0.5; + private void DrainLife(BaseCreature source, Mobile defender) + { + source.DoHarmful(defender); + defender.Mana -= 15; + + if (defender.Alive) + { + var damageGiven = AOS.Damage(defender, source, 5, 0, 0, 0, 0, 100); + source.Hits += damageGiven; + } + else + { + RemoveEffect(source, defender); + defender.SendLocalizedMessage(1070849); // The drain on your life force is gone. + } + } + protected override bool CanEffectTarget(MonsterAbilityTrigger trigger, BaseCreature source, Mobile defender) => - base.CanEffectTarget(trigger, source, defender) && defender.Mana > 14 && !IsUnderEffect(defender); + base.CanEffectTarget(trigger, source, defender) && defender.Mana > 14; protected override void OnBeforeTarget(MonsterAbilityTrigger trigger, BaseCreature source, Mobile defender) { @@ -32,20 +49,12 @@ protected override void OnBeforeTarget(MonsterAbilityTrigger trigger, BaseCreatu protected override void OnTarget(MonsterAbilityTrigger trigger, BaseCreature source, Mobile defender) { base.OnTarget(trigger, source, defender); + DrainLife(source, defender); + } - source.DoHarmful(defender); - defender.Mana -= 15; - - if (defender.Alive) - { - var damageGiven = AOS.Damage(defender, source, 5, 0, 0, 0, 0, 100); - source.Hits += damageGiven; - } - else - { - RemoveEffect(source, defender); - defender.SendLocalizedMessage(1070849); // The drain on your life force is gone. - } + protected override void EffectTick(BaseCreature source, Mobile defender, ref TimeSpan nextDelay) + { + DrainLife(source, defender); } protected override void EndEffect(BaseCreature source, Mobile defender) diff --git a/Projects/UOContent/Mobiles/Abilities/FanningFire.cs b/Projects/UOContent/Mobiles/Abilities/FanningFire.cs index c9fdb71a50..a06bb561f2 100644 --- a/Projects/UOContent/Mobiles/Abilities/FanningFire.cs +++ b/Projects/UOContent/Mobiles/Abilities/FanningFire.cs @@ -1,4 +1,6 @@ -namespace Server.Mobiles; +using System; + +namespace Server.Mobiles; public class FanningFire : MonsterAbilitySingleTargetDoT { @@ -62,6 +64,10 @@ protected override void OnTarget(MonsterAbilityTrigger trigger, BaseCreature sou AOS.Damage(defender, source, Utility.RandomMinMax(35, 45), 0, 100, 0, 0, 0); } + protected override void EffectTick(BaseCreature source, Mobile defender, ref TimeSpan nextDelay) + { + } + protected override void EndEffect(BaseCreature source, Mobile defender) { defender.RemoveResistanceMod(Name); diff --git a/Projects/UOContent/Mobiles/Abilities/GraspingClaw.cs b/Projects/UOContent/Mobiles/Abilities/GraspingClaw.cs index 13aab5b2d9..547820b187 100644 --- a/Projects/UOContent/Mobiles/Abilities/GraspingClaw.cs +++ b/Projects/UOContent/Mobiles/Abilities/GraspingClaw.cs @@ -1,4 +1,6 @@ -namespace Server.Mobiles; +using System; + +namespace Server.Mobiles; public class GraspingClaw : MonsterAbilitySingleTargetDoT { @@ -51,6 +53,10 @@ protected override void OnTarget(MonsterAbilityTrigger trigger, BaseCreature sou defender.FixedEffect(0x37B9, 10, 5); } + protected override void EffectTick(BaseCreature source, Mobile defender, ref TimeSpan nextDelay) + { + } + protected override void EndEffect(BaseCreature source, Mobile defender) { defender.RemoveResistanceMod(Name); diff --git a/Projects/UOContent/Mobiles/Abilities/MonsterAbilities.cs b/Projects/UOContent/Mobiles/Abilities/MonsterAbilities.cs index 935241eea5..9df7ffd0a6 100644 --- a/Projects/UOContent/Mobiles/Abilities/MonsterAbilities.cs +++ b/Projects/UOContent/Mobiles/Abilities/MonsterAbilities.cs @@ -47,4 +47,6 @@ public static class MonsterAbilities public static MagicalBarrier MagicalBarrier => new(); public static ReflectPhysicalDamage ReflectPhysicalDamage => new(); + + public static BloodBathAttack BloodBathAttack => new(); } diff --git a/Projects/UOContent/Mobiles/Abilities/MonsterAbilitySingleTargetDoT.cs b/Projects/UOContent/Mobiles/Abilities/MonsterAbilitySingleTargetDoT.cs index f862f985c2..290ae42b06 100644 --- a/Projects/UOContent/Mobiles/Abilities/MonsterAbilitySingleTargetDoT.cs +++ b/Projects/UOContent/Mobiles/Abilities/MonsterAbilitySingleTargetDoT.cs @@ -22,10 +22,7 @@ protected override void OnTarget(MonsterAbilityTrigger trigger, BaseCreature sou protected virtual int GetCount(BaseCreature source, Mobile defender) => 1; - protected virtual void EffectTick(BaseCreature source, Mobile defender, out TimeSpan nextDelay) - { - nextDelay = Utility.RandomMinMax(MinDelay, MaxDelay); - } + protected abstract void EffectTick(BaseCreature source, Mobile defender, ref TimeSpan nextDelay); protected abstract void EndEffect(BaseCreature source, Mobile defender); protected abstract void OnEffectExpired(BaseCreature source, Mobile defender); @@ -65,8 +62,12 @@ int count protected override void OnTick() { - _ability.EffectTick(_source, _defender, out var delay); - Delay = delay; + var delay = RemainingCount == 0 + ? TimeSpan.MinValue + : Utility.RandomMinMax(_ability.MinDelay, _ability.MaxDelay); + + _ability.EffectTick(_source, _defender, ref delay); + Interval = delay; if (RemainingCount == 0) { diff --git a/Projects/UOContent/Mobiles/Abilities/MonsterAbilityType.cs b/Projects/UOContent/Mobiles/Abilities/MonsterAbilityType.cs index 73e26e9aa6..9f188243dd 100644 --- a/Projects/UOContent/Mobiles/Abilities/MonsterAbilityType.cs +++ b/Projects/UOContent/Mobiles/Abilities/MonsterAbilityType.cs @@ -19,5 +19,6 @@ public enum MonsterAbilityType ReflectPhysicalDamage, FanningFire, // Fire debuff RuneCorruption, - FanThrow + FanThrow, + BloodBath } diff --git a/Projects/UOContent/Mobiles/Abilities/RuneCorruption.cs b/Projects/UOContent/Mobiles/Abilities/RuneCorruption.cs index 2e68c61ced..2e24ae5420 100644 --- a/Projects/UOContent/Mobiles/Abilities/RuneCorruption.cs +++ b/Projects/UOContent/Mobiles/Abilities/RuneCorruption.cs @@ -1,4 +1,6 @@ -namespace Server.Mobiles; +using System; + +namespace Server.Mobiles; public class RuneCorruption : MonsterAbilitySingleTargetDoT { @@ -151,6 +153,10 @@ protected override void OnTarget(MonsterAbilityTrigger trigger, BaseCreature sou defender.FixedEffect(0x37B9, 10, 5); } + protected override void EffectTick(BaseCreature source, Mobile defender, ref TimeSpan nextDelay) + { + } + protected override void EndEffect(BaseCreature source, Mobile defender) { defender.RemoveResistanceMod(Name); diff --git a/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs b/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs index 4a1b5b94b4..af441766d5 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; @@ -7,8 +6,6 @@ namespace Server.Mobiles { public class BakeKitsune : BaseCreature { - private static readonly Dictionary m_Table = new(); - private TimerExecutionToken _disguiseTimerToken; [Constructible] @@ -67,6 +64,9 @@ public BakeKitsune(Serial serial) : base(serial) public override bool ClickTitle => false; public override bool PropertyTitle => false; + private static MonsterAbility[] _abilities = { MonsterAbilities.BloodBathAttack }; + public override MonsterAbility[] GetMonsterAbilities() => _abilities; + public override void GenerateLoot() { AddLoot(LootPack.FilthyRich); @@ -89,38 +89,6 @@ public override bool OnBeforeDeath() return base.OnBeforeDeath(); } - public override void OnGaveMeleeAttack(Mobile defender, int damage) - { - base.OnGaveMeleeAttack(defender, damage); - - if (Utility.RandomDouble() < 0.9) - { - return; - } - - /* Blood Bath - * Start cliloc 1070826 - * Sound: 0x52B - * 2-3 blood spots - * Damage: 2 hps per second for 5 seconds - * End cliloc: 1070824 - */ - - if (m_Table.TryGetValue(defender, out var timer)) - { - timer.DoExpire(); - defender.SendLocalizedMessage(1070825); // The creature continues to rage! - } - else - { - defender.SendLocalizedMessage(1070826); // The creature goes into a rage, inflicting heavy damage! - } - - timer = new ExpireTimer(defender, this); - timer.Start(); - m_Table[defender] = timer; - } - public override int GetAngerSound() => 0x4DE; public override int GetIdleSound() => 0x4DD; @@ -187,17 +155,25 @@ public void Disguise() switch (Utility.Random(4)) { case 0: - AddItem(new Shoes(Utility.RandomNeutralHue())); - break; + { + AddItem(new Shoes(Utility.RandomNeutralHue())); + break; + } case 1: - AddItem(new Boots(Utility.RandomNeutralHue())); - break; + { + AddItem(new Boots(Utility.RandomNeutralHue())); + break; + } case 2: - AddItem(new Sandals(Utility.RandomNeutralHue())); - break; + { + AddItem(new Sandals(Utility.RandomNeutralHue())); + break; + } case 3: - AddItem(new ThighBoots(Utility.RandomNeutralHue())); - break; + { + AddItem(new ThighBoots(Utility.RandomNeutralHue())); + break; + } } AddItem(new Robe(Utility.RandomNondyedHue())); @@ -232,47 +208,5 @@ public void DeleteItemOnLayer(Layer layer) { FindItemOnLayer(layer)?.Delete(); } - - private class ExpireTimer : Timer - { - private readonly Mobile m_From; - private readonly Mobile m_Mobile; - private int m_Count; - - public ExpireTimer(Mobile m, Mobile from) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) - { - m_Mobile = m; - m_From = from; - } - - public void DoExpire() - { - Stop(); - m_Table.Remove(m_Mobile); - } - - public void DrainLife() - { - if (m_Mobile.Alive) - { - m_Mobile.Damage(2, m_From); - } - else - { - DoExpire(); - } - } - - protected override void OnTick() - { - DrainLife(); - - if (++m_Count >= 5) - { - DoExpire(); - m_Mobile.SendLocalizedMessage(1070824); // The creature's rage subsides. - } - } - } } } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs b/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs index 5359763648..7e0675d198 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/TsukiWolf.cs @@ -1,180 +1,103 @@ -using System; -using System.Collections.Generic; using Server.Engines.Plants; using Server.Items; -namespace Server.Mobiles +namespace Server.Mobiles; + +public class TsukiWolf : BaseCreature { - public class TsukiWolf : BaseCreature + [Constructible] + public TsukiWolf() : base(AIType.AI_Melee) { - private static readonly Dictionary m_Table = new(); - - [Constructible] - public TsukiWolf() : base(AIType.AI_Melee) - { - Body = 250; - Hue = Utility.Random(3) == 0 ? Utility.RandomNeutralHue() : 0; - - SetStr(401, 450); - SetDex(151, 200); - SetInt(66, 76); - - SetHits(376, 450); - SetMana(40); - - SetDamage(14, 18); + Body = 250; + Hue = Utility.Random(3) == 0 ? Utility.RandomNeutralHue() : 0; - SetDamageType(ResistanceType.Physical, 90); - SetDamageType(ResistanceType.Cold, 5); - SetDamageType(ResistanceType.Energy, 5); + SetStr(401, 450); + SetDex(151, 200); + SetInt(66, 76); - SetResistance(ResistanceType.Physical, 40, 60); - SetResistance(ResistanceType.Fire, 50, 70); - SetResistance(ResistanceType.Cold, 50, 70); - SetResistance(ResistanceType.Poison, 50, 70); - SetResistance(ResistanceType.Energy, 50, 70); + SetHits(376, 450); + SetMana(40); - SetSkill(SkillName.Anatomy, 65.1, 72.0); - SetSkill(SkillName.MagicResist, 65.1, 70.0); - SetSkill(SkillName.Tactics, 95.1, 110.0); - SetSkill(SkillName.Wrestling, 97.6, 107.5); + SetDamage(14, 18); - Fame = 8500; - Karma = -8500; + SetDamageType(ResistanceType.Physical, 90); + SetDamageType(ResistanceType.Cold, 5); + SetDamageType(ResistanceType.Energy, 5); - if (Core.ML && Utility.RandomDouble() < .33) - { - PackItem(Seed.RandomPeculiarSeed(1)); - } - - PackItem( - Utility.Random(10) switch - { - 0 => new LeftArm(), - 1 => new RightArm(), - 2 => new Torso(), - 3 => new Bone(), - 4 => new RibCage(), - 5 => new RibCage(), - _ => new BonePile() // 6-9 - } - ); - } + SetResistance(ResistanceType.Physical, 40, 60); + SetResistance(ResistanceType.Fire, 50, 70); + SetResistance(ResistanceType.Cold, 50, 70); + SetResistance(ResistanceType.Poison, 50, 70); + SetResistance(ResistanceType.Energy, 50, 70); - public TsukiWolf(Serial serial) - : base(serial) - { - } + SetSkill(SkillName.Anatomy, 65.1, 72.0); + SetSkill(SkillName.MagicResist, 65.1, 70.0); + SetSkill(SkillName.Tactics, 95.1, 110.0); + SetSkill(SkillName.Wrestling, 97.6, 107.5); - public override string CorpseName => "a tsuki wolf corpse"; - public override string DefaultName => "a tsuki wolf"; - public override int Meat => 4; - public override int Hides => 25; - public override FoodType FavoriteFood => FoodType.Meat; + Fame = 8500; + Karma = -8500; - public override void GenerateLoot() + if (Core.ML && Utility.RandomDouble() < .33) { - AddLoot(LootPack.Average); - AddLoot(LootPack.Rich); + PackItem(Seed.RandomPeculiarSeed(1)); } - public override void OnGaveMeleeAttack(Mobile defender, int damage) - { - base.OnGaveMeleeAttack(defender, damage); - - if (Utility.RandomDouble() < 0.9) - { - return; - } - - /* Blood Bath - * Start cliloc 1070826 - * Sound: 0x52B - * 2-3 blood spots - * Damage: 2 hps per second for 5 seconds - * End cliloc: 1070824 - */ - - if (m_Table.TryGetValue(defender, out var timer)) + PackItem( + Utility.Random(10) switch { - timer.DoExpire(); - defender.SendLocalizedMessage(1070825); // The creature continues to rage! + 0 => new LeftArm(), + 1 => new RightArm(), + 2 => new Torso(), + 3 => new Bone(), + 4 => new RibCage(), + 5 => new RibCage(), + _ => new BonePile() // 6-9 } - else - { - defender.SendLocalizedMessage(1070826); // The creature goes into a rage, inflicting heavy damage! - } - - timer = new ExpireTimer(defender, this); - timer.Start(); - m_Table[defender] = timer; - } - - public override void Serialize(IGenericWriter writer) - { - base.Serialize(writer); - - writer.Write(0); - } + ); + } - public override void Deserialize(IGenericReader reader) - { - base.Deserialize(reader); + public TsukiWolf(Serial serial) + : base(serial) + { + } - var version = reader.ReadInt(); - } + public override string CorpseName => "a tsuki wolf corpse"; + public override string DefaultName => "a tsuki wolf"; + public override int Meat => 4; + public override int Hides => 25; + public override FoodType FavoriteFood => FoodType.Meat; - public override int GetAngerSound() => 0x52D; + private static MonsterAbility[] _abilities = { MonsterAbilities.BloodBathAttack }; + public override MonsterAbility[] GetMonsterAbilities() => _abilities; - public override int GetIdleSound() => 0x52C; + public override void GenerateLoot() + { + AddLoot(LootPack.Average); + AddLoot(LootPack.Rich); + } - public override int GetAttackSound() => 0x52B; + public override void Serialize(IGenericWriter writer) + { + base.Serialize(writer); - public override int GetHurtSound() => 0x52E; + writer.Write(0); + } - public override int GetDeathSound() => 0x52A; + public override void Deserialize(IGenericReader reader) + { + base.Deserialize(reader); - private class ExpireTimer : Timer - { - private readonly Mobile m_From; - private readonly Mobile m_Mobile; - private int m_Count; + var version = reader.ReadInt(); + } - public ExpireTimer(Mobile m, Mobile from) - : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) - { - m_Mobile = m; - m_From = from; - } + public override int GetAngerSound() => 0x52D; - public void DoExpire() - { - Stop(); - m_Table.Remove(m_Mobile); - } + public override int GetIdleSound() => 0x52C; - public void DrainLife() - { - if (m_Mobile.Alive) - { - m_Mobile.Damage(2, m_From); - } - else - { - DoExpire(); - } - } + public override int GetAttackSound() => 0x52B; - protected override void OnTick() - { - DrainLife(); + public override int GetHurtSound() => 0x52E; - if (++m_Count >= 5) - { - DoExpire(); - m_Mobile.SendLocalizedMessage(1070824); // The creature's rage subsides. - } - } - } - } + public override int GetDeathSound() => 0x52A; }