ModernUO/Projects/UOContent/Items/Weapons/Abilities/WeaponAbilityPackets.cs
mark1145 053dbcbad0
fix: Fixes ignoring mobs, champions, party crash, slayer rarity, boat speedhack, etc (#1222)
* Movie ignore mobiles to Mobile class
* Allow necromancer familiars to ignore mobiles
* ChampionSpawn should not quietly fail when creating new spawn
* Fix client party crash bug: 2 people partied, the leader logs out, other client is hung
* Fix spellbooks creating with magery/meditation only and creating magery multiple times
* Fix BaseRunicTool.GetRandomSlayer() creating more undead slayers than intended
* Do not allow players to dismount each other whilst mounted
* Fix AOS onwards damage increase tooltip and wrong formula in AOS
* Fix monsters killing other monster revenants + animate dead should not attack player pets + other animates
* Fix fire steed having loot pack added twice
* Fix oaks spawn not able to create Unicorns + Kirins via Activator.CreateInstace() due to constructor having name as parametr
* Fix ignoreMobiles flag not propagated to client for non-players.
* Fix harrower tents not leeching from players
* Fix boats speedhacking around the map
* Fix bless, agility etc. not renewing duration
* Fix reveal always worked
* Fix empty constructor for steeds so they don't throw now.
2022-10-31 22:16:50 -07:00

57 lines
1.7 KiB
C#

using System.Buffers;
using System.Runtime.CompilerServices;
using Server.Network;
namespace Server.Items
{
public static class WeaponAbilityPackets
{
public static unsafe void Configure()
{
IncomingPackets.RegisterEncoded(0x19, true, &SetAbility);
}
public static void SetAbility(NetState state, IEntity e, EncodedReader reader)
{
var m = state.Mobile;
var index = reader.ReadInt32();
if (index >= 1 && index < WeaponAbility.Abilities.Length)
{
if (m.Mounted && index == 6) //dismount
{
WeaponAbility.ClearCurrentAbility(m);
m.SendLocalizedMessage(1061283); // You cannot perform that attack while mounted!
return;
}
WeaponAbility.SetCurrentAbility(m, WeaponAbility.Abilities[index]);
}
else
{
WeaponAbility.ClearCurrentAbility(m);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void SendClearWeaponAbility(this NetState ns) =>
ns?.Send(stackalloc byte[] { 0xBF, 0x00, 0x5, 0x00, 0x21 });
public static void SendToggleSpecialAbility(this NetState ns, int abilityId, bool active)
{
if (ns.CannotSendPackets())
{
return;
}
var writer = new SpanWriter(stackalloc byte[8]);
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)8);
writer.Write((short)0x25);
writer.Write((short)abilityId);
writer.Write(active);
ns.Send(writer.Span);
}
}
}