fix: Fixes boat movement & moves weapon ability out of core (#750)

* Fixes boats only moving once.
* Removes event sink for weapon ability
* Moves weapon ability packets out of the core.
This commit is contained in:
Kamron Batman 2021-08-30 21:30:09 -07:00 • committed by GitHub
parent c789a7f78a
commit fd59b080f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 142 additions and 130 deletions

View file

@ -3,9 +3,8 @@ using System;
namespace Server.Items
{
/// <summary>
/// This devastating strike is most effective against those who are in good health and whose reserves of mana are low, or
/// vice
/// versa.
/// This devastating strike is most effective against those who are in good health and whose reserves
/// of mana are low, or vice versa.
/// </summary>
public class ConcussionBlow : WeaponAbility
{

View file

@ -132,15 +132,17 @@ namespace Server.Items
{
var mana = BaseMana;
var skillTotal = GetSkill(from, SkillName.Swords) + GetSkill(from, SkillName.Macing)
+ GetSkill(from, SkillName.Fencing) +
GetSkill(from, SkillName.Archery) +
GetSkill(from, SkillName.Parry)
+ GetSkill(from, SkillName.Lumberjacking) +
GetSkill(from, SkillName.Stealth)
+ GetSkill(from, SkillName.Poisoning) +
GetSkill(from, SkillName.Bushido) +
GetSkill(from, SkillName.Ninjitsu);
var skillTotal =
GetSkill(from, SkillName.Swords) +
GetSkill(from, SkillName.Macing) +
GetSkill(from, SkillName.Fencing) +
GetSkill(from, SkillName.Archery) +
GetSkill(from, SkillName.Parry) +
GetSkill(from, SkillName.Lumberjacking) +
GetSkill(from, SkillName.Stealth) +
GetSkill(from, SkillName.Poisoning) +
GetSkill(from, SkillName.Bushido) +
GetSkill(from, SkillName.Ninjitsu);
if (skillTotal >= 300.0)
{
@ -196,9 +198,11 @@ namespace Server.Items
}
/* <UBWS> */
if (weapon.WeaponAttributes.UseBestSkill > 0 && (from.Skills.Swords.Base >= reqSkill ||
from.Skills.Macing.Base >= reqSkill ||
from.Skills.Fencing.Base >= reqSkill))
if (weapon.WeaponAttributes.UseBestSkill > 0 &&
(from.Skills.Swords.Base >= reqSkill ||
from.Skills.Macing.Base >= reqSkill ||
from.Skills.Fencing.Base >= reqSkill)
)
{
return true;
}
@ -394,23 +398,6 @@ namespace Server.Items
}
}
public static void Initialize()
{
EventSink.SetAbility += EventSink_SetAbility;
}
private static void EventSink_SetAbility(Mobile m, int index)
{
if (index == 0)
{
ClearCurrentAbility(m);
}
else if (index >= 1 && index < Abilities.Length)
{
SetCurrentAbility(m, Abilities[index]);
}
}
private static void AddContext(Mobile m, WeaponAbilityContext context)
{
m_PlayersTable[m] = context;
@ -418,21 +405,12 @@ namespace Server.Items
private static void RemoveContext(Mobile m)
{
var context = GetContext(m);
if (context != null)
if (m_PlayersTable.Remove(m, out var context))
{
RemoveContext(m, context);
context.Timer?.Stop();
}
}
private static void RemoveContext(Mobile m, WeaponAbilityContext context)
{
m_PlayersTable.Remove(m);
context.Timer.Stop();
}
private static WeaponAbilityContext GetContext(Mobile m)
{
m_PlayersTable.TryGetValue(m, out var context);

View file

@ -0,0 +1,50 @@
using System.Buffers;
using System.Runtime.CompilerServices;
using Server.Network;
namespace Server.Items
{
public static class WeaponAbilityPackets
{
public static 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)
{
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 == null)
{
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);
}
}
}

View file

@ -1342,7 +1342,7 @@ namespace Server.Multis
Order = BoatOrder.Move;
_moveTimerToken.Cancel();
Timer.StartTimer(interval, StopBoat, out _moveTimerToken);
Timer.StartTimer(interval, single ? 1 : 0, StopBoat, out _moveTimerToken);
return true;
}

View file

@ -1,6 +1,6 @@
using System;
using Server.Items;
using Server.Mobiles;
using Server.Network;
namespace Server.Spells.Bushido
{