Inital Commit
This commit is contained in:
+180
-145
@@ -186,7 +186,7 @@ namespace Server
|
||||
/// <summary>
|
||||
/// Unused, using this layer makes you invisible to other players. Strange.
|
||||
/// </summary>
|
||||
///
|
||||
///
|
||||
Reserved_1 = 0x1E,
|
||||
|
||||
/// <summary>
|
||||
@@ -856,7 +856,7 @@ namespace Server
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private byte m_GridLocation = 0;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
@@ -1261,7 +1261,7 @@ namespace Server
|
||||
public virtual void AddLootTypeProperty(ObjectPropertyList list)
|
||||
{
|
||||
if (DisplayLootType)
|
||||
{
|
||||
{
|
||||
if (m_LootType == LootType.Blessed)
|
||||
{
|
||||
list.Add(1038021); // blessed
|
||||
@@ -1610,7 +1610,7 @@ namespace Server
|
||||
/// {
|
||||
/// if ( from.Int >= 100 )
|
||||
/// return true;
|
||||
///
|
||||
///
|
||||
/// return base.AllowEquipedCast( from );
|
||||
/// }</code>
|
||||
/// When placed in an Item script, the item may be cast when equiped if the <paramref name="from" /> has 100 or more intelligence. Otherwise, it will drop to their backpack.
|
||||
@@ -2137,7 +2137,7 @@ namespace Server
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (Sockets != null && item.Sockets != null)
|
||||
else if (Sockets != null && item.Sockets != null)
|
||||
{
|
||||
if (Sockets.Any(s => !item.HasSocket(s.GetType())))
|
||||
{
|
||||
@@ -2515,7 +2515,18 @@ namespace Server
|
||||
{ }
|
||||
|
||||
public virtual void OnAdded(object parent)
|
||||
{ }
|
||||
{
|
||||
// Only enforce insurance when the item is added to a Mobile (player)
|
||||
if (parent is Mobile newOwner)
|
||||
{
|
||||
if (Insured && InsuredBy != Serial.MinusOne && newOwner.Serial != InsuredBy)
|
||||
{
|
||||
Insured = false;
|
||||
InsuredBy = Serial.MinusOne;
|
||||
newOwner.SendMessage("The insurance on this item has been removed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.Decorator)]
|
||||
public Map Map
|
||||
@@ -2619,16 +2630,16 @@ namespace Server
|
||||
|
||||
// 14
|
||||
writer.Write(Sockets != null ? Sockets.Count : 0);
|
||||
|
||||
if(Sockets != null)
|
||||
{
|
||||
foreach(var socket in Sockets)
|
||||
{
|
||||
ItemSocket.Save(socket, writer);
|
||||
}
|
||||
}
|
||||
|
||||
// 13: Merge sync
|
||||
if (Sockets != null)
|
||||
{
|
||||
foreach (var socket in Sockets)
|
||||
{
|
||||
ItemSocket.Save(socket, writer);
|
||||
}
|
||||
}
|
||||
|
||||
// 13: Merge sync
|
||||
// 12: Light no longer backed by Direction
|
||||
|
||||
// 11
|
||||
@@ -3031,6 +3042,7 @@ namespace Server
|
||||
OnLockDownChange();
|
||||
}
|
||||
}
|
||||
public Serial InsuredBy;
|
||||
|
||||
public virtual void OnLockDownChange()
|
||||
{
|
||||
@@ -3125,13 +3137,13 @@ namespace Server
|
||||
case 14:
|
||||
var socketCount = reader.ReadInt();
|
||||
|
||||
for(int i = 0; i < socketCount; i++)
|
||||
for (int i = 0; i < socketCount; i++)
|
||||
{
|
||||
ItemSocket.Load(this, reader);
|
||||
}
|
||||
|
||||
goto case 13;
|
||||
case 13:
|
||||
case 13:
|
||||
case 12:
|
||||
case 11:
|
||||
m_GridLocation = reader.ReadByte();
|
||||
@@ -3185,7 +3197,7 @@ namespace Server
|
||||
{
|
||||
m_Light = (LightType)reader.ReadByte();
|
||||
}
|
||||
else if(version < 12)
|
||||
else if (version < 12)
|
||||
{
|
||||
m_Light = (LightType)m_Direction;
|
||||
}
|
||||
@@ -3721,7 +3733,7 @@ namespace Server
|
||||
state.Send(OPLPacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected virtual Packet GetWorldPacketFor(NetState state)
|
||||
{
|
||||
if (state.HighSeas)
|
||||
@@ -4619,7 +4631,7 @@ namespace Server
|
||||
module.Delete();
|
||||
}
|
||||
|
||||
if(Sockets != null)
|
||||
if (Sockets != null)
|
||||
{
|
||||
Sockets.IterateReverse(socket =>
|
||||
{
|
||||
@@ -4722,7 +4734,7 @@ namespace Server
|
||||
|
||||
#region Location Location Location!
|
||||
public virtual void OnLocationChange(Point3D oldLocation)
|
||||
{
|
||||
{
|
||||
var items = Items;
|
||||
|
||||
if (items == null)
|
||||
@@ -4746,7 +4758,7 @@ namespace Server
|
||||
o.OnParentLocationChange(oldLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnParentLocationChange(Point3D oldLocation)
|
||||
{ }
|
||||
@@ -4858,7 +4870,7 @@ namespace Server
|
||||
int oldPileWeight = PileWeight;
|
||||
|
||||
m_ItemID = value;
|
||||
|
||||
|
||||
ReleaseWorldPackets();
|
||||
|
||||
int newPileWeight = PileWeight;
|
||||
@@ -4954,6 +4966,29 @@ namespace Server
|
||||
root.Obtained(this);
|
||||
}
|
||||
}
|
||||
// Character-bound insurance enforcement
|
||||
if (!World.Loading && Parent is Mobile newOwner)
|
||||
{
|
||||
// Murderers cannot have insured items at all
|
||||
if (newOwner.Murderer)
|
||||
{
|
||||
if (Insured)
|
||||
{
|
||||
Insured = false;
|
||||
InsuredBy = Serial.MinusOne;
|
||||
newOwner.SendMessage("The Insurance Agency will not cover items owned by murderers.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Character-bound insurance enforcement
|
||||
if (Insured && InsuredBy != Serial.MinusOne && newOwner.Serial != InsuredBy)
|
||||
{
|
||||
Insured = false;
|
||||
InsuredBy = Serial.MinusOne;
|
||||
newOwner.SendMessage("The insurance on this item has been removed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Decorator)]
|
||||
@@ -5432,12 +5467,12 @@ namespace Server
|
||||
}
|
||||
|
||||
okay = ((m_OpenSlots >> i) & match) == match;
|
||||
|
||||
|
||||
if (okay)
|
||||
{
|
||||
z += i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!okay)
|
||||
{
|
||||
@@ -6178,7 +6213,7 @@ namespace Server
|
||||
{
|
||||
m_Serial = Serial.NewItem;
|
||||
m_Map = Map.Internal;
|
||||
|
||||
|
||||
m_Light = LightType.Empty;
|
||||
|
||||
m_Amount = 1;
|
||||
@@ -6255,17 +6290,17 @@ namespace Server
|
||||
public List<ItemSocket> Sockets { get; private set; }
|
||||
|
||||
public void AttachSocket(ItemSocket socket)
|
||||
{
|
||||
if(Sockets == null)
|
||||
{
|
||||
Sockets = new List<ItemSocket>();
|
||||
}
|
||||
{
|
||||
if (Sockets == null)
|
||||
{
|
||||
Sockets = new List<ItemSocket>();
|
||||
}
|
||||
|
||||
Sockets.Add(socket);
|
||||
socket.Owner = this;
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
Sockets.Add(socket);
|
||||
socket.Owner = this;
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public bool RemoveSocket<T>()
|
||||
{
|
||||
@@ -6297,26 +6332,26 @@ namespace Server
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public T GetSocket<T>() where T : ItemSocket
|
||||
{
|
||||
|
||||
public T GetSocket<T>() where T : ItemSocket
|
||||
{
|
||||
if (Sockets == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return Sockets.FirstOrDefault(s => s.GetType() == typeof(T)) as T;
|
||||
}
|
||||
|
||||
public T GetSocket<T>(Func<T, bool> predicate) where T : ItemSocket
|
||||
{
|
||||
return Sockets.FirstOrDefault(s => s.GetType() == typeof(T)) as T;
|
||||
}
|
||||
|
||||
public T GetSocket<T>(Func<T, bool> predicate) where T : ItemSocket
|
||||
{
|
||||
if (Sockets == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return Sockets.FirstOrDefault(s => s.GetType() == typeof(T) && (predicate == null || predicate(s as T))) as T;
|
||||
}
|
||||
return Sockets.FirstOrDefault(s => s.GetType() == typeof(T) && (predicate == null || predicate(s as T))) as T;
|
||||
}
|
||||
|
||||
public ItemSocket GetSocket(Type type)
|
||||
{
|
||||
@@ -6329,14 +6364,14 @@ namespace Server
|
||||
}
|
||||
|
||||
public bool HasSocket<T>()
|
||||
{
|
||||
{
|
||||
if (Sockets == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Sockets.Any(s => s.GetType() == typeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasSocket(Type t)
|
||||
{
|
||||
@@ -6351,71 +6386,71 @@ namespace Server
|
||||
}
|
||||
|
||||
public class ItemSocket
|
||||
{
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Item Owner { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime Expires { get; set; }
|
||||
|
||||
public virtual TimeSpan TickDuration { get { return TimeSpan.FromMinutes(1); } }
|
||||
|
||||
public Timer Timer { get; set; }
|
||||
{
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Item Owner { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime Expires { get; set; }
|
||||
|
||||
public virtual TimeSpan TickDuration { get { return TimeSpan.FromMinutes(1); } }
|
||||
|
||||
public Timer Timer { get; set; }
|
||||
|
||||
public ItemSocket()
|
||||
: this(TimeSpan.Zero)
|
||||
{
|
||||
}
|
||||
|
||||
public ItemSocket(TimeSpan duration)
|
||||
{
|
||||
if(duration != TimeSpan.Zero)
|
||||
{
|
||||
Expires = DateTime.UtcNow + duration;
|
||||
|
||||
BeginTimer();
|
||||
}
|
||||
}
|
||||
|
||||
protected void BeginTimer()
|
||||
{
|
||||
EndTimer();
|
||||
|
||||
Timer = Timer.DelayCall(TickDuration, TickDuration, OnTick);
|
||||
|
||||
public ItemSocket(TimeSpan duration)
|
||||
{
|
||||
if (duration != TimeSpan.Zero)
|
||||
{
|
||||
Expires = DateTime.UtcNow + duration;
|
||||
|
||||
BeginTimer();
|
||||
}
|
||||
}
|
||||
|
||||
protected void BeginTimer()
|
||||
{
|
||||
EndTimer();
|
||||
|
||||
Timer = Timer.DelayCall(TickDuration, TickDuration, OnTick);
|
||||
Timer.Start();
|
||||
}
|
||||
|
||||
protected void EndTimer()
|
||||
{
|
||||
if(Timer != null)
|
||||
{
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnTick()
|
||||
{
|
||||
if(Expires < DateTime.UtcNow || Owner.Deleted)
|
||||
{
|
||||
Remove();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Remove()
|
||||
{
|
||||
EndTimer();
|
||||
|
||||
Owner.RemoveItemSocket(this);
|
||||
}
|
||||
|
||||
public virtual void OnRemoved()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
protected void EndTimer()
|
||||
{
|
||||
if (Timer != null)
|
||||
{
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnTick()
|
||||
{
|
||||
if (Expires < DateTime.UtcNow || Owner.Deleted)
|
||||
{
|
||||
Remove();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Remove()
|
||||
{
|
||||
EndTimer();
|
||||
|
||||
Owner.RemoveItemSocket(this);
|
||||
}
|
||||
|
||||
public virtual void OnRemoved()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnOwnerDuped(Item newItem)
|
||||
{
|
||||
@@ -6451,46 +6486,46 @@ namespace Server
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write(Expires);
|
||||
}
|
||||
|
||||
public virtual void Deserialize(Item owner, GenericReader reader)
|
||||
{
|
||||
reader.ReadInt(); // version
|
||||
|
||||
Expires = reader.ReadDateTime();
|
||||
|
||||
if(Expires != DateTime.MinValue)
|
||||
{
|
||||
if(Expires < DateTime.UtcNow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
BeginTimer();
|
||||
}
|
||||
}
|
||||
|
||||
owner.AttachSocket(this);
|
||||
}
|
||||
|
||||
public static void Save(ItemSocket socket, GenericWriter writer)
|
||||
{
|
||||
writer.Write(socket.GetType().Name);
|
||||
socket.Serialize(writer);
|
||||
}
|
||||
|
||||
public static void Load(Item item, GenericReader reader)
|
||||
{
|
||||
var typeName = ScriptCompiler.FindTypeByName(reader.ReadString());
|
||||
public virtual void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write(Expires);
|
||||
}
|
||||
|
||||
public virtual void Deserialize(Item owner, GenericReader reader)
|
||||
{
|
||||
reader.ReadInt(); // version
|
||||
|
||||
Expires = reader.ReadDateTime();
|
||||
|
||||
if (Expires != DateTime.MinValue)
|
||||
{
|
||||
if (Expires < DateTime.UtcNow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
BeginTimer();
|
||||
}
|
||||
}
|
||||
|
||||
owner.AttachSocket(this);
|
||||
}
|
||||
|
||||
public static void Save(ItemSocket socket, GenericWriter writer)
|
||||
{
|
||||
writer.Write(socket.GetType().Name);
|
||||
socket.Serialize(writer);
|
||||
}
|
||||
|
||||
public static void Load(Item item, GenericReader reader)
|
||||
{
|
||||
var typeName = ScriptCompiler.FindTypeByName(reader.ReadString());
|
||||
var socket = Activator.CreateInstance(typeName) as ItemSocket;
|
||||
|
||||
socket.Deserialize(item, reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user