Skip to content

Commit

Permalink
feat: Adds Pre-Pub 81 (UOML) Force of Nature (#1842)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Jul 22, 2024
1 parent 4d03095 commit e41d35d
Showing 1 changed file with 101 additions and 59 deletions.
160 changes: 101 additions & 59 deletions Projects/UOContent/Items/Weapons/Abilities/ForceOfNature.cs
Original file line number Diff line number Diff line change
@@ -1,107 +1,149 @@
using System;
using System.Collections.Generic;

namespace Server.Items
namespace Server.Items;

Check notice on line 4 in Projects/UOContent/Items/Weapons/Abilities/ForceOfNature.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Namespace does not correspond to file location

Namespace does not correspond to file location, must be: 'Server.Items.Weapons.Abilities'

public class ForceOfNature : WeaponAbility
{
public class ForceOfNature : WeaponAbility
{
public override int BaseMana => 35;
public override int BaseMana => Core.SA ? 35 : 40;

public override void OnHit(Mobile attacker, Mobile defender, int damage, WorldLocation worldLocation)
public override void OnHit(Mobile attacker, Mobile defender, int damage, WorldLocation worldLocation)
{
if (!Validate(attacker) || !CheckMana(attacker, true))
{
if (!Validate(attacker) || !CheckMana(attacker, true))
{
return;
}
return;
}

ClearCurrentAbility(attacker);
ClearCurrentAbility(attacker);

attacker.SendLocalizedMessage(1074374); // You attack your enemy with the force of nature!
defender.SendLocalizedMessage(1074375); // You are assaulted with great force!
attacker.SendLocalizedMessage(1074374); // You attack your enemy with the force of nature!
defender.SendLocalizedMessage(1074375); // You are assaulted with great force!

defender.PlaySound(0x22F);
defender.FixedParticles(0x36CB, 1, 9, 9911, 67, 5, EffectLayer.Head);
defender.FixedParticles(0x374A, 1, 17, 9502, 1108, 4, (EffectLayer)255);
defender.PlaySound(0x22F);
defender.FixedParticles(0x36CB, 1, 9, 9911, 67, 5, EffectLayer.Head);
defender.FixedParticles(0x374A, 1, 17, 9502, 1108, 4, (EffectLayer)255);

Remove(attacker);
Remove(attacker);

ForceOfNatureTimer t = new ForceOfNatureTimer(attacker, defender);
t.Start();
ForceOfNatureTimer t = new ForceOfNatureTimer(attacker, defender);
t.Start();

_table[attacker] = t;
}
_table[attacker] = t;
}

private static readonly Dictionary<Mobile, ForceOfNatureTimer> _table = new Dictionary<Mobile, ForceOfNatureTimer>();
private static readonly Dictionary<Mobile, ForceOfNatureTimer> _table = new();

public static void Remove(Mobile m)
public static void Remove(Mobile m)
{
if (_table.Remove(m, out var timer))
{
if (_table.Remove(m, out var timer))
{
timer.Stop();
}
timer.Stop();
}
}

public static void OnHit(Mobile from, Mobile target)
public static void OnHit(Mobile from, Mobile target)
{
if (!_table.TryGetValue(from, out var t) || t.Target != target)
{
if (_table.TryGetValue(from, out var t))
{
t.Hits++;
t.LastHit = Core.Now;
return;
}

if (t.Hits % 12 == 0)
{
int duration = target.Skills[SkillName.MagicResist].Value >= 90.0 ? 1 : 2;
target.Paralyze(TimeSpan.FromSeconds(duration));
if (Core.SA)
{
OnHitSA(t);
}
else
{
OnHitML(t);
}
}

target.FixedEffect(0x376A, 9, 32);
target.PlaySound(0x204);
private static void OnHitSA(ForceOfNatureTimer t)
{
var from = t.From;
var target = t.Target;

t.Hits = 0;
t.Hits++;
t.LastHit = Core.Now;

from.SendLocalizedMessage(1004013); // You successfully stun your opponent!
target.SendLocalizedMessage(1004014); // You have been stunned!
}
}
if (t.Hits % 12 == 0)
{
int duration = target.Skills[SkillName.MagicResist].Value >= 90.0 ? 1 : 2;
target.Paralyze(TimeSpan.FromSeconds(duration));

target.FixedEffect(0x376A, 9, 32);
target.PlaySound(0x204);

t.Hits = 0;

from.SendLocalizedMessage(1004013); // You successfully stun your opponent!
target.SendLocalizedMessage(1004014); // You have been stunned!
}
}

private static void OnHitML(ForceOfNatureTimer t)
{
var from = t.From;

// TODO: What is the effect?
AOS.Damage(from, from, Utility.Random(25, 10), false, 0, 0, 0, 100, 0);
}

public static double GetDamageScalar(Mobile from, Mobile target)
public static double GetDamageScalar(Mobile from, Mobile target)
{
if (_table.TryGetValue(from, out var t) && t.Target == target)
{
if (_table.TryGetValue(from, out var t) && t.Target == target)
if (Core.SA)
{
var bonus = Math.Min(100, Math.Max(50, from.Str - 50));
return (100.0 + bonus) / 100.0;
}

return 1.0;
return 1.65;
}

private class ForceOfNatureTimer : Timer
return 1.0;
}

private class ForceOfNatureTimer : Timer
{
public Mobile Target { get; }
public Mobile From { get; }
public int Hits { get; set; }
public DateTime LastHit { get; set; }

public ForceOfNatureTimer(Mobile from, Mobile target)
: base(
Core.SA ? TimeSpan.FromSeconds(1) : TimeSpan.FromSeconds(10),
Core.SA ? TimeSpan.FromSeconds(1) : TimeSpan.Zero,
Core.SA ? 36 : 1
)
{
public Mobile Target { get; }
public Mobile From { get; }
public int Hits { get; set; }
public DateTime LastHit { get; set; }
Target = target;
From = from;
Hits = 1;
LastHit = Core.Now;
}

public ForceOfNatureTimer(Mobile from, Mobile target)
: base(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))
protected override void OnTick()
{
if (!From.Alive || !Target.Alive || Target.Map != From.Map || Target.GetDistanceToSqrt(From.Location) > 10)
{
Target = target;
From = from;
Hits = 1;
LastHit = Core.Now;
Remove(From);
return;
}

protected override void OnTick()
if (Core.SA)
{
if (!From.Alive || !Target.Alive || Target.Map != From.Map || Target.GetDistanceToSqrt(From.Location) > 10 || LastHit + TimeSpan.FromSeconds(20) < Core.Now || Index > 36)
if (LastHit + TimeSpan.FromSeconds(20) < Core.Now)
{
Remove(From);
return;
}

if (Index == 1)
{
int damage = Utility.RandomMinMax(15, 35);
int damage = Utility.Random(15, 20);

AOS.Damage(Target, From, damage, false, 0, 0, 0, 0, 0, 0, 100);
}
Expand Down

0 comments on commit e41d35d

Please sign in to comment.