Formats UO Content (#201)

This commit is contained in:
Kamron Batman 2020-08-27 18:30:38 -07:00 • committed by GitHub
parent 86b7b3aed1
commit ad3775c4d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3249 changed files with 431083 additions and 440981 deletions

View file

@ -1,62 +1,69 @@
using System;
using System.Collections.Generic;
using Server.Network;
namespace Server.Misc
{
public class AttackMessage
{
private const string AggressorFormat = "You are attacking {0}!";
private const string AggressedFormat = "{0} is attacking you!";
private const int Hue = 0x22;
private static readonly TimeSpan Delay = TimeSpan.FromMinutes(1.0);
public static void Initialize()
public class AttackMessage
{
EventSink.AggressiveAction += EventSink_AggressiveAction;
private const string AggressorFormat = "You are attacking {0}!";
private const string AggressedFormat = "{0} is attacking you!";
private const int Hue = 0x22;
private static readonly TimeSpan Delay = TimeSpan.FromMinutes(1.0);
public static void Initialize()
{
EventSink.AggressiveAction += EventSink_AggressiveAction;
}
public static void EventSink_AggressiveAction(AggressiveActionEventArgs e)
{
var aggressor = e.Aggressor;
var aggressed = e.Aggressed;
if (!aggressor.Player || !aggressed.Player)
return;
if (!CheckAggressions(aggressor, aggressed))
{
aggressor.LocalOverheadMessage(
MessageType.Regular,
Hue,
true,
string.Format(AggressorFormat, aggressed.Name)
);
aggressed.LocalOverheadMessage(
MessageType.Regular,
Hue,
true,
string.Format(AggressedFormat, aggressor.Name)
);
}
}
public static bool CheckAggressions(Mobile m1, Mobile m2)
{
var list = m1.Aggressors;
for (var i = 0; i < list.Count; ++i)
{
var info = list[i];
if (info.Attacker == m2 && DateTime.UtcNow < info.LastCombatTime + Delay)
return true;
}
list = m2.Aggressors;
for (var i = 0; i < list.Count; ++i)
{
var info = list[i];
if (info.Attacker == m1 && DateTime.UtcNow < info.LastCombatTime + Delay)
return true;
}
return false;
}
}
public static void EventSink_AggressiveAction(AggressiveActionEventArgs e)
{
Mobile aggressor = e.Aggressor;
Mobile aggressed = e.Aggressed;
if (!aggressor.Player || !aggressed.Player)
return;
if (!CheckAggressions(aggressor, aggressed))
{
aggressor.LocalOverheadMessage(MessageType.Regular, Hue, true,
string.Format(AggressorFormat, aggressed.Name));
aggressed.LocalOverheadMessage(MessageType.Regular, Hue, true,
string.Format(AggressedFormat, aggressor.Name));
}
}
public static bool CheckAggressions(Mobile m1, Mobile m2)
{
List<AggressorInfo> list = m1.Aggressors;
for (int i = 0; i < list.Count; ++i)
{
AggressorInfo info = list[i];
if (info.Attacker == m2 && DateTime.UtcNow < info.LastCombatTime + Delay)
return true;
}
list = m2.Aggressors;
for (int i = 0; i < list.Count; ++i)
{
AggressorInfo info = list[i];
if (info.Attacker == m1 && DateTime.UtcNow < info.LastCombatTime + Delay)
return true;
}
return false;
}
}
}