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.
This commit is contained in:
mark1145 2022-10-31 22:16:50 -07:00 • committed by GitHub
parent 910e06767b
commit 053dbcbad0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 871 additions and 454 deletions

View file

@ -20,11 +20,14 @@ using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Regions;
using Server.Logging;
using Server.Utilities;
namespace Server.Engines.CannedEvil
{
public class ChampionSpawn : Item
{
private static readonly ILogger logger = LogFactory.GetLogger(typeof(ChampionSpawn));
private bool m_Active;
private ChampionSpawnType m_Type;
private List<Mobile> m_Creatures;
@ -597,11 +600,11 @@ namespace Server.Engines.CannedEvil
{
if (gainedPath)
{
m.SendLocalizedMessage(1054032); // You have gained a path in Valor!
pm.SendLocalizedMessage(1054032); // You have gained a path in Valor!
}
else
{
m.SendLocalizedMessage(1054030); // You have gained in Valor!
pm.SendLocalizedMessage(1054030); // You have gained in Valor!
}
// No delay on Valor gains
@ -682,10 +685,18 @@ namespace Server.Engines.CannedEvil
try
{
Champion = Activator.CreateInstance(ChampionSpawnInfo.GetInfo(m_Type).Champion) as Mobile;
Champion = ChampionSpawnInfo.GetInfo(m_Type).Champion.CreateInstance<Mobile>();
}
catch (Exception e)
{ Console.WriteLine($"Exception creating champion {m_Type}: {e}"); }
{
logger.Error(
e,
"Failed to spawn champion \"{MobileType}\" at {Location} ({Map}).",
m_Type,
Location,
Map
);
}
if (Champion != null)
{
@ -851,12 +862,21 @@ namespace Server.Engines.CannedEvil
public Mobile Spawn(params Type[] types)
{
var type = types[Utility.Random(types.Length)];
try
{
return Activator.CreateInstance(types[Utility.Random(types.Length)]) as Mobile;
return type.CreateInstance<Mobile>();
}
catch
catch (Exception e)
{
logger.Error(
e,
"Failed to spawn minion \"{Type}\" for champion {ChampionSpawnType} at {Location} ({Map}).",
type,
m_Type,
Location,
Map
);
return null;
}
}

View file

@ -106,9 +106,15 @@ namespace Server.Engines.CannedEvil
}
}
}
catch
catch (Exception e)
{
logger.Warning($"Failed to generate champion spawn {entry.m_ChampType.FullName} at {entry.m_SignLocation} ({entry.m_Map})");
logger.Error(
e,
"Failed to generate champion \"{Type}\" at {Location} ({Map}).",
entry.m_ChampType.FullName,
entry.m_SignLocation,
entry.m_Map
);
}
}
}

View file

@ -4,9 +4,10 @@ namespace Server.Mobiles
{
public class UnholySteed : BaseMount
{
public override string DefaultName => "a dark steed";
[Constructible]
public UnholySteed()
: base("a dark steed", 0x74, 0x3EA7, AIType.AI_Melee, FightMode.Aggressor)
public UnholySteed() : base(0x74, 0x3EA7, AIType.AI_Melee, FightMode.Aggressor)
{
SetStr(496, 525);
SetDex(86, 105);

View file

@ -4,9 +4,9 @@ namespace Server.Mobiles
{
public class HolySteed : BaseMount
{
public override string DefaultName => "a silver steed";
[Constructible]
public HolySteed()
: base("a silver steed", 0x75, 0x3EA8, AIType.AI_Melee, FightMode.Aggressor)
public HolySteed() : base(0x75, 0x3EA8, AIType.AI_Melee, FightMode.Aggressor)
{
SetStr(496, 525);
SetDex(86, 105);

View file

@ -8,9 +8,10 @@ namespace Server.Factions
public const int GoldPrice = 3000;
private Faction m_Faction;
public override string DefaultName => "a war horse";
[Constructible]
public FactionWarHorse(Faction faction = null)
: base("a war horse", 0xE2, 0x3EA0, AIType.AI_Melee, FightMode.Aggressor)
public FactionWarHorse(Faction faction = null) : base(0xE2, 0x3EA0, AIType.AI_Melee, FightMode.Aggressor)
{
BaseSoundID = 0xA8;

View file

@ -195,7 +195,7 @@ namespace Server.Engines.PartySystem
m.Party = this;
Span<byte> memberList =
stackalloc byte[PartyPackets.GetPartyMemberListPacketLength(this)].InitializePacket();
stackalloc byte[PartyPackets.GetPartyMemberListPacketLength(Count)].InitializePacket();
Span<byte> attrsPacket = stackalloc byte[OutgoingMobilePackets.MobileAttributesPacketLength].InitializePacket();
for (var i = 0; i < Members.Count; ++i)
@ -216,12 +216,7 @@ namespace Server.Engines.PartySystem
}
}
public void OnAccept(Mobile from)
{
OnAccept(from, false);
}
public void OnAccept(Mobile from, bool force)
public void OnAccept(Mobile from, bool force = false)
{
var ourFaction = Faction.Find(Leader);
var theirFaction = Faction.Find(from);
@ -289,28 +284,33 @@ namespace Server.Engines.PartySystem
return;
}
Span<byte> removeMember =
stackalloc byte[PartyPackets.GetPartyRemoveMemberPacketLength(this)].InitializePacket();
var removed = false;
for (var i = 0; i < Members.Count; i++)
{
if (Members[i].Mobile == m)
{
Members.RemoveAt(i);
m.NetState.SendPartyRemoveMember(m.Serial);
m.Party = null;
m.SendLocalizedMessage(1005451); // You have been removed from the party.
PartyPackets.CreatePartyRemoveMember(removeMember, m.Serial, this);
SendToAll(removeMember);
SendToAll(1005452); // A player has been removed from your party.
removed = true;
break;
}
}
if (removed)
{
Span<byte> removeMember =
stackalloc byte[PartyPackets.GetPartyRemoveMemberPacketLength(Count)].InitializePacket();
// Send empty party to the player removed
m.NetState.SendPartyRemoveMember(m.Serial);
m.Party = null;
m.SendLocalizedMessage(1005451); // You have been removed from the party.
PartyPackets.CreatePartyRemoveMember(removeMember, m.Serial, this);
SendToAll(removeMember);
SendToAll(1005452); // A player has been removed from your party.
}
if (Members.Count == 1)
{
SendToAll(1005450); // The last person has left the party...

View file

@ -23,7 +23,7 @@ namespace Server.Engines.PartySystem
public static class PartyPackets
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetPartyMemberListPacketLength(Party p) => 7 + p.Count * 4;
public static int GetPartyMemberListPacketLength(int partyCount) => 7 + partyCount * 4;
public static void CreatePartyMemberList(Span<byte> buffer, Party p)
{
@ -32,15 +32,16 @@ namespace Server.Engines.PartySystem
return;
}
var length = GetPartyMemberListPacketLength(p);
var count = p.Count;
var length = GetPartyMemberListPacketLength(count);
var writer = new SpanWriter(buffer);
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)length);
writer.Write((ushort)0x06); // Sub-packet
writer.Write((byte)0x01); // Command
writer.Write((byte)p.Count);
writer.Write((byte)count);
for (var i = 0; i < p.Count; ++i)
for (var i = 0; i < count; ++i)
{
writer.Write(p[i].Mobile.Serial);
}
@ -53,14 +54,14 @@ namespace Server.Engines.PartySystem
return;
}
Span<byte> buffer = stackalloc byte[GetPartyMemberListPacketLength(p)];
Span<byte> buffer = stackalloc byte[GetPartyMemberListPacketLength(p.Count)];
CreatePartyMemberList(buffer, p);
ns.Send(buffer);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetPartyRemoveMemberPacketLength(Party p) => 11 + (p?.Count * 4 ?? 0);
public static int GetPartyRemoveMemberPacketLength(int partyCount) => 11 + partyCount * 4;
public static void SendPartyRemoveMember(this NetState ns, Serial m, Party p = null)
{
@ -69,7 +70,7 @@ namespace Server.Engines.PartySystem
return;
}
Span<byte> buffer = stackalloc byte[GetPartyRemoveMemberPacketLength(p)];
Span<byte> buffer = stackalloc byte[GetPartyRemoveMemberPacketLength(p?.Count ?? 0)];
CreatePartyRemoveMember(buffer, m, p);
ns.Send(buffer);
@ -82,14 +83,14 @@ namespace Server.Engines.PartySystem
return;
}
var length = GetPartyRemoveMemberPacketLength(p);
var count = p?.Count ?? 0;
var length = GetPartyRemoveMemberPacketLength(count);
var writer = new SpanWriter(buffer);
writer.Write((byte)0xBF); // Packet ID
writer.Write((ushort)length);
writer.Write((ushort)0x06); // Sub-packet
writer.Write((byte)0x02); // Command
var count = p?.Count ?? 0;
writer.Write((byte)count);
writer.Write(removed);

View file

@ -218,13 +218,13 @@ namespace Server
m_Timer = new InternalTimer(this);
m_Timer.Start();
source.m_hontime = Core.Now + TimeSpan.FromMinutes(40);
source._honorTime = Core.Now + TimeSpan.FromMinutes(40);
Timer.StartTimer(
TimeSpan.FromMinutes(40),
() =>
{
if (source.m_hontime < Core.Now && source.SentHonorContext != null)
if (source._honorTime < Core.Now && source.SentHonorContext != null)
{
Cancel();
}

View file

@ -109,6 +109,7 @@ public static class ValorVirtue
// Your challenge is heard by the Champion of this region! Beware its wrath!
from.SendLocalizedMessage(1054037);
idol.Spawn.Start();
idol.Spawn.ActivatedByValor = true;
// Uncomment to not allow advancing level after starting with valor.
// idol.Spawn.HasBeenAdvanced = true;
}