## Summary - Adds `Mobile.Murderer` virtual property and consolidates kill-threshold checks across the codebase - Tracks ping-pong count: how many times a player crosses the 5-kill murderer threshold (T2A/UOR/UOTD only, disabled on LBR+) - Adds `[CommandProperty]` to view a player's ping-pong count via the admin panel - After enough ping-pongs, player is permanently flagged as a murderer regardless of kill count - Accounts for perma-red players with low kills in murderer status transition notifications - Implements era-appropriate "I must consider my sins" speech responses: - **T2A**: contextual cliloc flavor text (502122–502126) - **UOR–AOS**: raw short/long-term murder counts + ping-pong count if applicable - **SE+**: localized stats message (1114370) - Refactors kill-report logic out of `Keywords.cs` into `PlayerMurderSystem.ReportKillsToSelf` ## Testing - [x] Thoroughly tested and self reviewed - [x] Test T2A "I must consider my sins" behaviour over all scenarios. - [x] Test UOR "I must consider my sins" behaviour over all scenarios. - [x] Test that LBR does not have ping pongs enabled (I must consider my sins) - [x] Test serialization cross over from v0 -> v1 increments 1 ping pong if player is already red. ## Notes * Manually setting kills to 5 does not trigger a ping pong, it must go through the actual murder system. This includes if the kills were manually set to 5 and then migrated (as manually setting kills to 5 never adds the player into the murder system - it only happens via ReportMurderer). This is arguably a bug in the existing system, but one that currently only ever happens via staff interaction. * Thieves guild SuspendOnMurder specifically checks for kills > 0. This means a person with 0 shorts but 5 ping pongs (flagged as murderer) can steal. This may be accurate, as according to a forum post this is how it works on UOSA which is the T2A gold standard. * This doesn't implement Pre-T2A behaviour which should be that "I must consider my sins" does nothing at all. The reason I didn't implement it for Pre-T2A is then it 100% have to sit behind a feature flag. I don't mind adding it as a feature flag, just let me know.
111 lines
3 KiB
C#
111 lines
3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using ModernUO.Serialization;
|
|
using Server.Mobiles;
|
|
|
|
namespace Server.Engines.PlayerMurderSystem;
|
|
|
|
[SerializationGenerator(1)]
|
|
public partial class MurderContext
|
|
{
|
|
[SerializableField(0)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private TimeSpan _shortTermElapse;
|
|
|
|
[SerializableField(1)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private TimeSpan _longTermElapse;
|
|
|
|
[SerializableProperty(2)]
|
|
[CommandProperty(AccessLevel.GameMaster)]
|
|
public int ShortTermMurders
|
|
{
|
|
get => _shortTermMurders;
|
|
set => _shortTermMurders = Math.Max(value, 0);
|
|
}
|
|
|
|
[SerializableField(3)]
|
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
|
private int _pingPong;
|
|
|
|
private void MigrateFrom(V0Content content)
|
|
{
|
|
_shortTermElapse = content.ShortTermElapse;
|
|
_longTermElapse = content.LongTermElapse;
|
|
_shortTermMurders = content.ShortTermMurders;
|
|
// Players already at >= 5 kills have crossed the threshold at least once
|
|
_pingPong = _player.Kills >= 5 ? 1 : 0;
|
|
}
|
|
|
|
public PlayerMobile _player;
|
|
|
|
public PlayerMobile Player => _player;
|
|
|
|
// Wall clock time for next short or long term expiration
|
|
internal DateTime _nextElapse;
|
|
|
|
public MurderContext(PlayerMobile player) => _player = player;
|
|
|
|
public void ResetKillTime()
|
|
{
|
|
var gameTime = _player.GameTime;
|
|
|
|
if (ShortTermMurders > 0)
|
|
{
|
|
ShortTermElapse = gameTime + PlayerMurderSystem.ShortTermMurderDuration;
|
|
}
|
|
|
|
if (_player.Kills > 0)
|
|
{
|
|
LongTermElapse = gameTime + PlayerMurderSystem.LongTermMurderDuration;
|
|
}
|
|
}
|
|
|
|
public void DecayKills()
|
|
{
|
|
var gameTime = _player.GameTime;
|
|
|
|
if (ShortTermMurders > 0 && _shortTermElapse < gameTime)
|
|
{
|
|
ShortTermElapse += PlayerMurderSystem.ShortTermMurderDuration;
|
|
--ShortTermMurders;
|
|
}
|
|
|
|
if (_player.Kills > 0 && _longTermElapse < gameTime)
|
|
{
|
|
LongTermElapse += PlayerMurderSystem.LongTermMurderDuration;
|
|
--_player.Kills;
|
|
}
|
|
}
|
|
|
|
public bool CanRemove() => _pingPong <= 0 && _shortTermMurders <= 0 && _player.Kills <= 0;
|
|
|
|
public bool CheckStart()
|
|
{
|
|
_nextElapse = DateTime.MaxValue;
|
|
|
|
var now = Core.Now;
|
|
var gameTime = _player.GameTime;
|
|
|
|
if (ShortTermMurders > 0)
|
|
{
|
|
_nextElapse = now + (ShortTermElapse - gameTime);
|
|
}
|
|
|
|
if (_player.Kills > 0)
|
|
{
|
|
_nextElapse = Utility.Min(_nextElapse, now + (LongTermElapse - gameTime));
|
|
}
|
|
|
|
return _nextElapse != DateTime.MaxValue;
|
|
}
|
|
|
|
public class EqualityComparer : IEqualityComparer<MurderContext>
|
|
{
|
|
public static EqualityComparer Default { get; } = new ();
|
|
|
|
public bool Equals(MurderContext x, MurderContext y) => x?._player == y?._player;
|
|
|
|
public int GetHashCode(MurderContext context) => context._player?.GetHashCode() ?? 0;
|
|
}
|
|
}
|