Skip to content

Commit

Permalink
fix: Fixes Dot abilities. Adds blood bath attack (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Nov 24, 2022
1 parent f884193 commit 9c74276
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 257 deletions.
49 changes: 49 additions & 0 deletions Projects/UOContent/Mobiles/Abilities/BloodBathAttack.cs
Original file line number Diff line number Diff line change
@@ -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.
}
}
37 changes: 23 additions & 14 deletions Projects/UOContent/Mobiles/Abilities/DrainLifeAttack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion Projects/UOContent/Mobiles/Abilities/FanningFire.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Server.Mobiles;
using System;

namespace Server.Mobiles;

public class FanningFire : MonsterAbilitySingleTargetDoT
{
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion Projects/UOContent/Mobiles/Abilities/GraspingClaw.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Server.Mobiles;
using System;

namespace Server.Mobiles;

public class GraspingClaw : MonsterAbilitySingleTargetDoT
{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Projects/UOContent/Mobiles/Abilities/MonsterAbilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ public static class MonsterAbilities
public static MagicalBarrier MagicalBarrier => new();

public static ReflectPhysicalDamage ReflectPhysicalDamage => new();

public static BloodBathAttack BloodBathAttack => new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion Projects/UOContent/Mobiles/Abilities/MonsterAbilityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public enum MonsterAbilityType
ReflectPhysicalDamage,
FanningFire, // Fire debuff
RuneCorruption,
FanThrow
FanThrow,
BloodBath
}
8 changes: 7 additions & 1 deletion Projects/UOContent/Mobiles/Abilities/RuneCorruption.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Server.Mobiles;
using System;

namespace Server.Mobiles;

public class RuneCorruption : MonsterAbilitySingleTargetDoT
{
Expand Down Expand Up @@ -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);
Expand Down
104 changes: 19 additions & 85 deletions Projects/UOContent/Mobiles/Monsters/SE/BakeKitsune.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using Server.Engines.Plants;
using Server.Items;

namespace Server.Mobiles
{
public class BakeKitsune : BaseCreature
{
private static readonly Dictionary<Mobile, ExpireTimer> m_Table = new();

private TimerExecutionToken _disguiseTimerToken;

[Constructible]
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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.
}
}
}
}
}
Loading

0 comments on commit 9c74276

Please sign in to comment.