Files
abysmal-isle/Scripts/Misc/EquipLastWeapon.cs
Unstable Kitsune b918192e4e Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
2023-11-28 23:20:26 -05:00

48 lines
1.5 KiB
C#

using System;
using Server;
using Server.Mobiles;
using Server.Items;
namespace Server.Network
{
public class EquipLastWeaponPacket
{
public static void Initialize()
{
PacketHandlers.RegisterEncoded(0x1E, true, new OnEncodedPacketReceive(EquipLastWeaponRequest));
}
public static void EquipLastWeaponRequest(NetState state, IEntity e, EncodedReader reader)
{
PlayerMobile from = state.Mobile as PlayerMobile;
if (from == null || from.Backpack == null)
return;
if (from.IsStaff() || Core.TickCount - from.NextActionTime >= 0)
{
BaseWeapon toEquip = from.LastWeapon;
BaseWeapon toDisarm = from.FindItemOnLayer(Layer.OneHanded) as BaseWeapon;
if (toDisarm == null)
toDisarm = from.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon;
if (toDisarm != null)
{
from.Backpack.DropItem(toDisarm);
from.NextActionTime = Core.TickCount + Mobile.ActionDelay;
}
if (toEquip != toDisarm && toEquip != null && toEquip.Movable && toEquip.IsChildOf(from.Backpack))
{
from.EquipItem(toEquip);
from.NextActionTime = Core.TickCount + Mobile.ActionDelay;
}
}
else
{
from.SendActionMessage();
}
}
}
}