fix: Consolidates and fixes movement/direction checks (#1861)
This commit is contained in:
parent
06e05f2e52
commit
e6bfc45228
11 changed files with 146 additions and 320 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Runtime.CompilerServices;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Targeting;
|
||||
using CalcMoves = Server.Movement.Movement;
|
||||
|
||||
namespace Server.Items;
|
||||
|
||||
|
|
@ -233,53 +234,7 @@ public abstract partial class BaseDoor : Item, ILockable, ITelekinesisable
|
|||
int x = m.X;
|
||||
int y = m.Y;
|
||||
|
||||
switch (m.Direction & Direction.Mask)
|
||||
{
|
||||
case Direction.North:
|
||||
{
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
case Direction.Right:
|
||||
{
|
||||
++x;
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
case Direction.East:
|
||||
{
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
case Direction.Down:
|
||||
{
|
||||
++x;
|
||||
++y;
|
||||
break;
|
||||
}
|
||||
case Direction.South:
|
||||
{
|
||||
++y;
|
||||
break;
|
||||
}
|
||||
case Direction.Left:
|
||||
{
|
||||
--x;
|
||||
++y;
|
||||
break;
|
||||
}
|
||||
case Direction.West:
|
||||
{
|
||||
--x;
|
||||
break;
|
||||
}
|
||||
case Direction.Up:
|
||||
{
|
||||
--x;
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CalcMoves.Offset(m.Direction, ref x, ref y);
|
||||
|
||||
foreach (var item in m.Map.GetItemsAt(x, y))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,132 +1,82 @@
|
|||
using System;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Targeting;
|
||||
using CalcMoves = Server.Movement.Movement;
|
||||
|
||||
namespace Server.Items
|
||||
namespace Server.Items;
|
||||
|
||||
[Flippable(0xF52, 0xF51)]
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class ThrowingDagger : Item
|
||||
{
|
||||
[Flippable(0xF52, 0xF51)]
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class ThrowingDagger : Item
|
||||
[Constructible]
|
||||
public ThrowingDagger() : base(0xF52)
|
||||
{
|
||||
[Constructible]
|
||||
public ThrowingDagger() : base(0xF52)
|
||||
Weight = 1.0;
|
||||
Layer = Layer.OneHanded;
|
||||
}
|
||||
|
||||
public override string DefaultName => "a throwing dagger";
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.Items.Contains(this))
|
||||
{
|
||||
Weight = 1.0;
|
||||
Layer = Layer.OneHanded;
|
||||
var t = new InternalTarget(this);
|
||||
from.Target = t;
|
||||
}
|
||||
|
||||
public override string DefaultName => "a throwing dagger";
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
else
|
||||
{
|
||||
if (from.Items.Contains(this))
|
||||
from.SendMessage("You must be holding that weapon to use it.");
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly ThrowingDagger m_Dagger;
|
||||
|
||||
public InternalTarget(ThrowingDagger dagger) : base(10, false, TargetFlags.Harmful) => m_Dagger = dagger;
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (m_Dagger.Deleted)
|
||||
{
|
||||
var t = new InternalTarget(this);
|
||||
from.Target = t;
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
if (!from.Items.Contains(m_Dagger))
|
||||
{
|
||||
from.SendMessage("You must be holding that weapon to use it.");
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly ThrowingDagger m_Dagger;
|
||||
|
||||
public InternalTarget(ThrowingDagger dagger) : base(10, false, TargetFlags.Harmful) => m_Dagger = dagger;
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
else if (targeted is Mobile m && m != from && from.HarmfulCheck(m))
|
||||
{
|
||||
if (m_Dagger.Deleted)
|
||||
var to = from.GetDirectionTo(m);
|
||||
|
||||
from.Direction = to;
|
||||
|
||||
from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0);
|
||||
|
||||
if (Utility.RandomDouble() >= Math.Sqrt(m.Dex / 100.0) * 0.8)
|
||||
{
|
||||
return;
|
||||
from.MovingEffect(m, 0x1BFE, 7, 1, false, false, 0x481, 0);
|
||||
|
||||
AOS.Damage(m, from, Utility.Random(5, from.Str / 10), 100, 0, 0, 0, 0);
|
||||
|
||||
m_Dagger.MoveToWorld(m.Location, m.Map);
|
||||
}
|
||||
|
||||
if (!from.Items.Contains(m_Dagger))
|
||||
else
|
||||
{
|
||||
from.SendMessage("You must be holding that weapon to use it.");
|
||||
}
|
||||
else if (targeted is Mobile m && m != from && from.HarmfulCheck(m))
|
||||
{
|
||||
var to = from.GetDirectionTo(m);
|
||||
var p = m.Location;
|
||||
CalcMoves.Offset(to, ref p);
|
||||
|
||||
from.Direction = to;
|
||||
p.X += Utility.Random(-1, 3);
|
||||
p.Y += Utility.Random(-1, 3);
|
||||
|
||||
from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0);
|
||||
m_Dagger.MoveToWorld(p, m.Map);
|
||||
|
||||
if (Utility.RandomDouble() >= Math.Sqrt(m.Dex / 100.0) * 0.8)
|
||||
{
|
||||
from.MovingEffect(m, 0x1BFE, 7, 1, false, false, 0x481, 0);
|
||||
from.MovingEffect(m_Dagger, 0x1BFE, 7, 1, false, false, 0x481, 0);
|
||||
|
||||
AOS.Damage(m, from, Utility.Random(5, from.Str / 10), 100, 0, 0, 0, 0);
|
||||
|
||||
m_Dagger.MoveToWorld(m.Location, m.Map);
|
||||
}
|
||||
else
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
|
||||
switch (to & Direction.Mask)
|
||||
{
|
||||
case Direction.North:
|
||||
{
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
case Direction.South:
|
||||
{
|
||||
++y;
|
||||
break;
|
||||
}
|
||||
case Direction.West:
|
||||
{
|
||||
--x;
|
||||
break;
|
||||
}
|
||||
case Direction.East:
|
||||
{
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
case Direction.Up:
|
||||
{
|
||||
--x;
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
case Direction.Down:
|
||||
{
|
||||
++x;
|
||||
++y;
|
||||
break;
|
||||
}
|
||||
case Direction.Left:
|
||||
{
|
||||
--x;
|
||||
++y;
|
||||
break;
|
||||
}
|
||||
case Direction.Right:
|
||||
{
|
||||
++x;
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x += Utility.Random(-1, 3);
|
||||
y += Utility.Random(-1, 3);
|
||||
|
||||
x += m.X;
|
||||
y += m.Y;
|
||||
|
||||
m_Dagger.MoveToWorld(new Point3D(x, y, m.Z), m.Map);
|
||||
|
||||
from.MovingEffect(m_Dagger, 0x1BFE, 7, 1, false, false, 0x481, 0);
|
||||
|
||||
from.SendMessage("You miss.");
|
||||
}
|
||||
from.SendMessage("You miss.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue