feat: Adds PlayerDeathEvent and CreatureDeathEvent using code generated events (#1927)
### Summary - Adds [Code Generated Events](https://github.com/modernuo/CodeGeneratedEvents) - Removes EventSink.PlayerDeath - Adds `PlayerDeathEvent` and `CreatureDeathEvent` using code generated events > [!Important] > **Developer Note** > Use `[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]` instead of `EventSink.PlayerDeath` delegate > Check this commit for examples of how to use this.
This commit is contained in:
parent
d5984ce058
commit
95cd8749a3
26 changed files with 191 additions and 135 deletions
|
|
@ -34,14 +34,6 @@ public static partial class EventSink
|
|||
public static event Action<Mobile> Disconnected;
|
||||
public static void InvokeDisconnected(Mobile m) => Disconnected?.Invoke(m);
|
||||
|
||||
public static event Action<Mobile> PlayerDeath;
|
||||
public static void InvokePlayerDeath(Mobile m) => PlayerDeath?.Invoke(m);
|
||||
|
||||
public static event Action<Mobile, int> VirtueMacroRequest;
|
||||
|
||||
public static void InvokeVirtueMacroRequest(Mobile mobile, int virtueID) =>
|
||||
VirtueMacroRequest?.Invoke(mobile, virtueID);
|
||||
|
||||
public static event Action<Mobile, Mobile> PaperdollRequest;
|
||||
|
||||
public static void InvokePaperdollRequest(Mobile beholder, Mobile beheld) =>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Network;
|
||||
|
||||
|
|
|
|||
|
|
@ -2847,6 +2847,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
Layer.FacialHair
|
||||
);
|
||||
}
|
||||
|
||||
ourState.Send(facialHairPacket);
|
||||
}
|
||||
|
||||
|
|
@ -2984,6 +2985,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
Layer.FacialHair
|
||||
);
|
||||
}
|
||||
|
||||
state.Send(facialHairPacket);
|
||||
}
|
||||
|
||||
|
|
@ -3429,7 +3431,6 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
Skills[mod.Skill]?.Update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public virtual void AddSkillMod(SkillMod mod)
|
||||
|
|
@ -4826,37 +4827,34 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (!m_Player)
|
||||
{
|
||||
Delete();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_NetState.SendDeathStatus();
|
||||
|
||||
Warmode = false;
|
||||
m_NetState.SendDeathStatus();
|
||||
|
||||
BodyMod = 0;
|
||||
// Body = this.Female ? 0x193 : 0x192;
|
||||
Body = Race.GhostBody(this);
|
||||
Warmode = false;
|
||||
|
||||
var deathShroud = new Item(0x204E) { Movable = false, Layer = Layer.OuterTorso };
|
||||
BodyMod = 0;
|
||||
// Body = this.Female ? 0x193 : 0x192;
|
||||
Body = Race.GhostBody(this);
|
||||
|
||||
AddItem(deathShroud);
|
||||
var deathShroud = new Item(0x204E) { Movable = false, Layer = Layer.OuterTorso };
|
||||
|
||||
Items.Remove(deathShroud);
|
||||
Items.Insert(0, deathShroud);
|
||||
AddItem(deathShroud);
|
||||
|
||||
Poison = null;
|
||||
Combatant = null;
|
||||
Items.Remove(deathShroud);
|
||||
Items.Insert(0, deathShroud);
|
||||
|
||||
Hits = 0;
|
||||
Stam = 0;
|
||||
Mana = 0;
|
||||
Poison = null;
|
||||
Combatant = null;
|
||||
|
||||
EventSink.InvokePlayerDeath(this);
|
||||
Hits = 0;
|
||||
Stam = 0;
|
||||
Mana = 0;
|
||||
|
||||
ProcessDelta();
|
||||
ProcessDelta();
|
||||
|
||||
CheckStatTimers();
|
||||
}
|
||||
CheckStatTimers();
|
||||
}
|
||||
|
||||
public virtual bool CheckTarget(Mobile from, Target targ, object targeted) => true;
|
||||
|
|
@ -5070,7 +5068,8 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
{
|
||||
var rootItem = root as Item;
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength].InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength]
|
||||
.InitializePacket();
|
||||
|
||||
foreach (var ns in map.GetClientsInRange(from.Location))
|
||||
{
|
||||
|
|
@ -5588,7 +5587,8 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
ProcessDelta();
|
||||
|
||||
Span<byte> regBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
Span<byte> mutBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(mutatedText)].InitializePacket();
|
||||
Span<byte> mutBuffer =
|
||||
stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(mutatedText)].InitializePacket();
|
||||
|
||||
// TODO: Should this be sorted like onSpeech is below?
|
||||
for (var i = 0; i < hears.Count; ++i)
|
||||
|
|
@ -5598,7 +5598,16 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext))
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
regBuffer, Serial, Body, type, hue, 3, false, m_Language, Name, text
|
||||
regBuffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
false,
|
||||
m_Language,
|
||||
Name,
|
||||
text
|
||||
);
|
||||
|
||||
if (length != regBuffer.Length)
|
||||
|
|
@ -5612,7 +5621,16 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
else
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
mutBuffer, Serial, Body, type, hue, 3, false, m_Language, Name, mutatedText
|
||||
mutBuffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
false,
|
||||
m_Language,
|
||||
Name,
|
||||
mutatedText
|
||||
);
|
||||
|
||||
if (length != mutBuffer.Length)
|
||||
|
|
@ -6899,10 +6917,12 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
}
|
||||
}
|
||||
|
||||
var range = new Rectangle2D(m_Location.X - Core.GlobalMaxUpdateRange,
|
||||
var range = new Rectangle2D(
|
||||
m_Location.X - Core.GlobalMaxUpdateRange,
|
||||
m_Location.Y - Core.GlobalMaxUpdateRange,
|
||||
Core.GlobalMaxUpdateRange * 2 + 1,
|
||||
Core.GlobalMaxUpdateRange * 2 + 1);
|
||||
Core.GlobalMaxUpdateRange * 2 + 1
|
||||
);
|
||||
|
||||
foreach (var multi in m_Map.GetMultisInBounds(range))
|
||||
{
|
||||
|
|
@ -8072,7 +8092,8 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
m_Map == null ? Map.MobileBoundsEnumerable<T>.Empty : m_Map.GetMobilesInRange<T>(m_Location, range);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Map.ClientAtEnumerable GetClientsAt() => m_Map == null ? Map.ClientAtEnumerable.Empty : Map.GetClientsAt(m_Location);
|
||||
public Map.ClientAtEnumerable GetClientsAt() =>
|
||||
m_Map == null ? Map.ClientAtEnumerable.Empty : Map.GetClientsAt(m_Location);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Map.ClientBoundsEnumerable GetClientsInRange(int range) =>
|
||||
|
|
@ -8852,7 +8873,16 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, Body, type, hue, 3, ascii, Language, Name, text
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
ascii,
|
||||
Language,
|
||||
Name,
|
||||
text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
@ -8879,7 +8909,15 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, args
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
number,
|
||||
Name,
|
||||
args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
@ -8915,7 +8953,17 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalizedAffix(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, affixType, affix, args
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
number,
|
||||
Name,
|
||||
affixType,
|
||||
affix,
|
||||
args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
@ -8959,7 +9007,15 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (state != m_NetState && state.Mobile.CanSee(this))
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, args
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
number,
|
||||
Name,
|
||||
args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
@ -8986,7 +9042,16 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (state != m_NetState && state.Mobile.CanSee(this))
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, Body, type, hue, 3, ascii, Language, Name, text
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
ascii,
|
||||
Language,
|
||||
Name,
|
||||
text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Engines.PartySystem;
|
||||
using Server.Factions;
|
||||
using Server.Gumps;
|
||||
|
|
@ -596,6 +597,9 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
}
|
||||
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnPlayerDeath(PlayerMobile m) => m.DuelContext?.OnDeath(m, m.Corpse);
|
||||
|
||||
public void OnDeath(Mobile mob, Container corpse)
|
||||
{
|
||||
if (!Registered || !Started)
|
||||
|
|
@ -1843,7 +1847,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
|
||||
TransformationSpellHelper.RemoveContext(mob, true);
|
||||
AnimalForm.RemoveContext(mob, true);
|
||||
AnimalForm.RemoveContext(mob);
|
||||
DisguisePersistence.StopTimer(mob);
|
||||
|
||||
if (!mob.CanBeginAction<PolymorphSpell>())
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Commands;
|
||||
using Server.Commands.Generic;
|
||||
using Server.Engines.MLQuests.Gumps;
|
||||
|
|
@ -611,6 +612,7 @@ namespace Server.Engines.MLQuests
|
|||
return context;
|
||||
}
|
||||
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void HandleDeath(PlayerMobile pm)
|
||||
{
|
||||
var context = GetContext(pm);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Factions;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -99,7 +101,6 @@ namespace Server.Engines.PartySystem
|
|||
public static void Configure()
|
||||
{
|
||||
EventSink.Logout += EventSink_Logout;
|
||||
EventSink.PlayerDeath += EventSink_PlayerDeath;
|
||||
|
||||
CommandSystem.Register("ListenToParty", AccessLevel.GameMaster, ListenToParty_OnCommand);
|
||||
}
|
||||
|
|
@ -135,7 +136,8 @@ namespace Server.Engines.PartySystem
|
|||
}
|
||||
}
|
||||
|
||||
public static void EventSink_PlayerDeath(Mobile from)
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnPlayerDeathEvent(Mobile from)
|
||||
{
|
||||
var p = Get(from);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Gumps;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
|
|
@ -26,16 +27,16 @@ public class ReportMurdererGump : StaticGump<ReportMurdererGump>
|
|||
public static void Initialize()
|
||||
{
|
||||
_recentlyReportedDelay = ServerConfiguration.GetOrUpdateSetting("murderSystem.recentlyReportedDelay", TimeSpan.FromMinutes(10));
|
||||
EventSink.PlayerDeath += OnPlayerDeath;
|
||||
}
|
||||
|
||||
public static void OnPlayerDeath(Mobile m)
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnPlayerDeathEvent(PlayerMobile m)
|
||||
{
|
||||
List<Mobile> killers = null;
|
||||
HashSet<Mobile> toGive = null;
|
||||
|
||||
// Guards won't take reports of the death of a thief!
|
||||
bool notInThievesGuild = m is not PlayerMobile { NpcGuild: NpcGuild.ThievesGuild };
|
||||
bool notInThievesGuild = m.NpcGuild != NpcGuild.ThievesGuild;
|
||||
|
||||
foreach (var ai in m.Aggressors)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Events.Halloween;
|
||||
using Server.Items;
|
||||
|
|
@ -60,15 +61,13 @@ namespace Server.Engines.Events
|
|||
{
|
||||
_timer = Timer.DelayCall(tick, 0, Timer_Callback);
|
||||
_clearTimer = Timer.DelayCall(clear, 0, Clear_Callback);
|
||||
|
||||
EventSink.PlayerDeath += EventSink_PlayerDeath;
|
||||
}
|
||||
}
|
||||
|
||||
public static void EventSink_PlayerDeath(Mobile m)
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnPlayerDeathEvent(PlayerMobile pm)
|
||||
{
|
||||
if (m is PlayerMobile { Deleted: false } pm &&
|
||||
_timer.Running && !_deathQueue.Contains(pm) && _deathQueue.Count < m_DeathQueueLimit)
|
||||
if (_timer.Running && !_deathQueue.Contains(pm) && _deathQueue.Count < m_DeathQueueLimit)
|
||||
{
|
||||
_deathQueue.Add(pm);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Items;
|
||||
|
|
@ -69,6 +70,7 @@ public class DisguisePersistence : GenericPersistence
|
|||
t.Stop();
|
||||
}
|
||||
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void RemoveTimer(Mobile m)
|
||||
{
|
||||
if (Timers.Remove(m, out var t))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public partial class BaseFormTalisman : Item
|
|||
|
||||
if (parent is Mobile m)
|
||||
{
|
||||
AnimalForm.RemoveContext(m, true);
|
||||
AnimalForm.RemoveContext(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1248,7 +1248,7 @@ namespace Server
|
|||
|
||||
if (m.Skills.Ninjitsu.Value < AnimalForm.Entries[i].ReqSkill)
|
||||
{
|
||||
AnimalForm.RemoveContext(m, true);
|
||||
AnimalForm.RemoveContext(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1050,7 +1050,7 @@ namespace Server.Guilds
|
|||
}
|
||||
}
|
||||
|
||||
public static void HandleDeath(Mobile victim, Mobile killer = null)
|
||||
public static void HandleDeath(Mobile victim, Mobile killer)
|
||||
{
|
||||
if (!NewGuildSystem)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Engines.ConPVP;
|
||||
|
|
@ -155,7 +156,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
public abstract class BaseCreature : Mobile, IHonorTarget, IQuestGiver
|
||||
public abstract partial class BaseCreature : Mobile, IHonorTarget, IQuestGiver
|
||||
{
|
||||
public enum Allegiance
|
||||
{
|
||||
|
|
@ -3248,10 +3249,11 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
[GeneratedEvent(nameof(CreatureDeathEvent))]
|
||||
public static partial void CreatureDeathEvent(Mobile m);
|
||||
|
||||
public override void OnDeath(Container c)
|
||||
{
|
||||
MeerMage.StopEffect(this, false);
|
||||
|
||||
if (IsBonded)
|
||||
{
|
||||
Effects.PlaySound(this, GetDeathSound());
|
||||
|
|
@ -3312,7 +3314,7 @@ namespace Server.Mobiles
|
|||
OwnerAbandonTime = DateTime.MinValue;
|
||||
}
|
||||
|
||||
GiftOfLifeSpell.HandleDeath(this);
|
||||
CreatureDeathEvent(this);
|
||||
|
||||
CheckStatTimers();
|
||||
return;
|
||||
|
|
@ -3435,6 +3437,8 @@ namespace Server.Mobiles
|
|||
{
|
||||
c.Delete();
|
||||
}
|
||||
|
||||
CreatureDeathEvent(this);
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using ModernUO.Serialization;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Mobiles;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Items;
|
||||
|
||||
|
|
@ -65,12 +66,8 @@ namespace Server.Mobiles
|
|||
public override bool BardImmune => true;
|
||||
public override Poison PoisonImmune => Poison.Lethal;
|
||||
|
||||
public new static void Initialize()
|
||||
{
|
||||
EventSink.PlayerDeath += EventSink_PlayerDeath;
|
||||
}
|
||||
|
||||
public static void EventSink_PlayerDeath(Mobile m)
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnPlayerDeathEvent(Mobile m)
|
||||
{
|
||||
var lastKiller = m.LastKiller;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using ModernUO.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Mobiles
|
||||
|
|
@ -152,7 +153,9 @@ namespace Server.Mobiles
|
|||
|
||||
public static bool UnderEffect(Mobile m) => m_Table.ContainsKey(m);
|
||||
|
||||
public static void StopEffect(Mobile m, bool message)
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
[OnEvent(nameof(CreatureDeathEvent))]
|
||||
public static void StopEffect(Mobile m, bool message = false)
|
||||
{
|
||||
if (m_Table.Remove(m, out var timer))
|
||||
{
|
||||
|
|
@ -170,7 +173,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
if (!m.Alive)
|
||||
{
|
||||
StopEffect(m, false);
|
||||
StopEffect(m);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -197,7 +200,7 @@ namespace Server.Mobiles
|
|||
|
||||
if (!m.Alive)
|
||||
{
|
||||
StopEffect(m, false);
|
||||
StopEffect(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Accounting;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
|
|
@ -34,7 +35,6 @@ using Server.Spells.Mysticism;
|
|||
using Server.Spells.Necromancy;
|
||||
using Server.Spells.Ninjitsu;
|
||||
using Server.Spells.Second;
|
||||
using Server.Spells.Seventh;
|
||||
using Server.Spells.Sixth;
|
||||
using Server.Spells.Spellweaving;
|
||||
using Server.Targeting;
|
||||
|
|
@ -97,7 +97,7 @@ namespace Server.Mobiles
|
|||
DismountRecovery = 1070859 // You cannot mount while recovering from a dismount special maneuver.
|
||||
}
|
||||
|
||||
public class PlayerMobile : Mobile, IHonorTarget, IHasSteps
|
||||
public partial class PlayerMobile : Mobile, IHonorTarget, IHasSteps
|
||||
{
|
||||
private static bool m_NoRecursion;
|
||||
|
||||
|
|
@ -1089,7 +1089,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
else if (AnimalForm.UnderTransformation(this))
|
||||
{
|
||||
AnimalForm.RemoveContext(this, true);
|
||||
AnimalForm.RemoveContext(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2549,6 +2549,9 @@ namespace Server.Mobiles
|
|||
return res;
|
||||
}
|
||||
|
||||
[GeneratedEvent(nameof(PlayerDeathEvent))]
|
||||
public static partial void PlayerDeathEvent(PlayerMobile m);
|
||||
|
||||
public override void OnDeath(Container c)
|
||||
{
|
||||
if (m_NonAutoreinsuredItems > 0)
|
||||
|
|
@ -2563,27 +2566,14 @@ namespace Server.Mobiles
|
|||
HueMod = -1;
|
||||
NameMod = null;
|
||||
SavagePaintExpiration = TimeSpan.Zero;
|
||||
|
||||
SetHairMods(-1, -1);
|
||||
|
||||
PolymorphSpell.StopTimer(this);
|
||||
IncognitoSpell.StopTimer(this);
|
||||
DisguisePersistence.RemoveTimer(this);
|
||||
AnimalForm.RemoveContext(this, true);
|
||||
|
||||
EndAction<PolymorphSpell>();
|
||||
EndAction<IncognitoSpell>();
|
||||
|
||||
MeerMage.StopEffect(this, false);
|
||||
|
||||
if (Flying)
|
||||
{
|
||||
Flying = false;
|
||||
BuffInfo.RemoveBuff(this, BuffIcon.Fly);
|
||||
}
|
||||
|
||||
StolenItem.ReturnOnDeath(this, c);
|
||||
|
||||
if (PermaFlags.Count > 0)
|
||||
{
|
||||
PermaFlags.Clear();
|
||||
|
|
@ -2669,10 +2659,6 @@ namespace Server.Mobiles
|
|||
|
||||
Guilds.Guild.HandleDeath(this, killer);
|
||||
|
||||
MLQuestSystem.HandleDeath(this);
|
||||
|
||||
DuelContext?.OnDeath(this, c);
|
||||
|
||||
if (m_BuffTable != null)
|
||||
{
|
||||
using var queue = PooledRefQueue<BuffInfo>.Create();
|
||||
|
|
@ -2690,6 +2676,8 @@ namespace Server.Mobiles
|
|||
RemoveBuff(queue.Dequeue());
|
||||
}
|
||||
}
|
||||
|
||||
PlayerDeathEvent(this);
|
||||
}
|
||||
|
||||
public override bool MutateSpeech(List<Mobile> hears, ref string text, ref object context)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Engines.ConPVP;
|
||||
using Server.Engines.Stealables;
|
||||
using Server.Factions;
|
||||
|
|
@ -465,10 +466,13 @@ namespace Server.SkillHandlers
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void ReturnOnDeath(Mobile killed, Container corpse)
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void ReturnOnDeath(Mobile killed)
|
||||
{
|
||||
Clean();
|
||||
|
||||
var corpse = killed.Corpse;
|
||||
|
||||
foreach (var si in m_Queue)
|
||||
{
|
||||
if (si.Stolen.RootParent == corpse && si.Victim != null && !si.IsExpired)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Factions;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
|
@ -124,6 +125,13 @@ namespace Server.Spells.Fifth
|
|||
FinishSequence();
|
||||
}
|
||||
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnPlayerDeathEvent(Mobile m)
|
||||
{
|
||||
StopTimer(m);
|
||||
m.EndAction<IncognitoSpell>();
|
||||
}
|
||||
|
||||
public static void StopTimer(Mobile m)
|
||||
{
|
||||
if (_table.Remove(m, out var timerToken))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Spells.Mysticism;
|
||||
|
|
@ -25,11 +27,6 @@ public class SpellPlagueSpell : MysticSpell, ITargetingSpell<Mobile>
|
|||
|
||||
public override SpellCircle Circle => SpellCircle.Seventh;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.PlayerDeath += OnPlayerDeath;
|
||||
}
|
||||
|
||||
public override void OnCast()
|
||||
{
|
||||
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
|
||||
|
|
@ -75,6 +72,7 @@ public class SpellPlagueSpell : MysticSpell, ITargetingSpell<Mobile>
|
|||
|
||||
public static bool UnderEffect(Mobile m) => _table.ContainsKey(m);
|
||||
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static bool RemoveEffect(Mobile m)
|
||||
{
|
||||
if (_table.Remove(m, out var timer))
|
||||
|
|
@ -95,8 +93,6 @@ public class SpellPlagueSpell : MysticSpell, ITargetingSpell<Mobile>
|
|||
}
|
||||
}
|
||||
|
||||
private static void OnPlayerDeath(Mobile m) => RemoveEffect(m);
|
||||
|
||||
private static void VisualEffect(Mobile to)
|
||||
{
|
||||
to.PlaySound(0x658);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Factions;
|
||||
using Server.Mobiles;
|
||||
using Server.Spells.Fifth;
|
||||
using Server.Spells.Ninjitsu;
|
||||
using Server.Spells.Seventh;
|
||||
|
|
@ -26,11 +28,6 @@ namespace Server.Spells.Mysticism
|
|||
|
||||
public override SpellCircle Circle => SpellCircle.Fourth;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.PlayerDeath += OnPlayerDeath;
|
||||
}
|
||||
|
||||
public static bool UnderEffect(Mobile m) => _table.ContainsKey(m);
|
||||
|
||||
public override bool CheckCast()
|
||||
|
|
@ -137,6 +134,7 @@ namespace Server.Spells.Mysticism
|
|||
FinishSequence();
|
||||
}
|
||||
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void RemoveEffects(Mobile m)
|
||||
{
|
||||
if (!_table.Remove(m, out var mods))
|
||||
|
|
@ -154,10 +152,5 @@ namespace Server.Spells.Mysticism
|
|||
|
||||
BuffInfo.RemoveBuff(m, BuffIcon.StoneForm);
|
||||
}
|
||||
|
||||
private static void OnPlayerDeath(Mobile m)
|
||||
{
|
||||
RemoveEffects(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
|
@ -135,7 +136,7 @@ public class AnimalForm : NinjaSpell
|
|||
}
|
||||
else if (context != null)
|
||||
{
|
||||
RemoveContext(Caster, context, true);
|
||||
RemoveContext(Caster, context);
|
||||
Caster.Mana -= mana;
|
||||
}
|
||||
else
|
||||
|
|
@ -254,17 +255,18 @@ public class AnimalForm : NinjaSpell
|
|||
}
|
||||
}
|
||||
|
||||
public static void RemoveContext(Mobile m, bool resetGraphics)
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void RemoveContext(Mobile m)
|
||||
{
|
||||
var context = GetContext(m);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
RemoveContext(m, context, resetGraphics);
|
||||
RemoveContext(m, context);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveContext(Mobile m, AnimalFormContext context, bool resetGraphics)
|
||||
public static void RemoveContext(Mobile m, AnimalFormContext context)
|
||||
{
|
||||
_table.Remove(m);
|
||||
|
||||
|
|
@ -287,11 +289,8 @@ public class AnimalForm : NinjaSpell
|
|||
m.RemoveSkillMod(mod);
|
||||
}
|
||||
|
||||
if (resetGraphics)
|
||||
{
|
||||
m.HueMod = -1;
|
||||
m.BodyMod = 0;
|
||||
}
|
||||
m.HueMod = -1;
|
||||
m.BodyMod = 0;
|
||||
|
||||
m.FixedParticles(0x3728, 10, 13, 2023, EffectLayer.Waist);
|
||||
|
||||
|
|
@ -517,7 +516,7 @@ public class AnimalFormTimer : Timer
|
|||
{
|
||||
if (_mobile.Deleted || !_mobile.Alive || _mobile.Body != _body || _mobile.Hue != _hue)
|
||||
{
|
||||
AnimalForm.RemoveContext(_mobile, true);
|
||||
AnimalForm.RemoveContext(_mobile);
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Factions;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Spells.Fifth;
|
||||
|
||||
namespace Server.Spells.Seventh
|
||||
|
|
@ -184,6 +186,13 @@ namespace Server.Spells.Seventh
|
|||
FinishSequence();
|
||||
}
|
||||
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnPlayerDeathEvent(Mobile m)
|
||||
{
|
||||
StopTimer(m);
|
||||
m.EndAction<PolymorphSpell>();
|
||||
}
|
||||
|
||||
public static void StopTimer(Mobile m)
|
||||
{
|
||||
if (_table.Remove(m, out var timer))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
|
|
@ -70,17 +71,14 @@ namespace Server.Spells.Spellweaving
|
|||
}
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.PlayerDeath += HandleDeath;
|
||||
}
|
||||
|
||||
public override void OnCast()
|
||||
{
|
||||
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Beneficial);
|
||||
}
|
||||
|
||||
public static void HandleDeath(Mobile m)
|
||||
[OnEvent(nameof(BaseCreature.CreatureDeathEvent))]
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnDeathEvent(Mobile m)
|
||||
{
|
||||
if (_table.ContainsKey(m))
|
||||
{
|
||||
|
|
@ -130,16 +128,6 @@ namespace Server.Spells.Spellweaving
|
|||
timer.DoExpire();
|
||||
}
|
||||
|
||||
public static void OnLogin(Mobile m)
|
||||
{
|
||||
if (m?.Alive != false || _table[m] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HandleDeath_OnCallback(m);
|
||||
}
|
||||
|
||||
private class ExpireTimer : Timer
|
||||
{
|
||||
private Mobile _mobile;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@
|
|||
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
|
||||
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.2.2" />
|
||||
<PackageReference Include="Argon2.Bindings" Version="1.16.1" />
|
||||
<PackageReference Include="ModernUO.CodeGeneratedEvents.Annotations" Version="1.0.0" />
|
||||
<PackageReference Include="ModernUO.CodeGeneratedEvents.Generator" Version="1.0.3.2" PrivateAssets="all" />
|
||||
<PackageReference Include="Zstd.Binaries" Version="1.6.0" />
|
||||
|
||||
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.9.1" />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
|
||||
"version": "0.13.4"
|
||||
"version": "0.13.5"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue