Code cleanup (#188)
This commit is contained in:
parent
df53c16620
commit
010fd9402a
185 changed files with 1052 additions and 1271 deletions
|
|
@ -40,7 +40,7 @@ namespace Server.Diagnostics
|
||||||
|
|
||||||
public long Count { get; private set; }
|
public long Count { get; private set; }
|
||||||
|
|
||||||
public TimeSpan AverageTime => TimeSpan.FromTicks(TotalTime.Ticks / Math.Max(1, Count));
|
public TimeSpan AverageTime => TimeSpan.FromTicks(TotalTime.Ticks / Math.Max(Count, 1));
|
||||||
|
|
||||||
public TimeSpan PeakTime { get; private set; }
|
public TimeSpan PeakTime { get; private set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Server.Diagnostics
|
||||||
|
|
||||||
public long TotalLength { get; private set; }
|
public long TotalLength { get; private set; }
|
||||||
|
|
||||||
public double AverageLength => (double)TotalLength / Math.Max(1, Count);
|
public double AverageLength => (double)TotalLength / Math.Max(Count, 1);
|
||||||
|
|
||||||
public void Finish(long length)
|
public void Finish(long length)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@ namespace Server.Guilds
|
||||||
|
|
||||||
protected BaseGuild(uint id) // serialization ctor
|
protected BaseGuild(uint id) // serialization ctor
|
||||||
{
|
{
|
||||||
this.Serial = id;
|
Serial = id;
|
||||||
List.Add(this.Serial, this);
|
List.Add(Serial, this);
|
||||||
if (this.Serial + 1 > m_NextID)
|
if (Serial + 1 > m_NextID)
|
||||||
m_NextID = this.Serial + 1;
|
m_NextID = Serial + 1;
|
||||||
m_SaveBuffer = new BufferWriter(true);
|
m_SaveBuffer = new BufferWriter(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ namespace Server
|
||||||
int MaxRange { get; }
|
int MaxRange { get; }
|
||||||
void OnBeforeSwing(Mobile attacker, Mobile defender);
|
void OnBeforeSwing(Mobile attacker, Mobile defender);
|
||||||
TimeSpan OnSwing(Mobile attacker, Mobile defender);
|
TimeSpan OnSwing(Mobile attacker, Mobile defender);
|
||||||
|
TimeSpan OnSwing(Mobile attacker, Mobile defender, double damageBonus);
|
||||||
void GetStatusDamage(Mobile from, out int min, out int max);
|
void GetStatusDamage(Mobile from, out int min, out int max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2550,7 +2550,7 @@ namespace Server
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HeldBy != null)
|
if (HeldBy != null)
|
||||||
Timer.DelayCall(TimeSpan.Zero, FixHolding_Sandbox);
|
Timer.DelayCall(FixHolding_Sandbox);
|
||||||
|
|
||||||
// if (version < 9)
|
// if (version < 9)
|
||||||
VerifyCompactInfo();
|
VerifyCompactInfo();
|
||||||
|
|
@ -3070,18 +3070,12 @@ namespace Server
|
||||||
if (checkTop == checkZ && !id.Surface)
|
if (checkTop == checkZ && !id.Surface)
|
||||||
++checkTop;
|
++checkTop;
|
||||||
|
|
||||||
var zStart = checkZ - z;
|
var zStart = Math.Max(checkZ - z, 0);
|
||||||
var zEnd = checkTop - z;
|
var zEnd = Math.Min(checkTop - z, 19);
|
||||||
|
|
||||||
if (zStart >= 20 || zEnd < 0)
|
if (zStart >= 20 || zEnd < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (zStart < 0)
|
|
||||||
zStart = 0;
|
|
||||||
|
|
||||||
if (zEnd > 19)
|
|
||||||
zEnd = 19;
|
|
||||||
|
|
||||||
var bitCount = zEnd - zStart;
|
var bitCount = zEnd - zStart;
|
||||||
|
|
||||||
m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart);
|
m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart);
|
||||||
|
|
@ -3098,18 +3092,12 @@ namespace Server
|
||||||
if (checkTop == checkZ && !id.Surface)
|
if (checkTop == checkZ && !id.Surface)
|
||||||
++checkTop;
|
++checkTop;
|
||||||
|
|
||||||
var zStart = checkZ - z;
|
var zStart = Math.Max(checkZ - z, 0);
|
||||||
var zEnd = checkTop - z;
|
var zEnd = Math.Min(checkTop - z, 19);
|
||||||
|
|
||||||
if (zStart >= 20 || zEnd < 0)
|
if (zStart >= 20 || zEnd < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (zStart < 0)
|
|
||||||
zStart = 0;
|
|
||||||
|
|
||||||
if (zEnd > 19)
|
|
||||||
zEnd = 19;
|
|
||||||
|
|
||||||
var bitCount = zEnd - zStart;
|
var bitCount = zEnd - zStart;
|
||||||
|
|
||||||
m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart);
|
m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
|
||||||
|
|
@ -655,34 +655,14 @@ namespace Server
|
||||||
|
|
||||||
public void Bound(int x, int y, out int newX, out int newY)
|
public void Bound(int x, int y, out int newX, out int newY)
|
||||||
{
|
{
|
||||||
if (x < 0)
|
newX = Math.Clamp(x, 0, Width - 1);
|
||||||
newX = 0;
|
newY = Math.Clamp(y, 0, Height - 1);
|
||||||
else if (x >= Width)
|
|
||||||
newX = Width - 1;
|
|
||||||
else
|
|
||||||
newX = x;
|
|
||||||
|
|
||||||
if (y < 0)
|
|
||||||
newY = 0;
|
|
||||||
else if (y >= Height)
|
|
||||||
newY = Height - 1;
|
|
||||||
else
|
|
||||||
newY = y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point2D Bound(Point2D p)
|
public Point2D Bound(Point2D p)
|
||||||
{
|
{
|
||||||
int x = p.m_X, y = p.m_Y;
|
int x = Math.Clamp(p.m_X, 0, Width - 1);
|
||||||
|
int y = Math.Clamp(p.m_Y, 0, Height - 1);
|
||||||
if (x < 0)
|
|
||||||
x = 0;
|
|
||||||
else if (x >= Width)
|
|
||||||
x = Width - 1;
|
|
||||||
|
|
||||||
if (y < 0)
|
|
||||||
y = 0;
|
|
||||||
else if (y >= Height)
|
|
||||||
y = Height - 1;
|
|
||||||
|
|
||||||
return new Point2D(x, y);
|
return new Point2D(x, y);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1486,7 +1486,7 @@ namespace Server
|
||||||
AddToBackpack(item.Items[j]);
|
AddToBackpack(item.Items[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, item.Delete);
|
Timer.DelayCall(item.Delete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1811,10 +1811,7 @@ namespace Server
|
||||||
|
|
||||||
if (m_Kills != value)
|
if (m_Kills != value)
|
||||||
{
|
{
|
||||||
m_Kills = value;
|
m_Kills = Math.Max(value, 0);
|
||||||
|
|
||||||
if (m_Kills < 0)
|
|
||||||
m_Kills = 0;
|
|
||||||
|
|
||||||
if (oldValue >= 5 != m_Kills >= 5)
|
if (oldValue >= 5 != m_Kills >= 5)
|
||||||
{
|
{
|
||||||
|
|
@ -1834,12 +1831,7 @@ namespace Server
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (m_ShortTermMurders != value)
|
if (m_ShortTermMurders != value)
|
||||||
{
|
m_ShortTermMurders = Math.Max(value, 0);
|
||||||
m_ShortTermMurders = value;
|
|
||||||
|
|
||||||
if (m_ShortTermMurders < 0)
|
|
||||||
m_ShortTermMurders = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5250,9 +5242,8 @@ namespace Server
|
||||||
|
|
||||||
OnDamage(amount, from, newHits < 0);
|
OnDamage(amount, from, newHits < 0);
|
||||||
|
|
||||||
var m = Mount;
|
if (informMount)
|
||||||
if (m != null && informMount)
|
Mount?.OnRiderDamaged(amount, from, newHits < 0);
|
||||||
m.OnRiderDamaged(amount, from, newHits < 0);
|
|
||||||
|
|
||||||
if (newHits < 0)
|
if (newHits < 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -501,8 +501,7 @@ namespace Server.Network
|
||||||
var vendor = World.FindMobile(pvSrc.ReadUInt32());
|
var vendor = World.FindMobile(pvSrc.ReadUInt32());
|
||||||
var flag = pvSrc.ReadByte();
|
var flag = pvSrc.ReadByte();
|
||||||
|
|
||||||
if (vendor == null)
|
if (vendor == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (vendor.Deleted || !Utility.RangeCheck(vendor.Location, state.Mobile.Location, 10))
|
if (vendor.Deleted || !Utility.RangeCheck(vendor.Location, state.Mobile.Location, 10))
|
||||||
{
|
{
|
||||||
|
|
@ -840,8 +839,7 @@ namespace Server.Network
|
||||||
var beholder = state.Mobile;
|
var beholder = state.Mobile;
|
||||||
var beheld = World.FindMobile(serial);
|
var beheld = World.FindMobile(serial);
|
||||||
|
|
||||||
if (beheld == null)
|
if (beheld == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
|
@ -1014,8 +1012,7 @@ namespace Server.Network
|
||||||
|
|
||||||
var t = from.Target;
|
var t = from.Target;
|
||||||
|
|
||||||
if (t == null)
|
if (t == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
var prof = TargetProfile.Acquire(t.GetType());
|
var prof = TargetProfile.Acquire(t.GetType());
|
||||||
prof?.Start();
|
prof?.Start();
|
||||||
|
|
@ -1640,45 +1637,41 @@ namespace Server.Network
|
||||||
|
|
||||||
public static void PartyMessage_AddMember(NetState state, PacketReader pvSrc)
|
public static void PartyMessage_AddMember(NetState state, PacketReader pvSrc)
|
||||||
{
|
{
|
||||||
if (PartyCommands.Handler != null)
|
PartyCommands.Handler?.OnAdd(state.Mobile);
|
||||||
PartyCommands.Handler.OnAdd(state.Mobile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PartyMessage_RemoveMember(NetState state, PacketReader pvSrc)
|
public static void PartyMessage_RemoveMember(NetState state, PacketReader pvSrc)
|
||||||
{
|
{
|
||||||
if (PartyCommands.Handler != null)
|
PartyCommands.Handler?.OnRemove(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()));
|
||||||
PartyCommands.Handler.OnRemove(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PartyMessage_PrivateMessage(NetState state, PacketReader pvSrc)
|
public static void PartyMessage_PrivateMessage(NetState state, PacketReader pvSrc)
|
||||||
{
|
{
|
||||||
if (PartyCommands.Handler != null)
|
PartyCommands.Handler?.OnPrivateMessage(
|
||||||
PartyCommands.Handler.OnPrivateMessage(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()),
|
state.Mobile,
|
||||||
pvSrc.ReadUnicodeStringSafe());
|
World.FindMobile(pvSrc.ReadUInt32()),
|
||||||
|
pvSrc.ReadUnicodeStringSafe()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PartyMessage_PublicMessage(NetState state, PacketReader pvSrc)
|
public static void PartyMessage_PublicMessage(NetState state, PacketReader pvSrc)
|
||||||
{
|
{
|
||||||
if (PartyCommands.Handler != null)
|
PartyCommands.Handler?.OnPublicMessage(state.Mobile, pvSrc.ReadUnicodeStringSafe());
|
||||||
PartyCommands.Handler.OnPublicMessage(state.Mobile, pvSrc.ReadUnicodeStringSafe());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PartyMessage_SetCanLoot(NetState state, PacketReader pvSrc)
|
public static void PartyMessage_SetCanLoot(NetState state, PacketReader pvSrc)
|
||||||
{
|
{
|
||||||
if (PartyCommands.Handler != null)
|
PartyCommands.Handler?.OnSetCanLoot(state.Mobile, pvSrc.ReadBoolean());
|
||||||
PartyCommands.Handler.OnSetCanLoot(state.Mobile, pvSrc.ReadBoolean());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PartyMessage_Accept(NetState state, PacketReader pvSrc)
|
public static void PartyMessage_Accept(NetState state, PacketReader pvSrc)
|
||||||
{
|
{
|
||||||
if (PartyCommands.Handler != null)
|
PartyCommands.Handler?.OnAccept(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()));
|
||||||
PartyCommands.Handler.OnAccept(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PartyMessage_Decline(NetState state, PacketReader pvSrc)
|
public static void PartyMessage_Decline(NetState state, PacketReader pvSrc)
|
||||||
{
|
{
|
||||||
if (PartyCommands.Handler != null)
|
PartyCommands.Handler?.OnDecline(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()));
|
||||||
PartyCommands.Handler.OnDecline(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StunRequest(NetState state, PacketReader pvSrc)
|
public static void StunRequest(NetState state, PacketReader pvSrc)
|
||||||
|
|
@ -1725,41 +1718,40 @@ namespace Server.Network
|
||||||
{
|
{
|
||||||
var from = state.Mobile;
|
var from = state.Mobile;
|
||||||
|
|
||||||
if (from != null)
|
if (from == null) return;
|
||||||
|
|
||||||
|
var menu = from.ContextMenu;
|
||||||
|
|
||||||
|
from.ContextMenu = null;
|
||||||
|
|
||||||
|
if (menu != null && from == menu.From)
|
||||||
{
|
{
|
||||||
var menu = from.ContextMenu;
|
var entity = World.FindEntity(pvSrc.ReadUInt32());
|
||||||
|
|
||||||
from.ContextMenu = null;
|
if (entity != null && entity == menu.Target && from.CanSee(entity))
|
||||||
|
|
||||||
if (menu != null && from == menu.From)
|
|
||||||
{
|
{
|
||||||
var entity = World.FindEntity(pvSrc.ReadUInt32());
|
Point3D p;
|
||||||
|
|
||||||
if (entity != null && entity == menu.Target && from.CanSee(entity))
|
if (entity is Mobile)
|
||||||
|
p = entity.Location;
|
||||||
|
else if (entity is Item item)
|
||||||
|
p = item.GetWorldLocation();
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
int index = pvSrc.ReadUInt16();
|
||||||
|
|
||||||
|
if (index >= 0 && index < menu.Entries.Length)
|
||||||
{
|
{
|
||||||
Point3D p;
|
var e = menu.Entries[index];
|
||||||
|
|
||||||
if (entity is Mobile)
|
var range = e.Range;
|
||||||
p = entity.Location;
|
|
||||||
else if (entity is Item item)
|
|
||||||
p = item.GetWorldLocation();
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
int index = pvSrc.ReadUInt16();
|
if (range == -1)
|
||||||
|
range = 18;
|
||||||
|
|
||||||
if (index >= 0 && index < menu.Entries.Length)
|
if (e.Enabled && from.InRange(p, range))
|
||||||
{
|
e.OnClick();
|
||||||
var e = menu.Entries[index];
|
|
||||||
|
|
||||||
var range = e.Range;
|
|
||||||
|
|
||||||
if (range == -1)
|
|
||||||
range = 18;
|
|
||||||
|
|
||||||
if (e.Enabled && from.InRange(p, range))
|
|
||||||
e.OnClick();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Server.Network
|
namespace Server.Network
|
||||||
{
|
{
|
||||||
public sealed class DamagePacketOld : Packet
|
public sealed class DamagePacketOld : Packet
|
||||||
|
|
@ -30,12 +32,7 @@ namespace Server.Network
|
||||||
Stream.Write((byte)1);
|
Stream.Write((byte)1);
|
||||||
Stream.Write(mobile);
|
Stream.Write(mobile);
|
||||||
|
|
||||||
if (amount > 255)
|
Stream.Write((byte)Math.Clamp(amount, 0, 255));
|
||||||
amount = 255;
|
|
||||||
else if (amount < 0)
|
|
||||||
amount = 0;
|
|
||||||
|
|
||||||
Stream.Write((byte)amount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,12 +42,7 @@ namespace Server.Network
|
||||||
{
|
{
|
||||||
Stream.Write(mobile);
|
Stream.Write(mobile);
|
||||||
|
|
||||||
if (amount > 0xFFFF)
|
Stream.Write((ushort)Math.Clamp(amount, 0, 0xFFFF));
|
||||||
amount = 0xFFFF;
|
|
||||||
else if (amount < 0)
|
|
||||||
amount = 0;
|
|
||||||
|
|
||||||
Stream.Write((ushort)amount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace Server
|
||||||
fileStream = FileOperations.OpenSequentialStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
|
fileStream = FileOperations.OpenSequentialStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||||
|
|
||||||
fileQueue = new FileQueue(
|
fileQueue = new FileQueue(
|
||||||
Math.Max(1, FileOperations.Concurrency),
|
Math.Max(FileOperations.Concurrency, 1),
|
||||||
FileCallback);
|
FileCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.Json;
|
|
||||||
using Server.Json;
|
using Server.Json;
|
||||||
using Server.Utilities;
|
using Server.Utilities;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,12 +183,7 @@ namespace Server
|
||||||
get => m_Base;
|
get => m_Base;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value < 0)
|
var sv = (ushort)Math.Clamp(value, 0, 0xFFFF);
|
||||||
value = 0;
|
|
||||||
else if (value >= 0x10000)
|
|
||||||
value = 0xFFFF;
|
|
||||||
|
|
||||||
var sv = (ushort)value;
|
|
||||||
|
|
||||||
int oldBase = m_Base;
|
int oldBase = m_Base;
|
||||||
|
|
||||||
|
|
@ -219,12 +214,7 @@ namespace Server
|
||||||
get => m_Cap;
|
get => m_Cap;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value < 0)
|
var sv = (ushort)Math.Clamp(value, 0, 0xFFFF);
|
||||||
value = 0;
|
|
||||||
else if (value >= 0x10000)
|
|
||||||
value = 0xFFFF;
|
|
||||||
|
|
||||||
var sv = (ushort)value;
|
|
||||||
|
|
||||||
if (m_Cap != sv)
|
if (m_Cap != sv)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Server
|
namespace Server
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,7 @@ namespace Server
|
||||||
OneMinute
|
OneMinute
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate void TimerCallback();
|
public partial class Timer
|
||||||
|
|
||||||
public delegate void TimerStateCallback<in T>(T state);
|
|
||||||
|
|
||||||
public class Timer
|
|
||||||
{
|
{
|
||||||
private static readonly Queue<Timer> m_Queue = new Queue<Timer>();
|
private static readonly Queue<Timer> m_Queue = new Queue<Timer>();
|
||||||
|
|
||||||
|
|
@ -464,90 +460,6 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Timer DelayCall(TimerCallback callback) => DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback);
|
|
||||||
|
|
||||||
public static Timer DelayCall(TimeSpan delay, TimerCallback callback) => DelayCall(delay, TimeSpan.Zero, 1, callback);
|
|
||||||
|
|
||||||
public static Timer DelayCall(TimeSpan delay, TimeSpan interval, TimerCallback callback) =>
|
|
||||||
DelayCall(delay, interval, 0, callback);
|
|
||||||
|
|
||||||
public static Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, TimerCallback callback)
|
|
||||||
{
|
|
||||||
Timer t = new DelayCallTimer(delay, interval, count, callback);
|
|
||||||
|
|
||||||
t.Priority = ComputePriority(count == 1 ? delay : interval);
|
|
||||||
t.Start();
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Timer DelayCall<T>(TimerStateCallback<T> callback, T state) =>
|
|
||||||
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, state);
|
|
||||||
|
|
||||||
public static Timer DelayCall<T>(TimeSpan delay, TimerStateCallback<T> callback, T state) =>
|
|
||||||
DelayCall(delay, TimeSpan.Zero, 1, callback, state);
|
|
||||||
|
|
||||||
public static Timer DelayCall<T>(TimeSpan delay, TimeSpan interval, TimerStateCallback<T> callback, T state) =>
|
|
||||||
DelayCall(delay, interval, 0, callback, state);
|
|
||||||
|
|
||||||
public static Timer DelayCall<T>(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T> callback,
|
|
||||||
T state)
|
|
||||||
{
|
|
||||||
Timer t = new DelayStateCallTimer<T>(delay, interval, count, callback, state);
|
|
||||||
|
|
||||||
t.Priority = ComputePriority(count == 1 ? delay : interval);
|
|
||||||
|
|
||||||
t.Start();
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DelayCallTimer : Timer
|
|
||||||
{
|
|
||||||
public DelayCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerCallback callback) : base(delay,
|
|
||||||
interval, count)
|
|
||||||
{
|
|
||||||
Callback = callback;
|
|
||||||
RegCreation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimerCallback Callback { get; }
|
|
||||||
|
|
||||||
public override bool DefRegCreation => false;
|
|
||||||
|
|
||||||
protected override void OnTick()
|
|
||||||
{
|
|
||||||
Callback?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString() => $"DelayCallTimer[{FormatDelegate(Callback)}]";
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DelayStateCallTimer<T> : Timer
|
|
||||||
{
|
|
||||||
private readonly T m_State;
|
|
||||||
|
|
||||||
public DelayStateCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T> callback, T state)
|
|
||||||
: base(delay, interval, count)
|
|
||||||
{
|
|
||||||
Callback = callback;
|
|
||||||
m_State = state;
|
|
||||||
|
|
||||||
RegCreation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimerStateCallback<T> Callback { get; }
|
|
||||||
|
|
||||||
public override bool DefRegCreation => false;
|
|
||||||
|
|
||||||
protected override void OnTick()
|
|
||||||
{
|
|
||||||
Callback?.Invoke(m_State);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DelayTaskTimer : Timer
|
private class DelayTaskTimer : Timer
|
||||||
{
|
{
|
||||||
private readonly TaskCompletionSource<DelayTaskTimer> m_TaskCompleter;
|
private readonly TaskCompletionSource<DelayTaskTimer> m_TaskCompleter;
|
||||||
268
Projects/Server/Timer/TimerDelayCalls.cs
Normal file
268
Projects/Server/Timer/TimerDelayCalls.cs
Normal file
|
|
@ -0,0 +1,268 @@
|
||||||
|
/*************************************************************************
|
||||||
|
* ModernUO *
|
||||||
|
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||||
|
* Email: hi@modernuo.com *
|
||||||
|
* File: TimerDelayCalls.cs - Created: 2020/07/31 - Updated: 2020/07/31 *
|
||||||
|
* *
|
||||||
|
* 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. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
namespace Server
|
||||||
|
{
|
||||||
|
public delegate void TimerCallback();
|
||||||
|
public delegate void TimerStateCallback<in T>(T state);
|
||||||
|
public delegate void TimerStateCallback<in T1, in T2>(T1 t1, T2 t2);
|
||||||
|
public delegate void TimerStateCallback<in T1, in T2, in T3>(T1 t1, T2 t2, T3 t3);
|
||||||
|
public delegate void TimerStateCallback<in T1, in T2, in T3, in T4>(T1 t1, T2 t2, T3 t3, T4 t4);
|
||||||
|
|
||||||
|
public partial class Timer
|
||||||
|
{
|
||||||
|
public static Timer DelayCall(TimerCallback callback) => DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback);
|
||||||
|
|
||||||
|
public static Timer DelayCall(TimeSpan delay, TimerCallback callback) => DelayCall(delay, TimeSpan.Zero, 1, callback);
|
||||||
|
|
||||||
|
public static Timer DelayCall(TimeSpan delay, TimeSpan interval, TimerCallback callback) =>
|
||||||
|
DelayCall(delay, interval, 0, callback);
|
||||||
|
|
||||||
|
public static Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, TimerCallback callback)
|
||||||
|
{
|
||||||
|
Timer t = new DelayCallTimer(delay, interval, count, callback);
|
||||||
|
|
||||||
|
t.Priority = ComputePriority(count == 1 ? delay : interval);
|
||||||
|
t.Start();
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DelayCallTimer : Timer
|
||||||
|
{
|
||||||
|
public DelayCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerCallback callback) : base(delay,
|
||||||
|
interval, count)
|
||||||
|
{
|
||||||
|
Callback = callback;
|
||||||
|
RegCreation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimerCallback Callback { get; }
|
||||||
|
|
||||||
|
public override bool DefRegCreation => false;
|
||||||
|
|
||||||
|
protected override void OnTick()
|
||||||
|
{
|
||||||
|
Callback?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() => $"DelayCallTimer[{FormatDelegate(Callback)}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Timer DelayCall<T>(TimerStateCallback<T> callback, T state) =>
|
||||||
|
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, state);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T>(TimeSpan delay, TimerStateCallback<T> callback, T state) =>
|
||||||
|
DelayCall(delay, TimeSpan.Zero, 1, callback, state);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T>(TimeSpan delay, TimeSpan interval, TimerStateCallback<T> callback, T state) =>
|
||||||
|
DelayCall(delay, interval, 0, callback, state);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T>(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T> callback,
|
||||||
|
T state)
|
||||||
|
{
|
||||||
|
Timer t = new DelayStateCallTimer<T>(delay, interval, count, callback, state);
|
||||||
|
|
||||||
|
t.Priority = ComputePriority(count == 1 ? delay : interval);
|
||||||
|
|
||||||
|
t.Start();
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DelayStateCallTimer<T> : Timer
|
||||||
|
{
|
||||||
|
private readonly T m_State;
|
||||||
|
|
||||||
|
public DelayStateCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T> callback, T state)
|
||||||
|
: base(delay, interval, count)
|
||||||
|
{
|
||||||
|
Callback = callback;
|
||||||
|
m_State = state;
|
||||||
|
|
||||||
|
RegCreation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimerStateCallback<T> Callback { get; }
|
||||||
|
|
||||||
|
public override bool DefRegCreation => false;
|
||||||
|
|
||||||
|
protected override void OnTick()
|
||||||
|
{
|
||||||
|
Callback?.Invoke(m_State);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2>(TimerStateCallback<T1, T2> callback, T1 t1, T2 t2) =>
|
||||||
|
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2>(TimeSpan delay, TimerStateCallback<T1, T2> callback, T1 t1, T2 t2) =>
|
||||||
|
DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2>(TimeSpan delay, TimeSpan interval, TimerStateCallback<T1, T2> callback,
|
||||||
|
T1 t1, T2 t2) => DelayCall(delay, interval, 0, callback, t1, t2);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2>(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T1, T2> callback,
|
||||||
|
T1 t1, T2 t2)
|
||||||
|
{
|
||||||
|
Timer t = new DelayStateCallTimer<T1, T2>(delay, interval, count, callback, t1, t2);
|
||||||
|
|
||||||
|
t.Priority = ComputePriority(count == 1 ? delay : interval);
|
||||||
|
|
||||||
|
t.Start();
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DelayStateCallTimer<T1, T2> : Timer
|
||||||
|
{
|
||||||
|
private readonly T1 m_T1;
|
||||||
|
private readonly T2 m_T2;
|
||||||
|
|
||||||
|
public DelayStateCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T1, T2> callback,
|
||||||
|
T1 t1, T2 t2) : base(delay, interval, count)
|
||||||
|
{
|
||||||
|
Callback = callback;
|
||||||
|
m_T1 = t1;
|
||||||
|
m_T2 = t2;
|
||||||
|
|
||||||
|
RegCreation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimerStateCallback<T1, T2> Callback { get; }
|
||||||
|
|
||||||
|
public override bool DefRegCreation => false;
|
||||||
|
|
||||||
|
protected override void OnTick()
|
||||||
|
{
|
||||||
|
Callback?.Invoke(m_T1, m_T2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2, T3>(TimerStateCallback<T1, T2, T3> callback, T1 t1, T2 t2, T3 t3) =>
|
||||||
|
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2, T3>(TimeSpan delay, TimerStateCallback<T1, T2, T3> callback, T1 t1, T2 t2, T3 t3) =>
|
||||||
|
DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2, t3);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2, T3>(TimeSpan delay, TimeSpan interval, TimerStateCallback<T1, T2, T3> callback,
|
||||||
|
T1 t1, T2 t2, T3 t3) => DelayCall(delay, interval, 0, callback, t1, t2, t3);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2, T3>(TimeSpan delay, TimeSpan interval, int count,
|
||||||
|
TimerStateCallback<T1, T2, T3> callback, T1 t1, T2 t2, T3 t3)
|
||||||
|
{
|
||||||
|
Timer t = new DelayStateCallTimer<T1, T2, T3>(delay, interval, count, callback, t1, t2, t3);
|
||||||
|
|
||||||
|
t.Priority = ComputePriority(count == 1 ? delay : interval);
|
||||||
|
|
||||||
|
t.Start();
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DelayStateCallTimer<T1, T2, T3> : Timer
|
||||||
|
{
|
||||||
|
private readonly T1 m_T1;
|
||||||
|
private readonly T2 m_T2;
|
||||||
|
private readonly T3 m_T3;
|
||||||
|
|
||||||
|
public DelayStateCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T1, T2, T3> callback,
|
||||||
|
T1 t1, T2 t2, T3 t3) : base(delay, interval, count)
|
||||||
|
{
|
||||||
|
Callback = callback;
|
||||||
|
m_T1 = t1;
|
||||||
|
m_T2 = t2;
|
||||||
|
m_T3 = t3;
|
||||||
|
|
||||||
|
RegCreation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimerStateCallback<T1, T2, T3> Callback { get; }
|
||||||
|
|
||||||
|
public override bool DefRegCreation => false;
|
||||||
|
|
||||||
|
protected override void OnTick()
|
||||||
|
{
|
||||||
|
Callback?.Invoke(m_T1, m_T2, m_T3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2, T3, T4>(TimerStateCallback<T1, T2, T3, T4> callback, T1 t1, T2 t2, T3 t3, T4 t4) =>
|
||||||
|
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3, t4);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2, T3, T4>(TimeSpan delay, TimerStateCallback<T1, T2, T3, T4> callback,
|
||||||
|
T1 t1, T2 t2, T3 t3, T4 t4) => DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2, t3, t4);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2, T3, T4>(TimeSpan delay, TimeSpan interval,
|
||||||
|
TimerStateCallback<T1, T2, T3, T4> callback, T1 t1, T2 t2, T3 t3, T4 t4) =>
|
||||||
|
DelayCall(delay, interval, 0, callback, t1, t2, t3, t4);
|
||||||
|
|
||||||
|
public static Timer DelayCall<T1, T2, T3, T4>(TimeSpan delay, TimeSpan interval, int count,
|
||||||
|
TimerStateCallback<T1, T2, T3, T4> callback, T1 t1, T2 t2, T3 t3, T4 t4)
|
||||||
|
{
|
||||||
|
Timer t = new DelayStateCallTimer<T1, T2, T3, T4>(delay, interval, count, callback, t1, t2, t3, t4);
|
||||||
|
|
||||||
|
t.Priority = ComputePriority(count == 1 ? delay : interval);
|
||||||
|
|
||||||
|
t.Start();
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DelayStateCallTimer<T1, T2, T3, T4> : Timer
|
||||||
|
{
|
||||||
|
private readonly T1 m_T1;
|
||||||
|
private readonly T2 m_T2;
|
||||||
|
private readonly T3 m_T3;
|
||||||
|
private readonly T4 m_T4;
|
||||||
|
|
||||||
|
public DelayStateCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T1, T2, T3, T4> callback,
|
||||||
|
T1 t1, T2 t2, T3 t3, T4 t4) : base(delay, interval, count)
|
||||||
|
{
|
||||||
|
Callback = callback;
|
||||||
|
m_T1 = t1;
|
||||||
|
m_T2 = t2;
|
||||||
|
m_T3 = t3;
|
||||||
|
m_T4 = t4;
|
||||||
|
|
||||||
|
RegCreation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimerStateCallback<T1, T2, T3, T4> Callback { get; }
|
||||||
|
|
||||||
|
public override bool DefRegCreation => false;
|
||||||
|
|
||||||
|
protected override void OnTick()
|
||||||
|
{
|
||||||
|
Callback?.Invoke(m_T1, m_T2, m_T3, m_T4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*************************************************************************
|
||||||
|
* ModernUO *
|
||||||
|
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||||
|
* Email: hi@modernuo.com *
|
||||||
|
* File: ActivatorUtil.cs - Created: 2020/02/19 - Updated: 2020/07/30 *
|
||||||
|
* *
|
||||||
|
* 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. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* 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;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*************************************************************************
|
||||||
|
* ModernUO *
|
||||||
|
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||||
|
* Email: hi@modernuo.com *
|
||||||
|
* File: RefPool.cs - Created: 2020/02/20 - Updated: 2020/07/30 *
|
||||||
|
* *
|
||||||
|
* 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. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* 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;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -493,19 +493,8 @@ namespace Server
|
||||||
return dy > 0 ? Direction.Left : Direction.Up;
|
return dy > 0 ? Direction.Left : Direction.Up;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static object GetArrayCap(Array array, int index, object emptyValue = null)
|
public static object GetArrayCap(Array array, int index, object emptyValue = null) =>
|
||||||
{
|
array.Length > 0 ? array.GetValue(Math.Clamp(index, 0, array.Length - 1)) : emptyValue;
|
||||||
if (array.Length > 0)
|
|
||||||
{
|
|
||||||
if (index < 0)
|
|
||||||
index = 0;
|
|
||||||
else if (index >= array.Length) index = array.Length - 1;
|
|
||||||
|
|
||||||
return array.GetValue(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
return emptyValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SkillName RandomSkill() =>
|
public static SkillName RandomSkill() =>
|
||||||
m_AllSkills[Random(m_AllSkills.Length - (Core.ML ? 0 : Core.SE ? 1 : Core.AOS ? 3 : 6))];
|
m_AllSkills[Random(m_AllSkills.Length - (Core.ML ? 0 : Core.SE ? 1 : Core.AOS ? 3 : 6))];
|
||||||
|
|
@ -1002,5 +991,12 @@ namespace Server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int RandomBrightHue() =>
|
public static int RandomBrightHue() =>
|
||||||
RandomDouble() < 0.1 ? RandomList(0x62, 0x71) : RandomList(0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59);
|
RandomDouble() < 0.1 ? RandomList(0x62, 0x71) : RandomList(0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59);
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T> =>
|
||||||
|
val.CompareTo(min) < 0 ? min : val.CompareTo(max) > 0 ? max : val;
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static TimeSpan Max(this TimeSpan val, TimeSpan max) => val > max ? max : val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Server.Commands.Generic
|
||||||
{
|
{
|
||||||
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
|
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
|
||||||
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
||||||
(m, targeted) => OnTarget(m, targeted, command, args));
|
(m, targeted, a) => OnTarget(m, targeted, command, a), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
|
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace Server.Commands.Generic
|
||||||
{
|
{
|
||||||
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
|
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
|
||||||
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
||||||
(m, targeted) => OnTarget(m, targeted, command, args));
|
(m, targeted, a) => OnTarget(m, targeted, command, a), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
|
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Server.Commands.Generic
|
||||||
{
|
{
|
||||||
from.SendLocalizedMessage(500447); // That is not accessible.
|
from.SendLocalizedMessage(500447); // That is not accessible.
|
||||||
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
||||||
(m, t) => OnTarget(m, t, command, args));
|
(m, t, a) => OnTarget(m, t, command, a), args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ namespace Server.Commands.Generic
|
||||||
RunCommand(from, targeted, command, args);
|
RunCommand(from, targeted, command, args);
|
||||||
|
|
||||||
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
||||||
(m, t) => OnTarget(m, t, command, args));
|
(m, t, a) => OnTarget(m, t, command, a), args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ namespace Server.Commands.Generic
|
||||||
{
|
{
|
||||||
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
|
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
|
||||||
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
||||||
(m, targeted) => OnTarget(m, targeted, command, args));
|
(m, targeted, a) => OnTarget(m, targeted, command, a), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
|
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
|
||||||
|
|
|
||||||
|
|
@ -91,12 +91,7 @@ namespace Server.Gumps
|
||||||
|
|
||||||
CAGNode[] nodes = m_Category.Nodes;
|
CAGNode[] nodes = m_Category.Nodes;
|
||||||
|
|
||||||
int count = nodes.Length - page * EntryCount;
|
int count = Math.Clamp(nodes.Length - page * EntryCount, 0, EntryCount);
|
||||||
|
|
||||||
if (count < 0)
|
|
||||||
count = 0;
|
|
||||||
else if (count > EntryCount)
|
|
||||||
count = EntryCount;
|
|
||||||
|
|
||||||
int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1);
|
int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ namespace Server.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return chain[chain.Length - 1];
|
return chain[^1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetValue(Mobile from, object o, string name)
|
public static string GetValue(Mobile from, object o, string name)
|
||||||
|
|
@ -328,7 +328,7 @@ namespace Server.Commands
|
||||||
concat[i * 2 + 1] = i < chain.Length - 1 ? "." : " = ";
|
concat[i * 2 + 1] = i < chain.Length - 1 ? "." : " = ";
|
||||||
}
|
}
|
||||||
|
|
||||||
concat[concat.Length - 1] = toString;
|
concat[^1] = toString;
|
||||||
|
|
||||||
return string.Concat(concat);
|
return string.Concat(concat);
|
||||||
}
|
}
|
||||||
|
|
@ -654,7 +654,7 @@ namespace Server
|
||||||
if (!IsBound)
|
if (!IsBound)
|
||||||
throw new NotYetBoundException(this);
|
throw new NotYetBoundException(this);
|
||||||
|
|
||||||
return m_Chain[m_Chain.Length - 1].PropertyType;
|
return m_Chain[^1].PropertyType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Server.Engines.BulkOrders
|
||||||
if (split.Length >= 2)
|
if (split.Length >= 2)
|
||||||
{
|
{
|
||||||
Type type = AssemblyHandler.FindFirstTypeForName(split[0]);
|
Type type = AssemblyHandler.FindFirstTypeForName(split[0]);
|
||||||
int graphic = Utility.ToInt32(split[split.Length - 1]);
|
int graphic = Utility.ToInt32(split[^1]);
|
||||||
|
|
||||||
if (type != null && graphic > 0)
|
if (type != null && graphic > 0)
|
||||||
list.Add(new SmallBulkEntry(type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic));
|
list.Add(new SmallBulkEntry(type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic));
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Server.Engines.CannedEvil
|
||||||
|
|
||||||
m_DamageEntries = new Dictionary<Mobile, int>();
|
m_DamageEntries = new Dictionary<Mobile, int>();
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, SetInitialSpawnArea);
|
Timer.DelayCall(SetInitialSpawnArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChampionSpawn(Serial serial) : base(serial)
|
public ChampionSpawn(Serial serial) : base(serial)
|
||||||
|
|
@ -1130,7 +1130,7 @@ namespace Server.Engines.CannedEvil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, UpdateRegion);
|
Timer.DelayCall(UpdateRegion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@ namespace Server.Engines.ConPVP
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(2.0), Evict);
|
Timer.DelayCall(TimeSpan.FromSeconds(2.0), Evict);
|
||||||
|
|
||||||
if (m_Tournament != null)
|
if (m_Tournament != null)
|
||||||
Timer.DelayCall(TimeSpan.Zero, AttachToTournament_Sandbox);
|
Timer.DelayCall(AttachToTournament_Sandbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
|
|
@ -345,21 +345,7 @@ namespace Server.Engines.ConPVP
|
||||||
set => m_Bounds = value;
|
set => m_Bounds = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Spectators
|
public int Spectators => m_Region == null ? 0 : Math.Max(m_Region.GetPlayerCount() - Players.Count, 0);
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (m_Region == null)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int specs = m_Region.GetPlayerCount() - Players.Count;
|
|
||||||
|
|
||||||
if (specs < 0)
|
|
||||||
specs = 0;
|
|
||||||
|
|
||||||
return specs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
public Rectangle2D Zone
|
public Rectangle2D Zone
|
||||||
|
|
@ -476,22 +462,13 @@ namespace Server.Engines.ConPVP
|
||||||
|
|
||||||
public override string ToString() => "...";
|
public override string ToString() => "...";
|
||||||
|
|
||||||
public Point3D GetBaseStartPoint(int index)
|
public Point3D GetBaseStartPoint(int index) => Points.Points[Math.Max(index, 0) % Points.Points.Length];
|
||||||
{
|
|
||||||
if (index < 0)
|
|
||||||
index = 0;
|
|
||||||
|
|
||||||
return Points.Points[index % Points.Points.Length];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MoveInside(DuelPlayer[] players, int index)
|
public void MoveInside(DuelPlayer[] players, int index)
|
||||||
{
|
{
|
||||||
if (index < 0)
|
index = Math.Min(index, 0) % Points.Points.Length;
|
||||||
index = 0;
|
|
||||||
else
|
|
||||||
index %= Points.Points.Length;
|
|
||||||
|
|
||||||
Point3D start = GetBaseStartPoint(index);
|
Point3D start = Points.Points[index];
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
|
|
@ -512,7 +489,7 @@ namespace Server.Engines.ConPVP
|
||||||
if (offset < offsets.Length)
|
if (offset < offsets.Length)
|
||||||
p = offsets[offset++];
|
p = offsets[offset++];
|
||||||
else
|
else
|
||||||
p = offsets[offsets.Length - 1];
|
p = offsets[^1];
|
||||||
|
|
||||||
p.X = p.X * matrix[0, 0] + p.Y * matrix[0, 1];
|
p.X = p.X * matrix[0, 0] + p.Y * matrix[0, 1];
|
||||||
p.Y = p.X * matrix[1, 0] + p.Y * matrix[1, 1];
|
p.Y = p.X * matrix[1, 0] + p.Y * matrix[1, 1];
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ namespace Server.Engines.ConPVP
|
||||||
|
|
||||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||||
{
|
{
|
||||||
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
|
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move) => (from as PlayerMobile)?.DuelContext?.InstAllowSpecialMove(from, name, move) != false;
|
public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move) => (from as PlayerMobile)?.DuelContext?.InstAllowSpecialMove(from, name, move) != false;
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Server.Engines.ConPVP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, Delete).Start(); // delete this after the world loads
|
Timer.DelayCall(Delete); // delete this after the world loads
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
public override void Serialize(IGenericWriter writer)
|
||||||
|
|
@ -202,7 +202,7 @@ namespace Server.Engines.ConPVP
|
||||||
m_Path.Clear();
|
m_Path.Clear();
|
||||||
m_PathIdx = 0;
|
m_PathIdx = 0;
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(0.05), ContinueFlight).Start();
|
Timer.DelayCall(TimeSpan.FromSeconds(0.05), ContinueFlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CheckCatch(Mobile m, Point3D myLoc)
|
private bool CheckCatch(Mobile m, Point3D myLoc)
|
||||||
|
|
@ -292,7 +292,7 @@ namespace Server.Engines.ConPVP
|
||||||
|
|
||||||
if (list.Count > 0)
|
if (list.Count > 0)
|
||||||
{
|
{
|
||||||
Point3D p = list[list.Count - 1];
|
Point3D p = list[^1];
|
||||||
|
|
||||||
if (p.X != ix || p.Y != iy || p.Z != iz)
|
if (p.X != ix || p.Y != iy || p.Z != iz)
|
||||||
list.Add(new Point3D(ix, iy, iz));
|
list.Add(new Point3D(ix, iy, iz));
|
||||||
|
|
@ -307,7 +307,7 @@ namespace Server.Engines.ConPVP
|
||||||
z += zslp;
|
z += zslp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.Count > 0 && list[list.Count - 1] != dest)
|
if (list.Count > 0 && list[^1] != dest)
|
||||||
list.Add(dest);
|
list.Add(dest);
|
||||||
|
|
||||||
/*if (dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y ))
|
/*if (dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y ))
|
||||||
|
|
@ -540,7 +540,7 @@ namespace Server.Engines.ConPVP
|
||||||
if (m_PathIdx > 0 && m_PathIdx - 1 < m_Path.Count)
|
if (m_PathIdx > 0 && m_PathIdx - 1 < m_Path.Count)
|
||||||
DoAnim(GetWorldLocation(), m_Path[m_PathIdx - 1], Map);
|
DoAnim(GetWorldLocation(), m_Path[m_PathIdx - 1], Map);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(0.1), ContinueFlight).Start();
|
Timer.DelayCall(TimeSpan.FromSeconds(0.1), ContinueFlight);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -734,7 +734,7 @@ namespace Server.Engines.ConPVP
|
||||||
|
|
||||||
// has to be delayed in case some other target canceled us...
|
// has to be delayed in case some other target canceled us...
|
||||||
if (m_Resend)
|
if (m_Resend)
|
||||||
Timer.DelayCall(TimeSpan.Zero, ResendBombTarget).Start();
|
Timer.DelayCall(ResendBombTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResendBombTarget()
|
private void ResendBombTarget()
|
||||||
|
|
@ -1499,7 +1499,7 @@ namespace Server.Engines.ConPVP
|
||||||
|
|
||||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||||
{
|
{
|
||||||
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
|
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
||||||
|
|
|
||||||
|
|
@ -877,7 +877,7 @@ namespace Server.Engines.ConPVP
|
||||||
|
|
||||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||||
{
|
{
|
||||||
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
|
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
||||||
|
|
|
||||||
|
|
@ -516,7 +516,7 @@ namespace Server.Engines.ConPVP
|
||||||
|
|
||||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||||
{
|
{
|
||||||
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
|
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
||||||
|
|
@ -846,7 +846,6 @@ namespace Server.Engines.ConPVP
|
||||||
{
|
{
|
||||||
m_CapStage = 0;
|
m_CapStage = 0;
|
||||||
m_CaptureTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1.0), CaptureTick);
|
m_CaptureTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1.0), CaptureTick);
|
||||||
m_CaptureTimer.Start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -883,7 +883,7 @@ namespace Server.Engines.ConPVP
|
||||||
|
|
||||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||||
{
|
{
|
||||||
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
|
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
||||||
|
|
|
||||||
|
|
@ -657,7 +657,7 @@ namespace Server.Engines.ConPVP
|
||||||
m_PerPage = perPage;
|
m_PerPage = perPage;
|
||||||
|
|
||||||
index = Math.Max(m_Page * perPage, 0);
|
index = Math.Max(m_Page * perPage, 0);
|
||||||
count = Math.Max(Math.Min(m_List.Count - index, perPage), 0);
|
count = Math.Clamp(m_List.Count - index, 0, perPage);
|
||||||
|
|
||||||
y = 53 + (12 - perPage) * 18;
|
y = 53 + (12 - perPage) * 18;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ namespace Server.Engines.ConPVP
|
||||||
}
|
}
|
||||||
|
|
||||||
Resize(Players.Length + 1);
|
Resize(Players.Length + 1);
|
||||||
Players[Players.Length - 1] = new DuelPlayer(player, this);
|
Players[^1] = new DuelPlayer(player, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Resize(int count)
|
public void Resize(int count)
|
||||||
|
|
|
||||||
|
|
@ -433,7 +433,7 @@ namespace Server.Engines.ConPVP
|
||||||
if (Pyramid.Levels.Count < 1)
|
if (Pyramid.Levels.Count < 1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
|
PyramidLevel top = Pyramid.Levels[^1];
|
||||||
|
|
||||||
if (top.FreeAdvance != null || top.Matches.Count != 1)
|
if (top.FreeAdvance != null || top.Matches.Count != 1)
|
||||||
break;
|
break;
|
||||||
|
|
@ -451,7 +451,7 @@ namespace Server.Engines.ConPVP
|
||||||
if (Pyramid.Levels.Count < 2)
|
if (Pyramid.Levels.Count < 2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
|
PyramidLevel top = Pyramid.Levels[^1];
|
||||||
|
|
||||||
if (top.FreeAdvance != null || top.Matches.Count != 1)
|
if (top.FreeAdvance != null || top.Matches.Count != 1)
|
||||||
break;
|
break;
|
||||||
|
|
@ -471,7 +471,7 @@ namespace Server.Engines.ConPVP
|
||||||
GiveAwards(part.Players, TrophyRank.Silver, cash / 2);
|
GiveAwards(part.Players, TrophyRank.Silver, cash / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyramidLevel next = Pyramid.Levels[Pyramid.Levels.Count - 2];
|
PyramidLevel next = Pyramid.Levels[^2];
|
||||||
|
|
||||||
if (next.Matches.Count > 2)
|
if (next.Matches.Count > 2)
|
||||||
break;
|
break;
|
||||||
|
|
@ -739,7 +739,7 @@ namespace Server.Engines.ConPVP
|
||||||
}
|
}
|
||||||
else if (Pyramid.Levels.Count > 0)
|
else if (Pyramid.Levels.Count > 0)
|
||||||
{
|
{
|
||||||
PyramidLevel activeLevel = Pyramid.Levels[Pyramid.Levels.Count - 1];
|
PyramidLevel activeLevel = Pyramid.Levels[^1];
|
||||||
bool stillGoing = false;
|
bool stillGoing = false;
|
||||||
|
|
||||||
for (int i = 0; i < activeLevel.Matches.Count; ++i)
|
for (int i = 0; i < activeLevel.Matches.Count; ++i)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Server.Engines.Craft
|
||||||
|
{
|
||||||
|
public static class CraftCollectionExtensions
|
||||||
|
{
|
||||||
|
public static int SearchFor(this List<CraftGroup> list, TextDefinition groupName)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < list.Count; i++)
|
||||||
|
{
|
||||||
|
CraftGroup craftGroup = list[i];
|
||||||
|
|
||||||
|
int nameNumber = craftGroup.NameNumber;
|
||||||
|
string nameString = craftGroup.NameString;
|
||||||
|
|
||||||
|
if (nameNumber != 0 && nameNumber == groupName.Number ||
|
||||||
|
nameString != null && nameString == groupName.String)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CraftItem SearchForSubclass(this List<CraftItem> list, Type type)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < list.Count; i++)
|
||||||
|
{
|
||||||
|
CraftItem craftItem = list[i];
|
||||||
|
|
||||||
|
if (craftItem.ItemType == type || type.IsSubclassOf(craftItem.ItemType))
|
||||||
|
return craftItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CraftItem SearchFor(this List<CraftItem> list, Type type)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < list.Count; i++)
|
||||||
|
{
|
||||||
|
CraftItem craftItem = list[i];
|
||||||
|
if (craftItem.ItemType == type) return craftItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Server.Engines.Craft
|
namespace Server.Engines.Craft
|
||||||
{
|
{
|
||||||
public class CraftGroup
|
public class CraftGroup
|
||||||
|
|
@ -6,10 +8,10 @@ namespace Server.Engines.Craft
|
||||||
{
|
{
|
||||||
NameNumber = groupName;
|
NameNumber = groupName;
|
||||||
NameString = groupName;
|
NameString = groupName;
|
||||||
CraftItems = new CraftItemCol();
|
CraftItems = new List<CraftItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftItemCol CraftItems { get; }
|
public List<CraftItem> CraftItems { get; }
|
||||||
|
|
||||||
public string NameString { get; }
|
public string NameString { get; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace Server.Engines.Craft
|
|
||||||
{
|
|
||||||
public class CraftGroupCol : CollectionBase
|
|
||||||
{
|
|
||||||
public int Add(CraftGroup craftGroup) => List.Add(craftGroup);
|
|
||||||
|
|
||||||
public void Remove(int index)
|
|
||||||
{
|
|
||||||
if (index > Count - 1 || index < 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List.RemoveAt(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CraftGroup GetAt(int index) => (CraftGroup)List[index];
|
|
||||||
|
|
||||||
public int SearchFor(TextDefinition groupName)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < List.Count; i++)
|
|
||||||
{
|
|
||||||
CraftGroup craftGroup = (CraftGroup)List[i];
|
|
||||||
|
|
||||||
int nameNumber = craftGroup.NameNumber;
|
|
||||||
string nameString = craftGroup.NameString;
|
|
||||||
|
|
||||||
if ((nameNumber != 0 && nameNumber == groupName.Number) ||
|
|
||||||
(nameString != null && nameString == groupName.String))
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -186,7 +186,7 @@ namespace Server.Engines.Craft
|
||||||
{
|
{
|
||||||
int index = i % 10;
|
int index = i % 10;
|
||||||
|
|
||||||
CraftSubRes subResource = res.GetAt(i);
|
CraftSubRes subResource = res[i];
|
||||||
|
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -279,15 +279,14 @@ namespace Server.Engines.Craft
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
|
CraftGroup craftGroup = m_CraftSystem.CraftGroups[selectedGroup];
|
||||||
CraftGroup craftGroup = craftGroupCol.GetAt(selectedGroup);
|
List<CraftItem> craftItemCol = craftGroup.CraftItems;
|
||||||
CraftItemCol craftItemCol = craftGroup.CraftItems;
|
|
||||||
|
|
||||||
for (int i = 0; i < craftItemCol.Count; ++i)
|
for (int i = 0; i < craftItemCol.Count; ++i)
|
||||||
{
|
{
|
||||||
int index = i % 10;
|
int index = i % 10;
|
||||||
|
|
||||||
CraftItem craftItem = craftItemCol.GetAt(i);
|
CraftItem craftItem = craftItemCol[i];
|
||||||
|
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -319,14 +318,14 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
public int CreateGroupList()
|
public int CreateGroupList()
|
||||||
{
|
{
|
||||||
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
|
List<CraftGroup> craftGroupCol = m_CraftSystem.CraftGroups;
|
||||||
|
|
||||||
AddButton(15, 60, 4005, 4007, GetButtonID(6, 3));
|
AddButton(15, 60, 4005, 4007, GetButtonID(6, 3));
|
||||||
AddHtmlLocalized(50, 63, 150, 18, 1044014, LabelColor); // LAST TEN
|
AddHtmlLocalized(50, 63, 150, 18, 1044014, LabelColor); // LAST TEN
|
||||||
|
|
||||||
for (int i = 0; i < craftGroupCol.Count; i++)
|
for (int i = 0; i < craftGroupCol.Count; i++)
|
||||||
{
|
{
|
||||||
CraftGroup craftGroup = craftGroupCol.GetAt(i);
|
CraftGroup craftGroup = craftGroupCol[i];
|
||||||
|
|
||||||
AddButton(15, 80 + i * 20, 4005, 4007, GetButtonID(0, i));
|
AddButton(15, 80 + i * 20, 4005, 4007, GetButtonID(0, i));
|
||||||
|
|
||||||
|
|
@ -378,7 +377,7 @@ namespace Server.Engines.Craft
|
||||||
int index = buttonID / 7;
|
int index = buttonID / 7;
|
||||||
|
|
||||||
CraftSystem system = m_CraftSystem;
|
CraftSystem system = m_CraftSystem;
|
||||||
CraftGroupCol groups = system.CraftGroups;
|
List<CraftGroup> groups = system.CraftGroups;
|
||||||
CraftContext context = system.GetContext(m_From);
|
CraftContext context = system.GetContext(m_From);
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
@ -405,10 +404,10 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
if (groupIndex >= 0 && groupIndex < groups.Count)
|
if (groupIndex >= 0 && groupIndex < groups.Count)
|
||||||
{
|
{
|
||||||
CraftGroup group = groups.GetAt(groupIndex);
|
CraftGroup group = groups[groupIndex];
|
||||||
|
|
||||||
if (index >= 0 && index < group.CraftItems.Count)
|
if (index >= 0 && index < group.CraftItems.Count)
|
||||||
CraftItem(group.CraftItems.GetAt(index));
|
CraftItem(group.CraftItems[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -422,10 +421,10 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
if (groupIndex >= 0 && groupIndex < groups.Count)
|
if (groupIndex >= 0 && groupIndex < groups.Count)
|
||||||
{
|
{
|
||||||
CraftGroup group = groups.GetAt(groupIndex);
|
CraftGroup group = groups[groupIndex];
|
||||||
|
|
||||||
if (index >= 0 && index < group.CraftItems.Count)
|
if (index >= 0 && index < group.CraftItems.Count)
|
||||||
m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool));
|
m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems[index], m_Tool));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ namespace Server.Engines.Craft
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_CraftItem.Skills.Count; i++)
|
for (int i = 0; i < m_CraftItem.Skills.Count; i++)
|
||||||
{
|
{
|
||||||
CraftSkill skill = m_CraftItem.Skills.GetAt(i);
|
CraftSkill skill = m_CraftItem.Skills[i];
|
||||||
double minSkill = skill.MinSkill;
|
double minSkill = skill.MinSkill;
|
||||||
|
|
||||||
if (minSkill < 0)
|
if (minSkill < 0)
|
||||||
|
|
@ -191,7 +191,7 @@ namespace Server.Engines.Craft
|
||||||
resIndex = m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex;
|
resIndex = m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex;
|
||||||
|
|
||||||
bool cropScroll = m_CraftItem.Resources.Count > 1
|
bool cropScroll = m_CraftItem.Resources.Count > 1
|
||||||
&& m_CraftItem.Resources.GetAt(m_CraftItem.Resources.Count - 1).ItemType == typeofBlankScroll
|
&& m_CraftItem.Resources[^1].ItemType == typeofBlankScroll
|
||||||
&& typeofSpellScroll.IsAssignableFrom(m_CraftItem.ItemType);
|
&& typeofSpellScroll.IsAssignableFrom(m_CraftItem.ItemType);
|
||||||
|
|
||||||
for (int i = 0; i < m_CraftItem.Resources.Count - (cropScroll ? 1 : 0) && i < 4; i++)
|
for (int i = 0; i < m_CraftItem.Resources.Count - (cropScroll ? 1 : 0) && i < 4; i++)
|
||||||
|
|
@ -200,7 +200,7 @@ namespace Server.Engines.Craft
|
||||||
string nameString;
|
string nameString;
|
||||||
int nameNumber;
|
int nameNumber;
|
||||||
|
|
||||||
CraftRes craftResource = m_CraftItem.Resources.GetAt(i);
|
CraftRes craftResource = m_CraftItem.Resources[i];
|
||||||
|
|
||||||
type = craftResource.ItemType;
|
type = craftResource.ItemType;
|
||||||
nameString = craftResource.NameString;
|
nameString = craftResource.NameString;
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
public CraftItem(Type type, TextDefinition groupName, TextDefinition name)
|
public CraftItem(Type type, TextDefinition groupName, TextDefinition name)
|
||||||
{
|
{
|
||||||
Resources = new CraftResCol();
|
Resources = new List<CraftRes>();
|
||||||
Skills = new CraftSkillCol();
|
Skills = new List<CraftSkill>();
|
||||||
|
|
||||||
ItemType = type;
|
ItemType = type;
|
||||||
|
|
||||||
|
|
@ -82,9 +82,9 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
public int NameNumber { get; }
|
public int NameNumber { get; }
|
||||||
|
|
||||||
public CraftResCol Resources { get; }
|
public List<CraftRes> Resources { get; }
|
||||||
|
|
||||||
public CraftSkillCol Skills { get; }
|
public List<CraftSkill> Skills { get; }
|
||||||
|
|
||||||
public void AddRecipe(int id, CraftSystem system)
|
public void AddRecipe(int id, CraftSystem system)
|
||||||
{
|
{
|
||||||
|
|
@ -452,7 +452,7 @@ namespace Server.Engines.Craft
|
||||||
CraftRes res;
|
CraftRes res;
|
||||||
for (int i = 0; i < types.Length; ++i)
|
for (int i = 0; i < types.Length; ++i)
|
||||||
{
|
{
|
||||||
CraftRes craftRes = Resources.GetAt(i);
|
CraftRes craftRes = Resources[i];
|
||||||
Type baseType = craftRes.ItemType;
|
Type baseType = craftRes.ItemType;
|
||||||
|
|
||||||
// Resource Mutation
|
// Resource Mutation
|
||||||
|
|
@ -490,7 +490,7 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
if (maxAmount == 0)
|
if (maxAmount == 0)
|
||||||
{
|
{
|
||||||
res = Resources.GetAt(i);
|
res = Resources[i];
|
||||||
|
|
||||||
if (res.MessageNumber > 0)
|
if (res.MessageNumber > 0)
|
||||||
message = res.MessageNumber;
|
message = res.MessageNumber;
|
||||||
|
|
@ -599,7 +599,7 @@ namespace Server.Engines.Craft
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = Resources.GetAt(index);
|
res = Resources[index];
|
||||||
|
|
||||||
if (res.MessageNumber > 0)
|
if (res.MessageNumber > 0)
|
||||||
message = res.MessageNumber;
|
message = res.MessageNumber;
|
||||||
|
|
@ -692,7 +692,7 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
for (int i = 0; i < Skills.Count; i++)
|
for (int i = 0; i < Skills.Count; i++)
|
||||||
{
|
{
|
||||||
CraftSkill craftSkill = Skills.GetAt(i);
|
CraftSkill craftSkill = Skills[i];
|
||||||
|
|
||||||
double minSkill = craftSkill.MinSkill;
|
double minSkill = craftSkill.MinSkill;
|
||||||
double maxSkill = craftSkill.MaxSkill;
|
double maxSkill = craftSkill.MaxSkill;
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace Server.Engines.Craft
|
|
||||||
{
|
|
||||||
public class CraftItemCol : CollectionBase
|
|
||||||
{
|
|
||||||
public int Add(CraftItem craftItem) => List.Add(craftItem);
|
|
||||||
|
|
||||||
public void Remove(int index)
|
|
||||||
{
|
|
||||||
if (index > Count - 1 || index < 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List.RemoveAt(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CraftItem GetAt(int index) => (CraftItem)List[index];
|
|
||||||
|
|
||||||
public CraftItem SearchForSubclass(Type type)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < List.Count; i++)
|
|
||||||
{
|
|
||||||
CraftItem craftItem = (CraftItem)List[i];
|
|
||||||
|
|
||||||
if (craftItem.ItemType == type || type.IsSubclassOf(craftItem.ItemType))
|
|
||||||
return craftItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CraftItem SearchFor(Type type)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < List.Count; i++)
|
|
||||||
{
|
|
||||||
CraftItem craftItem = (CraftItem)List[i];
|
|
||||||
if (craftItem.ItemType == type) return craftItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace Server.Engines.Craft
|
|
||||||
{
|
|
||||||
public class CraftResCol : CollectionBase
|
|
||||||
{
|
|
||||||
public void Add(CraftRes craftRes)
|
|
||||||
{
|
|
||||||
List.Add(craftRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Remove(int index)
|
|
||||||
{
|
|
||||||
if (index > Count - 1 || index < 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List.RemoveAt(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CraftRes GetAt(int index) => (CraftRes)List[index];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace Server.Engines.Craft
|
|
||||||
{
|
|
||||||
public class CraftSkillCol : CollectionBase
|
|
||||||
{
|
|
||||||
public void Add(CraftSkill craftSkill)
|
|
||||||
{
|
|
||||||
List.Add(craftSkill);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Remove(int index)
|
|
||||||
{
|
|
||||||
if (index > Count - 1 || index < 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List.RemoveAt(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CraftSkill GetAt(int index) => (CraftSkill)List[index];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Server.Engines.Craft
|
namespace Server.Engines.Craft
|
||||||
{
|
{
|
||||||
public class CraftSubResCol : CollectionBase
|
public class CraftSubResCol : List<CraftSubRes>
|
||||||
{
|
{
|
||||||
public CraftSubResCol() => Init = false;
|
public CraftSubResCol() => Init = false;
|
||||||
|
|
||||||
|
|
@ -15,29 +15,13 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
public int NameNumber { get; set; }
|
public int NameNumber { get; set; }
|
||||||
|
|
||||||
public void Add(CraftSubRes craftSubRes)
|
public CraftSubRes GetAt(int index) => this[index];
|
||||||
{
|
|
||||||
List.Add(craftSubRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Remove(int index)
|
|
||||||
{
|
|
||||||
if (index > Count - 1 || index < 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List.RemoveAt(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CraftSubRes GetAt(int index) => (CraftSubRes)List[index];
|
|
||||||
|
|
||||||
public CraftSubRes SearchFor(Type type)
|
public CraftSubRes SearchFor(Type type)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < List.Count; i++)
|
for (int i = 0; i < Count; i++)
|
||||||
{
|
{
|
||||||
CraftSubRes craftSubRes = (CraftSubRes)List[i];
|
CraftSubRes craftSubRes = this[i];
|
||||||
if (craftSubRes.ItemType == type) return craftSubRes;
|
if (craftSubRes.ItemType == type) return craftSubRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ namespace Server.Engines.Craft
|
||||||
MaxCraftEffect = maxCraftEffect;
|
MaxCraftEffect = maxCraftEffect;
|
||||||
Delay = delay;
|
Delay = delay;
|
||||||
|
|
||||||
CraftItems = new CraftItemCol();
|
CraftItems = new List<CraftItem>();
|
||||||
CraftGroups = new CraftGroupCol();
|
CraftGroups = new List<CraftGroup>();
|
||||||
CraftSubRes = new CraftSubResCol();
|
CraftSubRes = new CraftSubResCol();
|
||||||
CraftSubRes2 = new CraftSubResCol();
|
CraftSubRes2 = new CraftSubResCol();
|
||||||
|
|
||||||
|
|
@ -40,9 +40,9 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
public double Delay { get; }
|
public double Delay { get; }
|
||||||
|
|
||||||
public CraftItemCol CraftItems { get; }
|
public List<CraftItem> CraftItems { get; }
|
||||||
|
|
||||||
public CraftGroupCol CraftGroups { get; }
|
public List<CraftGroup> CraftGroups { get; }
|
||||||
|
|
||||||
public CraftSubResCol CraftSubRes { get; }
|
public CraftSubResCol CraftSubRes { get; }
|
||||||
|
|
||||||
|
|
@ -134,7 +134,8 @@ namespace Server.Engines.Craft
|
||||||
craftItem.AddSkill(skillToMake, minSkill, maxSkill);
|
craftItem.AddSkill(skillToMake, minSkill, maxSkill);
|
||||||
|
|
||||||
DoGroup(group, craftItem);
|
DoGroup(group, craftItem);
|
||||||
return CraftItems.Add(craftItem);
|
CraftItems.Add(craftItem);
|
||||||
|
return CraftItems.Count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoGroup(TextDefinition groupName, CraftItem craftItem)
|
private void DoGroup(TextDefinition groupName, CraftItem craftItem)
|
||||||
|
|
@ -149,68 +150,58 @@ namespace Server.Engines.Craft
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CraftGroups.GetAt(index).AddCraftItem(craftItem);
|
CraftGroups[index].AddCraftItem(craftItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetItemHue(int index, int hue)
|
public void SetItemHue(int index, int hue)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].ItemHue = hue;
|
||||||
craftItem.ItemHue = hue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetManaReq(int index, int mana)
|
public void SetManaReq(int index, int mana)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].Mana = mana;
|
||||||
craftItem.Mana = mana;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStamReq(int index, int stam)
|
public void SetStamReq(int index, int stam)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].Stam = stam;
|
||||||
craftItem.Stam = stam;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHitsReq(int index, int hits)
|
public void SetHitsReq(int index, int hits)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].Hits = hits;
|
||||||
craftItem.Hits = hits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetUseAllRes(int index, bool useAll)
|
public void SetUseAllRes(int index, bool useAll)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].UseAllRes = useAll;
|
||||||
craftItem.UseAllRes = useAll;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetNeedHeat(int index, bool needHeat)
|
public void SetNeedHeat(int index, bool needHeat)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].NeedHeat = needHeat;
|
||||||
craftItem.NeedHeat = needHeat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetNeedOven(int index, bool needOven)
|
public void SetNeedOven(int index, bool needOven)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].NeedOven = needOven;
|
||||||
craftItem.NeedOven = needOven;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBeverageType(int index, BeverageType requiredBeverage)
|
public void SetBeverageType(int index, BeverageType requiredBeverage)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].RequiredBeverage = requiredBeverage;
|
||||||
craftItem.RequiredBeverage = requiredBeverage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetNeedMill(int index, bool needMill)
|
public void SetNeedMill(int index, bool needMill)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].NeedMill = needMill;
|
||||||
craftItem.NeedMill = needMill;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetNeededExpansion(int index, Expansion expansion)
|
public void SetNeededExpansion(int index, Expansion expansion)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].RequiredExpansion = expansion;
|
||||||
craftItem.RequiredExpansion = expansion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRes(int index, Type type, TextDefinition name, int amount)
|
public void AddRes(int index, Type type, TextDefinition name, int amount)
|
||||||
|
|
@ -220,26 +211,22 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
public void AddRes(int index, Type type, TextDefinition name, int amount, TextDefinition message)
|
public void AddRes(int index, Type type, TextDefinition name, int amount, TextDefinition message)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].AddRes(type, name, amount, message);
|
||||||
craftItem.AddRes(type, name, amount, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSkill(int index, SkillName skillToMake, double minSkill, double maxSkill)
|
public void AddSkill(int index, SkillName skillToMake, double minSkill, double maxSkill)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].AddSkill(skillToMake, minSkill, maxSkill);
|
||||||
craftItem.AddSkill(skillToMake, minSkill, maxSkill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetUseSubRes2(int index, bool val)
|
public void SetUseSubRes2(int index, bool val)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].UseSubRes2 = val;
|
||||||
craftItem.UseSubRes2 = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddRecipeBase(int index, int id)
|
private void AddRecipeBase(int index, int id)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].AddRecipe(id, this);
|
||||||
craftItem.AddRecipe(id, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRecipe(int index, int id)
|
public void AddRecipe(int index, int id)
|
||||||
|
|
@ -261,8 +248,7 @@ namespace Server.Engines.Craft
|
||||||
|
|
||||||
public void ForceNonExceptional(int index)
|
public void ForceNonExceptional(int index)
|
||||||
{
|
{
|
||||||
CraftItem craftItem = CraftItems.GetAt(index);
|
CraftItems[index].ForceNonExceptional = true;
|
||||||
craftItem.ForceNonExceptional = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSubRes(Type type, string name)
|
public void SetSubRes(Type type, string name)
|
||||||
|
|
|
||||||
|
|
@ -54,11 +54,11 @@ namespace Server.Engines.Craft
|
||||||
foreach (KeyValuePair<int, Recipe> kvp in Recipes)
|
foreach (KeyValuePair<int, Recipe> kvp in Recipes)
|
||||||
mobile.AcquireRecipe(kvp.Key);
|
mobile.AcquireRecipe(kvp.Key);
|
||||||
|
|
||||||
m.SendMessage("You teach them all of the recipes.");
|
from.SendMessage("You teach them all of the recipes.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m.SendMessage("That is not a player!");
|
from.SendMessage("That is not a player!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -70,17 +70,17 @@ namespace Server.Engines.Craft
|
||||||
Mobile m = e.Mobile;
|
Mobile m = e.Mobile;
|
||||||
m.SendMessage("Target a player to have them forget all of the recipes they've learned.");
|
m.SendMessage("Target a player to have them forget all of the recipes they've learned.");
|
||||||
|
|
||||||
m.BeginTarget(-1, false, TargetFlags.None, delegate(Mobile from, object targeted)
|
m.BeginTarget(-1, false, TargetFlags.None, (from, targeted) =>
|
||||||
{
|
{
|
||||||
if (targeted is PlayerMobile mobile)
|
if (targeted is PlayerMobile mobile)
|
||||||
{
|
{
|
||||||
mobile.ResetRecipes();
|
mobile.ResetRecipes();
|
||||||
|
|
||||||
m.SendMessage("They forget all their recipes.");
|
from.SendMessage("They forget all their recipes.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m.SendMessage("That is not a player!");
|
from.SendMessage("That is not a player!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Server.Engines.Craft
|
||||||
NoSkill
|
NoSkill
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Resmelt
|
public static class Resmelt
|
||||||
{
|
{
|
||||||
public static void Do(Mobile from, CraftSystem craftSystem, BaseTool tool)
|
public static void Do(Mobile from, CraftSystem craftSystem, BaseTool tool)
|
||||||
{
|
{
|
||||||
|
|
@ -61,7 +61,7 @@ namespace Server.Engines.Craft
|
||||||
if (craftItem == null || craftItem.Resources.Count == 0)
|
if (craftItem == null || craftItem.Resources.Count == 0)
|
||||||
return SmeltResult.Invalid;
|
return SmeltResult.Invalid;
|
||||||
|
|
||||||
CraftRes craftResource = craftItem.Resources.GetAt(0);
|
CraftRes craftResource = craftItem.Resources[0];
|
||||||
|
|
||||||
if (craftResource.Amount < 2)
|
if (craftResource.Amount < 2)
|
||||||
return SmeltResult.Invalid; // Not enough metal to resmelt
|
return SmeltResult.Invalid; // Not enough metal to resmelt
|
||||||
|
|
@ -85,9 +85,9 @@ namespace Server.Engines.Craft
|
||||||
Type resourceType = info.ResourceTypes[0];
|
Type resourceType = info.ResourceTypes[0];
|
||||||
Item ingot = (Item)ActivatorUtil.CreateInstance(resourceType);
|
Item ingot = (Item)ActivatorUtil.CreateInstance(resourceType);
|
||||||
|
|
||||||
if (item is DragonBardingDeed || (item is BaseArmor armor && armor.PlayerConstructed) ||
|
if (item is DragonBardingDeed || item is BaseArmor armor && armor.PlayerConstructed ||
|
||||||
(item is BaseWeapon weapon && weapon.PlayerConstructed) ||
|
item is BaseWeapon weapon && weapon.PlayerConstructed ||
|
||||||
(item is BaseClothing clothing && clothing.PlayerConstructed))
|
item is BaseClothing clothing && clothing.PlayerConstructed)
|
||||||
ingot.Amount = craftResource.Amount / 2;
|
ingot.Amount = craftResource.Amount / 2;
|
||||||
else
|
else
|
||||||
ingot.Amount = 1;
|
ingot.Amount = 1;
|
||||||
|
|
@ -144,7 +144,6 @@ namespace Server.Engines.Craft
|
||||||
else if (targeted is DragonBardingDeed deed)
|
else if (targeted is DragonBardingDeed deed)
|
||||||
{
|
{
|
||||||
result = Resmelt(from, deed, deed.Resource);
|
result = Resmelt(from, deed, deed.Resource);
|
||||||
isStoreBought = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message = result switch
|
message = result switch
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ namespace Server.Engines.Craft
|
||||||
{
|
{
|
||||||
if (tool?.Deleted != false || tool.UsesRemaining < 0)
|
if (tool?.Deleted != false || tool.UsesRemaining < 0)
|
||||||
return 1044038; // You have worn out your tool!
|
return 1044038; // You have worn out your tool!
|
||||||
|
|
||||||
if (!BaseTool.CheckAccessible(tool, from))
|
if (!BaseTool.CheckAccessible(tool, from))
|
||||||
return 1044263; // The tool must be on your person to use.
|
return 1044263; // The tool must be on your person to use.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ namespace Server.Engines.Craft
|
||||||
{
|
{
|
||||||
if (tool?.Deleted != false || tool.UsesRemaining < 0)
|
if (tool?.Deleted != false || tool.UsesRemaining < 0)
|
||||||
return 1044038; // You have worn out your tool!
|
return 1044038; // You have worn out your tool!
|
||||||
|
|
||||||
if (!BaseTool.CheckAccessible(tool, from))
|
if (!BaseTool.CheckAccessible(tool, from))
|
||||||
return 1044263; // The tool must be on your person to use.
|
return 1044263; // The tool must be on your person to use.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Server.Ethics.Evil;
|
using Server.Ethics.Evil;
|
||||||
using Server.Ethics.Hero;
|
using Server.Ethics.Hero;
|
||||||
|
|
@ -203,7 +202,7 @@ namespace Server.Ethics
|
||||||
Player pl = new Player(this, reader);
|
Player pl = new Player(this, reader);
|
||||||
|
|
||||||
if (pl.Mobile != null)
|
if (pl.Mobile != null)
|
||||||
Timer.DelayCall(TimeSpan.Zero, pl.CheckAttach);
|
Timer.DelayCall(pl.CheckAttach);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -423,12 +423,7 @@ namespace Server.Factions
|
||||||
int factorKillPts = 100 + kp * 2;
|
int factorKillPts = 100 + kp * 2;
|
||||||
int factorGameTime = 50 + (int)(gameTime.Ticks * 100 / TimeSpan.TicksPerDay);
|
int factorGameTime = 50 + (int)(gameTime.Ticks * 100 / TimeSpan.TicksPerDay);
|
||||||
|
|
||||||
int totalFactor = factorSkills * factorKillPts * Math.Max(factorGameTime, 100) / 10000;
|
int totalFactor = Math.Clamp(factorSkills * factorKillPts * Math.Max(factorGameTime, 100) / 10000, 0, 100);
|
||||||
|
|
||||||
if (totalFactor > 100)
|
|
||||||
totalFactor = 100;
|
|
||||||
else if (totalFactor < 0)
|
|
||||||
totalFactor = 0;
|
|
||||||
|
|
||||||
return new object[] { From, Address, Time, totalFactor };
|
return new object[] { From, Address, Time, totalFactor };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1169,9 +1169,11 @@ namespace Server.Factions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.m_Timer = Timer.DelayCall(SkillLossPeriod, () => ClearSkillLoss(mob));
|
context.m_Timer = Timer.DelayCall(SkillLossPeriod, ClearSkillLoss_Event, mob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ClearSkillLoss_Event(Mobile mob) => ClearSkillLoss(mob);
|
||||||
|
|
||||||
public static bool ClearSkillLoss(Mobile mob)
|
public static bool ClearSkillLoss(Mobile mob)
|
||||||
{
|
{
|
||||||
if (!m_SkillLoss.TryGetValue(mob, out SkillLossContext context))
|
if (!m_SkillLoss.TryGetValue(mob, out SkillLossContext context))
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ namespace Server.Factions
|
||||||
{
|
{
|
||||||
FactionItem factionItem = new FactionItem(reader, m_Faction);
|
FactionItem factionItem = new FactionItem(reader, m_Faction);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, factionItem.CheckAttach); // sandbox attachment
|
Timer.DelayCall(factionItem.CheckAttach); // sandbox attachment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ namespace Server.Factions
|
||||||
PlayerState pl = PlayerState.Find(from);
|
PlayerState pl = PlayerState.Find(from);
|
||||||
|
|
||||||
if (pl != null)
|
if (pl != null)
|
||||||
Timer.DelayCall(TimeSpan.Zero, ShowScore_Sandbox, pl);
|
Timer.DelayCall(ShowScore_Sandbox, pl);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,75 +22,78 @@ namespace Server
|
||||||
|
|
||||||
public override bool Use(Mobile user)
|
public override bool Use(Mobile user)
|
||||||
{
|
{
|
||||||
if (Movable)
|
if (!Movable) return false;
|
||||||
user.BeginTarget(12, true, TargetFlags.None, (from, obj) =>
|
|
||||||
{
|
|
||||||
if (Movable && !Deleted)
|
|
||||||
if (obj is IPoint3D pt)
|
|
||||||
{
|
|
||||||
SpellHelper.GetSurfaceTop(ref pt);
|
|
||||||
|
|
||||||
Point3D origin = new Point3D(pt);
|
user.BeginTarget(12, true, TargetFlags.None, (from, obj, stormsEye) =>
|
||||||
Map facet = from.Map;
|
{
|
||||||
|
if (!stormsEye.Movable || stormsEye.Deleted || !(obj is IPoint3D pt)) return;
|
||||||
|
|
||||||
if (facet?.CanFit(pt.X, pt.Y, pt.Z, 16, false, false) != true)
|
SpellHelper.GetSurfaceTop(ref pt);
|
||||||
return;
|
|
||||||
|
|
||||||
Movable = false;
|
Point3D origin = new Point3D(pt);
|
||||||
|
Map facet = from.Map;
|
||||||
|
|
||||||
Effects.SendMovingEffect(
|
if (facet?.CanFit(pt.X, pt.Y, pt.Z, 16, false, false) != true)
|
||||||
from, new Entity(Serial.Zero, origin, facet),
|
return;
|
||||||
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1);
|
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(0.5), () =>
|
stormsEye.Movable = false;
|
||||||
{
|
|
||||||
Delete();
|
|
||||||
|
|
||||||
Effects.PlaySound(origin, facet, 530);
|
Effects.SendMovingEffect(
|
||||||
Effects.PlaySound(origin, facet, 263);
|
from, new Entity(Serial.Zero, origin, facet),
|
||||||
|
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1);
|
||||||
|
|
||||||
Effects.SendLocationEffect(
|
Timer.DelayCall(TimeSpan.FromSeconds(0.5), OnDelay, from, stormsEye, origin, facet);
|
||||||
origin, facet,
|
}, this);
|
||||||
14284, 96, 1, 0, 2);
|
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), () =>
|
|
||||||
{
|
|
||||||
List<Mobile> targets = facet.GetMobilesInRange(origin, 12).Where(mob =>
|
|
||||||
from.CanBeHarmful(mob, false) && mob.InLOS(new Point3D(origin, origin.Z + 1)) &&
|
|
||||||
Faction.Find(mob) != null).ToList();
|
|
||||||
|
|
||||||
foreach (Mobile mob in targets)
|
|
||||||
{
|
|
||||||
int damage = mob.Hits * 6 / 10;
|
|
||||||
|
|
||||||
if (!mob.Player && damage < 10)
|
|
||||||
damage = 10;
|
|
||||||
else if (damage > 75)
|
|
||||||
damage = 75;
|
|
||||||
|
|
||||||
Effects.SendMovingEffect(
|
|
||||||
new Entity(Serial.Zero, new Point3D(origin, origin.Z + 4), facet), mob,
|
|
||||||
14068, 1, 32, false, false, 1111, 2);
|
|
||||||
|
|
||||||
from.DoHarmful(mob);
|
|
||||||
|
|
||||||
SpellHelper.Damage(TimeSpan.FromSeconds(0.50), mob, from, damage / 3.0, 0, 0, 0, 0,
|
|
||||||
100);
|
|
||||||
SpellHelper.Damage(TimeSpan.FromSeconds(0.70), mob, from, damage / 3.0, 0, 0, 0, 0,
|
|
||||||
100);
|
|
||||||
SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3.0, 0, 0, 0, 0,
|
|
||||||
100);
|
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(0.50), mob.PlaySound, 0x1FB);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void OnDelay(Mobile from, StormsEye stormsEye, Point3D origin, Map facet)
|
||||||
|
{
|
||||||
|
stormsEye.Delete();
|
||||||
|
|
||||||
|
Effects.PlaySound(origin, facet, 530);
|
||||||
|
Effects.PlaySound(origin, facet, 263);
|
||||||
|
|
||||||
|
Effects.SendLocationEffect(
|
||||||
|
origin, facet,
|
||||||
|
14284, 96, 1, 0, 2);
|
||||||
|
|
||||||
|
Timer.DelayCall(TimeSpan.FromSeconds(1.0), OnHit, from, origin, facet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnHit(Mobile from, Point3D origin, Map facet)
|
||||||
|
{
|
||||||
|
List<Mobile> targets = facet.GetMobilesInRange(origin, 12).Where(mob =>
|
||||||
|
from.CanBeHarmful(mob, false) && mob.InLOS(new Point3D(origin, origin.Z + 1)) &&
|
||||||
|
Faction.Find(mob) != null).ToList();
|
||||||
|
|
||||||
|
foreach (Mobile mob in targets)
|
||||||
|
{
|
||||||
|
int damage = mob.Hits * 6 / 10;
|
||||||
|
|
||||||
|
if (!mob.Player && damage < 10)
|
||||||
|
damage = 10;
|
||||||
|
else if (damage > 75)
|
||||||
|
damage = 75;
|
||||||
|
|
||||||
|
Effects.SendMovingEffect(
|
||||||
|
new Entity(Serial.Zero, new Point3D(origin, origin.Z + 4), facet), mob,
|
||||||
|
14068, 1, 32, false, false, 1111, 2);
|
||||||
|
|
||||||
|
from.DoHarmful(mob);
|
||||||
|
|
||||||
|
SpellHelper.Damage(TimeSpan.FromSeconds(0.50), mob, from, damage / 3.0, 0, 0, 0, 0,
|
||||||
|
100);
|
||||||
|
SpellHelper.Damage(TimeSpan.FromSeconds(0.70), mob, from, damage / 3.0, 0, 0, 0, 0,
|
||||||
|
100);
|
||||||
|
SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3.0, 0, 0, 0, 0,
|
||||||
|
100);
|
||||||
|
|
||||||
|
Timer.DelayCall(TimeSpan.FromSeconds(0.50), mob.PlaySound, 0x1FB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
public override void Serialize(IGenericWriter writer)
|
||||||
{
|
{
|
||||||
base.Serialize(writer);
|
base.Serialize(writer);
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ namespace Server.Factions
|
||||||
|
|
||||||
if (TimeOfPlacement + decayPeriod < DateTime.UtcNow)
|
if (TimeOfPlacement + decayPeriod < DateTime.UtcNow)
|
||||||
{
|
{
|
||||||
Timer.DelayCall(TimeSpan.Zero, Delete);
|
Timer.DelayCall(Delete);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@ namespace Server.Factions
|
||||||
m_Town = Town.ReadReference(reader);
|
m_Town = Town.ReadReference(reader);
|
||||||
Orders = new Orders(this, reader);
|
Orders = new Orders(this, reader);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, Register);
|
Timer.DelayCall(Register);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ namespace Server.Items
|
||||||
|
|
||||||
int version = reader.ReadEncodedInt();
|
int version = reader.ReadEncodedInt();
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, Refresh);
|
Timer.DelayCall(Refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ namespace Server.Engines.Quests
|
||||||
|
|
||||||
--Charges;
|
--Charges;
|
||||||
|
|
||||||
m_PlayTimer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), () => PlayTimer_Callback(from));
|
m_PlayTimer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), PlayTimer_Callback, from);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ namespace Server.Engines.Quests
|
||||||
|
|
||||||
From.SendGump(new QuestObjectivesGump(Objectives));
|
From.SendGump(new QuestObjectivesGump(Objectives));
|
||||||
|
|
||||||
QuestObjective last = Objectives[Objectives.Count - 1];
|
QuestObjective last = Objectives[^1];
|
||||||
|
|
||||||
if (last.Info != null)
|
if (last.Info != null)
|
||||||
From.SendGump(new QuestItemInfoGump(last.Info));
|
From.SendGump(new QuestItemInfoGump(last.Info));
|
||||||
|
|
@ -276,7 +276,7 @@ namespace Server.Engines.Quests
|
||||||
|
|
||||||
From.SendGump(new QuestConversationsGump(Conversations));
|
From.SendGump(new QuestConversationsGump(Conversations));
|
||||||
|
|
||||||
QuestConversation last = Conversations[Conversations.Count - 1];
|
QuestConversation last = Conversations[^1];
|
||||||
|
|
||||||
if (last.Info != null)
|
if (last.Info != null)
|
||||||
From.SendGump(new QuestItemInfoGump(last.Info));
|
From.SendGump(new QuestItemInfoGump(last.Info));
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ namespace Server.Engines.Quests.Samurai
|
||||||
|
|
||||||
int version = reader.ReadEncodedInt();
|
int version = reader.ReadEncodedInt();
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, GenerateTreasure);
|
Timer.DelayCall(GenerateTreasure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Server.Engines.Quests.Doom
|
||||||
|
|
||||||
Effects.PlaySound(GetWorldLocation(), Map, 0x100);
|
Effects.PlaySound(GetWorldLocation(), Map, 0x100);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(8.0), () => EndSummon(from));
|
Timer.DelayCall(TimeSpan.FromSeconds(8.0), EndSummon, from);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace Server.Engines.Quests.Hag
|
||||||
// * You see a strange imp stealing a scrap of paper from the bloodied corpse *
|
// * You see a strange imp stealing a scrap of paper from the bloodied corpse *
|
||||||
Corpse.SendLocalizedMessageTo(player, 1055049);
|
Corpse.SendLocalizedMessageTo(player, 1055049);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(3.0), () => DeleteImp(imp));
|
Timer.DelayCall(TimeSpan.FromSeconds(3.0), DeleteImp, imp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteImp(Mobile m)
|
private void DeleteImp(Mobile m)
|
||||||
|
|
@ -212,7 +212,7 @@ namespace Server.Engines.Quests.Hag
|
||||||
|
|
||||||
imp.Direction = imp.GetDirectionTo(from);
|
imp.Direction = imp.GetDirectionTo(from);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(3.0), () => DeleteImp(imp));
|
Timer.DelayCall(TimeSpan.FromSeconds(3.0), DeleteImp, imp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteImp(object imp)
|
private void DeleteImp(object imp)
|
||||||
|
|
@ -266,7 +266,7 @@ namespace Server.Engines.Quests.Hag
|
||||||
for (int i = 0; i < oldIngredients.Length; i++)
|
for (int i = 0; i < oldIngredients.Length; i++)
|
||||||
Ingredients[i] = oldIngredients[i];
|
Ingredients[i] = oldIngredients[i];
|
||||||
|
|
||||||
Ingredients[Ingredients.Length - 1] = IngredientInfo.RandomIngredient(oldIngredients);
|
Ingredients[^1] = IngredientInfo.RandomIngredient(oldIngredients);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -324,7 +324,7 @@ namespace Server.Engines.Quests.Hag
|
||||||
|
|
||||||
public Ingredient[] Ingredients { get; private set; }
|
public Ingredient[] Ingredients { get; private set; }
|
||||||
|
|
||||||
public Ingredient Ingredient => Ingredients[Ingredients.Length - 1];
|
public Ingredient Ingredient => Ingredients[^1];
|
||||||
public int Step => Ingredients.Length;
|
public int Step => Ingredients.Length;
|
||||||
public bool BlackheartMet { get; private set; }
|
public bool BlackheartMet { get; private set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ namespace Server.Mobiles
|
||||||
Frozen = true;
|
Frozen = true;
|
||||||
|
|
||||||
if (m_SculptedBy == null || Map == Map.Internal) // Remove preview statues
|
if (m_SculptedBy == null || Map == Map.Internal) // Remove preview statues
|
||||||
Timer.DelayCall(TimeSpan.Zero, Delete);
|
Timer.DelayCall(Delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sculpt(Mobile by)
|
public void Sculpt(Mobile by)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using Server.Gumps;
|
using Server.Gumps;
|
||||||
using Server.Mobiles;
|
using Server.Mobiles;
|
||||||
using Server.Multis;
|
using Server.Multis;
|
||||||
|
|
@ -86,7 +85,8 @@ namespace Server.Items
|
||||||
|
|
||||||
m_Statue = reader.ReadMobile() as CharacterStatue;
|
m_Statue = reader.ReadMobile() as CharacterStatue;
|
||||||
|
|
||||||
if (m_Statue?.SculptedBy == null || Map == Map.Internal) Timer.DelayCall(TimeSpan.Zero, Delete);
|
if (m_Statue?.SculptedBy == null || Map == Map.Internal)
|
||||||
|
Timer.DelayCall(Delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InvalidateHue()
|
public void InvalidateHue()
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
|
||||||
namespace Server.Gumps
|
namespace Server.Gumps
|
||||||
|
|
@ -107,12 +108,7 @@ namespace Server.Gumps
|
||||||
int x = BorderSize + OffsetSize;
|
int x = BorderSize + OffsetSize;
|
||||||
int y = BorderSize + OffsetSize;
|
int y = BorderSize + OffsetSize;
|
||||||
|
|
||||||
int count = node.Categories.Length + node.Locations.Length - page * EntryCount;
|
int count = Math.Clamp(node.Categories.Length + node.Locations.Length - page * EntryCount, 0, EntryCount);
|
||||||
|
|
||||||
if (count < 0)
|
|
||||||
count = 0;
|
|
||||||
else if (count > EntryCount)
|
|
||||||
count = EntryCount;
|
|
||||||
|
|
||||||
int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1);
|
int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ namespace Server.Guilds
|
||||||
}
|
}
|
||||||
|
|
||||||
m_List.Sort(m_Comparer);
|
m_List.Sort(m_Comparer);
|
||||||
m_StartNumber = Math.Max(Math.Min(m_StartNumber, m_List.Count - 1), 0);
|
m_StartNumber = Math.Clamp(m_StartNumber, 0, m_List.Count - 1);
|
||||||
|
|
||||||
AddBackground(130, 75, 385, 30, 0xBB8);
|
AddBackground(130, 75, 385, 30, 0xBB8);
|
||||||
AddTextEntry(135, 80, 375, 30, 0x481, 1, m_Filter);
|
AddTextEntry(135, 80, 375, 30, 0x481, 1, m_Filter);
|
||||||
|
|
|
||||||
|
|
@ -83,11 +83,9 @@ namespace Server.Guilds
|
||||||
TextRelay tWarLength = info.GetTextEntry(10);
|
TextRelay tWarLength = info.GetTextEntry(10);
|
||||||
|
|
||||||
int maxKills = tKills == null
|
int maxKills = tKills == null
|
||||||
? 0
|
? 0 : Math.Clamp(Utility.ToInt32(info.GetTextEntry(11).Text), 0, 0xFFFF);
|
||||||
: Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(11).Text), 0xFFFF), 0);
|
TimeSpan warLength = TimeSpan.FromHours(tWarLength == null ? 0
|
||||||
TimeSpan warLength = TimeSpan.FromHours(tWarLength == null
|
: Math.Clamp(Utility.ToInt32(info.GetTextEntry(10).Text), 0, 0xFFFF));
|
||||||
? 0
|
|
||||||
: Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(10).Text), 0xFFFF), 0));
|
|
||||||
|
|
||||||
if (war != null)
|
if (war != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ namespace Server.Gumps
|
||||||
ArtID = art;
|
ArtID = art;
|
||||||
BodyID = body;
|
BodyID = body;
|
||||||
LocNumber = locNum;
|
LocNumber = locNum;
|
||||||
this.X = x;
|
X = x;
|
||||||
this.Y = y;
|
Y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ArtID { get; }
|
public int ArtID { get; }
|
||||||
|
|
|
||||||
|
|
@ -180,12 +180,7 @@ namespace Server.Gumps
|
||||||
{
|
{
|
||||||
m_Page = page;
|
m_Page = page;
|
||||||
|
|
||||||
int count = m_List.Count - page * EntryCount;
|
int count = Math.Clamp(m_List.Count - page * EntryCount, 0, EntryCount);
|
||||||
|
|
||||||
if (count < 0)
|
|
||||||
count = 0;
|
|
||||||
else if (count > EntryCount)
|
|
||||||
count = EntryCount;
|
|
||||||
|
|
||||||
int lastIndex = page * EntryCount + count - 1;
|
int lastIndex = page * EntryCount + count - 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ namespace Server.Gumps
|
||||||
if (Core.SE)
|
if (Core.SE)
|
||||||
{
|
{
|
||||||
from.RecentlyReported.Add(killer);
|
from.RecentlyReported.Add(killer);
|
||||||
Timer.DelayCall(TimeSpan.FromMinutes(10), () => ReportedListExpiry_Callback(from, killer));
|
Timer.DelayCall(TimeSpan.FromMinutes(10), ReportedListExpiry_Callback, from, killer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (killer is PlayerMobile pk)
|
if (killer is PlayerMobile pk)
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ namespace Server.Engines.Events
|
||||||
{
|
{
|
||||||
DateTime now = DateTime.UtcNow;
|
DateTime now = DateTime.UtcNow;
|
||||||
|
|
||||||
if (DateTime.UtcNow >= HolidaySettings.StartHalloween && DateTime.UtcNow <= HolidaySettings.FinishHalloween)
|
if (now >= HolidaySettings.StartHalloween && now <= HolidaySettings.FinishHalloween)
|
||||||
m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromMinutes(.50), 0, PumpkinPatchSpawnerCallback);
|
m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(30), 0, PumpkinPatchSpawnerCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void PumpkinPatchSpawnerCallback()
|
protected static void PumpkinPatchSpawnerCallback()
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Server.Items
|
||||||
public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes,
|
public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes,
|
||||||
BaseTool tool, CraftItem craftItem, int resHue)
|
BaseTool tool, CraftItem craftItem, int resHue)
|
||||||
{
|
{
|
||||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
Type resourceType = typeRes ?? craftItem.Resources[0].ItemType;
|
||||||
|
|
||||||
Resource = CraftResources.GetFromType(resourceType);
|
Resource = CraftResources.GetFromType(resourceType);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Server.Items
|
namespace Server.Items
|
||||||
{
|
{
|
||||||
public class JackOLantern : BaseAddon
|
public class JackOLantern : BaseAddon
|
||||||
|
|
@ -15,18 +13,18 @@ namespace Server.Items
|
||||||
{
|
{
|
||||||
AddComponent(new AddonComponent(5703), 0, 0, +0);
|
AddComponent(new AddonComponent(5703), 0, 0, +0);
|
||||||
|
|
||||||
int hue = 1161;
|
const int hue = 1161;
|
||||||
// ( 1 > Utility.Random( 5 ) ? 2118 : 1161 );
|
// ( 1 > Utility.Random( 5 ) ? 2118 : 1161 );
|
||||||
|
|
||||||
if (!south)
|
if (!south)
|
||||||
{
|
{
|
||||||
AddComponent(GetComponent(3178, 0000), 0, 0, -1);
|
AddComponent(GetComponent(3178, 0), 0, 0, -1);
|
||||||
AddComponent(GetComponent(3883, hue), 0, 0, +1);
|
AddComponent(GetComponent(3883, hue), 0, 0, +1);
|
||||||
AddComponent(GetComponent(3862, hue), 0, 0, +0);
|
AddComponent(GetComponent(3862, hue), 0, 0, +0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddComponent(GetComponent(3179, 0000), 0, 0, +0);
|
AddComponent(GetComponent(3179, 0), 0, 0, +0);
|
||||||
AddComponent(GetComponent(3885, hue), 0, 0, -1);
|
AddComponent(GetComponent(3885, hue), 0, 0, -1);
|
||||||
AddComponent(GetComponent(3871, hue), 0, 0, +0);
|
AddComponent(GetComponent(3871, hue), 0, 0, +0);
|
||||||
}
|
}
|
||||||
|
|
@ -39,15 +37,12 @@ namespace Server.Items
|
||||||
|
|
||||||
public override bool ShareHue => false;
|
public override bool ShareHue => false;
|
||||||
|
|
||||||
private AddonComponent GetComponent(int itemID, int hue)
|
private static AddonComponent GetComponent(int itemID, int hue) =>
|
||||||
{
|
new AddonComponent(itemID)
|
||||||
AddonComponent ac = new AddonComponent(itemID);
|
{
|
||||||
|
Hue = hue,
|
||||||
ac.Hue = hue;
|
Name = "jack-o-lantern"
|
||||||
ac.Name = "jack-o-lantern";
|
};
|
||||||
|
|
||||||
return ac;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
public override void Serialize(IGenericWriter writer)
|
||||||
{
|
{
|
||||||
|
|
@ -62,21 +57,31 @@ namespace Server.Items
|
||||||
|
|
||||||
int version = reader.ReadByte();
|
int version = reader.ReadByte();
|
||||||
|
|
||||||
if (version == 0)
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, () =>
|
|
||||||
{
|
|
||||||
for (int i = 0; i < Components.Count; ++i)
|
|
||||||
if (Components[i] is AddonComponent ac && ac.Hue == 2118)
|
|
||||||
ac.Hue = 1161;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (version <= 1)
|
if (version <= 1)
|
||||||
Timer.DelayCall(TimeSpan.Zero, () =>
|
Timer.DelayCall(Fix, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Fix(int version)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Components.Count; ++i)
|
||||||
|
{
|
||||||
|
var ac = Components[i];
|
||||||
|
switch (version)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Components.Count; ++i)
|
case 1:
|
||||||
if (Components[i] is AddonComponent ac)
|
{
|
||||||
ac.Name = "jack-o-lantern";
|
ac.Name = "jack-o-lantern";
|
||||||
});
|
goto case 0;
|
||||||
|
}
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (ac.Hue == 2118)
|
||||||
|
ac.Hue = 1161;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace Server.Items
|
||||||
SendLocalizedMessageTo(from, 500803); // You feel as though you've slept for days!
|
SendLocalizedMessageTo(from, 500803); // You feel as though you've slept for days!
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromHours(2.0), () => ReleaseUseLock_Callback(from, random));
|
Timer.DelayCall(TimeSpan.FromHours(2.0), ReleaseUseLock_Callback, from, random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -633,7 +633,7 @@ namespace Server.Items
|
||||||
fish = new StrippedFlakeFish();
|
fish = new StrippedFlakeFish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5:
|
default: // 5
|
||||||
{
|
{
|
||||||
message = 1074365; // A new creature has hatched overnight in the tank.
|
message = 1074365; // A new creature has hatched overnight in the tank.
|
||||||
fish = new StrippedSosarianSwill();
|
fish = new StrippedSosarianSwill();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Server.Items
|
namespace Server.Items
|
||||||
{
|
{
|
||||||
public enum WaterState
|
public enum WaterState
|
||||||
|
|
@ -27,16 +29,7 @@ namespace Server.Items
|
||||||
public int State
|
public int State
|
||||||
{
|
{
|
||||||
get => m_State;
|
get => m_State;
|
||||||
set
|
set => m_State = Math.Clamp(value, 0, 4);
|
||||||
{
|
|
||||||
m_State = value;
|
|
||||||
|
|
||||||
if (m_State < 0)
|
|
||||||
m_State = 0;
|
|
||||||
|
|
||||||
if (m_State > 4)
|
|
||||||
m_State = 4;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
|
|
|
||||||
|
|
@ -479,7 +479,7 @@ namespace Server.Items
|
||||||
if (makersMark)
|
if (makersMark)
|
||||||
Crafter = from;
|
Crafter = from;
|
||||||
|
|
||||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
Type resourceType = typeRes ?? craftItem.Resources[0].ItemType;
|
||||||
|
|
||||||
Resource = CraftResources.GetFromType(resourceType);
|
Resource = CraftResources.GetFromType(resourceType);
|
||||||
PlayerConstructed = true;
|
PlayerConstructed = true;
|
||||||
|
|
@ -547,12 +547,12 @@ namespace Server.Items
|
||||||
|
|
||||||
CraftItem item = system.CraftItems.SearchFor(GetType());
|
CraftItem item = system.CraftItems.SearchFor(GetType());
|
||||||
|
|
||||||
if (item?.Resources.Count == 1 && item.Resources.GetAt(0).Amount >= 2)
|
if (item?.Resources.Count == 1 && item.Resources[0].Amount >= 2)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Item res = (Item)ActivatorUtil.CreateInstance(CraftResources.GetInfo(m_Resource).ResourceTypes[0]);
|
Item res = (Item)ActivatorUtil.CreateInstance(CraftResources.GetInfo(m_Resource).ResourceTypes[0]);
|
||||||
|
|
||||||
ScissorHelper(from, res, PlayerConstructed ? item.Resources.GetAt(0).Amount / 2 : 1);
|
ScissorHelper(from, res, PlayerConstructed ? item.Resources[0].Amount / 2 : 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
@ -623,9 +623,8 @@ namespace Server.Items
|
||||||
double halfar = ArmorRating / 2.0;
|
double halfar = ArmorRating / 2.0;
|
||||||
int absorbed = (int)(halfar + halfar * Utility.RandomDouble());
|
int absorbed = (int)(halfar + halfar * Utility.RandomDouble());
|
||||||
|
|
||||||
damageTaken -= absorbed;
|
// Don't go below zero
|
||||||
if (damageTaken < 0)
|
damageTaken = Math.Min(absorbed, damageTaken);
|
||||||
damageTaken = 0;
|
|
||||||
|
|
||||||
if (absorbed < 2)
|
if (absorbed < 2)
|
||||||
absorbed = 2;
|
absorbed = 2;
|
||||||
|
|
@ -1584,7 +1583,7 @@ namespace Server.Items
|
||||||
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
||||||
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
|
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
|
||||||
|
|
||||||
this.AddResistanceProperties(list);
|
AddResistanceProperties(list);
|
||||||
|
|
||||||
if ((prop = GetDurabilityBonus()) > 0)
|
if ((prop = GetDurabilityBonus()) > 0)
|
||||||
list.Add(1060410, prop.ToString()); // durability ~1_val~%
|
list.Add(1060410, prop.ToString()); // durability ~1_val~%
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Server.Items
|
||||||
if (Deleted || !from.CanSee(this))
|
if (Deleted || !from.CanSee(this))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.ScissorHelper(from, new Bone(), Utility.RandomMinMax(10, 15));
|
ScissorHelper(from, new Bone(), Utility.RandomMinMax(10, 15));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Server.Items
|
||||||
if (Deleted || !from.CanSee(this))
|
if (Deleted || !from.CanSee(this))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.ScissorHelper(from, new Bone(), Utility.RandomMinMax(3, 5));
|
ScissorHelper(from, new Bone(), Utility.RandomMinMax(3, 5));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Server.Items
|
||||||
get => m_Level;
|
get => m_Level;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
m_Level = Math.Max(Math.Min(2, value), 0);
|
m_Level = Math.Clamp(value, 0, 2);
|
||||||
Attributes.BonusInt = 2 + m_Level;
|
Attributes.BonusInt = 2 + m_Level;
|
||||||
InvalidateProperties();
|
InvalidateProperties();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ namespace Server.Items
|
||||||
|
|
||||||
if (DefaultResource != CraftResource.None)
|
if (DefaultResource != CraftResource.None)
|
||||||
{
|
{
|
||||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
Type resourceType = typeRes ?? craftItem.Resources[0].ItemType;
|
||||||
|
|
||||||
Resource = CraftResources.GetFromType(resourceType);
|
Resource = CraftResources.GetFromType(resourceType);
|
||||||
}
|
}
|
||||||
|
|
@ -200,16 +200,16 @@ namespace Server.Items
|
||||||
|
|
||||||
CraftItem item = system.CraftItems.SearchFor(GetType());
|
CraftItem item = system.CraftItems.SearchFor(GetType());
|
||||||
|
|
||||||
if (item?.Resources.Count == 1 && item.Resources.GetAt(0).Amount >= 2)
|
if (item?.Resources.Count == 1 && item.Resources[0].Amount >= 2)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CraftResourceInfo info = CraftResources.GetInfo(m_Resource);
|
CraftResourceInfo info = CraftResources.GetInfo(m_Resource);
|
||||||
|
|
||||||
Type resourceType = info.ResourceTypes?[0] ?? item.Resources.GetAt(0).ItemType;
|
Type resourceType = info.ResourceTypes?[0] ?? item.Resources[0].ItemType;
|
||||||
|
|
||||||
Item res = (Item)ActivatorUtil.CreateInstance(resourceType);
|
Item res = (Item)ActivatorUtil.CreateInstance(resourceType);
|
||||||
|
|
||||||
ScissorHelper(from, res, PlayerConstructed ? item.Resources.GetAt(0).Amount / 2 : 1);
|
ScissorHelper(from, res, PlayerConstructed ? item.Resources[0].Amount / 2 : 1);
|
||||||
|
|
||||||
res.LootType = LootType.Regular;
|
res.LootType = LootType.Regular;
|
||||||
|
|
||||||
|
|
@ -262,12 +262,10 @@ namespace Server.Items
|
||||||
|
|
||||||
public virtual int OnHit(BaseWeapon weapon, int damageTaken)
|
public virtual int OnHit(BaseWeapon weapon, int damageTaken)
|
||||||
{
|
{
|
||||||
int Absorbed = Utility.RandomMinMax(1, 4);
|
int absorbed = Utility.RandomMinMax(1, 4);
|
||||||
|
|
||||||
damageTaken -= Absorbed;
|
// Don't go below zero
|
||||||
|
damageTaken = Math.Min(absorbed, damageTaken);
|
||||||
if (damageTaken < 0)
|
|
||||||
damageTaken = 0;
|
|
||||||
|
|
||||||
if (Utility.Random(100) < 25) // 25% chance to lower durability
|
if (Utility.Random(100) < 25) // 25% chance to lower durability
|
||||||
{
|
{
|
||||||
|
|
@ -280,7 +278,7 @@ namespace Server.Items
|
||||||
int wear;
|
int wear;
|
||||||
|
|
||||||
if (weapon.Type == WeaponType.Bashing)
|
if (weapon.Type == WeaponType.Bashing)
|
||||||
wear = Absorbed / 2;
|
wear = absorbed / 2;
|
||||||
else
|
else
|
||||||
wear = Utility.Random(2);
|
wear = Utility.Random(2);
|
||||||
|
|
||||||
|
|
@ -338,13 +336,8 @@ namespace Server.Items
|
||||||
InvalidateProperties();
|
InvalidateProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted)
|
public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) =>
|
||||||
{
|
Ethic.CheckTrade(from, to, newOwner, this) && base.AllowSecureTrade(from, to, newOwner, accepted);
|
||||||
if (!Ethic.CheckTrade(from, to, newOwner, this))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return base.AllowSecureTrade(from, to, newOwner, accepted);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanEquip(Mobile from)
|
public override bool CanEquip(Mobile from)
|
||||||
{
|
{
|
||||||
|
|
@ -406,14 +399,13 @@ namespace Server.Items
|
||||||
return AOS.Scale(v, 100 - GetLowerStatReq());
|
return AOS.Scale(v, 100 - GetLowerStatReq());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ComputeStatBonus(StatType type)
|
public int ComputeStatBonus(StatType type) =>
|
||||||
{
|
type switch
|
||||||
if (type == StatType.Str)
|
{
|
||||||
return BaseStrBonus + Attributes.BonusStr;
|
StatType.Str => BaseStrBonus + Attributes.BonusStr,
|
||||||
if (type == StatType.Dex)
|
StatType.Dex => BaseDexBonus + Attributes.BonusDex,
|
||||||
return BaseDexBonus + Attributes.BonusDex;
|
_ => BaseIntBonus + Attributes.BonusInt
|
||||||
return BaseIntBonus + Attributes.BonusInt;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void AddStatBonuses(Mobile parent)
|
public virtual void AddStatBonuses(Mobile parent)
|
||||||
{
|
{
|
||||||
|
|
@ -533,26 +525,19 @@ namespace Server.Items
|
||||||
clothing.ClothingAttributes = new AosArmorAttributes(newItem, ClothingAttributes);
|
clothing.ClothingAttributes = new AosArmorAttributes(newItem, ClothingAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool AllowEquippedCast(Mobile from)
|
public override bool AllowEquippedCast(Mobile from) => base.AllowEquippedCast(from) || Attributes.SpellChanneling != 0;
|
||||||
{
|
|
||||||
if (base.AllowEquippedCast(from))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return Attributes.SpellChanneling != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CheckPropertyConflict(Mobile m)
|
public override bool CheckPropertyConflict(Mobile m)
|
||||||
{
|
{
|
||||||
if (base.CheckPropertyConflict(m))
|
if (base.CheckPropertyConflict(m))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (Layer == Layer.Pants)
|
return Layer switch
|
||||||
return m.FindItemOnLayer(Layer.InnerLegs) != null;
|
{
|
||||||
|
Layer.Pants => m.FindItemOnLayer(Layer.InnerLegs) != null,
|
||||||
if (Layer == Layer.Shirt)
|
Layer.Shirt => m.FindItemOnLayer(Layer.InnerTorso) != null,
|
||||||
return m.FindItemOnLayer(Layer.InnerTorso) != null;
|
_ => false
|
||||||
|
};
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetNameString() => Name ?? $"#{LabelNumber}";
|
private string GetNameString() => Name ?? $"#{LabelNumber}";
|
||||||
|
|
@ -693,7 +678,7 @@ namespace Server.Items
|
||||||
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
||||||
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
|
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
|
||||||
|
|
||||||
this.AddResistanceProperties(list);
|
AddResistanceProperties(list);
|
||||||
|
|
||||||
if ((prop = ClothingAttributes.DurabilityBonus) > 0)
|
if ((prop = ClothingAttributes.DurabilityBonus) > 0)
|
||||||
list.Add(1060410, prop.ToString()); // durability ~1_val~%
|
list.Add(1060410, prop.ToString()); // durability ~1_val~%
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ namespace Server.Items
|
||||||
int version = reader.ReadEncodedInt();
|
int version = reader.ReadEncodedInt();
|
||||||
|
|
||||||
if (version == 0 && m_Content == null)
|
if (version == 0 && m_Content == null)
|
||||||
Timer.DelayCall(TimeSpan.Zero, AcquireContent);
|
Timer.DelayCall(AcquireContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Server.Items
|
||||||
if (craftItem == null || craftItem.Resources.Count == 0)
|
if (craftItem == null || craftItem.Resources.Count == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CraftRes craftResource = craftItem.Resources.GetAt(0);
|
CraftRes craftResource = craftItem.Resources[0];
|
||||||
|
|
||||||
if (craftResource.Amount < 2)
|
if (craftResource.Amount < 2)
|
||||||
return false; // Not enough metal to resmelt
|
return false; // Not enough metal to resmelt
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace Server.Items
|
||||||
if (makersMark)
|
if (makersMark)
|
||||||
Crafter = from;
|
Crafter = from;
|
||||||
|
|
||||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
Type resourceType = typeRes ?? craftItem.Resources[0].ItemType;
|
||||||
|
|
||||||
Resource = CraftResources.GetFromType(resourceType);
|
Resource = CraftResources.GetFromType(resourceType);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using Server.Factions;
|
using Server.Factions;
|
||||||
using Server.Guilds;
|
using Server.Guilds;
|
||||||
using Server.Gumps;
|
using Server.Gumps;
|
||||||
|
|
@ -143,7 +142,7 @@ namespace Server.Items
|
||||||
m_BeforeChangeover = true;
|
m_BeforeChangeover = true;
|
||||||
|
|
||||||
if (Guild.NewGuildSystem && m_BeforeChangeover)
|
if (Guild.NewGuildSystem && m_BeforeChangeover)
|
||||||
Timer.DelayCall(TimeSpan.Zero, AddToHouse);
|
Timer.DelayCall(AddToHouse);
|
||||||
|
|
||||||
if (!Guild.NewGuildSystem && Guild == null)
|
if (!Guild.NewGuildSystem && Guild == null)
|
||||||
Delete();
|
Delete();
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ namespace Server.Items
|
||||||
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
|
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
|
||||||
CraftItem craftItem, int resHue)
|
CraftItem craftItem, int resHue)
|
||||||
{
|
{
|
||||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
Type resourceType = typeRes ?? craftItem.Resources[0].ItemType;
|
||||||
|
|
||||||
Resource = CraftResources.GetFromType(resourceType);
|
Resource = CraftResources.GetFromType(resourceType);
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ namespace Server.Items
|
||||||
|
|
||||||
if (craftItem.Resources.Count > 1)
|
if (craftItem.Resources.Count > 1)
|
||||||
{
|
{
|
||||||
resourceType = craftItem.Resources.GetAt(1).ItemType;
|
resourceType = craftItem.Resources[1].ItemType;
|
||||||
|
|
||||||
if (resourceType == typeof(StarSapphire))
|
if (resourceType == typeof(StarSapphire))
|
||||||
GemType = GemType.StarSapphire;
|
GemType = GemType.StarSapphire;
|
||||||
|
|
@ -302,7 +302,7 @@ namespace Server.Items
|
||||||
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
||||||
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
|
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
|
||||||
|
|
||||||
this.AddResistanceProperties(list);
|
AddResistanceProperties(list);
|
||||||
|
|
||||||
if (m_HitPoints >= 0 && m_MaxHitPoints > 0)
|
if (m_HitPoints >= 0 && m_MaxHitPoints > 0)
|
||||||
list.Add(1060639, "{0}\t{1}", m_HitPoints, m_MaxHitPoints); // durability ~1_val~ / ~2_val~
|
list.Add(1060639, "{0}\t{1}", m_HitPoints, m_MaxHitPoints); // durability ~1_val~ / ~2_val~
|
||||||
|
|
|
||||||
|
|
@ -160,15 +160,8 @@ namespace Server.Items
|
||||||
|
|
||||||
public virtual void Validate(ref int x, ref int y)
|
public virtual void Validate(ref int x, ref int y)
|
||||||
{
|
{
|
||||||
if (x < 0)
|
x = Math.Clamp(x, 0, Width - 1);
|
||||||
x = 0;
|
y = Math.Clamp(y, 0, Height - 1);
|
||||||
else if (x >= Width)
|
|
||||||
x = Width - 1;
|
|
||||||
|
|
||||||
if (y < 0)
|
|
||||||
y = 0;
|
|
||||||
else if (y >= Height)
|
|
||||||
y = Height - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool ValidateEdit(Mobile from) => m_Editable && Validate(from);
|
public virtual bool ValidateEdit(Mobile from) => m_Editable && Validate(from);
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Server.Items
|
||||||
|
|
||||||
to.Damage(1);
|
to.Damage(1);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(2.0), () => from.EndAction<Bola>());
|
Timer.DelayCall(TimeSpan.FromSeconds(2.0), from.EndAction<Bola>);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool HasFreeHands(Mobile from)
|
private static bool HasFreeHands(Mobile from)
|
||||||
|
|
@ -191,7 +191,7 @@ namespace Server.Items
|
||||||
from.Animate(11, 5, 1, true, false, 0);
|
from.Animate(11, 5, 1, true, false, 0);
|
||||||
from.MovingEffect(to, 0x26AC, 10, 0, false, false);
|
from.MovingEffect(to, 0x26AC, 10, 0, false, false);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(0.5), () => FinishThrow(from, to));
|
Timer.DelayCall(TimeSpan.FromSeconds(0.5), FinishThrow, from, to);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -391,7 +391,7 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remainder == 0)
|
if (remainder == 0)
|
||||||
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[attackers.Count - 1]));
|
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[^1]));
|
||||||
else
|
else
|
||||||
m_Unstackables.Add(item);
|
m_Unstackables.Add(item);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,19 @@ namespace Server.Items
|
||||||
Effects.PlaySound(loc, map, 0x225);
|
Effects.PlaySound(loc, map, 0x225);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SummonCreatureToWorld(BaseCreature bc, Point3D spawnLoc, Map map)
|
||||||
|
{
|
||||||
|
bc.Home = Location;
|
||||||
|
bc.RangeHome = SpawnRange;
|
||||||
|
bc.FightMode = FightMode.Closest;
|
||||||
|
|
||||||
|
bc.MoveToWorld(spawnLoc, map);
|
||||||
|
|
||||||
|
DoEffect(spawnLoc, map);
|
||||||
|
|
||||||
|
bc.ForceReacquire();
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnDoubleClick(Mobile from)
|
public override void OnDoubleClick(Mobile from)
|
||||||
{
|
{
|
||||||
if (Utility.InRange(from.Location, Location, 2))
|
if (Utility.InRange(from.Location, Location, 2))
|
||||||
|
|
@ -146,18 +159,7 @@ namespace Server.Items
|
||||||
|
|
||||||
DoEffect(spawnLoc, map);
|
DoEffect(spawnLoc, map);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
|
Timer.DelayCall(TimeSpan.FromSeconds(1), SummonCreatureToWorld, bc, spawnLoc, map);
|
||||||
{
|
|
||||||
bc.Home = Location;
|
|
||||||
bc.RangeHome = SpawnRange;
|
|
||||||
bc.FightMode = FightMode.Closest;
|
|
||||||
|
|
||||||
bc.MoveToWorld(spawnLoc, map);
|
|
||||||
|
|
||||||
DoEffect(spawnLoc, map);
|
|
||||||
|
|
||||||
bc.ForceReacquire();
|
|
||||||
});
|
|
||||||
|
|
||||||
NextSpawn = DateTime.UtcNow + NextSpawnDelay;
|
NextSpawn = DateTime.UtcNow + NextSpawnDelay;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ namespace Server.Items
|
||||||
|
|
||||||
Effects.SendMovingEffect(from, to, ItemID, 7, 0, false, false, Hue);
|
Effects.SendMovingEffect(from, to, ItemID, 7, 0, false, false, Hue);
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), () => FirebombReposition_OnTick(p, Map));
|
Timer.DelayCall(TimeSpan.FromSeconds(1.0), FirebombReposition_OnTick, p, Map);
|
||||||
Internalize();
|
Internalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Server.Items
|
namespace Server.Items
|
||||||
|
|
@ -118,7 +117,7 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, Refresh);
|
Timer.DelayCall(Refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Server.Items
|
||||||
if (Deleted || !from.CanSee(this))
|
if (Deleted || !from.CanSee(this))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.ScissorHelper(from, new Bandage(), 1);
|
ScissorHelper(from, new Bandage(), 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,7 @@ namespace Server.Items
|
||||||
hues[n.X, n.Y] = NodeHue.Blue;
|
hues[n.X, n.Y] = NodeHue.Blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node lastNode = path[path.Length - 1];
|
Node lastNode = path[^1];
|
||||||
hues[lastNode.X, lastNode.Y] = NodeHue.Red;
|
hues[lastNode.X, lastNode.Y] = NodeHue.Red;
|
||||||
|
|
||||||
for (int i = 0; i < sideLength; i++)
|
for (int i = 0; i < sideLength; i++)
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@ namespace Server.Items
|
||||||
m.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, m_MessageNumber, null,
|
m.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, m_MessageNumber, null,
|
||||||
""));
|
""));
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), () => m.EndAction(this));
|
Timer.DelayCall(TimeSpan.FromSeconds(5.0), m.EndAction, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -105,10 +105,10 @@ namespace Server.Items
|
||||||
list[i].Broadcast(triggerer);
|
list[i].Broadcast(triggerer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer.DelayCall(TimeSpan.Zero, InternalCallback);
|
Timer.DelayCall(StopBroadcasting);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InternalCallback()
|
private void StopBroadcasting()
|
||||||
{
|
{
|
||||||
m_Broadcasting = false;
|
m_Broadcasting = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Server.Items
|
||||||
|
|
||||||
public void Carve(Mobile from, Item item)
|
public void Carve(Mobile from, Item item)
|
||||||
{
|
{
|
||||||
this.ScissorHelper(from, new RawFishSteak(), Math.Max(16, (int)Weight) / 4, false);
|
ScissorHelper(from, new RawFishSteak(), Math.Max(16, (int)Weight) / 4, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void GetProperties(ObjectPropertyList list)
|
public override void GetProperties(ObjectPropertyList list)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Server.Items
|
||||||
|
|
||||||
public void Carve(Mobile from, Item item)
|
public void Carve(Mobile from, Item item)
|
||||||
{
|
{
|
||||||
this.ScissorHelper(from, new RawFishSteak(), 4);
|
ScissorHelper(from, new RawFishSteak(), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
public override void Serialize(IGenericWriter writer)
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue