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 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; }
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Server.Diagnostics
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ namespace Server.Guilds
|
|||
|
||||
protected BaseGuild(uint id) // serialization ctor
|
||||
{
|
||||
this.Serial = id;
|
||||
List.Add(this.Serial, this);
|
||||
if (this.Serial + 1 > m_NextID)
|
||||
m_NextID = this.Serial + 1;
|
||||
Serial = id;
|
||||
List.Add(Serial, this);
|
||||
if (Serial + 1 > m_NextID)
|
||||
m_NextID = Serial + 1;
|
||||
m_SaveBuffer = new BufferWriter(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ namespace Server
|
|||
int MaxRange { get; }
|
||||
void OnBeforeSwing(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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2550,7 +2550,7 @@ namespace Server
|
|||
}
|
||||
|
||||
if (HeldBy != null)
|
||||
Timer.DelayCall(TimeSpan.Zero, FixHolding_Sandbox);
|
||||
Timer.DelayCall(FixHolding_Sandbox);
|
||||
|
||||
// if (version < 9)
|
||||
VerifyCompactInfo();
|
||||
|
|
@ -3070,18 +3070,12 @@ namespace Server
|
|||
if (checkTop == checkZ && !id.Surface)
|
||||
++checkTop;
|
||||
|
||||
var zStart = checkZ - z;
|
||||
var zEnd = checkTop - z;
|
||||
var zStart = Math.Max(checkZ - z, 0);
|
||||
var zEnd = Math.Min(checkTop - z, 19);
|
||||
|
||||
if (zStart >= 20 || zEnd < 0)
|
||||
continue;
|
||||
|
||||
if (zStart < 0)
|
||||
zStart = 0;
|
||||
|
||||
if (zEnd > 19)
|
||||
zEnd = 19;
|
||||
|
||||
var bitCount = zEnd - zStart;
|
||||
|
||||
m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart);
|
||||
|
|
@ -3098,18 +3092,12 @@ namespace Server
|
|||
if (checkTop == checkZ && !id.Surface)
|
||||
++checkTop;
|
||||
|
||||
var zStart = checkZ - z;
|
||||
var zEnd = checkTop - z;
|
||||
var zStart = Math.Max(checkZ - z, 0);
|
||||
var zEnd = Math.Min(checkTop - z, 19);
|
||||
|
||||
if (zStart >= 20 || zEnd < 0)
|
||||
continue;
|
||||
|
||||
if (zStart < 0)
|
||||
zStart = 0;
|
||||
|
||||
if (zEnd > 19)
|
||||
zEnd = 19;
|
||||
|
||||
var bitCount = zEnd - zStart;
|
||||
|
||||
m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
|
|
|||
|
|
@ -655,34 +655,14 @@ namespace Server
|
|||
|
||||
public void Bound(int x, int y, out int newX, out int newY)
|
||||
{
|
||||
if (x < 0)
|
||||
newX = 0;
|
||||
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;
|
||||
newX = Math.Clamp(x, 0, Width - 1);
|
||||
newY = Math.Clamp(y, 0, Height - 1);
|
||||
}
|
||||
|
||||
public Point2D Bound(Point2D p)
|
||||
{
|
||||
int x = p.m_X, y = p.m_Y;
|
||||
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x >= Width)
|
||||
x = Width - 1;
|
||||
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y >= Height)
|
||||
y = Height - 1;
|
||||
int x = Math.Clamp(p.m_X, 0, Width - 1);
|
||||
int y = Math.Clamp(p.m_Y, 0, Height - 1);
|
||||
|
||||
return new Point2D(x, y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1486,7 +1486,7 @@ namespace Server
|
|||
AddToBackpack(item.Items[j]);
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.Zero, item.Delete);
|
||||
Timer.DelayCall(item.Delete);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1811,10 +1811,7 @@ namespace Server
|
|||
|
||||
if (m_Kills != value)
|
||||
{
|
||||
m_Kills = value;
|
||||
|
||||
if (m_Kills < 0)
|
||||
m_Kills = 0;
|
||||
m_Kills = Math.Max(value, 0);
|
||||
|
||||
if (oldValue >= 5 != m_Kills >= 5)
|
||||
{
|
||||
|
|
@ -1834,12 +1831,7 @@ namespace Server
|
|||
set
|
||||
{
|
||||
if (m_ShortTermMurders != value)
|
||||
{
|
||||
m_ShortTermMurders = value;
|
||||
|
||||
if (m_ShortTermMurders < 0)
|
||||
m_ShortTermMurders = 0;
|
||||
}
|
||||
m_ShortTermMurders = Math.Max(value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5250,9 +5242,8 @@ namespace Server
|
|||
|
||||
OnDamage(amount, from, newHits < 0);
|
||||
|
||||
var m = Mount;
|
||||
if (m != null && informMount)
|
||||
m.OnRiderDamaged(amount, from, newHits < 0);
|
||||
if (informMount)
|
||||
Mount?.OnRiderDamaged(amount, from, newHits < 0);
|
||||
|
||||
if (newHits < 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -501,8 +501,7 @@ namespace Server.Network
|
|||
var vendor = World.FindMobile(pvSrc.ReadUInt32());
|
||||
var flag = pvSrc.ReadByte();
|
||||
|
||||
if (vendor == null)
|
||||
return;
|
||||
if (vendor == null) return;
|
||||
|
||||
if (vendor.Deleted || !Utility.RangeCheck(vendor.Location, state.Mobile.Location, 10))
|
||||
{
|
||||
|
|
@ -840,8 +839,7 @@ namespace Server.Network
|
|||
var beholder = state.Mobile;
|
||||
var beheld = World.FindMobile(serial);
|
||||
|
||||
if (beheld == null)
|
||||
return;
|
||||
if (beheld == null) return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
|
@ -1014,8 +1012,7 @@ namespace Server.Network
|
|||
|
||||
var t = from.Target;
|
||||
|
||||
if (t == null)
|
||||
return;
|
||||
if (t == null) return;
|
||||
|
||||
var prof = TargetProfile.Acquire(t.GetType());
|
||||
prof?.Start();
|
||||
|
|
@ -1640,45 +1637,41 @@ namespace Server.Network
|
|||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (PartyCommands.Handler != null)
|
||||
PartyCommands.Handler.OnPrivateMessage(state.Mobile, World.FindMobile(pvSrc.ReadUInt32()),
|
||||
pvSrc.ReadUnicodeStringSafe());
|
||||
PartyCommands.Handler?.OnPrivateMessage(
|
||||
state.Mobile,
|
||||
World.FindMobile(pvSrc.ReadUInt32()),
|
||||
pvSrc.ReadUnicodeStringSafe()
|
||||
);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
|
@ -1725,41 +1718,40 @@ namespace Server.Network
|
|||
{
|
||||
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 (menu != null && from == menu.From)
|
||||
if (entity != null && entity == menu.Target && from.CanSee(entity))
|
||||
{
|
||||
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)
|
||||
p = entity.Location;
|
||||
else if (entity is Item item)
|
||||
p = item.GetWorldLocation();
|
||||
else
|
||||
return;
|
||||
var range = e.Range;
|
||||
|
||||
int index = pvSrc.ReadUInt16();
|
||||
if (range == -1)
|
||||
range = 18;
|
||||
|
||||
if (index >= 0 && index < menu.Entries.Length)
|
||||
{
|
||||
var e = menu.Entries[index];
|
||||
|
||||
var range = e.Range;
|
||||
|
||||
if (range == -1)
|
||||
range = 18;
|
||||
|
||||
if (e.Enabled && from.InRange(p, range))
|
||||
e.OnClick();
|
||||
}
|
||||
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/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public sealed class DamagePacketOld : Packet
|
||||
|
|
@ -30,12 +32,7 @@ namespace Server.Network
|
|||
Stream.Write((byte)1);
|
||||
Stream.Write(mobile);
|
||||
|
||||
if (amount > 255)
|
||||
amount = 255;
|
||||
else if (amount < 0)
|
||||
amount = 0;
|
||||
|
||||
Stream.Write((byte)amount);
|
||||
Stream.Write((byte)Math.Clamp(amount, 0, 255));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,12 +42,7 @@ namespace Server.Network
|
|||
{
|
||||
Stream.Write(mobile);
|
||||
|
||||
if (amount > 0xFFFF)
|
||||
amount = 0xFFFF;
|
||||
else if (amount < 0)
|
||||
amount = 0;
|
||||
|
||||
Stream.Write((ushort)amount);
|
||||
Stream.Write((ushort)Math.Clamp(amount, 0, 0xFFFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Server
|
|||
fileStream = FileOperations.OpenSequentialStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
|
||||
fileQueue = new FileQueue(
|
||||
Math.Max(1, FileOperations.Concurrency),
|
||||
Math.Max(FileOperations.Concurrency, 1),
|
||||
FileCallback);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using Server.Json;
|
||||
using Server.Utilities;
|
||||
|
||||
|
|
|
|||
|
|
@ -183,12 +183,7 @@ namespace Server
|
|||
get => m_Base;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
else if (value >= 0x10000)
|
||||
value = 0xFFFF;
|
||||
|
||||
var sv = (ushort)value;
|
||||
var sv = (ushort)Math.Clamp(value, 0, 0xFFFF);
|
||||
|
||||
int oldBase = m_Base;
|
||||
|
||||
|
|
@ -219,12 +214,7 @@ namespace Server
|
|||
get => m_Cap;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
else if (value >= 0x10000)
|
||||
value = 0xFFFF;
|
||||
|
||||
var sv = (ushort)value;
|
||||
var sv = (ushort)Math.Clamp(value, 0, 0xFFFF);
|
||||
|
||||
if (m_Cap != sv)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Server
|
||||
|
|
|
|||
|
|
@ -39,11 +39,7 @@ namespace Server
|
|||
OneMinute
|
||||
}
|
||||
|
||||
public delegate void TimerCallback();
|
||||
|
||||
public delegate void TimerStateCallback<in T>(T state);
|
||||
|
||||
public class Timer
|
||||
public partial class 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 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.Linq;
|
||||
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.Collections.Generic;
|
||||
|
||||
|
|
|
|||
|
|
@ -493,19 +493,8 @@ namespace Server
|
|||
return dy > 0 ? Direction.Left : Direction.Up;
|
||||
}
|
||||
|
||||
public static object GetArrayCap(Array array, int index, object emptyValue = null)
|
||||
{
|
||||
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 object GetArrayCap(Array array, int index, object emptyValue = null) =>
|
||||
array.Length > 0 ? array.GetValue(Math.Clamp(index, 0, array.Length - 1)) : emptyValue;
|
||||
|
||||
public static SkillName RandomSkill() =>
|
||||
m_AllSkills[Random(m_AllSkills.Length - (Core.ML ? 0 : Core.SE ? 1 : Core.AOS ? 3 : 6))];
|
||||
|
|
@ -1002,5 +991,12 @@ namespace Server
|
|||
/// </summary>
|
||||
public static int RandomBrightHue() =>
|
||||
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)))
|
||||
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)
|
||||
|
|
@ -70,4 +70,4 @@ namespace Server.Commands.Generic
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Server.Commands.Generic
|
|||
{
|
||||
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
|
||||
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)
|
||||
|
|
@ -26,7 +26,7 @@ namespace Server.Commands.Generic
|
|||
{
|
||||
from.SendLocalizedMessage(500447); // That is not accessible.
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ namespace Server.Commands.Generic
|
|||
RunCommand(from, targeted, command, args);
|
||||
|
||||
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)))
|
||||
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)
|
||||
|
|
@ -86,4 +86,4 @@ namespace Server.Commands.Generic
|
|||
RunCommand(from, targeted, command, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,12 +91,7 @@ namespace Server.Gumps
|
|||
|
||||
CAGNode[] nodes = m_Category.Nodes;
|
||||
|
||||
int count = nodes.Length - page * EntryCount;
|
||||
|
||||
if (count < 0)
|
||||
count = 0;
|
||||
else if (count > EntryCount)
|
||||
count = EntryCount;
|
||||
int count = Math.Clamp(nodes.Length - page * EntryCount, 0, EntryCount);
|
||||
|
||||
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)
|
||||
|
|
@ -328,7 +328,7 @@ namespace Server.Commands
|
|||
concat[i * 2 + 1] = i < chain.Length - 1 ? "." : " = ";
|
||||
}
|
||||
|
||||
concat[concat.Length - 1] = toString;
|
||||
concat[^1] = toString;
|
||||
|
||||
return string.Concat(concat);
|
||||
}
|
||||
|
|
@ -654,7 +654,7 @@ namespace Server
|
|||
if (!IsBound)
|
||||
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)
|
||||
{
|
||||
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)
|
||||
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>();
|
||||
|
||||
Timer.DelayCall(TimeSpan.Zero, SetInitialSpawnArea);
|
||||
Timer.DelayCall(SetInitialSpawnArea);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (m_Tournament != null)
|
||||
Timer.DelayCall(TimeSpan.Zero, AttachToTournament_Sandbox);
|
||||
Timer.DelayCall(AttachToTournament_Sandbox);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
|
|
@ -345,21 +345,7 @@ namespace Server.Engines.ConPVP
|
|||
set => m_Bounds = value;
|
||||
}
|
||||
|
||||
public int Spectators
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Region == null)
|
||||
return 0;
|
||||
|
||||
int specs = m_Region.GetPlayerCount() - Players.Count;
|
||||
|
||||
if (specs < 0)
|
||||
specs = 0;
|
||||
|
||||
return specs;
|
||||
}
|
||||
}
|
||||
public int Spectators => m_Region == null ? 0 : Math.Max(m_Region.GetPlayerCount() - Players.Count, 0);
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Rectangle2D Zone
|
||||
|
|
@ -476,22 +462,13 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public override string ToString() => "...";
|
||||
|
||||
public Point3D GetBaseStartPoint(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
|
||||
return Points.Points[index % Points.Points.Length];
|
||||
}
|
||||
public Point3D GetBaseStartPoint(int index) => Points.Points[Math.Max(index, 0) % Points.Points.Length];
|
||||
|
||||
public void MoveInside(DuelPlayer[] players, int index)
|
||||
{
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
else
|
||||
index %= Points.Points.Length;
|
||||
index = Math.Min(index, 0) % Points.Points.Length;
|
||||
|
||||
Point3D start = GetBaseStartPoint(index);
|
||||
Point3D start = Points.Points[index];
|
||||
|
||||
int offset = 0;
|
||||
|
||||
|
|
@ -512,7 +489,7 @@ namespace Server.Engines.ConPVP
|
|||
if (offset < offsets.Length)
|
||||
p = offsets[offset++];
|
||||
else
|
||||
p = offsets[offsets.Length - 1];
|
||||
p = offsets[^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];
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -202,7 +202,7 @@ namespace Server.Engines.ConPVP
|
|||
m_Path.Clear();
|
||||
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)
|
||||
|
|
@ -292,7 +292,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
if (list.Count > 0)
|
||||
{
|
||||
Point3D p = list[list.Count - 1];
|
||||
Point3D p = list[^1];
|
||||
|
||||
if (p.X != ix || p.Y != iy || p.Z != iz)
|
||||
list.Add(new Point3D(ix, iy, iz));
|
||||
|
|
@ -307,7 +307,7 @@ namespace Server.Engines.ConPVP
|
|||
z += zslp;
|
||||
}
|
||||
|
||||
if (list.Count > 0 && list[list.Count - 1] != dest)
|
||||
if (list.Count > 0 && list[^1] != dest)
|
||||
list.Add(dest);
|
||||
|
||||
/*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)
|
||||
DoAnim(GetWorldLocation(), m_Path[m_PathIdx - 1], Map);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.1), ContinueFlight).Start();
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.1), ContinueFlight);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -734,7 +734,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
// has to be delayed in case some other target canceled us...
|
||||
if (m_Resend)
|
||||
Timer.DelayCall(TimeSpan.Zero, ResendBombTarget).Start();
|
||||
Timer.DelayCall(ResendBombTarget);
|
||||
}
|
||||
|
||||
private void ResendBombTarget()
|
||||
|
|
@ -1499,7 +1499,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -877,7 +877,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -516,7 +516,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
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)
|
||||
|
|
@ -846,7 +846,6 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
m_CapStage = 0;
|
||||
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)
|
||||
{
|
||||
Timer.DelayCall(ts, () => DelayBounce_Callback(mob, corpse));
|
||||
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||
}
|
||||
|
||||
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
||||
|
|
|
|||
|
|
@ -657,7 +657,7 @@ namespace Server.Engines.ConPVP
|
|||
m_PerPage = perPage;
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
|
||||
Resize(Players.Length + 1);
|
||||
Players[Players.Length - 1] = new DuelPlayer(player, this);
|
||||
Players[^1] = new DuelPlayer(player, this);
|
||||
}
|
||||
|
||||
public void Resize(int count)
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ namespace Server.Engines.ConPVP
|
|||
if (Pyramid.Levels.Count < 1)
|
||||
break;
|
||||
|
||||
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
|
||||
PyramidLevel top = Pyramid.Levels[^1];
|
||||
|
||||
if (top.FreeAdvance != null || top.Matches.Count != 1)
|
||||
break;
|
||||
|
|
@ -451,7 +451,7 @@ namespace Server.Engines.ConPVP
|
|||
if (Pyramid.Levels.Count < 2)
|
||||
break;
|
||||
|
||||
PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1];
|
||||
PyramidLevel top = Pyramid.Levels[^1];
|
||||
|
||||
if (top.FreeAdvance != null || top.Matches.Count != 1)
|
||||
break;
|
||||
|
|
@ -471,7 +471,7 @@ namespace Server.Engines.ConPVP
|
|||
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)
|
||||
break;
|
||||
|
|
@ -739,7 +739,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
else if (Pyramid.Levels.Count > 0)
|
||||
{
|
||||
PyramidLevel activeLevel = Pyramid.Levels[Pyramid.Levels.Count - 1];
|
||||
PyramidLevel activeLevel = Pyramid.Levels[^1];
|
||||
bool stillGoing = false;
|
||||
|
||||
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
|
||||
{
|
||||
public class CraftGroup
|
||||
|
|
@ -6,10 +8,10 @@ namespace Server.Engines.Craft
|
|||
{
|
||||
NameNumber = groupName;
|
||||
NameString = groupName;
|
||||
CraftItems = new CraftItemCol();
|
||||
CraftItems = new List<CraftItem>();
|
||||
}
|
||||
|
||||
public CraftItemCol CraftItems { get; }
|
||||
public List<CraftItem> CraftItems { get; }
|
||||
|
||||
public string NameString { get; }
|
||||
|
||||
|
|
@ -20,4 +22,4 @@ namespace Server.Engines.Craft
|
|||
CraftItems.Add(craftItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
CraftSubRes subResource = res.GetAt(i);
|
||||
CraftSubRes subResource = res[i];
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
|
|
@ -279,15 +279,14 @@ namespace Server.Engines.Craft
|
|||
return;
|
||||
}
|
||||
|
||||
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
|
||||
CraftGroup craftGroup = craftGroupCol.GetAt(selectedGroup);
|
||||
CraftItemCol craftItemCol = craftGroup.CraftItems;
|
||||
CraftGroup craftGroup = m_CraftSystem.CraftGroups[selectedGroup];
|
||||
List<CraftItem> craftItemCol = craftGroup.CraftItems;
|
||||
|
||||
for (int i = 0; i < craftItemCol.Count; ++i)
|
||||
{
|
||||
int index = i % 10;
|
||||
|
||||
CraftItem craftItem = craftItemCol.GetAt(i);
|
||||
CraftItem craftItem = craftItemCol[i];
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
|
|
@ -319,14 +318,14 @@ namespace Server.Engines.Craft
|
|||
|
||||
public int CreateGroupList()
|
||||
{
|
||||
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
|
||||
List<CraftGroup> craftGroupCol = m_CraftSystem.CraftGroups;
|
||||
|
||||
AddButton(15, 60, 4005, 4007, GetButtonID(6, 3));
|
||||
AddHtmlLocalized(50, 63, 150, 18, 1044014, LabelColor); // LAST TEN
|
||||
|
||||
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));
|
||||
|
||||
|
|
@ -378,7 +377,7 @@ namespace Server.Engines.Craft
|
|||
int index = buttonID / 7;
|
||||
|
||||
CraftSystem system = m_CraftSystem;
|
||||
CraftGroupCol groups = system.CraftGroups;
|
||||
List<CraftGroup> groups = system.CraftGroups;
|
||||
CraftContext context = system.GetContext(m_From);
|
||||
|
||||
switch (type)
|
||||
|
|
@ -405,10 +404,10 @@ namespace Server.Engines.Craft
|
|||
|
||||
if (groupIndex >= 0 && groupIndex < groups.Count)
|
||||
{
|
||||
CraftGroup group = groups.GetAt(groupIndex);
|
||||
CraftGroup group = groups[groupIndex];
|
||||
|
||||
if (index >= 0 && index < group.CraftItems.Count)
|
||||
CraftItem(group.CraftItems.GetAt(index));
|
||||
CraftItem(group.CraftItems[index]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -422,10 +421,10 @@ namespace Server.Engines.Craft
|
|||
|
||||
if (groupIndex >= 0 && groupIndex < groups.Count)
|
||||
{
|
||||
CraftGroup group = groups.GetAt(groupIndex);
|
||||
CraftGroup group = groups[groupIndex];
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ namespace Server.Engines.Craft
|
|||
{
|
||||
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;
|
||||
|
||||
if (minSkill < 0)
|
||||
|
|
@ -191,7 +191,7 @@ namespace Server.Engines.Craft
|
|||
resIndex = m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex;
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
int nameNumber;
|
||||
|
||||
CraftRes craftResource = m_CraftItem.Resources.GetAt(i);
|
||||
CraftRes craftResource = m_CraftItem.Resources[i];
|
||||
|
||||
type = craftResource.ItemType;
|
||||
nameString = craftResource.NameString;
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ namespace Server.Engines.Craft
|
|||
|
||||
public CraftItem(Type type, TextDefinition groupName, TextDefinition name)
|
||||
{
|
||||
Resources = new CraftResCol();
|
||||
Skills = new CraftSkillCol();
|
||||
Resources = new List<CraftRes>();
|
||||
Skills = new List<CraftSkill>();
|
||||
|
||||
ItemType = type;
|
||||
|
||||
|
|
@ -82,9 +82,9 @@ namespace Server.Engines.Craft
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
@ -452,7 +452,7 @@ namespace Server.Engines.Craft
|
|||
CraftRes res;
|
||||
for (int i = 0; i < types.Length; ++i)
|
||||
{
|
||||
CraftRes craftRes = Resources.GetAt(i);
|
||||
CraftRes craftRes = Resources[i];
|
||||
Type baseType = craftRes.ItemType;
|
||||
|
||||
// Resource Mutation
|
||||
|
|
@ -490,7 +490,7 @@ namespace Server.Engines.Craft
|
|||
|
||||
if (maxAmount == 0)
|
||||
{
|
||||
res = Resources.GetAt(i);
|
||||
res = Resources[i];
|
||||
|
||||
if (res.MessageNumber > 0)
|
||||
message = res.MessageNumber;
|
||||
|
|
@ -599,7 +599,7 @@ namespace Server.Engines.Craft
|
|||
return true;
|
||||
}
|
||||
|
||||
res = Resources.GetAt(index);
|
||||
res = Resources[index];
|
||||
|
||||
if (res.MessageNumber > 0)
|
||||
message = res.MessageNumber;
|
||||
|
|
@ -692,7 +692,7 @@ namespace Server.Engines.Craft
|
|||
|
||||
for (int i = 0; i < Skills.Count; i++)
|
||||
{
|
||||
CraftSkill craftSkill = Skills.GetAt(i);
|
||||
CraftSkill craftSkill = Skills[i];
|
||||
|
||||
double minSkill = craftSkill.MinSkill;
|
||||
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.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.Craft
|
||||
{
|
||||
public class CraftSubResCol : CollectionBase
|
||||
public class CraftSubResCol : List<CraftSubRes>
|
||||
{
|
||||
public CraftSubResCol() => Init = false;
|
||||
|
||||
|
|
@ -15,33 +15,17 @@ namespace Server.Engines.Craft
|
|||
|
||||
public int NameNumber { get; set; }
|
||||
|
||||
public void Add(CraftSubRes craftSubRes)
|
||||
{
|
||||
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 GetAt(int index) => this[index];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ namespace Server.Engines.Craft
|
|||
MaxCraftEffect = maxCraftEffect;
|
||||
Delay = delay;
|
||||
|
||||
CraftItems = new CraftItemCol();
|
||||
CraftGroups = new CraftGroupCol();
|
||||
CraftItems = new List<CraftItem>();
|
||||
CraftGroups = new List<CraftGroup>();
|
||||
CraftSubRes = new CraftSubResCol();
|
||||
CraftSubRes2 = new CraftSubResCol();
|
||||
|
||||
|
|
@ -40,9 +40,9 @@ namespace Server.Engines.Craft
|
|||
|
||||
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; }
|
||||
|
||||
|
|
@ -134,7 +134,8 @@ namespace Server.Engines.Craft
|
|||
craftItem.AddSkill(skillToMake, minSkill, maxSkill);
|
||||
|
||||
DoGroup(group, craftItem);
|
||||
return CraftItems.Add(craftItem);
|
||||
CraftItems.Add(craftItem);
|
||||
return CraftItems.Count - 1;
|
||||
}
|
||||
|
||||
private void DoGroup(TextDefinition groupName, CraftItem craftItem)
|
||||
|
|
@ -149,68 +150,58 @@ namespace Server.Engines.Craft
|
|||
}
|
||||
else
|
||||
{
|
||||
CraftGroups.GetAt(index).AddCraftItem(craftItem);
|
||||
CraftGroups[index].AddCraftItem(craftItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetItemHue(int index, int hue)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.ItemHue = hue;
|
||||
CraftItems[index].ItemHue = hue;
|
||||
}
|
||||
|
||||
public void SetManaReq(int index, int mana)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.Mana = mana;
|
||||
CraftItems[index].Mana = mana;
|
||||
}
|
||||
|
||||
public void SetStamReq(int index, int stam)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.Stam = stam;
|
||||
CraftItems[index].Stam = stam;
|
||||
}
|
||||
|
||||
public void SetHitsReq(int index, int hits)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.Hits = hits;
|
||||
CraftItems[index].Hits = hits;
|
||||
}
|
||||
|
||||
public void SetUseAllRes(int index, bool useAll)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.UseAllRes = useAll;
|
||||
CraftItems[index].UseAllRes = useAll;
|
||||
}
|
||||
|
||||
public void SetNeedHeat(int index, bool needHeat)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.NeedHeat = needHeat;
|
||||
CraftItems[index].NeedHeat = needHeat;
|
||||
}
|
||||
|
||||
public void SetNeedOven(int index, bool needOven)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.NeedOven = needOven;
|
||||
CraftItems[index].NeedOven = needOven;
|
||||
}
|
||||
|
||||
public void SetBeverageType(int index, BeverageType requiredBeverage)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.RequiredBeverage = requiredBeverage;
|
||||
CraftItems[index].RequiredBeverage = requiredBeverage;
|
||||
}
|
||||
|
||||
public void SetNeedMill(int index, bool needMill)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.NeedMill = needMill;
|
||||
CraftItems[index].NeedMill = needMill;
|
||||
}
|
||||
|
||||
public void SetNeededExpansion(int index, Expansion expansion)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.RequiredExpansion = expansion;
|
||||
CraftItems[index].RequiredExpansion = expansion;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.AddRes(type, name, amount, message);
|
||||
CraftItems[index].AddRes(type, name, amount, message);
|
||||
}
|
||||
|
||||
public void AddSkill(int index, SkillName skillToMake, double minSkill, double maxSkill)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.AddSkill(skillToMake, minSkill, maxSkill);
|
||||
CraftItems[index].AddSkill(skillToMake, minSkill, maxSkill);
|
||||
}
|
||||
|
||||
public void SetUseSubRes2(int index, bool val)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.UseSubRes2 = val;
|
||||
CraftItems[index].UseSubRes2 = val;
|
||||
}
|
||||
|
||||
private void AddRecipeBase(int index, int id)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.AddRecipe(id, this);
|
||||
CraftItems[index].AddRecipe(id, this);
|
||||
}
|
||||
|
||||
public void AddRecipe(int index, int id)
|
||||
|
|
@ -261,8 +248,7 @@ namespace Server.Engines.Craft
|
|||
|
||||
public void ForceNonExceptional(int index)
|
||||
{
|
||||
CraftItem craftItem = CraftItems.GetAt(index);
|
||||
craftItem.ForceNonExceptional = true;
|
||||
CraftItems[index].ForceNonExceptional = true;
|
||||
}
|
||||
|
||||
public void SetSubRes(Type type, string name)
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ namespace Server.Engines.Craft
|
|||
foreach (KeyValuePair<int, Recipe> kvp in Recipes)
|
||||
mobile.AcquireRecipe(kvp.Key);
|
||||
|
||||
m.SendMessage("You teach them all of the recipes.");
|
||||
from.SendMessage("You teach them all of the recipes.");
|
||||
}
|
||||
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;
|
||||
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)
|
||||
{
|
||||
mobile.ResetRecipes();
|
||||
|
||||
m.SendMessage("They forget all their recipes.");
|
||||
from.SendMessage("They forget all their recipes.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendMessage("That is not a player!");
|
||||
from.SendMessage("That is not a player!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Server.Engines.Craft
|
|||
NoSkill
|
||||
}
|
||||
|
||||
public class Resmelt
|
||||
public static class Resmelt
|
||||
{
|
||||
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)
|
||||
return SmeltResult.Invalid;
|
||||
|
||||
CraftRes craftResource = craftItem.Resources.GetAt(0);
|
||||
CraftRes craftResource = craftItem.Resources[0];
|
||||
|
||||
if (craftResource.Amount < 2)
|
||||
return SmeltResult.Invalid; // Not enough metal to resmelt
|
||||
|
|
@ -85,9 +85,9 @@ namespace Server.Engines.Craft
|
|||
Type resourceType = info.ResourceTypes[0];
|
||||
Item ingot = (Item)ActivatorUtil.CreateInstance(resourceType);
|
||||
|
||||
if (item is DragonBardingDeed || (item is BaseArmor armor && armor.PlayerConstructed) ||
|
||||
(item is BaseWeapon weapon && weapon.PlayerConstructed) ||
|
||||
(item is BaseClothing clothing && clothing.PlayerConstructed))
|
||||
if (item is DragonBardingDeed || item is BaseArmor armor && armor.PlayerConstructed ||
|
||||
item is BaseWeapon weapon && weapon.PlayerConstructed ||
|
||||
item is BaseClothing clothing && clothing.PlayerConstructed)
|
||||
ingot.Amount = craftResource.Amount / 2;
|
||||
else
|
||||
ingot.Amount = 1;
|
||||
|
|
@ -144,7 +144,6 @@ namespace Server.Engines.Craft
|
|||
else if (targeted is DragonBardingDeed deed)
|
||||
{
|
||||
result = Resmelt(from, deed, deed.Resource);
|
||||
isStoreBought = false;
|
||||
}
|
||||
|
||||
message = result switch
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ namespace Server.Engines.Craft
|
|||
{
|
||||
if (tool?.Deleted != false || tool.UsesRemaining < 0)
|
||||
return 1044038; // You have worn out your tool!
|
||||
|
||||
if (!BaseTool.CheckAccessible(tool, from))
|
||||
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)
|
||||
return 1044038; // You have worn out your tool!
|
||||
|
||||
if (!BaseTool.CheckAccessible(tool, from))
|
||||
return 1044263; // The tool must be on your person to use.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Ethics.Evil;
|
||||
using Server.Ethics.Hero;
|
||||
|
|
@ -203,7 +202,7 @@ namespace Server.Ethics
|
|||
Player pl = new Player(this, reader);
|
||||
|
||||
if (pl.Mobile != null)
|
||||
Timer.DelayCall(TimeSpan.Zero, pl.CheckAttach);
|
||||
Timer.DelayCall(pl.CheckAttach);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -423,12 +423,7 @@ namespace Server.Factions
|
|||
int factorKillPts = 100 + kp * 2;
|
||||
int factorGameTime = 50 + (int)(gameTime.Ticks * 100 / TimeSpan.TicksPerDay);
|
||||
|
||||
int totalFactor = factorSkills * factorKillPts * Math.Max(factorGameTime, 100) / 10000;
|
||||
|
||||
if (totalFactor > 100)
|
||||
totalFactor = 100;
|
||||
else if (totalFactor < 0)
|
||||
totalFactor = 0;
|
||||
int totalFactor = Math.Clamp(factorSkills * factorKillPts * Math.Max(factorGameTime, 100) / 10000, 0, 100);
|
||||
|
||||
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)
|
||||
{
|
||||
if (!m_SkillLoss.TryGetValue(mob, out SkillLossContext context))
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ namespace Server.Factions
|
|||
{
|
||||
FactionItem factionItem = new FactionItem(reader, m_Faction);
|
||||
|
||||
Timer.DelayCall(TimeSpan.Zero, factionItem.CheckAttach); // sandbox attachment
|
||||
Timer.DelayCall(factionItem.CheckAttach); // sandbox attachment
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -270,4 +270,4 @@ namespace Server.Factions
|
|||
writer.Write(Traps[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ namespace Server.Factions
|
|||
PlayerState pl = PlayerState.Find(from);
|
||||
|
||||
if (pl != null)
|
||||
Timer.DelayCall(TimeSpan.Zero, ShowScore_Sandbox, pl);
|
||||
Timer.DelayCall(ShowScore_Sandbox, pl);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,75 +22,78 @@ namespace Server
|
|||
|
||||
public override bool Use(Mobile user)
|
||||
{
|
||||
if (Movable)
|
||||
user.BeginTarget(12, true, TargetFlags.None, (from, obj) =>
|
||||
{
|
||||
if (Movable && !Deleted)
|
||||
if (obj is IPoint3D pt)
|
||||
{
|
||||
SpellHelper.GetSurfaceTop(ref pt);
|
||||
if (!Movable) return false;
|
||||
|
||||
Point3D origin = new Point3D(pt);
|
||||
Map facet = from.Map;
|
||||
user.BeginTarget(12, true, TargetFlags.None, (from, obj, stormsEye) =>
|
||||
{
|
||||
if (!stormsEye.Movable || stormsEye.Deleted || !(obj is IPoint3D pt)) return;
|
||||
|
||||
if (facet?.CanFit(pt.X, pt.Y, pt.Z, 16, false, false) != true)
|
||||
return;
|
||||
SpellHelper.GetSurfaceTop(ref pt);
|
||||
|
||||
Movable = false;
|
||||
Point3D origin = new Point3D(pt);
|
||||
Map facet = from.Map;
|
||||
|
||||
Effects.SendMovingEffect(
|
||||
from, new Entity(Serial.Zero, origin, facet),
|
||||
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1);
|
||||
if (facet?.CanFit(pt.X, pt.Y, pt.Z, 16, false, false) != true)
|
||||
return;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.5), () =>
|
||||
{
|
||||
Delete();
|
||||
stormsEye.Movable = false;
|
||||
|
||||
Effects.PlaySound(origin, facet, 530);
|
||||
Effects.PlaySound(origin, facet, 263);
|
||||
Effects.SendMovingEffect(
|
||||
from, new Entity(Serial.Zero, origin, facet),
|
||||
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1);
|
||||
|
||||
Effects.SendLocationEffect(
|
||||
origin, facet,
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.5), OnDelay, from, stormsEye, origin, facet);
|
||||
}, this);
|
||||
|
||||
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)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ namespace Server.Factions
|
|||
|
||||
if (TimeOfPlacement + decayPeriod < DateTime.UtcNow)
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.Zero, Delete);
|
||||
Timer.DelayCall(Delete);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ namespace Server.Factions
|
|||
m_Town = Town.ReadReference(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();
|
||||
|
||||
Timer.DelayCall(TimeSpan.Zero, Refresh);
|
||||
Timer.DelayCall(Refresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace Server.Engines.Quests
|
|||
|
||||
--Charges;
|
||||
|
||||
m_PlayTimer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), () => PlayTimer_Callback(from));
|
||||
m_PlayTimer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), PlayTimer_Callback, from);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -189,4 +189,4 @@ namespace Server.Engines.Quests
|
|||
Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ namespace Server.Engines.Quests
|
|||
|
||||
From.SendGump(new QuestObjectivesGump(Objectives));
|
||||
|
||||
QuestObjective last = Objectives[Objectives.Count - 1];
|
||||
QuestObjective last = Objectives[^1];
|
||||
|
||||
if (last.Info != null)
|
||||
From.SendGump(new QuestItemInfoGump(last.Info));
|
||||
|
|
@ -276,7 +276,7 @@ namespace Server.Engines.Quests
|
|||
|
||||
From.SendGump(new QuestConversationsGump(Conversations));
|
||||
|
||||
QuestConversation last = Conversations[Conversations.Count - 1];
|
||||
QuestConversation last = Conversations[^1];
|
||||
|
||||
if (last.Info != null)
|
||||
From.SendGump(new QuestItemInfoGump(last.Info));
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ namespace Server.Engines.Quests.Samurai
|
|||
|
||||
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);
|
||||
|
||||
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 *
|
||||
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)
|
||||
|
|
@ -212,7 +212,7 @@ namespace Server.Engines.Quests.Hag
|
|||
|
||||
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)
|
||||
|
|
@ -266,7 +266,7 @@ namespace Server.Engines.Quests.Hag
|
|||
for (int i = 0; i < oldIngredients.Length; i++)
|
||||
Ingredients[i] = oldIngredients[i];
|
||||
|
||||
Ingredients[Ingredients.Length - 1] = IngredientInfo.RandomIngredient(oldIngredients);
|
||||
Ingredients[^1] = IngredientInfo.RandomIngredient(oldIngredients);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -324,7 +324,7 @@ namespace Server.Engines.Quests.Hag
|
|||
|
||||
public Ingredient[] Ingredients { get; private set; }
|
||||
|
||||
public Ingredient Ingredient => Ingredients[Ingredients.Length - 1];
|
||||
public Ingredient Ingredient => Ingredients[^1];
|
||||
public int Step => Ingredients.Length;
|
||||
public bool BlackheartMet { get; private set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ namespace Server.Mobiles
|
|||
Frozen = true;
|
||||
|
||||
if (m_SculptedBy == null || Map == Map.Internal) // Remove preview statues
|
||||
Timer.DelayCall(TimeSpan.Zero, Delete);
|
||||
Timer.DelayCall(Delete);
|
||||
}
|
||||
|
||||
public void Sculpt(Mobile by)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
|
|
@ -86,7 +85,8 @@ namespace Server.Items
|
|||
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
|
|
@ -107,12 +108,7 @@ namespace Server.Gumps
|
|||
int x = BorderSize + OffsetSize;
|
||||
int y = BorderSize + OffsetSize;
|
||||
|
||||
int count = node.Categories.Length + node.Locations.Length - page * EntryCount;
|
||||
|
||||
if (count < 0)
|
||||
count = 0;
|
||||
else if (count > EntryCount)
|
||||
count = EntryCount;
|
||||
int count = Math.Clamp(node.Categories.Length + node.Locations.Length - page * EntryCount, 0, EntryCount);
|
||||
|
||||
int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace Server.Guilds
|
|||
}
|
||||
|
||||
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);
|
||||
AddTextEntry(135, 80, 375, 30, 0x481, 1, m_Filter);
|
||||
|
|
|
|||
|
|
@ -83,11 +83,9 @@ namespace Server.Guilds
|
|||
TextRelay tWarLength = info.GetTextEntry(10);
|
||||
|
||||
int maxKills = tKills == null
|
||||
? 0
|
||||
: Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(11).Text), 0xFFFF), 0);
|
||||
TimeSpan warLength = TimeSpan.FromHours(tWarLength == null
|
||||
? 0
|
||||
: Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(10).Text), 0xFFFF), 0));
|
||||
? 0 : Math.Clamp(Utility.ToInt32(info.GetTextEntry(11).Text), 0, 0xFFFF);
|
||||
TimeSpan warLength = TimeSpan.FromHours(tWarLength == null ? 0
|
||||
: Math.Clamp(Utility.ToInt32(info.GetTextEntry(10).Text), 0, 0xFFFF));
|
||||
|
||||
if (war != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ namespace Server.Gumps
|
|||
ArtID = art;
|
||||
BodyID = body;
|
||||
LocNumber = locNum;
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public int ArtID { get; }
|
||||
|
|
|
|||
|
|
@ -180,12 +180,7 @@ namespace Server.Gumps
|
|||
{
|
||||
m_Page = page;
|
||||
|
||||
int count = m_List.Count - page * EntryCount;
|
||||
|
||||
if (count < 0)
|
||||
count = 0;
|
||||
else if (count > EntryCount)
|
||||
count = EntryCount;
|
||||
int count = Math.Clamp(m_List.Count - page * EntryCount, 0, EntryCount);
|
||||
|
||||
int lastIndex = page * EntryCount + count - 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ namespace Server.Gumps
|
|||
if (Core.SE)
|
||||
{
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ namespace Server.Engines.Events
|
|||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
if (DateTime.UtcNow >= HolidaySettings.StartHalloween && DateTime.UtcNow <= HolidaySettings.FinishHalloween)
|
||||
m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromMinutes(.50), 0, PumpkinPatchSpawnerCallback);
|
||||
if (now >= HolidaySettings.StartHalloween && now <= HolidaySettings.FinishHalloween)
|
||||
m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(30), 0, 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,
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class JackOLantern : BaseAddon
|
||||
|
|
@ -15,18 +13,18 @@ namespace Server.Items
|
|||
{
|
||||
AddComponent(new AddonComponent(5703), 0, 0, +0);
|
||||
|
||||
int hue = 1161;
|
||||
const int hue = 1161;
|
||||
// ( 1 > Utility.Random( 5 ) ? 2118 : 1161 );
|
||||
|
||||
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(3862, hue), 0, 0, +0);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddComponent(GetComponent(3179, 0000), 0, 0, +0);
|
||||
AddComponent(GetComponent(3179, 0), 0, 0, +0);
|
||||
AddComponent(GetComponent(3885, hue), 0, 0, -1);
|
||||
AddComponent(GetComponent(3871, hue), 0, 0, +0);
|
||||
}
|
||||
|
|
@ -39,15 +37,12 @@ namespace Server.Items
|
|||
|
||||
public override bool ShareHue => false;
|
||||
|
||||
private AddonComponent GetComponent(int itemID, int hue)
|
||||
{
|
||||
AddonComponent ac = new AddonComponent(itemID);
|
||||
|
||||
ac.Hue = hue;
|
||||
ac.Name = "jack-o-lantern";
|
||||
|
||||
return ac;
|
||||
}
|
||||
private static AddonComponent GetComponent(int itemID, int hue) =>
|
||||
new AddonComponent(itemID)
|
||||
{
|
||||
Hue = hue,
|
||||
Name = "jack-o-lantern"
|
||||
};
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
|
|
@ -62,21 +57,31 @@ namespace Server.Items
|
|||
|
||||
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)
|
||||
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)
|
||||
if (Components[i] is AddonComponent ac)
|
||||
ac.Name = "jack-o-lantern";
|
||||
});
|
||||
case 1:
|
||||
{
|
||||
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!
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromHours(2.0), () => ReleaseUseLock_Callback(from, random));
|
||||
Timer.DelayCall(TimeSpan.FromHours(2.0), ReleaseUseLock_Callback, from, random);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,4 +168,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ namespace Server.Items
|
|||
fish = new StrippedFlakeFish();
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
default: // 5
|
||||
{
|
||||
message = 1074365; // A new creature has hatched overnight in the tank.
|
||||
fish = new StrippedSosarianSwill();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum WaterState
|
||||
|
|
@ -27,16 +29,7 @@ namespace Server.Items
|
|||
public int State
|
||||
{
|
||||
get => m_State;
|
||||
set
|
||||
{
|
||||
m_State = value;
|
||||
|
||||
if (m_State < 0)
|
||||
m_State = 0;
|
||||
|
||||
if (m_State > 4)
|
||||
m_State = 4;
|
||||
}
|
||||
set => m_State = Math.Clamp(value, 0, 4);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
|
|
@ -70,4 +63,4 @@ namespace Server.Items
|
|||
Added = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ namespace Server.Items
|
|||
if (makersMark)
|
||||
Crafter = from;
|
||||
|
||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
||||
Type resourceType = typeRes ?? craftItem.Resources[0].ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType(resourceType);
|
||||
PlayerConstructed = true;
|
||||
|
|
@ -547,12 +547,12 @@ namespace Server.Items
|
|||
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
catch
|
||||
|
|
@ -623,9 +623,8 @@ namespace Server.Items
|
|||
double halfar = ArmorRating / 2.0;
|
||||
int absorbed = (int)(halfar + halfar * Utility.RandomDouble());
|
||||
|
||||
damageTaken -= absorbed;
|
||||
if (damageTaken < 0)
|
||||
damageTaken = 0;
|
||||
// Don't go below zero
|
||||
damageTaken = Math.Min(absorbed, damageTaken);
|
||||
|
||||
if (absorbed < 2)
|
||||
absorbed = 2;
|
||||
|
|
@ -1584,7 +1583,7 @@ namespace Server.Items
|
|||
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
||||
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
|
||||
|
||||
this.AddResistanceProperties(list);
|
||||
AddResistanceProperties(list);
|
||||
|
||||
if ((prop = GetDurabilityBonus()) > 0)
|
||||
list.Add(1060410, prop.ToString()); // durability ~1_val~%
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Server.Items
|
|||
if (Deleted || !from.CanSee(this))
|
||||
return false;
|
||||
|
||||
this.ScissorHelper(from, new Bone(), Utility.RandomMinMax(10, 15));
|
||||
ScissorHelper(from, new Bone(), Utility.RandomMinMax(10, 15));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Server.Items
|
|||
if (Deleted || !from.CanSee(this))
|
||||
return false;
|
||||
|
||||
this.ScissorHelper(from, new Bone(), Utility.RandomMinMax(3, 5));
|
||||
ScissorHelper(from, new Bone(), Utility.RandomMinMax(3, 5));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Server.Items
|
|||
get => m_Level;
|
||||
set
|
||||
{
|
||||
m_Level = Math.Max(Math.Min(2, value), 0);
|
||||
m_Level = Math.Clamp(value, 0, 2);
|
||||
Attributes.BonusInt = 2 + m_Level;
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
|
@ -52,4 +52,4 @@ namespace Server.Items
|
|||
Level = Attributes.BonusInt - 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ namespace Server.Items
|
|||
|
||||
if (DefaultResource != CraftResource.None)
|
||||
{
|
||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
||||
Type resourceType = typeRes ?? craftItem.Resources[0].ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType(resourceType);
|
||||
}
|
||||
|
|
@ -200,16 +200,16 @@ namespace Server.Items
|
|||
|
||||
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
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
|
|
@ -262,12 +262,10 @@ namespace Server.Items
|
|||
|
||||
public virtual int OnHit(BaseWeapon weapon, int damageTaken)
|
||||
{
|
||||
int Absorbed = Utility.RandomMinMax(1, 4);
|
||||
int absorbed = Utility.RandomMinMax(1, 4);
|
||||
|
||||
damageTaken -= Absorbed;
|
||||
|
||||
if (damageTaken < 0)
|
||||
damageTaken = 0;
|
||||
// Don't go below zero
|
||||
damageTaken = Math.Min(absorbed, damageTaken);
|
||||
|
||||
if (Utility.Random(100) < 25) // 25% chance to lower durability
|
||||
{
|
||||
|
|
@ -280,7 +278,7 @@ namespace Server.Items
|
|||
int wear;
|
||||
|
||||
if (weapon.Type == WeaponType.Bashing)
|
||||
wear = Absorbed / 2;
|
||||
wear = absorbed / 2;
|
||||
else
|
||||
wear = Utility.Random(2);
|
||||
|
||||
|
|
@ -338,13 +336,8 @@ namespace Server.Items
|
|||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted)
|
||||
{
|
||||
if (!Ethic.CheckTrade(from, to, newOwner, this))
|
||||
return false;
|
||||
|
||||
return base.AllowSecureTrade(from, to, newOwner, 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);
|
||||
|
||||
public override bool CanEquip(Mobile from)
|
||||
{
|
||||
|
|
@ -406,14 +399,13 @@ namespace Server.Items
|
|||
return AOS.Scale(v, 100 - GetLowerStatReq());
|
||||
}
|
||||
|
||||
public int ComputeStatBonus(StatType type)
|
||||
{
|
||||
if (type == StatType.Str)
|
||||
return BaseStrBonus + Attributes.BonusStr;
|
||||
if (type == StatType.Dex)
|
||||
return BaseDexBonus + Attributes.BonusDex;
|
||||
return BaseIntBonus + Attributes.BonusInt;
|
||||
}
|
||||
public int ComputeStatBonus(StatType type) =>
|
||||
type switch
|
||||
{
|
||||
StatType.Str => BaseStrBonus + Attributes.BonusStr,
|
||||
StatType.Dex => BaseDexBonus + Attributes.BonusDex,
|
||||
_ => BaseIntBonus + Attributes.BonusInt
|
||||
};
|
||||
|
||||
public virtual void AddStatBonuses(Mobile parent)
|
||||
{
|
||||
|
|
@ -533,26 +525,19 @@ namespace Server.Items
|
|||
clothing.ClothingAttributes = new AosArmorAttributes(newItem, ClothingAttributes);
|
||||
}
|
||||
|
||||
public override bool AllowEquippedCast(Mobile from)
|
||||
{
|
||||
if (base.AllowEquippedCast(from))
|
||||
return true;
|
||||
|
||||
return Attributes.SpellChanneling != 0;
|
||||
}
|
||||
public override bool AllowEquippedCast(Mobile from) => base.AllowEquippedCast(from) || Attributes.SpellChanneling != 0;
|
||||
|
||||
public override bool CheckPropertyConflict(Mobile m)
|
||||
{
|
||||
if (base.CheckPropertyConflict(m))
|
||||
return true;
|
||||
|
||||
if (Layer == Layer.Pants)
|
||||
return m.FindItemOnLayer(Layer.InnerLegs) != null;
|
||||
|
||||
if (Layer == Layer.Shirt)
|
||||
return m.FindItemOnLayer(Layer.InnerTorso) != null;
|
||||
|
||||
return false;
|
||||
return Layer switch
|
||||
{
|
||||
Layer.Pants => m.FindItemOnLayer(Layer.InnerLegs) != null,
|
||||
Layer.Shirt => m.FindItemOnLayer(Layer.InnerTorso) != null,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
private string GetNameString() => Name ?? $"#{LabelNumber}";
|
||||
|
|
@ -693,7 +678,7 @@ namespace Server.Items
|
|||
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
||||
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
|
||||
|
||||
this.AddResistanceProperties(list);
|
||||
AddResistanceProperties(list);
|
||||
|
||||
if ((prop = ClothingAttributes.DurabilityBonus) > 0)
|
||||
list.Add(1060410, prop.ToString()); // durability ~1_val~%
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ namespace Server.Items
|
|||
int version = reader.ReadEncodedInt();
|
||||
|
||||
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)
|
||||
return false;
|
||||
|
||||
CraftRes craftResource = craftItem.Resources.GetAt(0);
|
||||
CraftRes craftResource = craftItem.Resources[0];
|
||||
|
||||
if (craftResource.Amount < 2)
|
||||
return false; // Not enough metal to resmelt
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace Server.Items
|
|||
if (makersMark)
|
||||
Crafter = from;
|
||||
|
||||
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
|
||||
Type resourceType = typeRes ?? craftItem.Resources[0].ItemType;
|
||||
|
||||
Resource = CraftResources.GetFromType(resourceType);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using Server.Factions;
|
||||
using Server.Guilds;
|
||||
using Server.Gumps;
|
||||
|
|
@ -143,7 +142,7 @@ namespace Server.Items
|
|||
m_BeforeChangeover = true;
|
||||
|
||||
if (Guild.NewGuildSystem && m_BeforeChangeover)
|
||||
Timer.DelayCall(TimeSpan.Zero, AddToHouse);
|
||||
Timer.DelayCall(AddToHouse);
|
||||
|
||||
if (!Guild.NewGuildSystem && Guild == null)
|
||||
Delete();
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ namespace Server.Items
|
|||
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, 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);
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ namespace Server.Items
|
|||
|
||||
if (craftItem.Resources.Count > 1)
|
||||
{
|
||||
resourceType = craftItem.Resources.GetAt(1).ItemType;
|
||||
resourceType = craftItem.Resources[1].ItemType;
|
||||
|
||||
if (resourceType == typeof(StarSapphire))
|
||||
GemType = GemType.StarSapphire;
|
||||
|
|
@ -302,7 +302,7 @@ namespace Server.Items
|
|||
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
|
||||
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~%
|
||||
|
||||
this.AddResistanceProperties(list);
|
||||
AddResistanceProperties(list);
|
||||
|
||||
if (m_HitPoints >= 0 && m_MaxHitPoints > 0)
|
||||
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)
|
||||
{
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x >= Width)
|
||||
x = Width - 1;
|
||||
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y >= Height)
|
||||
y = Height - 1;
|
||||
x = Math.Clamp(x, 0, Width - 1);
|
||||
y = Math.Clamp(y, 0, Height - 1);
|
||||
}
|
||||
|
||||
public virtual bool ValidateEdit(Mobile from) => m_Editable && Validate(from);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace Server.Items
|
|||
|
||||
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)
|
||||
|
|
@ -191,7 +191,7 @@ namespace Server.Items
|
|||
from.Animate(11, 5, 1, true, false, 0);
|
||||
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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
if (remainder == 0)
|
||||
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[attackers.Count - 1]));
|
||||
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[^1]));
|
||||
else
|
||||
m_Unstackables.Add(item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,6 +131,19 @@ namespace Server.Items
|
|||
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)
|
||||
{
|
||||
if (Utility.InRange(from.Location, Location, 2))
|
||||
|
|
@ -146,18 +159,7 @@ namespace Server.Items
|
|||
|
||||
DoEffect(spawnLoc, map);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
|
||||
{
|
||||
bc.Home = Location;
|
||||
bc.RangeHome = SpawnRange;
|
||||
bc.FightMode = FightMode.Closest;
|
||||
|
||||
bc.MoveToWorld(spawnLoc, map);
|
||||
|
||||
DoEffect(spawnLoc, map);
|
||||
|
||||
bc.ForceReacquire();
|
||||
});
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), SummonCreatureToWorld, bc, spawnLoc, map);
|
||||
|
||||
NextSpawn = DateTime.UtcNow + NextSpawnDelay;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ namespace Server.Items
|
|||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
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))
|
||||
return false;
|
||||
|
||||
this.ScissorHelper(from, new Bandage(), 1);
|
||||
ScissorHelper(from, new Bandage(), 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ namespace Server.Items
|
|||
hues[n.X, n.Y] = NodeHue.Blue;
|
||||
}
|
||||
|
||||
Node lastNode = path[path.Length - 1];
|
||||
Node lastNode = path[^1];
|
||||
hues[lastNode.X, lastNode.Y] = NodeHue.Red;
|
||||
|
||||
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,
|
||||
""));
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), () => m.EndAction(this));
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), m.EndAction, this);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ namespace Server.Items
|
|||
list[i].Broadcast(triggerer);
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.Zero, InternalCallback);
|
||||
Timer.DelayCall(StopBroadcasting);
|
||||
}
|
||||
|
||||
private void InternalCallback()
|
||||
private void StopBroadcasting()
|
||||
{
|
||||
m_Broadcasting = false;
|
||||
}
|
||||
|
|
@ -207,4 +207,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Server.Items
|
|||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Server.Items
|
|||
|
||||
public void Carve(Mobile from, Item item)
|
||||
{
|
||||
this.ScissorHelper(from, new RawFishSteak(), 4);
|
||||
ScissorHelper(from, new RawFishSteak(), 4);
|
||||
}
|
||||
|
||||
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