Splits up mobile (#296)
This commit is contained in:
parent
1ca8655fc1
commit
daf48ebdf2
7 changed files with 407 additions and 616 deletions
56
Projects/Server/Comparers/LocationComparer.cs
Normal file
56
Projects/Server/Comparers/LocationComparer.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: LocationComparer.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public class LocationComparer : IComparer<IPoint3D>
|
||||
{
|
||||
private static LocationComparer m_Instance;
|
||||
|
||||
public LocationComparer(IPoint3D relativeTo) => RelativeTo = relativeTo;
|
||||
|
||||
public IPoint3D RelativeTo { get; set; }
|
||||
|
||||
public int Compare(IPoint3D x, IPoint3D y) => GetDistance(x) - GetDistance(y);
|
||||
|
||||
public static LocationComparer GetInstance(IPoint3D relativeTo)
|
||||
{
|
||||
if (m_Instance == null)
|
||||
{
|
||||
m_Instance = new LocationComparer(relativeTo);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Instance.RelativeTo = relativeTo;
|
||||
}
|
||||
|
||||
return m_Instance;
|
||||
}
|
||||
|
||||
private int GetDistance(IPoint3D p)
|
||||
{
|
||||
var x = RelativeTo.X - p.X;
|
||||
var y = RelativeTo.Y - p.Y;
|
||||
var z = RelativeTo.Z - p.Z;
|
||||
|
||||
x *= 11;
|
||||
y *= 11;
|
||||
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
57
Projects/Server/Mobiles/MovementRecord.cs
Normal file
57
Projects/Server/Mobiles/MovementRecord.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: MovementRecord.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class MovementRecord
|
||||
{
|
||||
private static readonly Queue<MovementRecord> m_InstancePool = new Queue<MovementRecord>();
|
||||
public long m_End;
|
||||
|
||||
private MovementRecord(long end) => m_End = end;
|
||||
|
||||
public static MovementRecord NewInstance(long end)
|
||||
{
|
||||
MovementRecord r;
|
||||
|
||||
if (m_InstancePool.Count > 0)
|
||||
{
|
||||
r = m_InstancePool.Dequeue();
|
||||
|
||||
r.m_End = end;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = new MovementRecord(end);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public bool Expired()
|
||||
{
|
||||
var v = Core.TickCount - m_End >= 0;
|
||||
|
||||
if (v)
|
||||
{
|
||||
m_InstancePool.Enqueue(this);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
91
Projects/Server/Mobiles/SimplePrompt.cs
Normal file
91
Projects/Server/Mobiles/SimplePrompt.cs
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: SimplePrompt.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using Server.Prompts;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class SimplePrompt : Prompt
|
||||
{
|
||||
private readonly PromptCallback m_Callback;
|
||||
private readonly bool m_CallbackHandlesCancel;
|
||||
private readonly PromptCallback m_CancelCallback;
|
||||
|
||||
public SimplePrompt(PromptCallback callback, PromptCallback cancelCallback)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_CancelCallback = cancelCallback;
|
||||
}
|
||||
|
||||
public SimplePrompt(PromptCallback callback, bool callbackHandlesCancel = false)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_CallbackHandlesCancel = callbackHandlesCancel;
|
||||
}
|
||||
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
m_Callback?.Invoke(from, text);
|
||||
}
|
||||
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
if (m_CallbackHandlesCancel && m_Callback != null)
|
||||
{
|
||||
m_Callback(from, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CancelCallback?.Invoke(from, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleStatePrompt<T> : Prompt
|
||||
{
|
||||
private readonly PromptStateCallback<T> m_Callback;
|
||||
private readonly PromptStateCallback<T> m_CancelCallback;
|
||||
|
||||
private readonly T m_State;
|
||||
|
||||
public SimpleStatePrompt(PromptStateCallback<T> callback, PromptStateCallback<T> cancelCallback, T state)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_CancelCallback = cancelCallback;
|
||||
m_State = state;
|
||||
}
|
||||
|
||||
public SimpleStatePrompt(PromptStateCallback<T> callback, bool callbackHandlesCancel, T state)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_State = state;
|
||||
m_CancelCallback = callbackHandlesCancel ? callback : null;
|
||||
}
|
||||
|
||||
public SimpleStatePrompt(PromptStateCallback<T> callback, T state) : this(callback, false, state)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
m_Callback?.Invoke(from, text, m_State);
|
||||
}
|
||||
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
m_CancelCallback?.Invoke(from, "", m_State);
|
||||
}
|
||||
}
|
||||
}
|
||||
54
Projects/Server/Mobiles/SimpleTarget.cs
Normal file
54
Projects/Server/Mobiles/SimpleTarget.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: SimpleTarget.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public class SimpleTarget : Target
|
||||
{
|
||||
private readonly TargetCallback m_Callback;
|
||||
|
||||
public SimpleTarget(int range, TargetFlags flags, bool allowGround, TargetCallback callback)
|
||||
: base(range, allowGround, flags) =>
|
||||
m_Callback = callback;
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
m_Callback?.Invoke(from, targeted);
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleStateTarget<T> : Target
|
||||
{
|
||||
private readonly TargetStateCallback<T> m_Callback;
|
||||
private readonly T m_State;
|
||||
|
||||
public SimpleStateTarget(
|
||||
int range, TargetFlags flags, bool allowGround, TargetStateCallback<T> callback,
|
||||
T state
|
||||
)
|
||||
: base(range, allowGround, flags)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_State = state;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
m_Callback?.Invoke(from, targeted, m_State);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1342,7 +1342,7 @@ namespace Server.Mobiles
|
|||
return (double)chance / 1000;
|
||||
}
|
||||
|
||||
public override void Damage(int amount, Mobile from)
|
||||
public override void Damage(int amount, Mobile from = null, bool informMount = true)
|
||||
{
|
||||
var oldHits = Hits;
|
||||
|
||||
|
|
@ -1356,9 +1356,7 @@ namespace Server.Mobiles
|
|||
amount = (int)(amount * 1.25);
|
||||
}
|
||||
|
||||
var oath = BloodOathSpell.GetBloodOath(from);
|
||||
|
||||
if (oath == this)
|
||||
if (from != null && BloodOathSpell.GetBloodOath(from) == this)
|
||||
{
|
||||
amount = (int)(amount * 1.1);
|
||||
from.Damage(amount, from);
|
||||
|
|
|
|||
|
|
@ -2874,20 +2874,18 @@ namespace Server.Mobiles
|
|||
SendToStaffMessage(from, string.Format(format, args));
|
||||
}
|
||||
|
||||
public override void Damage(int amount, Mobile from)
|
||||
public override void Damage(int amount, Mobile from = null, bool informMount = true)
|
||||
{
|
||||
if (EvilOmenSpell.TryEndEffect(this))
|
||||
{
|
||||
amount = (int)(amount * 1.25);
|
||||
}
|
||||
|
||||
var oath = BloodOathSpell.GetBloodOath(from);
|
||||
|
||||
/* Per EA's UO Herald Pub48 (ML):
|
||||
* ((resist spellsx10)/20 + 10=percentage of damage resisted)
|
||||
*/
|
||||
|
||||
if (oath == this)
|
||||
if (from != null && BloodOathSpell.GetBloodOath(from) == this)
|
||||
{
|
||||
amount = (int)(amount * 1.1);
|
||||
|
||||
|
|
@ -2919,7 +2917,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
base.Damage(amount, from);
|
||||
base.Damage(amount, from, informMount);
|
||||
}
|
||||
|
||||
public override bool IsHarmfulCriminal(Mobile target)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue