Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
2848
Scripts/Misc/AOS.cs
2848
Scripts/Misc/AOS.cs
File diff suppressed because it is too large
Load diff
|
|
@ -3,37 +3,37 @@ using Server.Accounting;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class AccountPrompt
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
if ( Accounts.Count == 0 && !Core.Service )
|
||||
{
|
||||
Console.WriteLine( "This server has no accounts." );
|
||||
Console.Write( "Do you want to create the owner account now? (y/n)" );
|
||||
public class AccountPrompt
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Accounts.Count == 0 && !Core.Service)
|
||||
{
|
||||
Console.WriteLine("This server has no accounts.");
|
||||
Console.Write("Do you want to create the owner account now? (y/n)");
|
||||
|
||||
if ( Console.ReadKey( true ).Key == ConsoleKey.Y )
|
||||
{
|
||||
Console.WriteLine();
|
||||
if (Console.ReadKey(true).Key == ConsoleKey.Y)
|
||||
{
|
||||
Console.WriteLine();
|
||||
|
||||
Console.Write( "Username: " );
|
||||
string username = Console.ReadLine();
|
||||
Console.Write("Username: ");
|
||||
string username = Console.ReadLine();
|
||||
|
||||
Console.Write( "Password: " );
|
||||
string password = Console.ReadLine();
|
||||
Console.Write("Password: ");
|
||||
string password = Console.ReadLine();
|
||||
|
||||
Account a = new Account( username, password );
|
||||
a.AccessLevel = AccessLevel.Owner;
|
||||
Account a = new Account(username, password);
|
||||
a.AccessLevel = AccessLevel.Owner;
|
||||
|
||||
Console.WriteLine( "Account created." );
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Account created.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine( "Account not created." );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Account not created.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +1,31 @@
|
|||
namespace Server.Misc
|
||||
{
|
||||
public class Animations
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.AnimateRequest += EventSink_AnimateRequest;
|
||||
}
|
||||
public class Animations
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.AnimateRequest += EventSink_AnimateRequest;
|
||||
}
|
||||
|
||||
private static void EventSink_AnimateRequest( AnimateRequestEventArgs e )
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
private static void EventSink_AnimateRequest(AnimateRequestEventArgs e)
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
|
||||
int action;
|
||||
int action;
|
||||
|
||||
switch ( e.Action )
|
||||
{
|
||||
case "bow": action = 32; break;
|
||||
case "salute": action = 33; break;
|
||||
default: return;
|
||||
}
|
||||
switch (e.Action)
|
||||
{
|
||||
case "bow":
|
||||
action = 32;
|
||||
break;
|
||||
case "salute":
|
||||
action = 33;
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
if ( from.Alive && !from.Mounted && from.Body.IsHuman )
|
||||
from.Animate( action, 5, 1, true, false, 0 );
|
||||
}
|
||||
}
|
||||
if (from.Alive && !from.Mounted && from.Body.IsHuman)
|
||||
from.Animate(action, 5, 1, true, false, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,184 +1,185 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public static partial class Assistants
|
||||
{
|
||||
private static class Settings
|
||||
{
|
||||
public const bool Enabled = false;
|
||||
public const bool KickOnFailure = true; // It will also kick clients running without assistants
|
||||
public static class Assistants
|
||||
{
|
||||
private static class Settings
|
||||
{
|
||||
[Flags]
|
||||
public enum Features : ulong
|
||||
{
|
||||
None = 0,
|
||||
|
||||
public static readonly TimeSpan HandshakeTimeout = TimeSpan.FromSeconds(30.0);
|
||||
public static readonly TimeSpan DisconnectDelay = TimeSpan.FromSeconds(15.0);
|
||||
FilterWeather = 1 << 0, // Weather Filter
|
||||
FilterLight = 1 << 1, // Light Filter
|
||||
SmartTarget = 1 << 2, // Smart Last Target
|
||||
RangedTarget = 1 << 3, // Range Check Last Target
|
||||
AutoOpenDoors = 1 << 4, // Automatically Open Doors
|
||||
DequipOnCast = 1 << 5, // Unequip Weapon on spell cast
|
||||
AutoPotionEquip = 1 << 6, // Un/re-equip weapon on potion use
|
||||
PoisonedChecks = 1 << 7, // Block heal If poisoned/Macro If Poisoned condition/Heal or Cure self
|
||||
LoopedMacros = 1 << 8, // Disallow looping or recursive macros
|
||||
UseOnceAgent = 1 << 9, // The use once agent
|
||||
RestockAgent = 1 << 10, // The restock agent
|
||||
SellAgent = 1 << 11, // The sell agent
|
||||
BuyAgent = 1 << 12, // The buy agent
|
||||
PotionHotkeys = 1 << 13, // All potion hotkeys
|
||||
RandomTargets = 1 << 14, // All random target hotkeys (not target next, last target, target self)
|
||||
ClosestTargets = 1 << 15, // All closest target hotkeys
|
||||
OverheadHealth = 1 << 16, // Health and Mana/Stam messages shown over player's heads
|
||||
AutolootAgent = 1 << 17, // The autoloot agent
|
||||
BoneCutterAgent = 1 << 18, // The bone cutter agent
|
||||
AdvancedMacros = 1 << 19, // Advanced macro engine
|
||||
AutoRemount = 1 << 20, // Auto remount after dismount
|
||||
AutoBandage = 1 << 21, // Auto bandage friends, self, last and mount option
|
||||
EnemyTargetShare = 1 << 22, // Enemy target share on guild, party or alliance chat
|
||||
FilterSeason = 1 << 23, // Season Filter
|
||||
SpellTargetShare = 1 << 24, // Spell target share on guild, party or alliance chat
|
||||
|
||||
public const string WarningMessage = "The server was unable to negotiate features with your assistant. "
|
||||
+ "You must download and run an updated version of <A HREF=\"http://uosteam.com\">UOSteam</A>"
|
||||
+ " or <A HREF=\"https://bitbucket.org/msturgill/razor-releases/downloads\">Razor</A>."
|
||||
+ "<BR><BR>Make sure you've checked the option <B>Negotiate features with server</B>, "
|
||||
+ "once you have this box checked you may log in and play normally."
|
||||
+ "<BR><BR>You will be disconnected shortly.";
|
||||
All = ulong.MaxValue
|
||||
}
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
//DisallowFeature( Features.FilterWeather );
|
||||
}
|
||||
public const bool Enabled = false;
|
||||
public const bool KickOnFailure = true; // It will also kick clients running without assistants
|
||||
|
||||
[Flags]
|
||||
public enum Features : ulong
|
||||
{
|
||||
None = 0,
|
||||
public const string WarningMessage = "The server was unable to negotiate features with your assistant. "
|
||||
+ "You must download and run an updated version of <A HREF=\"http://uosteam.com\">UOSteam</A>"
|
||||
+ " or <A HREF=\"https://bitbucket.org/msturgill/razor-releases/downloads\">Razor</A>."
|
||||
+ "<BR><BR>Make sure you've checked the option <B>Negotiate features with server</B>, "
|
||||
+ "once you have this box checked you may log in and play normally."
|
||||
+ "<BR><BR>You will be disconnected shortly.";
|
||||
|
||||
FilterWeather = 1 << 0, // Weather Filter
|
||||
FilterLight = 1 << 1, // Light Filter
|
||||
SmartTarget = 1 << 2, // Smart Last Target
|
||||
RangedTarget = 1 << 3, // Range Check Last Target
|
||||
AutoOpenDoors = 1 << 4, // Automatically Open Doors
|
||||
DequipOnCast = 1 << 5, // Unequip Weapon on spell cast
|
||||
AutoPotionEquip = 1 << 6, // Un/re-equip weapon on potion use
|
||||
PoisonedChecks = 1 << 7, // Block heal If poisoned/Macro If Poisoned condition/Heal or Cure self
|
||||
LoopedMacros = 1 << 8, // Disallow looping or recursive macros
|
||||
UseOnceAgent = 1 << 9, // The use once agent
|
||||
RestockAgent = 1 << 10, // The restock agent
|
||||
SellAgent = 1 << 11, // The sell agent
|
||||
BuyAgent = 1 << 12, // The buy agent
|
||||
PotionHotkeys = 1 << 13, // All potion hotkeys
|
||||
RandomTargets = 1 << 14, // All random target hotkeys (not target next, last target, target self)
|
||||
ClosestTargets = 1 << 15, // All closest target hotkeys
|
||||
OverheadHealth = 1 << 16, // Health and Mana/Stam messages shown over player's heads
|
||||
AutolootAgent = 1 << 17, // The autoloot agent
|
||||
BoneCutterAgent = 1 << 18, // The bone cutter agent
|
||||
AdvancedMacros = 1 << 19, // Advanced macro engine
|
||||
AutoRemount = 1 << 20, // Auto remount after dismount
|
||||
AutoBandage = 1 << 21, // Auto bandage friends, self, last and mount option
|
||||
EnemyTargetShare = 1 << 22, // Enemy target share on guild, party or alliance chat
|
||||
FilterSeason = 1 << 23, // Season Filter
|
||||
SpellTargetShare = 1 << 24, // Spell target share on guild, party or alliance chat
|
||||
public static readonly TimeSpan HandshakeTimeout = TimeSpan.FromSeconds(30.0);
|
||||
public static readonly TimeSpan DisconnectDelay = TimeSpan.FromSeconds(15.0);
|
||||
|
||||
All = ulong.MaxValue
|
||||
}
|
||||
public static Features DisallowedFeatures{ get; private set; } = Features.None;
|
||||
|
||||
public static void DisallowFeature(Features feature)
|
||||
{
|
||||
SetDisallowed(feature, true);
|
||||
}
|
||||
public static void Configure()
|
||||
{
|
||||
//DisallowFeature( Features.FilterWeather );
|
||||
}
|
||||
|
||||
public static void AllowFeature(Features feature)
|
||||
{
|
||||
SetDisallowed(feature, false);
|
||||
}
|
||||
public static void DisallowFeature(Features feature)
|
||||
{
|
||||
SetDisallowed(feature, true);
|
||||
}
|
||||
|
||||
public static void SetDisallowed(Features feature, bool value)
|
||||
{
|
||||
if (value)
|
||||
DisallowedFeatures |= feature;
|
||||
else
|
||||
DisallowedFeatures &= ~feature;
|
||||
}
|
||||
public static void AllowFeature(Features feature)
|
||||
{
|
||||
SetDisallowed(feature, false);
|
||||
}
|
||||
|
||||
public static Features DisallowedFeatures { get; private set; } = Features.None;
|
||||
}
|
||||
public static void SetDisallowed(Features feature, bool value)
|
||||
{
|
||||
if (value)
|
||||
DisallowedFeatures |= feature;
|
||||
else
|
||||
DisallowedFeatures &= ~feature;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Negotiator
|
||||
{
|
||||
private static Dictionary<Mobile, Timer> m_Dictionary = new Dictionary<Mobile, Timer>();
|
||||
private static class Negotiator
|
||||
{
|
||||
private static Dictionary<Mobile, Timer> m_Dictionary = new Dictionary<Mobile, Timer>();
|
||||
|
||||
private static TimerStateCallback OnHandshakeTimeout_Callback = OnHandshakeTimeout;
|
||||
private static TimerStateCallback OnForceDisconnect_Callback = OnForceDisconnect;
|
||||
private static TimerStateCallback OnHandshakeTimeout_Callback = OnHandshakeTimeout;
|
||||
private static TimerStateCallback OnForceDisconnect_Callback = OnForceDisconnect;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Settings.Enabled)
|
||||
{
|
||||
EventSink.Login += EventSink_Login;
|
||||
ProtocolExtensions.Register(0xFF, true, OnHandshakeResponse);
|
||||
}
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Settings.Enabled)
|
||||
{
|
||||
EventSink.Login += EventSink_Login;
|
||||
ProtocolExtensions.Register(0xFF, true, OnHandshakeResponse);
|
||||
}
|
||||
}
|
||||
|
||||
private static void EventSink_Login(LoginEventArgs e)
|
||||
{
|
||||
Mobile m = e.Mobile;
|
||||
private static void EventSink_Login(LoginEventArgs e)
|
||||
{
|
||||
Mobile m = e.Mobile;
|
||||
|
||||
if (m?.NetState != null && m.NetState.Running)
|
||||
{
|
||||
m.Send(new BeginHandshake());
|
||||
if (m?.NetState != null && m.NetState.Running)
|
||||
{
|
||||
m.Send(new BeginHandshake());
|
||||
|
||||
if (Settings.KickOnFailure)
|
||||
m.Send(new BeginHandshake());
|
||||
if (Settings.KickOnFailure)
|
||||
m.Send(new BeginHandshake());
|
||||
|
||||
if (m_Dictionary.TryGetValue(m, out Timer t))
|
||||
t?.Stop();
|
||||
if (m_Dictionary.TryGetValue(m, out Timer t))
|
||||
t?.Stop();
|
||||
|
||||
m_Dictionary[m] = t = Timer.DelayCall(Settings.HandshakeTimeout, OnHandshakeTimeout_Callback, m);
|
||||
t.Start();
|
||||
}
|
||||
}
|
||||
m_Dictionary[m] = t = Timer.DelayCall(Settings.HandshakeTimeout, OnHandshakeTimeout_Callback, m);
|
||||
t.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnHandshakeResponse(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
pvSrc.Trace(state);
|
||||
private static void OnHandshakeResponse(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
pvSrc.Trace(state);
|
||||
|
||||
if (state?.Mobile == null || !state.Running)
|
||||
return;
|
||||
if (state?.Mobile == null || !state.Running)
|
||||
return;
|
||||
|
||||
Mobile m = state.Mobile;
|
||||
if (m_Dictionary.TryGetValue( m, out Timer t ))
|
||||
{
|
||||
t?.Stop();
|
||||
Mobile m = state.Mobile;
|
||||
if (m_Dictionary.TryGetValue(m, out Timer t))
|
||||
{
|
||||
t?.Stop();
|
||||
|
||||
m_Dictionary.Remove(m);
|
||||
}
|
||||
}
|
||||
m_Dictionary.Remove(m);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnHandshakeTimeout(object state)
|
||||
{
|
||||
if (!(state is Mobile m))
|
||||
return;
|
||||
private static void OnHandshakeTimeout(object state)
|
||||
{
|
||||
if (!(state is Mobile m))
|
||||
return;
|
||||
|
||||
m_Dictionary.Remove(m);
|
||||
m_Dictionary.Remove(m);
|
||||
|
||||
// if (!Settings.KickOnFailure)
|
||||
// {
|
||||
// Console.WriteLine("Player '{0}' failed to negotiate features.", m);
|
||||
// }
|
||||
|
||||
if (m.NetState != null && m.NetState.Running)
|
||||
{
|
||||
m.SendGump(new Gumps.WarningGump(1060635, 30720, Settings.WarningMessage, 0xFFC000, 420, 250, null, null));
|
||||
if (m.NetState != null && m.NetState.Running)
|
||||
{
|
||||
m.SendGump(new WarningGump(1060635, 30720, Settings.WarningMessage, 0xFFC000, 420, 250, null, null));
|
||||
|
||||
if (m.AccessLevel <= AccessLevel.Player)
|
||||
{
|
||||
Timer t;
|
||||
m_Dictionary[m] = t = Timer.DelayCall(Settings.DisconnectDelay, OnForceDisconnect_Callback, m);
|
||||
t.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m.AccessLevel <= AccessLevel.Player)
|
||||
{
|
||||
Timer t;
|
||||
m_Dictionary[m] = t = Timer.DelayCall(Settings.DisconnectDelay, OnForceDisconnect_Callback, m);
|
||||
t.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnForceDisconnect(object state)
|
||||
{
|
||||
if (state is Mobile m)
|
||||
{
|
||||
if (m.NetState != null && m.NetState.Running)
|
||||
m.NetState.Dispose();
|
||||
private static void OnForceDisconnect(object state)
|
||||
{
|
||||
if (state is Mobile m)
|
||||
{
|
||||
if (m.NetState != null && m.NetState.Running)
|
||||
m.NetState.Dispose();
|
||||
|
||||
m_Dictionary.Remove(m);
|
||||
m_Dictionary.Remove(m);
|
||||
|
||||
Console.WriteLine("Player {0} kicked (Failed assistant handshake)", m);
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Player {0} kicked (Failed assistant handshake)", m);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class BeginHandshake : ProtocolExtension
|
||||
{
|
||||
public BeginHandshake()
|
||||
: base(0xFE, 8)
|
||||
{
|
||||
m_Stream.Write((uint)((ulong)Settings.DisallowedFeatures >> 32));
|
||||
m_Stream.Write((uint)((ulong)Settings.DisallowedFeatures & 0xFFFFFFFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private sealed class BeginHandshake : ProtocolExtension
|
||||
{
|
||||
public BeginHandshake()
|
||||
: base(0xFE, 8)
|
||||
{
|
||||
m_Stream.Write((uint)((ulong)Settings.DisallowedFeatures >> 32));
|
||||
m_Stream.Write((uint)((ulong)Settings.DisallowedFeatures & 0xFFFFFFFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,57 +4,59 @@ 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;
|
||||
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 TimeSpan Delay = TimeSpan.FromMinutes( 1.0 );
|
||||
private static TimeSpan Delay = TimeSpan.FromMinutes(1.0);
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.AggressiveAction += EventSink_AggressiveAction;
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.AggressiveAction += EventSink_AggressiveAction;
|
||||
}
|
||||
|
||||
public static void EventSink_AggressiveAction( AggressiveActionEventArgs e )
|
||||
{
|
||||
Mobile aggressor = e.Aggressor;
|
||||
Mobile aggressed = e.Aggressed;
|
||||
public static void EventSink_AggressiveAction(AggressiveActionEventArgs e)
|
||||
{
|
||||
Mobile aggressor = e.Aggressor;
|
||||
Mobile aggressed = e.Aggressed;
|
||||
|
||||
if ( !aggressor.Player || !aggressed.Player )
|
||||
return;
|
||||
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 ) );
|
||||
}
|
||||
}
|
||||
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;
|
||||
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];
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
AggressorInfo info = list[i];
|
||||
|
||||
if ( info.Attacker == m2 && DateTime.UtcNow < (info.LastCombatTime + Delay) )
|
||||
return true;
|
||||
}
|
||||
if (info.Attacker == m2 && DateTime.UtcNow < info.LastCombatTime + Delay)
|
||||
return true;
|
||||
}
|
||||
|
||||
list = m2.Aggressors;
|
||||
list = m2.Aggressors;
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
AggressorInfo info = list[i];
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
AggressorInfo info = list[i];
|
||||
|
||||
if ( info.Attacker == m1 && DateTime.UtcNow < (info.LastCombatTime + Delay) )
|
||||
return true;
|
||||
}
|
||||
if (info.Attacker == m1 && DateTime.UtcNow < info.LastCombatTime + Delay)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,78 +3,82 @@ using Server.Commands;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class AutoRestart : Timer
|
||||
{
|
||||
public static bool Enabled; // is the script enabled?
|
||||
public class AutoRestart : Timer
|
||||
{
|
||||
public static bool Enabled; // is the script enabled?
|
||||
|
||||
private static TimeSpan RestartTime = TimeSpan.FromHours( 2.0 ); // time of day at which to restart
|
||||
private static TimeSpan RestartDelay = TimeSpan.Zero; // how long the server should remain active before restart (period of 'server wars')
|
||||
private static TimeSpan RestartTime = TimeSpan.FromHours(2.0); // time of day at which to restart
|
||||
|
||||
private static TimeSpan WarningDelay = TimeSpan.FromMinutes( 1.0 ); // at what interval should the shutdown message be displayed?
|
||||
private static TimeSpan
|
||||
RestartDelay =
|
||||
TimeSpan.Zero; // how long the server should remain active before restart (period of 'server wars')
|
||||
|
||||
private static DateTime m_RestartTime;
|
||||
private static TimeSpan
|
||||
WarningDelay = TimeSpan.FromMinutes(1.0); // at what interval should the shutdown message be displayed?
|
||||
|
||||
public static bool Restarting { get; private set; }
|
||||
private static DateTime m_RestartTime;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "Restart", AccessLevel.Administrator, Restart_OnCommand );
|
||||
new AutoRestart().Start();
|
||||
}
|
||||
public AutoRestart() : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
|
||||
{
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
|
||||
public static void Restart_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
if ( Restarting )
|
||||
{
|
||||
e.Mobile.SendMessage( "The server is already restarting." );
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Mobile.SendMessage( "You have initiated server shutdown." );
|
||||
Enabled = true;
|
||||
m_RestartTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
m_RestartTime = DateTime.UtcNow.Date + RestartTime;
|
||||
|
||||
public AutoRestart() : base( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ) )
|
||||
{
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
if (m_RestartTime < DateTime.UtcNow)
|
||||
m_RestartTime += TimeSpan.FromDays(1.0);
|
||||
}
|
||||
|
||||
m_RestartTime = DateTime.UtcNow.Date + RestartTime;
|
||||
public static bool Restarting{ get; private set; }
|
||||
|
||||
if ( m_RestartTime < DateTime.UtcNow )
|
||||
m_RestartTime += TimeSpan.FromDays( 1.0 );
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("Restart", AccessLevel.Administrator, Restart_OnCommand);
|
||||
new AutoRestart().Start();
|
||||
}
|
||||
|
||||
private void Warning_Callback()
|
||||
{
|
||||
World.Broadcast( 0x22, true, "The server is going down shortly." );
|
||||
}
|
||||
public static void Restart_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
if (Restarting)
|
||||
{
|
||||
e.Mobile.SendMessage("The server is already restarting.");
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Mobile.SendMessage("You have initiated server shutdown.");
|
||||
Enabled = true;
|
||||
m_RestartTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
private void Restart_Callback()
|
||||
{
|
||||
Core.Kill( true );
|
||||
}
|
||||
private void Warning_Callback()
|
||||
{
|
||||
World.Broadcast(0x22, true, "The server is going down shortly.");
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if ( Restarting || !Enabled )
|
||||
return;
|
||||
private void Restart_Callback()
|
||||
{
|
||||
Core.Kill(true);
|
||||
}
|
||||
|
||||
if ( DateTime.UtcNow < m_RestartTime )
|
||||
return;
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (Restarting || !Enabled)
|
||||
return;
|
||||
|
||||
if ( WarningDelay > TimeSpan.Zero )
|
||||
{
|
||||
Warning_Callback();
|
||||
DelayCall( WarningDelay, WarningDelay, Warning_Callback );
|
||||
}
|
||||
if (DateTime.UtcNow < m_RestartTime)
|
||||
return;
|
||||
|
||||
AutoSave.Save();
|
||||
if (WarningDelay > TimeSpan.Zero)
|
||||
{
|
||||
Warning_Callback();
|
||||
DelayCall(WarningDelay, WarningDelay, Warning_Callback);
|
||||
}
|
||||
|
||||
Restarting = true;
|
||||
AutoSave.Save();
|
||||
|
||||
DelayCall( RestartDelay, Restart_Callback );
|
||||
}
|
||||
}
|
||||
Restarting = true;
|
||||
|
||||
DelayCall(RestartDelay, Restart_Callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,170 +4,186 @@ using Server.Commands;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class AutoSave : Timer
|
||||
{
|
||||
private static TimeSpan m_Delay = TimeSpan.FromMinutes( 5.0 );
|
||||
private static TimeSpan m_Warning = TimeSpan.Zero;
|
||||
//private static TimeSpan m_Warning = TimeSpan.FromSeconds( 15.0 );
|
||||
public class AutoSave : Timer
|
||||
{
|
||||
private static TimeSpan m_Delay = TimeSpan.FromMinutes(5.0);
|
||||
private static TimeSpan m_Warning = TimeSpan.Zero;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
new AutoSave().Start();
|
||||
CommandSystem.Register( "SetSaves", AccessLevel.Administrator, SetSaves_OnCommand );
|
||||
}
|
||||
private static string[] m_Backups =
|
||||
{
|
||||
"Third Backup",
|
||||
"Second Backup",
|
||||
"Most Recent"
|
||||
};
|
||||
|
||||
public static bool SavesEnabled { get; set; } = true;
|
||||
public AutoSave() : base(m_Delay - m_Warning, m_Delay)
|
||||
{
|
||||
Priority = TimerPriority.OneMinute;
|
||||
}
|
||||
|
||||
[Usage( "SetSaves <true | false>" )]
|
||||
[Description( "Enables or disables automatic shard saving." )]
|
||||
public static void SetSaves_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
if ( e.Length == 1 )
|
||||
{
|
||||
SavesEnabled = e.GetBoolean( 0 );
|
||||
e.Mobile.SendMessage( "Saves have been {0}.", SavesEnabled ? "enabled" : "disabled" );
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Mobile.SendMessage( "Format: SetSaves <true | false>" );
|
||||
}
|
||||
}
|
||||
public static bool SavesEnabled{ get; set; } = true;
|
||||
//private static TimeSpan m_Warning = TimeSpan.FromSeconds( 15.0 );
|
||||
|
||||
public AutoSave() : base( m_Delay - m_Warning, m_Delay )
|
||||
{
|
||||
Priority = TimerPriority.OneMinute;
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
new AutoSave().Start();
|
||||
CommandSystem.Register("SetSaves", AccessLevel.Administrator, SetSaves_OnCommand);
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if ( !SavesEnabled || AutoRestart.Restarting )
|
||||
return;
|
||||
[Usage("SetSaves <true | false>")]
|
||||
[Description("Enables or disables automatic shard saving.")]
|
||||
public static void SetSaves_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
if (e.Length == 1)
|
||||
{
|
||||
SavesEnabled = e.GetBoolean(0);
|
||||
e.Mobile.SendMessage("Saves have been {0}.", SavesEnabled ? "enabled" : "disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Mobile.SendMessage("Format: SetSaves <true | false>");
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_Warning == TimeSpan.Zero )
|
||||
{
|
||||
Save( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
int s = (int)m_Warning.TotalSeconds;
|
||||
int m = s / 60;
|
||||
s %= 60;
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (!SavesEnabled || AutoRestart.Restarting)
|
||||
return;
|
||||
|
||||
if ( m > 0 && s > 0 )
|
||||
World.Broadcast( 0x35, true, "The world will save in {0} minute{1} and {2} second{3}.", m, m != 1 ? "s" : "", s, s != 1 ? "s" : "" );
|
||||
else if ( m > 0 )
|
||||
World.Broadcast( 0x35, true, "The world will save in {0} minute{1}.", m, m != 1 ? "s" : "" );
|
||||
else
|
||||
World.Broadcast( 0x35, true, "The world will save in {0} second{1}.", s, s != 1 ? "s" : "" );
|
||||
if (m_Warning == TimeSpan.Zero)
|
||||
{
|
||||
Save(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int s = (int)m_Warning.TotalSeconds;
|
||||
int m = s / 60;
|
||||
s %= 60;
|
||||
|
||||
DelayCall( m_Warning, Save );
|
||||
}
|
||||
}
|
||||
if (m > 0 && s > 0)
|
||||
World.Broadcast(0x35, true, "The world will save in {0} minute{1} and {2} second{3}.", m,
|
||||
m != 1 ? "s" : "", s, s != 1 ? "s" : "");
|
||||
else if (m > 0)
|
||||
World.Broadcast(0x35, true, "The world will save in {0} minute{1}.", m, m != 1 ? "s" : "");
|
||||
else
|
||||
World.Broadcast(0x35, true, "The world will save in {0} second{1}.", s, s != 1 ? "s" : "");
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
Save( false );
|
||||
}
|
||||
DelayCall(m_Warning, Save);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save( bool permitBackgroundWrite )
|
||||
{
|
||||
if ( AutoRestart.Restarting )
|
||||
return;
|
||||
public static void Save()
|
||||
{
|
||||
Save(false);
|
||||
}
|
||||
|
||||
World.WaitForWriteCompletion();
|
||||
public static void Save(bool permitBackgroundWrite)
|
||||
{
|
||||
if (AutoRestart.Restarting)
|
||||
return;
|
||||
|
||||
try{ Backup(); }
|
||||
catch ( Exception e ) { Console.WriteLine("WARNING: Automatic backup FAILED: {0}", e); }
|
||||
World.WaitForWriteCompletion();
|
||||
|
||||
World.Save( true, permitBackgroundWrite );
|
||||
}
|
||||
try
|
||||
{
|
||||
Backup();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("WARNING: Automatic backup FAILED: {0}", e);
|
||||
}
|
||||
|
||||
private static string[] m_Backups = {
|
||||
"Third Backup",
|
||||
"Second Backup",
|
||||
"Most Recent"
|
||||
};
|
||||
World.Save(true, permitBackgroundWrite);
|
||||
}
|
||||
|
||||
private static void Backup()
|
||||
{
|
||||
if ( m_Backups.Length == 0 )
|
||||
return;
|
||||
private static void Backup()
|
||||
{
|
||||
if (m_Backups.Length == 0)
|
||||
return;
|
||||
|
||||
string root = Path.Combine( Core.BaseDirectory, "Backups/Automatic" );
|
||||
string root = Path.Combine(Core.BaseDirectory, "Backups/Automatic");
|
||||
|
||||
if ( !Directory.Exists( root ) )
|
||||
Directory.CreateDirectory( root );
|
||||
if (!Directory.Exists(root))
|
||||
Directory.CreateDirectory(root);
|
||||
|
||||
string[] existing = Directory.GetDirectories( root );
|
||||
string[] existing = Directory.GetDirectories(root);
|
||||
|
||||
for ( int i = 0; i < m_Backups.Length; ++i )
|
||||
{
|
||||
DirectoryInfo dir = Match( existing, m_Backups[i] );
|
||||
for (int i = 0; i < m_Backups.Length; ++i)
|
||||
{
|
||||
DirectoryInfo dir = Match(existing, m_Backups[i]);
|
||||
|
||||
if ( dir == null )
|
||||
continue;
|
||||
if (dir == null)
|
||||
continue;
|
||||
|
||||
if ( i > 0 )
|
||||
{
|
||||
string timeStamp = FindTimeStamp( dir.Name );
|
||||
if (i > 0)
|
||||
{
|
||||
string timeStamp = FindTimeStamp(dir.Name);
|
||||
|
||||
if ( timeStamp != null )
|
||||
{
|
||||
try{ dir.MoveTo( FormatDirectory( root, m_Backups[i - 1], timeStamp ) ); }
|
||||
catch{}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try{ dir.Delete( true ); }
|
||||
catch{}
|
||||
}
|
||||
}
|
||||
if (timeStamp != null)
|
||||
try
|
||||
{
|
||||
dir.MoveTo(FormatDirectory(root, m_Backups[i - 1], timeStamp));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
dir.Delete(true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string saves = Path.Combine( Core.BaseDirectory, "Saves" );
|
||||
string saves = Path.Combine(Core.BaseDirectory, "Saves");
|
||||
|
||||
if ( Directory.Exists( saves ) )
|
||||
Directory.Move( saves, FormatDirectory( root, m_Backups[m_Backups.Length - 1], GetTimeStamp() ) );
|
||||
}
|
||||
if (Directory.Exists(saves))
|
||||
Directory.Move(saves, FormatDirectory(root, m_Backups[m_Backups.Length - 1], GetTimeStamp()));
|
||||
}
|
||||
|
||||
private static DirectoryInfo Match( string[] paths, string match )
|
||||
{
|
||||
for ( int i = 0; i < paths.Length; ++i )
|
||||
{
|
||||
DirectoryInfo info = new DirectoryInfo( paths[i] );
|
||||
private static DirectoryInfo Match(string[] paths, string match)
|
||||
{
|
||||
for (int i = 0; i < paths.Length; ++i)
|
||||
{
|
||||
DirectoryInfo info = new DirectoryInfo(paths[i]);
|
||||
|
||||
if ( info.Name.StartsWith( match ) )
|
||||
return info;
|
||||
}
|
||||
if (info.Name.StartsWith(match))
|
||||
return info;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string FormatDirectory( string root, string name, string timeStamp )
|
||||
{
|
||||
return Path.Combine( root, $"{name} ({timeStamp})");
|
||||
}
|
||||
private static string FormatDirectory(string root, string name, string timeStamp)
|
||||
{
|
||||
return Path.Combine(root, $"{name} ({timeStamp})");
|
||||
}
|
||||
|
||||
private static string FindTimeStamp( string input )
|
||||
{
|
||||
int start = input.IndexOf( '(' );
|
||||
private static string FindTimeStamp(string input)
|
||||
{
|
||||
int start = input.IndexOf('(');
|
||||
|
||||
if ( start >= 0 )
|
||||
{
|
||||
int end = input.IndexOf( ')', ++start );
|
||||
if (start >= 0)
|
||||
{
|
||||
int end = input.IndexOf(')', ++start);
|
||||
|
||||
if ( end >= start )
|
||||
return input.Substring( start, end-start );
|
||||
}
|
||||
if (end >= start)
|
||||
return input.Substring(start, end - start);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetTimeStamp()
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
private static string GetTimeStamp()
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
return $"{now.Day}-{now.Month}-{now.Year} {now.Hour}-{now.Minute:D2}-{now.Second:D2}";
|
||||
}
|
||||
}
|
||||
return $"{now.Day}-{now.Month}-{now.Year} {now.Hour}-{now.Minute:D2}-{now.Second:D2}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +1,33 @@
|
|||
namespace Server.Misc
|
||||
{
|
||||
public class Broadcasts
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Crashed += EventSink_Crashed;
|
||||
EventSink.Shutdown += EventSink_Shutdown;
|
||||
}
|
||||
public class Broadcasts
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Crashed += EventSink_Crashed;
|
||||
EventSink.Shutdown += EventSink_Shutdown;
|
||||
}
|
||||
|
||||
public static void EventSink_Crashed( CrashedEventArgs e )
|
||||
{
|
||||
try
|
||||
{
|
||||
World.Broadcast( 0x35, true, "The server has crashed." );
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
public static void EventSink_Crashed(CrashedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
World.Broadcast(0x35, true, "The server has crashed.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static void EventSink_Shutdown( ShutdownEventArgs e )
|
||||
{
|
||||
try
|
||||
{
|
||||
World.Broadcast( 0x35, true, "The server has shut down." );
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void EventSink_Shutdown(ShutdownEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
World.Broadcast(0x35, true, "The server has shut down.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,285 +4,292 @@ using Server.Network;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public class BuffInfo
|
||||
{
|
||||
public static bool Enabled => Core.ML;
|
||||
public class BuffInfo
|
||||
{
|
||||
public static bool Enabled => Core.ML;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if ( Enabled )
|
||||
{
|
||||
EventSink.ClientVersionReceived += delegate( ClientVersionReceivedArgs args )
|
||||
{
|
||||
if ( args.State.Mobile is PlayerMobile pm )
|
||||
Timer.DelayCall( TimeSpan.Zero, pm.ResendBuffs );
|
||||
};
|
||||
}
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Enabled)
|
||||
EventSink.ClientVersionReceived += delegate(ClientVersionReceivedArgs args)
|
||||
{
|
||||
if (args.State.Mobile is PlayerMobile pm)
|
||||
Timer.DelayCall(TimeSpan.Zero, pm.ResendBuffs);
|
||||
};
|
||||
}
|
||||
|
||||
#region Properties
|
||||
#region Properties
|
||||
|
||||
public BuffIcon ID { get; }
|
||||
public BuffIcon ID{ get; }
|
||||
|
||||
public int TitleCliloc { get; }
|
||||
public int TitleCliloc{ get; }
|
||||
|
||||
public int SecondaryCliloc { get; }
|
||||
public int SecondaryCliloc{ get; }
|
||||
|
||||
public TimeSpan TimeLength { get; }
|
||||
public TimeSpan TimeLength{ get; }
|
||||
|
||||
public DateTime TimeStart { get; }
|
||||
public DateTime TimeStart{ get; }
|
||||
|
||||
public Timer Timer { get; }
|
||||
public Timer Timer{ get; }
|
||||
|
||||
public bool RetainThroughDeath { get; }
|
||||
public bool RetainThroughDeath{ get; }
|
||||
|
||||
public TextDefinition Args { get; }
|
||||
public TextDefinition Args{ get; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc )
|
||||
: this( iconID, titleCliloc, titleCliloc + 1 )
|
||||
{
|
||||
}
|
||||
#region Constructors
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, int secondaryCliloc )
|
||||
{
|
||||
ID = iconID;
|
||||
TitleCliloc = titleCliloc;
|
||||
SecondaryCliloc = secondaryCliloc;
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc)
|
||||
: this(iconID, titleCliloc, titleCliloc + 1)
|
||||
{
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, TimeSpan length, Mobile m )
|
||||
: this( iconID, titleCliloc, titleCliloc + 1, length, m )
|
||||
{
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc)
|
||||
{
|
||||
ID = iconID;
|
||||
TitleCliloc = titleCliloc;
|
||||
SecondaryCliloc = secondaryCliloc;
|
||||
}
|
||||
|
||||
//Only the timed one needs to Mobile to know when to automagically remove it.
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, int secondaryCliloc, TimeSpan length, Mobile m )
|
||||
: this( iconID, titleCliloc, secondaryCliloc )
|
||||
{
|
||||
TimeLength = length;
|
||||
TimeStart = DateTime.UtcNow;
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, TimeSpan length, Mobile m)
|
||||
: this(iconID, titleCliloc, titleCliloc + 1, length, m)
|
||||
{
|
||||
}
|
||||
|
||||
Timer = Timer.DelayCall( length, delegate
|
||||
{
|
||||
if ( !(m is PlayerMobile pm) )
|
||||
return;
|
||||
//Only the timed one needs to Mobile to know when to automagically remove it.
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TimeSpan length, Mobile m)
|
||||
: this(iconID, titleCliloc, secondaryCliloc)
|
||||
{
|
||||
TimeLength = length;
|
||||
TimeStart = DateTime.UtcNow;
|
||||
|
||||
pm.RemoveBuff( this );
|
||||
} );
|
||||
}
|
||||
Timer = Timer.DelayCall(length, delegate
|
||||
{
|
||||
if (!(m is PlayerMobile pm))
|
||||
return;
|
||||
|
||||
pm.RemoveBuff(this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, TextDefinition args )
|
||||
: this( iconID, titleCliloc, titleCliloc + 1, args )
|
||||
{
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, TextDefinition args)
|
||||
: this(iconID, titleCliloc, titleCliloc + 1, args)
|
||||
{
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args )
|
||||
: this( iconID, titleCliloc, secondaryCliloc )
|
||||
{
|
||||
Args = args;
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args)
|
||||
: this(iconID, titleCliloc, secondaryCliloc)
|
||||
{
|
||||
Args = args;
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, bool retainThroughDeath )
|
||||
: this( iconID, titleCliloc, titleCliloc + 1, retainThroughDeath )
|
||||
{
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, bool retainThroughDeath)
|
||||
: this(iconID, titleCliloc, titleCliloc + 1, retainThroughDeath)
|
||||
{
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, int secondaryCliloc, bool retainThroughDeath )
|
||||
: this( iconID, titleCliloc, secondaryCliloc )
|
||||
{
|
||||
RetainThroughDeath = retainThroughDeath;
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, bool retainThroughDeath)
|
||||
: this(iconID, titleCliloc, secondaryCliloc)
|
||||
{
|
||||
RetainThroughDeath = retainThroughDeath;
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, TextDefinition args, bool retainThroughDeath )
|
||||
: this( iconID, titleCliloc, titleCliloc + 1, args, retainThroughDeath )
|
||||
{
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, TextDefinition args, bool retainThroughDeath)
|
||||
: this(iconID, titleCliloc, titleCliloc + 1, args, retainThroughDeath)
|
||||
{
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args, bool retainThroughDeath )
|
||||
: this( iconID, titleCliloc, secondaryCliloc, args )
|
||||
{
|
||||
RetainThroughDeath = retainThroughDeath;
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args, bool retainThroughDeath)
|
||||
: this(iconID, titleCliloc, secondaryCliloc, args)
|
||||
{
|
||||
RetainThroughDeath = retainThroughDeath;
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, TimeSpan length, Mobile m, TextDefinition args )
|
||||
: this( iconID, titleCliloc, titleCliloc + 1, length, m, args )
|
||||
{
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, TimeSpan length, Mobile m, TextDefinition args)
|
||||
: this(iconID, titleCliloc, titleCliloc + 1, length, m, args)
|
||||
{
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, int secondaryCliloc, TimeSpan length, Mobile m, TextDefinition args )
|
||||
: this( iconID, titleCliloc, secondaryCliloc, length, m )
|
||||
{
|
||||
Args = args;
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TimeSpan length, Mobile m,
|
||||
TextDefinition args)
|
||||
: this(iconID, titleCliloc, secondaryCliloc, length, m)
|
||||
{
|
||||
Args = args;
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, TimeSpan length, Mobile m, TextDefinition args, bool retainThroughDeath )
|
||||
: this( iconID, titleCliloc, titleCliloc + 1, length, m, args, retainThroughDeath )
|
||||
{
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, TimeSpan length, Mobile m, TextDefinition args,
|
||||
bool retainThroughDeath)
|
||||
: this(iconID, titleCliloc, titleCliloc + 1, length, m, args, retainThroughDeath)
|
||||
{
|
||||
}
|
||||
|
||||
public BuffInfo( BuffIcon iconID, int titleCliloc, int secondaryCliloc, TimeSpan length, Mobile m, TextDefinition args, bool retainThroughDeath )
|
||||
: this( iconID, titleCliloc, secondaryCliloc, length, m )
|
||||
{
|
||||
Args = args;
|
||||
RetainThroughDeath = retainThroughDeath;
|
||||
}
|
||||
public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TimeSpan length, Mobile m,
|
||||
TextDefinition args, bool retainThroughDeath)
|
||||
: this(iconID, titleCliloc, secondaryCliloc, length, m)
|
||||
{
|
||||
Args = args;
|
||||
RetainThroughDeath = retainThroughDeath;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Convenience Methods
|
||||
public static void AddBuff( Mobile m, BuffInfo b )
|
||||
{
|
||||
if ( m is PlayerMobile pm )
|
||||
pm.AddBuff( b );
|
||||
}
|
||||
#region Convenience Methods
|
||||
|
||||
public static void RemoveBuff( Mobile m, BuffInfo b )
|
||||
{
|
||||
if ( m is PlayerMobile pm )
|
||||
pm.RemoveBuff( b );
|
||||
}
|
||||
public static void AddBuff(Mobile m, BuffInfo b)
|
||||
{
|
||||
if (m is PlayerMobile pm)
|
||||
pm.AddBuff(b);
|
||||
}
|
||||
|
||||
public static void RemoveBuff( Mobile m, BuffIcon b )
|
||||
{
|
||||
if ( m is PlayerMobile pm )
|
||||
pm.RemoveBuff( b );
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public static void RemoveBuff(Mobile m, BuffInfo b)
|
||||
{
|
||||
if (m is PlayerMobile pm)
|
||||
pm.RemoveBuff(b);
|
||||
}
|
||||
|
||||
public enum BuffIcon : short
|
||||
{
|
||||
DismountPrevention=0x3E9,
|
||||
NoRearm=0x3EA,
|
||||
//Currently, no 0x3EB or 0x3EC
|
||||
NightSight=0x3ED, //*
|
||||
DeathStrike,
|
||||
EvilOmen,
|
||||
UnknownStandingSwirl, //Which is healing throttle & Stamina throttle?
|
||||
UnknownKneelingSword,
|
||||
DivineFury, //*
|
||||
EnemyOfOne, //*
|
||||
HidingAndOrStealth, //*
|
||||
ActiveMeditation, //*
|
||||
BloodOathCaster, //*
|
||||
BloodOathCurse, //*
|
||||
CorpseSkin, //*
|
||||
Mindrot, //*
|
||||
PainSpike, //*
|
||||
Strangle,
|
||||
GiftOfRenewal, //*
|
||||
AttuneWeapon, //*
|
||||
Thunderstorm, //*
|
||||
EssenceOfWind, //*
|
||||
EtherealVoyage, //*
|
||||
GiftOfLife, //*
|
||||
ArcaneEmpowerment, //*
|
||||
MortalStrike,
|
||||
ReactiveArmor, //*
|
||||
Protection, //*
|
||||
ArchProtection,
|
||||
MagicReflection, //*
|
||||
Incognito, //*
|
||||
Disguised,
|
||||
AnimalForm,
|
||||
Polymorph,
|
||||
Invisibility, //*
|
||||
Paralyze, //*
|
||||
Poison,
|
||||
Bleed,
|
||||
Clumsy, //*
|
||||
FeebleMind, //*
|
||||
Weaken, //*
|
||||
Curse, //*
|
||||
MassCurse,
|
||||
Agility, //*
|
||||
Cunning, //*
|
||||
Strength, //*
|
||||
Bless, //*
|
||||
Sleep,
|
||||
StoneForm,
|
||||
SpellPlague,
|
||||
SpellTrigger,
|
||||
NetherBolt,
|
||||
Fly
|
||||
}
|
||||
public static void RemoveBuff(Mobile m, BuffIcon b)
|
||||
{
|
||||
if (m is PlayerMobile pm)
|
||||
pm.RemoveBuff(b);
|
||||
}
|
||||
|
||||
public sealed class AddBuffPacket : Packet
|
||||
{
|
||||
public AddBuffPacket( Mobile m, BuffInfo info )
|
||||
: this( m, info.ID, info.TitleCliloc, info.SecondaryCliloc, info.Args, (info.TimeStart != DateTime.MinValue) ? ((info.TimeStart + info.TimeLength) - DateTime.UtcNow) : TimeSpan.Zero )
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public AddBuffPacket( Mobile mob, BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args, TimeSpan length )
|
||||
: base( 0xDF )
|
||||
{
|
||||
bool hasArgs = (args != null);
|
||||
public enum BuffIcon : short
|
||||
{
|
||||
DismountPrevention = 0x3E9,
|
||||
NoRearm = 0x3EA,
|
||||
|
||||
EnsureCapacity( (hasArgs ? (48 + args.ToString().Length * 2): 44) );
|
||||
m_Stream.Write( (int)mob.Serial );
|
||||
//Currently, no 0x3EB or 0x3EC
|
||||
NightSight = 0x3ED, //*
|
||||
DeathStrike,
|
||||
EvilOmen,
|
||||
UnknownStandingSwirl, //Which is healing throttle & Stamina throttle?
|
||||
UnknownKneelingSword,
|
||||
DivineFury, //*
|
||||
EnemyOfOne, //*
|
||||
HidingAndOrStealth, //*
|
||||
ActiveMeditation, //*
|
||||
BloodOathCaster, //*
|
||||
BloodOathCurse, //*
|
||||
CorpseSkin, //*
|
||||
Mindrot, //*
|
||||
PainSpike, //*
|
||||
Strangle,
|
||||
GiftOfRenewal, //*
|
||||
AttuneWeapon, //*
|
||||
Thunderstorm, //*
|
||||
EssenceOfWind, //*
|
||||
EtherealVoyage, //*
|
||||
GiftOfLife, //*
|
||||
ArcaneEmpowerment, //*
|
||||
MortalStrike,
|
||||
ReactiveArmor, //*
|
||||
Protection, //*
|
||||
ArchProtection,
|
||||
MagicReflection, //*
|
||||
Incognito, //*
|
||||
Disguised,
|
||||
AnimalForm,
|
||||
Polymorph,
|
||||
Invisibility, //*
|
||||
Paralyze, //*
|
||||
Poison,
|
||||
Bleed,
|
||||
Clumsy, //*
|
||||
FeebleMind, //*
|
||||
Weaken, //*
|
||||
Curse, //*
|
||||
MassCurse,
|
||||
Agility, //*
|
||||
Cunning, //*
|
||||
Strength, //*
|
||||
Bless, //*
|
||||
Sleep,
|
||||
StoneForm,
|
||||
SpellPlague,
|
||||
SpellTrigger,
|
||||
NetherBolt,
|
||||
Fly
|
||||
}
|
||||
|
||||
public sealed class AddBuffPacket : Packet
|
||||
{
|
||||
public AddBuffPacket(Mobile m, BuffInfo info)
|
||||
: this(m, info.ID, info.TitleCliloc, info.SecondaryCliloc, info.Args,
|
||||
info.TimeStart != DateTime.MinValue ? info.TimeStart + info.TimeLength - DateTime.UtcNow : TimeSpan.Zero)
|
||||
{
|
||||
}
|
||||
|
||||
public AddBuffPacket(Mobile mob, BuffIcon iconID, int titleCliloc, int secondaryCliloc, TextDefinition args,
|
||||
TimeSpan length)
|
||||
: base(0xDF)
|
||||
{
|
||||
bool hasArgs = args != null;
|
||||
|
||||
EnsureCapacity(hasArgs ? 48 + args.ToString().Length * 2 : 44);
|
||||
m_Stream.Write(mob.Serial);
|
||||
|
||||
|
||||
m_Stream.Write( (short)iconID ); //ID
|
||||
m_Stream.Write( (short)0x1 ); //Type 0 for removal. 1 for add 2 for Data
|
||||
m_Stream.Write((short)iconID); //ID
|
||||
m_Stream.Write((short)0x1); //Type 0 for removal. 1 for add 2 for Data
|
||||
|
||||
m_Stream.Fill( 4 );
|
||||
m_Stream.Fill(4);
|
||||
|
||||
m_Stream.Write( (short)iconID ); //ID
|
||||
m_Stream.Write( (short)0x01 ); //Type 0 for removal. 1 for add 2 for Data
|
||||
m_Stream.Write((short)iconID); //ID
|
||||
m_Stream.Write((short)0x01); //Type 0 for removal. 1 for add 2 for Data
|
||||
|
||||
m_Stream.Fill( 4 );
|
||||
m_Stream.Fill(4);
|
||||
|
||||
if ( length < TimeSpan.Zero )
|
||||
length = TimeSpan.Zero;
|
||||
if (length < TimeSpan.Zero)
|
||||
length = TimeSpan.Zero;
|
||||
|
||||
m_Stream.Write( (short)length.TotalSeconds ); //Time in seconds
|
||||
m_Stream.Write((short)length.TotalSeconds); //Time in seconds
|
||||
|
||||
m_Stream.Fill( 3 );
|
||||
m_Stream.Write( (int)titleCliloc );
|
||||
m_Stream.Write( (int)secondaryCliloc );
|
||||
m_Stream.Fill(3);
|
||||
m_Stream.Write(titleCliloc);
|
||||
m_Stream.Write(secondaryCliloc);
|
||||
|
||||
if ( !hasArgs )
|
||||
{
|
||||
//m_Stream.Fill( 2 );
|
||||
m_Stream.Fill( 10 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Stream.Fill( 4 );
|
||||
m_Stream.Write( (short)0x1 ); //Unknown -> Possibly something saying 'hey, I have more data!'?
|
||||
m_Stream.Fill( 2 );
|
||||
if (!hasArgs)
|
||||
{
|
||||
//m_Stream.Fill( 2 );
|
||||
m_Stream.Fill(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Stream.Fill(4);
|
||||
m_Stream.Write((short)0x1); //Unknown -> Possibly something saying 'hey, I have more data!'?
|
||||
m_Stream.Fill(2);
|
||||
|
||||
//m_Stream.WriteLittleUniNull( "\t#1018280" );
|
||||
m_Stream.WriteLittleUniNull($"\t{args.ToString()}");
|
||||
//m_Stream.WriteLittleUniNull( "\t#1018280" );
|
||||
m_Stream.WriteLittleUniNull($"\t{args}");
|
||||
|
||||
m_Stream.Write( (short)0x1 ); //Even more Unknown -> Possibly something saying 'hey, I have more data!'?
|
||||
m_Stream.Fill( 2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Stream.Write((short)0x1); //Even more Unknown -> Possibly something saying 'hey, I have more data!'?
|
||||
m_Stream.Fill(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RemoveBuffPacket : Packet
|
||||
{
|
||||
public RemoveBuffPacket( Mobile mob, BuffInfo info )
|
||||
: this( mob, info.ID )
|
||||
{
|
||||
}
|
||||
public sealed class RemoveBuffPacket : Packet
|
||||
{
|
||||
public RemoveBuffPacket(Mobile mob, BuffInfo info)
|
||||
: this(mob, info.ID)
|
||||
{
|
||||
}
|
||||
|
||||
public RemoveBuffPacket( Mobile mob, BuffIcon iconID )
|
||||
: base( 0xDF )
|
||||
{
|
||||
EnsureCapacity( 13 );
|
||||
m_Stream.Write( (int)mob.Serial );
|
||||
public RemoveBuffPacket(Mobile mob, BuffIcon iconID)
|
||||
: base(0xDF)
|
||||
{
|
||||
EnsureCapacity(13);
|
||||
m_Stream.Write(mob.Serial);
|
||||
|
||||
m_Stream.Write( (short)iconID ); //ID
|
||||
m_Stream.Write( (short)0x0 ); //Type 0 for removal. 1 for add 2 for Data
|
||||
m_Stream.Write((short)iconID); //ID
|
||||
m_Stream.Write((short)0x0); //Type 0 for removal. 1 for add 2 for Data
|
||||
|
||||
m_Stream.Fill( 4 );
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Stream.Fill(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,163 +1,169 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Multis;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class Cleanup
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 2.5 ), Run );
|
||||
}
|
||||
public class Cleanup
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2.5), Run);
|
||||
}
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
List<Item> items = new List<Item>();
|
||||
List<Item> validItems = new List<Item>();
|
||||
List<Mobile> hairCleanup = new List<Mobile>();
|
||||
public static void Run()
|
||||
{
|
||||
List<Item> items = new List<Item>();
|
||||
List<Item> validItems = new List<Item>();
|
||||
List<Mobile> hairCleanup = new List<Mobile>();
|
||||
|
||||
int boxes = 0;
|
||||
int boxes = 0;
|
||||
|
||||
foreach ( Item item in World.Items.Values )
|
||||
{
|
||||
if ( item.Map == null )
|
||||
{
|
||||
items.Add( item );
|
||||
continue;
|
||||
}
|
||||
if ( item is CommodityDeed deed )
|
||||
{
|
||||
if ( deed.Commodity != null )
|
||||
validItems.Add( deed.Commodity );
|
||||
foreach (Item item in World.Items.Values)
|
||||
{
|
||||
if (item.Map == null)
|
||||
{
|
||||
items.Add(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
if ( item is BaseHouse house )
|
||||
{
|
||||
foreach ( RelocatedEntity relEntity in house.RelocatedEntities )
|
||||
{
|
||||
if ( relEntity.Entity is Item item1 )
|
||||
validItems.Add( item1 );
|
||||
}
|
||||
if (item is CommodityDeed deed)
|
||||
{
|
||||
if (deed.Commodity != null)
|
||||
validItems.Add(deed.Commodity);
|
||||
|
||||
foreach ( VendorInventory inventory in house.VendorInventories )
|
||||
{
|
||||
foreach ( Item subItem in inventory.Items )
|
||||
validItems.Add( subItem );
|
||||
}
|
||||
}
|
||||
else if ( item is BankBox box )
|
||||
{
|
||||
Mobile owner = box.Owner;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( owner == null )
|
||||
{
|
||||
items.Add( box );
|
||||
++boxes;
|
||||
}
|
||||
else if ( box.Items.Count == 0 )
|
||||
{
|
||||
items.Add( box );
|
||||
++boxes;
|
||||
}
|
||||
if (item is BaseHouse house)
|
||||
{
|
||||
foreach (RelocatedEntity relEntity in house.RelocatedEntities)
|
||||
if (relEntity.Entity is Item item1)
|
||||
validItems.Add(item1);
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair) )
|
||||
{
|
||||
object rootParent = item.RootParent;
|
||||
foreach (VendorInventory inventory in house.VendorInventories)
|
||||
foreach (Item subItem in inventory.Items)
|
||||
validItems.Add(subItem);
|
||||
}
|
||||
else if (item is BankBox box)
|
||||
{
|
||||
Mobile owner = box.Owner;
|
||||
|
||||
if ( rootParent is Mobile rootMobile )
|
||||
{
|
||||
if ( item.Parent != rootMobile && rootMobile.AccessLevel == AccessLevel.Player )
|
||||
{
|
||||
items.Add( item );
|
||||
continue;
|
||||
}
|
||||
if ( item.Parent == rootMobile )
|
||||
{
|
||||
hairCleanup.Add( rootMobile );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (owner == null)
|
||||
{
|
||||
items.Add(box);
|
||||
++boxes;
|
||||
}
|
||||
else if (box.Items.Count == 0)
|
||||
{
|
||||
items.Add(box);
|
||||
++boxes;
|
||||
}
|
||||
|
||||
if ( item.Parent != null || item.Map != Map.Internal || item.HeldBy != null )
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
else if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair)
|
||||
{
|
||||
object rootParent = item.RootParent;
|
||||
|
||||
if ( item.Location != Point3D.Zero )
|
||||
continue;
|
||||
if (rootParent is Mobile rootMobile)
|
||||
{
|
||||
if (item.Parent != rootMobile && rootMobile.AccessLevel == AccessLevel.Player)
|
||||
{
|
||||
items.Add(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !IsBuggable( item ) )
|
||||
continue;
|
||||
if (item.Parent == rootMobile)
|
||||
{
|
||||
hairCleanup.Add(rootMobile);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
items.Add( item );
|
||||
}
|
||||
if (item.Parent != null || item.Map != Map.Internal || item.HeldBy != null)
|
||||
continue;
|
||||
|
||||
for ( int i = 0; i < validItems.Count; ++i )
|
||||
items.Remove( validItems[i] );
|
||||
if (item.Location != Point3D.Zero)
|
||||
continue;
|
||||
|
||||
if ( items.Count > 0 )
|
||||
{
|
||||
if ( boxes > 0 )
|
||||
Console.WriteLine( "Cleanup: Detected {0} inaccessible items, including {1} bank boxes, removing..", items.Count, boxes );
|
||||
else
|
||||
Console.WriteLine( "Cleanup: Detected {0} inaccessible items, removing..", items.Count );
|
||||
if (!IsBuggable(item))
|
||||
continue;
|
||||
|
||||
for ( int i = 0; i < items.Count; ++i )
|
||||
items[i].Delete();
|
||||
}
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
if ( hairCleanup.Count > 0 )
|
||||
{
|
||||
Console.WriteLine( "Cleanup: Detected {0} hair and facial hair items being worn, converting to their virtual counterparts..", hairCleanup.Count );
|
||||
for (int i = 0; i < validItems.Count; ++i)
|
||||
items.Remove(validItems[i]);
|
||||
|
||||
for ( int i = 0; i < hairCleanup.Count; i++ )
|
||||
hairCleanup[i].ConvertHair();
|
||||
}
|
||||
}
|
||||
if (items.Count > 0)
|
||||
{
|
||||
if (boxes > 0)
|
||||
Console.WriteLine("Cleanup: Detected {0} inaccessible items, including {1} bank boxes, removing..",
|
||||
items.Count, boxes);
|
||||
else
|
||||
Console.WriteLine("Cleanup: Detected {0} inaccessible items, removing..", items.Count);
|
||||
|
||||
public static bool IsBuggable( Item item )
|
||||
{
|
||||
if ( item is Fists )
|
||||
return false;
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
items[i].Delete();
|
||||
}
|
||||
|
||||
if ( item is ICommodity || item is BaseBoat
|
||||
|| item is Fish || item is BigFish
|
||||
|| item is BasePotion || item is Food || item is CookableFood
|
||||
|| item is SpecialFishingNet || item is BaseMagicFish
|
||||
|| item is Shoes || item is Sandals
|
||||
|| item is Boots || item is ThighBoots
|
||||
|| item is TreasureMap || item is MessageInABottle
|
||||
|| item is BaseArmor || item is BaseWeapon
|
||||
|| item is BaseClothing
|
||||
|| ( item is BaseJewel && Core.AOS )
|
||||
|| ( item is BasePotion && Core.ML )
|
||||
#region Champion artifacts
|
||||
|| item is SkullPole
|
||||
|| item is EvilIdolSkull
|
||||
|| item is MonsterStatuette
|
||||
|| item is Pier
|
||||
|| item is ArtifactLargeVase
|
||||
|| item is ArtifactVase
|
||||
|| item is MinotaurStatueDeed
|
||||
|| item is SwampTile
|
||||
|| item is WallBlood
|
||||
|| item is TatteredAncientMummyWrapping
|
||||
|| item is LavaTile
|
||||
|| item is DemonSkull
|
||||
|| item is Web
|
||||
|| item is WaterTile
|
||||
|| item is WindSpirit
|
||||
|| item is DirtPatch
|
||||
|| item is Futon )
|
||||
#endregion
|
||||
return true;
|
||||
if (hairCleanup.Count > 0)
|
||||
{
|
||||
Console.WriteLine(
|
||||
"Cleanup: Detected {0} hair and facial hair items being worn, converting to their virtual counterparts..",
|
||||
hairCleanup.Count);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < hairCleanup.Count; i++)
|
||||
hairCleanup[i].ConvertHair();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsBuggable(Item item)
|
||||
{
|
||||
if (item is Fists)
|
||||
return false;
|
||||
|
||||
if (item is ICommodity || item is BaseBoat
|
||||
|| item is Fish || item is BigFish
|
||||
|| item is BasePotion || item is Food || item is CookableFood
|
||||
|| item is SpecialFishingNet || item is BaseMagicFish
|
||||
|| item is Shoes || item is Sandals
|
||||
|| item is Boots || item is ThighBoots
|
||||
|| item is TreasureMap || item is MessageInABottle
|
||||
|| item is BaseArmor || item is BaseWeapon
|
||||
|| item is BaseClothing
|
||||
|| item is BaseJewel && Core.AOS
|
||||
|| item is BasePotion && Core.ML
|
||||
|
||||
#region Champion artifacts
|
||||
|
||||
|| item is SkullPole
|
||||
|| item is EvilIdolSkull
|
||||
|| item is MonsterStatuette
|
||||
|| item is Pier
|
||||
|| item is ArtifactLargeVase
|
||||
|| item is ArtifactVase
|
||||
|| item is MinotaurStatueDeed
|
||||
|| item is SwampTile
|
||||
|| item is WallBlood
|
||||
|| item is TatteredAncientMummyWrapping
|
||||
|| item is LavaTile
|
||||
|| item is DemonSkull
|
||||
|| item is Web
|
||||
|| item is WaterTile
|
||||
|| item is WindSpirit
|
||||
|| item is DirtPatch
|
||||
|| item is Futon)
|
||||
|
||||
#endregion
|
||||
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,166 +1,175 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Server.Network;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class ClientVerification
|
||||
{
|
||||
private enum OldClientResponse
|
||||
{
|
||||
Ignore,
|
||||
Warn,
|
||||
Annoy,
|
||||
LenientKick,
|
||||
Kick
|
||||
}
|
||||
public class ClientVerification
|
||||
{
|
||||
private static bool m_DetectClientRequirement = true;
|
||||
private static OldClientResponse m_OldClientResponse = OldClientResponse.LenientKick;
|
||||
|
||||
private static bool m_DetectClientRequirement = true;
|
||||
private static OldClientResponse m_OldClientResponse = OldClientResponse.LenientKick;
|
||||
private static TimeSpan m_AgeLeniency = TimeSpan.FromDays(10);
|
||||
private static TimeSpan m_GameTimeLeniency = TimeSpan.FromHours(25);
|
||||
|
||||
private static TimeSpan m_AgeLeniency = TimeSpan.FromDays( 10 );
|
||||
private static TimeSpan m_GameTimeLeniency = TimeSpan.FromHours( 25 );
|
||||
public static ClientVersion Required{ get; set; }
|
||||
|
||||
public static ClientVersion Required { get; set; }
|
||||
public static bool AllowRegular{ get; set; } = true;
|
||||
|
||||
public static bool AllowRegular { get; set; } = true;
|
||||
public static bool AllowUOTD{ get; set; } = true;
|
||||
|
||||
public static bool AllowUOTD { get; set; } = true;
|
||||
public static bool AllowGod{ get; set; } = true;
|
||||
|
||||
public static bool AllowGod { get; set; } = true;
|
||||
public static TimeSpan KickDelay{ get; set; } = TimeSpan.FromSeconds(20.0);
|
||||
|
||||
public static TimeSpan KickDelay { get; set; } = TimeSpan.FromSeconds( 20.0 );
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.ClientVersionReceived += EventSink_ClientVersionReceived;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.ClientVersionReceived += EventSink_ClientVersionReceived;
|
||||
//ClientVersion.Required = null;
|
||||
//Required = new ClientVersion( "6.0.0.0" );
|
||||
|
||||
//ClientVersion.Required = null;
|
||||
//Required = new ClientVersion( "6.0.0.0" );
|
||||
if (m_DetectClientRequirement)
|
||||
{
|
||||
string path = Core.FindDataFile("client.exe");
|
||||
|
||||
if ( m_DetectClientRequirement )
|
||||
{
|
||||
string path = Core.FindDataFile( "client.exe" );
|
||||
if (File.Exists(path))
|
||||
{
|
||||
FileVersionInfo info = FileVersionInfo.GetVersionInfo(path);
|
||||
|
||||
if ( File.Exists( path ) )
|
||||
{
|
||||
FileVersionInfo info = FileVersionInfo.GetVersionInfo( path );
|
||||
if (info.FileMajorPart != 0 || info.FileMinorPart != 0 || info.FileBuildPart != 0 ||
|
||||
info.FilePrivatePart != 0)
|
||||
Required = new ClientVersion(info.FileMajorPart, info.FileMinorPart, info.FileBuildPart,
|
||||
info.FilePrivatePart);
|
||||
}
|
||||
}
|
||||
|
||||
if ( info.FileMajorPart != 0 || info.FileMinorPart != 0 || info.FileBuildPart != 0 || info.FilePrivatePart != 0 )
|
||||
{
|
||||
Required = new ClientVersion( info.FileMajorPart, info.FileMinorPart, info.FileBuildPart, info.FilePrivatePart );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Required != null)
|
||||
{
|
||||
Utility.PushColor(ConsoleColor.White);
|
||||
Console.WriteLine("Restricting client version to {0}. Action to be taken: {1}", Required,
|
||||
m_OldClientResponse);
|
||||
Utility.PopColor();
|
||||
}
|
||||
}
|
||||
|
||||
if ( Required != null )
|
||||
{
|
||||
Utility.PushColor( ConsoleColor.White );
|
||||
Console.WriteLine( "Restricting client version to {0}. Action to be taken: {1}", Required, m_OldClientResponse );
|
||||
Utility.PopColor();
|
||||
}
|
||||
}
|
||||
private static void EventSink_ClientVersionReceived(ClientVersionReceivedArgs e)
|
||||
{
|
||||
string kickMessage = null;
|
||||
NetState state = e.State;
|
||||
ClientVersion version = e.Version;
|
||||
|
||||
private static void EventSink_ClientVersionReceived( ClientVersionReceivedArgs e )
|
||||
{
|
||||
string kickMessage = null;
|
||||
NetState state = e.State;
|
||||
ClientVersion version = e.Version;
|
||||
if (state.Mobile == null || state.Mobile.AccessLevel > AccessLevel.Player)
|
||||
return;
|
||||
|
||||
if ( state.Mobile == null || state.Mobile.AccessLevel > AccessLevel.Player )
|
||||
return;
|
||||
if (Required != null && version < Required && (m_OldClientResponse == OldClientResponse.Kick ||
|
||||
m_OldClientResponse == OldClientResponse.LenientKick &&
|
||||
DateTime.UtcNow - state.Mobile.CreationTime > m_AgeLeniency &&
|
||||
state.Mobile is PlayerMobile mobile &&
|
||||
mobile.GameTime > m_GameTimeLeniency))
|
||||
{
|
||||
kickMessage = $"This server requires your client version be at least {Required}.";
|
||||
}
|
||||
else if (!AllowGod || !AllowRegular || !AllowUOTD)
|
||||
{
|
||||
if (!AllowGod && version.Type == ClientType.God)
|
||||
kickMessage = "This server does not allow god clients to connect.";
|
||||
else if (!AllowRegular && version.Type == ClientType.Regular)
|
||||
kickMessage = "This server does not allow regular clients to connect.";
|
||||
else if (!AllowUOTD && state.IsUOTDClient)
|
||||
kickMessage = "This server does not allow UO:TD clients to connect.";
|
||||
|
||||
if ( Required != null && version < Required && ( m_OldClientResponse == OldClientResponse.Kick ||( m_OldClientResponse == OldClientResponse.LenientKick && (DateTime.UtcNow - state.Mobile.CreationTime) > m_AgeLeniency && state.Mobile is PlayerMobile mobile && mobile.GameTime > m_GameTimeLeniency )))
|
||||
{
|
||||
kickMessage = $"This server requires your client version be at least {Required}.";
|
||||
}
|
||||
else if ( !AllowGod || !AllowRegular || !AllowUOTD )
|
||||
{
|
||||
if ( !AllowGod && version.Type == ClientType.God )
|
||||
kickMessage = "This server does not allow god clients to connect.";
|
||||
else if ( !AllowRegular && version.Type == ClientType.Regular )
|
||||
kickMessage = "This server does not allow regular clients to connect.";
|
||||
else if ( !AllowUOTD && state.IsUOTDClient )
|
||||
kickMessage = "This server does not allow UO:TD clients to connect.";
|
||||
if (!AllowGod && !AllowRegular && !AllowUOTD)
|
||||
{
|
||||
kickMessage = "This server does not allow any clients to connect.";
|
||||
}
|
||||
else if (AllowGod && !AllowRegular && !AllowUOTD && version.Type != ClientType.God)
|
||||
{
|
||||
kickMessage = "This server requires you to use the god client.";
|
||||
}
|
||||
else if (kickMessage != null)
|
||||
{
|
||||
if (AllowRegular && AllowUOTD)
|
||||
kickMessage += " You can use regular or UO:TD clients.";
|
||||
else if (AllowRegular)
|
||||
kickMessage += " You can use regular clients.";
|
||||
else if (AllowUOTD)
|
||||
kickMessage += " You can use UO:TD clients.";
|
||||
}
|
||||
}
|
||||
|
||||
if ( !AllowGod && !AllowRegular && !AllowUOTD )
|
||||
{
|
||||
kickMessage = "This server does not allow any clients to connect.";
|
||||
}
|
||||
else if ( AllowGod && !AllowRegular && !AllowUOTD && version.Type != ClientType.God )
|
||||
{
|
||||
kickMessage = "This server requires you to use the god client.";
|
||||
}
|
||||
else if ( kickMessage != null )
|
||||
{
|
||||
if ( AllowRegular && AllowUOTD )
|
||||
kickMessage += " You can use regular or UO:TD clients.";
|
||||
else if ( AllowRegular )
|
||||
kickMessage += " You can use regular clients.";
|
||||
else if ( AllowUOTD )
|
||||
kickMessage += " You can use UO:TD clients.";
|
||||
}
|
||||
}
|
||||
if (kickMessage != null)
|
||||
{
|
||||
state.Mobile.SendMessage(0x22, kickMessage);
|
||||
state.Mobile.SendMessage(0x22, "You will be disconnected in {0} seconds.", KickDelay.TotalSeconds);
|
||||
|
||||
if ( kickMessage != null )
|
||||
{
|
||||
state.Mobile.SendMessage( 0x22, kickMessage );
|
||||
state.Mobile.SendMessage( 0x22, "You will be disconnected in {0} seconds.", KickDelay.TotalSeconds );
|
||||
Timer.DelayCall(KickDelay, delegate
|
||||
{
|
||||
if (state.Socket != null)
|
||||
{
|
||||
Console.WriteLine("Client: {0}: Disconnecting, bad version", state);
|
||||
state.Dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (Required != null && version < Required)
|
||||
{
|
||||
switch (m_OldClientResponse)
|
||||
{
|
||||
case OldClientResponse.Warn:
|
||||
{
|
||||
state.Mobile.SendMessage(0x22, "Your client is out of date. Please update your client.", Required);
|
||||
state.Mobile.SendMessage(0x22, "This server recommends that your client version be at least {0}.",
|
||||
Required);
|
||||
break;
|
||||
}
|
||||
case OldClientResponse.LenientKick:
|
||||
case OldClientResponse.Annoy:
|
||||
{
|
||||
SendAnnoyGump(state.Mobile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall( KickDelay, delegate
|
||||
{
|
||||
if ( state.Socket != null )
|
||||
{
|
||||
Console.WriteLine( "Client: {0}: Disconnecting, bad version", state );
|
||||
state.Dispose();
|
||||
}
|
||||
} );
|
||||
}
|
||||
else if ( Required != null && version < Required )
|
||||
{
|
||||
switch( m_OldClientResponse )
|
||||
{
|
||||
case OldClientResponse.Warn:
|
||||
{
|
||||
state.Mobile.SendMessage( 0x22, "Your client is out of date. Please update your client.", Required );
|
||||
state.Mobile.SendMessage( 0x22, "This server recommends that your client version be at least {0}.", Required );
|
||||
break;
|
||||
}
|
||||
case OldClientResponse.LenientKick:
|
||||
case OldClientResponse.Annoy:
|
||||
{
|
||||
SendAnnoyGump( state.Mobile );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void SendAnnoyGump(Mobile m)
|
||||
{
|
||||
if (m.NetState != null && m.NetState.Version < Required)
|
||||
{
|
||||
Gump g = new WarningGump(1060637, 30720,
|
||||
$"Your client is out of date. Please update your client.<br>This server recommends that your client version be at least {Required}.<br> <br>You are currently using version {m.NetState.Version}.<br> <br>To patch, run UOPatch.exe inside your Ultima Online folder.",
|
||||
0xFFC000, 480, 360,
|
||||
delegate
|
||||
{
|
||||
m.SendMessage("You will be reminded of this again.");
|
||||
|
||||
private static void SendAnnoyGump( Mobile m )
|
||||
{
|
||||
if ( m.NetState != null && m.NetState.Version < Required )
|
||||
{
|
||||
Gump g = new WarningGump( 1060637, 30720,
|
||||
$"Your client is out of date. Please update your client.<br>This server recommends that your client version be at least {Required}.<br> <br>You are currently using version {m.NetState.Version}.<br> <br>To patch, run UOPatch.exe inside your Ultima Online folder.", 0xFFC000, 480, 360,
|
||||
delegate( Mobile mob, bool selection, object o )
|
||||
{
|
||||
m.SendMessage( "You will be reminded of this again." );
|
||||
if (m_OldClientResponse == OldClientResponse.LenientKick)
|
||||
m.SendMessage(
|
||||
"Old clients will be kicked after {0} days of character age and {1} hours of play time",
|
||||
m_AgeLeniency, m_GameTimeLeniency);
|
||||
|
||||
if ( m_OldClientResponse == OldClientResponse.LenientKick )
|
||||
m.SendMessage( "Old clients will be kicked after {0} days of character age and {1} hours of play time", m_AgeLeniency, m_GameTimeLeniency );
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(Utility.Random(5, 15)), delegate { SendAnnoyGump(m); });
|
||||
}, null, false);
|
||||
|
||||
Timer.DelayCall( TimeSpan.FromMinutes( Utility.Random( 5, 15 ) ), delegate { SendAnnoyGump( m ); } );
|
||||
}, null, false );
|
||||
g.Dragable = false;
|
||||
g.Closable = false;
|
||||
g.Resizable = false;
|
||||
|
||||
g.Dragable = false;
|
||||
g.Closable = false;
|
||||
g.Resizable = false;
|
||||
m.SendGump(g);
|
||||
}
|
||||
}
|
||||
|
||||
m.SendGump( g );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private enum OldClientResponse
|
||||
{
|
||||
Ignore,
|
||||
Warn,
|
||||
Annoy,
|
||||
LenientKick,
|
||||
Kick
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,245 +8,256 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class CrashGuard
|
||||
{
|
||||
private static bool Enabled = true;
|
||||
private static bool SaveBackup = true;
|
||||
private static bool RestartServer = true;
|
||||
private static bool GenerateReport = true;
|
||||
public class CrashGuard
|
||||
{
|
||||
private static bool Enabled = true;
|
||||
private static bool SaveBackup = true;
|
||||
private static bool RestartServer = true;
|
||||
private static bool GenerateReport = true;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if ( Enabled ) // If enabled, register our crash event handler
|
||||
EventSink.Crashed += CrashGuard_OnCrash;
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Enabled) // If enabled, register our crash event handler
|
||||
EventSink.Crashed += CrashGuard_OnCrash;
|
||||
}
|
||||
|
||||
public static void CrashGuard_OnCrash( CrashedEventArgs e )
|
||||
{
|
||||
if ( GenerateReport )
|
||||
GenerateCrashReport( e );
|
||||
public static void CrashGuard_OnCrash(CrashedEventArgs e)
|
||||
{
|
||||
if (GenerateReport)
|
||||
GenerateCrashReport(e);
|
||||
|
||||
World.WaitForWriteCompletion();
|
||||
World.WaitForWriteCompletion();
|
||||
|
||||
if ( SaveBackup )
|
||||
Backup();
|
||||
if (SaveBackup)
|
||||
Backup();
|
||||
|
||||
|
||||
/*if ( Core.Service )
|
||||
e.Close = true;
|
||||
else */ if ( RestartServer )
|
||||
Restart( e );
|
||||
}
|
||||
/*if ( Core.Service )
|
||||
e.Close = true;
|
||||
else */
|
||||
if (RestartServer)
|
||||
Restart(e);
|
||||
}
|
||||
|
||||
private static void SendEmail( string filePath )
|
||||
{
|
||||
Console.Write( "Crash: Sending email..." );
|
||||
private static void SendEmail(string filePath)
|
||||
{
|
||||
Console.Write("Crash: Sending email...");
|
||||
|
||||
MailMessage message = new MailMessage( Email.FromAddress, Email.CrashAddresses );
|
||||
MailMessage message = new MailMessage(Email.FromAddress, Email.CrashAddresses);
|
||||
|
||||
message.Subject = "Automated RunUO Crash Report";
|
||||
message.Subject = "Automated RunUO Crash Report";
|
||||
|
||||
message.Body = "Automated RunUO Crash Report. See attachment for details.";
|
||||
message.Body = "Automated RunUO Crash Report. See attachment for details.";
|
||||
|
||||
message.Attachments.Add( new Attachment( filePath ) );
|
||||
message.Attachments.Add(new Attachment(filePath));
|
||||
|
||||
if ( Email.Send( message ) )
|
||||
Console.WriteLine( "done" );
|
||||
else
|
||||
Console.WriteLine( "failed" );
|
||||
}
|
||||
if (Email.Send(message))
|
||||
Console.WriteLine("done");
|
||||
else
|
||||
Console.WriteLine("failed");
|
||||
}
|
||||
|
||||
private static string GetRoot()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Path.GetDirectoryName( Environment.GetCommandLineArgs()[0] );
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
private static string GetRoot()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static string Combine( string path1, string path2 )
|
||||
{
|
||||
if ( path1.Length == 0 )
|
||||
return path2;
|
||||
private static string Combine(string path1, string path2)
|
||||
{
|
||||
if (path1.Length == 0)
|
||||
return path2;
|
||||
|
||||
return Path.Combine( path1, path2 );
|
||||
}
|
||||
return Path.Combine(path1, path2);
|
||||
}
|
||||
|
||||
private static void Restart( CrashedEventArgs e )
|
||||
{
|
||||
string root = GetRoot();
|
||||
private static void Restart(CrashedEventArgs e)
|
||||
{
|
||||
string root = GetRoot();
|
||||
|
||||
Console.Write( "Crash: Restarting..." );
|
||||
Console.Write("Crash: Restarting...");
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start( Core.ExePath, Core.Arguments );
|
||||
Console.WriteLine( "done" );
|
||||
try
|
||||
{
|
||||
Process.Start(Core.ExePath, Core.Arguments);
|
||||
Console.WriteLine("done");
|
||||
|
||||
e.Close = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine( "failed" );
|
||||
}
|
||||
}
|
||||
e.Close = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("failed");
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateDirectory( string path )
|
||||
{
|
||||
if ( !Directory.Exists( path ) )
|
||||
Directory.CreateDirectory( path );
|
||||
}
|
||||
private static void CreateDirectory(string path)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
private static void CreateDirectory( string path1, string path2 )
|
||||
{
|
||||
CreateDirectory( Combine( path1, path2 ) );
|
||||
}
|
||||
private static void CreateDirectory(string path1, string path2)
|
||||
{
|
||||
CreateDirectory(Combine(path1, path2));
|
||||
}
|
||||
|
||||
private static void CopyFile( string rootOrigin, string rootBackup, string path )
|
||||
{
|
||||
string originPath = Combine( rootOrigin, path );
|
||||
string backupPath = Combine( rootBackup, path );
|
||||
private static void CopyFile(string rootOrigin, string rootBackup, string path)
|
||||
{
|
||||
string originPath = Combine(rootOrigin, path);
|
||||
string backupPath = Combine(rootBackup, path);
|
||||
|
||||
try
|
||||
{
|
||||
if ( File.Exists( originPath ) )
|
||||
File.Copy( originPath, backupPath );
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
if (File.Exists(originPath))
|
||||
File.Copy(originPath, backupPath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static void Backup()
|
||||
{
|
||||
Console.Write( "Crash: Backing up..." );
|
||||
private static void Backup()
|
||||
{
|
||||
Console.Write("Crash: Backing up...");
|
||||
|
||||
try
|
||||
{
|
||||
string timeStamp = GetTimeStamp();
|
||||
try
|
||||
{
|
||||
string timeStamp = GetTimeStamp();
|
||||
|
||||
string root = GetRoot();
|
||||
string rootBackup = Combine( root, $"Backups/Crashed/{timeStamp}/");
|
||||
string rootOrigin = Combine( root, string.Format( "Saves/" ) );
|
||||
string root = GetRoot();
|
||||
string rootBackup = Combine(root, $"Backups/Crashed/{timeStamp}/");
|
||||
string rootOrigin = Combine(root, "Saves/");
|
||||
|
||||
// Create new directories
|
||||
CreateDirectory( rootBackup );
|
||||
CreateDirectory( rootBackup, "Accounts/" );
|
||||
CreateDirectory( rootBackup, "Items/" );
|
||||
CreateDirectory( rootBackup, "Mobiles/" );
|
||||
CreateDirectory( rootBackup, "Guilds/" );
|
||||
CreateDirectory( rootBackup, "Regions/" );
|
||||
// Create new directories
|
||||
CreateDirectory(rootBackup);
|
||||
CreateDirectory(rootBackup, "Accounts/");
|
||||
CreateDirectory(rootBackup, "Items/");
|
||||
CreateDirectory(rootBackup, "Mobiles/");
|
||||
CreateDirectory(rootBackup, "Guilds/");
|
||||
CreateDirectory(rootBackup, "Regions/");
|
||||
|
||||
// Copy files
|
||||
CopyFile( rootOrigin, rootBackup, "Accounts/Accounts.xml" );
|
||||
// Copy files
|
||||
CopyFile(rootOrigin, rootBackup, "Accounts/Accounts.xml");
|
||||
|
||||
CopyFile( rootOrigin, rootBackup, "Items/Items.bin" );
|
||||
CopyFile( rootOrigin, rootBackup, "Items/Items.idx" );
|
||||
CopyFile( rootOrigin, rootBackup, "Items/Items.tdb" );
|
||||
CopyFile(rootOrigin, rootBackup, "Items/Items.bin");
|
||||
CopyFile(rootOrigin, rootBackup, "Items/Items.idx");
|
||||
CopyFile(rootOrigin, rootBackup, "Items/Items.tdb");
|
||||
|
||||
CopyFile( rootOrigin, rootBackup, "Mobiles/Mobiles.bin" );
|
||||
CopyFile( rootOrigin, rootBackup, "Mobiles/Mobiles.idx" );
|
||||
CopyFile( rootOrigin, rootBackup, "Mobiles/Mobiles.tdb" );
|
||||
CopyFile(rootOrigin, rootBackup, "Mobiles/Mobiles.bin");
|
||||
CopyFile(rootOrigin, rootBackup, "Mobiles/Mobiles.idx");
|
||||
CopyFile(rootOrigin, rootBackup, "Mobiles/Mobiles.tdb");
|
||||
|
||||
CopyFile( rootOrigin, rootBackup, "Guilds/Guilds.bin" );
|
||||
CopyFile( rootOrigin, rootBackup, "Guilds/Guilds.idx" );
|
||||
CopyFile(rootOrigin, rootBackup, "Guilds/Guilds.bin");
|
||||
CopyFile(rootOrigin, rootBackup, "Guilds/Guilds.idx");
|
||||
|
||||
CopyFile( rootOrigin, rootBackup, "Regions/Regions.bin" );
|
||||
CopyFile( rootOrigin, rootBackup, "Regions/Regions.idx" );
|
||||
CopyFile(rootOrigin, rootBackup, "Regions/Regions.bin");
|
||||
CopyFile(rootOrigin, rootBackup, "Regions/Regions.idx");
|
||||
|
||||
Console.WriteLine( "done" );
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine( "failed" );
|
||||
}
|
||||
}
|
||||
Console.WriteLine("done");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("failed");
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateCrashReport( CrashedEventArgs e )
|
||||
{
|
||||
Console.Write( "Crash: Generating report..." );
|
||||
private static void GenerateCrashReport(CrashedEventArgs e)
|
||||
{
|
||||
Console.Write("Crash: Generating report...");
|
||||
|
||||
try
|
||||
{
|
||||
string timeStamp = GetTimeStamp();
|
||||
string fileName = $"Crash {timeStamp}.log";
|
||||
try
|
||||
{
|
||||
string timeStamp = GetTimeStamp();
|
||||
string fileName = $"Crash {timeStamp}.log";
|
||||
|
||||
string root = GetRoot();
|
||||
string filePath = Combine( root, fileName );
|
||||
string root = GetRoot();
|
||||
string filePath = Combine(root, fileName);
|
||||
|
||||
using ( StreamWriter op = new StreamWriter( filePath ) )
|
||||
{
|
||||
Version ver = Core.Assembly.GetName().Version;
|
||||
using (StreamWriter op = new StreamWriter(filePath))
|
||||
{
|
||||
Version ver = Core.Assembly.GetName().Version;
|
||||
|
||||
op.WriteLine( "Server Crash Report" );
|
||||
op.WriteLine( "===================" );
|
||||
op.WriteLine();
|
||||
op.WriteLine( "RunUO Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision );
|
||||
op.WriteLine( "Operating System: {0}", Environment.OSVersion );
|
||||
op.WriteLine( ".NET Framework: {0}", Environment.Version );
|
||||
op.WriteLine( "Time: {0}", DateTime.UtcNow );
|
||||
op.WriteLine("Server Crash Report");
|
||||
op.WriteLine("===================");
|
||||
op.WriteLine();
|
||||
op.WriteLine("RunUO Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
|
||||
op.WriteLine("Operating System: {0}", Environment.OSVersion);
|
||||
op.WriteLine(".NET Framework: {0}", Environment.Version);
|
||||
op.WriteLine("Time: {0}", DateTime.UtcNow);
|
||||
|
||||
try { op.WriteLine( "Mobiles: {0}", World.Mobiles.Count ); }
|
||||
catch {}
|
||||
try
|
||||
{
|
||||
op.WriteLine("Mobiles: {0}", World.Mobiles.Count);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
try { op.WriteLine( "Items: {0}", World.Items.Count ); }
|
||||
catch {}
|
||||
try
|
||||
{
|
||||
op.WriteLine("Items: {0}", World.Items.Count);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
op.WriteLine( "Exception:" );
|
||||
op.WriteLine( e.Exception );
|
||||
op.WriteLine();
|
||||
op.WriteLine("Exception:");
|
||||
op.WriteLine(e.Exception);
|
||||
op.WriteLine();
|
||||
|
||||
op.WriteLine( "Clients:" );
|
||||
op.WriteLine("Clients:");
|
||||
|
||||
try
|
||||
{
|
||||
List<NetState> states = NetState.Instances;
|
||||
try
|
||||
{
|
||||
List<NetState> states = NetState.Instances;
|
||||
|
||||
op.WriteLine( "- Count: {0}", states.Count );
|
||||
op.WriteLine("- Count: {0}", states.Count);
|
||||
|
||||
for ( int i = 0; i < states.Count; ++i )
|
||||
{
|
||||
NetState state = states[i];
|
||||
for (int i = 0; i < states.Count; ++i)
|
||||
{
|
||||
NetState state = states[i];
|
||||
|
||||
op.Write( "+ {0}:", state );
|
||||
op.Write("+ {0}:", state);
|
||||
|
||||
if ( state.Account is Account a )
|
||||
op.Write( " (account = {0})", a.Username );
|
||||
if (state.Account is Account a)
|
||||
op.Write(" (account = {0})", a.Username);
|
||||
|
||||
Mobile m = state.Mobile;
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( m != null )
|
||||
op.Write( " (mobile = 0x{0:X} '{1}')", m.Serial.Value, m.Name );
|
||||
if (m != null)
|
||||
op.Write(" (mobile = 0x{0:X} '{1}')", m.Serial.Value, m.Name);
|
||||
|
||||
op.WriteLine();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
op.WriteLine( "- Failed" );
|
||||
}
|
||||
}
|
||||
op.WriteLine();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
op.WriteLine("- Failed");
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine( "done" );
|
||||
Console.WriteLine("done");
|
||||
|
||||
if ( Email.FromAddress != null && Email.CrashAddresses != null )
|
||||
SendEmail( filePath );
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine( "failed" );
|
||||
}
|
||||
}
|
||||
if (Email.FromAddress != null && Email.CrashAddresses != null)
|
||||
SendEmail(filePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("failed");
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetTimeStamp()
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
private static string GetTimeStamp()
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
return $"{now.Day}-{now.Month}-{now.Year}-{now.Hour}-{now.Minute}-{now.Second}";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $"{now.Day}-{now.Month}-{now.Year}-{now.Hour}-{now.Minute}-{now.Second}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,37 +3,38 @@ using Server.Network;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public class CurrentExpansion
|
||||
{
|
||||
private static readonly Expansion Expansion = Expansion.TOL;
|
||||
public class CurrentExpansion
|
||||
{
|
||||
private static readonly Expansion Expansion = Expansion.TOL;
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
Core.Expansion = Expansion;
|
||||
public static void Configure()
|
||||
{
|
||||
Core.Expansion = Expansion;
|
||||
|
||||
AccountGold.Enabled = Core.TOL;
|
||||
AccountGold.ConvertOnBank = true;
|
||||
AccountGold.ConvertOnTrade = false;
|
||||
VirtualCheck.UseEditGump = true;
|
||||
AccountGold.Enabled = Core.TOL;
|
||||
AccountGold.ConvertOnBank = true;
|
||||
AccountGold.ConvertOnTrade = false;
|
||||
VirtualCheck.UseEditGump = true;
|
||||
|
||||
bool Enabled = Core.AOS;
|
||||
bool Enabled = Core.AOS;
|
||||
|
||||
Mobile.InsuranceEnabled = Enabled;
|
||||
ObjectPropertyList.Enabled = Enabled;
|
||||
Mobile.VisibleDamageType = Enabled ? VisibleDamageType.Related : VisibleDamageType.None;
|
||||
Mobile.GuildClickMessage = !Enabled;
|
||||
Mobile.AsciiClickMessage = !Enabled;
|
||||
Mobile.InsuranceEnabled = Enabled;
|
||||
ObjectPropertyList.Enabled = Enabled;
|
||||
Mobile.VisibleDamageType = Enabled ? VisibleDamageType.Related : VisibleDamageType.None;
|
||||
Mobile.GuildClickMessage = !Enabled;
|
||||
Mobile.AsciiClickMessage = !Enabled;
|
||||
|
||||
if ( Enabled )
|
||||
{
|
||||
AOS.DisableStatInfluences();
|
||||
if (Enabled)
|
||||
{
|
||||
AOS.DisableStatInfluences();
|
||||
|
||||
if ( ObjectPropertyList.Enabled )
|
||||
PacketHandlers.SingleClickProps = true; // single click for everything is overridden to check object property list
|
||||
if (ObjectPropertyList.Enabled)
|
||||
PacketHandlers.SingleClickProps =
|
||||
true; // single click for everything is overridden to check object property list
|
||||
|
||||
Mobile.ActionDelay = 1000;
|
||||
Mobile.AOSStatusHandler = AOS.GetStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Mobile.ActionDelay = 1000;
|
||||
Mobile.AOSStatusHandler = AOS.GetStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,103 +4,105 @@ using Microsoft.Win32;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class DataPath
|
||||
{
|
||||
/* If you have not installed Ultima Online,
|
||||
* or wish the server to use a separate set of datafiles,
|
||||
* change the 'CustomPath' value.
|
||||
* Example:
|
||||
* private static string CustomPath = @"C:\Program Files\Ultima Online";
|
||||
*/
|
||||
private static string CustomPath = null;
|
||||
public class DataPath
|
||||
{
|
||||
/* If you have not installed Ultima Online,
|
||||
* or wish the server to use a separate set of datafiles,
|
||||
* change the 'CustomPath' value.
|
||||
* Example:
|
||||
* private static string CustomPath = @"C:\Program Files\Ultima Online";
|
||||
*/
|
||||
private static string CustomPath = null;
|
||||
|
||||
/* The following is a list of files which a required for proper execution:
|
||||
*
|
||||
* Multi.idx
|
||||
* Multi.mul
|
||||
* VerData.mul
|
||||
* TileData.mul
|
||||
* Map*.mul or Map*LegacyMUL.uop
|
||||
* StaIdx*.mul
|
||||
* Statics*.mul
|
||||
* MapDif*.mul
|
||||
* MapDifL*.mul
|
||||
* StaDif*.mul
|
||||
* StaDifL*.mul
|
||||
* StaDifI*.mul
|
||||
*/
|
||||
/* The following is a list of files which a required for proper execution:
|
||||
*
|
||||
* Multi.idx
|
||||
* Multi.mul
|
||||
* VerData.mul
|
||||
* TileData.mul
|
||||
* Map*.mul or Map*LegacyMUL.uop
|
||||
* StaIdx*.mul
|
||||
* Statics*.mul
|
||||
* MapDif*.mul
|
||||
* MapDifL*.mul
|
||||
* StaDif*.mul
|
||||
* StaDifL*.mul
|
||||
* StaDifI*.mul
|
||||
*/
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
string pathUO = GetPath( @"Origin Worlds Online\Ultima Online\1.0", "ExePath" );
|
||||
string pathTD = GetPath( @"Origin Worlds Online\Ultima Online Third Dawn\1.0", "ExePath" ); //These refer to 2D & 3D, not the Third Dawn expansion
|
||||
string pathKR = GetPath( @"Origin Worlds Online\Ultima Online\KR Legacy Beta", "ExePath" ); //After KR, This is the new registry key for the 2D client
|
||||
string pathSA = GetPath( @"Electronic Arts\EA Games\Ultima Online Stygian Abyss Classic", "InstallDir" );
|
||||
string pathHS = GetPath( @"Electronic Arts\EA Games\Ultima Online Classic", "InstallDir" );
|
||||
public static void Configure()
|
||||
{
|
||||
string pathUO = GetPath(@"Origin Worlds Online\Ultima Online\1.0", "ExePath");
|
||||
string pathTD = GetPath(@"Origin Worlds Online\Ultima Online Third Dawn\1.0",
|
||||
"ExePath"); //These refer to 2D & 3D, not the Third Dawn expansion
|
||||
string pathKR = GetPath(@"Origin Worlds Online\Ultima Online\KR Legacy Beta",
|
||||
"ExePath"); //After KR, This is the new registry key for the 2D client
|
||||
string pathSA = GetPath(@"Electronic Arts\EA Games\Ultima Online Stygian Abyss Classic", "InstallDir");
|
||||
string pathHS = GetPath(@"Electronic Arts\EA Games\Ultima Online Classic", "InstallDir");
|
||||
|
||||
if ( CustomPath != null )
|
||||
Core.DataDirectories.Add( CustomPath );
|
||||
if (CustomPath != null)
|
||||
Core.DataDirectories.Add(CustomPath);
|
||||
|
||||
if ( pathUO != null )
|
||||
Core.DataDirectories.Add( pathUO );
|
||||
if (pathUO != null)
|
||||
Core.DataDirectories.Add(pathUO);
|
||||
|
||||
if ( pathTD != null )
|
||||
Core.DataDirectories.Add( pathTD );
|
||||
if (pathTD != null)
|
||||
Core.DataDirectories.Add(pathTD);
|
||||
|
||||
if ( pathKR != null )
|
||||
Core.DataDirectories.Add( pathKR );
|
||||
if (pathKR != null)
|
||||
Core.DataDirectories.Add(pathKR);
|
||||
|
||||
if ( pathSA != null )
|
||||
Core.DataDirectories.Add( pathSA );
|
||||
if (pathSA != null)
|
||||
Core.DataDirectories.Add(pathSA);
|
||||
|
||||
if ( pathHS != null )
|
||||
Core.DataDirectories.Add( pathHS );
|
||||
if (pathHS != null)
|
||||
Core.DataDirectories.Add(pathHS);
|
||||
|
||||
if ( Core.DataDirectories.Count == 0 && !Core.Service )
|
||||
{
|
||||
Console.WriteLine( "Enter the Ultima Online directory:" );
|
||||
Console.Write( "> " );
|
||||
if (Core.DataDirectories.Count == 0 && !Core.Service)
|
||||
{
|
||||
Console.WriteLine("Enter the Ultima Online directory:");
|
||||
Console.Write("> ");
|
||||
|
||||
Core.DataDirectories.Add( Console.ReadLine() );
|
||||
}
|
||||
}
|
||||
Core.DataDirectories.Add(Console.ReadLine());
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetPath( string subName, string keyName )
|
||||
{
|
||||
try
|
||||
{
|
||||
string keyString;
|
||||
private static string GetPath(string subName, string keyName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string keyString;
|
||||
|
||||
if ( Core.Is64Bit )
|
||||
keyString = @"SOFTWARE\Wow6432Node\{0}";
|
||||
else
|
||||
keyString = @"SOFTWARE\{0}";
|
||||
if (Core.Is64Bit)
|
||||
keyString = @"SOFTWARE\Wow6432Node\{0}";
|
||||
else
|
||||
keyString = @"SOFTWARE\{0}";
|
||||
|
||||
using( RegistryKey key = Registry.LocalMachine.OpenSubKey( string.Format( keyString, subName ) ) )
|
||||
{
|
||||
if ( key == null )
|
||||
return null;
|
||||
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(string.Format(keyString, subName)))
|
||||
{
|
||||
if (key == null)
|
||||
return null;
|
||||
|
||||
string v = key.GetValue( keyName ) as string;
|
||||
string v = key.GetValue(keyName) as string;
|
||||
|
||||
if ( string.IsNullOrEmpty( v ) )
|
||||
return null;
|
||||
if (string.IsNullOrEmpty(v))
|
||||
return null;
|
||||
|
||||
if ( keyName == "InstallDir" )
|
||||
v = v + @"\";
|
||||
if (keyName == "InstallDir")
|
||||
v = v + @"\";
|
||||
|
||||
v = Path.GetDirectoryName( v );
|
||||
v = Path.GetDirectoryName(v);
|
||||
|
||||
if ( string.IsNullOrEmpty( v ) )
|
||||
return null;
|
||||
if (string.IsNullOrEmpty(v))
|
||||
return null;
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@ using System;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
[AttributeUsage( AttributeTargets.Class )]
|
||||
public class DispellableAttribute : Attribute
|
||||
{
|
||||
}
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class DispellableAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@ using System;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
[AttributeUsage( AttributeTargets.Class )]
|
||||
public class DispellableFieldAttribute : Attribute
|
||||
{
|
||||
}
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class DispellableFieldAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,98 +1,98 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class Email
|
||||
{
|
||||
/* In order to support emailing, fill in EmailServer and FromAddress:
|
||||
* Example:
|
||||
* public static readonly string EmailServer = "mail.domain.com";
|
||||
* public static readonly string FromAddress = "runuo@domain.com";
|
||||
*
|
||||
* If you want to add crash reporting emailing, fill in CrashAddresses:
|
||||
* Example:
|
||||
* public static readonly string CrashAddresses = "first@email.here,second@email.here,third@email.here";
|
||||
*
|
||||
* If you want to add speech log page emailing, fill in SpeechLogPageAddresses:
|
||||
* Example:
|
||||
* public static readonly string SpeechLogPageAddresses = "first@email.here,second@email.here,third@email.here";
|
||||
*/
|
||||
public class Email
|
||||
{
|
||||
/* In order to support emailing, fill in EmailServer and FromAddress:
|
||||
* Example:
|
||||
* public static readonly string EmailServer = "mail.domain.com";
|
||||
* public static readonly string FromAddress = "runuo@domain.com";
|
||||
*
|
||||
* If you want to add crash reporting emailing, fill in CrashAddresses:
|
||||
* Example:
|
||||
* public static readonly string CrashAddresses = "first@email.here,second@email.here,third@email.here";
|
||||
*
|
||||
* If you want to add speech log page emailing, fill in SpeechLogPageAddresses:
|
||||
* Example:
|
||||
* public static readonly string SpeechLogPageAddresses = "first@email.here,second@email.here,third@email.here";
|
||||
*/
|
||||
|
||||
public static readonly string EmailServer = null;
|
||||
public static readonly int EmailPort = 25;
|
||||
public static readonly string EmailServer = null;
|
||||
public static readonly int EmailPort = 25;
|
||||
|
||||
public static readonly string FromAddress = null;
|
||||
public static readonly string EmailUsername = null;
|
||||
public static readonly string EmailPassword = null;
|
||||
public static readonly string FromAddress = null;
|
||||
public static readonly string EmailUsername = null;
|
||||
public static readonly string EmailPassword = null;
|
||||
|
||||
|
||||
public static readonly string CrashAddresses = null;
|
||||
public static readonly string SpeechLogPageAddresses = null;
|
||||
public static readonly string CrashAddresses = null;
|
||||
public static readonly string SpeechLogPageAddresses = null;
|
||||
|
||||
private static Regex _pattern = new Regex( @"^[a-z0-9.+_-]+@([a-z0-9-]+\.)+[a-z]+$", RegexOptions.Compiled | RegexOptions.IgnoreCase );
|
||||
private static Regex _pattern = new Regex(@"^[a-z0-9.+_-]+@([a-z0-9-]+\.)+[a-z]+$",
|
||||
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public static bool IsValid( string address )
|
||||
{
|
||||
if ( address == null || address.Length > 320 )
|
||||
return false;
|
||||
private static SmtpClient _Client;
|
||||
|
||||
return _pattern.IsMatch( address );
|
||||
}
|
||||
public static bool IsValid(string address)
|
||||
{
|
||||
if (address == null || address.Length > 320)
|
||||
return false;
|
||||
|
||||
private static SmtpClient _Client;
|
||||
return _pattern.IsMatch(address);
|
||||
}
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
if ( EmailServer != null )
|
||||
{
|
||||
_Client = new SmtpClient( EmailServer, EmailPort );
|
||||
if ( EmailUsername != null )
|
||||
{
|
||||
_Client.Credentials = new System.Net.NetworkCredential( EmailUsername, EmailPassword );
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void Configure()
|
||||
{
|
||||
if (EmailServer != null)
|
||||
{
|
||||
_Client = new SmtpClient(EmailServer, EmailPort);
|
||||
if (EmailUsername != null) _Client.Credentials = new NetworkCredential(EmailUsername, EmailPassword);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Send( MailMessage message )
|
||||
{
|
||||
try
|
||||
{
|
||||
// .NET relies on the MTA to generate Message-ID header. Not all MTAs will add this header.
|
||||
public static bool Send(MailMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
// .NET relies on the MTA to generate Message-ID header. Not all MTAs will add this header.
|
||||
|
||||
DateTime now = DateTime.UtcNow;
|
||||
string messageID = $"<{now.ToString("yyyyMMdd")}.{now.ToString("HHmmssff")}@{EmailServer}>";
|
||||
message.Headers.Add("Message-ID", messageID );
|
||||
DateTime now = DateTime.UtcNow;
|
||||
string messageID = $"<{now.ToString("yyyyMMdd")}.{now.ToString("HHmmssff")}@{EmailServer}>";
|
||||
message.Headers.Add("Message-ID", messageID);
|
||||
|
||||
message.Headers.Add("X-Mailer", "RunUO");
|
||||
message.Headers.Add("X-Mailer", "RunUO");
|
||||
|
||||
lock ( _Client ) {
|
||||
_Client.Send( message );
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
lock (_Client)
|
||||
{
|
||||
_Client.Send(message);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void AsyncSend( MailMessage message )
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem( SendCallback, message );
|
||||
}
|
||||
public static void AsyncSend(MailMessage message)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(SendCallback, message);
|
||||
}
|
||||
|
||||
private static void SendCallback( object state )
|
||||
{
|
||||
MailMessage message = (MailMessage) state;
|
||||
private static void SendCallback(object state)
|
||||
{
|
||||
MailMessage message = (MailMessage)state;
|
||||
|
||||
if ( Send( message ) )
|
||||
Console.WriteLine( "Sent e-mail '{0}' to '{1}'.", message.Subject, message.To );
|
||||
else
|
||||
Console.WriteLine( "Failure sending e-mail '{0}' to '{1}'.", message.Subject, message.To );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Send(message))
|
||||
Console.WriteLine("Sent e-mail '{0}' to '{1}'.", message.Subject, message.To);
|
||||
else
|
||||
Console.WriteLine("Failure sending e-mail '{0}' to '{1}'.", message.Subject, message.To);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,30 +2,32 @@ using System;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
// This fastwalk detection is no longer required
|
||||
// As of B36 PlayerMobile implements movement packet throttling which more reliably controls movement speeds
|
||||
public class Fastwalk
|
||||
{
|
||||
private static int MaxSteps = 4; // Maximum number of queued steps until fastwalk is detected
|
||||
private static bool Enabled = false; // Is fastwalk detection enabled?
|
||||
private static bool UOTDOverride = false; // Should UO:TD clients not be checked for fastwalk?
|
||||
private static AccessLevel AccessOverride = AccessLevel.GameMaster; // Anyone with this or higher access level is not checked for fastwalk
|
||||
// This fastwalk detection is no longer required
|
||||
// As of B36 PlayerMobile implements movement packet throttling which more reliably controls movement speeds
|
||||
public class Fastwalk
|
||||
{
|
||||
private static int MaxSteps = 4; // Maximum number of queued steps until fastwalk is detected
|
||||
private static bool Enabled = false; // Is fastwalk detection enabled?
|
||||
private static bool UOTDOverride = false; // Should UO:TD clients not be checked for fastwalk?
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Mobile.FwdMaxSteps = MaxSteps;
|
||||
Mobile.FwdEnabled = Enabled;
|
||||
Mobile.FwdUOTDOverride = UOTDOverride;
|
||||
Mobile.FwdAccessOverride = AccessOverride;
|
||||
private static AccessLevel
|
||||
AccessOverride = AccessLevel.GameMaster; // Anyone with this or higher access level is not checked for fastwalk
|
||||
|
||||
if ( Enabled )
|
||||
EventSink.FastWalk += OnFastWalk;
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
Mobile.FwdMaxSteps = MaxSteps;
|
||||
Mobile.FwdEnabled = Enabled;
|
||||
Mobile.FwdUOTDOverride = UOTDOverride;
|
||||
Mobile.FwdAccessOverride = AccessOverride;
|
||||
|
||||
public static void OnFastWalk( FastWalkEventArgs e )
|
||||
{
|
||||
e.Blocked = true;//disallow this fastwalk
|
||||
Console.WriteLine( "Client: {0}: Fast movement detected (name={1})", e.NetState, e.NetState.Mobile.Name );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Enabled)
|
||||
EventSink.FastWalk += OnFastWalk;
|
||||
}
|
||||
|
||||
public static void OnFastWalk(FastWalkEventArgs e)
|
||||
{
|
||||
e.Blocked = true; //disallow this fastwalk
|
||||
Console.WriteLine("Client: {0}: Fast movement detected (name={1})", e.NetState, e.NetState.Mobile.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,42 +3,42 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class FoodDecayTimer : Timer
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
new FoodDecayTimer().Start();
|
||||
}
|
||||
public class FoodDecayTimer : Timer
|
||||
{
|
||||
public FoodDecayTimer() : base(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5))
|
||||
{
|
||||
Priority = TimerPriority.OneMinute;
|
||||
}
|
||||
|
||||
public FoodDecayTimer() : base( TimeSpan.FromMinutes( 5 ), TimeSpan.FromMinutes( 5 ) )
|
||||
{
|
||||
Priority = TimerPriority.OneMinute;
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
new FoodDecayTimer().Start();
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
FoodDecay();
|
||||
}
|
||||
protected override void OnTick()
|
||||
{
|
||||
FoodDecay();
|
||||
}
|
||||
|
||||
public static void FoodDecay()
|
||||
{
|
||||
foreach ( NetState state in NetState.Instances )
|
||||
{
|
||||
HungerDecay( state.Mobile );
|
||||
ThirstDecay( state.Mobile );
|
||||
}
|
||||
}
|
||||
public static void FoodDecay()
|
||||
{
|
||||
foreach (NetState state in NetState.Instances)
|
||||
{
|
||||
HungerDecay(state.Mobile);
|
||||
ThirstDecay(state.Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
public static void HungerDecay( Mobile m )
|
||||
{
|
||||
if ( m != null && m.Hunger >= 1 )
|
||||
m.Hunger -= 1;
|
||||
}
|
||||
public static void HungerDecay(Mobile m)
|
||||
{
|
||||
if (m != null && m.Hunger >= 1)
|
||||
m.Hunger -= 1;
|
||||
}
|
||||
|
||||
public static void ThirstDecay( Mobile m )
|
||||
{
|
||||
if ( m != null && m.Thirst >= 1 )
|
||||
m.Thirst -= 1;
|
||||
}
|
||||
}
|
||||
public static void ThirstDecay(Mobile m)
|
||||
{
|
||||
if (m != null && m.Thirst >= 1)
|
||||
m.Thirst -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,220 +2,226 @@ using System;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public delegate void DoEffect_Callback( Point3D p, Map map );
|
||||
|
||||
public static class Geometry
|
||||
{
|
||||
public static void Swap<T>( ref T a, ref T b )
|
||||
{
|
||||
T temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
public static double RadiansToDegrees( double angle )
|
||||
{
|
||||
return angle * (180.0 / Math.PI);
|
||||
}
|
||||
|
||||
public static double DegreesToRadians( double angle )
|
||||
{
|
||||
return angle * ( Math.PI / 180.0 );
|
||||
}
|
||||
|
||||
public class CirclePoint
|
||||
{
|
||||
public Point2D Point { get; }
|
||||
public delegate void DoEffect_Callback(Point3D p, Map map);
|
||||
|
||||
public int Angle { get; }
|
||||
public static class Geometry
|
||||
{
|
||||
public static void Swap<T>(ref T a, ref T b)
|
||||
{
|
||||
T temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
public int Quadrant { get; }
|
||||
public static double RadiansToDegrees(double angle)
|
||||
{
|
||||
return angle * (180.0 / Math.PI);
|
||||
}
|
||||
|
||||
public CirclePoint( Point2D point, int angle, int quadrant )
|
||||
{
|
||||
this.Point = point;
|
||||
this.Angle = angle;
|
||||
this.Quadrant = quadrant;
|
||||
}
|
||||
}
|
||||
public static double DegreesToRadians(double angle)
|
||||
{
|
||||
return angle * (Math.PI / 180.0);
|
||||
}
|
||||
|
||||
public static Point2D ArcPoint( Point3D loc, int radius, int angle )
|
||||
{
|
||||
int sideA, sideB;
|
||||
|
||||
if ( angle < 0 )
|
||||
angle = 0;
|
||||
|
||||
if ( angle > 90 )
|
||||
angle = 90;
|
||||
|
||||
sideA = (int) Math.Round( radius * Math.Sin( DegreesToRadians( angle ) ) );
|
||||
sideB = (int) Math.Round( radius * Math.Cos( DegreesToRadians( angle ) ) );
|
||||
|
||||
return new Point2D( loc.X - sideB, loc.Y - sideA );
|
||||
}
|
||||
|
||||
public static void Circle2D( Point3D loc, Map map, int radius, DoEffect_Callback effect )
|
||||
{
|
||||
Circle2D( loc, map, radius, effect, 0, 360 );
|
||||
}
|
||||
|
||||
public static void Circle2D( Point3D loc, Map map, int radius, DoEffect_Callback effect, int angleStart, int angleEnd )
|
||||
{
|
||||
if ( angleStart < 0 || angleStart > 360 )
|
||||
angleStart = 0;
|
||||
|
||||
if ( angleEnd > 360 || angleEnd < 0 )
|
||||
angleEnd = 360;
|
||||
|
||||
if ( angleStart == angleEnd )
|
||||
return;
|
||||
public static Point2D ArcPoint(Point3D loc, int radius, int angle)
|
||||
{
|
||||
int sideA, sideB;
|
||||
|
||||
bool opposite = angleStart > angleEnd;
|
||||
|
||||
int startQuadrant = angleStart / 90;
|
||||
int endQuadrant = angleEnd / 90;
|
||||
|
||||
Point2D start = ArcPoint( loc, radius, angleStart % 90 );
|
||||
Point2D end = ArcPoint( loc, radius, angleEnd % 90 );
|
||||
|
||||
if ( opposite )
|
||||
{
|
||||
Swap( ref start, ref end );
|
||||
Swap( ref startQuadrant, ref endQuadrant );
|
||||
}
|
||||
|
||||
CirclePoint startPoint = new CirclePoint( start, angleStart, startQuadrant );
|
||||
CirclePoint endPoint = new CirclePoint( end, angleEnd, endQuadrant );
|
||||
|
||||
int error = -radius;
|
||||
int x = radius;
|
||||
int y = 0;
|
||||
|
||||
while (x > y)
|
||||
{
|
||||
plot4points( loc, map, x, y, startPoint, endPoint, effect, opposite );
|
||||
plot4points( loc, map, y, x, startPoint, endPoint, effect, opposite );
|
||||
|
||||
error += ( y * 2 ) + 1;
|
||||
++y;
|
||||
|
||||
if (error >= 0)
|
||||
{
|
||||
--x;
|
||||
error -= x * 2;
|
||||
}
|
||||
}
|
||||
|
||||
plot4points( loc, map, x, y, startPoint, endPoint, effect, opposite );
|
||||
}
|
||||
|
||||
public static void plot4points( Point3D loc, Map map, int x, int y, CirclePoint start, CirclePoint end, DoEffect_Callback effect, bool opposite )
|
||||
{
|
||||
Point2D pointA = new Point2D( loc.X - x, loc.Y - y );
|
||||
Point2D pointB = new Point2D( loc.X - y, loc.Y - x );
|
||||
|
||||
int quadrant = 2;
|
||||
|
||||
if ( x == 0 && start.Quadrant == 3 )
|
||||
quadrant = 3;
|
||||
|
||||
if ( WithinCircleBounds( quadrant == 3 ? pointB : pointA, quadrant, loc, start, end, opposite ) )
|
||||
effect( new Point3D( loc.X + x, loc.Y + y, loc.Z ), map );
|
||||
|
||||
quadrant = 3;
|
||||
|
||||
if ( y == 0 && start.Quadrant == 0 )
|
||||
quadrant = 0;
|
||||
|
||||
if ( x != 0 && WithinCircleBounds( quadrant == 0 ? pointA : pointB, quadrant, loc, start, end, opposite ) )
|
||||
effect( new Point3D( loc.X - x, loc.Y + y, loc.Z ), map );
|
||||
if ( y != 0 && WithinCircleBounds( pointB, 1, loc, start, end, opposite ) )
|
||||
effect( new Point3D( loc.X + x, loc.Y - y, loc.Z ), map );
|
||||
if ( x != 0 && y != 0 && WithinCircleBounds( pointA, 0, loc, start, end, opposite ) )
|
||||
effect( new Point3D( loc.X - x, loc.Y - y, loc.Z ), map );
|
||||
}
|
||||
|
||||
public static bool WithinCircleBounds( Point2D pointLoc, int pointQuadrant, Point3D center, CirclePoint start, CirclePoint end, bool opposite )
|
||||
{
|
||||
if ( start.Angle == 0 && end.Angle == 360 )
|
||||
return true;
|
||||
if (angle < 0)
|
||||
angle = 0;
|
||||
|
||||
int startX = start.Point.X;
|
||||
int startY = start.Point.Y;
|
||||
int endX = end.Point.X;
|
||||
int endY = end.Point.Y;
|
||||
|
||||
int x = pointLoc.X;
|
||||
int y = pointLoc.Y;
|
||||
if (angle > 90)
|
||||
angle = 90;
|
||||
|
||||
if ( pointQuadrant < start.Quadrant || pointQuadrant > end.Quadrant )
|
||||
return opposite;
|
||||
|
||||
if ( pointQuadrant > start.Quadrant && pointQuadrant < end.Quadrant )
|
||||
return !opposite;
|
||||
sideA = (int)Math.Round(radius * Math.Sin(DegreesToRadians(angle)));
|
||||
sideB = (int)Math.Round(radius * Math.Cos(DegreesToRadians(angle)));
|
||||
|
||||
bool withinBounds = true;
|
||||
|
||||
if ( start.Quadrant == end.Quadrant )
|
||||
{
|
||||
if ( startX == endX && ( x > startX || y > startY || y < endY ) )
|
||||
withinBounds = false;
|
||||
else if ( startY == endY && ( y < startY || x < startX || x > endX ) )
|
||||
withinBounds = false;
|
||||
else if ( x < startX || x > endX || y > startY || y < endY )
|
||||
withinBounds = false;
|
||||
}
|
||||
else if ( pointQuadrant == start.Quadrant && ( x < startX || y > startY ) )
|
||||
withinBounds = false;
|
||||
else if ( pointQuadrant == end.Quadrant && ( x > endX || y < endY ) )
|
||||
withinBounds = false;
|
||||
|
||||
return opposite ? !withinBounds : withinBounds;
|
||||
}
|
||||
return new Point2D(loc.X - sideB, loc.Y - sideA);
|
||||
}
|
||||
|
||||
public static void Line2D( Point3D start, Point3D end, Map map, DoEffect_Callback effect )
|
||||
{
|
||||
bool steep = Math.Abs( end.Y - start.Y ) > Math.Abs( end.X - start.X );
|
||||
|
||||
int x0 = start.X;
|
||||
int x1 = end.X;
|
||||
int y0 = start.Y;
|
||||
int y1 = end.Y;
|
||||
|
||||
if ( steep )
|
||||
{
|
||||
Swap( ref x0, ref y0 );
|
||||
Swap( ref x1, ref y1 );
|
||||
}
|
||||
|
||||
if ( x0 > x1 )
|
||||
{
|
||||
Swap( ref x0, ref x1 );
|
||||
Swap( ref y0, ref y1 );
|
||||
}
|
||||
|
||||
int deltax = x1 - x0;
|
||||
int deltay = Math.Abs( y1 - y0 );
|
||||
int error = deltax / 2;
|
||||
int ystep = y0 < y1 ? 1 : -1;
|
||||
int y = y0;
|
||||
|
||||
for ( int x = x0; x <= x1; x++ )
|
||||
{
|
||||
if ( steep )
|
||||
effect( new Point3D( y, x, start.Z ), map );
|
||||
else
|
||||
effect( new Point3D( x, y, start.Z ), map );
|
||||
|
||||
error -= deltay;
|
||||
|
||||
if ( error < 0 )
|
||||
{
|
||||
y += ystep;
|
||||
error += deltax;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void Circle2D(Point3D loc, Map map, int radius, DoEffect_Callback effect)
|
||||
{
|
||||
Circle2D(loc, map, radius, effect, 0, 360);
|
||||
}
|
||||
|
||||
public static void Circle2D(Point3D loc, Map map, int radius, DoEffect_Callback effect, int angleStart, int angleEnd)
|
||||
{
|
||||
if (angleStart < 0 || angleStart > 360)
|
||||
angleStart = 0;
|
||||
|
||||
if (angleEnd > 360 || angleEnd < 0)
|
||||
angleEnd = 360;
|
||||
|
||||
if (angleStart == angleEnd)
|
||||
return;
|
||||
|
||||
bool opposite = angleStart > angleEnd;
|
||||
|
||||
int startQuadrant = angleStart / 90;
|
||||
int endQuadrant = angleEnd / 90;
|
||||
|
||||
Point2D start = ArcPoint(loc, radius, angleStart % 90);
|
||||
Point2D end = ArcPoint(loc, radius, angleEnd % 90);
|
||||
|
||||
if (opposite)
|
||||
{
|
||||
Swap(ref start, ref end);
|
||||
Swap(ref startQuadrant, ref endQuadrant);
|
||||
}
|
||||
|
||||
CirclePoint startPoint = new CirclePoint(start, angleStart, startQuadrant);
|
||||
CirclePoint endPoint = new CirclePoint(end, angleEnd, endQuadrant);
|
||||
|
||||
int error = -radius;
|
||||
int x = radius;
|
||||
int y = 0;
|
||||
|
||||
while (x > y)
|
||||
{
|
||||
plot4points(loc, map, x, y, startPoint, endPoint, effect, opposite);
|
||||
plot4points(loc, map, y, x, startPoint, endPoint, effect, opposite);
|
||||
|
||||
error += y * 2 + 1;
|
||||
++y;
|
||||
|
||||
if (error >= 0)
|
||||
{
|
||||
--x;
|
||||
error -= x * 2;
|
||||
}
|
||||
}
|
||||
|
||||
plot4points(loc, map, x, y, startPoint, endPoint, effect, opposite);
|
||||
}
|
||||
|
||||
public static void plot4points(Point3D loc, Map map, int x, int y, CirclePoint start, CirclePoint end,
|
||||
DoEffect_Callback effect, bool opposite)
|
||||
{
|
||||
Point2D pointA = new Point2D(loc.X - x, loc.Y - y);
|
||||
Point2D pointB = new Point2D(loc.X - y, loc.Y - x);
|
||||
|
||||
int quadrant = 2;
|
||||
|
||||
if (x == 0 && start.Quadrant == 3)
|
||||
quadrant = 3;
|
||||
|
||||
if (WithinCircleBounds(quadrant == 3 ? pointB : pointA, quadrant, loc, start, end, opposite))
|
||||
effect(new Point3D(loc.X + x, loc.Y + y, loc.Z), map);
|
||||
|
||||
quadrant = 3;
|
||||
|
||||
if (y == 0 && start.Quadrant == 0)
|
||||
quadrant = 0;
|
||||
|
||||
if (x != 0 && WithinCircleBounds(quadrant == 0 ? pointA : pointB, quadrant, loc, start, end, opposite))
|
||||
effect(new Point3D(loc.X - x, loc.Y + y, loc.Z), map);
|
||||
if (y != 0 && WithinCircleBounds(pointB, 1, loc, start, end, opposite))
|
||||
effect(new Point3D(loc.X + x, loc.Y - y, loc.Z), map);
|
||||
if (x != 0 && y != 0 && WithinCircleBounds(pointA, 0, loc, start, end, opposite))
|
||||
effect(new Point3D(loc.X - x, loc.Y - y, loc.Z), map);
|
||||
}
|
||||
|
||||
public static bool WithinCircleBounds(Point2D pointLoc, int pointQuadrant, Point3D center, CirclePoint start,
|
||||
CirclePoint end, bool opposite)
|
||||
{
|
||||
if (start.Angle == 0 && end.Angle == 360)
|
||||
return true;
|
||||
|
||||
int startX = start.Point.X;
|
||||
int startY = start.Point.Y;
|
||||
int endX = end.Point.X;
|
||||
int endY = end.Point.Y;
|
||||
|
||||
int x = pointLoc.X;
|
||||
int y = pointLoc.Y;
|
||||
|
||||
if (pointQuadrant < start.Quadrant || pointQuadrant > end.Quadrant)
|
||||
return opposite;
|
||||
|
||||
if (pointQuadrant > start.Quadrant && pointQuadrant < end.Quadrant)
|
||||
return !opposite;
|
||||
|
||||
bool withinBounds = true;
|
||||
|
||||
if (start.Quadrant == end.Quadrant)
|
||||
{
|
||||
if (startX == endX && (x > startX || y > startY || y < endY))
|
||||
withinBounds = false;
|
||||
else if (startY == endY && (y < startY || x < startX || x > endX))
|
||||
withinBounds = false;
|
||||
else if (x < startX || x > endX || y > startY || y < endY)
|
||||
withinBounds = false;
|
||||
}
|
||||
else if (pointQuadrant == start.Quadrant && (x < startX || y > startY))
|
||||
{
|
||||
withinBounds = false;
|
||||
}
|
||||
else if (pointQuadrant == end.Quadrant && (x > endX || y < endY))
|
||||
{
|
||||
withinBounds = false;
|
||||
}
|
||||
|
||||
return opposite ? !withinBounds : withinBounds;
|
||||
}
|
||||
|
||||
public static void Line2D(Point3D start, Point3D end, Map map, DoEffect_Callback effect)
|
||||
{
|
||||
bool steep = Math.Abs(end.Y - start.Y) > Math.Abs(end.X - start.X);
|
||||
|
||||
int x0 = start.X;
|
||||
int x1 = end.X;
|
||||
int y0 = start.Y;
|
||||
int y1 = end.Y;
|
||||
|
||||
if (steep)
|
||||
{
|
||||
Swap(ref x0, ref y0);
|
||||
Swap(ref x1, ref y1);
|
||||
}
|
||||
|
||||
if (x0 > x1)
|
||||
{
|
||||
Swap(ref x0, ref x1);
|
||||
Swap(ref y0, ref y1);
|
||||
}
|
||||
|
||||
int deltax = x1 - x0;
|
||||
int deltay = Math.Abs(y1 - y0);
|
||||
int error = deltax / 2;
|
||||
int ystep = y0 < y1 ? 1 : -1;
|
||||
int y = y0;
|
||||
|
||||
for (int x = x0; x <= x1; x++)
|
||||
{
|
||||
if (steep)
|
||||
effect(new Point3D(y, x, start.Z), map);
|
||||
else
|
||||
effect(new Point3D(x, y, start.Z), map);
|
||||
|
||||
error -= deltay;
|
||||
|
||||
if (error < 0)
|
||||
{
|
||||
y += ystep;
|
||||
error += deltax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CirclePoint
|
||||
{
|
||||
public CirclePoint(Point2D point, int angle, int quadrant)
|
||||
{
|
||||
Point = point;
|
||||
Angle = angle;
|
||||
Quadrant = quadrant;
|
||||
}
|
||||
|
||||
public Point2D Point{ get; }
|
||||
|
||||
public int Angle{ get; }
|
||||
|
||||
public int Quadrant{ get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +1,44 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
public class DecorativeTopiary : Item
|
||||
{
|
||||
[Constructible]
|
||||
public DecorativeTopiary() : base( 0x2378 )
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
public class DecorativeTopiary : Item
|
||||
{
|
||||
[Constructible]
|
||||
public DecorativeTopiary() : base(0x2378)
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public DecorativeTopiary( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public DecorativeTopiary(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
base.OnSingleClick( from );
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
LabelTo( from, 1070880 ); // Winter 2004
|
||||
}
|
||||
LabelTo(from, 1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add( 1070880 ); // Winter 2004
|
||||
}
|
||||
list.Add(1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +1,44 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
public class FestiveCactus : Item
|
||||
{
|
||||
[Constructible]
|
||||
public FestiveCactus() : base( 0x2376 )
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
public class FestiveCactus : Item
|
||||
{
|
||||
[Constructible]
|
||||
public FestiveCactus() : base(0x2376)
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public FestiveCactus( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public FestiveCactus(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
base.OnSingleClick( from );
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
LabelTo( from, 1070880 ); // Winter 2004
|
||||
}
|
||||
LabelTo(from, 1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add( 1070880 ); // Winter 2004
|
||||
}
|
||||
list.Add(1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,99 +1,98 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
[FlippableAttribute( 0x236E, 0x2371 )]
|
||||
public class LightOfTheWinterSolstice : Item
|
||||
{
|
||||
private static string[] m_StaffNames = {
|
||||
"Aenima",
|
||||
"Alkiser",
|
||||
"ASayre",
|
||||
"David",
|
||||
"Krrios",
|
||||
"Mark",
|
||||
"Merlin",
|
||||
"Merlix", //LordMerlix
|
||||
"Phantom",
|
||||
"Phenos",
|
||||
"psz",
|
||||
"Ryan",
|
||||
"Quantos",
|
||||
"Outkast", //TheOutkastDev
|
||||
"V", //Admin_V
|
||||
"Zippy"
|
||||
};
|
||||
[Flippable(0x236E, 0x2371)]
|
||||
public class LightOfTheWinterSolstice : Item
|
||||
{
|
||||
private static string[] m_StaffNames =
|
||||
{
|
||||
"Aenima",
|
||||
"Alkiser",
|
||||
"ASayre",
|
||||
"David",
|
||||
"Krrios",
|
||||
"Mark",
|
||||
"Merlin",
|
||||
"Merlix", //LordMerlix
|
||||
"Phantom",
|
||||
"Phenos",
|
||||
"psz",
|
||||
"Ryan",
|
||||
"Quantos",
|
||||
"Outkast", //TheOutkastDev
|
||||
"V", //Admin_V
|
||||
"Zippy"
|
||||
};
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public string Dipper { get; set; }
|
||||
[Constructible]
|
||||
public LightOfTheWinterSolstice() : this(m_StaffNames[Utility.Random(m_StaffNames.Length)])
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public LightOfTheWinterSolstice() : this( m_StaffNames[Utility.Random( m_StaffNames.Length )] )
|
||||
{
|
||||
}
|
||||
[Constructible]
|
||||
public LightOfTheWinterSolstice(string dipper) : base(0x236E)
|
||||
{
|
||||
Dipper = dipper;
|
||||
|
||||
[Constructible]
|
||||
public LightOfTheWinterSolstice( string dipper ) : base( 0x236E )
|
||||
{
|
||||
Dipper = dipper;
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
Light = LightType.Circle300;
|
||||
Hue = Utility.RandomDyedHue();
|
||||
}
|
||||
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
Light = LightType.Circle300;
|
||||
Hue = Utility.RandomDyedHue();
|
||||
}
|
||||
public LightOfTheWinterSolstice(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public LightOfTheWinterSolstice( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string Dipper{ get; set; }
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
base.OnSingleClick( from );
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
LabelTo( from, 1070881, Dipper ); // Hand Dipped by ~1_name~
|
||||
LabelTo( from, 1070880 ); // Winter 2004
|
||||
}
|
||||
LabelTo(from, 1070881, Dipper); // Hand Dipped by ~1_name~
|
||||
LabelTo(from, 1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add( 1070881, Dipper ); // Hand Dipped by ~1_name~
|
||||
list.Add( 1070880 ); // Winter 2004
|
||||
}
|
||||
list.Add(1070881, Dipper); // Hand Dipped by ~1_name~
|
||||
list.Add(1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write( (string) Dipper );
|
||||
}
|
||||
writer.Write(Dipper);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch ( version )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Dipper = reader.ReadString();
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
Dipper = m_StaffNames[Utility.Random( m_StaffNames.Length )];
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Dipper = reader.ReadString();
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
Dipper = m_StaffNames[Utility.Random(m_StaffNames.Length)];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( Dipper != null )
|
||||
Dipper = string.Intern( Dipper );
|
||||
}
|
||||
}
|
||||
if (Dipper != null)
|
||||
Dipper = string.Intern(Dipper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,325 +6,325 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class MistletoeAddon : Item, IDyable, IAddon
|
||||
{
|
||||
[Constructible]
|
||||
public MistletoeAddon() : this( Utility.RandomDyedHue() )
|
||||
{
|
||||
}
|
||||
public class MistletoeAddon : Item, IDyable, IAddon
|
||||
{
|
||||
[Constructible]
|
||||
public MistletoeAddon() : this(Utility.RandomDyedHue())
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public MistletoeAddon( int hue ) : base( 0x2375 )
|
||||
{
|
||||
Hue = hue;
|
||||
Movable = false;
|
||||
}
|
||||
[Constructible]
|
||||
public MistletoeAddon(int hue) : base(0x2375)
|
||||
{
|
||||
Hue = hue;
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public MistletoeAddon( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public MistletoeAddon(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public bool CouldFit( IPoint3D p, Map map )
|
||||
{
|
||||
if ( !map.CanFit( p.X, p.Y, p.Z, ItemData.Height ) )
|
||||
return false;
|
||||
public bool CouldFit(IPoint3D p, Map map)
|
||||
{
|
||||
if (!map.CanFit(p.X, p.Y, p.Z, ItemData.Height))
|
||||
return false;
|
||||
|
||||
if ( ItemID == 0x2375 )
|
||||
return BaseAddon.IsWall( p.X, p.Y - 1, p.Z, map ); // North wall
|
||||
return BaseAddon.IsWall( p.X - 1, p.Y, p.Z, map ); // West wall
|
||||
}
|
||||
if (ItemID == 0x2375)
|
||||
return BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map); // North wall
|
||||
return BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map); // West wall
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public Item Deed => new MistletoeDeed(Hue);
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
public virtual bool Dye(Mobile from, DyeTub sender)
|
||||
{
|
||||
if (Deleted)
|
||||
return false;
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
BaseHouse house = BaseHouse.FindHouseAt(this);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
if (house != null && house.IsCoOwner(from))
|
||||
{
|
||||
if (from.InRange(GetWorldLocation(), 1))
|
||||
{
|
||||
Hue = sender.DyedHue;
|
||||
return true;
|
||||
}
|
||||
|
||||
Timer.DelayCall( TimeSpan.Zero, FixMovingCrate );
|
||||
}
|
||||
from.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
return false;
|
||||
}
|
||||
|
||||
private void FixMovingCrate()
|
||||
{
|
||||
if ( Deleted )
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( Movable || IsLockedDown )
|
||||
{
|
||||
Item deed = Deed;
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
if ( Parent is Item item )
|
||||
{
|
||||
item.AddItem( deed );
|
||||
deed.Location = Location;
|
||||
}
|
||||
else
|
||||
{
|
||||
deed.MoveToWorld( Location, Map );
|
||||
}
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
public Item Deed => new MistletoeDeed( Hue );
|
||||
int version = reader.ReadInt();
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt( this );
|
||||
Timer.DelayCall(TimeSpan.Zero, FixMovingCrate);
|
||||
}
|
||||
|
||||
if ( house != null && house.IsCoOwner( from ) )
|
||||
{
|
||||
if ( from.InRange( GetWorldLocation(), 3 ) )
|
||||
{
|
||||
from.CloseGump( typeof( MistletoeAddonGump ) );
|
||||
from.SendGump( new MistletoeAddonGump( from, this ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
}
|
||||
}
|
||||
}
|
||||
private void FixMovingCrate()
|
||||
{
|
||||
if (Deleted)
|
||||
return;
|
||||
|
||||
public virtual bool Dye( Mobile from, DyeTub sender )
|
||||
{
|
||||
if ( Deleted )
|
||||
return false;
|
||||
if (Movable || IsLockedDown)
|
||||
{
|
||||
Item deed = Deed;
|
||||
|
||||
BaseHouse house = BaseHouse.FindHouseAt( this );
|
||||
if (Parent is Item item)
|
||||
{
|
||||
item.AddItem(deed);
|
||||
deed.Location = Location;
|
||||
}
|
||||
else
|
||||
{
|
||||
deed.MoveToWorld(Location, Map);
|
||||
}
|
||||
|
||||
if ( house != null && house.IsCoOwner( from ) )
|
||||
{
|
||||
if ( from.InRange( GetWorldLocation(), 1 ) )
|
||||
{
|
||||
Hue = sender.DyedHue;
|
||||
return true;
|
||||
}
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage( 500295 ); // You are too far away to do that.
|
||||
return false;
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(this);
|
||||
|
||||
return false;
|
||||
}
|
||||
if (house != null && house.IsCoOwner(from))
|
||||
{
|
||||
if (from.InRange(GetWorldLocation(), 3))
|
||||
{
|
||||
from.CloseGump(typeof(MistletoeAddonGump));
|
||||
from.SendGump(new MistletoeAddonGump(from, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MistletoeAddonGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private MistletoeAddon m_Addon;
|
||||
private class MistletoeAddonGump : Gump
|
||||
{
|
||||
private MistletoeAddon m_Addon;
|
||||
private Mobile m_From;
|
||||
|
||||
public MistletoeAddonGump( Mobile from, MistletoeAddon addon ) : base( 150, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Addon = addon;
|
||||
public MistletoeAddonGump(Mobile from, MistletoeAddon addon) : base(150, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Addon = addon;
|
||||
|
||||
AddPage( 0 );
|
||||
AddPage(0);
|
||||
|
||||
AddBackground( 0, 0, 220, 170, 0x13BE );
|
||||
AddBackground( 10, 10, 200, 150, 0xBB8 );
|
||||
AddHtmlLocalized( 20, 30, 180, 60, 1062839, false, false ); // Do you wish to re-deed this decoration?
|
||||
AddHtmlLocalized( 55, 100, 160, 25, 1011011, false, false ); // CONTINUE
|
||||
AddButton( 20, 100, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
|
||||
AddHtmlLocalized( 55, 125, 160, 25, 1011012, false, false ); // CANCEL
|
||||
AddButton( 20, 125, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
AddBackground(0, 0, 220, 170, 0x13BE);
|
||||
AddBackground(10, 10, 200, 150, 0xBB8);
|
||||
AddHtmlLocalized(20, 30, 180, 60, 1062839, false, false); // Do you wish to re-deed this decoration?
|
||||
AddHtmlLocalized(55, 100, 160, 25, 1011011, false, false); // CONTINUE
|
||||
AddButton(20, 100, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(55, 125, 160, 25, 1011012, false, false); // CANCEL
|
||||
AddButton(20, 125, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( m_Addon.Deleted )
|
||||
return;
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (m_Addon.Deleted)
|
||||
return;
|
||||
|
||||
if ( info.ButtonID == 1 )
|
||||
{
|
||||
if ( m_From.InRange( m_Addon.GetWorldLocation(), 3 ) )
|
||||
{
|
||||
m_From.AddToBackpack( m_Addon.Deed );
|
||||
m_Addon.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendLocalizedMessage( 500295 ); // You are too far away to do that.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (info.ButtonID == 1)
|
||||
{
|
||||
if (m_From.InRange(m_Addon.GetWorldLocation(), 3))
|
||||
{
|
||||
m_From.AddToBackpack(m_Addon.Deed);
|
||||
m_Addon.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendLocalizedMessage(500295); // You are too far away to do that.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Flippable( 0x14F0, 0x14EF )]
|
||||
public class MistletoeDeed : Item
|
||||
{
|
||||
public override int LabelNumber => 1070882; // Mistletoe Deed
|
||||
[Flippable(0x14F0, 0x14EF)]
|
||||
public class MistletoeDeed : Item
|
||||
{
|
||||
[Constructible]
|
||||
public MistletoeDeed() : this(0)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public MistletoeDeed() : this( 0 )
|
||||
{
|
||||
}
|
||||
[Constructible]
|
||||
public MistletoeDeed(int hue) : base(0x14F0)
|
||||
{
|
||||
Hue = hue;
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public MistletoeDeed( int hue ) : base( 0x14F0 )
|
||||
{
|
||||
Hue = hue;
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
public MistletoeDeed(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public MistletoeDeed( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override int LabelNumber => 1070882; // Mistletoe Deed
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
base.OnSingleClick( from );
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
LabelTo( from, 1070880 ); // Winter 2004
|
||||
}
|
||||
LabelTo(from, 1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add( 1070880 ); // Winter 2004
|
||||
}
|
||||
list.Add(1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( IsChildOf( from.Backpack ) )
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt( from );
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(from);
|
||||
|
||||
if ( house != null && house.IsCoOwner( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1062838 ); // Where would you like to place this decoration?
|
||||
from.BeginTarget( -1, true, TargetFlags.None, Placement_OnTarget, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 502092 ); // You must be in your house to do this.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
if (house != null && house.IsCoOwner(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1062838); // Where would you like to place this decoration?
|
||||
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(502092); // You must be in your house to do this.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
}
|
||||
}
|
||||
|
||||
public void Placement_OnTarget( Mobile from, object targeted, object state )
|
||||
{
|
||||
if ( !(targeted is IPoint3D p) )
|
||||
return;
|
||||
public void Placement_OnTarget(Mobile from, object targeted, object state)
|
||||
{
|
||||
if (!(targeted is IPoint3D p))
|
||||
return;
|
||||
|
||||
Point3D loc = new Point3D( p );
|
||||
Point3D loc = new Point3D(p);
|
||||
|
||||
BaseHouse house = BaseHouse.FindHouseAt( loc, from.Map, 16 );
|
||||
BaseHouse house = BaseHouse.FindHouseAt(loc, from.Map, 16);
|
||||
|
||||
if ( house != null && house.IsCoOwner( from ) )
|
||||
{
|
||||
bool northWall = BaseAddon.IsWall( loc.X, loc.Y - 1, loc.Z, from.Map );
|
||||
bool westWall = BaseAddon.IsWall( loc.X - 1, loc.Y, loc.Z, from.Map );
|
||||
if (house != null && house.IsCoOwner(from))
|
||||
{
|
||||
bool northWall = BaseAddon.IsWall(loc.X, loc.Y - 1, loc.Z, from.Map);
|
||||
bool westWall = BaseAddon.IsWall(loc.X - 1, loc.Y, loc.Z, from.Map);
|
||||
|
||||
if ( northWall && westWall )
|
||||
from.SendGump( new MistletoeDeedGump( from, loc, this ) );
|
||||
else
|
||||
PlaceAddon( from, loc, northWall, westWall );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1042036 ); // That location is not in your house.
|
||||
}
|
||||
}
|
||||
if (northWall && westWall)
|
||||
from.SendGump(new MistletoeDeedGump(from, loc, this));
|
||||
else
|
||||
PlaceAddon(from, loc, northWall, westWall);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042036); // That location is not in your house.
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaceAddon( Mobile from, Point3D loc, bool northWall, bool westWall )
|
||||
{
|
||||
if ( Deleted )
|
||||
return;
|
||||
private void PlaceAddon(Mobile from, Point3D loc, bool northWall, bool westWall)
|
||||
{
|
||||
if (Deleted)
|
||||
return;
|
||||
|
||||
BaseHouse house = BaseHouse.FindHouseAt( loc, from.Map, 16 );
|
||||
BaseHouse house = BaseHouse.FindHouseAt(loc, from.Map, 16);
|
||||
|
||||
if ( house == null || !house.IsCoOwner( from ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1042036 ); // That location is not in your house.
|
||||
return;
|
||||
}
|
||||
if (house == null || !house.IsCoOwner(from))
|
||||
{
|
||||
from.SendLocalizedMessage(1042036); // That location is not in your house.
|
||||
return;
|
||||
}
|
||||
|
||||
int itemID = 0;
|
||||
int itemID = 0;
|
||||
|
||||
if ( northWall )
|
||||
itemID = 0x2374;
|
||||
else if ( westWall )
|
||||
itemID = 0x2375;
|
||||
else
|
||||
from.SendLocalizedMessage( 1070883 ); // The mistletoe must be placed next to a wall.
|
||||
if (northWall)
|
||||
itemID = 0x2374;
|
||||
else if (westWall)
|
||||
itemID = 0x2375;
|
||||
else
|
||||
from.SendLocalizedMessage(1070883); // The mistletoe must be placed next to a wall.
|
||||
|
||||
if ( itemID > 0 )
|
||||
{
|
||||
Item addon = new MistletoeAddon( Hue );
|
||||
if (itemID > 0)
|
||||
{
|
||||
Item addon = new MistletoeAddon(Hue);
|
||||
|
||||
addon.ItemID = itemID;
|
||||
addon.MoveToWorld( loc, from.Map );
|
||||
addon.ItemID = itemID;
|
||||
addon.MoveToWorld(loc, from.Map);
|
||||
|
||||
house.Addons.Add( addon );
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
house.Addons.Add(addon);
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
private class MistletoeDeedGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private Point3D m_Loc;
|
||||
private MistletoeDeed m_Deed;
|
||||
private class MistletoeDeedGump : Gump
|
||||
{
|
||||
private MistletoeDeed m_Deed;
|
||||
private Mobile m_From;
|
||||
private Point3D m_Loc;
|
||||
|
||||
public MistletoeDeedGump( Mobile from, Point3D loc, MistletoeDeed deed ) : base( 150, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Loc = loc;
|
||||
m_Deed = deed;
|
||||
public MistletoeDeedGump(Mobile from, Point3D loc, MistletoeDeed deed) : base(150, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Loc = loc;
|
||||
m_Deed = deed;
|
||||
|
||||
AddBackground( 0, 0, 300, 150, 0xA28 );
|
||||
AddBackground(0, 0, 300, 150, 0xA28);
|
||||
|
||||
AddPage( 0 );
|
||||
AddPage(0);
|
||||
|
||||
AddItem( 90, 30, 0x2375 );
|
||||
AddItem( 180, 30, 0x2374 );
|
||||
AddButton( 50, 35, 0x868, 0x869, 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 145, 35, 0x868, 0x869, 2, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
AddItem(90, 30, 0x2375);
|
||||
AddItem(180, 30, 0x2374);
|
||||
AddButton(50, 35, 0x868, 0x869, 1, GumpButtonType.Reply, 0);
|
||||
AddButton(145, 35, 0x868, 0x869, 2, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( m_Deed.Deleted )
|
||||
return;
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (m_Deed.Deleted)
|
||||
return;
|
||||
|
||||
switch( info.ButtonID )
|
||||
{
|
||||
case 1:
|
||||
m_Deed.PlaceAddon( m_From, m_Loc, false, true );
|
||||
break;
|
||||
case 2:
|
||||
m_Deed.PlaceAddon( m_From, m_Loc, true, false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1:
|
||||
m_Deed.PlaceAddon(m_From, m_Loc, false, true);
|
||||
break;
|
||||
case 2:
|
||||
m_Deed.PlaceAddon(m_From, m_Loc, true, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,148 +1,153 @@
|
|||
using System;
|
||||
using Server.Engines.ConPVP;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class PileOfGlacialSnow : Item
|
||||
{
|
||||
[Constructible]
|
||||
public PileOfGlacialSnow() : base( 0x913 )
|
||||
{
|
||||
Hue = 0x480;
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
public class PileOfGlacialSnow : Item
|
||||
{
|
||||
[Constructible]
|
||||
public PileOfGlacialSnow() : base(0x913)
|
||||
{
|
||||
Hue = 0x480;
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1070874; // a Pile of Glacial Snow
|
||||
public PileOfGlacialSnow(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public PileOfGlacialSnow( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override int LabelNumber => 1070874; // a Pile of Glacial Snow
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
}
|
||||
writer.Write(1); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if ( version == 0 )
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
}
|
||||
if (version == 0)
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
base.OnSingleClick( from );
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
LabelTo( from, 1070880 ); // Winter 2004
|
||||
}
|
||||
LabelTo(from, 1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add( 1070880 ); // Winter 2004
|
||||
}
|
||||
list.Add(1070880); // Winter 2004
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( !IsChildOf( from.Backpack ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1042010 ); // You must have the object in your backpack to use it.
|
||||
}
|
||||
else if ( from.Mounted )
|
||||
from.SendLocalizedMessage ( 1010097 ); // You cannot use this while mounted.
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042010); // You must have the object in your backpack to use it.
|
||||
}
|
||||
else if (from.Mounted)
|
||||
{
|
||||
from.SendLocalizedMessage(1010097); // You cannot use this while mounted.
|
||||
}
|
||||
|
||||
else if ( from.CanBeginAction( typeof( SnowPile ) ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1005575 ); // You carefully pack the snow into a ball...
|
||||
from.Target = new SnowTarget( from, this );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1005574 ); // The snow is not ready to be packed yet. Keep trying.
|
||||
}
|
||||
}
|
||||
else if (from.CanBeginAction(typeof(SnowPile)))
|
||||
{
|
||||
from.SendLocalizedMessage(1005575); // You carefully pack the snow into a ball...
|
||||
from.Target = new SnowTarget(from, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1005574); // The snow is not ready to be packed yet. Keep trying.
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private Mobile m_From;
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private Mobile m_From;
|
||||
|
||||
public InternalTimer( Mobile from ) : base( TimeSpan.FromSeconds( 5.0 ) )
|
||||
{
|
||||
m_From = from;
|
||||
}
|
||||
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(5.0))
|
||||
{
|
||||
m_From = from;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_From.EndAction( typeof( SnowPile ) );
|
||||
}
|
||||
}
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_From.EndAction(typeof(SnowPile));
|
||||
}
|
||||
}
|
||||
|
||||
private class SnowTarget : Target
|
||||
{
|
||||
private Mobile m_Thrower;
|
||||
private Item m_Snow;
|
||||
private class SnowTarget : Target
|
||||
{
|
||||
private Item m_Snow;
|
||||
private Mobile m_Thrower;
|
||||
|
||||
public SnowTarget( Mobile thrower, Item snow ) : base ( 10, false, TargetFlags.None )
|
||||
{
|
||||
m_Thrower = thrower;
|
||||
m_Snow = snow;
|
||||
}
|
||||
public SnowTarget(Mobile thrower, Item snow) : base(10, false, TargetFlags.None)
|
||||
{
|
||||
m_Thrower = thrower;
|
||||
m_Snow = snow;
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object target )
|
||||
{
|
||||
if ( target == from )
|
||||
{
|
||||
from.SendLocalizedMessage( 1005576 ); // You can't throw this at yourself.
|
||||
}
|
||||
else if ( target is Mobile targ )
|
||||
{
|
||||
Container pack = targ.Backpack;
|
||||
protected override void OnTarget(Mobile from, object target)
|
||||
{
|
||||
if (target == from)
|
||||
{
|
||||
from.SendLocalizedMessage(1005576); // You can't throw this at yourself.
|
||||
}
|
||||
else if (target is Mobile targ)
|
||||
{
|
||||
Container pack = targ.Backpack;
|
||||
|
||||
if ( from.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) || targ.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) )
|
||||
{
|
||||
from.SendMessage( "You may not throw snow here." );
|
||||
}
|
||||
else if ( pack?.FindItemByType( new[]{ typeof( SnowPile ), typeof( PileOfGlacialSnow ) } ) != null )
|
||||
{
|
||||
if ( from.BeginAction( typeof( SnowPile ) ) )
|
||||
{
|
||||
new InternalTimer( from ).Start();
|
||||
if (from.Region.IsPartOf(typeof(SafeZone)) || targ.Region.IsPartOf(typeof(SafeZone)))
|
||||
{
|
||||
from.SendMessage("You may not throw snow here.");
|
||||
}
|
||||
else if (pack?.FindItemByType(new[] { typeof(SnowPile), typeof(PileOfGlacialSnow) }) != null)
|
||||
{
|
||||
if (from.BeginAction(typeof(SnowPile)))
|
||||
{
|
||||
new InternalTimer(from).Start();
|
||||
|
||||
from.PlaySound( 0x145 );
|
||||
from.PlaySound(0x145);
|
||||
|
||||
from.Animate( 9, 1, 1, true, false, 0 );
|
||||
from.Animate(9, 1, 1, true, false, 0);
|
||||
|
||||
targ.SendLocalizedMessage( 1010572 ); // You have just been hit by a snowball!
|
||||
from.SendLocalizedMessage( 1010573 ); // You throw the snowball and hit the target!
|
||||
targ.SendLocalizedMessage(1010572); // You have just been hit by a snowball!
|
||||
from.SendLocalizedMessage(1010573); // You throw the snowball and hit the target!
|
||||
|
||||
Effects.SendMovingEffect( from, targ, 0x36E4, 7, 0, false, true, 0x47F, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1005574 ); // The snow is not ready to be packed yet. Keep trying.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1005577 ); // You can only throw a snowball at something that can throw one back.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1005577 ); // You can only throw a snowball at something that can throw one back.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Effects.SendMovingEffect(from, targ, 0x36E4, 7, 0, false, true, 0x47F, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1005574); // The snow is not ready to be packed yet. Keep trying.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1005577); // You can only throw a snowball at something that can throw one back.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1005577); // You can only throw a snowball at something that can throw one back.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,134 +1,139 @@
|
|||
using System;
|
||||
using Server.Engines.ConPVP;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class SnowPile : Item
|
||||
{
|
||||
[Constructible]
|
||||
public SnowPile() : base( 0x913 )
|
||||
{
|
||||
Hue = 0x481;
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
public class SnowPile : Item
|
||||
{
|
||||
[Constructible]
|
||||
public SnowPile() : base(0x913)
|
||||
{
|
||||
Hue = 0x481;
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public override int LabelNumber => 1005578; // a pile of snow
|
||||
public SnowPile(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public SnowPile( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override int LabelNumber => 1005578; // a pile of snow
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 1 ); // version
|
||||
}
|
||||
writer.Write(1); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if ( version == 0 )
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
}
|
||||
if (version == 0)
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( !IsChildOf( from.Backpack ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1042010 ); // You must have the object in your backpack to use it.
|
||||
}
|
||||
else if ( from.Mounted )
|
||||
from.SendLocalizedMessage ( 1010097 ); // You cannot use this while mounted.
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042010); // You must have the object in your backpack to use it.
|
||||
}
|
||||
else if (from.Mounted)
|
||||
{
|
||||
from.SendLocalizedMessage(1010097); // You cannot use this while mounted.
|
||||
}
|
||||
|
||||
else if ( from.CanBeginAction( typeof( SnowPile ) ) )
|
||||
{
|
||||
from.SendLocalizedMessage( 1005575 ); // You carefully pack the snow into a ball...
|
||||
from.Target = new SnowTarget( from, this );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1005574 ); // The snow is not ready to be packed yet. Keep trying.
|
||||
}
|
||||
}
|
||||
else if (from.CanBeginAction(typeof(SnowPile)))
|
||||
{
|
||||
from.SendLocalizedMessage(1005575); // You carefully pack the snow into a ball...
|
||||
from.Target = new SnowTarget(from, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1005574); // The snow is not ready to be packed yet. Keep trying.
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private Mobile m_From;
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private Mobile m_From;
|
||||
|
||||
public InternalTimer( Mobile from ) : base( TimeSpan.FromSeconds( 5.0 ) )
|
||||
{
|
||||
m_From = from;
|
||||
}
|
||||
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(5.0))
|
||||
{
|
||||
m_From = from;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_From.EndAction( typeof( SnowPile ) );
|
||||
}
|
||||
}
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_From.EndAction(typeof(SnowPile));
|
||||
}
|
||||
}
|
||||
|
||||
private class SnowTarget : Target
|
||||
{
|
||||
private Mobile m_Thrower;
|
||||
private Item m_Snow;
|
||||
private class SnowTarget : Target
|
||||
{
|
||||
private Item m_Snow;
|
||||
private Mobile m_Thrower;
|
||||
|
||||
public SnowTarget( Mobile thrower, Item snow ) : base ( 10, false, TargetFlags.None )
|
||||
{
|
||||
m_Thrower = thrower;
|
||||
m_Snow = snow;
|
||||
}
|
||||
public SnowTarget(Mobile thrower, Item snow) : base(10, false, TargetFlags.None)
|
||||
{
|
||||
m_Thrower = thrower;
|
||||
m_Snow = snow;
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object target )
|
||||
{
|
||||
if ( target == from )
|
||||
{
|
||||
from.SendLocalizedMessage( 1005576 ); // You can't throw this at yourself.
|
||||
}
|
||||
else if ( target is Mobile targ )
|
||||
{
|
||||
Container pack = targ.Backpack;
|
||||
protected override void OnTarget(Mobile from, object target)
|
||||
{
|
||||
if (target == from)
|
||||
{
|
||||
from.SendLocalizedMessage(1005576); // You can't throw this at yourself.
|
||||
}
|
||||
else if (target is Mobile targ)
|
||||
{
|
||||
Container pack = targ.Backpack;
|
||||
|
||||
if ( from.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) || targ.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) )
|
||||
{
|
||||
from.SendMessage( "You may not throw snow here." );
|
||||
}
|
||||
else if ( pack?.FindItemByType( new[]{ typeof( SnowPile ), typeof( PileOfGlacialSnow ) } ) != null )
|
||||
{
|
||||
if ( from.BeginAction( typeof( SnowPile ) ) )
|
||||
{
|
||||
new InternalTimer( from ).Start();
|
||||
if (from.Region.IsPartOf(typeof(SafeZone)) || targ.Region.IsPartOf(typeof(SafeZone)))
|
||||
{
|
||||
from.SendMessage("You may not throw snow here.");
|
||||
}
|
||||
else if (pack?.FindItemByType(new[] { typeof(SnowPile), typeof(PileOfGlacialSnow) }) != null)
|
||||
{
|
||||
if (from.BeginAction(typeof(SnowPile)))
|
||||
{
|
||||
new InternalTimer(from).Start();
|
||||
|
||||
from.PlaySound( 0x145 );
|
||||
from.PlaySound(0x145);
|
||||
|
||||
from.Animate( 9, 1, 1, true, false, 0 );
|
||||
from.Animate(9, 1, 1, true, false, 0);
|
||||
|
||||
targ.SendLocalizedMessage( 1010572 ); // You have just been hit by a snowball!
|
||||
from.SendLocalizedMessage( 1010573 ); // You throw the snowball and hit the target!
|
||||
targ.SendLocalizedMessage(1010572); // You have just been hit by a snowball!
|
||||
from.SendLocalizedMessage(1010573); // You throw the snowball and hit the target!
|
||||
|
||||
Effects.SendMovingEffect( from, targ, 0x36E4, 7, 0, false, true, 0x480, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1005574 ); // The snow is not ready to be packed yet. Keep trying.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1005577 ); // You can only throw a snowball at something that can throw one back.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 1005577 ); // You can only throw a snowball at something that can throw one back.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Effects.SendMovingEffect(from, targ, 0x36E4, 7, 0, false, true, 0x480, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1005574); // The snow is not ready to be packed yet. Keep trying.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1005577); // You can only throw a snowball at something that can throw one back.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1005577); // You can only throw a snowball at something that can throw one back.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +1,44 @@
|
|||
namespace Server.Items
|
||||
{
|
||||
public class SnowyTree : Item
|
||||
{
|
||||
[Constructible]
|
||||
public SnowyTree() : base( 0x2377 )
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
public class SnowyTree : Item
|
||||
{
|
||||
[Constructible]
|
||||
public SnowyTree() : base(0x2377)
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
}
|
||||
|
||||
public SnowyTree( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public SnowyTree(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnSingleClick( Mobile from )
|
||||
{
|
||||
base.OnSingleClick( from );
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
|
||||
LabelTo( from, 1070880 ); // Winter 2004
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
LabelTo(from, 1070880); // Winter 2004
|
||||
}
|
||||
|
||||
list.Add( 1070880 ); // Winter 2004
|
||||
}
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
list.Add(1070880); // Winter 2004
|
||||
}
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,42 +3,42 @@ using Server.Items;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class WinterGiftGiver2004 : GiftGiver
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
GiftGiving.Register( new WinterGiftGiver2004() );
|
||||
}
|
||||
public class WinterGiftGiver2004 : GiftGiver
|
||||
{
|
||||
public override DateTime Start => new DateTime(2004, 12, 24);
|
||||
public override DateTime Finish => new DateTime(2005, 1, 1);
|
||||
|
||||
public override DateTime Start => new DateTime( 2004, 12, 24 );
|
||||
public override DateTime Finish => new DateTime( 2005, 1, 1 );
|
||||
public static void Initialize()
|
||||
{
|
||||
GiftGiving.Register(new WinterGiftGiver2004());
|
||||
}
|
||||
|
||||
public override void GiveGift( Mobile mob )
|
||||
{
|
||||
GiftBox box = new GiftBox();
|
||||
public override void GiveGift(Mobile mob)
|
||||
{
|
||||
GiftBox box = new GiftBox();
|
||||
|
||||
box.DropItem( new MistletoeDeed() );
|
||||
box.DropItem( new PileOfGlacialSnow() );
|
||||
box.DropItem( new LightOfTheWinterSolstice() );
|
||||
box.DropItem(new MistletoeDeed());
|
||||
box.DropItem(new PileOfGlacialSnow());
|
||||
box.DropItem(new LightOfTheWinterSolstice());
|
||||
|
||||
int random = Utility.Random( 100 );
|
||||
int random = Utility.Random(100);
|
||||
|
||||
if ( random < 60 )
|
||||
box.DropItem( new DecorativeTopiary() );
|
||||
else if ( random < 84 )
|
||||
box.DropItem( new FestiveCactus() );
|
||||
else
|
||||
box.DropItem( new SnowyTree() );
|
||||
if (random < 60)
|
||||
box.DropItem(new DecorativeTopiary());
|
||||
else if (random < 84)
|
||||
box.DropItem(new FestiveCactus());
|
||||
else
|
||||
box.DropItem(new SnowyTree());
|
||||
|
||||
switch ( GiveGift( mob, box ) )
|
||||
{
|
||||
case GiftResult.Backpack:
|
||||
mob.SendMessage( 0x482, "Happy Holidays from the team! Gift items have been placed in your backpack." );
|
||||
break;
|
||||
case GiftResult.BankBox:
|
||||
mob.SendMessage( 0x482, "Happy Holidays from the team! Gift items have been placed in your bank box." );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (GiveGift(mob, box))
|
||||
{
|
||||
case GiftResult.Backpack:
|
||||
mob.SendMessage(0x482, "Happy Holidays from the team! Gift items have been placed in your backpack.");
|
||||
break;
|
||||
case GiftResult.BankBox:
|
||||
mob.SendMessage(0x482, "Happy Holidays from the team! Gift items have been placed in your bank box.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,170 +1,172 @@
|
|||
using System;
|
||||
using Server.Commands;
|
||||
using Server.Accounting;
|
||||
using Server.Commands;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public class HardwareInfo
|
||||
{
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int CpuModel { get; private set; }
|
||||
public class HardwareInfo
|
||||
{
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int CpuModel{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int CpuClockSpeed { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int CpuClockSpeed{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int CpuQuantity { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int CpuQuantity{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int OSMajor { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int OSMajor{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int OSMinor { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int OSMinor{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int OSRevision { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int OSRevision{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int InstanceID { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int InstanceID{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int ScreenWidth { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ScreenWidth{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int ScreenHeight { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ScreenHeight{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int ScreenDepth { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ScreenDepth{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int PhysicalMemory { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int PhysicalMemory{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int CpuManufacturer { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int CpuManufacturer{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int CpuFamily { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int CpuFamily{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int VCVendorID { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int VCVendorID{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int VCDeviceID { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int VCDeviceID{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int VCMemory { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int VCMemory{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int DXMajor { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int DXMajor{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int DXMinor { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int DXMinor{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public string VCDescription { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string VCDescription{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public string Language { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string Language{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int Distribution { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Distribution{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int ClientsRunning { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ClientsRunning{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int ClientsInstalled { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ClientsInstalled{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int PartialInstalled { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int PartialInstalled{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public string Unknown { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string Unknown{ get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DateTime TimeReceived { get; private set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime TimeReceived{ get; private set; }
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register( 0xD9, 0x10C, false, OnReceive );
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register(0xD9, 0x10C, false, OnReceive);
|
||||
|
||||
CommandSystem.Register( "HWInfo", AccessLevel.GameMaster, HWInfo_OnCommand );
|
||||
}
|
||||
CommandSystem.Register("HWInfo", AccessLevel.GameMaster, HWInfo_OnCommand);
|
||||
}
|
||||
|
||||
[Usage( "HWInfo" )]
|
||||
[Description( "Displays information about a targeted player's hardware." )]
|
||||
public static void HWInfo_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
e.Mobile.BeginTarget( -1, false, TargetFlags.None, HWInfo_OnTarget );
|
||||
e.Mobile.SendMessage( "Target a player to view their hardware information." );
|
||||
}
|
||||
[Usage("HWInfo")]
|
||||
[Description("Displays information about a targeted player's hardware.")]
|
||||
public static void HWInfo_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
e.Mobile.BeginTarget(-1, false, TargetFlags.None, HWInfo_OnTarget);
|
||||
e.Mobile.SendMessage("Target a player to view their hardware information.");
|
||||
}
|
||||
|
||||
public static void HWInfo_OnTarget( Mobile from, object obj )
|
||||
{
|
||||
if ( obj is Mobile m && m.Player )
|
||||
{
|
||||
if ( m.Account is Account acct )
|
||||
{
|
||||
HardwareInfo hwInfo = acct.HardwareInfo;
|
||||
public static void HWInfo_OnTarget(Mobile from, object obj)
|
||||
{
|
||||
if (obj is Mobile m && m.Player)
|
||||
{
|
||||
if (m.Account is Account acct)
|
||||
{
|
||||
HardwareInfo hwInfo = acct.HardwareInfo;
|
||||
|
||||
if ( hwInfo != null )
|
||||
CommandLogging.WriteLine( from, "{0} {1} viewing hardware info of {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( m ) );
|
||||
if (hwInfo != null)
|
||||
CommandLogging.WriteLine(from, "{0} {1} viewing hardware info of {2}", from.AccessLevel,
|
||||
CommandLogging.Format(from), CommandLogging.Format(m));
|
||||
|
||||
if ( hwInfo != null )
|
||||
from.SendGump( new Gumps.PropertiesGump( from, hwInfo ) );
|
||||
else
|
||||
from.SendMessage( "No hardware information for that account was found." );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( "No account has been attached to that player." );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.BeginTarget( -1, false, TargetFlags.None, HWInfo_OnTarget );
|
||||
from.SendMessage( "That is not a player. Try again." );
|
||||
}
|
||||
}
|
||||
if (hwInfo != null)
|
||||
from.SendGump(new PropertiesGump(from, hwInfo));
|
||||
else
|
||||
from.SendMessage("No hardware information for that account was found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("No account has been attached to that player.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.BeginTarget(-1, false, TargetFlags.None, HWInfo_OnTarget);
|
||||
from.SendMessage("That is not a player. Try again.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnReceive( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
pvSrc.ReadByte(); // 1: <4.0.1a, 2>=4.0.1a
|
||||
public static void OnReceive(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
pvSrc.ReadByte(); // 1: <4.0.1a, 2>=4.0.1a
|
||||
|
||||
HardwareInfo info = new HardwareInfo();
|
||||
HardwareInfo info = new HardwareInfo();
|
||||
|
||||
info.InstanceID = pvSrc.ReadInt32();
|
||||
info.OSMajor = pvSrc.ReadInt32();
|
||||
info.OSMinor = pvSrc.ReadInt32();
|
||||
info.OSRevision = pvSrc.ReadInt32();
|
||||
info.CpuManufacturer = pvSrc.ReadByte();
|
||||
info.CpuFamily = pvSrc.ReadInt32();
|
||||
info.CpuModel = pvSrc.ReadInt32();
|
||||
info.CpuClockSpeed = pvSrc.ReadInt32();
|
||||
info.CpuQuantity = pvSrc.ReadByte();
|
||||
info.PhysicalMemory = pvSrc.ReadInt32();
|
||||
info.ScreenWidth = pvSrc.ReadInt32();
|
||||
info.ScreenHeight = pvSrc.ReadInt32();
|
||||
info.ScreenDepth = pvSrc.ReadInt32();
|
||||
info.DXMajor = pvSrc.ReadInt16();
|
||||
info.DXMinor = pvSrc.ReadInt16();
|
||||
info.VCDescription = pvSrc.ReadUnicodeStringLESafe( 64 );
|
||||
info.VCVendorID = pvSrc.ReadInt32();
|
||||
info.VCDeviceID = pvSrc.ReadInt32();
|
||||
info.VCMemory = pvSrc.ReadInt32();
|
||||
info.Distribution = pvSrc.ReadByte();
|
||||
info.ClientsRunning = pvSrc.ReadByte();
|
||||
info.ClientsInstalled = pvSrc.ReadByte();
|
||||
info.PartialInstalled = pvSrc.ReadByte();
|
||||
info.Language = pvSrc.ReadUnicodeStringLESafe( 4 );
|
||||
info.Unknown = pvSrc.ReadStringSafe( 64 );
|
||||
info.InstanceID = pvSrc.ReadInt32();
|
||||
info.OSMajor = pvSrc.ReadInt32();
|
||||
info.OSMinor = pvSrc.ReadInt32();
|
||||
info.OSRevision = pvSrc.ReadInt32();
|
||||
info.CpuManufacturer = pvSrc.ReadByte();
|
||||
info.CpuFamily = pvSrc.ReadInt32();
|
||||
info.CpuModel = pvSrc.ReadInt32();
|
||||
info.CpuClockSpeed = pvSrc.ReadInt32();
|
||||
info.CpuQuantity = pvSrc.ReadByte();
|
||||
info.PhysicalMemory = pvSrc.ReadInt32();
|
||||
info.ScreenWidth = pvSrc.ReadInt32();
|
||||
info.ScreenHeight = pvSrc.ReadInt32();
|
||||
info.ScreenDepth = pvSrc.ReadInt32();
|
||||
info.DXMajor = pvSrc.ReadInt16();
|
||||
info.DXMinor = pvSrc.ReadInt16();
|
||||
info.VCDescription = pvSrc.ReadUnicodeStringLESafe(64);
|
||||
info.VCVendorID = pvSrc.ReadInt32();
|
||||
info.VCDeviceID = pvSrc.ReadInt32();
|
||||
info.VCMemory = pvSrc.ReadInt32();
|
||||
info.Distribution = pvSrc.ReadByte();
|
||||
info.ClientsRunning = pvSrc.ReadByte();
|
||||
info.ClientsInstalled = pvSrc.ReadByte();
|
||||
info.PartialInstalled = pvSrc.ReadByte();
|
||||
info.Language = pvSrc.ReadUnicodeStringLESafe(4);
|
||||
info.Unknown = pvSrc.ReadStringSafe(64);
|
||||
|
||||
info.TimeReceived = DateTime.UtcNow;
|
||||
info.TimeReceived = DateTime.UtcNow;
|
||||
|
||||
if ( state.Account is Account acct )
|
||||
acct.HardwareInfo = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state.Account is Account acct)
|
||||
acct.HardwareInfo = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +1,54 @@
|
|||
using Server.Guilds;
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class Keywords
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
// Register our speech handler
|
||||
EventSink.Speech += EventSink_Speech;
|
||||
}
|
||||
public class Keywords
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
// Register our speech handler
|
||||
EventSink.Speech += EventSink_Speech;
|
||||
}
|
||||
|
||||
public static void EventSink_Speech( SpeechEventArgs args )
|
||||
{
|
||||
Mobile from = args.Mobile;
|
||||
int[] keywords = args.Keywords;
|
||||
public static void EventSink_Speech(SpeechEventArgs args)
|
||||
{
|
||||
Mobile from = args.Mobile;
|
||||
int[] keywords = args.Keywords;
|
||||
|
||||
for ( int i = 0; i < keywords.Length; ++i )
|
||||
{
|
||||
switch ( keywords[i] )
|
||||
{
|
||||
case 0x002A: // *i resign from my guild*
|
||||
{
|
||||
((Guild)from.Guild)?.RemoveMember( from );
|
||||
for (int i = 0; i < keywords.Length; ++i)
|
||||
switch (keywords[i])
|
||||
{
|
||||
case 0x002A: // *i resign from my guild*
|
||||
{
|
||||
((Guild)from.Guild)?.RemoveMember(from);
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x0032: // *i must consider my sins*
|
||||
{
|
||||
if ( !Core.SE )
|
||||
{
|
||||
from.SendMessage( "Short Term Murders : {0}", from.ShortTermMurders );
|
||||
from.SendMessage( "Long Term Murders : {0}", from.Kills );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( 0x3B2, "Short Term Murders: {0} Long Term Murders: {1}", from.ShortTermMurders, from.Kills );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x0035: // i renounce my young player status*
|
||||
{
|
||||
if ( from is PlayerMobile mobile && mobile.Young && !mobile.HasGump( typeof( RenounceYoungGump ) ) )
|
||||
{
|
||||
mobile.SendGump( new RenounceYoungGump() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x0032: // *i must consider my sins*
|
||||
{
|
||||
if (!Core.SE)
|
||||
{
|
||||
from.SendMessage("Short Term Murders : {0}", from.ShortTermMurders);
|
||||
from.SendMessage("Long Term Murders : {0}", from.Kills);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage(0x3B2, "Short Term Murders: {0} Long Term Murders: {1}", from.ShortTermMurders,
|
||||
from.Kills);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x0035: // i renounce my young player status*
|
||||
{
|
||||
if (from is PlayerMobile mobile && mobile.Young && !mobile.HasGump(typeof(RenounceYoungGump)))
|
||||
mobile.SendGump(new RenounceYoungGump());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Accounting;
|
||||
|
|
@ -6,364 +5,349 @@ using Server.Commands;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
/**
|
||||
* This file requires to be saved in a Unicode
|
||||
* compatible format.
|
||||
*
|
||||
* Warning: if you change String.Format methods,
|
||||
* please note that the following character
|
||||
* is suggested before any left-to-right text
|
||||
* in order to prevent undesired formatting
|
||||
* resulting from mixing LR and RL text:
|
||||
*
|
||||
* Use this one if you need to force RL:
|
||||
*
|
||||
* If you do not see the above chars, please
|
||||
* enable showing of unicode control chars
|
||||
**/
|
||||
/**
|
||||
* This file requires to be saved in a Unicode
|
||||
* compatible format.
|
||||
*
|
||||
* Warning: if you change String.Format methods,
|
||||
* please note that the following character
|
||||
* is suggested before any left-to-right text
|
||||
* in order to prevent undesired formatting
|
||||
* resulting from mixing LR and RL text:
|
||||
*
|
||||
* Use this one if you need to force RL:
|
||||
*
|
||||
* If you do not see the above chars, please
|
||||
* enable showing of unicode control chars
|
||||
**/
|
||||
|
||||
public class LanguageStatistics
|
||||
{
|
||||
struct InternationalCode
|
||||
{
|
||||
bool m_HasLocalInfo;
|
||||
public class LanguageStatistics
|
||||
{
|
||||
private static InternationalCode[] InternationalCodes =
|
||||
{
|
||||
new InternationalCode("ARA", "Arabic", "Saudi Arabia", "العربية", "السعودية"),
|
||||
new InternationalCode("ARI", "Arabic", "Iraq", "العربية", "العراق"),
|
||||
new InternationalCode("ARE", "Arabic", "Egypt", "العربية", "مصر"),
|
||||
new InternationalCode("ARL", "Arabic", "Libya", "العربية", "ليبيا"),
|
||||
new InternationalCode("ARG", "Arabic", "Algeria", "العربية", "الجزائر"),
|
||||
new InternationalCode("ARM", "Arabic", "Morocco", "العربية", "المغرب"),
|
||||
new InternationalCode("ART", "Arabic", "Tunisia", "العربية", "تونس"),
|
||||
new InternationalCode("ARO", "Arabic", "Oman", "العربية", "عمان"),
|
||||
new InternationalCode("ARY", "Arabic", "Yemen", "العربية", "اليمن"),
|
||||
new InternationalCode("ARS", "Arabic", "Syria", "العربية", "سورية"),
|
||||
new InternationalCode("ARJ", "Arabic", "Jordan", "العربية", "الأردن"),
|
||||
new InternationalCode("ARB", "Arabic", "Lebanon", "العربية", "لبنان"),
|
||||
new InternationalCode("ARK", "Arabic", "Kuwait", "العربية", "الكويت"),
|
||||
new InternationalCode("ARU", "Arabic", "U.A.E.", "العربية", "الامارات"),
|
||||
new InternationalCode("ARH", "Arabic", "Bahrain", "العربية", "البحرين"),
|
||||
new InternationalCode("ARQ", "Arabic", "Qatar", "العربية", "قطر"),
|
||||
new InternationalCode("BGR", "Bulgarian", "Bulgaria", "Български", "България"),
|
||||
new InternationalCode("CAT", "Catalan", "Spain", "Català", "Espanya"),
|
||||
new InternationalCode("CHT", "Chinese", "Taiwan", "台語", "臺灣"),
|
||||
new InternationalCode("CHS", "Chinese", "PRC", "中文", "中国"),
|
||||
new InternationalCode("ZHH", "Chinese", "Hong Kong", "中文", "香港"),
|
||||
new InternationalCode("ZHI", "Chinese", "Singapore", "中文", "新加坡"),
|
||||
new InternationalCode("ZHM", "Chinese", "Macau", "中文", "澳門"),
|
||||
new InternationalCode("CSY", "Czech", "Czech Republic", "Čeština", "Česká republika"),
|
||||
new InternationalCode("DAN", "Danish", "Denmark", "Dansk", "Danmark"),
|
||||
new InternationalCode("DEU", "German", "Germany", "Deutsch", "Deutschland"),
|
||||
new InternationalCode("DES", "German", "Switzerland", "Deutsch", "der Schweiz"),
|
||||
new InternationalCode("DEA", "German", "Austria", "Deutsch", "Österreich"),
|
||||
new InternationalCode("DEL", "German", "Luxembourg", "Deutsch", "Luxembourg"),
|
||||
new InternationalCode("DEC", "German", "Liechtenstein", "Deutsch", "Liechtenstein"),
|
||||
new InternationalCode("ELL", "Greek", "Greece", "Ελληνικά", "Ελλάδα"),
|
||||
new InternationalCode("ENU", "English", "United States"),
|
||||
new InternationalCode("ENG", "English", "United Kingdom"),
|
||||
new InternationalCode("ENA", "English", "Australia"),
|
||||
new InternationalCode("ENC", "English", "Canada"),
|
||||
new InternationalCode("ENZ", "English", "New Zealand"),
|
||||
new InternationalCode("ENI", "English", "Ireland"),
|
||||
new InternationalCode("ENS", "English", "South Africa"),
|
||||
new InternationalCode("ENJ", "English", "Jamaica"),
|
||||
new InternationalCode("ENB", "English", "Caribbean"),
|
||||
new InternationalCode("ENL", "English", "Belize"),
|
||||
new InternationalCode("ENT", "English", "Trinidad"),
|
||||
new InternationalCode("ENW", "English", "Zimbabwe"),
|
||||
new InternationalCode("ENP", "English", "Philippines"),
|
||||
new InternationalCode("ESP", "Spanish", "Spain (Traditional Sort)", "Español", "España (tipo tradicional)"),
|
||||
new InternationalCode("ESM", "Spanish", "Mexico", "Español", "México"),
|
||||
new InternationalCode("ESN", "Spanish", "Spain (International Sort)", "Español", "España (tipo internacional)"),
|
||||
new InternationalCode("ESG", "Spanish", "Guatemala", "Español", "Guatemala"),
|
||||
new InternationalCode("ESC", "Spanish", "Costa Rica", "Español", "Costa Rica"),
|
||||
new InternationalCode("ESA", "Spanish", "Panama", "Español", "Panama"),
|
||||
new InternationalCode("ESD", "Spanish", "Dominican Republic", "Español", "Republica Dominicana"),
|
||||
new InternationalCode("ESV", "Spanish", "Venezuela", "Español", "Venezuela"),
|
||||
new InternationalCode("ESO", "Spanish", "Colombia", "Español", "Colombia"),
|
||||
new InternationalCode("ESR", "Spanish", "Peru", "Español", "Peru"),
|
||||
new InternationalCode("ESS", "Spanish", "Argentina", "Español", "Argentina"),
|
||||
new InternationalCode("ESF", "Spanish", "Ecuador", "Español", "Ecuador"),
|
||||
new InternationalCode("ESL", "Spanish", "Chile", "Español", "Chile"),
|
||||
new InternationalCode("ESY", "Spanish", "Uruguay", "Español", "Uruguay"),
|
||||
new InternationalCode("ESZ", "Spanish", "Paraguay", "Español", "Paraguay"),
|
||||
new InternationalCode("ESB", "Spanish", "Bolivia", "Español", "Bolivia"),
|
||||
new InternationalCode("ESE", "Spanish", "El Salvador", "Español", "El Salvador"),
|
||||
new InternationalCode("ESH", "Spanish", "Honduras", "Español", "Honduras"),
|
||||
new InternationalCode("ESI", "Spanish", "Nicaragua", "Español", "Nicaragua"),
|
||||
new InternationalCode("ESU", "Spanish", "Puerto Rico", "Español", "Puerto Rico"),
|
||||
new InternationalCode("FIN", "Finnish", "Finland", "Suomi", "Suomi"),
|
||||
new InternationalCode("FRA", "French", "France", "Français", "France"),
|
||||
new InternationalCode("FRB", "French", "Belgium", "Français", "Belgique"),
|
||||
new InternationalCode("FRC", "French", "Canada", "Français", "Canada"),
|
||||
new InternationalCode("FRS", "French", "Switzerland", "Français", "Suisse"),
|
||||
new InternationalCode("FRL", "French", "Luxembourg", "Français", "Luxembourg"),
|
||||
new InternationalCode("FRM", "French", "Monaco", "Français", "Monaco"),
|
||||
new InternationalCode("HEB", "Hebrew", "Israel", "עִבְרִית", "ישׂראל"),
|
||||
new InternationalCode("HUN", "Hungarian", "Hungary", "Magyar", "Magyarország"),
|
||||
new InternationalCode("ISL", "Icelandic", "Iceland", "Íslenska", "Ísland"),
|
||||
new InternationalCode("ITA", "Italian", "Italy", "Italiano", "Italia"),
|
||||
new InternationalCode("ITS", "Italian", "Switzerland", "Italiano", "Svizzera"),
|
||||
new InternationalCode("JPN", "Japanese", "Japan", "日本語", "日本"),
|
||||
new InternationalCode("KOR", "Korean (Extended Wansung)", "Korea", "한국어", "한국"),
|
||||
new InternationalCode("NLD", "Dutch", "Netherlands", "Nederlands", "Nederland"),
|
||||
new InternationalCode("NLB", "Dutch", "Belgium", "Nederlands", "België"),
|
||||
new InternationalCode("NOR", "Norwegian", "Norway (Bokmål)", "Norsk", "Norge (Bokmål)"),
|
||||
new InternationalCode("NON", "Norwegian", "Norway (Nynorsk)", "Norsk", "Norge (Nynorsk)"),
|
||||
new InternationalCode("PLK", "Polish", "Poland", "Polski", "Polska"),
|
||||
new InternationalCode("PTB", "Portuguese", "Brazil", "Português", "Brasil"),
|
||||
new InternationalCode("PTG", "Portuguese", "Portugal", "Português", "Brasil"),
|
||||
new InternationalCode("ROM", "Romanian", "Romania", "Limba Română", "România"),
|
||||
new InternationalCode("RUS", "Russian", "Russia", "Русский", "Россия"),
|
||||
new InternationalCode("HRV", "Croatian", "Croatia", "Hrvatski", "Hrvatska"),
|
||||
new InternationalCode("SRL", "Serbian", "Serbia (Latin)", "Srpski", "Srbija i Crna Gora"),
|
||||
new InternationalCode("SRB", "Serbian", "Serbia (Cyrillic)", "Српски", "Србија и Црна Гора"),
|
||||
new InternationalCode("SKY", "Slovak", "Slovakia", "Slovenčina", "Slovensko"),
|
||||
new InternationalCode("SQI", "Albanian", "Albania", "Shqip", "Shqipëria"),
|
||||
new InternationalCode("SVE", "Swedish", "Sweden", "Svenska", "Sverige"),
|
||||
new InternationalCode("SVF", "Swedish", "Finland", "Svenska", "Finland"),
|
||||
new InternationalCode("THA", "Thai", "Thailand", "ภาษาไทย", "ประเทศไทย"),
|
||||
new InternationalCode("TRK", "Turkish", "Turkey", "Türkçe", "Türkiye"),
|
||||
new InternationalCode("URP", "Urdu", "Pakistan", "اردو", "پاکستان"),
|
||||
new InternationalCode("IND", "Indonesian", "Indonesia", "Bahasa Indonesia", "Indonesia"),
|
||||
new InternationalCode("UKR", "Ukrainian", "Ukraine", "Українська", "Украина"),
|
||||
new InternationalCode("BEL", "Belarusian", "Belarus", "Беларускі", "Беларусь"),
|
||||
new InternationalCode("SLV", "Slovene", "Slovenia", "Slovenščina", "Slovenija"),
|
||||
new InternationalCode("ETI", "Estonian", "Estonia", "Eesti", "Eesti"),
|
||||
new InternationalCode("LVI", "Latvian", "Latvia", "Latviešu", "Latvija"),
|
||||
new InternationalCode("LTH", "Lithuanian", "Lithuania", "Lietuvių", "Lietuva"),
|
||||
new InternationalCode("LTC", "Classic Lithuanian", "Lithuania", "Lietuviškai", "Lietuva"),
|
||||
new InternationalCode("FAR", "Farsi", "Iran", "فارسى", "ايران"),
|
||||
new InternationalCode("VIT", "Vietnamese", "Viet Nam", "tiếng Việt", "Việt Nam"),
|
||||
new InternationalCode("HYE", "Armenian", "Armenia", "Հայերէն", "Հայաստան"),
|
||||
new InternationalCode("AZE", "Azeri", "Azerbaijan (Latin)", "Azərbaycanca", "Azərbaycan"),
|
||||
new InternationalCode("AZE", "Azeri", "Azerbaijan (Cyrillic)", "Азәрбајҹанҹа", "Азәрбајҹан"),
|
||||
new InternationalCode("EUQ", "Basque", "Spain", "Euskera", "Espainia"),
|
||||
new InternationalCode("MKI", "Macedonian", "Macedonia", "Македонски", "Македонија"),
|
||||
new InternationalCode("AFK", "Afrikaans", "South Africa", "Afrikaans", "Republiek van Suid-Afrika"),
|
||||
new InternationalCode("KAT", "Georgian", "Georgia", "ქართული", "საკარტველო"),
|
||||
new InternationalCode("FOS", "Faeroese", "Faeroe Islands", "Føroyska", "Føroya"),
|
||||
new InternationalCode("HIN", "Hindi", "India", "हिन्दी", "भारत"),
|
||||
new InternationalCode("MSL", "Malay", "Malaysia", "Bahasa melayu", "Malaysia"),
|
||||
new InternationalCode("MSB", "Malay", "Brunei Darussalam", "Bahasa melayu", "Negara Brunei Darussalam"),
|
||||
new InternationalCode("KAZ", "Kazak", "Kazakstan", "Қазақ", "Қазақстан"),
|
||||
new InternationalCode("SWK", "Swahili", "Kenya", "Kiswahili", "Kenya"),
|
||||
new InternationalCode("UZB", "Uzbek", "Uzbekistan (Latin)", "O'zbek", "O'zbekiston"),
|
||||
new InternationalCode("UZB", "Uzbek", "Uzbekistan (Cyrillic)", "Ўзбек", "Ўзбекистон"),
|
||||
new InternationalCode("TAT", "Tatar", "Tatarstan", "Татарча", "Татарстан"),
|
||||
new InternationalCode("BEN", "Bengali", "India", "বাংলা", "ভারত"),
|
||||
new InternationalCode("PAN", "Punjabi", "India", "ਪੰਜਾਬੀ", "ਭਾਰਤ"),
|
||||
new InternationalCode("GUJ", "Gujarati", "India", "ગુજરાતી", "ભારત"),
|
||||
new InternationalCode("ORI", "Oriya", "India", "ଓଡ଼ିଆ", "ଭାରତ"),
|
||||
new InternationalCode("TAM", "Tamil", "India", "தமிழ்", "இந்தியா"),
|
||||
new InternationalCode("TEL", "Telugu", "India", "తెలుగు", "భారత"),
|
||||
new InternationalCode("KAN", "Kannada", "India", "ಕನ್ನಡ", "ಭಾರತ"),
|
||||
new InternationalCode("MAL", "Malayalam", "India", "മലയാളം", "ഭാരത"),
|
||||
new InternationalCode("ASM", "Assamese", "India", "অসমিয়া", "Bhārat"), // missing correct country name
|
||||
new InternationalCode("MAR", "Marathi", "India", "मराठी", "भारत"),
|
||||
new InternationalCode("SAN", "Sanskrit", "India", "संस्कृत", "भारतम्"),
|
||||
new InternationalCode("KOK", "Konkani", "India", "कोंकणी", "भारत")
|
||||
};
|
||||
|
||||
public string Code { get; }
|
||||
private static bool DefaultLocalNames = false;
|
||||
private static bool ShowAlternatives = true;
|
||||
private static bool CountAccounts = true; // will consider only first character's valid language
|
||||
|
||||
public string Language { get; }
|
||||
private static string GetFormattedInfo(string code)
|
||||
{
|
||||
if (code == null || code.Length != 3)
|
||||
return $"Unknown code {code}";
|
||||
|
||||
public string Country { get; }
|
||||
for (int i = 0; i < InternationalCodes.Length; i++)
|
||||
if (code == InternationalCodes[i].Code)
|
||||
return $"{InternationalCodes[i].GetName()}";
|
||||
|
||||
public string Language_LocalName { get; }
|
||||
return $"Unknown code {code}";
|
||||
}
|
||||
|
||||
public string Country_LocalName { get; }
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("LanguageStatistics", AccessLevel.Administrator, LanguageStatistics_OnCommand);
|
||||
}
|
||||
|
||||
public InternationalCode( string code, string language, string country ) : this( code, language, country, null, null )
|
||||
{
|
||||
m_HasLocalInfo = false;
|
||||
}
|
||||
[Usage("LanguageStatistics")]
|
||||
[Description("Generate a file containing the list of languages for each PlayerMobile.")]
|
||||
public static void LanguageStatistics_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
Dictionary<string, InternationalCodeCounter> ht = new Dictionary<string, InternationalCodeCounter>();
|
||||
|
||||
public InternationalCode( string code, string language, string country, string language_localname, string country_localname )
|
||||
{
|
||||
Code = code;
|
||||
Language = language;
|
||||
Country = country;
|
||||
Language_LocalName = language_localname;
|
||||
Country_LocalName = country_localname;
|
||||
m_HasLocalInfo = true;
|
||||
}
|
||||
using (StreamWriter writer = new StreamWriter("languages.txt"))
|
||||
{
|
||||
if (CountAccounts)
|
||||
foreach (Account acc in Accounts.GetAccounts())
|
||||
for (int i = 0; i < acc.Length; i++)
|
||||
{
|
||||
Mobile mob = acc[i];
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
string s;
|
||||
string lang = mob?.Language;
|
||||
|
||||
if ( m_HasLocalInfo )
|
||||
{
|
||||
s =
|
||||
$"{(DefaultLocalNames ? Language_LocalName : Language)} - {(DefaultLocalNames ? Country_LocalName : Country)}";
|
||||
if (lang != null)
|
||||
{
|
||||
lang = lang.ToUpper();
|
||||
|
||||
if ( ShowAlternatives )
|
||||
s +=
|
||||
$" 【{(DefaultLocalNames ? Language : Language_LocalName)} - {(DefaultLocalNames ? Country : Country_LocalName)}】";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = $"{Language} - {Country}";
|
||||
}
|
||||
if (!ht.ContainsKey(lang))
|
||||
ht[lang] = new InternationalCodeCounter(lang);
|
||||
else
|
||||
ht[lang].Increase();
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
foreach (Mobile mob in World.Mobiles.Values)
|
||||
if (mob.Player)
|
||||
{
|
||||
string lang = mob.Language;
|
||||
|
||||
private static InternationalCode[] InternationalCodes =
|
||||
{
|
||||
new InternationalCode( "ARA", "Arabic", "Saudi Arabia", "العربية", "السعودية" ),
|
||||
new InternationalCode( "ARI", "Arabic", "Iraq", "العربية", "العراق" ),
|
||||
new InternationalCode( "ARE", "Arabic", "Egypt", "العربية", "مصر" ),
|
||||
new InternationalCode( "ARL", "Arabic", "Libya", "العربية", "ليبيا" ),
|
||||
new InternationalCode( "ARG", "Arabic", "Algeria", "العربية", "الجزائر" ),
|
||||
new InternationalCode( "ARM", "Arabic", "Morocco", "العربية", "المغرب" ),
|
||||
new InternationalCode( "ART", "Arabic", "Tunisia", "العربية", "تونس" ),
|
||||
new InternationalCode( "ARO", "Arabic", "Oman", "العربية", "عمان" ),
|
||||
new InternationalCode( "ARY", "Arabic", "Yemen", "العربية", "اليمن" ),
|
||||
new InternationalCode( "ARS", "Arabic", "Syria", "العربية", "سورية" ),
|
||||
new InternationalCode( "ARJ", "Arabic", "Jordan", "العربية", "الأردن" ),
|
||||
new InternationalCode( "ARB", "Arabic", "Lebanon", "العربية", "لبنان" ),
|
||||
new InternationalCode( "ARK", "Arabic", "Kuwait", "العربية", "الكويت" ),
|
||||
new InternationalCode( "ARU", "Arabic", "U.A.E.", "العربية", "الامارات" ),
|
||||
new InternationalCode( "ARH", "Arabic", "Bahrain", "العربية", "البحرين" ),
|
||||
new InternationalCode( "ARQ", "Arabic", "Qatar", "العربية", "قطر" ),
|
||||
new InternationalCode( "BGR", "Bulgarian", "Bulgaria", "Български", "България" ),
|
||||
new InternationalCode( "CAT", "Catalan", "Spain", "Català", "Espanya" ),
|
||||
new InternationalCode( "CHT", "Chinese", "Taiwan", "台語", "臺灣" ),
|
||||
new InternationalCode( "CHS", "Chinese", "PRC", "中文", "中国" ),
|
||||
new InternationalCode( "ZHH", "Chinese", "Hong Kong", "中文", "香港" ),
|
||||
new InternationalCode( "ZHI", "Chinese", "Singapore", "中文", "新加坡" ),
|
||||
new InternationalCode( "ZHM", "Chinese", "Macau", "中文", "澳門" ),
|
||||
new InternationalCode( "CSY", "Czech", "Czech Republic", "Čeština", "Česká republika" ),
|
||||
new InternationalCode( "DAN", "Danish", "Denmark", "Dansk", "Danmark" ),
|
||||
new InternationalCode( "DEU", "German", "Germany", "Deutsch", "Deutschland" ),
|
||||
new InternationalCode( "DES", "German", "Switzerland", "Deutsch", "der Schweiz" ),
|
||||
new InternationalCode( "DEA", "German", "Austria", "Deutsch", "Österreich" ),
|
||||
new InternationalCode( "DEL", "German", "Luxembourg", "Deutsch", "Luxembourg" ),
|
||||
new InternationalCode( "DEC", "German", "Liechtenstein", "Deutsch", "Liechtenstein" ),
|
||||
new InternationalCode( "ELL", "Greek", "Greece", "Ελληνικά", "Ελλάδα" ),
|
||||
new InternationalCode( "ENU", "English", "United States" ),
|
||||
new InternationalCode( "ENG", "English", "United Kingdom" ),
|
||||
new InternationalCode( "ENA", "English", "Australia" ),
|
||||
new InternationalCode( "ENC", "English", "Canada" ),
|
||||
new InternationalCode( "ENZ", "English", "New Zealand" ),
|
||||
new InternationalCode( "ENI", "English", "Ireland" ),
|
||||
new InternationalCode( "ENS", "English", "South Africa" ),
|
||||
new InternationalCode( "ENJ", "English", "Jamaica" ),
|
||||
new InternationalCode( "ENB", "English", "Caribbean" ),
|
||||
new InternationalCode( "ENL", "English", "Belize" ),
|
||||
new InternationalCode( "ENT", "English", "Trinidad" ),
|
||||
new InternationalCode( "ENW", "English", "Zimbabwe" ),
|
||||
new InternationalCode( "ENP", "English", "Philippines" ),
|
||||
new InternationalCode( "ESP", "Spanish", "Spain (Traditional Sort)", "Español", "España (tipo tradicional)" ),
|
||||
new InternationalCode( "ESM", "Spanish", "Mexico", "Español", "México" ),
|
||||
new InternationalCode( "ESN", "Spanish", "Spain (International Sort)", "Español", "España (tipo internacional)" ),
|
||||
new InternationalCode( "ESG", "Spanish", "Guatemala", "Español", "Guatemala" ),
|
||||
new InternationalCode( "ESC", "Spanish", "Costa Rica", "Español", "Costa Rica" ),
|
||||
new InternationalCode( "ESA", "Spanish", "Panama", "Español", "Panama" ),
|
||||
new InternationalCode( "ESD", "Spanish", "Dominican Republic", "Español", "Republica Dominicana" ),
|
||||
new InternationalCode( "ESV", "Spanish", "Venezuela", "Español", "Venezuela" ),
|
||||
new InternationalCode( "ESO", "Spanish", "Colombia", "Español", "Colombia" ),
|
||||
new InternationalCode( "ESR", "Spanish", "Peru", "Español", "Peru" ),
|
||||
new InternationalCode( "ESS", "Spanish", "Argentina", "Español", "Argentina" ),
|
||||
new InternationalCode( "ESF", "Spanish", "Ecuador", "Español", "Ecuador" ),
|
||||
new InternationalCode( "ESL", "Spanish", "Chile", "Español", "Chile" ),
|
||||
new InternationalCode( "ESY", "Spanish", "Uruguay", "Español", "Uruguay" ),
|
||||
new InternationalCode( "ESZ", "Spanish", "Paraguay", "Español", "Paraguay" ),
|
||||
new InternationalCode( "ESB", "Spanish", "Bolivia", "Español", "Bolivia" ),
|
||||
new InternationalCode( "ESE", "Spanish", "El Salvador", "Español", "El Salvador" ),
|
||||
new InternationalCode( "ESH", "Spanish", "Honduras", "Español", "Honduras" ),
|
||||
new InternationalCode( "ESI", "Spanish", "Nicaragua", "Español", "Nicaragua" ),
|
||||
new InternationalCode( "ESU", "Spanish", "Puerto Rico", "Español", "Puerto Rico" ),
|
||||
new InternationalCode( "FIN", "Finnish", "Finland", "Suomi", "Suomi" ),
|
||||
new InternationalCode( "FRA", "French", "France", "Français", "France" ),
|
||||
new InternationalCode( "FRB", "French", "Belgium", "Français", "Belgique" ),
|
||||
new InternationalCode( "FRC", "French", "Canada", "Français", "Canada" ),
|
||||
new InternationalCode( "FRS", "French", "Switzerland", "Français", "Suisse" ),
|
||||
new InternationalCode( "FRL", "French", "Luxembourg", "Français", "Luxembourg" ),
|
||||
new InternationalCode( "FRM", "French", "Monaco", "Français", "Monaco" ),
|
||||
new InternationalCode( "HEB", "Hebrew", "Israel", "עִבְרִית", "ישׂראל" ),
|
||||
new InternationalCode( "HUN", "Hungarian", "Hungary", "Magyar", "Magyarország" ),
|
||||
new InternationalCode( "ISL", "Icelandic", "Iceland", "Íslenska", "Ísland" ),
|
||||
new InternationalCode( "ITA", "Italian", "Italy", "Italiano", "Italia" ),
|
||||
new InternationalCode( "ITS", "Italian", "Switzerland", "Italiano", "Svizzera" ),
|
||||
new InternationalCode( "JPN", "Japanese", "Japan", "日本語", "日本" ),
|
||||
new InternationalCode( "KOR", "Korean (Extended Wansung)", "Korea", "한국어", "한국" ),
|
||||
new InternationalCode( "NLD", "Dutch", "Netherlands", "Nederlands", "Nederland" ),
|
||||
new InternationalCode( "NLB", "Dutch", "Belgium", "Nederlands", "België" ),
|
||||
new InternationalCode( "NOR", "Norwegian", "Norway (Bokmål)", "Norsk", "Norge (Bokmål)" ),
|
||||
new InternationalCode( "NON", "Norwegian", "Norway (Nynorsk)", "Norsk", "Norge (Nynorsk)" ),
|
||||
new InternationalCode( "PLK", "Polish", "Poland", "Polski", "Polska" ),
|
||||
new InternationalCode( "PTB", "Portuguese", "Brazil", "Português", "Brasil" ),
|
||||
new InternationalCode( "PTG", "Portuguese", "Portugal", "Português", "Brasil" ),
|
||||
new InternationalCode( "ROM", "Romanian", "Romania", "Limba Română", "România" ),
|
||||
new InternationalCode( "RUS", "Russian", "Russia", "Русский", "Россия" ),
|
||||
new InternationalCode( "HRV", "Croatian", "Croatia", "Hrvatski", "Hrvatska" ),
|
||||
new InternationalCode( "SRL", "Serbian", "Serbia (Latin)", "Srpski", "Srbija i Crna Gora" ),
|
||||
new InternationalCode( "SRB", "Serbian", "Serbia (Cyrillic)", "Српски", "Србија и Црна Гора" ),
|
||||
new InternationalCode( "SKY", "Slovak", "Slovakia", "Slovenčina", "Slovensko" ),
|
||||
new InternationalCode( "SQI", "Albanian", "Albania", "Shqip", "Shqipëria" ),
|
||||
new InternationalCode( "SVE", "Swedish", "Sweden", "Svenska", "Sverige" ),
|
||||
new InternationalCode( "SVF", "Swedish", "Finland", "Svenska", "Finland" ),
|
||||
new InternationalCode( "THA", "Thai", "Thailand", "ภาษาไทย", "ประเทศไทย" ),
|
||||
new InternationalCode( "TRK", "Turkish", "Turkey", "Türkçe", "Türkiye" ),
|
||||
new InternationalCode( "URP", "Urdu", "Pakistan", "اردو", "پاکستان" ),
|
||||
new InternationalCode( "IND", "Indonesian", "Indonesia", "Bahasa Indonesia", "Indonesia" ),
|
||||
new InternationalCode( "UKR", "Ukrainian", "Ukraine", "Українська", "Украина" ),
|
||||
new InternationalCode( "BEL", "Belarusian", "Belarus", "Беларускі", "Беларусь" ),
|
||||
new InternationalCode( "SLV", "Slovene", "Slovenia", "Slovenščina", "Slovenija" ),
|
||||
new InternationalCode( "ETI", "Estonian", "Estonia", "Eesti", "Eesti" ),
|
||||
new InternationalCode( "LVI", "Latvian", "Latvia", "Latviešu", "Latvija" ),
|
||||
new InternationalCode( "LTH", "Lithuanian", "Lithuania", "Lietuvių", "Lietuva" ),
|
||||
new InternationalCode( "LTC", "Classic Lithuanian", "Lithuania", "Lietuviškai", "Lietuva" ),
|
||||
new InternationalCode( "FAR", "Farsi", "Iran", "فارسى", "ايران" ),
|
||||
new InternationalCode( "VIT", "Vietnamese", "Viet Nam", "tiếng Việt", "Việt Nam" ),
|
||||
new InternationalCode( "HYE", "Armenian", "Armenia", "Հայերէն", "Հայաստան" ),
|
||||
new InternationalCode( "AZE", "Azeri", "Azerbaijan (Latin)", "Azərbaycanca", "Azərbaycan" ),
|
||||
new InternationalCode( "AZE", "Azeri", "Azerbaijan (Cyrillic)", "Азәрбајҹанҹа", "Азәрбајҹан" ),
|
||||
new InternationalCode( "EUQ", "Basque", "Spain", "Euskera", "Espainia" ),
|
||||
new InternationalCode( "MKI", "Macedonian", "Macedonia", "Македонски", "Македонија" ),
|
||||
new InternationalCode( "AFK", "Afrikaans", "South Africa", "Afrikaans", "Republiek van Suid-Afrika" ),
|
||||
new InternationalCode( "KAT", "Georgian", "Georgia", "ქართული", "საკარტველო" ),
|
||||
new InternationalCode( "FOS", "Faeroese", "Faeroe Islands", "Føroyska", "Føroya" ),
|
||||
new InternationalCode( "HIN", "Hindi", "India", "हिन्दी", "भारत" ),
|
||||
new InternationalCode( "MSL", "Malay", "Malaysia", "Bahasa melayu", "Malaysia" ),
|
||||
new InternationalCode( "MSB", "Malay", "Brunei Darussalam", "Bahasa melayu", "Negara Brunei Darussalam" ),
|
||||
new InternationalCode( "KAZ", "Kazak", "Kazakstan", "Қазақ", "Қазақстан" ),
|
||||
new InternationalCode( "SWK", "Swahili", "Kenya", "Kiswahili", "Kenya" ),
|
||||
new InternationalCode( "UZB", "Uzbek", "Uzbekistan (Latin)", "O'zbek", "O'zbekiston" ),
|
||||
new InternationalCode( "UZB", "Uzbek", "Uzbekistan (Cyrillic)", "Ўзбек", "Ўзбекистон" ),
|
||||
new InternationalCode( "TAT", "Tatar", "Tatarstan", "Татарча", "Татарстан" ),
|
||||
new InternationalCode( "BEN", "Bengali", "India", "বাংলা", "ভারত" ),
|
||||
new InternationalCode( "PAN", "Punjabi", "India", "ਪੰਜਾਬੀ", "ਭਾਰਤ" ),
|
||||
new InternationalCode( "GUJ", "Gujarati", "India", "ગુજરાતી", "ભારત" ),
|
||||
new InternationalCode( "ORI", "Oriya", "India", "ଓଡ଼ିଆ", "ଭାରତ" ),
|
||||
new InternationalCode( "TAM", "Tamil", "India", "தமிழ்", "இந்தியா" ),
|
||||
new InternationalCode( "TEL", "Telugu", "India", "తెలుగు", "భారత" ),
|
||||
new InternationalCode( "KAN", "Kannada", "India", "ಕನ್ನಡ", "ಭಾರತ" ),
|
||||
new InternationalCode( "MAL", "Malayalam", "India", "മലയാളം", "ഭാരത" ),
|
||||
new InternationalCode( "ASM", "Assamese", "India", "অসমিয়া", "Bhārat" ), // missing correct country name
|
||||
new InternationalCode( "MAR", "Marathi", "India", "मराठी", "भारत" ),
|
||||
new InternationalCode( "SAN", "Sanskrit", "India", "संस्कृत", "भारतम्" ),
|
||||
new InternationalCode( "KOK", "Konkani", "India", "कोंकणी", "भारत" )
|
||||
};
|
||||
if (lang != null)
|
||||
{
|
||||
lang = lang.ToUpper();
|
||||
|
||||
private static string GetFormattedInfo( string code )
|
||||
{
|
||||
if ( code == null || code.Length != 3 )
|
||||
return $"Unknown code {code}";
|
||||
if (!ht.ContainsKey(lang))
|
||||
ht[lang] = new InternationalCodeCounter(lang);
|
||||
else
|
||||
ht[lang].Increase();
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < InternationalCodes.Length; i++ )
|
||||
{
|
||||
if ( code == InternationalCodes[i].Code )
|
||||
{
|
||||
return $"{InternationalCodes[i].GetName()}";
|
||||
}
|
||||
}
|
||||
writer.WriteLine(
|
||||
$"Language statistics. Numbers show how many {(CountAccounts ? "accounts" : "playermobile")} use the specified language.");
|
||||
writer.WriteLine(
|
||||
"====================================================================================================");
|
||||
writer.WriteLine();
|
||||
|
||||
return $"Unknown code {code}";
|
||||
}
|
||||
// sort the list
|
||||
List<InternationalCodeCounter> list = new List<InternationalCodeCounter>(ht.Values);
|
||||
list.Sort(InternationalCodeComparer.Instance);
|
||||
|
||||
private static bool DefaultLocalNames = false;
|
||||
private static bool ShowAlternatives = true;
|
||||
private static bool CountAccounts = true; // will consider only first character's valid language
|
||||
foreach (InternationalCodeCounter c in list)
|
||||
writer.WriteLine($"{GetFormattedInfo(c.Code)} : {c.Count}");
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "LanguageStatistics", AccessLevel.Administrator, LanguageStatistics_OnCommand );
|
||||
}
|
||||
e.Mobile.SendMessage("Languages list generated.");
|
||||
}
|
||||
}
|
||||
|
||||
[Usage( "LanguageStatistics" )]
|
||||
[Description( "Generate a file containing the list of languages for each PlayerMobile." )]
|
||||
public static void LanguageStatistics_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
Dictionary<string, InternationalCodeCounter> ht = new Dictionary<string, InternationalCodeCounter>();
|
||||
private struct InternationalCode
|
||||
{
|
||||
private bool m_HasLocalInfo;
|
||||
|
||||
using ( StreamWriter writer = new StreamWriter( "languages.txt" ) )
|
||||
{
|
||||
if ( CountAccounts )
|
||||
{
|
||||
// count accounts
|
||||
foreach ( Account acc in Accounts.GetAccounts() )
|
||||
{
|
||||
for ( int i = 0; i < acc.Length; i++ )
|
||||
{
|
||||
Mobile mob = acc[i];
|
||||
public string Code{ get; }
|
||||
|
||||
string lang = mob?.Language;
|
||||
public string Language{ get; }
|
||||
|
||||
if ( lang != null )
|
||||
{
|
||||
lang = lang.ToUpper();
|
||||
public string Country{ get; }
|
||||
|
||||
if ( !ht.ContainsKey( lang ) )
|
||||
ht[lang] = new InternationalCodeCounter( lang );
|
||||
else
|
||||
ht[lang].Increase();
|
||||
public string Language_LocalName{ get; }
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// count playermobiles
|
||||
foreach( Mobile mob in World.Mobiles.Values )
|
||||
{
|
||||
if ( mob.Player )
|
||||
{
|
||||
string lang = mob.Language;
|
||||
public string Country_LocalName{ get; }
|
||||
|
||||
if ( lang != null )
|
||||
{
|
||||
lang = lang.ToUpper();
|
||||
public InternationalCode(string code, string language, string country) : this(code, language, country, null,
|
||||
null)
|
||||
{
|
||||
m_HasLocalInfo = false;
|
||||
}
|
||||
|
||||
if ( !ht.ContainsKey( lang ) )
|
||||
ht[lang] = new InternationalCodeCounter( lang );
|
||||
else
|
||||
ht[lang].Increase();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public InternationalCode(string code, string language, string country, string language_localname,
|
||||
string country_localname)
|
||||
{
|
||||
Code = code;
|
||||
Language = language;
|
||||
Country = country;
|
||||
Language_LocalName = language_localname;
|
||||
Country_LocalName = country_localname;
|
||||
m_HasLocalInfo = true;
|
||||
}
|
||||
|
||||
writer.WriteLine(
|
||||
$"Language statistics. Numbers show how many {(CountAccounts ? "accounts" : "playermobile")} use the specified language.");
|
||||
writer.WriteLine( "====================================================================================================" );
|
||||
writer.WriteLine();
|
||||
public string GetName()
|
||||
{
|
||||
string s;
|
||||
|
||||
// sort the list
|
||||
List<InternationalCodeCounter> list = new List<InternationalCodeCounter>( ht.Values );
|
||||
list.Sort( InternationalCodeComparer.Instance );
|
||||
if (m_HasLocalInfo)
|
||||
{
|
||||
s =
|
||||
$"{(DefaultLocalNames ? Language_LocalName : Language)} - {(DefaultLocalNames ? Country_LocalName : Country)}";
|
||||
|
||||
foreach ( InternationalCodeCounter c in list )
|
||||
writer.WriteLine($"{GetFormattedInfo(c.Code)} : {c.Count}");
|
||||
if (ShowAlternatives)
|
||||
s +=
|
||||
$" 【{(DefaultLocalNames ? Language : Language_LocalName)} - {(DefaultLocalNames ? Country : Country_LocalName)}】";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = $"{Language} - {Country}";
|
||||
}
|
||||
|
||||
e.Mobile.SendMessage( "Languages list generated." );
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private class InternationalCodeCounter
|
||||
{
|
||||
public string Code { get; }
|
||||
private class InternationalCodeCounter
|
||||
{
|
||||
public InternationalCodeCounter(string code)
|
||||
{
|
||||
Code = code;
|
||||
Count = 1;
|
||||
}
|
||||
|
||||
public int Count { get; private set; }
|
||||
public string Code{ get; }
|
||||
|
||||
public InternationalCodeCounter( string code )
|
||||
{
|
||||
Code = code;
|
||||
Count = 1;
|
||||
}
|
||||
public int Count{ get; private set; }
|
||||
|
||||
public void Increase()
|
||||
{
|
||||
Count++;
|
||||
}
|
||||
}
|
||||
public void Increase()
|
||||
{
|
||||
Count++;
|
||||
}
|
||||
}
|
||||
|
||||
private class InternationalCodeComparer : IComparer<InternationalCodeCounter>
|
||||
{
|
||||
public static readonly InternationalCodeComparer Instance = new InternationalCodeComparer();
|
||||
private class InternationalCodeComparer : IComparer<InternationalCodeCounter>
|
||||
{
|
||||
public static readonly InternationalCodeComparer Instance = new InternationalCodeComparer();
|
||||
|
||||
public InternationalCodeComparer()
|
||||
{
|
||||
}
|
||||
public int Compare(InternationalCodeCounter x, InternationalCodeCounter y)
|
||||
{
|
||||
string a = null, b = null;
|
||||
int ca = 0, cb = 0;
|
||||
|
||||
public int Compare( InternationalCodeCounter x, InternationalCodeCounter y )
|
||||
{
|
||||
string a = null, b = null;
|
||||
int ca = 0, cb = 0;
|
||||
|
||||
a = x.Code;
|
||||
ca = x.Count;
|
||||
b = y.Code;
|
||||
cb = y.Count;
|
||||
a = x.Code;
|
||||
ca = x.Count;
|
||||
b = y.Code;
|
||||
cb = y.Count;
|
||||
|
||||
|
||||
if ( ca > cb )
|
||||
return -1;
|
||||
if (ca > cb)
|
||||
return -1;
|
||||
|
||||
if ( ca < cb )
|
||||
return 1;
|
||||
if (ca < cb)
|
||||
return 1;
|
||||
|
||||
if ( a == null && b == null )
|
||||
return 0;
|
||||
if (a == null && b == null)
|
||||
return 0;
|
||||
|
||||
if ( a == null )
|
||||
return 1;
|
||||
if (a == null)
|
||||
return 1;
|
||||
|
||||
if ( b == null )
|
||||
return -1;
|
||||
if (b == null)
|
||||
return -1;
|
||||
|
||||
return a.CompareTo( b );
|
||||
}
|
||||
}
|
||||
}
|
||||
return a.CompareTo(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,138 +1,139 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
using Server.Commands;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public class LightCycle
|
||||
{
|
||||
public const int DayLevel = 0;
|
||||
public const int NightLevel = 12;
|
||||
public const int DungeonLevel = 26;
|
||||
public const int JailLevel = 9;
|
||||
public class LightCycle
|
||||
{
|
||||
public const int DayLevel = 0;
|
||||
public const int NightLevel = 12;
|
||||
public const int DungeonLevel = 26;
|
||||
public const int JailLevel = 9;
|
||||
|
||||
private static int m_LevelOverride = int.MinValue;
|
||||
private static int m_LevelOverride = int.MinValue;
|
||||
|
||||
public static int LevelOverride
|
||||
{
|
||||
get => m_LevelOverride;
|
||||
set
|
||||
{
|
||||
m_LevelOverride = value;
|
||||
public static int LevelOverride
|
||||
{
|
||||
get => m_LevelOverride;
|
||||
set
|
||||
{
|
||||
m_LevelOverride = value;
|
||||
|
||||
for ( int i = 0; i < NetState.Instances.Count; ++i )
|
||||
{
|
||||
NetState ns = NetState.Instances[i];
|
||||
Mobile m = ns.Mobile;
|
||||
for (int i = 0; i < NetState.Instances.Count; ++i)
|
||||
{
|
||||
NetState ns = NetState.Instances[i];
|
||||
Mobile m = ns.Mobile;
|
||||
|
||||
m?.CheckLightLevels( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
m?.CheckLightLevels(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
new LightCycleTimer().Start();
|
||||
EventSink.Login += OnLogin;
|
||||
public static void Initialize()
|
||||
{
|
||||
new LightCycleTimer().Start();
|
||||
EventSink.Login += OnLogin;
|
||||
|
||||
CommandSystem.Register( "GlobalLight", AccessLevel.GameMaster, Light_OnCommand );
|
||||
}
|
||||
CommandSystem.Register("GlobalLight", AccessLevel.GameMaster, Light_OnCommand);
|
||||
}
|
||||
|
||||
[Usage( "GlobalLight <value>" )]
|
||||
[Description( "Sets the current global light level." )]
|
||||
private static void Light_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
if ( e.Length >= 1 )
|
||||
{
|
||||
LevelOverride = e.GetInt32( 0 );
|
||||
e.Mobile.SendMessage( "Global light level override has been changed to {0}.", m_LevelOverride );
|
||||
}
|
||||
else
|
||||
{
|
||||
LevelOverride = int.MinValue;
|
||||
e.Mobile.SendMessage( "Global light level override has been cleared." );
|
||||
}
|
||||
}
|
||||
[Usage("GlobalLight <value>")]
|
||||
[Description("Sets the current global light level.")]
|
||||
private static void Light_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
if (e.Length >= 1)
|
||||
{
|
||||
LevelOverride = e.GetInt32(0);
|
||||
e.Mobile.SendMessage("Global light level override has been changed to {0}.", m_LevelOverride);
|
||||
}
|
||||
else
|
||||
{
|
||||
LevelOverride = int.MinValue;
|
||||
e.Mobile.SendMessage("Global light level override has been cleared.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnLogin( LoginEventArgs args )
|
||||
{
|
||||
Mobile m = args.Mobile;
|
||||
public static void OnLogin(LoginEventArgs args)
|
||||
{
|
||||
Mobile m = args.Mobile;
|
||||
|
||||
m.CheckLightLevels( true );
|
||||
}
|
||||
m.CheckLightLevels(true);
|
||||
}
|
||||
|
||||
public static int ComputeLevelFor( Mobile from )
|
||||
{
|
||||
if ( m_LevelOverride > int.MinValue )
|
||||
return m_LevelOverride;
|
||||
public static int ComputeLevelFor(Mobile from)
|
||||
{
|
||||
if (m_LevelOverride > int.MinValue)
|
||||
return m_LevelOverride;
|
||||
|
||||
int hours, minutes;
|
||||
int hours, minutes;
|
||||
|
||||
Items.Clock.GetTime( from.Map, from.X, from.Y, out hours, out minutes );
|
||||
Clock.GetTime(from.Map, from.X, from.Y, out hours, out minutes);
|
||||
|
||||
/* OSI times:
|
||||
*
|
||||
* Midnight -> 3:59 AM : Night
|
||||
* 4:00 AM -> 11:59 PM : Day
|
||||
*
|
||||
* RunUO times:
|
||||
*
|
||||
* 10:00 PM -> 11:59 PM : Scale to night
|
||||
* Midnight -> 3:59 AM : Night
|
||||
* 4:00 AM -> 5:59 AM : Scale to day
|
||||
* 6:00 AM -> 9:59 PM : Day
|
||||
*/
|
||||
/* OSI times:
|
||||
*
|
||||
* Midnight -> 3:59 AM : Night
|
||||
* 4:00 AM -> 11:59 PM : Day
|
||||
*
|
||||
* RunUO times:
|
||||
*
|
||||
* 10:00 PM -> 11:59 PM : Scale to night
|
||||
* Midnight -> 3:59 AM : Night
|
||||
* 4:00 AM -> 5:59 AM : Scale to day
|
||||
* 6:00 AM -> 9:59 PM : Day
|
||||
*/
|
||||
|
||||
if ( hours < 4 )
|
||||
return NightLevel;
|
||||
if (hours < 4)
|
||||
return NightLevel;
|
||||
|
||||
if ( hours < 6 )
|
||||
return NightLevel + (((((hours - 4) * 60) + minutes) * (DayLevel - NightLevel)) / 120);
|
||||
if (hours < 6)
|
||||
return NightLevel + ((hours - 4) * 60 + minutes) * (DayLevel - NightLevel) / 120;
|
||||
|
||||
if ( hours < 22 )
|
||||
return DayLevel;
|
||||
if (hours < 22)
|
||||
return DayLevel;
|
||||
|
||||
if ( hours < 24 )
|
||||
return DayLevel + (((((hours - 22) * 60) + minutes) * (NightLevel - DayLevel)) / 120);
|
||||
if (hours < 24)
|
||||
return DayLevel + ((hours - 22) * 60 + minutes) * (NightLevel - DayLevel) / 120;
|
||||
|
||||
return NightLevel; // should never be
|
||||
}
|
||||
return NightLevel; // should never be
|
||||
}
|
||||
|
||||
private class LightCycleTimer : Timer
|
||||
{
|
||||
public LightCycleTimer() : base( TimeSpan.FromSeconds( 0 ), TimeSpan.FromSeconds( 5.0 ) )
|
||||
{
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
}
|
||||
private class LightCycleTimer : Timer
|
||||
{
|
||||
public LightCycleTimer() : base(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(5.0))
|
||||
{
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
for ( int i = 0; i < NetState.Instances.Count; ++i )
|
||||
{
|
||||
NetState ns = NetState.Instances[i];
|
||||
Mobile m = ns.Mobile;
|
||||
protected override void OnTick()
|
||||
{
|
||||
for (int i = 0; i < NetState.Instances.Count; ++i)
|
||||
{
|
||||
NetState ns = NetState.Instances[i];
|
||||
Mobile m = ns.Mobile;
|
||||
|
||||
m?.CheckLightLevels( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
m?.CheckLightLevels(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NightSightTimer : Timer
|
||||
{
|
||||
private Mobile m_Owner;
|
||||
public class NightSightTimer : Timer
|
||||
{
|
||||
private Mobile m_Owner;
|
||||
|
||||
public NightSightTimer( Mobile owner ) : base( TimeSpan.FromMinutes( Utility.Random( 15, 25 ) ) )
|
||||
{
|
||||
m_Owner = owner;
|
||||
Priority = TimerPriority.OneMinute;
|
||||
}
|
||||
public NightSightTimer(Mobile owner) : base(TimeSpan.FromMinutes(Utility.Random(15, 25)))
|
||||
{
|
||||
m_Owner = owner;
|
||||
Priority = TimerPriority.OneMinute;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_Owner.EndAction( typeof( LightCycle ) );
|
||||
m_Owner.LightLevel = 0;
|
||||
BuffInfo.RemoveBuff( m_Owner, BuffIcon.NightSight );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_Owner.EndAction(typeof(LightCycle));
|
||||
m_Owner.LightLevel = 0;
|
||||
BuffInfo.RemoveBuff(m_Owner, BuffIcon.NightSight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,28 +2,29 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class LoginStats
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
// Register our event handler
|
||||
EventSink.Login += EventSink_Login;
|
||||
}
|
||||
public class LoginStats
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
// Register our event handler
|
||||
EventSink.Login += EventSink_Login;
|
||||
}
|
||||
|
||||
private static void EventSink_Login( LoginEventArgs args )
|
||||
{
|
||||
int userCount = NetState.Instances.Count;
|
||||
int itemCount = World.Items.Count;
|
||||
int mobileCount = World.Mobiles.Count;
|
||||
private static void EventSink_Login(LoginEventArgs args)
|
||||
{
|
||||
int userCount = NetState.Instances.Count;
|
||||
int itemCount = World.Items.Count;
|
||||
int mobileCount = World.Mobiles.Count;
|
||||
|
||||
Mobile m = args.Mobile;
|
||||
Mobile m = args.Mobile;
|
||||
|
||||
m.SendMessage( "Welcome, {0}! There {1} currently {2} user{3} online, with {4} item{5} and {6} mobile{7} in the world.",
|
||||
args.Mobile.Name,
|
||||
userCount == 1 ? "is" : "are",
|
||||
userCount, userCount == 1 ? "" : "s",
|
||||
itemCount, itemCount == 1 ? "" : "s",
|
||||
mobileCount, mobileCount == 1 ? "" : "s" );
|
||||
}
|
||||
}
|
||||
m.SendMessage(
|
||||
"Welcome, {0}! There {1} currently {2} user{3} online, with {4} item{5} and {6} mobile{7} in the world.",
|
||||
args.Mobile.Name,
|
||||
userCount == 1 ? "is" : "are",
|
||||
userCount, userCount == 1 ? "" : "s",
|
||||
itemCount, itemCount == 1 ? "" : "s",
|
||||
mobileCount, mobileCount == 1 ? "" : "s");
|
||||
}
|
||||
}
|
||||
}
|
||||
1572
Scripts/Misc/Loot.cs
1572
Scripts/Misc/Loot.cs
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,51 +1,52 @@
|
|||
namespace Server.Misc
|
||||
{
|
||||
public class MapDefinitions
|
||||
{
|
||||
public static void Configure()
|
||||
{
|
||||
/* Here we configure all maps. Some notes:
|
||||
*
|
||||
* 1) The first 32 maps are reserved for core use.
|
||||
* 2) Map 0x7F is reserved for core use.
|
||||
* 3) Map 0xFF is reserved for core use.
|
||||
* 4) Changing or removing any predefined maps may cause server instability.
|
||||
*/
|
||||
public class MapDefinitions
|
||||
{
|
||||
public static void Configure()
|
||||
{
|
||||
/* Here we configure all maps. Some notes:
|
||||
*
|
||||
* 1) The first 32 maps are reserved for core use.
|
||||
* 2) Map 0x7F is reserved for core use.
|
||||
* 3) Map 0xFF is reserved for core use.
|
||||
* 4) Changing or removing any predefined maps may cause server instability.
|
||||
*/
|
||||
|
||||
RegisterMap( 0, 0, 0, 7168, 4096, 4, "Felucca", MapRules.FeluccaRules );
|
||||
RegisterMap( 1, 1, 1, 7168, 4096, 0, "Trammel", MapRules.TrammelRules );
|
||||
RegisterMap( 2, 2, 2, 2304, 1600, 1, "Ilshenar", MapRules.TrammelRules );
|
||||
RegisterMap( 3, 3, 3, 2560, 2048, 1, "Malas", MapRules.TrammelRules );
|
||||
RegisterMap( 4, 4, 4, 1448, 1448, 1, "Tokuno", MapRules.TrammelRules );
|
||||
RegisterMap( 5, 5, 5, 1280, 4096, 1, "TerMur", MapRules.TrammelRules );
|
||||
RegisterMap(0, 0, 0, 7168, 4096, 4, "Felucca", MapRules.FeluccaRules);
|
||||
RegisterMap(1, 1, 1, 7168, 4096, 0, "Trammel", MapRules.TrammelRules);
|
||||
RegisterMap(2, 2, 2, 2304, 1600, 1, "Ilshenar", MapRules.TrammelRules);
|
||||
RegisterMap(3, 3, 3, 2560, 2048, 1, "Malas", MapRules.TrammelRules);
|
||||
RegisterMap(4, 4, 4, 1448, 1448, 1, "Tokuno", MapRules.TrammelRules);
|
||||
RegisterMap(5, 5, 5, 1280, 4096, 1, "TerMur", MapRules.TrammelRules);
|
||||
|
||||
RegisterMap( 0x7F, 0x7F, 0x7F, Map.SectorSize, Map.SectorSize, 1, "Internal", MapRules.Internal );
|
||||
RegisterMap(0x7F, 0x7F, 0x7F, Map.SectorSize, Map.SectorSize, 1, "Internal", MapRules.Internal);
|
||||
|
||||
/* Example of registering a custom map:
|
||||
* RegisterMap( 32, 0, 0, 6144, 4096, 3, "Iceland", MapRules.FeluccaRules );
|
||||
*
|
||||
* Defined:
|
||||
* RegisterMap( <index>, <mapID>, <fileIndex>, <width>, <height>, <season>, <name>, <rules> );
|
||||
* - <index> : An unreserved unique index for this map
|
||||
* - <mapID> : An identification number used in client communications. For any visible maps, this value must be from 0-5
|
||||
* - <fileIndex> : A file identification number. For any visible maps, this value must be from 0-5
|
||||
* - <width>, <height> : Size of the map (in tiles)
|
||||
* - <season> : Season of the map. 0 = Spring, 1 = Summer, 2 = Fall, 3 = Winter, 4 = Desolation
|
||||
* - <name> : Reference name for the map, used in props gump, get/set commands, region loading, etc
|
||||
* - <rules> : Rules and restrictions associated with the map. See documentation for details
|
||||
*/
|
||||
/* Example of registering a custom map:
|
||||
* RegisterMap( 32, 0, 0, 6144, 4096, 3, "Iceland", MapRules.FeluccaRules );
|
||||
*
|
||||
* Defined:
|
||||
* RegisterMap( <index>, <mapID>, <fileIndex>, <width>, <height>, <season>, <name>, <rules> );
|
||||
* - <index> : An unreserved unique index for this map
|
||||
* - <mapID> : An identification number used in client communications. For any visible maps, this value must be from 0-5
|
||||
* - <fileIndex> : A file identification number. For any visible maps, this value must be from 0-5
|
||||
* - <width>, <height> : Size of the map (in tiles)
|
||||
* - <season> : Season of the map. 0 = Spring, 1 = Summer, 2 = Fall, 3 = Winter, 4 = Desolation
|
||||
* - <name> : Reference name for the map, used in props gump, get/set commands, region loading, etc
|
||||
* - <rules> : Rules and restrictions associated with the map. See documentation for details
|
||||
*/
|
||||
|
||||
TileMatrixPatch.Enabled = false; // OSI Client Patch 6.0.0.0
|
||||
TileMatrixPatch.Enabled = false; // OSI Client Patch 6.0.0.0
|
||||
|
||||
MultiComponentList.PostHSFormat = true; // OSI Client Patch 7.0.9.0
|
||||
}
|
||||
MultiComponentList.PostHSFormat = true; // OSI Client Patch 7.0.9.0
|
||||
}
|
||||
|
||||
public static void RegisterMap( int mapIndex, int mapID, int fileIndex, int width, int height, int season, string name, MapRules rules )
|
||||
{
|
||||
Map newMap = new Map( mapID, mapIndex, fileIndex, width, height, season, name, rules );
|
||||
public static void RegisterMap(int mapIndex, int mapID, int fileIndex, int width, int height, int season,
|
||||
string name, MapRules rules)
|
||||
{
|
||||
Map newMap = new Map(mapID, mapIndex, fileIndex, width, height, season, name, rules);
|
||||
|
||||
Map.Maps[mapIndex] = newMap;
|
||||
Map.AllMaps.Add( newMap );
|
||||
}
|
||||
}
|
||||
Map.Maps[mapIndex] = newMap;
|
||||
Map.AllMaps.Add(newMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,127 +1,130 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
using Server.Engines.PartySystem;
|
||||
using Server.Guilds;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public static partial class MapUO
|
||||
{
|
||||
private static class Settings
|
||||
{
|
||||
public const bool PartyTrack = true;
|
||||
public const bool GuildTrack = true;
|
||||
public const bool GuildHitsPercent = true;
|
||||
}
|
||||
public static class MapUO
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Settings.PartyTrack)
|
||||
ProtocolExtensions.Register(0x00, true, OnPartyTrack);
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if ( Settings.PartyTrack )
|
||||
ProtocolExtensions.Register( 0x00, true, OnPartyTrack );
|
||||
if (Settings.GuildTrack)
|
||||
ProtocolExtensions.Register(0x01, true, OnGuildTrack);
|
||||
}
|
||||
|
||||
if ( Settings.GuildTrack )
|
||||
ProtocolExtensions.Register( 0x01, true, OnGuildTrack );
|
||||
}
|
||||
private static void OnPartyTrack(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
Party party = Party.Get(from);
|
||||
|
||||
private static void OnPartyTrack( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
Party party = Party.Get( from );
|
||||
if (party != null)
|
||||
{
|
||||
Packets.PartyTrack packet = new Packets.PartyTrack(from, party);
|
||||
|
||||
if ( party != null )
|
||||
{
|
||||
Packets.PartyTrack packet = new Packets.PartyTrack( from, party );
|
||||
if (packet.UnderlyingStream.Length > 8)
|
||||
state.Send(packet);
|
||||
}
|
||||
}
|
||||
|
||||
if ( packet.UnderlyingStream.Length > 8 )
|
||||
state.Send( packet );
|
||||
}
|
||||
}
|
||||
private static void OnGuildTrack(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
|
||||
private static void OnGuildTrack( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
if (from.Guild is Guild guild)
|
||||
{
|
||||
bool locations = pvSrc.ReadByte() != 0;
|
||||
|
||||
if ( from.Guild is Guild guild )
|
||||
{
|
||||
bool locations = pvSrc.ReadByte() != 0;
|
||||
Packets.GuildTrack packet = new Packets.GuildTrack(from, guild, locations);
|
||||
|
||||
Packets.GuildTrack packet = new Packets.GuildTrack( from, guild, locations );
|
||||
if (packet.UnderlyingStream.Length > (locations ? 9 : 5))
|
||||
state.Send(packet);
|
||||
}
|
||||
else
|
||||
{
|
||||
state.Send(new Packets.GuildTrack());
|
||||
}
|
||||
}
|
||||
|
||||
if ( packet.UnderlyingStream.Length > ( locations ? 9 : 5 ) )
|
||||
state.Send( packet );
|
||||
}
|
||||
else
|
||||
state.Send( new Packets.GuildTrack() );
|
||||
}
|
||||
private static class Settings
|
||||
{
|
||||
public const bool PartyTrack = true;
|
||||
public const bool GuildTrack = true;
|
||||
public const bool GuildHitsPercent = true;
|
||||
}
|
||||
|
||||
private static class Packets
|
||||
{
|
||||
public sealed class PartyTrack : ProtocolExtension
|
||||
{
|
||||
public PartyTrack( Mobile from, Party party ) : base( 0x01, ( ( party.Members.Count - 1 ) * 9 ) + 4 )
|
||||
{
|
||||
for ( int i = 0; i < party.Members.Count; ++i )
|
||||
{
|
||||
PartyMemberInfo pmi = (PartyMemberInfo)party.Members[i];
|
||||
private static class Packets
|
||||
{
|
||||
public sealed class PartyTrack : ProtocolExtension
|
||||
{
|
||||
public PartyTrack(Mobile from, Party party) : base(0x01, (party.Members.Count - 1) * 9 + 4)
|
||||
{
|
||||
for (int i = 0; i < party.Members.Count; ++i)
|
||||
{
|
||||
PartyMemberInfo pmi = party.Members[i];
|
||||
|
||||
if ( pmi == null || pmi.Mobile == from )
|
||||
continue;
|
||||
if (pmi == null || pmi.Mobile == from)
|
||||
continue;
|
||||
|
||||
Mobile mob = pmi.Mobile;
|
||||
Mobile mob = pmi.Mobile;
|
||||
|
||||
if ( Utility.InUpdateRange( from, mob ) && from.CanSee( mob ) )
|
||||
continue;
|
||||
if (Utility.InUpdateRange(from, mob) && from.CanSee(mob))
|
||||
continue;
|
||||
|
||||
m_Stream.Write( (int) mob.Serial );
|
||||
m_Stream.Write( (short) mob.X );
|
||||
m_Stream.Write( (short) mob.Y );
|
||||
m_Stream.Write( (byte) (mob.Map?.MapID ?? 0) );
|
||||
}
|
||||
m_Stream.Write(mob.Serial);
|
||||
m_Stream.Write((short)mob.X);
|
||||
m_Stream.Write((short)mob.Y);
|
||||
m_Stream.Write((byte)(mob.Map?.MapID ?? 0));
|
||||
}
|
||||
|
||||
m_Stream.Write( (int) 0 );
|
||||
}
|
||||
}
|
||||
m_Stream.Write(0);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class GuildTrack : ProtocolExtension
|
||||
{
|
||||
public GuildTrack() : base( 0x02, 5 )
|
||||
{
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (int) 0 );
|
||||
}
|
||||
public sealed class GuildTrack : ProtocolExtension
|
||||
{
|
||||
public GuildTrack() : base(0x02, 5)
|
||||
{
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write(0);
|
||||
}
|
||||
|
||||
public GuildTrack( Mobile from, Guild guild, bool locations ) : base( 0x02, ( ( guild.Members.Count - 1 ) * ( locations ? 10 : 4 ) ) + 5 )
|
||||
{
|
||||
m_Stream.Write( (byte) ( locations ? 1 : 0 ) );
|
||||
public GuildTrack(Mobile from, Guild guild, bool locations) : base(0x02,
|
||||
(guild.Members.Count - 1) * (locations ? 10 : 4) + 5)
|
||||
{
|
||||
m_Stream.Write((byte)(locations ? 1 : 0));
|
||||
|
||||
for ( int i = 0; i < guild.Members.Count; ++i )
|
||||
{
|
||||
Mobile mob = guild.Members[i];
|
||||
for (int i = 0; i < guild.Members.Count; ++i)
|
||||
{
|
||||
Mobile mob = guild.Members[i];
|
||||
|
||||
if ( mob == null || mob == from || mob.NetState == null )
|
||||
continue;
|
||||
if (mob == null || mob == from || mob.NetState == null)
|
||||
continue;
|
||||
|
||||
if ( locations && Utility.InUpdateRange( from, mob ) && from.CanSee( mob ) )
|
||||
continue;
|
||||
if (locations && Utility.InUpdateRange(from, mob) && from.CanSee(mob))
|
||||
continue;
|
||||
|
||||
m_Stream.Write( (int) mob.Serial );
|
||||
m_Stream.Write(mob.Serial);
|
||||
|
||||
if ( locations )
|
||||
{
|
||||
m_Stream.Write( (short) mob.X );
|
||||
m_Stream.Write( (short) mob.Y );
|
||||
m_Stream.Write( (byte) (mob.Map?.MapID ?? 0) );
|
||||
if (locations)
|
||||
{
|
||||
m_Stream.Write((short)mob.X);
|
||||
m_Stream.Write((short)mob.Y);
|
||||
m_Stream.Write((byte)(mob.Map?.MapID ?? 0));
|
||||
|
||||
if ( Settings.GuildHitsPercent && mob.Alive )
|
||||
m_Stream.Write( (byte) ( mob.Hits / Math.Max( mob.HitsMax, 1.0 ) * 100 ) );
|
||||
else
|
||||
m_Stream.Write( (byte) 0 );
|
||||
}
|
||||
}
|
||||
if (Settings.GuildHitsPercent && mob.Alive)
|
||||
m_Stream.Write((byte)(mob.Hits / Math.Max(mob.HitsMax, 1.0) * 100));
|
||||
else
|
||||
m_Stream.Write((byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
m_Stream.Write( (int) 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Stream.Write(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,73 +4,75 @@ using Server.Mobiles;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public static class MondainsLegacy
|
||||
{
|
||||
public static Type[] Artifacts { get; } =
|
||||
{
|
||||
typeof( AegisOfGrace ), typeof( BladeDance ), typeof( BloodwoodSpirit ), typeof( Bonesmasher ),
|
||||
typeof( Boomstick ), typeof( BrightsightLenses ), typeof( FeyLeggings ), typeof( FleshRipper ),
|
||||
typeof( HelmOfSwiftness ), typeof( PadsOfTheCuSidhe ), typeof( QuiverOfRage ), typeof( QuiverOfElements ),
|
||||
typeof( RaedsGlory ), typeof( RighteousAnger ), typeof( RobeOfTheEclipse ), typeof( RobeOfTheEquinox ),
|
||||
typeof( SoulSeeker ), typeof( TalonBite ), typeof( TotemOfVoid ), typeof( WildfireBow ),
|
||||
typeof( Windsong )
|
||||
};
|
||||
public static class MondainsLegacy
|
||||
{
|
||||
public static Type[] Artifacts{ get; } =
|
||||
{
|
||||
typeof(AegisOfGrace), typeof(BladeDance), typeof(BloodwoodSpirit), typeof(Bonesmasher),
|
||||
typeof(Boomstick), typeof(BrightsightLenses), typeof(FeyLeggings), typeof(FleshRipper),
|
||||
typeof(HelmOfSwiftness), typeof(PadsOfTheCuSidhe), typeof(QuiverOfRage), typeof(QuiverOfElements),
|
||||
typeof(RaedsGlory), typeof(RighteousAnger), typeof(RobeOfTheEclipse), typeof(RobeOfTheEquinox),
|
||||
typeof(SoulSeeker), typeof(TalonBite), typeof(TotemOfVoid), typeof(WildfireBow),
|
||||
typeof(Windsong)
|
||||
};
|
||||
|
||||
public static bool CheckArtifactChance( Mobile m, BaseCreature bc )
|
||||
{
|
||||
if ( !Core.ML )
|
||||
return false;
|
||||
public static bool CheckArtifactChance(Mobile m, BaseCreature bc)
|
||||
{
|
||||
if (!Core.ML)
|
||||
return false;
|
||||
|
||||
return Paragon.CheckArtifactChance( m, bc );
|
||||
}
|
||||
return Paragon.CheckArtifactChance(m, bc);
|
||||
}
|
||||
|
||||
public static void GiveArtifactTo( Mobile m )
|
||||
{
|
||||
if ( !(Activator.CreateInstance( Artifacts[Utility.Random( Artifacts.Length )] ) is Item item) )
|
||||
return;
|
||||
public static void GiveArtifactTo(Mobile m)
|
||||
{
|
||||
if (!(Activator.CreateInstance(Artifacts[Utility.Random(Artifacts.Length)]) is Item item))
|
||||
return;
|
||||
|
||||
if ( m.AddToBackpack( item ) )
|
||||
{
|
||||
m.SendLocalizedMessage( 1072223 ); // An item has been placed in your backpack.
|
||||
m.SendLocalizedMessage( 1062317 ); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
|
||||
}
|
||||
else if ( m.BankBox.TryDropItem( m, item, false ) )
|
||||
{
|
||||
m.SendLocalizedMessage( 1072224 ); // An item has been placed in your bank box.
|
||||
m.SendLocalizedMessage( 1062317 ); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Item was placed at feet by m.AddToBackpack
|
||||
m.SendLocalizedMessage( 1072523 ); // You find an artifact, but your backpack and bank are too full to hold it.
|
||||
}
|
||||
}
|
||||
if (m.AddToBackpack(item))
|
||||
{
|
||||
m.SendLocalizedMessage(1072223); // An item has been placed in your backpack.
|
||||
m.SendLocalizedMessage(
|
||||
1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
|
||||
}
|
||||
else if (m.BankBox.TryDropItem(m, item, false))
|
||||
{
|
||||
m.SendLocalizedMessage(1072224); // An item has been placed in your bank box.
|
||||
m.SendLocalizedMessage(
|
||||
1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Item was placed at feet by m.AddToBackpack
|
||||
m.SendLocalizedMessage(1072523); // You find an artifact, but your backpack and bank are too full to hold it.
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckML( Mobile from, bool message = true)
|
||||
{
|
||||
if ( from?.NetState == null )
|
||||
return false;
|
||||
public static bool CheckML(Mobile from, bool message = true)
|
||||
{
|
||||
if (from?.NetState == null)
|
||||
return false;
|
||||
|
||||
if ( from.NetState.SupportsExpansion( Expansion.ML ) )
|
||||
return true;
|
||||
if (from.NetState.SupportsExpansion(Expansion.ML))
|
||||
return true;
|
||||
|
||||
if ( message )
|
||||
from.SendLocalizedMessage( 1072791 ); // You must upgrade to Mondain's Legacy in order to use that item.
|
||||
if (message)
|
||||
from.SendLocalizedMessage(1072791); // You must upgrade to Mondain's Legacy in order to use that item.
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsMLRegion( Region region )
|
||||
{
|
||||
return region.IsPartOf( "Twisted Weald" )
|
||||
|| region.IsPartOf( "Sanctuary" )
|
||||
|| region.IsPartOf( "The Prism of Light" )
|
||||
|| region.IsPartOf( "The Citadel" )
|
||||
|| region.IsPartOf( "Bedlam" )
|
||||
|| region.IsPartOf( "Blighted Grove" )
|
||||
|| region.IsPartOf( "The Painted Caves" )
|
||||
|| region.IsPartOf( "The Palace of Paroxysmus" )
|
||||
|| region.IsPartOf( "Labyrinth" );
|
||||
}
|
||||
}
|
||||
}
|
||||
public static bool IsMLRegion(Region region)
|
||||
{
|
||||
return region.IsPartOf("Twisted Weald")
|
||||
|| region.IsPartOf("Sanctuary")
|
||||
|| region.IsPartOf("The Prism of Light")
|
||||
|| region.IsPartOf("The Citadel")
|
||||
|| region.IsPartOf("Bedlam")
|
||||
|| region.IsPartOf("Blighted Grove")
|
||||
|| region.IsPartOf("The Painted Caves")
|
||||
|| region.IsPartOf("The Palace of Paroxysmus")
|
||||
|| region.IsPartOf("Labyrinth");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,200 +2,201 @@ using Server.Commands;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class NameVerification
|
||||
{
|
||||
public static readonly char[] SpaceDashPeriodQuote = {
|
||||
' ', '-', '.', '\''
|
||||
};
|
||||
public class NameVerification
|
||||
{
|
||||
public static readonly char[] SpaceDashPeriodQuote =
|
||||
{
|
||||
' ', '-', '.', '\''
|
||||
};
|
||||
|
||||
public static readonly char[] Empty = new char[0];
|
||||
public static readonly char[] Empty = new char[0];
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "ValidateName", AccessLevel.Administrator, ValidateName_OnCommand );
|
||||
}
|
||||
public static string[] StartDisallowed{ get; } =
|
||||
{
|
||||
"seer",
|
||||
"counselor",
|
||||
"gm",
|
||||
"admin",
|
||||
"lady",
|
||||
"lord"
|
||||
};
|
||||
|
||||
[Usage( "ValidateName" )]
|
||||
[Description( "Checks the result of NameValidation on the specified name." )]
|
||||
public static void ValidateName_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
if ( Validate( e.ArgString, 2, 16, true, false, true, 1, SpaceDashPeriodQuote ) )
|
||||
e.Mobile.SendMessage( 0x59, "That name is considered valid." );
|
||||
else
|
||||
e.Mobile.SendMessage( 0x22, "That name is considered invalid." );
|
||||
}
|
||||
public static string[] Disallowed{ get; } =
|
||||
{
|
||||
"jigaboo",
|
||||
"chigaboo",
|
||||
"wop",
|
||||
"kyke",
|
||||
"kike",
|
||||
"tit",
|
||||
"spic",
|
||||
"prick",
|
||||
"piss",
|
||||
"lezbo",
|
||||
"lesbo",
|
||||
"felatio",
|
||||
"dyke",
|
||||
"dildo",
|
||||
"chinc",
|
||||
"chink",
|
||||
"cunnilingus",
|
||||
"cum",
|
||||
"cocksucker",
|
||||
"cock",
|
||||
"clitoris",
|
||||
"clit",
|
||||
"ass",
|
||||
"hitler",
|
||||
"penis",
|
||||
"nigga",
|
||||
"nigger",
|
||||
"klit",
|
||||
"kunt",
|
||||
"jiz",
|
||||
"jism",
|
||||
"jerkoff",
|
||||
"jackoff",
|
||||
"goddamn",
|
||||
"fag",
|
||||
"blowjob",
|
||||
"bitch",
|
||||
"asshole",
|
||||
"dick",
|
||||
"pussy",
|
||||
"snatch",
|
||||
"cunt",
|
||||
"twat",
|
||||
"shit",
|
||||
"fuck",
|
||||
"tailor",
|
||||
"smith",
|
||||
"scholar",
|
||||
"rogue",
|
||||
"novice",
|
||||
"neophyte",
|
||||
"merchant",
|
||||
"medium",
|
||||
"master",
|
||||
"mage",
|
||||
"lb",
|
||||
"journeyman",
|
||||
"grandmaster",
|
||||
"fisherman",
|
||||
"expert",
|
||||
"chef",
|
||||
"carpenter",
|
||||
"british",
|
||||
"blackthorne",
|
||||
"blackthorn",
|
||||
"beggar",
|
||||
"archer",
|
||||
"apprentice",
|
||||
"adept",
|
||||
"gamemaster",
|
||||
"frozen",
|
||||
"squelched",
|
||||
"invulnerable",
|
||||
"osi",
|
||||
"origin"
|
||||
};
|
||||
|
||||
public static bool Validate( string name, int minLength, int maxLength, bool allowLetters, bool allowDigits, bool noExceptionsAtStart, int maxExceptions, char[] exceptions )
|
||||
{
|
||||
return Validate( name, minLength, maxLength, allowLetters, allowDigits, noExceptionsAtStart, maxExceptions, exceptions, Disallowed, StartDisallowed );
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("ValidateName", AccessLevel.Administrator, ValidateName_OnCommand);
|
||||
}
|
||||
|
||||
public static bool Validate( string name, int minLength, int maxLength, bool allowLetters, bool allowDigits, bool noExceptionsAtStart, int maxExceptions, char[] exceptions, string[] disallowed, string[] startDisallowed )
|
||||
{
|
||||
if ( name == null || name.Length < minLength || name.Length > maxLength )
|
||||
return false;
|
||||
[Usage("ValidateName")]
|
||||
[Description("Checks the result of NameValidation on the specified name.")]
|
||||
public static void ValidateName_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
if (Validate(e.ArgString, 2, 16, true, false, true, 1, SpaceDashPeriodQuote))
|
||||
e.Mobile.SendMessage(0x59, "That name is considered valid.");
|
||||
else
|
||||
e.Mobile.SendMessage(0x22, "That name is considered invalid.");
|
||||
}
|
||||
|
||||
int exceptCount = 0;
|
||||
public static bool Validate(string name, int minLength, int maxLength, bool allowLetters, bool allowDigits,
|
||||
bool noExceptionsAtStart, int maxExceptions, char[] exceptions)
|
||||
{
|
||||
return Validate(name, minLength, maxLength, allowLetters, allowDigits, noExceptionsAtStart, maxExceptions,
|
||||
exceptions, Disallowed, StartDisallowed);
|
||||
}
|
||||
|
||||
name = name.ToLower();
|
||||
public static bool Validate(string name, int minLength, int maxLength, bool allowLetters, bool allowDigits,
|
||||
bool noExceptionsAtStart, int maxExceptions, char[] exceptions, string[] disallowed, string[] startDisallowed)
|
||||
{
|
||||
if (name == null || name.Length < minLength || name.Length > maxLength)
|
||||
return false;
|
||||
|
||||
if ( !allowLetters || !allowDigits || (exceptions.Length > 0 && (noExceptionsAtStart || maxExceptions < int.MaxValue)) )
|
||||
{
|
||||
for ( int i = 0; i < name.Length; ++i )
|
||||
{
|
||||
char c = name[i];
|
||||
int exceptCount = 0;
|
||||
|
||||
if ( c >= 'a' && c <= 'z' )
|
||||
{
|
||||
if ( !allowLetters )
|
||||
return false;
|
||||
name = name.ToLower();
|
||||
|
||||
exceptCount = 0;
|
||||
}
|
||||
else if ( c >= '0' && c <= '9' )
|
||||
{
|
||||
if ( !allowDigits )
|
||||
return false;
|
||||
if (!allowLetters || !allowDigits ||
|
||||
exceptions.Length > 0 && (noExceptionsAtStart || maxExceptions < int.MaxValue))
|
||||
for (int i = 0; i < name.Length; ++i)
|
||||
{
|
||||
char c = name[i];
|
||||
|
||||
exceptCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool except = false;
|
||||
if (c >= 'a' && c <= 'z')
|
||||
{
|
||||
if (!allowLetters)
|
||||
return false;
|
||||
|
||||
for ( int j = 0; !except && j < exceptions.Length; ++j )
|
||||
if ( c == exceptions[j] )
|
||||
except = true;
|
||||
exceptCount = 0;
|
||||
}
|
||||
else if (c >= '0' && c <= '9')
|
||||
{
|
||||
if (!allowDigits)
|
||||
return false;
|
||||
|
||||
if ( !except || (i == 0 && noExceptionsAtStart) )
|
||||
return false;
|
||||
exceptCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool except = false;
|
||||
|
||||
if ( exceptCount++ == maxExceptions )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j = 0; !except && j < exceptions.Length; ++j)
|
||||
if (c == exceptions[j])
|
||||
except = true;
|
||||
|
||||
for ( int i = 0; i < disallowed.Length; ++i )
|
||||
{
|
||||
int indexOf = name.IndexOf( disallowed[i] );
|
||||
if (!except || i == 0 && noExceptionsAtStart)
|
||||
return false;
|
||||
|
||||
if ( indexOf == -1 )
|
||||
continue;
|
||||
if (exceptCount++ == maxExceptions)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool badPrefix = ( indexOf == 0 );
|
||||
for (int i = 0; i < disallowed.Length; ++i)
|
||||
{
|
||||
int indexOf = name.IndexOf(disallowed[i]);
|
||||
|
||||
for ( int j = 0; !badPrefix && j < exceptions.Length; ++j )
|
||||
badPrefix = ( name[indexOf - 1] == exceptions[j] );
|
||||
if (indexOf == -1)
|
||||
continue;
|
||||
|
||||
if ( !badPrefix )
|
||||
continue;
|
||||
bool badPrefix = indexOf == 0;
|
||||
|
||||
bool badSuffix = ( (indexOf + disallowed[i].Length) >= name.Length );
|
||||
for (int j = 0; !badPrefix && j < exceptions.Length; ++j)
|
||||
badPrefix = name[indexOf - 1] == exceptions[j];
|
||||
|
||||
for ( int j = 0; !badSuffix && j < exceptions.Length; ++j )
|
||||
badSuffix = ( name[indexOf + disallowed[i].Length] == exceptions[j] );
|
||||
if (!badPrefix)
|
||||
continue;
|
||||
|
||||
if ( badSuffix )
|
||||
return false;
|
||||
}
|
||||
bool badSuffix = indexOf + disallowed[i].Length >= name.Length;
|
||||
|
||||
for ( int i = 0; i < startDisallowed.Length; ++i )
|
||||
{
|
||||
if ( name.StartsWith( startDisallowed[i] ) )
|
||||
return false;
|
||||
}
|
||||
for (int j = 0; !badSuffix && j < exceptions.Length; ++j)
|
||||
badSuffix = name[indexOf + disallowed[i].Length] == exceptions[j];
|
||||
|
||||
return true;
|
||||
}
|
||||
if (badSuffix)
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string[] StartDisallowed { get; } =
|
||||
{
|
||||
"seer",
|
||||
"counselor",
|
||||
"gm",
|
||||
"admin",
|
||||
"lady",
|
||||
"lord"
|
||||
};
|
||||
for (int i = 0; i < startDisallowed.Length; ++i)
|
||||
if (name.StartsWith(startDisallowed[i]))
|
||||
return false;
|
||||
|
||||
public static string[] Disallowed { get; } =
|
||||
{
|
||||
"jigaboo",
|
||||
"chigaboo",
|
||||
"wop",
|
||||
"kyke",
|
||||
"kike",
|
||||
"tit",
|
||||
"spic",
|
||||
"prick",
|
||||
"piss",
|
||||
"lezbo",
|
||||
"lesbo",
|
||||
"felatio",
|
||||
"dyke",
|
||||
"dildo",
|
||||
"chinc",
|
||||
"chink",
|
||||
"cunnilingus",
|
||||
"cum",
|
||||
"cocksucker",
|
||||
"cock",
|
||||
"clitoris",
|
||||
"clit",
|
||||
"ass",
|
||||
"hitler",
|
||||
"penis",
|
||||
"nigga",
|
||||
"nigger",
|
||||
"klit",
|
||||
"kunt",
|
||||
"jiz",
|
||||
"jism",
|
||||
"jerkoff",
|
||||
"jackoff",
|
||||
"goddamn",
|
||||
"fag",
|
||||
"blowjob",
|
||||
"bitch",
|
||||
"asshole",
|
||||
"dick",
|
||||
"pussy",
|
||||
"snatch",
|
||||
"cunt",
|
||||
"twat",
|
||||
"shit",
|
||||
"fuck",
|
||||
"tailor",
|
||||
"smith",
|
||||
"scholar",
|
||||
"rogue",
|
||||
"novice",
|
||||
"neophyte",
|
||||
"merchant",
|
||||
"medium",
|
||||
"master",
|
||||
"mage",
|
||||
"lb",
|
||||
"journeyman",
|
||||
"grandmaster",
|
||||
"fisherman",
|
||||
"expert",
|
||||
"chef",
|
||||
"carpenter",
|
||||
"british",
|
||||
"blackthorne",
|
||||
"blackthorn",
|
||||
"beggar",
|
||||
"archer",
|
||||
"apprentice",
|
||||
"adept",
|
||||
"gamemaster",
|
||||
"frozen",
|
||||
"squelched",
|
||||
"invulnerable",
|
||||
"osi",
|
||||
"origin"
|
||||
};
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,463 +1,491 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Engines.ConPVP;
|
||||
using Server.Items;
|
||||
using Server.Guilds;
|
||||
using Server.Multis;
|
||||
using Server.Mobiles;
|
||||
using Server.Engines.PartySystem;
|
||||
using Server.Factions;
|
||||
using Server.Guilds;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
using Server.SkillHandlers;
|
||||
using Server.Spells.Seventh;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class NotorietyHandlers
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Notoriety.Hues[Notoriety.Innocent] = 0x59;
|
||||
Notoriety.Hues[Notoriety.Ally] = 0x3F;
|
||||
Notoriety.Hues[Notoriety.CanBeAttacked] = 0x3B2;
|
||||
Notoriety.Hues[Notoriety.Criminal] = 0x3B2;
|
||||
Notoriety.Hues[Notoriety.Enemy] = 0x90;
|
||||
Notoriety.Hues[Notoriety.Murderer] = 0x22;
|
||||
Notoriety.Hues[Notoriety.Invulnerable] = 0x35;
|
||||
|
||||
Notoriety.Handler = MobileNotoriety;
|
||||
public class NotorietyHandlers
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
Notoriety.Hues[Notoriety.Innocent] = 0x59;
|
||||
Notoriety.Hues[Notoriety.Ally] = 0x3F;
|
||||
Notoriety.Hues[Notoriety.CanBeAttacked] = 0x3B2;
|
||||
Notoriety.Hues[Notoriety.Criminal] = 0x3B2;
|
||||
Notoriety.Hues[Notoriety.Enemy] = 0x90;
|
||||
Notoriety.Hues[Notoriety.Murderer] = 0x22;
|
||||
Notoriety.Hues[Notoriety.Invulnerable] = 0x35;
|
||||
|
||||
Notoriety.Handler = MobileNotoriety;
|
||||
|
||||
Mobile.AllowBeneficialHandler = Mobile_AllowBeneficial;
|
||||
Mobile.AllowHarmfulHandler = Mobile_AllowHarmful;
|
||||
}
|
||||
Mobile.AllowBeneficialHandler = Mobile_AllowBeneficial;
|
||||
Mobile.AllowHarmfulHandler = Mobile_AllowHarmful;
|
||||
}
|
||||
|
||||
private enum GuildStatus { None, Peaceful, Waring }
|
||||
private static GuildStatus GetGuildStatus(Mobile m)
|
||||
{
|
||||
if (m.Guild == null)
|
||||
return GuildStatus.None;
|
||||
if (((Guild)m.Guild).Enemies.Count == 0 && m.Guild.Type == GuildType.Regular)
|
||||
return GuildStatus.Peaceful;
|
||||
|
||||
private static GuildStatus GetGuildStatus( Mobile m )
|
||||
{
|
||||
if ( m.Guild == null )
|
||||
return GuildStatus.None;
|
||||
if ( ((Guild)m.Guild).Enemies.Count == 0 && m.Guild.Type == GuildType.Regular )
|
||||
return GuildStatus.Peaceful;
|
||||
return GuildStatus.Waring;
|
||||
}
|
||||
|
||||
return GuildStatus.Waring;
|
||||
}
|
||||
private static bool CheckBeneficialStatus(GuildStatus from, GuildStatus target)
|
||||
{
|
||||
if (from == GuildStatus.Waring || target == GuildStatus.Waring)
|
||||
return false;
|
||||
|
||||
private static bool CheckBeneficialStatus( GuildStatus from, GuildStatus target )
|
||||
{
|
||||
if ( from == GuildStatus.Waring || target == GuildStatus.Waring )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target )
|
||||
{
|
||||
if ( from == GuildStatus.Waring && target == GuildStatus.Waring )
|
||||
return true;
|
||||
|
||||
/*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target )
|
||||
{
|
||||
if ( from == GuildStatus.Waring && target == GuildStatus.Waring )
|
||||
return true;
|
||||
return false;
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}*/
|
||||
public static bool Mobile_AllowBeneficial(Mobile from, Mobile target)
|
||||
{
|
||||
if (from == null || target == null || from.AccessLevel > AccessLevel.Player ||
|
||||
target.AccessLevel > AccessLevel.Player)
|
||||
return true;
|
||||
|
||||
public static bool Mobile_AllowBeneficial( Mobile from, Mobile target )
|
||||
{
|
||||
if ( from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player )
|
||||
return true;
|
||||
#region Dueling
|
||||
|
||||
#region Dueling
|
||||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
|
||||
if ( pmFrom == null && from is BaseCreature bcFrom )
|
||||
{
|
||||
if ( bcFrom.Summoned )
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
}
|
||||
if (pmFrom == null && from is BaseCreature bcFrom)
|
||||
if (bcFrom.Summoned)
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( pmTarg == null && target is BaseCreature bcTarg )
|
||||
{
|
||||
if ( bcTarg.Summoned )
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
}
|
||||
if (pmTarg == null && target is BaseCreature bcTarg)
|
||||
if (bcTarg.Summoned)
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( pmFrom != null && pmTarg != null )
|
||||
{
|
||||
if ( pmFrom.DuelContext != pmTarg.DuelContext && ((pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg.DuelContext != null && pmTarg.DuelContext.Started)) )
|
||||
return false;
|
||||
if (pmFrom != null && pmTarg != null)
|
||||
{
|
||||
if (pmFrom.DuelContext != pmTarg.DuelContext &&
|
||||
(pmFrom.DuelContext != null && pmFrom.DuelContext.Started ||
|
||||
pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
|
||||
return false;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated) )
|
||||
return false;
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
|
||||
(pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started || pmFrom.DuelContext.Tied ||
|
||||
pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated))
|
||||
return false;
|
||||
|
||||
if ( pmFrom.DuelPlayer != null && !pmFrom.DuelPlayer.Eliminated && pmFrom.DuelContext != null && pmFrom.DuelContext.IsSuddenDeath )
|
||||
return false;
|
||||
if (pmFrom.DuelPlayer != null && !pmFrom.DuelPlayer.Eliminated && pmFrom.DuelContext != null &&
|
||||
pmFrom.DuelContext.IsSuddenDeath)
|
||||
return false;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant )
|
||||
return false;
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
|
||||
pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted &&
|
||||
pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null &&
|
||||
pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant)
|
||||
return false;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started )
|
||||
return true;
|
||||
}
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started)
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) )
|
||||
return false;
|
||||
if (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started ||
|
||||
pmTarg?.DuelContext != null && pmTarg.DuelContext.Started)
|
||||
return false;
|
||||
|
||||
if ( from.Region.GetRegion( typeof( SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
if (from.Region.GetRegion(typeof(SafeZone)) is SafeZone sz /*&& sz.IsDisabled()*/)
|
||||
return false;
|
||||
|
||||
sz = target.Region.GetRegion( typeof( SafeZone ) ) as SafeZone;
|
||||
sz = target.Region.GetRegion(typeof(SafeZone)) as SafeZone;
|
||||
|
||||
if ( sz != null /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
#endregion
|
||||
if (sz != null /*&& sz.IsDisabled()*/)
|
||||
return false;
|
||||
|
||||
Map map = from.Map;
|
||||
#endregion
|
||||
|
||||
#region Factions
|
||||
Faction targetFaction = Faction.Find( target, true );
|
||||
Map map = from.Map;
|
||||
|
||||
if ( (!Core.ML || map == Faction.Facet) && targetFaction != null )
|
||||
{
|
||||
if ( Faction.Find( from, true ) != targetFaction )
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
#region Factions
|
||||
|
||||
Faction targetFaction = Faction.Find(target, true);
|
||||
|
||||
if ( map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0 )
|
||||
return true; // In felucca, anything goes
|
||||
if ((!Core.ML || map == Faction.Facet) && targetFaction != null)
|
||||
if (Faction.Find(from, true) != targetFaction)
|
||||
return false;
|
||||
|
||||
if ( !from.Player )
|
||||
return true; // NPCs have no restrictions
|
||||
#endregion
|
||||
|
||||
if ( target is BaseCreature creature && !creature.Controlled )
|
||||
return false; // Players cannot heal uncontrolled mobiles
|
||||
|
||||
if ( pmFrom?.Young == true || pmTarg?.Young == true )
|
||||
return false; // Young players cannot perform beneficial actions towards older players
|
||||
if (map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0)
|
||||
return true; // In felucca, anything goes
|
||||
|
||||
if ( from.Guild is Guild fromGuild && target.Guild is Guild targetGuild && (targetGuild == fromGuild || fromGuild.IsAlly( targetGuild )) )
|
||||
return true; // Guild members can be beneficial
|
||||
if (!from.Player)
|
||||
return true; // NPCs have no restrictions
|
||||
|
||||
return CheckBeneficialStatus( GetGuildStatus( from ), GetGuildStatus( target ) );
|
||||
}
|
||||
if (target is BaseCreature creature && !creature.Controlled)
|
||||
return false; // Players cannot heal uncontrolled mobiles
|
||||
|
||||
public static bool Mobile_AllowHarmful( Mobile from, Mobile target )
|
||||
{
|
||||
if ( from == null || target == null || from.AccessLevel > AccessLevel.Player || target.AccessLevel > AccessLevel.Player )
|
||||
return true;
|
||||
if (pmFrom?.Young == true || pmTarg?.Young == true)
|
||||
return false; // Young players cannot perform beneficial actions towards older players
|
||||
|
||||
#region Dueling
|
||||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
if (from.Guild is Guild fromGuild && target.Guild is Guild targetGuild &&
|
||||
(targetGuild == fromGuild || fromGuild.IsAlly(targetGuild)))
|
||||
return true; // Guild members can be beneficial
|
||||
|
||||
if ( pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned )
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
return CheckBeneficialStatus(GetGuildStatus(from), GetGuildStatus(target));
|
||||
}
|
||||
|
||||
if ( pmTarg == null && bcTarg?.Summoned == true )
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
public static bool Mobile_AllowHarmful(Mobile from, Mobile target)
|
||||
{
|
||||
if (from == null || target == null || from.AccessLevel > AccessLevel.Player ||
|
||||
target.AccessLevel > AccessLevel.Player)
|
||||
return true;
|
||||
|
||||
if ( pmFrom != null && pmTarg != null )
|
||||
{
|
||||
if ( pmFrom.DuelContext != pmTarg.DuelContext && ((pmFrom.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg.DuelContext != null && pmTarg.DuelContext.Started)) )
|
||||
return false;
|
||||
#region Dueling
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated) )
|
||||
return false;
|
||||
PlayerMobile pmFrom = from as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted && pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null && pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant )
|
||||
return false;
|
||||
if (pmFrom == null && from is BaseCreature bcFrom && bcFrom.Summoned)
|
||||
pmFrom = bcFrom.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started )
|
||||
return true;
|
||||
}
|
||||
if (pmTarg == null && bcTarg?.Summoned == true)
|
||||
pmTarg = bcTarg.SummonMaster as PlayerMobile;
|
||||
|
||||
if ( (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started) || (pmTarg?.DuelContext != null && pmTarg.DuelContext.Started) )
|
||||
return false;
|
||||
if (pmFrom != null && pmTarg != null)
|
||||
{
|
||||
if (pmFrom.DuelContext != pmTarg.DuelContext &&
|
||||
(pmFrom.DuelContext != null && pmFrom.DuelContext.Started ||
|
||||
pmTarg.DuelContext != null && pmTarg.DuelContext.Started))
|
||||
return false;
|
||||
|
||||
if ( from.Region.GetRegion( typeof( SafeZone ) ) is SafeZone sz /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
|
||||
(pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started || pmFrom.DuelContext.Tied ||
|
||||
pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated))
|
||||
return false;
|
||||
|
||||
sz = target.Region.GetRegion( typeof( SafeZone ) ) as SafeZone;
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext &&
|
||||
pmFrom.DuelContext.m_Tournament != null && pmFrom.DuelContext.m_Tournament.IsNotoRestricted &&
|
||||
pmFrom.DuelPlayer != null && pmTarg.DuelPlayer != null &&
|
||||
pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant)
|
||||
return false;
|
||||
|
||||
if ( sz != null /*&& sz.IsDisabled()*/ )
|
||||
return false;
|
||||
#endregion
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && pmFrom.DuelContext.Started)
|
||||
return true;
|
||||
}
|
||||
|
||||
Map map = from.Map;
|
||||
if (pmFrom?.DuelContext != null && pmFrom.DuelContext.Started ||
|
||||
pmTarg?.DuelContext != null && pmTarg.DuelContext.Started)
|
||||
return false;
|
||||
|
||||
if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 )
|
||||
return true; // In felucca, anything goes
|
||||
if (from.Region.GetRegion(typeof(SafeZone)) is SafeZone sz /*&& sz.IsDisabled()*/)
|
||||
return false;
|
||||
|
||||
if ( !from.Player && !(from is BaseCreature bc && bc.GetMaster() != null && bc.GetMaster().AccessLevel == AccessLevel.Player ) )
|
||||
{
|
||||
if ( !CheckAggressor( from.Aggressors, target ) && !CheckAggressed( from.Aggressed, target ) && pmTarg?.CheckYoungProtection( from ) == true )
|
||||
return false;
|
||||
sz = target.Region.GetRegion(typeof(SafeZone)) as SafeZone;
|
||||
|
||||
return true; // Uncontrolled NPCs are only restricted by the young system
|
||||
}
|
||||
if (sz != null /*&& sz.IsDisabled()*/)
|
||||
return false;
|
||||
|
||||
Guild fromGuild = GetGuildFor( from.Guild as Guild, from );
|
||||
Guild targetGuild = GetGuildFor( target.Guild as Guild, target );
|
||||
#endregion
|
||||
|
||||
if ( fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly( targetGuild ) || fromGuild.IsEnemy( targetGuild )) )
|
||||
return true; // Guild allies or enemies can be harmful
|
||||
Map map = from.Map;
|
||||
|
||||
if ( bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg?.SummonMaster != from )
|
||||
return false; // Cannot harm other controlled mobiles
|
||||
if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
return true; // In felucca, anything goes
|
||||
|
||||
if ( target.Player )
|
||||
return false; // Cannot harm other players
|
||||
if (!from.Player && !(from is BaseCreature bc && bc.GetMaster() != null &&
|
||||
bc.GetMaster().AccessLevel == AccessLevel.Player))
|
||||
{
|
||||
if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) &&
|
||||
pmTarg?.CheckYoungProtection(from) == true)
|
||||
return false;
|
||||
|
||||
if ( bcTarg?.InitialInnocent != true )
|
||||
{
|
||||
if ( Notoriety.Compute( from, target ) == Notoriety.Innocent )
|
||||
return false; // Cannot harm innocent mobiles
|
||||
}
|
||||
return true; // Uncontrolled NPCs are only restricted by the young system
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Guild fromGuild = GetGuildFor(from.Guild as Guild, from);
|
||||
Guild targetGuild = GetGuildFor(target.Guild as Guild, target);
|
||||
|
||||
public static Guild GetGuildFor( Guild def, Mobile m )
|
||||
{
|
||||
Guild g = def;
|
||||
if (fromGuild != null && targetGuild != null &&
|
||||
(fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild)))
|
||||
return true; // Guild allies or enemies can be harmful
|
||||
|
||||
if ( m is BaseCreature c && c.Controlled && c.ControlMaster != null )
|
||||
{
|
||||
c.DisplayGuildTitle = false;
|
||||
if (bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg?.SummonMaster != from)
|
||||
return false; // Cannot harm other controlled mobiles
|
||||
|
||||
if ( c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder == OrderType.Attack || c.ControlOrder == OrderType.Guard) )
|
||||
g = (Guild)(c.Guild = c.ControlMaster.Guild);
|
||||
else if ( c.Map == Map.Internal || c.ControlMaster.Guild == null )
|
||||
g = (Guild)(c.Guild = null);
|
||||
}
|
||||
if (target.Player)
|
||||
return false; // Cannot harm other players
|
||||
|
||||
return g;
|
||||
}
|
||||
if (bcTarg?.InitialInnocent != true)
|
||||
if (Notoriety.Compute(from, target) == Notoriety.Innocent)
|
||||
return false; // Cannot harm innocent mobiles
|
||||
|
||||
public static int CorpseNotoriety( Mobile source, Corpse target )
|
||||
{
|
||||
if ( target.AccessLevel > AccessLevel.Player )
|
||||
return Notoriety.CanBeAttacked;
|
||||
return true;
|
||||
}
|
||||
|
||||
Body body = target.Amount;
|
||||
public static Guild GetGuildFor(Guild def, Mobile m)
|
||||
{
|
||||
Guild g = def;
|
||||
|
||||
Guild sourceGuild = GetGuildFor( source.Guild as Guild, source );
|
||||
Guild targetGuild = GetGuildFor( target.Guild, target.Owner );
|
||||
if (m is BaseCreature c && c.Controlled && c.ControlMaster != null)
|
||||
{
|
||||
c.DisplayGuildTitle = false;
|
||||
|
||||
Faction srcFaction = Faction.Find( source, true, true );
|
||||
Faction trgFaction = Faction.Find( target.Owner, true, true );
|
||||
List<Mobile> list = target.Aggressors;
|
||||
if (c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder == OrderType.Attack ||
|
||||
c.ControlOrder == OrderType.Guard))
|
||||
g = (Guild)(c.Guild = c.ControlMaster.Guild);
|
||||
else if (c.Map == Map.Internal || c.ControlMaster.Guild == null)
|
||||
g = (Guild)(c.Guild = null);
|
||||
}
|
||||
|
||||
if ( sourceGuild != null && targetGuild != null )
|
||||
{
|
||||
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
|
||||
return Notoriety.Ally;
|
||||
if ( sourceGuild.IsEnemy( targetGuild ) )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
if ( target.Owner is BaseCreature creature )
|
||||
{
|
||||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
return Notoriety.Enemy;
|
||||
public static int CorpseNotoriety(Mobile source, Corpse target)
|
||||
{
|
||||
if (target.AccessLevel > AccessLevel.Player)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( CheckHouseFlag( source, creature, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
Body body = target.Amount;
|
||||
|
||||
int actual = Notoriety.CanBeAttacked;
|
||||
Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
|
||||
Guild targetGuild = GetGuildFor(target.Guild, target.Owner);
|
||||
|
||||
if ( target.Kills >= 5 || body.IsMonster && IsSummoned( creature ) || creature.AlwaysMurderer || creature.IsAnimatedDead )
|
||||
actual = Notoriety.Murderer;
|
||||
Faction srcFaction = Faction.Find(source, true, true);
|
||||
Faction trgFaction = Faction.Find(target.Owner, true, true);
|
||||
List<Mobile> list = target.Aggressors;
|
||||
|
||||
if ( DateTime.UtcNow >= target.TimeOfDeath + Corpse.MonsterLootRightSacrifice )
|
||||
return actual;
|
||||
if (sourceGuild != null && targetGuild != null)
|
||||
{
|
||||
if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
|
||||
return Notoriety.Ally;
|
||||
if (sourceGuild.IsEnemy(targetGuild))
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
Party sourceParty = Party.Get( source );
|
||||
if (target.Owner is BaseCreature creature)
|
||||
{
|
||||
if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
|
||||
return Notoriety.Enemy;
|
||||
|
||||
for( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( list[i] == source || sourceParty != null && Party.Get( list[i] ) == sourceParty )
|
||||
return actual;
|
||||
}
|
||||
if (CheckHouseFlag(source, creature, target.Location, target.Map))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
int actual = Notoriety.CanBeAttacked;
|
||||
|
||||
if ( target.Kills >= 5 || body.IsMonster )
|
||||
return Notoriety.Murderer;
|
||||
if (target.Kills >= 5 || body.IsMonster && IsSummoned(creature) || creature.AlwaysMurderer ||
|
||||
creature.IsAnimatedDead)
|
||||
actual = Notoriety.Murderer;
|
||||
|
||||
if (target.Criminal && target.Map != null && (target.Map.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
return Notoriety.Criminal;
|
||||
if (DateTime.UtcNow >= target.TimeOfDeath + Corpse.MonsterLootRightSacrifice)
|
||||
return actual;
|
||||
|
||||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
{
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( list[i] == source || list[i] is BaseFactionGuard )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
}
|
||||
Party sourceParty = Party.Get(source);
|
||||
|
||||
if ( CheckHouseFlag( source, target.Owner, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
if (list[i] == source || sourceParty != null && Party.Get(list[i]) == sourceParty)
|
||||
return actual;
|
||||
|
||||
if ( !(target.Owner is PlayerMobile) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
if ( list[i] == source )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
if (target.Kills >= 5 || body.IsMonster)
|
||||
return Notoriety.Murderer;
|
||||
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
if (target.Criminal && target.Map != null && (target.Map.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
return Notoriety.Criminal;
|
||||
|
||||
/* Must be thread-safe */
|
||||
public static int MobileNotoriety( Mobile source, Mobile target )
|
||||
{
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
if (list[i] == source || list[i] is BaseFactionGuard)
|
||||
return Notoriety.Enemy;
|
||||
|
||||
if ( Core.AOS && ( target.Blessed || bcTarg?.IsInvulnerable == true || target is PlayerVendor || target is TownCrier ) )
|
||||
return Notoriety.Invulnerable;
|
||||
if (CheckHouseFlag(source, target.Owner, target.Location, target.Map))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
PlayerMobile pmFrom = source as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
if (!(target.Owner is PlayerMobile))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
#region Dueling
|
||||
if ( pmFrom != null && pmTarg != null )
|
||||
{
|
||||
if ( pmFrom.DuelContext != null && pmFrom.DuelContext.StartedBeginCountdown && !pmFrom.DuelContext.Finished && pmFrom.DuelContext == pmTarg.DuelContext )
|
||||
return pmFrom.DuelContext.IsAlly( pmFrom, pmTarg ) ? Notoriety.Ally : Notoriety.Enemy;
|
||||
}
|
||||
#endregion
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
if (list[i] == source)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( target.AccessLevel > AccessLevel.Player )
|
||||
return Notoriety.CanBeAttacked;
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
|
||||
if ( source.Player && !target.Player && pmFrom != null && bcTarg != null )
|
||||
{
|
||||
Mobile master = bcTarg.GetMaster();
|
||||
/* Must be thread-safe */
|
||||
public static int MobileNotoriety(Mobile source, Mobile target)
|
||||
{
|
||||
BaseCreature bcTarg = target as BaseCreature;
|
||||
|
||||
if ( master != null && master.AccessLevel > AccessLevel.Player )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (Core.AOS && (target.Blessed || bcTarg?.IsInvulnerable == true || target is PlayerVendor ||
|
||||
target is TownCrier))
|
||||
return Notoriety.Invulnerable;
|
||||
|
||||
master = bcTarg.ControlMaster;
|
||||
PlayerMobile pmFrom = source as PlayerMobile;
|
||||
PlayerMobile pmTarg = target as PlayerMobile;
|
||||
|
||||
if ( Core.ML && master != null )
|
||||
{
|
||||
if ( ( source == master && CheckAggressor( bcTarg.Aggressors, source ) ) || ( CheckAggressor( source.Aggressors, bcTarg ) ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
#region Dueling
|
||||
|
||||
return MobileNotoriety( source, master );
|
||||
}
|
||||
if (pmFrom != null && pmTarg != null)
|
||||
if (pmFrom.DuelContext != null && pmFrom.DuelContext.StartedBeginCountdown && !pmFrom.DuelContext.Finished &&
|
||||
pmFrom.DuelContext == pmTarg.DuelContext)
|
||||
return pmFrom.DuelContext.IsAlly(pmFrom, pmTarg) ? Notoriety.Ally : Notoriety.Enemy;
|
||||
|
||||
if ( !bcTarg.Summoned && !bcTarg.Controlled && pmFrom.EnemyOfOneType == bcTarg.GetType() )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
#endregion
|
||||
|
||||
if ( target.Kills >= 5 || target.Body.IsMonster && IsSummoned( bcTarg ) && !( target is BaseFamiliar ) && !( target is ArcaneFey ) && !( target is Golem ) || bcTarg?.AlwaysMurderer == true || bcTarg?.IsAnimatedDead == true )
|
||||
return Notoriety.Murderer;
|
||||
if (target.AccessLevel > AccessLevel.Player)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( target.Criminal )
|
||||
return Notoriety.Criminal;
|
||||
if (source.Player && !target.Player && pmFrom != null && bcTarg != null)
|
||||
{
|
||||
Mobile master = bcTarg.GetMaster();
|
||||
|
||||
Guild sourceGuild = GetGuildFor( source.Guild as Guild, source );
|
||||
Guild targetGuild = GetGuildFor( target.Guild as Guild, target );
|
||||
if (master != null && master.AccessLevel > AccessLevel.Player)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( sourceGuild != null && targetGuild != null )
|
||||
{
|
||||
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
|
||||
return Notoriety.Ally;
|
||||
if ( sourceGuild.IsEnemy( targetGuild ) )
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
master = bcTarg.ControlMaster;
|
||||
|
||||
Faction srcFaction = Faction.Find( source, true, true );
|
||||
Faction trgFaction = Faction.Find( target, true, true );
|
||||
if (Core.ML && master != null)
|
||||
{
|
||||
if (source == master && CheckAggressor(bcTarg.Aggressors, source) ||
|
||||
CheckAggressor(source.Aggressors, bcTarg))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
|
||||
return Notoriety.Enemy;
|
||||
return MobileNotoriety(source, master);
|
||||
}
|
||||
|
||||
if ( SkillHandlers.Stealing.ClassicMode && pmTarg?.PermaFlags.Contains( source ) == true )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (!bcTarg.Summoned && !bcTarg.Controlled && pmFrom.EnemyOfOneType == bcTarg.GetType())
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
if ( bcTarg?.AlwaysAttackable == true )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (target.Kills >= 5 ||
|
||||
target.Body.IsMonster && IsSummoned(bcTarg) && !(target is BaseFamiliar) && !(target is ArcaneFey) &&
|
||||
!(target is Golem) || bcTarg?.AlwaysMurderer == true || bcTarg?.IsAnimatedDead == true)
|
||||
return Notoriety.Murderer;
|
||||
|
||||
if ( CheckHouseFlag( source, target, target.Location, target.Map ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (target.Criminal)
|
||||
return Notoriety.Criminal;
|
||||
|
||||
if ( bcTarg?.InitialInnocent != true )
|
||||
{
|
||||
if ( !target.Body.IsHuman && !target.Body.IsGhost && !IsPet( bcTarg ) && pmTarg == null || !Core.ML && !target.CanBeginAction( typeof( Spells.Seventh.PolymorphSpell ) ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
|
||||
Guild targetGuild = GetGuildFor(target.Guild as Guild, target);
|
||||
|
||||
if ( CheckAggressor( source.Aggressors, target ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (sourceGuild != null && targetGuild != null)
|
||||
{
|
||||
if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
|
||||
return Notoriety.Ally;
|
||||
if (sourceGuild.IsEnemy(targetGuild))
|
||||
return Notoriety.Enemy;
|
||||
}
|
||||
|
||||
if ( CheckAggressed( source.Aggressed, target ) )
|
||||
return Notoriety.CanBeAttacked;
|
||||
Faction srcFaction = Faction.Find(source, true, true);
|
||||
Faction trgFaction = Faction.Find(target, true, true);
|
||||
|
||||
if ( bcTarg != null && bcTarg.Controlled && bcTarg.ControlOrder == OrderType.Guard && bcTarg.ControlTarget == source )
|
||||
return Notoriety.CanBeAttacked;
|
||||
if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
|
||||
return Notoriety.Enemy;
|
||||
|
||||
if ( source is BaseCreature bc )
|
||||
{
|
||||
Mobile master = bc.GetMaster();
|
||||
if (Stealing.ClassicMode && pmTarg?.PermaFlags.Contains(source) == true)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( master != null && CheckAggressor( master.Aggressors, target ) || MobileNotoriety( master, target ) == Notoriety.CanBeAttacked || bcTarg != null )
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
if (bcTarg?.AlwaysAttackable == true)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
if (CheckHouseFlag(source, target, target.Location, target.Map))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
public static bool CheckHouseFlag( Mobile from, Mobile m, Point3D p, Map map )
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt( p, map, 16 );
|
||||
if (bcTarg?.InitialInnocent != true)
|
||||
if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(bcTarg) && pmTarg == null ||
|
||||
!Core.ML && !target.CanBeginAction(typeof(PolymorphSpell)))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( house == null || house.Public || !house.IsFriend( from ) )
|
||||
return false;
|
||||
if (CheckAggressor(source.Aggressors, target))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( m != null && house.IsFriend( m ) )
|
||||
return false;
|
||||
if (CheckAggressed(source.Aggressed, target))
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
if ( m is BaseCreature c && !c.Deleted && c.Controlled && c.ControlMaster != null )
|
||||
return !house.IsFriend( c.ControlMaster );
|
||||
if (bcTarg != null && bcTarg.Controlled && bcTarg.ControlOrder == OrderType.Guard &&
|
||||
bcTarg.ControlTarget == source)
|
||||
return Notoriety.CanBeAttacked;
|
||||
|
||||
return true;
|
||||
}
|
||||
if (source is BaseCreature bc)
|
||||
{
|
||||
Mobile master = bc.GetMaster();
|
||||
|
||||
public static bool IsPet( BaseCreature c )
|
||||
{
|
||||
return (c != null && c.Controlled);
|
||||
}
|
||||
if (master != null && CheckAggressor(master.Aggressors, target) ||
|
||||
MobileNotoriety(master, target) == Notoriety.CanBeAttacked || bcTarg != null)
|
||||
return Notoriety.CanBeAttacked;
|
||||
}
|
||||
|
||||
public static bool IsSummoned( BaseCreature c )
|
||||
{
|
||||
return (c != null && /*c.Controlled &&*/ c.Summoned);
|
||||
}
|
||||
return Notoriety.Innocent;
|
||||
}
|
||||
|
||||
public static bool CheckAggressor( List<AggressorInfo> list, Mobile target )
|
||||
{
|
||||
for( int i = 0; i < list.Count; ++i )
|
||||
if ( list[i].Attacker == target )
|
||||
return true;
|
||||
public static bool CheckHouseFlag(Mobile from, Mobile m, Point3D p, Map map)
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(p, map, 16);
|
||||
|
||||
return false;
|
||||
}
|
||||
if (house == null || house.Public || !house.IsFriend(from))
|
||||
return false;
|
||||
|
||||
public static bool CheckAggressed( List<AggressorInfo> list, Mobile target )
|
||||
{
|
||||
for( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
AggressorInfo info = list[i];
|
||||
if (m != null && house.IsFriend(m))
|
||||
return false;
|
||||
|
||||
if ( !info.CriminalAggression && info.Defender == target )
|
||||
return true;
|
||||
}
|
||||
if (m is BaseCreature c && !c.Deleted && c.Controlled && c.ControlMaster != null)
|
||||
return !house.IsFriend(c.ControlMaster);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsPet(BaseCreature c)
|
||||
{
|
||||
return c != null && c.Controlled;
|
||||
}
|
||||
|
||||
public static bool IsSummoned(BaseCreature c)
|
||||
{
|
||||
return c != null && /*c.Controlled &&*/ c.Summoned;
|
||||
}
|
||||
|
||||
public static bool CheckAggressor(List<AggressorInfo> list, Mobile target)
|
||||
{
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
if (list[i].Attacker == target)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CheckAggressed(List<AggressorInfo> list, Mobile target)
|
||||
{
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
AggressorInfo info = list[i];
|
||||
|
||||
if (!info.CriminalAggression && info.Defender == target)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private enum GuildStatus
|
||||
{
|
||||
None,
|
||||
Peaceful,
|
||||
Waring
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,30 +3,31 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class Paperdoll
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.PaperdollRequest += EventSink_PaperdollRequest;
|
||||
}
|
||||
public class Paperdoll
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.PaperdollRequest += EventSink_PaperdollRequest;
|
||||
}
|
||||
|
||||
public static void EventSink_PaperdollRequest( PaperdollRequestEventArgs e )
|
||||
{
|
||||
Mobile beholder = e.Beholder;
|
||||
Mobile beheld = e.Beheld;
|
||||
public static void EventSink_PaperdollRequest(PaperdollRequestEventArgs e)
|
||||
{
|
||||
Mobile beholder = e.Beholder;
|
||||
Mobile beheld = e.Beheld;
|
||||
|
||||
beholder.Send( new DisplayPaperdoll( beheld, Titles.ComputeTitle( beholder, beheld ), beheld.AllowEquipFrom( beholder ) ) );
|
||||
beholder.Send(new DisplayPaperdoll(beheld, Titles.ComputeTitle(beholder, beheld),
|
||||
beheld.AllowEquipFrom(beholder)));
|
||||
|
||||
if ( ObjectPropertyList.Enabled )
|
||||
{
|
||||
List<Item> items = beheld.Items;
|
||||
if (ObjectPropertyList.Enabled)
|
||||
{
|
||||
List<Item> items = beheld.Items;
|
||||
|
||||
for ( int i = 0; i < items.Count; ++i )
|
||||
beholder.Send( items[i].OPLPacket );
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
beholder.Send(items[i].OPLPacket);
|
||||
|
||||
// NOTE: OSI sends MobileUpdate when opening your own paperdoll.
|
||||
// It has a very bad rubber-banding affect. What positive affects does it have?
|
||||
}
|
||||
}
|
||||
}
|
||||
// NOTE: OSI sends MobileUpdate when opening your own paperdoll.
|
||||
// It has a very bad rubber-banding affect. What positive affects does it have?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,151 +1,153 @@
|
|||
using System;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Spells;
|
||||
using Server.Spells.Necromancy;
|
||||
using Server.Spells.Ninjitsu;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public class PoisonImpl : Poison
|
||||
{
|
||||
[CallPriority( 10 )]
|
||||
public static void Configure()
|
||||
{
|
||||
if ( Core.AOS )
|
||||
{
|
||||
Register( new PoisonImpl( "Lesser", 0, 4, 16, 7.5, 3.0, 2.25, 10, 4 ) );
|
||||
Register( new PoisonImpl( "Regular", 1, 8, 18, 10.0, 3.0, 3.25, 10, 3 ) );
|
||||
Register( new PoisonImpl( "Greater", 2, 12, 20, 15.0, 3.0, 4.25, 10, 2 ) );
|
||||
Register( new PoisonImpl( "Deadly", 3, 16, 30, 30.0, 3.0, 5.25, 15, 2 ) );
|
||||
Register( new PoisonImpl( "Lethal", 4, 20, 50, 35.0, 3.0, 5.25, 20, 2 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Register( new PoisonImpl( "Lesser", 0, 4, 26, 2.500, 3.5, 3.0, 10, 2 ) );
|
||||
Register( new PoisonImpl( "Regular", 1, 5, 26, 3.125, 3.5, 3.0, 10, 2 ) );
|
||||
Register( new PoisonImpl( "Greater", 2, 6, 26, 6.250, 3.5, 3.0, 10, 2 ) );
|
||||
Register( new PoisonImpl( "Deadly", 3, 7, 26, 12.500, 3.5, 4.0, 10, 2 ) );
|
||||
Register( new PoisonImpl( "Lethal", 4, 9, 26, 25.000, 3.5, 5.0, 10, 2 ) );
|
||||
}
|
||||
}
|
||||
public class PoisonImpl : Poison
|
||||
{
|
||||
private int m_Count, m_MessageInterval;
|
||||
|
||||
public static Poison IncreaseLevel( Poison oldPoison )
|
||||
{
|
||||
Poison newPoison = ( oldPoison == null ? null : GetPoison( oldPoison.Level + 1 ) );
|
||||
// Timers
|
||||
private TimeSpan m_Delay;
|
||||
private TimeSpan m_Interval;
|
||||
|
||||
return newPoison ?? oldPoison;
|
||||
}
|
||||
// Info
|
||||
|
||||
// Info
|
||||
// Damage
|
||||
private int m_Minimum, m_Maximum;
|
||||
private double m_Scalar;
|
||||
|
||||
// Damage
|
||||
private int m_Minimum, m_Maximum;
|
||||
private double m_Scalar;
|
||||
public PoisonImpl(string name, int level, int min, int max, double percent, double delay, double interval, int count,
|
||||
int messageInterval)
|
||||
{
|
||||
Name = name;
|
||||
Level = level;
|
||||
m_Minimum = min;
|
||||
m_Maximum = max;
|
||||
m_Scalar = percent * 0.01;
|
||||
m_Delay = TimeSpan.FromSeconds(delay);
|
||||
m_Interval = TimeSpan.FromSeconds(interval);
|
||||
m_Count = count;
|
||||
m_MessageInterval = messageInterval;
|
||||
}
|
||||
|
||||
// Timers
|
||||
private TimeSpan m_Delay;
|
||||
private TimeSpan m_Interval;
|
||||
private int m_Count, m_MessageInterval;
|
||||
public override string Name{ get; }
|
||||
|
||||
public PoisonImpl( string name, int level, int min, int max, double percent, double delay, double interval, int count, int messageInterval )
|
||||
{
|
||||
Name = name;
|
||||
Level = level;
|
||||
m_Minimum = min;
|
||||
m_Maximum = max;
|
||||
m_Scalar = percent * 0.01;
|
||||
m_Delay = TimeSpan.FromSeconds( delay );
|
||||
m_Interval = TimeSpan.FromSeconds( interval );
|
||||
m_Count = count;
|
||||
m_MessageInterval = messageInterval;
|
||||
}
|
||||
public override int Level{ get; }
|
||||
|
||||
public override string Name { get; }
|
||||
[CallPriority(10)]
|
||||
public static void Configure()
|
||||
{
|
||||
if (Core.AOS)
|
||||
{
|
||||
Register(new PoisonImpl("Lesser", 0, 4, 16, 7.5, 3.0, 2.25, 10, 4));
|
||||
Register(new PoisonImpl("Regular", 1, 8, 18, 10.0, 3.0, 3.25, 10, 3));
|
||||
Register(new PoisonImpl("Greater", 2, 12, 20, 15.0, 3.0, 4.25, 10, 2));
|
||||
Register(new PoisonImpl("Deadly", 3, 16, 30, 30.0, 3.0, 5.25, 15, 2));
|
||||
Register(new PoisonImpl("Lethal", 4, 20, 50, 35.0, 3.0, 5.25, 20, 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
Register(new PoisonImpl("Lesser", 0, 4, 26, 2.500, 3.5, 3.0, 10, 2));
|
||||
Register(new PoisonImpl("Regular", 1, 5, 26, 3.125, 3.5, 3.0, 10, 2));
|
||||
Register(new PoisonImpl("Greater", 2, 6, 26, 6.250, 3.5, 3.0, 10, 2));
|
||||
Register(new PoisonImpl("Deadly", 3, 7, 26, 12.500, 3.5, 4.0, 10, 2));
|
||||
Register(new PoisonImpl("Lethal", 4, 9, 26, 25.000, 3.5, 5.0, 10, 2));
|
||||
}
|
||||
}
|
||||
|
||||
public override int Level { get; }
|
||||
public static Poison IncreaseLevel(Poison oldPoison)
|
||||
{
|
||||
Poison newPoison = oldPoison == null ? null : GetPoison(oldPoison.Level + 1);
|
||||
|
||||
public class PoisonTimer : Timer
|
||||
{
|
||||
private PoisonImpl m_Poison;
|
||||
private Mobile m_Mobile;
|
||||
private int m_LastDamage;
|
||||
private int m_Index;
|
||||
return newPoison ?? oldPoison;
|
||||
}
|
||||
|
||||
public Mobile From { get; set; }
|
||||
public override Timer ConstructTimer(Mobile m)
|
||||
{
|
||||
return new PoisonTimer(m, this);
|
||||
}
|
||||
|
||||
public PoisonTimer( Mobile m, PoisonImpl p ) : base( p.m_Delay, p.m_Interval )
|
||||
{
|
||||
From = m;
|
||||
m_Mobile = m;
|
||||
m_Poison = p;
|
||||
}
|
||||
public class PoisonTimer : Timer
|
||||
{
|
||||
private int m_Index;
|
||||
private int m_LastDamage;
|
||||
private Mobile m_Mobile;
|
||||
private PoisonImpl m_Poison;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if ( (Core.AOS && m_Poison.Level < 4 && TransformationSpellHelper.UnderTransformation( m_Mobile, typeof( VampiricEmbraceSpell ) )) ||
|
||||
(m_Poison.Level < 3 && OrangePetals.UnderEffect( m_Mobile )) ||
|
||||
AnimalForm.UnderTransformation( m_Mobile, typeof( Unicorn ) ) )
|
||||
{
|
||||
if ( m_Mobile.CurePoison( m_Mobile ) )
|
||||
{
|
||||
m_Mobile.LocalOverheadMessage( MessageType.Emote, 0x3F, true,
|
||||
"* You feel yourself resisting the effects of the poison *" );
|
||||
public PoisonTimer(Mobile m, PoisonImpl p) : base(p.m_Delay, p.m_Interval)
|
||||
{
|
||||
From = m;
|
||||
m_Mobile = m;
|
||||
m_Poison = p;
|
||||
}
|
||||
|
||||
m_Mobile.NonlocalOverheadMessage( MessageType.Emote, 0x3F, true,
|
||||
$"* {m_Mobile.Name} seems resistant to the poison *");
|
||||
public Mobile From{ get; set; }
|
||||
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (Core.AOS && m_Poison.Level < 4 &&
|
||||
TransformationSpellHelper.UnderTransformation(m_Mobile, typeof(VampiricEmbraceSpell)) ||
|
||||
m_Poison.Level < 3 && OrangePetals.UnderEffect(m_Mobile) ||
|
||||
AnimalForm.UnderTransformation(m_Mobile, typeof(Unicorn)))
|
||||
if (m_Mobile.CurePoison(m_Mobile))
|
||||
{
|
||||
m_Mobile.LocalOverheadMessage(MessageType.Emote, 0x3F, true,
|
||||
"* You feel yourself resisting the effects of the poison *");
|
||||
|
||||
if ( m_Index++ == m_Poison.m_Count )
|
||||
{
|
||||
m_Mobile.SendLocalizedMessage( 502136 ); // The poison seems to have worn off.
|
||||
m_Mobile.Poison = null;
|
||||
m_Mobile.NonlocalOverheadMessage(MessageType.Emote, 0x3F, true,
|
||||
$"* {m_Mobile.Name} seems resistant to the poison *");
|
||||
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
int damage;
|
||||
if (m_Index++ == m_Poison.m_Count)
|
||||
{
|
||||
m_Mobile.SendLocalizedMessage(502136); // The poison seems to have worn off.
|
||||
m_Mobile.Poison = null;
|
||||
|
||||
if ( !Core.AOS && m_LastDamage != 0 && Utility.RandomBool() )
|
||||
{
|
||||
damage = m_LastDamage;
|
||||
}
|
||||
else
|
||||
{
|
||||
damage = 1 + (int)(m_Mobile.Hits * m_Poison.m_Scalar);
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( damage < m_Poison.m_Minimum )
|
||||
damage = m_Poison.m_Minimum;
|
||||
else if ( damage > m_Poison.m_Maximum )
|
||||
damage = m_Poison.m_Maximum;
|
||||
int damage;
|
||||
|
||||
m_LastDamage = damage;
|
||||
}
|
||||
if (!Core.AOS && m_LastDamage != 0 && Utility.RandomBool())
|
||||
{
|
||||
damage = m_LastDamage;
|
||||
}
|
||||
else
|
||||
{
|
||||
damage = 1 + (int)(m_Mobile.Hits * m_Poison.m_Scalar);
|
||||
|
||||
From?.DoHarmful( m_Mobile, true );
|
||||
if (damage < m_Poison.m_Minimum)
|
||||
damage = m_Poison.m_Minimum;
|
||||
else if (damage > m_Poison.m_Maximum)
|
||||
damage = m_Poison.m_Maximum;
|
||||
|
||||
if ( m_Mobile is IHonorTarget honorTarget )
|
||||
honorTarget.ReceivedHonorContext?.OnTargetPoisoned();
|
||||
m_LastDamage = damage;
|
||||
}
|
||||
|
||||
AOS.Damage( m_Mobile, From, damage, 0, 0, 0, 100, 0 );
|
||||
From?.DoHarmful(m_Mobile, true);
|
||||
|
||||
if ( 0.60 <= Utility.RandomDouble() ) // OSI: randomly revealed between first and third damage tick, guessing 60% chance
|
||||
m_Mobile.RevealingAction();
|
||||
if (m_Mobile is IHonorTarget honorTarget)
|
||||
honorTarget.ReceivedHonorContext?.OnTargetPoisoned();
|
||||
|
||||
if ( (m_Index % m_Poison.m_MessageInterval) == 0 )
|
||||
m_Mobile.OnPoisoned( From, m_Poison, m_Poison );
|
||||
}
|
||||
}
|
||||
AOS.Damage(m_Mobile, From, damage, 0, 0, 0, 100, 0);
|
||||
|
||||
public override Timer ConstructTimer( Mobile m )
|
||||
{
|
||||
return new PoisonTimer( m, this );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0.60 <= Utility.RandomDouble()
|
||||
) // OSI: randomly revealed between first and third damage tick, guessing 60% chance
|
||||
m_Mobile.RevealingAction();
|
||||
|
||||
if (m_Index % m_Poison.m_MessageInterval == 0)
|
||||
m_Mobile.OnPoisoned(From, m_Poison, m_Poison);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,116 +2,124 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public enum ProfanityAction
|
||||
{
|
||||
None, // no action taken
|
||||
Disallow, // speech is not displayed
|
||||
Criminal, // makes the player criminal, not killable by guards
|
||||
CriminalAction, // makes the player criminal, can be killed by guards
|
||||
Disconnect, // player is kicked
|
||||
Other // some other implementation
|
||||
}
|
||||
public enum ProfanityAction
|
||||
{
|
||||
None, // no action taken
|
||||
Disallow, // speech is not displayed
|
||||
Criminal, // makes the player criminal, not killable by guards
|
||||
CriminalAction, // makes the player criminal, can be killed by guards
|
||||
Disconnect, // player is kicked
|
||||
Other // some other implementation
|
||||
}
|
||||
|
||||
public class ProfanityProtection
|
||||
{
|
||||
private static bool Enabled = false;
|
||||
private static ProfanityAction Action = ProfanityAction.Disallow; // change here what to do when profanity is detected
|
||||
public class ProfanityProtection
|
||||
{
|
||||
private static bool Enabled = false;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if ( Enabled )
|
||||
EventSink.Speech += EventSink_Speech;
|
||||
}
|
||||
private static ProfanityAction
|
||||
Action = ProfanityAction.Disallow; // change here what to do when profanity is detected
|
||||
|
||||
private static bool OnProfanityDetected( Mobile from, string speech )
|
||||
{
|
||||
switch ( Action )
|
||||
{
|
||||
case ProfanityAction.None: return true;
|
||||
case ProfanityAction.Disallow: return false;
|
||||
case ProfanityAction.Criminal: from.Criminal = true; return true;
|
||||
case ProfanityAction.CriminalAction: from.CriminalAction( false ); return true;
|
||||
case ProfanityAction.Disconnect:
|
||||
{
|
||||
NetState ns = from.NetState;
|
||||
public static char[] Exceptions{ get; } =
|
||||
{
|
||||
' ', '-', '.', '\'', '"', ',', '_', '+', '=', '~', '`', '!', '^', '*', '\\', '/', ';', ':', '<', '>', '[', ']',
|
||||
'{', '}', '?', '|', '(', ')', '%', '$', '&', '#', '@'
|
||||
};
|
||||
|
||||
ns?.Dispose();
|
||||
public static string[] StartDisallowed{ get; } = { };
|
||||
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
case ProfanityAction.Other: // TODO: Provide custom implementation if this is chosen
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static string[] Disallowed{ get; } =
|
||||
{
|
||||
"jigaboo",
|
||||
"chigaboo",
|
||||
"wop",
|
||||
"kyke",
|
||||
"kike",
|
||||
"tit",
|
||||
"spic",
|
||||
"prick",
|
||||
"piss",
|
||||
"lezbo",
|
||||
"lesbo",
|
||||
"felatio",
|
||||
"dyke",
|
||||
"dildo",
|
||||
"chinc",
|
||||
"chink",
|
||||
"cunnilingus",
|
||||
"cum",
|
||||
"cocksucker",
|
||||
"cock",
|
||||
"clitoris",
|
||||
"clit",
|
||||
"ass",
|
||||
"hitler",
|
||||
"penis",
|
||||
"nigga",
|
||||
"nigger",
|
||||
"klit",
|
||||
"kunt",
|
||||
"jiz",
|
||||
"jism",
|
||||
"jerkoff",
|
||||
"jackoff",
|
||||
"goddamn",
|
||||
"fag",
|
||||
"blowjob",
|
||||
"bitch",
|
||||
"asshole",
|
||||
"dick",
|
||||
"pussy",
|
||||
"snatch",
|
||||
"cunt",
|
||||
"twat",
|
||||
"shit",
|
||||
"fuck"
|
||||
};
|
||||
|
||||
private static void EventSink_Speech( SpeechEventArgs e )
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Enabled)
|
||||
EventSink.Speech += EventSink_Speech;
|
||||
}
|
||||
|
||||
if ( from.AccessLevel > AccessLevel.Player )
|
||||
return;
|
||||
private static bool OnProfanityDetected(Mobile from, string speech)
|
||||
{
|
||||
switch (Action)
|
||||
{
|
||||
case ProfanityAction.None: return true;
|
||||
case ProfanityAction.Disallow: return false;
|
||||
case ProfanityAction.Criminal:
|
||||
from.Criminal = true;
|
||||
return true;
|
||||
case ProfanityAction.CriminalAction:
|
||||
from.CriminalAction(false);
|
||||
return true;
|
||||
case ProfanityAction.Disconnect:
|
||||
{
|
||||
NetState ns = from.NetState;
|
||||
|
||||
if ( !NameVerification.Validate( e.Speech, 0, int.MaxValue, true, true, false, int.MaxValue, Exceptions, Disallowed, StartDisallowed ) )
|
||||
e.Blocked = !OnProfanityDetected( from, e.Speech );
|
||||
}
|
||||
ns?.Dispose();
|
||||
|
||||
public static char[] Exceptions { get; } =
|
||||
{
|
||||
' ', '-', '.', '\'', '"', ',', '_', '+', '=', '~', '`', '!', '^', '*', '\\', '/', ';', ':', '<', '>', '[', ']', '{', '}', '?', '|', '(', ')', '%', '$', '&', '#', '@'
|
||||
};
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
case ProfanityAction.Other: // TODO: Provide custom implementation if this is chosen
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string[] StartDisallowed { get; } = {};
|
||||
private static void EventSink_Speech(SpeechEventArgs e)
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
|
||||
public static string[] Disallowed { get; } =
|
||||
{
|
||||
"jigaboo",
|
||||
"chigaboo",
|
||||
"wop",
|
||||
"kyke",
|
||||
"kike",
|
||||
"tit",
|
||||
"spic",
|
||||
"prick",
|
||||
"piss",
|
||||
"lezbo",
|
||||
"lesbo",
|
||||
"felatio",
|
||||
"dyke",
|
||||
"dildo",
|
||||
"chinc",
|
||||
"chink",
|
||||
"cunnilingus",
|
||||
"cum",
|
||||
"cocksucker",
|
||||
"cock",
|
||||
"clitoris",
|
||||
"clit",
|
||||
"ass",
|
||||
"hitler",
|
||||
"penis",
|
||||
"nigga",
|
||||
"nigger",
|
||||
"klit",
|
||||
"kunt",
|
||||
"jiz",
|
||||
"jism",
|
||||
"jerkoff",
|
||||
"jackoff",
|
||||
"goddamn",
|
||||
"fag",
|
||||
"blowjob",
|
||||
"bitch",
|
||||
"asshole",
|
||||
"dick",
|
||||
"pussy",
|
||||
"snatch",
|
||||
"cunt",
|
||||
"twat",
|
||||
"shit",
|
||||
"fuck"
|
||||
};
|
||||
}
|
||||
if (from.AccessLevel > AccessLevel.Player)
|
||||
return;
|
||||
|
||||
if (!NameVerification.Validate(e.Speech, 0, int.MaxValue, true, true, false, int.MaxValue, Exceptions,
|
||||
Disallowed, StartDisallowed))
|
||||
e.Blocked = !OnProfanityDetected(from, e.Speech);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,95 +1,95 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
using Server.Accounting;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class Profile
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.ProfileRequest += EventSink_ProfileRequest;
|
||||
EventSink.ChangeProfileRequest += EventSink_ChangeProfileRequest;
|
||||
}
|
||||
public class Profile
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.ProfileRequest += EventSink_ProfileRequest;
|
||||
EventSink.ChangeProfileRequest += EventSink_ChangeProfileRequest;
|
||||
}
|
||||
|
||||
public static void EventSink_ChangeProfileRequest( ChangeProfileRequestEventArgs e )
|
||||
{
|
||||
Mobile from = e.Beholder;
|
||||
public static void EventSink_ChangeProfileRequest(ChangeProfileRequestEventArgs e)
|
||||
{
|
||||
Mobile from = e.Beholder;
|
||||
|
||||
if ( from.ProfileLocked )
|
||||
from.SendMessage( "Your profile is locked. You may not change it." );
|
||||
else
|
||||
from.Profile = e.Text;
|
||||
}
|
||||
if (from.ProfileLocked)
|
||||
from.SendMessage("Your profile is locked. You may not change it.");
|
||||
else
|
||||
from.Profile = e.Text;
|
||||
}
|
||||
|
||||
public static void EventSink_ProfileRequest( ProfileRequestEventArgs e )
|
||||
{
|
||||
Mobile beholder = e.Beholder;
|
||||
Mobile beheld = e.Beheld;
|
||||
public static void EventSink_ProfileRequest(ProfileRequestEventArgs e)
|
||||
{
|
||||
Mobile beholder = e.Beholder;
|
||||
Mobile beheld = e.Beheld;
|
||||
|
||||
if ( !beheld.Player )
|
||||
return;
|
||||
if (!beheld.Player)
|
||||
return;
|
||||
|
||||
if ( beholder.Map != beheld.Map || !beholder.InRange( beheld, 12 ) || !beholder.CanSee( beheld ) )
|
||||
return;
|
||||
if (beholder.Map != beheld.Map || !beholder.InRange(beheld, 12) || !beholder.CanSee(beheld))
|
||||
return;
|
||||
|
||||
string header = Titles.ComputeTitle( beholder, beheld );
|
||||
string header = Titles.ComputeTitle(beholder, beheld);
|
||||
|
||||
string footer = "";
|
||||
string footer = "";
|
||||
|
||||
if ( beheld.ProfileLocked )
|
||||
{
|
||||
if ( beholder == beheld )
|
||||
footer = "Your profile has been locked.";
|
||||
else if ( beholder.AccessLevel >= AccessLevel.Counselor )
|
||||
footer = "This profile has been locked.";
|
||||
}
|
||||
if (beheld.ProfileLocked)
|
||||
{
|
||||
if (beholder == beheld)
|
||||
footer = "Your profile has been locked.";
|
||||
else if (beholder.AccessLevel >= AccessLevel.Counselor)
|
||||
footer = "This profile has been locked.";
|
||||
}
|
||||
|
||||
if ( footer.Length == 0 && beholder == beheld )
|
||||
footer = GetAccountDuration( beheld );
|
||||
if (footer.Length == 0 && beholder == beheld)
|
||||
footer = GetAccountDuration(beheld);
|
||||
|
||||
string body = beheld.Profile;
|
||||
string body = beheld.Profile;
|
||||
|
||||
if ( body == null || body.Length <= 0 )
|
||||
body = "";
|
||||
if (body == null || body.Length <= 0)
|
||||
body = "";
|
||||
|
||||
beholder.Send( new DisplayProfile( beholder != beheld || !beheld.ProfileLocked, beheld, header, body, footer ) );
|
||||
}
|
||||
beholder.Send(new DisplayProfile(beholder != beheld || !beheld.ProfileLocked, beheld, header, body, footer));
|
||||
}
|
||||
|
||||
private static string GetAccountDuration( Mobile m )
|
||||
{
|
||||
if ( !(m.Account is Account a) )
|
||||
return "";
|
||||
private static string GetAccountDuration(Mobile m)
|
||||
{
|
||||
if (!(m.Account is Account a))
|
||||
return "";
|
||||
|
||||
TimeSpan ts = DateTime.UtcNow - a.Created;
|
||||
TimeSpan ts = DateTime.UtcNow - a.Created;
|
||||
|
||||
string v;
|
||||
string v;
|
||||
|
||||
if ( Format( ts.TotalDays, "This account is {0} day{1} old.", out v ) )
|
||||
return v;
|
||||
if (Format(ts.TotalDays, "This account is {0} day{1} old.", out v))
|
||||
return v;
|
||||
|
||||
if ( Format( ts.TotalHours, "This account is {0} hour{1} old.", out v ) )
|
||||
return v;
|
||||
if (Format(ts.TotalHours, "This account is {0} hour{1} old.", out v))
|
||||
return v;
|
||||
|
||||
if ( Format( ts.TotalMinutes, "This account is {0} minute{1} old.", out v ) )
|
||||
return v;
|
||||
if (Format(ts.TotalMinutes, "This account is {0} minute{1} old.", out v))
|
||||
return v;
|
||||
|
||||
if ( Format( ts.TotalSeconds, "This account is {0} second{1} old.", out v ) )
|
||||
return v;
|
||||
if (Format(ts.TotalSeconds, "This account is {0} second{1} old.", out v))
|
||||
return v;
|
||||
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static bool Format( double value, string format, out string op )
|
||||
{
|
||||
if ( value >= 1.0 )
|
||||
{
|
||||
op = string.Format( format, (int)value, (int)value != 1 ? "s" : "" );
|
||||
return true;
|
||||
}
|
||||
public static bool Format(double value, string format, out string op)
|
||||
{
|
||||
if (value >= 1.0)
|
||||
{
|
||||
op = string.Format(format, (int)value, (int)value != 1 ? "s" : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
op = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
op = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,60 +3,62 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class ProtocolExtensions
|
||||
{
|
||||
private static PacketHandler[] m_Handlers = new PacketHandler[0x100];
|
||||
public class ProtocolExtensions
|
||||
{
|
||||
private static PacketHandler[] m_Handlers = new PacketHandler[0x100];
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register( 0xF0, 0, false, DecodeBundledPacket );
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register(0xF0, 0, false, DecodeBundledPacket);
|
||||
}
|
||||
|
||||
public static void Register( int packetID, bool ingame, OnPacketReceive onReceive )
|
||||
{
|
||||
m_Handlers[packetID] = new PacketHandler( packetID, 0, ingame, onReceive );
|
||||
}
|
||||
public static void Register(int packetID, bool ingame, OnPacketReceive onReceive)
|
||||
{
|
||||
m_Handlers[packetID] = new PacketHandler(packetID, 0, ingame, onReceive);
|
||||
}
|
||||
|
||||
public static PacketHandler GetHandler( int packetID )
|
||||
{
|
||||
if ( packetID >= 0 && packetID < m_Handlers.Length )
|
||||
return m_Handlers[packetID];
|
||||
public static PacketHandler GetHandler(int packetID)
|
||||
{
|
||||
if (packetID >= 0 && packetID < m_Handlers.Length)
|
||||
return m_Handlers[packetID];
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void DecodeBundledPacket( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
int packetID = pvSrc.ReadByte();
|
||||
public static void DecodeBundledPacket(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
int packetID = pvSrc.ReadByte();
|
||||
|
||||
PacketHandler ph = GetHandler( packetID );
|
||||
PacketHandler ph = GetHandler(packetID);
|
||||
|
||||
if ( ph != null )
|
||||
{
|
||||
if ( ph.Ingame && state.Mobile == null )
|
||||
{
|
||||
Console.WriteLine( "Client: {0}: Sent ingame packet (0xF0x{1:X2}) before having been attached to a mobile", state, packetID );
|
||||
state.Dispose();
|
||||
}
|
||||
else if ( ph.Ingame && state.Mobile.Deleted )
|
||||
{
|
||||
state.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
ph.OnReceive( state, pvSrc );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ph != null)
|
||||
{
|
||||
if (ph.Ingame && state.Mobile == null)
|
||||
{
|
||||
Console.WriteLine(
|
||||
"Client: {0}: Sent ingame packet (0xF0x{1:X2}) before having been attached to a mobile", state,
|
||||
packetID);
|
||||
state.Dispose();
|
||||
}
|
||||
else if (ph.Ingame && state.Mobile.Deleted)
|
||||
{
|
||||
state.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
ph.OnReceive(state, pvSrc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ProtocolExtension : Packet
|
||||
{
|
||||
public ProtocolExtension( int packetID, int capacity ) : base( 0xF0 )
|
||||
{
|
||||
EnsureCapacity( 4 + capacity );
|
||||
public abstract class ProtocolExtension : Packet
|
||||
{
|
||||
public ProtocolExtension(int packetID, int capacity) : base(0xF0)
|
||||
{
|
||||
EnsureCapacity(4 + capacity);
|
||||
|
||||
m_Stream.Write( (byte) packetID );
|
||||
}
|
||||
}
|
||||
m_Stream.Write((byte)packetID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,321 +1,326 @@
|
|||
namespace Server.Misc
|
||||
{
|
||||
public class RaceDefinitions
|
||||
{
|
||||
public static void Configure()
|
||||
{
|
||||
/* Here we configure all races. Some notes:
|
||||
*
|
||||
* 1) The first 32 races are reserved for core use.
|
||||
* 2) Race 0x7F is reserved for core use.
|
||||
* 3) Race 0xFF is reserved for core use.
|
||||
* 4) Changing or removing any predefined races may cause server instability.
|
||||
*/
|
||||
public class RaceDefinitions
|
||||
{
|
||||
public static void Configure()
|
||||
{
|
||||
/* Here we configure all races. Some notes:
|
||||
*
|
||||
* 1) The first 32 races are reserved for core use.
|
||||
* 2) Race 0x7F is reserved for core use.
|
||||
* 3) Race 0xFF is reserved for core use.
|
||||
* 4) Changing or removing any predefined races may cause server instability.
|
||||
*/
|
||||
|
||||
RegisterRace( new Human( 0, 0 ) );
|
||||
RegisterRace( new Elf( 1, 1 ) );
|
||||
RegisterRace( new Gargoyle( 2, 2 ) );
|
||||
}
|
||||
RegisterRace(new Human(0, 0));
|
||||
RegisterRace(new Elf(1, 1));
|
||||
RegisterRace(new Gargoyle(2, 2));
|
||||
}
|
||||
|
||||
public static void RegisterRace( Race race )
|
||||
{
|
||||
Race.Races[race.RaceIndex] = race;
|
||||
Race.AllRaces.Add( race );
|
||||
}
|
||||
public static void RegisterRace(Race race)
|
||||
{
|
||||
Race.Races[race.RaceIndex] = race;
|
||||
Race.AllRaces.Add(race);
|
||||
}
|
||||
|
||||
private class Human : Race
|
||||
{
|
||||
public Human( int raceID, int raceIndex )
|
||||
: base( raceID, raceIndex, "Human", "Humans", 400, 401, 402, 403, Expansion.None )
|
||||
{
|
||||
}
|
||||
private class Human : Race
|
||||
{
|
||||
public Human(int raceID, int raceIndex)
|
||||
: base(raceID, raceIndex, "Human", "Humans", 400, 401, 402, 403, Expansion.None)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool ValidateHair( bool female, int itemID )
|
||||
{
|
||||
if ( itemID == 0 )
|
||||
return true;
|
||||
public override bool ValidateHair(bool female, int itemID)
|
||||
{
|
||||
if (itemID == 0)
|
||||
return true;
|
||||
|
||||
if ( (female && itemID == 0x2048) || (!female && itemID == 0x2046 ) )
|
||||
return false; //Buns & Receeding Hair
|
||||
if (female && itemID == 0x2048 || !female && itemID == 0x2046)
|
||||
return false; //Buns & Receeding Hair
|
||||
|
||||
if ( itemID >= 0x203B && itemID <= 0x203D )
|
||||
return true;
|
||||
if (itemID >= 0x203B && itemID <= 0x203D)
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x2044 && itemID <= 0x204A )
|
||||
return true;
|
||||
if (itemID >= 0x2044 && itemID <= 0x204A)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int RandomHair( bool female ) //Random hair doesn't include baldness
|
||||
{
|
||||
switch( Utility.Random( 9 ) )
|
||||
{
|
||||
case 0: return 0x203B; //Short
|
||||
case 1: return 0x203C; //Long
|
||||
case 2: return 0x203D; //Pony Tail
|
||||
case 3: return 0x2044; //Mohawk
|
||||
case 4: return 0x2045; //Pageboy
|
||||
case 5: return 0x2047; //Afro
|
||||
case 6: return 0x2049; //Pig tails
|
||||
case 7: return 0x204A; //Krisna
|
||||
default: return (female ? 0x2046 : 0x2048); //Buns or Receeding Hair
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ValidateFacialHair( bool female, int itemID )
|
||||
{
|
||||
if ( itemID == 0 )
|
||||
return true;
|
||||
|
||||
if ( female )
|
||||
return false;
|
||||
|
||||
if ( itemID >= 0x203E && itemID <= 0x2041 )
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x204B && itemID <= 0x204D )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int RandomFacialHair( bool female )
|
||||
{
|
||||
if ( female )
|
||||
return 0;
|
||||
|
||||
int rand = Utility.Random( 7 );
|
||||
|
||||
return ((rand < 4) ? 0x203E : 0x2047) + rand;
|
||||
}
|
||||
|
||||
public override int ClipSkinHue( int hue )
|
||||
{
|
||||
if ( hue < 1002 )
|
||||
return 1002;
|
||||
if ( hue > 1058 )
|
||||
return 1058;
|
||||
return hue;
|
||||
}
|
||||
|
||||
public override int RandomSkinHue()
|
||||
{
|
||||
return Utility.Random( 1002, 57 ) | 0x8000;
|
||||
}
|
||||
|
||||
public override int ClipHairHue( int hue )
|
||||
{
|
||||
if ( hue < 1102 )
|
||||
return 1102;
|
||||
if ( hue > 1149 )
|
||||
return 1149;
|
||||
return hue;
|
||||
}
|
||||
|
||||
public override int RandomHairHue()
|
||||
{
|
||||
return Utility.Random( 1102, 48 );
|
||||
}
|
||||
}
|
||||
|
||||
private class Elf : Race
|
||||
{
|
||||
private static int[] m_SkinHues = {
|
||||
0x0BF, 0x24D, 0x24E, 0x24F, 0x353, 0x361, 0x367, 0x374,
|
||||
0x375, 0x376, 0x381, 0x382, 0x383, 0x384, 0x385, 0x389,
|
||||
0x3DE, 0x3E5, 0x3E6, 0x3E8, 0x3E9, 0x430, 0x4A7, 0x4DE,
|
||||
0x51D, 0x53F, 0x579, 0x76B, 0x76C, 0x76D, 0x835, 0x903
|
||||
};
|
||||
|
||||
private static int[] m_HairHues = {
|
||||
0x034, 0x035, 0x036, 0x037, 0x038, 0x039, 0x058, 0x08E,
|
||||
0x08F, 0x090, 0x091, 0x092, 0x101, 0x159, 0x15A, 0x15B,
|
||||
0x15C, 0x15D, 0x15E, 0x128, 0x12F, 0x1BD, 0x1E4, 0x1F3,
|
||||
0x207, 0x211, 0x239, 0x251, 0x26C, 0x2C3, 0x2C9, 0x31D,
|
||||
0x31E, 0x31F, 0x320, 0x321, 0x322, 0x323, 0x324, 0x325,
|
||||
0x326, 0x369, 0x386, 0x387, 0x388, 0x389, 0x38A, 0x59D,
|
||||
0x6B8, 0x725, 0x853
|
||||
};
|
||||
|
||||
public Elf( int raceID, int raceIndex )
|
||||
: base( raceID, raceIndex, "Elf", "Elves", 605, 606, 607, 608, Expansion.ML )
|
||||
{
|
||||
}
|
||||
|
||||
public override bool ValidateHair( bool female, int itemID )
|
||||
{
|
||||
if ( itemID == 0 )
|
||||
return true;
|
||||
|
||||
if ( (female && (itemID == 0x2FCD || itemID == 0x2FBF)) || (!female && (itemID == 0x2FCC || itemID == 0x2FD0)) )
|
||||
return false;
|
||||
|
||||
if ( itemID >= 0x2FBF && itemID <= 0x2FC2 )
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x2FCC && itemID <= 0x2FD1 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int RandomHair( bool female ) //Random hair doesn't include baldness
|
||||
{
|
||||
switch( Utility.Random( 8 ) )
|
||||
{
|
||||
case 0: return 0x2FC0; //Long Feather
|
||||
case 1: return 0x2FC1; //Short
|
||||
case 2: return 0x2FC2; //Mullet
|
||||
case 3: return 0x2FCE; //Knob
|
||||
case 4: return 0x2FCF; //Braided
|
||||
case 5: return 0x2FD1; //Spiked
|
||||
case 6: return (female ? 0x2FCC : 0x2FBF); //Flower or Mid-long
|
||||
default: return (female ? 0x2FD0 : 0x2FCD); //Bun or Long
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ValidateFacialHair( bool female, int itemID )
|
||||
{
|
||||
return (itemID == 0);
|
||||
}
|
||||
|
||||
public override int RandomFacialHair( bool female )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override int ClipSkinHue( int hue )
|
||||
{
|
||||
for( int i = 0; i < m_SkinHues.Length; i++ )
|
||||
if ( m_SkinHues[i] == hue )
|
||||
return hue;
|
||||
|
||||
return m_SkinHues[0];
|
||||
}
|
||||
|
||||
public override int RandomSkinHue()
|
||||
{
|
||||
return m_SkinHues[Utility.Random( m_SkinHues.Length )] | 0x8000;
|
||||
}
|
||||
|
||||
public override int ClipHairHue( int hue )
|
||||
{
|
||||
for( int i = 0; i < m_HairHues.Length; i++ )
|
||||
if ( m_HairHues[i] == hue )
|
||||
return hue;
|
||||
|
||||
return m_HairHues[0];
|
||||
}
|
||||
|
||||
public override int RandomHairHue()
|
||||
{
|
||||
return m_HairHues[Utility.Random( m_HairHues.Length )];
|
||||
}
|
||||
}
|
||||
|
||||
#region SA
|
||||
private class Gargoyle : Race
|
||||
public override int RandomHair(bool female) //Random hair doesn't include baldness
|
||||
{
|
||||
switch (Utility.Random(9))
|
||||
{
|
||||
public Gargoyle(int raceID, int raceIndex)
|
||||
: base(raceID, raceIndex, "Gargoyle", "Gargoyles", 666, 667, 402, 403, Expansion.SA)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool ValidateHair(bool female, int itemID)
|
||||
{
|
||||
if (female == false)
|
||||
{
|
||||
return itemID >= 0x4258 && itemID <= 0x425F;
|
||||
}
|
||||
|
||||
return ((itemID == 0x4261 || itemID == 0x4262) || (itemID >= 0x4273 && itemID <= 0x4275) || (itemID == 0x42B0 || itemID == 0x42B1) || (itemID == 0x42AA || itemID == 0x42AB));
|
||||
}
|
||||
|
||||
public override int RandomHair(bool female)
|
||||
{
|
||||
if (Utility.Random(9) == 0)
|
||||
return 0;
|
||||
if (!female)
|
||||
return 0x4258 + Utility.Random(8);
|
||||
switch (Utility.Random(9))
|
||||
{
|
||||
case 0:
|
||||
return 0x4261;
|
||||
case 1:
|
||||
return 0x4262;
|
||||
case 2:
|
||||
return 0x4273;
|
||||
case 3:
|
||||
return 0x4274;
|
||||
case 4:
|
||||
return 0x4275;
|
||||
case 5:
|
||||
return 0x42B0;
|
||||
case 6:
|
||||
return 0x42B1;
|
||||
case 7:
|
||||
return 0x42AA;
|
||||
case 8:
|
||||
return 0x42AB;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override bool ValidateFacialHair(bool female, int itemID)
|
||||
{
|
||||
if (female)
|
||||
return false;
|
||||
return itemID >= 0x42AD && itemID <= 0x42B0;
|
||||
}
|
||||
|
||||
public override int RandomFacialHair(bool female)
|
||||
{
|
||||
if (female)
|
||||
return 0;
|
||||
return Utility.RandomList(0, 0x42AD, 0x42AE, 0x42AF, 0x42B0);
|
||||
}
|
||||
|
||||
// Todo Finish body hues
|
||||
private static readonly int[] m_BodyHues = {
|
||||
0x86DB, 0x86DC, 0x86DD, 0x86DE,
|
||||
0x86DF, 0x86E0, 0x86E1, 0x86E2,
|
||||
0x86E3, 0x86E4, 0x86E5, 0x86E6
|
||||
// 0x, 0x, 0x, 0x, // 86E7/86E8/86E9/86EA?
|
||||
// 0x, 0x, 0x, 0x, // 86EB/86EC/86ED/86EE?
|
||||
// 0x86F3, 0x86DB, 0x86DC, 0x86DD
|
||||
};
|
||||
|
||||
public override int ClipSkinHue(int hue)
|
||||
{
|
||||
return hue; // for hue information gathering
|
||||
}
|
||||
|
||||
public override int RandomSkinHue()
|
||||
{
|
||||
return m_BodyHues[Utility.Random(m_BodyHues.Length)] | 0x8000;
|
||||
}
|
||||
|
||||
private static readonly int[] m_HornHues = {
|
||||
0x709, 0x70B, 0x70D, 0x70F, 0x711, 0x763,
|
||||
0x765, 0x768, 0x76B, 0x6F3, 0x6F1, 0x6EF,
|
||||
0x6E4, 0x6E2, 0x6E0, 0x709, 0x70B, 0x70D
|
||||
};
|
||||
|
||||
public override int ClipHairHue(int hue)
|
||||
{
|
||||
for (int i = 0; i < m_HornHues.Length; i++)
|
||||
if (m_HornHues[i] == hue)
|
||||
return hue;
|
||||
|
||||
return m_HornHues[0];
|
||||
}
|
||||
|
||||
public override int RandomHairHue()
|
||||
{
|
||||
return m_HornHues[Utility.Random(m_HornHues.Length)];
|
||||
}
|
||||
case 0: return 0x203B; //Short
|
||||
case 1: return 0x203C; //Long
|
||||
case 2: return 0x203D; //Pony Tail
|
||||
case 3: return 0x2044; //Mohawk
|
||||
case 4: return 0x2045; //Pageboy
|
||||
case 5: return 0x2047; //Afro
|
||||
case 6: return 0x2049; //Pig tails
|
||||
case 7: return 0x204A; //Krisna
|
||||
default: return female ? 0x2046 : 0x2048; //Buns or Receeding Hair
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ValidateFacialHair(bool female, int itemID)
|
||||
{
|
||||
if (itemID == 0)
|
||||
return true;
|
||||
|
||||
if (female)
|
||||
return false;
|
||||
|
||||
if (itemID >= 0x203E && itemID <= 0x2041)
|
||||
return true;
|
||||
|
||||
if (itemID >= 0x204B && itemID <= 0x204D)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int RandomFacialHair(bool female)
|
||||
{
|
||||
if (female)
|
||||
return 0;
|
||||
|
||||
int rand = Utility.Random(7);
|
||||
|
||||
return (rand < 4 ? 0x203E : 0x2047) + rand;
|
||||
}
|
||||
|
||||
public override int ClipSkinHue(int hue)
|
||||
{
|
||||
if (hue < 1002)
|
||||
return 1002;
|
||||
if (hue > 1058)
|
||||
return 1058;
|
||||
return hue;
|
||||
}
|
||||
|
||||
public override int RandomSkinHue()
|
||||
{
|
||||
return Utility.Random(1002, 57) | 0x8000;
|
||||
}
|
||||
|
||||
public override int ClipHairHue(int hue)
|
||||
{
|
||||
if (hue < 1102)
|
||||
return 1102;
|
||||
if (hue > 1149)
|
||||
return 1149;
|
||||
return hue;
|
||||
}
|
||||
|
||||
public override int RandomHairHue()
|
||||
{
|
||||
return Utility.Random(1102, 48);
|
||||
}
|
||||
}
|
||||
|
||||
private class Elf : Race
|
||||
{
|
||||
private static int[] m_SkinHues =
|
||||
{
|
||||
0x0BF, 0x24D, 0x24E, 0x24F, 0x353, 0x361, 0x367, 0x374,
|
||||
0x375, 0x376, 0x381, 0x382, 0x383, 0x384, 0x385, 0x389,
|
||||
0x3DE, 0x3E5, 0x3E6, 0x3E8, 0x3E9, 0x430, 0x4A7, 0x4DE,
|
||||
0x51D, 0x53F, 0x579, 0x76B, 0x76C, 0x76D, 0x835, 0x903
|
||||
};
|
||||
|
||||
private static int[] m_HairHues =
|
||||
{
|
||||
0x034, 0x035, 0x036, 0x037, 0x038, 0x039, 0x058, 0x08E,
|
||||
0x08F, 0x090, 0x091, 0x092, 0x101, 0x159, 0x15A, 0x15B,
|
||||
0x15C, 0x15D, 0x15E, 0x128, 0x12F, 0x1BD, 0x1E4, 0x1F3,
|
||||
0x207, 0x211, 0x239, 0x251, 0x26C, 0x2C3, 0x2C9, 0x31D,
|
||||
0x31E, 0x31F, 0x320, 0x321, 0x322, 0x323, 0x324, 0x325,
|
||||
0x326, 0x369, 0x386, 0x387, 0x388, 0x389, 0x38A, 0x59D,
|
||||
0x6B8, 0x725, 0x853
|
||||
};
|
||||
|
||||
public Elf(int raceID, int raceIndex)
|
||||
: base(raceID, raceIndex, "Elf", "Elves", 605, 606, 607, 608, Expansion.ML)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool ValidateHair(bool female, int itemID)
|
||||
{
|
||||
if (itemID == 0)
|
||||
return true;
|
||||
|
||||
if (female && (itemID == 0x2FCD || itemID == 0x2FBF) || !female && (itemID == 0x2FCC || itemID == 0x2FD0))
|
||||
return false;
|
||||
|
||||
if (itemID >= 0x2FBF && itemID <= 0x2FC2)
|
||||
return true;
|
||||
|
||||
if (itemID >= 0x2FCC && itemID <= 0x2FD1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int RandomHair(bool female) //Random hair doesn't include baldness
|
||||
{
|
||||
switch (Utility.Random(8))
|
||||
{
|
||||
case 0: return 0x2FC0; //Long Feather
|
||||
case 1: return 0x2FC1; //Short
|
||||
case 2: return 0x2FC2; //Mullet
|
||||
case 3: return 0x2FCE; //Knob
|
||||
case 4: return 0x2FCF; //Braided
|
||||
case 5: return 0x2FD1; //Spiked
|
||||
case 6: return female ? 0x2FCC : 0x2FBF; //Flower or Mid-long
|
||||
default: return female ? 0x2FD0 : 0x2FCD; //Bun or Long
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ValidateFacialHair(bool female, int itemID)
|
||||
{
|
||||
return itemID == 0;
|
||||
}
|
||||
|
||||
public override int RandomFacialHair(bool female)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override int ClipSkinHue(int hue)
|
||||
{
|
||||
for (int i = 0; i < m_SkinHues.Length; i++)
|
||||
if (m_SkinHues[i] == hue)
|
||||
return hue;
|
||||
|
||||
return m_SkinHues[0];
|
||||
}
|
||||
|
||||
public override int RandomSkinHue()
|
||||
{
|
||||
return m_SkinHues[Utility.Random(m_SkinHues.Length)] | 0x8000;
|
||||
}
|
||||
|
||||
public override int ClipHairHue(int hue)
|
||||
{
|
||||
for (int i = 0; i < m_HairHues.Length; i++)
|
||||
if (m_HairHues[i] == hue)
|
||||
return hue;
|
||||
|
||||
return m_HairHues[0];
|
||||
}
|
||||
|
||||
public override int RandomHairHue()
|
||||
{
|
||||
return m_HairHues[Utility.Random(m_HairHues.Length)];
|
||||
}
|
||||
}
|
||||
|
||||
#region SA
|
||||
|
||||
private class Gargoyle : Race
|
||||
{
|
||||
// Todo Finish body hues
|
||||
private static readonly int[] m_BodyHues =
|
||||
{
|
||||
0x86DB, 0x86DC, 0x86DD, 0x86DE,
|
||||
0x86DF, 0x86E0, 0x86E1, 0x86E2,
|
||||
0x86E3, 0x86E4, 0x86E5, 0x86E6
|
||||
// 0x, 0x, 0x, 0x, // 86E7/86E8/86E9/86EA?
|
||||
// 0x, 0x, 0x, 0x, // 86EB/86EC/86ED/86EE?
|
||||
// 0x86F3, 0x86DB, 0x86DC, 0x86DD
|
||||
};
|
||||
|
||||
private static readonly int[] m_HornHues =
|
||||
{
|
||||
0x709, 0x70B, 0x70D, 0x70F, 0x711, 0x763,
|
||||
0x765, 0x768, 0x76B, 0x6F3, 0x6F1, 0x6EF,
|
||||
0x6E4, 0x6E2, 0x6E0, 0x709, 0x70B, 0x70D
|
||||
};
|
||||
|
||||
public Gargoyle(int raceID, int raceIndex)
|
||||
: base(raceID, raceIndex, "Gargoyle", "Gargoyles", 666, 667, 402, 403, Expansion.SA)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool ValidateHair(bool female, int itemID)
|
||||
{
|
||||
if (female == false) return itemID >= 0x4258 && itemID <= 0x425F;
|
||||
|
||||
return itemID == 0x4261 || itemID == 0x4262 || itemID >= 0x4273 && itemID <= 0x4275 || itemID == 0x42B0 ||
|
||||
itemID == 0x42B1 || itemID == 0x42AA || itemID == 0x42AB;
|
||||
}
|
||||
|
||||
public override int RandomHair(bool female)
|
||||
{
|
||||
if (Utility.Random(9) == 0)
|
||||
return 0;
|
||||
if (!female)
|
||||
return 0x4258 + Utility.Random(8);
|
||||
switch (Utility.Random(9))
|
||||
{
|
||||
case 0:
|
||||
return 0x4261;
|
||||
case 1:
|
||||
return 0x4262;
|
||||
case 2:
|
||||
return 0x4273;
|
||||
case 3:
|
||||
return 0x4274;
|
||||
case 4:
|
||||
return 0x4275;
|
||||
case 5:
|
||||
return 0x42B0;
|
||||
case 6:
|
||||
return 0x42B1;
|
||||
case 7:
|
||||
return 0x42AA;
|
||||
case 8:
|
||||
return 0x42AB;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override bool ValidateFacialHair(bool female, int itemID)
|
||||
{
|
||||
if (female)
|
||||
return false;
|
||||
return itemID >= 0x42AD && itemID <= 0x42B0;
|
||||
}
|
||||
|
||||
public override int RandomFacialHair(bool female)
|
||||
{
|
||||
if (female)
|
||||
return 0;
|
||||
return Utility.RandomList(0, 0x42AD, 0x42AE, 0x42AF, 0x42B0);
|
||||
}
|
||||
|
||||
public override int ClipSkinHue(int hue)
|
||||
{
|
||||
return hue; // for hue information gathering
|
||||
}
|
||||
|
||||
public override int RandomSkinHue()
|
||||
{
|
||||
return m_BodyHues[Utility.Random(m_BodyHues.Length)] | 0x8000;
|
||||
}
|
||||
|
||||
public override int ClipHairHue(int hue)
|
||||
{
|
||||
for (int i = 0; i < m_HornHues.Length; i++)
|
||||
if (m_HornHues[i] == hue)
|
||||
return hue;
|
||||
|
||||
return m_HornHues[0];
|
||||
}
|
||||
|
||||
public override int RandomHairHue()
|
||||
{
|
||||
return m_HornHues[Utility.Random(m_HornHues.Length)];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -1,220 +1,220 @@
|
|||
using System;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Spells;
|
||||
using Server.Spells.Necromancy;
|
||||
using Server.Spells.Ninjitsu;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class RegenRates
|
||||
{
|
||||
[CallPriority( 10 )]
|
||||
public static void Configure()
|
||||
{
|
||||
Mobile.DefaultHitsRate = TimeSpan.FromSeconds( 11.0 );
|
||||
Mobile.DefaultStamRate = TimeSpan.FromSeconds( 7.0 );
|
||||
Mobile.DefaultManaRate = TimeSpan.FromSeconds( 7.0 );
|
||||
public class RegenRates
|
||||
{
|
||||
[CallPriority(10)]
|
||||
public static void Configure()
|
||||
{
|
||||
Mobile.DefaultHitsRate = TimeSpan.FromSeconds(11.0);
|
||||
Mobile.DefaultStamRate = TimeSpan.FromSeconds(7.0);
|
||||
Mobile.DefaultManaRate = TimeSpan.FromSeconds(7.0);
|
||||
|
||||
Mobile.ManaRegenRateHandler = Mobile_ManaRegenRate;
|
||||
Mobile.ManaRegenRateHandler = Mobile_ManaRegenRate;
|
||||
|
||||
if ( Core.AOS )
|
||||
{
|
||||
Mobile.StamRegenRateHandler = Mobile_StamRegenRate;
|
||||
Mobile.HitsRegenRateHandler = Mobile_HitsRegenRate;
|
||||
}
|
||||
}
|
||||
if (Core.AOS)
|
||||
{
|
||||
Mobile.StamRegenRateHandler = Mobile_StamRegenRate;
|
||||
Mobile.HitsRegenRateHandler = Mobile_HitsRegenRate;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckBonusSkill( Mobile m, int cur, int max, SkillName skill )
|
||||
{
|
||||
if ( !m.Alive )
|
||||
return;
|
||||
private static void CheckBonusSkill(Mobile m, int cur, int max, SkillName skill)
|
||||
{
|
||||
if (!m.Alive)
|
||||
return;
|
||||
|
||||
double n = (double)cur / max;
|
||||
double v = Math.Sqrt( m.Skills[skill].Value * 0.005 );
|
||||
double n = (double)cur / max;
|
||||
double v = Math.Sqrt(m.Skills[skill].Value * 0.005);
|
||||
|
||||
n *= (1.0 - v);
|
||||
n += v;
|
||||
n *= 1.0 - v;
|
||||
n += v;
|
||||
|
||||
m.CheckSkill( skill, n );
|
||||
}
|
||||
m.CheckSkill(skill, n);
|
||||
}
|
||||
|
||||
private static bool CheckTransform( Mobile m, Type type )
|
||||
{
|
||||
return TransformationSpellHelper.UnderTransformation( m, type );
|
||||
}
|
||||
private static bool CheckTransform(Mobile m, Type type)
|
||||
{
|
||||
return TransformationSpellHelper.UnderTransformation(m, type);
|
||||
}
|
||||
|
||||
private static bool CheckAnimal( Mobile m, Type type )
|
||||
{
|
||||
return AnimalForm.UnderTransformation( m, type );
|
||||
}
|
||||
private static bool CheckAnimal(Mobile m, Type type)
|
||||
{
|
||||
return AnimalForm.UnderTransformation(m, type);
|
||||
}
|
||||
|
||||
private static TimeSpan Mobile_HitsRegenRate( Mobile from )
|
||||
{
|
||||
int points = AosAttributes.GetValue( from, AosAttribute.RegenHits );
|
||||
private static TimeSpan Mobile_HitsRegenRate(Mobile from)
|
||||
{
|
||||
int points = AosAttributes.GetValue(from, AosAttribute.RegenHits);
|
||||
|
||||
BaseCreature bc = from as BaseCreature;
|
||||
BaseCreature bc = from as BaseCreature;
|
||||
|
||||
if ( bc != null && !bc.IsAnimatedDead )
|
||||
points += 4;
|
||||
if (bc != null && !bc.IsAnimatedDead)
|
||||
points += 4;
|
||||
|
||||
if ( bc?.IsParagon == true || from is Leviathan )
|
||||
points += 40;
|
||||
if (bc?.IsParagon == true || from is Leviathan)
|
||||
points += 40;
|
||||
|
||||
if ( Core.ML && from.Race == Race.Human ) //Is this affected by the cap?
|
||||
points += 2;
|
||||
if (Core.ML && from.Race == Race.Human) //Is this affected by the cap?
|
||||
points += 2;
|
||||
|
||||
if ( points < 0 )
|
||||
points = 0;
|
||||
if (points < 0)
|
||||
points = 0;
|
||||
|
||||
if ( Core.ML && from is PlayerMobile ) //does racial bonus go before/after?
|
||||
points = Math.Min( points, 18 );
|
||||
if (Core.ML && from is PlayerMobile) //does racial bonus go before/after?
|
||||
points = Math.Min(points, 18);
|
||||
|
||||
if ( CheckTransform( from, typeof( HorrificBeastSpell ) ) )
|
||||
points += 20;
|
||||
if (CheckTransform(from, typeof(HorrificBeastSpell)))
|
||||
points += 20;
|
||||
|
||||
if ( CheckAnimal( from, typeof( Dog ) ) || CheckAnimal( from, typeof( Cat ) ) )
|
||||
points += from.Skills[SkillName.Ninjitsu].Fixed / 30;
|
||||
if (CheckAnimal(from, typeof(Dog)) || CheckAnimal(from, typeof(Cat)))
|
||||
points += from.Skills[SkillName.Ninjitsu].Fixed / 30;
|
||||
|
||||
return TimeSpan.FromSeconds( 1.0 / (0.1 * (1 + points)) );
|
||||
}
|
||||
return TimeSpan.FromSeconds(1.0 / (0.1 * (1 + points)));
|
||||
}
|
||||
|
||||
private static TimeSpan Mobile_StamRegenRate( Mobile from )
|
||||
{
|
||||
if ( from.Skills == null )
|
||||
return Mobile.DefaultStamRate;
|
||||
private static TimeSpan Mobile_StamRegenRate(Mobile from)
|
||||
{
|
||||
if (from.Skills == null)
|
||||
return Mobile.DefaultStamRate;
|
||||
|
||||
CheckBonusSkill( from, from.Stam, from.StamMax, SkillName.Focus );
|
||||
CheckBonusSkill(from, from.Stam, from.StamMax, SkillName.Focus);
|
||||
|
||||
int points =(int)(from.Skills[SkillName.Focus].Value * 0.1);
|
||||
int points = (int)(from.Skills[SkillName.Focus].Value * 0.1);
|
||||
|
||||
if ( (from is BaseCreature creature && creature.IsParagon) || from is Leviathan )
|
||||
points += 40;
|
||||
if (from is BaseCreature creature && creature.IsParagon || from is Leviathan)
|
||||
points += 40;
|
||||
|
||||
int cappedPoints = AosAttributes.GetValue( from, AosAttribute.RegenStam );
|
||||
int cappedPoints = AosAttributes.GetValue(from, AosAttribute.RegenStam);
|
||||
|
||||
if ( CheckTransform( from, typeof( VampiricEmbraceSpell ) ) )
|
||||
cappedPoints += 15;
|
||||
if (CheckTransform(from, typeof(VampiricEmbraceSpell)))
|
||||
cappedPoints += 15;
|
||||
|
||||
if ( CheckAnimal( from, typeof( Kirin ) ) )
|
||||
cappedPoints += 20;
|
||||
if (CheckAnimal(from, typeof(Kirin)))
|
||||
cappedPoints += 20;
|
||||
|
||||
if ( Core.ML && from is PlayerMobile )
|
||||
cappedPoints = Math.Min( cappedPoints, 24 );
|
||||
if (Core.ML && from is PlayerMobile)
|
||||
cappedPoints = Math.Min(cappedPoints, 24);
|
||||
|
||||
points += cappedPoints;
|
||||
points += cappedPoints;
|
||||
|
||||
if ( points < -1 )
|
||||
points = -1;
|
||||
if (points < -1)
|
||||
points = -1;
|
||||
|
||||
return TimeSpan.FromSeconds( 1.0 / (0.1 * (2 + points)) );
|
||||
}
|
||||
return TimeSpan.FromSeconds(1.0 / (0.1 * (2 + points)));
|
||||
}
|
||||
|
||||
private static TimeSpan Mobile_ManaRegenRate( Mobile from )
|
||||
{
|
||||
if ( from.Skills == null )
|
||||
return Mobile.DefaultManaRate;
|
||||
private static TimeSpan Mobile_ManaRegenRate(Mobile from)
|
||||
{
|
||||
if (from.Skills == null)
|
||||
return Mobile.DefaultManaRate;
|
||||
|
||||
if ( !from.Meditating )
|
||||
CheckBonusSkill( from, from.Mana, from.ManaMax, SkillName.Meditation );
|
||||
if (!from.Meditating)
|
||||
CheckBonusSkill(from, from.Mana, from.ManaMax, SkillName.Meditation);
|
||||
|
||||
double rate;
|
||||
double armorPenalty = GetArmorOffset( from );
|
||||
double rate;
|
||||
double armorPenalty = GetArmorOffset(from);
|
||||
|
||||
if ( Core.AOS )
|
||||
{
|
||||
double medPoints = from.Int + (from.Skills[SkillName.Meditation].Value * 3);
|
||||
if (Core.AOS)
|
||||
{
|
||||
double medPoints = from.Int + from.Skills[SkillName.Meditation].Value * 3;
|
||||
|
||||
medPoints *= ( from.Skills[SkillName.Meditation].Value < 100.0 ) ? 0.025 : 0.0275;
|
||||
medPoints *= from.Skills[SkillName.Meditation].Value < 100.0 ? 0.025 : 0.0275;
|
||||
|
||||
CheckBonusSkill( from, from.Mana, from.ManaMax, SkillName.Focus );
|
||||
CheckBonusSkill(from, from.Mana, from.ManaMax, SkillName.Focus);
|
||||
|
||||
double focusPoints = (from.Skills[SkillName.Focus].Value * 0.05);
|
||||
double focusPoints = from.Skills[SkillName.Focus].Value * 0.05;
|
||||
|
||||
if ( armorPenalty > 0 )
|
||||
medPoints = 0; // In AOS, wearing any meditation-blocking armor completely removes meditation bonus
|
||||
if (armorPenalty > 0)
|
||||
medPoints = 0; // In AOS, wearing any meditation-blocking armor completely removes meditation bonus
|
||||
|
||||
double totalPoints = focusPoints + medPoints + (from.Meditating ? (medPoints > 13.0 ? 13.0 : medPoints) : 0.0);
|
||||
double totalPoints = focusPoints + medPoints + (from.Meditating ? medPoints > 13.0 ? 13.0 : medPoints : 0.0);
|
||||
|
||||
if ( (from is BaseCreature creature && creature.IsParagon) || from is Leviathan )
|
||||
totalPoints += 40;
|
||||
if (from is BaseCreature creature && creature.IsParagon || from is Leviathan)
|
||||
totalPoints += 40;
|
||||
|
||||
int cappedPoints = AosAttributes.GetValue( from, AosAttribute.RegenMana );
|
||||
int cappedPoints = AosAttributes.GetValue(from, AosAttribute.RegenMana);
|
||||
|
||||
if ( CheckTransform( from, typeof( VampiricEmbraceSpell ) ) )
|
||||
cappedPoints += 3;
|
||||
else if ( CheckTransform( from, typeof( LichFormSpell ) ) )
|
||||
cappedPoints += 13;
|
||||
if (CheckTransform(from, typeof(VampiricEmbraceSpell)))
|
||||
cappedPoints += 3;
|
||||
else if (CheckTransform(from, typeof(LichFormSpell)))
|
||||
cappedPoints += 13;
|
||||
|
||||
if ( Core.ML && from is PlayerMobile )
|
||||
cappedPoints = Math.Min( cappedPoints, 18 );
|
||||
if (Core.ML && from is PlayerMobile)
|
||||
cappedPoints = Math.Min(cappedPoints, 18);
|
||||
|
||||
totalPoints += cappedPoints;
|
||||
totalPoints += cappedPoints;
|
||||
|
||||
if ( totalPoints < -1 )
|
||||
totalPoints = -1;
|
||||
if (totalPoints < -1)
|
||||
totalPoints = -1;
|
||||
|
||||
if ( Core.ML )
|
||||
totalPoints = Math.Floor( totalPoints );
|
||||
if (Core.ML)
|
||||
totalPoints = Math.Floor(totalPoints);
|
||||
|
||||
rate = 1.0 / (0.1 * (2 + totalPoints));
|
||||
}
|
||||
else
|
||||
{
|
||||
double medPoints = (from.Int + from.Skills[SkillName.Meditation].Value) * 0.5;
|
||||
rate = 1.0 / (0.1 * (2 + totalPoints));
|
||||
}
|
||||
else
|
||||
{
|
||||
double medPoints = (from.Int + from.Skills[SkillName.Meditation].Value) * 0.5;
|
||||
|
||||
if ( medPoints <= 0 )
|
||||
rate = 7.0;
|
||||
else if ( medPoints <= 100 )
|
||||
rate = 7.0 - (239*medPoints/2400) + (19*medPoints*medPoints/48000);
|
||||
else if ( medPoints < 120 )
|
||||
rate = 1.0;
|
||||
else
|
||||
rate = 0.75;
|
||||
if (medPoints <= 0)
|
||||
rate = 7.0;
|
||||
else if (medPoints <= 100)
|
||||
rate = 7.0 - 239 * medPoints / 2400 + 19 * medPoints * medPoints / 48000;
|
||||
else if (medPoints < 120)
|
||||
rate = 1.0;
|
||||
else
|
||||
rate = 0.75;
|
||||
|
||||
rate += armorPenalty;
|
||||
rate += armorPenalty;
|
||||
|
||||
if ( from.Meditating )
|
||||
rate *= 0.5;
|
||||
if (from.Meditating)
|
||||
rate *= 0.5;
|
||||
|
||||
if ( rate < 0.5 )
|
||||
rate = 0.5;
|
||||
else if ( rate > 7.0 )
|
||||
rate = 7.0;
|
||||
}
|
||||
if (rate < 0.5)
|
||||
rate = 0.5;
|
||||
else if (rate > 7.0)
|
||||
rate = 7.0;
|
||||
}
|
||||
|
||||
return TimeSpan.FromSeconds( rate );
|
||||
}
|
||||
return TimeSpan.FromSeconds(rate);
|
||||
}
|
||||
|
||||
public static double GetArmorOffset( Mobile from )
|
||||
{
|
||||
double rating = 0.0;
|
||||
public static double GetArmorOffset(Mobile from)
|
||||
{
|
||||
double rating = 0.0;
|
||||
|
||||
if ( !Core.AOS )
|
||||
rating += GetArmorMeditationValue( from.ShieldArmor as BaseArmor );
|
||||
if (!Core.AOS)
|
||||
rating += GetArmorMeditationValue(from.ShieldArmor as BaseArmor);
|
||||
|
||||
rating += GetArmorMeditationValue( from.NeckArmor as BaseArmor );
|
||||
rating += GetArmorMeditationValue( from.HandArmor as BaseArmor );
|
||||
rating += GetArmorMeditationValue( from.HeadArmor as BaseArmor );
|
||||
rating += GetArmorMeditationValue( from.ArmsArmor as BaseArmor );
|
||||
rating += GetArmorMeditationValue( from.LegsArmor as BaseArmor );
|
||||
rating += GetArmorMeditationValue( from.ChestArmor as BaseArmor );
|
||||
rating += GetArmorMeditationValue(from.NeckArmor as BaseArmor);
|
||||
rating += GetArmorMeditationValue(from.HandArmor as BaseArmor);
|
||||
rating += GetArmorMeditationValue(from.HeadArmor as BaseArmor);
|
||||
rating += GetArmorMeditationValue(from.ArmsArmor as BaseArmor);
|
||||
rating += GetArmorMeditationValue(from.LegsArmor as BaseArmor);
|
||||
rating += GetArmorMeditationValue(from.ChestArmor as BaseArmor);
|
||||
|
||||
return rating / 4;
|
||||
}
|
||||
return rating / 4;
|
||||
}
|
||||
|
||||
private static double GetArmorMeditationValue( BaseArmor ar )
|
||||
{
|
||||
if ( ar == null || ar.ArmorAttributes.MageArmor != 0 || ar.Attributes.SpellChanneling != 0 )
|
||||
return 0.0;
|
||||
private static double GetArmorMeditationValue(BaseArmor ar)
|
||||
{
|
||||
if (ar == null || ar.ArmorAttributes.MageArmor != 0 || ar.Attributes.SpellChanneling != 0)
|
||||
return 0.0;
|
||||
|
||||
switch ( ar.MeditationAllowance )
|
||||
{
|
||||
default:
|
||||
case ArmorMeditationAllowance.None: return ar.BaseArmorRatingScaled;
|
||||
case ArmorMeditationAllowance.Half: return ar.BaseArmorRatingScaled / 2.0;
|
||||
case ArmorMeditationAllowance.All: return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (ar.MeditationAllowance)
|
||||
{
|
||||
default:
|
||||
case ArmorMeditationAllowance.None: return ar.BaseArmorRatingScaled;
|
||||
case ArmorMeditationAllowance.Half: return ar.BaseArmorRatingScaled / 2.0;
|
||||
case ArmorMeditationAllowance.All: return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +1,47 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class RenameRequests
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.RenameRequest += EventSink_RenameRequest;
|
||||
}
|
||||
public class RenameRequests
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.RenameRequest += EventSink_RenameRequest;
|
||||
}
|
||||
|
||||
private static void EventSink_RenameRequest( RenameRequestEventArgs e )
|
||||
{
|
||||
Mobile from = e.From;
|
||||
Mobile targ = e.Target;
|
||||
string name = e.Name;
|
||||
private static void EventSink_RenameRequest(RenameRequestEventArgs e)
|
||||
{
|
||||
Mobile from = e.From;
|
||||
Mobile targ = e.Target;
|
||||
string name = e.Name;
|
||||
|
||||
if ( from.CanSee( targ ) && from.InRange( targ, 12 ) && targ.CanBeRenamedBy( from ) )
|
||||
{
|
||||
name = name.Trim();
|
||||
if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
|
||||
{
|
||||
name = name.Trim();
|
||||
|
||||
if ( NameVerification.Validate( name, 1, 16, true, false, true, 0, NameVerification.Empty, NameVerification.StartDisallowed, ( Core.ML ? NameVerification.Disallowed : new string[]{} ) ) )
|
||||
{
|
||||
if (NameVerification.Validate(name, 1, 16, true, false, true, 0, NameVerification.Empty,
|
||||
NameVerification.StartDisallowed, Core.ML ? NameVerification.Disallowed : new string[] { }))
|
||||
{
|
||||
if (Core.ML)
|
||||
{
|
||||
string[] disallowed = ProfanityProtection.Disallowed;
|
||||
|
||||
if ( Core.ML )
|
||||
{
|
||||
string[] disallowed = ProfanityProtection.Disallowed;
|
||||
for (int i = 0; i < disallowed.Length; i++)
|
||||
if (name.IndexOf(disallowed[i]) != -1)
|
||||
{
|
||||
from.SendLocalizedMessage(1072622); // That name isn't very polite.
|
||||
return;
|
||||
}
|
||||
|
||||
for( int i = 0; i < disallowed.Length; i++ )
|
||||
{
|
||||
if ( name.IndexOf( disallowed[i] ) != -1 )
|
||||
{
|
||||
from.SendLocalizedMessage( 1072622 ); // That name isn't very polite.
|
||||
return;
|
||||
}
|
||||
}
|
||||
from.SendLocalizedMessage(1072623,
|
||||
$"{targ.Name}\t{name}"); // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage( 1072623, $"{targ.Name}\t{name}"); // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
|
||||
}
|
||||
|
||||
targ.Name = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( "That name is unacceptable." );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targ.Name = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("That name is unacceptable.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,190 +7,202 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class ServerList
|
||||
{
|
||||
/*
|
||||
* The default setting for Address, a value of 'null', will use your local IP address. If all of your local IP addresses
|
||||
* are private network addresses and AutoDetect is 'true' then RunUO will attempt to discover your public IP address
|
||||
* for you automatically.
|
||||
*
|
||||
* If you do not plan on allowing clients outside of your LAN to connect, you can set AutoDetect to 'false' and leave
|
||||
* Address set to 'null'.
|
||||
*
|
||||
* If your public IP address cannot be determined, you must change the value of Address to your public IP address
|
||||
* manually to allow clients outside of your LAN to connect to your server. Address can be either an IP address or
|
||||
* a hostname that will be resolved when RunUO starts.
|
||||
*
|
||||
* If you want players outside your LAN to be able to connect to your server and you are behind a router, you must also
|
||||
* forward TCP port 2593 to your private IP address. The procedure for doing this varies by manufacturer but generally
|
||||
* involves configuration of the router through your web browser.
|
||||
*
|
||||
* ServerList will direct connecting clients depending on both the address they are connecting from and the address and
|
||||
* port they are connecting to. If it is determined that both ends of a connection are private IP addresses, ServerList
|
||||
* will direct the client to the local private IP address. If a client is connecting to a local public IP address, they
|
||||
* will be directed to whichever address and port they initially connected to. This allows multihomed servers to function
|
||||
* properly and fully supports listening on multiple ports. If a client with a public IP address is connecting to a
|
||||
* locally private address, the server will direct the client to either the AutoDetected IP address or the manually entered
|
||||
* IP address or hostname, whichever is applicable. Loopback clients will be directed to loopback.
|
||||
*
|
||||
* If you would like to listen on additional ports (i.e. 22, 23, 80, for clients behind highly restrictive egress
|
||||
* firewalls) or specific IP adddresses you can do so by modifying the file SocketOptions.cs found in this directory.
|
||||
*/
|
||||
public class ServerList
|
||||
{
|
||||
/*
|
||||
* The default setting for Address, a value of 'null', will use your local IP address. If all of your local IP addresses
|
||||
* are private network addresses and AutoDetect is 'true' then RunUO will attempt to discover your public IP address
|
||||
* for you automatically.
|
||||
*
|
||||
* If you do not plan on allowing clients outside of your LAN to connect, you can set AutoDetect to 'false' and leave
|
||||
* Address set to 'null'.
|
||||
*
|
||||
* If your public IP address cannot be determined, you must change the value of Address to your public IP address
|
||||
* manually to allow clients outside of your LAN to connect to your server. Address can be either an IP address or
|
||||
* a hostname that will be resolved when RunUO starts.
|
||||
*
|
||||
* If you want players outside your LAN to be able to connect to your server and you are behind a router, you must also
|
||||
* forward TCP port 2593 to your private IP address. The procedure for doing this varies by manufacturer but generally
|
||||
* involves configuration of the router through your web browser.
|
||||
*
|
||||
* ServerList will direct connecting clients depending on both the address they are connecting from and the address and
|
||||
* port they are connecting to. If it is determined that both ends of a connection are private IP addresses, ServerList
|
||||
* will direct the client to the local private IP address. If a client is connecting to a local public IP address, they
|
||||
* will be directed to whichever address and port they initially connected to. This allows multihomed servers to function
|
||||
* properly and fully supports listening on multiple ports. If a client with a public IP address is connecting to a
|
||||
* locally private address, the server will direct the client to either the AutoDetected IP address or the manually entered
|
||||
* IP address or hostname, whichever is applicable. Loopback clients will be directed to loopback.
|
||||
*
|
||||
* If you would like to listen on additional ports (i.e. 22, 23, 80, for clients behind highly restrictive egress
|
||||
* firewalls) or specific IP adddresses you can do so by modifying the file SocketOptions.cs found in this directory.
|
||||
*/
|
||||
|
||||
public static readonly string Address = null;
|
||||
public static readonly string ServerName = "RunUO TC";
|
||||
public static readonly string Address = null;
|
||||
public static readonly string ServerName = "RunUO TC";
|
||||
|
||||
public static readonly bool AutoDetect = true;
|
||||
public static readonly bool AutoDetect = true;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if ( Address == null ) {
|
||||
if ( AutoDetect )
|
||||
AutoDetection();
|
||||
}
|
||||
else {
|
||||
Resolve( Address, out m_PublicAddress );
|
||||
}
|
||||
private static IPAddress m_PublicAddress;
|
||||
|
||||
EventSink.ServerList += EventSink_ServerList;
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Address == null)
|
||||
{
|
||||
if (AutoDetect)
|
||||
AutoDetection();
|
||||
}
|
||||
else
|
||||
{
|
||||
Resolve(Address, out m_PublicAddress);
|
||||
}
|
||||
|
||||
private static IPAddress m_PublicAddress;
|
||||
EventSink.ServerList += EventSink_ServerList;
|
||||
}
|
||||
|
||||
private static void EventSink_ServerList( ServerListEventArgs e )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetState ns = e.State;
|
||||
Socket s = ns.Socket;
|
||||
private static void EventSink_ServerList(ServerListEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
NetState ns = e.State;
|
||||
Socket s = ns.Socket;
|
||||
|
||||
IPEndPoint ipep = (IPEndPoint)s.LocalEndPoint;
|
||||
IPEndPoint ipep = (IPEndPoint)s.LocalEndPoint;
|
||||
|
||||
IPAddress localAddress = ipep.Address;
|
||||
int localPort = ipep.Port;
|
||||
IPAddress localAddress = ipep.Address;
|
||||
int localPort = ipep.Port;
|
||||
|
||||
if ( IsPrivateNetwork( localAddress ) ) {
|
||||
ipep = (IPEndPoint)s.RemoteEndPoint;
|
||||
if ( !IsPrivateNetwork( ipep.Address ) && m_PublicAddress != null )
|
||||
localAddress = m_PublicAddress;
|
||||
}
|
||||
if (IsPrivateNetwork(localAddress))
|
||||
{
|
||||
ipep = (IPEndPoint)s.RemoteEndPoint;
|
||||
if (!IsPrivateNetwork(ipep.Address) && m_PublicAddress != null)
|
||||
localAddress = m_PublicAddress;
|
||||
}
|
||||
|
||||
e.AddServer( ServerName, new IPEndPoint( localAddress, localPort ) );
|
||||
}
|
||||
catch
|
||||
{
|
||||
e.Rejected = true;
|
||||
}
|
||||
}
|
||||
e.AddServer(ServerName, new IPEndPoint(localAddress, localPort));
|
||||
}
|
||||
catch
|
||||
{
|
||||
e.Rejected = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AutoDetection()
|
||||
{
|
||||
if ( !HasPublicIPAddress() ) {
|
||||
Console.Write( "ServerList: Auto-detecting public IP address..." );
|
||||
m_PublicAddress = FindPublicAddress();
|
||||
private static void AutoDetection()
|
||||
{
|
||||
if (!HasPublicIPAddress())
|
||||
{
|
||||
Console.Write("ServerList: Auto-detecting public IP address...");
|
||||
m_PublicAddress = FindPublicAddress();
|
||||
|
||||
if ( m_PublicAddress != null )
|
||||
Console.WriteLine( "done ({0})", m_PublicAddress.ToString() );
|
||||
else
|
||||
Console.WriteLine( "failed" );
|
||||
}
|
||||
}
|
||||
if (m_PublicAddress != null)
|
||||
Console.WriteLine("done ({0})", m_PublicAddress);
|
||||
else
|
||||
Console.WriteLine("failed");
|
||||
}
|
||||
}
|
||||
|
||||
private static void Resolve( string addr, out IPAddress outValue )
|
||||
{
|
||||
if ( IPAddress.TryParse( addr, out outValue ) )
|
||||
return;
|
||||
private static void Resolve(string addr, out IPAddress outValue)
|
||||
{
|
||||
if (IPAddress.TryParse(addr, out outValue))
|
||||
return;
|
||||
|
||||
try {
|
||||
IPHostEntry iphe = Dns.GetHostEntry( addr );
|
||||
try
|
||||
{
|
||||
IPHostEntry iphe = Dns.GetHostEntry(addr);
|
||||
|
||||
if ( iphe.AddressList.Length > 0 )
|
||||
outValue = iphe.AddressList[iphe.AddressList.Length - 1];
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}
|
||||
if (iphe.AddressList.Length > 0)
|
||||
outValue = iphe.AddressList[iphe.AddressList.Length - 1];
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static bool HasPublicIPAddress()
|
||||
{
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
|
||||
private static bool HasPublicIPAddress()
|
||||
{
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
|
||||
|
||||
foreach ( NetworkInterface adapter in adapters ) {
|
||||
IPInterfaceProperties properties = adapter.GetIPProperties();
|
||||
foreach (NetworkInterface adapter in adapters)
|
||||
{
|
||||
IPInterfaceProperties properties = adapter.GetIPProperties();
|
||||
|
||||
foreach ( IPAddressInformation unicast in properties.UnicastAddresses ) {
|
||||
IPAddress ip = unicast.Address;
|
||||
foreach (IPAddressInformation unicast in properties.UnicastAddresses)
|
||||
{
|
||||
IPAddress ip = unicast.Address;
|
||||
|
||||
if ( !IPAddress.IsLoopback( ip ) && ip.AddressFamily != AddressFamily.InterNetworkV6 && !IsPrivateNetwork( ip ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!IPAddress.IsLoopback(ip) && ip.AddressFamily != AddressFamily.InterNetworkV6 &&
|
||||
!IsPrivateNetwork(ip))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
|
||||
|
||||
/*
|
||||
IPHostEntry iphe = Dns.GetHostEntry( Dns.GetHostName() );
|
||||
/*
|
||||
IPHostEntry iphe = Dns.GetHostEntry( Dns.GetHostName() );
|
||||
|
||||
IPAddress[] ips = iphe.AddressList;
|
||||
IPAddress[] ips = iphe.AddressList;
|
||||
|
||||
for ( int i = 0; i < ips.Length; ++i )
|
||||
{
|
||||
if ( ips[i].AddressFamily != AddressFamily.InterNetworkV6 && !IsPrivateNetwork( ips[i] ) )
|
||||
return true;
|
||||
}
|
||||
for ( int i = 0; i < ips.Length; ++i )
|
||||
{
|
||||
if ( ips[i].AddressFamily != AddressFamily.InterNetworkV6 && !IsPrivateNetwork( ips[i] ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
private static bool IsPrivateNetwork( IPAddress ip )
|
||||
{
|
||||
// 10.0.0.0/8
|
||||
// 172.16.0.0/12
|
||||
// 192.168.0.0/16
|
||||
// 169.254.0.0/16
|
||||
// 100.64.0.0/10 RFC 6598
|
||||
private static bool IsPrivateNetwork(IPAddress ip)
|
||||
{
|
||||
// 10.0.0.0/8
|
||||
// 172.16.0.0/12
|
||||
// 192.168.0.0/16
|
||||
// 169.254.0.0/16
|
||||
// 100.64.0.0/10 RFC 6598
|
||||
|
||||
if ( ip.AddressFamily == AddressFamily.InterNetworkV6 )
|
||||
return false;
|
||||
if (ip.AddressFamily == AddressFamily.InterNetworkV6)
|
||||
return false;
|
||||
|
||||
if ( Utility.IPMatch( "192.168.*", ip ) )
|
||||
return true;
|
||||
if ( Utility.IPMatch( "10.*", ip ) )
|
||||
return true;
|
||||
if ( Utility.IPMatch( "172.16-31.*", ip ) )
|
||||
return true;
|
||||
if ( Utility.IPMatch( "169.254.*", ip ) )
|
||||
return true;
|
||||
if ( Utility.IPMatch( "100.64-127.*", ip ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (Utility.IPMatch("192.168.*", ip))
|
||||
return true;
|
||||
if (Utility.IPMatch("10.*", ip))
|
||||
return true;
|
||||
if (Utility.IPMatch("172.16-31.*", ip))
|
||||
return true;
|
||||
if (Utility.IPMatch("169.254.*", ip))
|
||||
return true;
|
||||
if (Utility.IPMatch("100.64-127.*", ip))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static IPAddress FindPublicAddress()
|
||||
{
|
||||
try {
|
||||
WebRequest req = WebRequest.Create( "https://api.ipify.org" );
|
||||
private static IPAddress FindPublicAddress()
|
||||
{
|
||||
try
|
||||
{
|
||||
WebRequest req = WebRequest.Create("https://api.ipify.org");
|
||||
|
||||
req.Timeout = 15000;
|
||||
req.Timeout = 15000;
|
||||
|
||||
WebResponse res = req.GetResponse();
|
||||
WebResponse res = req.GetResponse();
|
||||
|
||||
Stream s = res.GetResponseStream();
|
||||
Stream s = res.GetResponseStream();
|
||||
|
||||
StreamReader sr = new StreamReader( s );
|
||||
StreamReader sr = new StreamReader(s);
|
||||
|
||||
IPAddress ip = IPAddress.Parse( sr.ReadLine() );
|
||||
IPAddress ip = IPAddress.Parse(sr.ReadLine());
|
||||
|
||||
sr.Close();
|
||||
s.Close();
|
||||
res.Close();
|
||||
sr.Close();
|
||||
s.Close();
|
||||
res.Close();
|
||||
|
||||
return ip;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -2,84 +2,84 @@ using System.IO;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public class ShrinkTable
|
||||
{
|
||||
public const int DefaultItemID = 0x1870; // Yellow virtue stone
|
||||
public class ShrinkTable
|
||||
{
|
||||
public const int DefaultItemID = 0x1870; // Yellow virtue stone
|
||||
|
||||
private static int[] m_Table;
|
||||
private static int[] m_Table;
|
||||
|
||||
public static int Lookup( Mobile m )
|
||||
{
|
||||
return Lookup( m.Body.BodyID, DefaultItemID );
|
||||
}
|
||||
public static int Lookup(Mobile m)
|
||||
{
|
||||
return Lookup(m.Body.BodyID, DefaultItemID);
|
||||
}
|
||||
|
||||
public static int Lookup( int body )
|
||||
{
|
||||
return Lookup( body, DefaultItemID );
|
||||
}
|
||||
public static int Lookup(int body)
|
||||
{
|
||||
return Lookup(body, DefaultItemID);
|
||||
}
|
||||
|
||||
public static int Lookup( Mobile m, int defaultValue )
|
||||
{
|
||||
return Lookup( m.Body.BodyID, defaultValue );
|
||||
}
|
||||
public static int Lookup(Mobile m, int defaultValue)
|
||||
{
|
||||
return Lookup(m.Body.BodyID, defaultValue);
|
||||
}
|
||||
|
||||
public static int Lookup( int body, int defaultValue )
|
||||
{
|
||||
if ( m_Table == null )
|
||||
Load();
|
||||
public static int Lookup(int body, int defaultValue)
|
||||
{
|
||||
if (m_Table == null)
|
||||
Load();
|
||||
|
||||
int val = 0;
|
||||
int val = 0;
|
||||
|
||||
if ( body >= 0 && body < m_Table.Length )
|
||||
val = m_Table[body];
|
||||
if (body >= 0 && body < m_Table.Length)
|
||||
val = m_Table[body];
|
||||
|
||||
if ( val == 0 )
|
||||
val = defaultValue;
|
||||
if (val == 0)
|
||||
val = defaultValue;
|
||||
|
||||
return val;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
private static void Load()
|
||||
{
|
||||
string path = Path.Combine( Core.BaseDirectory, "Data/shrink.cfg" );
|
||||
private static void Load()
|
||||
{
|
||||
string path = Path.Combine(Core.BaseDirectory, "Data/shrink.cfg");
|
||||
|
||||
if ( !File.Exists( path ) )
|
||||
{
|
||||
m_Table = new int[0];
|
||||
return;
|
||||
}
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
m_Table = new int[0];
|
||||
return;
|
||||
}
|
||||
|
||||
m_Table = new int[1000];
|
||||
m_Table = new int[1000];
|
||||
|
||||
using ( StreamReader ip = new StreamReader( path ) )
|
||||
{
|
||||
string line;
|
||||
using (StreamReader ip = new StreamReader(path))
|
||||
{
|
||||
string line;
|
||||
|
||||
while ( (line = ip.ReadLine()) != null )
|
||||
{
|
||||
line = line.Trim();
|
||||
while ((line = ip.ReadLine()) != null)
|
||||
{
|
||||
line = line.Trim();
|
||||
|
||||
if ( line.Length == 0 || line.StartsWith( "#" ) )
|
||||
continue;
|
||||
if (line.Length == 0 || line.StartsWith("#"))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
string[] split = line.Split( '\t' );
|
||||
try
|
||||
{
|
||||
string[] split = line.Split('\t');
|
||||
|
||||
if ( split.Length >= 2 )
|
||||
{
|
||||
int body = Utility.ToInt32( split[0] );
|
||||
int item = Utility.ToInt32( split[1] );
|
||||
if (split.Length >= 2)
|
||||
{
|
||||
int body = Utility.ToInt32(split[0]);
|
||||
int item = Utility.ToInt32(split[1]);
|
||||
|
||||
if ( body >= 0 && body < m_Table.Length )
|
||||
m_Table[body] = item;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (body >= 0 && body < m_Table.Length)
|
||||
m_Table[body] = item;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,386 +1,402 @@
|
|||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Factions;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class SkillCheck
|
||||
{
|
||||
private static readonly bool AntiMacroCode = !Core.ML; //Change this to false to disable anti-macro code
|
||||
|
||||
public static TimeSpan AntiMacroExpire = TimeSpan.FromMinutes( 5.0 ); //How long do we remember targets/locations?
|
||||
public const int Allowance = 3; //How many times may we use the same location/target for gain
|
||||
private const int LocationSize = 5; //The size of eeach location, make this smaller so players dont have to move as far
|
||||
private static bool[] UseAntiMacro = {
|
||||
// true if this skill uses the anti-macro code, false if it does not
|
||||
false,// Alchemy = 0,
|
||||
true,// Anatomy = 1,
|
||||
true,// AnimalLore = 2,
|
||||
true,// ItemID = 3,
|
||||
true,// ArmsLore = 4,
|
||||
false,// Parry = 5,
|
||||
true,// Begging = 6,
|
||||
false,// Blacksmith = 7,
|
||||
false,// Fletching = 8,
|
||||
true,// Peacemaking = 9,
|
||||
true,// Camping = 10,
|
||||
false,// Carpentry = 11,
|
||||
false,// Cartography = 12,
|
||||
false,// Cooking = 13,
|
||||
true,// DetectHidden = 14,
|
||||
true,// Discordance = 15,
|
||||
true,// EvalInt = 16,
|
||||
true,// Healing = 17,
|
||||
true,// Fishing = 18,
|
||||
true,// Forensics = 19,
|
||||
true,// Herding = 20,
|
||||
true,// Hiding = 21,
|
||||
true,// Provocation = 22,
|
||||
false,// Inscribe = 23,
|
||||
true,// Lockpicking = 24,
|
||||
true,// Magery = 25,
|
||||
true,// MagicResist = 26,
|
||||
false,// Tactics = 27,
|
||||
true,// Snooping = 28,
|
||||
true,// Musicianship = 29,
|
||||
true,// Poisoning = 30,
|
||||
false,// Archery = 31,
|
||||
true,// SpiritSpeak = 32,
|
||||
true,// Stealing = 33,
|
||||
false,// Tailoring = 34,
|
||||
true,// AnimalTaming = 35,
|
||||
true,// TasteID = 36,
|
||||
false,// Tinkering = 37,
|
||||
true,// Tracking = 38,
|
||||
true,// Veterinary = 39,
|
||||
false,// Swords = 40,
|
||||
false,// Macing = 41,
|
||||
false,// Fencing = 42,
|
||||
false,// Wrestling = 43,
|
||||
true,// Lumberjacking = 44,
|
||||
true,// Mining = 45,
|
||||
true,// Meditation = 46,
|
||||
true,// Stealth = 47,
|
||||
true,// RemoveTrap = 48,
|
||||
true,// Necromancy = 49,
|
||||
false,// Focus = 50,
|
||||
true,// Chivalry = 51
|
||||
true,// Bushido = 52
|
||||
true,//Ninjitsu = 53
|
||||
true // Spellweaving
|
||||
};
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Mobile.SkillCheckLocationHandler = Mobile_SkillCheckLocation;
|
||||
Mobile.SkillCheckDirectLocationHandler = Mobile_SkillCheckDirectLocation;
|
||||
|
||||
Mobile.SkillCheckTargetHandler = Mobile_SkillCheckTarget;
|
||||
Mobile.SkillCheckDirectTargetHandler = Mobile_SkillCheckDirectTarget;
|
||||
}
|
||||
|
||||
public static bool Mobile_SkillCheckLocation( Mobile from, SkillName skillName, double minSkill, double maxSkill )
|
||||
{
|
||||
Skill skill = from.Skills[skillName];
|
||||
|
||||
if ( skill == null )
|
||||
return false;
|
||||
|
||||
double value = skill.Value;
|
||||
|
||||
if ( value < minSkill )
|
||||
return false; // Too difficult
|
||||
if ( value >= maxSkill )
|
||||
return true; // No challenge
|
||||
|
||||
double chance = (value - minSkill) / (maxSkill - minSkill);
|
||||
|
||||
Point2D loc = new Point2D( from.Location.X / LocationSize, from.Location.Y / LocationSize );
|
||||
return CheckSkill( from, skill, loc, chance );
|
||||
}
|
||||
|
||||
public static bool Mobile_SkillCheckDirectLocation( Mobile from, SkillName skillName, double chance )
|
||||
{
|
||||
Skill skill = from.Skills[skillName];
|
||||
|
||||
if ( skill == null )
|
||||
return false;
|
||||
|
||||
if ( chance < 0.0 )
|
||||
return false; // Too difficult
|
||||
if ( chance >= 1.0 )
|
||||
return true; // No challenge
|
||||
|
||||
Point2D loc = new Point2D( from.Location.X / LocationSize, from.Location.Y / LocationSize );
|
||||
return CheckSkill( from, skill, loc, chance );
|
||||
}
|
||||
|
||||
public static bool CheckSkill( Mobile from, Skill skill, object amObj, double chance )
|
||||
{
|
||||
if ( from.Skills.Cap == 0 )
|
||||
return false;
|
||||
|
||||
bool success = ( chance >= Utility.RandomDouble() );
|
||||
double gc = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;
|
||||
gc += ( skill.Cap - skill.Base ) / skill.Cap;
|
||||
gc /= 2;
|
||||
|
||||
gc += ( 1.0 - chance ) * ( success ? 0.5 : (Core.AOS ? 0.0 : 0.2) );
|
||||
gc /= 2;
|
||||
|
||||
gc *= skill.Info.GainFactor;
|
||||
|
||||
if ( gc < 0.01 )
|
||||
gc = 0.01;
|
||||
|
||||
if ( from is BaseCreature creature && creature.Controlled )
|
||||
gc *= 2;
|
||||
|
||||
if ( from.Alive && ( ( gc >= Utility.RandomDouble() && AllowGain( from, skill, amObj ) ) || skill.Base < 10.0 ) )
|
||||
Gain( from, skill );
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public static bool Mobile_SkillCheckTarget( Mobile from, SkillName skillName, object target, double minSkill, double maxSkill )
|
||||
{
|
||||
Skill skill = from.Skills[skillName];
|
||||
|
||||
if ( skill == null )
|
||||
return false;
|
||||
|
||||
double value = skill.Value;
|
||||
|
||||
if ( value < minSkill )
|
||||
return false; // Too difficult
|
||||
if ( value >= maxSkill )
|
||||
return true; // No challenge
|
||||
|
||||
double chance = (value - minSkill) / (maxSkill - minSkill);
|
||||
|
||||
return CheckSkill( from, skill, target, chance );
|
||||
}
|
||||
public class SkillCheck
|
||||
{
|
||||
public enum Stat
|
||||
{
|
||||
Str,
|
||||
Dex,
|
||||
Int
|
||||
}
|
||||
|
||||
public const int Allowance = 3; //How many times may we use the same location/target for gain
|
||||
|
||||
private const int
|
||||
LocationSize = 5; //The size of eeach location, make this smaller so players dont have to move as far
|
||||
|
||||
private static readonly bool AntiMacroCode = !Core.ML; //Change this to false to disable anti-macro code
|
||||
|
||||
public static TimeSpan AntiMacroExpire = TimeSpan.FromMinutes(5.0); //How long do we remember targets/locations?
|
||||
|
||||
private static bool[] UseAntiMacro =
|
||||
{
|
||||
// true if this skill uses the anti-macro code, false if it does not
|
||||
false, // Alchemy = 0,
|
||||
true, // Anatomy = 1,
|
||||
true, // AnimalLore = 2,
|
||||
true, // ItemID = 3,
|
||||
true, // ArmsLore = 4,
|
||||
false, // Parry = 5,
|
||||
true, // Begging = 6,
|
||||
false, // Blacksmith = 7,
|
||||
false, // Fletching = 8,
|
||||
true, // Peacemaking = 9,
|
||||
true, // Camping = 10,
|
||||
false, // Carpentry = 11,
|
||||
false, // Cartography = 12,
|
||||
false, // Cooking = 13,
|
||||
true, // DetectHidden = 14,
|
||||
true, // Discordance = 15,
|
||||
true, // EvalInt = 16,
|
||||
true, // Healing = 17,
|
||||
true, // Fishing = 18,
|
||||
true, // Forensics = 19,
|
||||
true, // Herding = 20,
|
||||
true, // Hiding = 21,
|
||||
true, // Provocation = 22,
|
||||
false, // Inscribe = 23,
|
||||
true, // Lockpicking = 24,
|
||||
true, // Magery = 25,
|
||||
true, // MagicResist = 26,
|
||||
false, // Tactics = 27,
|
||||
true, // Snooping = 28,
|
||||
true, // Musicianship = 29,
|
||||
true, // Poisoning = 30,
|
||||
false, // Archery = 31,
|
||||
true, // SpiritSpeak = 32,
|
||||
true, // Stealing = 33,
|
||||
false, // Tailoring = 34,
|
||||
true, // AnimalTaming = 35,
|
||||
true, // TasteID = 36,
|
||||
false, // Tinkering = 37,
|
||||
true, // Tracking = 38,
|
||||
true, // Veterinary = 39,
|
||||
false, // Swords = 40,
|
||||
false, // Macing = 41,
|
||||
false, // Fencing = 42,
|
||||
false, // Wrestling = 43,
|
||||
true, // Lumberjacking = 44,
|
||||
true, // Mining = 45,
|
||||
true, // Meditation = 46,
|
||||
true, // Stealth = 47,
|
||||
true, // RemoveTrap = 48,
|
||||
true, // Necromancy = 49,
|
||||
false, // Focus = 50,
|
||||
true, // Chivalry = 51
|
||||
true, // Bushido = 52
|
||||
true, //Ninjitsu = 53
|
||||
true // Spellweaving
|
||||
};
|
||||
|
||||
private static TimeSpan m_StatGainDelay = TimeSpan.FromMinutes(Core.ML ? 0.05 : 15);
|
||||
private static TimeSpan m_PetStatGainDelay = TimeSpan.FromMinutes(5.0);
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Mobile.SkillCheckLocationHandler = Mobile_SkillCheckLocation;
|
||||
Mobile.SkillCheckDirectLocationHandler = Mobile_SkillCheckDirectLocation;
|
||||
|
||||
Mobile.SkillCheckTargetHandler = Mobile_SkillCheckTarget;
|
||||
Mobile.SkillCheckDirectTargetHandler = Mobile_SkillCheckDirectTarget;
|
||||
}
|
||||
|
||||
public static bool Mobile_SkillCheckLocation(Mobile from, SkillName skillName, double minSkill, double maxSkill)
|
||||
{
|
||||
Skill skill = from.Skills[skillName];
|
||||
|
||||
if (skill == null)
|
||||
return false;
|
||||
|
||||
double value = skill.Value;
|
||||
|
||||
if (value < minSkill)
|
||||
return false; // Too difficult
|
||||
if (value >= maxSkill)
|
||||
return true; // No challenge
|
||||
|
||||
double chance = (value - minSkill) / (maxSkill - minSkill);
|
||||
|
||||
Point2D loc = new Point2D(from.Location.X / LocationSize, from.Location.Y / LocationSize);
|
||||
return CheckSkill(from, skill, loc, chance);
|
||||
}
|
||||
|
||||
public static bool Mobile_SkillCheckDirectLocation(Mobile from, SkillName skillName, double chance)
|
||||
{
|
||||
Skill skill = from.Skills[skillName];
|
||||
|
||||
if (skill == null)
|
||||
return false;
|
||||
|
||||
if (chance < 0.0)
|
||||
return false; // Too difficult
|
||||
if (chance >= 1.0)
|
||||
return true; // No challenge
|
||||
|
||||
Point2D loc = new Point2D(from.Location.X / LocationSize, from.Location.Y / LocationSize);
|
||||
return CheckSkill(from, skill, loc, chance);
|
||||
}
|
||||
|
||||
public static bool CheckSkill(Mobile from, Skill skill, object amObj, double chance)
|
||||
{
|
||||
if (from.Skills.Cap == 0)
|
||||
return false;
|
||||
|
||||
bool success = chance >= Utility.RandomDouble();
|
||||
double gc = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;
|
||||
gc += (skill.Cap - skill.Base) / skill.Cap;
|
||||
gc /= 2;
|
||||
|
||||
gc += (1.0 - chance) * (success ? 0.5 : Core.AOS ? 0.0 : 0.2);
|
||||
gc /= 2;
|
||||
|
||||
gc *= skill.Info.GainFactor;
|
||||
|
||||
if (gc < 0.01)
|
||||
gc = 0.01;
|
||||
|
||||
if (from is BaseCreature creature && creature.Controlled)
|
||||
gc *= 2;
|
||||
|
||||
if (from.Alive && (gc >= Utility.RandomDouble() && AllowGain(from, skill, amObj) || skill.Base < 10.0))
|
||||
Gain(from, skill);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public static bool Mobile_SkillCheckTarget(Mobile from, SkillName skillName, object target, double minSkill,
|
||||
double maxSkill)
|
||||
{
|
||||
Skill skill = from.Skills[skillName];
|
||||
|
||||
if (skill == null)
|
||||
return false;
|
||||
|
||||
double value = skill.Value;
|
||||
|
||||
if (value < minSkill)
|
||||
return false; // Too difficult
|
||||
if (value >= maxSkill)
|
||||
return true; // No challenge
|
||||
|
||||
public static bool Mobile_SkillCheckDirectTarget( Mobile from, SkillName skillName, object target, double chance )
|
||||
{
|
||||
Skill skill = from.Skills[skillName];
|
||||
double chance = (value - minSkill) / (maxSkill - minSkill);
|
||||
|
||||
if ( skill == null )
|
||||
return false;
|
||||
return CheckSkill(from, skill, target, chance);
|
||||
}
|
||||
|
||||
if ( chance < 0.0 )
|
||||
return false; // Too difficult
|
||||
if ( chance >= 1.0 )
|
||||
return true; // No challenge
|
||||
public static bool Mobile_SkillCheckDirectTarget(Mobile from, SkillName skillName, object target, double chance)
|
||||
{
|
||||
Skill skill = from.Skills[skillName];
|
||||
|
||||
return CheckSkill( from, skill, target, chance );
|
||||
}
|
||||
if (skill == null)
|
||||
return false;
|
||||
|
||||
private static bool AllowGain( Mobile from, Skill skill, object obj )
|
||||
{
|
||||
if ( Core.AOS && Faction.InSkillLoss( from ) ) //Changed some time between the introduction of AoS and SE.
|
||||
return false;
|
||||
if (chance < 0.0)
|
||||
return false; // Too difficult
|
||||
if (chance >= 1.0)
|
||||
return true; // No challenge
|
||||
|
||||
if ( AntiMacroCode && from is PlayerMobile mobile && UseAntiMacro[skill.Info.SkillID] )
|
||||
return mobile.AntiMacroCheck( skill, obj );
|
||||
return CheckSkill(from, skill, target, chance);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum Stat { Str, Dex, Int }
|
||||
|
||||
public static void Gain( Mobile from, Skill skill )
|
||||
{
|
||||
if ( from.Region.IsPartOf( typeof( Regions.Jail ) ) )
|
||||
return;
|
||||
|
||||
if ( from is BaseCreature creature && creature.IsDeadPet )
|
||||
return;
|
||||
|
||||
if ( skill.SkillName == SkillName.Focus && from is BaseCreature )
|
||||
return;
|
||||
|
||||
if ( skill.Base < skill.Cap && skill.Lock == SkillLock.Up )
|
||||
{
|
||||
int toGain = 1;
|
||||
|
||||
if ( skill.Base <= 10.0 )
|
||||
toGain = Utility.Random( 4 ) + 1;
|
||||
|
||||
Skills skills = from.Skills;
|
||||
|
||||
if ( from.Player && ( skills.Total / skills.Cap ) >= Utility.RandomDouble() )//( skills.Total >= skills.Cap )
|
||||
{
|
||||
for ( int i = 0; i < skills.Length; ++i )
|
||||
{
|
||||
Skill toLower = skills[i];
|
||||
|
||||
if ( toLower != skill && toLower.Lock == SkillLock.Down && toLower.BaseFixedPoint >= toGain )
|
||||
{
|
||||
toLower.BaseFixedPoint -= toGain;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Scroll of Alacrity
|
||||
|
||||
if ( from is PlayerMobile pm && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.UtcNow )
|
||||
toGain *= Utility.RandomMinMax(2, 5);
|
||||
#endregion
|
||||
|
||||
if ( !from.Player || (skills.Total + toGain) <= skills.Cap )
|
||||
{
|
||||
skill.BaseFixedPoint += toGain;
|
||||
}
|
||||
}
|
||||
|
||||
if ( skill.Lock == SkillLock.Up )
|
||||
{
|
||||
SkillInfo info = skill.Info;
|
||||
|
||||
if ( from.StrLock == StatLockType.Up && (info.StrGain / 33.3) > Utility.RandomDouble() )
|
||||
GainStat( from, Stat.Str );
|
||||
else if ( from.DexLock == StatLockType.Up && (info.DexGain / 33.3) > Utility.RandomDouble() )
|
||||
GainStat( from, Stat.Dex );
|
||||
else if ( from.IntLock == StatLockType.Up && (info.IntGain / 33.3) > Utility.RandomDouble() )
|
||||
GainStat( from, Stat.Int );
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CanLower( Mobile from, Stat stat )
|
||||
{
|
||||
switch ( stat )
|
||||
{
|
||||
case Stat.Str: return ( from.StrLock == StatLockType.Down && from.RawStr > 10 );
|
||||
case Stat.Dex: return ( from.DexLock == StatLockType.Down && from.RawDex > 10 );
|
||||
case Stat.Int: return ( from.IntLock == StatLockType.Down && from.RawInt > 10 );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CanRaise( Mobile from, Stat stat )
|
||||
{
|
||||
if ( !(from is BaseCreature creature && creature.Controlled) )
|
||||
{
|
||||
if ( from.RawStatTotal >= from.StatCap )
|
||||
return false;
|
||||
}
|
||||
|
||||
switch ( stat )
|
||||
{
|
||||
case Stat.Str: return ( from.StrLock == StatLockType.Up && from.RawStr < 125 );
|
||||
case Stat.Dex: return ( from.DexLock == StatLockType.Up && from.RawDex < 125 );
|
||||
case Stat.Int: return ( from.IntLock == StatLockType.Up && from.RawInt < 125 );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void IncreaseStat( Mobile from, Stat stat, bool atrophy )
|
||||
{
|
||||
atrophy = atrophy || (from.RawStatTotal >= from.StatCap);
|
||||
|
||||
switch ( stat )
|
||||
{
|
||||
case Stat.Str:
|
||||
{
|
||||
if ( atrophy )
|
||||
{
|
||||
if ( CanLower( from, Stat.Dex ) && (from.RawDex < from.RawInt || !CanLower( from, Stat.Int )) )
|
||||
--from.RawDex;
|
||||
else if ( CanLower( from, Stat.Int ) )
|
||||
--from.RawInt;
|
||||
}
|
||||
|
||||
if ( CanRaise( from, Stat.Str ) )
|
||||
++from.RawStr;
|
||||
|
||||
break;
|
||||
}
|
||||
case Stat.Dex:
|
||||
{
|
||||
if ( atrophy )
|
||||
{
|
||||
if ( CanLower( from, Stat.Str ) && (from.RawStr < from.RawInt || !CanLower( from, Stat.Int )) )
|
||||
--from.RawStr;
|
||||
else if ( CanLower( from, Stat.Int ) )
|
||||
--from.RawInt;
|
||||
}
|
||||
|
||||
if ( CanRaise( from, Stat.Dex ) )
|
||||
++from.RawDex;
|
||||
|
||||
break;
|
||||
}
|
||||
case Stat.Int:
|
||||
{
|
||||
if ( atrophy )
|
||||
{
|
||||
if ( CanLower( from, Stat.Str ) && (from.RawStr < from.RawDex || !CanLower( from, Stat.Dex )) )
|
||||
--from.RawStr;
|
||||
else if ( CanLower( from, Stat.Dex ) )
|
||||
--from.RawDex;
|
||||
}
|
||||
|
||||
if ( CanRaise( from, Stat.Int ) )
|
||||
++from.RawInt;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static TimeSpan m_StatGainDelay = TimeSpan.FromMinutes( ( Core.ML ) ? 0.05 : 15 );
|
||||
private static TimeSpan m_PetStatGainDelay = TimeSpan.FromMinutes( 5.0 );
|
||||
|
||||
public static void GainStat( Mobile from, Stat stat )
|
||||
{
|
||||
switch( stat )
|
||||
{
|
||||
case Stat.Str:
|
||||
{
|
||||
if ( from is BaseCreature creature && creature.Controlled ) {
|
||||
if ( (creature.LastStrGain + m_PetStatGainDelay) >= DateTime.UtcNow )
|
||||
return;
|
||||
}
|
||||
else if ( (from.LastStrGain + m_StatGainDelay) >= DateTime.UtcNow )
|
||||
return;
|
||||
|
||||
from.LastStrGain = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
case Stat.Dex:
|
||||
{
|
||||
if ( from is BaseCreature creature && creature.Controlled ) {
|
||||
if ( (creature.LastDexGain + m_PetStatGainDelay) >= DateTime.UtcNow )
|
||||
return;
|
||||
}
|
||||
else if ( (from.LastDexGain + m_StatGainDelay) >= DateTime.UtcNow )
|
||||
return;
|
||||
|
||||
from.LastDexGain = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
case Stat.Int:
|
||||
{
|
||||
if ( from is BaseCreature creature && creature.Controlled ) {
|
||||
if ( (creature.LastIntGain + m_PetStatGainDelay) >= DateTime.UtcNow )
|
||||
return;
|
||||
}
|
||||
|
||||
else if ( (from.LastIntGain + m_StatGainDelay) >= DateTime.UtcNow )
|
||||
return;
|
||||
|
||||
from.LastIntGain = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool atrophy = ( (from.RawStatTotal / (double)from.StatCap) >= Utility.RandomDouble() );
|
||||
|
||||
IncreaseStat( from, stat, atrophy );
|
||||
}
|
||||
}
|
||||
}
|
||||
private static bool AllowGain(Mobile from, Skill skill, object obj)
|
||||
{
|
||||
if (Core.AOS && Faction.InSkillLoss(from)) //Changed some time between the introduction of AoS and SE.
|
||||
return false;
|
||||
|
||||
if (AntiMacroCode && from is PlayerMobile mobile && UseAntiMacro[skill.Info.SkillID])
|
||||
return mobile.AntiMacroCheck(skill, obj);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Gain(Mobile from, Skill skill)
|
||||
{
|
||||
if (from.Region.IsPartOf(typeof(Jail)))
|
||||
return;
|
||||
|
||||
if (from is BaseCreature creature && creature.IsDeadPet)
|
||||
return;
|
||||
|
||||
if (skill.SkillName == SkillName.Focus && from is BaseCreature)
|
||||
return;
|
||||
|
||||
if (skill.Base < skill.Cap && skill.Lock == SkillLock.Up)
|
||||
{
|
||||
int toGain = 1;
|
||||
|
||||
if (skill.Base <= 10.0)
|
||||
toGain = Utility.Random(4) + 1;
|
||||
|
||||
Skills skills = from.Skills;
|
||||
|
||||
if (from.Player && skills.Total / skills.Cap >= Utility.RandomDouble()) //( skills.Total >= skills.Cap )
|
||||
for (int i = 0; i < skills.Length; ++i)
|
||||
{
|
||||
Skill toLower = skills[i];
|
||||
|
||||
if (toLower != skill && toLower.Lock == SkillLock.Down && toLower.BaseFixedPoint >= toGain)
|
||||
{
|
||||
toLower.BaseFixedPoint -= toGain;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region Scroll of Alacrity
|
||||
|
||||
if (from is PlayerMobile pm && skill.SkillName == pm.AcceleratedSkill &&
|
||||
pm.AcceleratedStart > DateTime.UtcNow)
|
||||
toGain *= Utility.RandomMinMax(2, 5);
|
||||
|
||||
#endregion
|
||||
|
||||
if (!from.Player || skills.Total + toGain <= skills.Cap) skill.BaseFixedPoint += toGain;
|
||||
}
|
||||
|
||||
if (skill.Lock == SkillLock.Up)
|
||||
{
|
||||
SkillInfo info = skill.Info;
|
||||
|
||||
if (from.StrLock == StatLockType.Up && info.StrGain / 33.3 > Utility.RandomDouble())
|
||||
GainStat(from, Stat.Str);
|
||||
else if (from.DexLock == StatLockType.Up && info.DexGain / 33.3 > Utility.RandomDouble())
|
||||
GainStat(from, Stat.Dex);
|
||||
else if (from.IntLock == StatLockType.Up && info.IntGain / 33.3 > Utility.RandomDouble())
|
||||
GainStat(from, Stat.Int);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CanLower(Mobile from, Stat stat)
|
||||
{
|
||||
switch (stat)
|
||||
{
|
||||
case Stat.Str: return from.StrLock == StatLockType.Down && from.RawStr > 10;
|
||||
case Stat.Dex: return from.DexLock == StatLockType.Down && from.RawDex > 10;
|
||||
case Stat.Int: return from.IntLock == StatLockType.Down && from.RawInt > 10;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CanRaise(Mobile from, Stat stat)
|
||||
{
|
||||
if (!(from is BaseCreature creature && creature.Controlled))
|
||||
if (from.RawStatTotal >= from.StatCap)
|
||||
return false;
|
||||
|
||||
switch (stat)
|
||||
{
|
||||
case Stat.Str: return from.StrLock == StatLockType.Up && from.RawStr < 125;
|
||||
case Stat.Dex: return from.DexLock == StatLockType.Up && from.RawDex < 125;
|
||||
case Stat.Int: return from.IntLock == StatLockType.Up && from.RawInt < 125;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void IncreaseStat(Mobile from, Stat stat, bool atrophy)
|
||||
{
|
||||
atrophy = atrophy || from.RawStatTotal >= from.StatCap;
|
||||
|
||||
switch (stat)
|
||||
{
|
||||
case Stat.Str:
|
||||
{
|
||||
if (atrophy)
|
||||
{
|
||||
if (CanLower(from, Stat.Dex) && (from.RawDex < from.RawInt || !CanLower(from, Stat.Int)))
|
||||
--from.RawDex;
|
||||
else if (CanLower(from, Stat.Int))
|
||||
--from.RawInt;
|
||||
}
|
||||
|
||||
if (CanRaise(from, Stat.Str))
|
||||
++from.RawStr;
|
||||
|
||||
break;
|
||||
}
|
||||
case Stat.Dex:
|
||||
{
|
||||
if (atrophy)
|
||||
{
|
||||
if (CanLower(from, Stat.Str) && (from.RawStr < from.RawInt || !CanLower(from, Stat.Int)))
|
||||
--from.RawStr;
|
||||
else if (CanLower(from, Stat.Int))
|
||||
--from.RawInt;
|
||||
}
|
||||
|
||||
if (CanRaise(from, Stat.Dex))
|
||||
++from.RawDex;
|
||||
|
||||
break;
|
||||
}
|
||||
case Stat.Int:
|
||||
{
|
||||
if (atrophy)
|
||||
{
|
||||
if (CanLower(from, Stat.Str) && (from.RawStr < from.RawDex || !CanLower(from, Stat.Dex)))
|
||||
--from.RawStr;
|
||||
else if (CanLower(from, Stat.Dex))
|
||||
--from.RawDex;
|
||||
}
|
||||
|
||||
if (CanRaise(from, Stat.Int))
|
||||
++from.RawInt;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GainStat(Mobile from, Stat stat)
|
||||
{
|
||||
switch (stat)
|
||||
{
|
||||
case Stat.Str:
|
||||
{
|
||||
if (from is BaseCreature creature && creature.Controlled)
|
||||
{
|
||||
if (creature.LastStrGain + m_PetStatGainDelay >= DateTime.UtcNow)
|
||||
return;
|
||||
}
|
||||
else if (from.LastStrGain + m_StatGainDelay >= DateTime.UtcNow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
from.LastStrGain = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
case Stat.Dex:
|
||||
{
|
||||
if (from is BaseCreature creature && creature.Controlled)
|
||||
{
|
||||
if (creature.LastDexGain + m_PetStatGainDelay >= DateTime.UtcNow)
|
||||
return;
|
||||
}
|
||||
else if (from.LastDexGain + m_StatGainDelay >= DateTime.UtcNow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
from.LastDexGain = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
case Stat.Int:
|
||||
{
|
||||
if (from is BaseCreature creature && creature.Controlled)
|
||||
{
|
||||
if (creature.LastIntGain + m_PetStatGainDelay >= DateTime.UtcNow)
|
||||
return;
|
||||
}
|
||||
|
||||
else if (from.LastIntGain + m_StatGainDelay >= DateTime.UtcNow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
from.LastIntGain = DateTime.UtcNow;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool atrophy = from.RawStatTotal / (double)from.StatCap >= Utility.RandomDouble();
|
||||
|
||||
IncreaseStat(from, stat, atrophy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,35 +4,36 @@ using Server.Network;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public class SocketOptions
|
||||
{
|
||||
private const bool NagleEnabled = false; // Should the Nagle algorithm be enabled? This may reduce performance
|
||||
private const int CoalesceBufferSize = 512; // MSS that the core will use when buffering packets
|
||||
public class SocketOptions
|
||||
{
|
||||
private const bool NagleEnabled = false; // Should the Nagle algorithm be enabled? This may reduce performance
|
||||
private const int CoalesceBufferSize = 512; // MSS that the core will use when buffering packets
|
||||
|
||||
private static IPEndPoint[] m_ListenerEndPoints = {
|
||||
new IPEndPoint( IPAddress.Any, 2593 ), // Default: Listen on port 2593 on all IP addresses
|
||||
|
||||
// Examples:
|
||||
// new IPEndPoint( IPAddress.Any, 80 ), // Listen on port 80 on all IP addresses
|
||||
// new IPEndPoint( IPAddress.Parse( "1.2.3.4" ), 2593 ), // Listen on port 2593 on IP address 1.2.3.4
|
||||
};
|
||||
private static IPEndPoint[] m_ListenerEndPoints =
|
||||
{
|
||||
new IPEndPoint(IPAddress.Any, 2593) // Default: Listen on port 2593 on all IP addresses
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
SendQueue.CoalesceBufferSize = CoalesceBufferSize;
|
||||
// Examples:
|
||||
// new IPEndPoint( IPAddress.Any, 80 ), // Listen on port 80 on all IP addresses
|
||||
// new IPEndPoint( IPAddress.Parse( "1.2.3.4" ), 2593 ), // Listen on port 2593 on IP address 1.2.3.4
|
||||
};
|
||||
|
||||
EventSink.SocketConnect += EventSink_SocketConnect;
|
||||
public static void Initialize()
|
||||
{
|
||||
SendQueue.CoalesceBufferSize = CoalesceBufferSize;
|
||||
|
||||
Listener.EndPoints = m_ListenerEndPoints;
|
||||
}
|
||||
EventSink.SocketConnect += EventSink_SocketConnect;
|
||||
|
||||
private static void EventSink_SocketConnect( SocketConnectEventArgs e )
|
||||
{
|
||||
if ( !e.AllowConnection )
|
||||
return;
|
||||
Listener.EndPoints = m_ListenerEndPoints;
|
||||
}
|
||||
|
||||
if ( !NagleEnabled )
|
||||
e.Socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1 ); // RunUO uses its own algorithm
|
||||
}
|
||||
}
|
||||
private static void EventSink_SocketConnect(SocketConnectEventArgs e)
|
||||
{
|
||||
if (!e.AllowConnection)
|
||||
return;
|
||||
|
||||
if (!NagleEnabled)
|
||||
e.Socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1); // RunUO uses its own algorithm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,217 +1,219 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[Parsable]
|
||||
public class TextDefinition
|
||||
{
|
||||
public int Number { get; }
|
||||
[Parsable]
|
||||
public class TextDefinition
|
||||
{
|
||||
public TextDefinition() : this(0, null)
|
||||
{
|
||||
}
|
||||
|
||||
public string String { get; }
|
||||
public TextDefinition(int number) : this(number, null)
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsEmpty => ( Number <= 0 && String == null );
|
||||
public TextDefinition(string text) : this(0, text)
|
||||
{
|
||||
}
|
||||
|
||||
public TextDefinition() : this( 0, null )
|
||||
{
|
||||
}
|
||||
public TextDefinition(int number, string text)
|
||||
{
|
||||
Number = number;
|
||||
String = text;
|
||||
}
|
||||
|
||||
public TextDefinition( int number ) : this( number, null )
|
||||
{
|
||||
}
|
||||
public int Number{ get; }
|
||||
|
||||
public TextDefinition( string text ) : this( 0, text )
|
||||
{
|
||||
}
|
||||
public string String{ get; }
|
||||
|
||||
public TextDefinition( int number, string text )
|
||||
{
|
||||
Number = number;
|
||||
String = text;
|
||||
}
|
||||
public bool IsEmpty => Number <= 0 && String == null;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if ( Number > 0 )
|
||||
return string.Concat( "#", Number.ToString() );
|
||||
if ( String != null )
|
||||
return String;
|
||||
public override string ToString()
|
||||
{
|
||||
if (Number > 0)
|
||||
return string.Concat("#", Number.ToString());
|
||||
if (String != null)
|
||||
return String;
|
||||
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public string Format( bool propsGump )
|
||||
{
|
||||
if ( Number > 0 )
|
||||
return string.Format( "{0} (0x{0:X})", Number );
|
||||
if ( String != null )
|
||||
return $"\"{String}\"";
|
||||
public string Format(bool propsGump)
|
||||
{
|
||||
if (Number > 0)
|
||||
return string.Format("{0} (0x{0:X})", Number);
|
||||
if (String != null)
|
||||
return $"\"{String}\"";
|
||||
|
||||
return propsGump ? "-empty-" : "empty";
|
||||
}
|
||||
return propsGump ? "-empty-" : "empty";
|
||||
}
|
||||
|
||||
public string GetValue()
|
||||
{
|
||||
if ( Number > 0 )
|
||||
return Number.ToString();
|
||||
if ( String != null )
|
||||
return String;
|
||||
public string GetValue()
|
||||
{
|
||||
if (Number > 0)
|
||||
return Number.ToString();
|
||||
if (String != null)
|
||||
return String;
|
||||
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void Serialize( GenericWriter writer, TextDefinition def )
|
||||
{
|
||||
if ( def == null )
|
||||
{
|
||||
writer.WriteEncodedInt( 3 );
|
||||
}
|
||||
else if ( def.Number > 0 )
|
||||
{
|
||||
writer.WriteEncodedInt( 1 );
|
||||
writer.WriteEncodedInt( def.Number );
|
||||
}
|
||||
else if ( def.String != null )
|
||||
{
|
||||
writer.WriteEncodedInt( 2 );
|
||||
writer.Write( def.String );
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteEncodedInt( 0 );
|
||||
}
|
||||
}
|
||||
public static void Serialize(GenericWriter writer, TextDefinition def)
|
||||
{
|
||||
if (def == null)
|
||||
{
|
||||
writer.WriteEncodedInt(3);
|
||||
}
|
||||
else if (def.Number > 0)
|
||||
{
|
||||
writer.WriteEncodedInt(1);
|
||||
writer.WriteEncodedInt(def.Number);
|
||||
}
|
||||
else if (def.String != null)
|
||||
{
|
||||
writer.WriteEncodedInt(2);
|
||||
writer.Write(def.String);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteEncodedInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static TextDefinition Deserialize( GenericReader reader )
|
||||
{
|
||||
int type = reader.ReadEncodedInt();
|
||||
public static TextDefinition Deserialize(GenericReader reader)
|
||||
{
|
||||
int type = reader.ReadEncodedInt();
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case 0: return new TextDefinition();
|
||||
case 1: return new TextDefinition( reader.ReadEncodedInt() );
|
||||
case 2: return new TextDefinition( reader.ReadString() );
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case 0: return new TextDefinition();
|
||||
case 1: return new TextDefinition(reader.ReadEncodedInt());
|
||||
case 2: return new TextDefinition(reader.ReadString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void AddTo( ObjectPropertyList list, TextDefinition def )
|
||||
{
|
||||
if ( def == null )
|
||||
return;
|
||||
public static void AddTo(ObjectPropertyList list, TextDefinition def)
|
||||
{
|
||||
if (def == null)
|
||||
return;
|
||||
|
||||
if ( def.Number > 0 )
|
||||
list.Add( def.Number );
|
||||
else if ( def.String != null )
|
||||
list.Add( def.String );
|
||||
}
|
||||
if (def.Number > 0)
|
||||
list.Add(def.Number);
|
||||
else if (def.String != null)
|
||||
list.Add(def.String);
|
||||
}
|
||||
|
||||
public static implicit operator TextDefinition( int v )
|
||||
{
|
||||
return new TextDefinition( v );
|
||||
}
|
||||
public static implicit operator TextDefinition(int v)
|
||||
{
|
||||
return new TextDefinition(v);
|
||||
}
|
||||
|
||||
public static implicit operator TextDefinition( string s )
|
||||
{
|
||||
return new TextDefinition( s );
|
||||
}
|
||||
public static implicit operator TextDefinition(string s)
|
||||
{
|
||||
return new TextDefinition(s);
|
||||
}
|
||||
|
||||
public static implicit operator int( TextDefinition m )
|
||||
{
|
||||
if ( m == null )
|
||||
return 0;
|
||||
public static implicit operator int(TextDefinition m)
|
||||
{
|
||||
if (m == null)
|
||||
return 0;
|
||||
|
||||
return m.Number;
|
||||
}
|
||||
return m.Number;
|
||||
}
|
||||
|
||||
public static implicit operator string( TextDefinition m )
|
||||
{
|
||||
return m?.String;
|
||||
}
|
||||
public static implicit operator string(TextDefinition m)
|
||||
{
|
||||
return m?.String;
|
||||
}
|
||||
|
||||
public static void AddHtmlText( Gump g, int x, int y, int width, int height, TextDefinition def, bool back, bool scroll, int numberColor, int stringColor )
|
||||
{
|
||||
if ( def == null )
|
||||
return;
|
||||
public static void AddHtmlText(Gump g, int x, int y, int width, int height, TextDefinition def, bool back,
|
||||
bool scroll, int numberColor, int stringColor)
|
||||
{
|
||||
if (def == null)
|
||||
return;
|
||||
|
||||
if ( def.Number > 0 )
|
||||
{
|
||||
if ( numberColor >= 0 ) // 5 bits per RGB component (15 bit RGB)
|
||||
g.AddHtmlLocalized( x, y, width, height, def.Number, numberColor, back, scroll );
|
||||
else
|
||||
g.AddHtmlLocalized( x, y, width, height, def.Number, back, scroll );
|
||||
}
|
||||
else if ( def.String != null )
|
||||
{
|
||||
if ( stringColor >= 0 ) // 8 bits per RGB component (24 bit RGB)
|
||||
g.AddHtml( x, y, width, height, $"<BASEFONT COLOR=#{stringColor:X6}>{def.String}</BASEFONT>", back, scroll );
|
||||
else
|
||||
g.AddHtml( x, y, width, height, def.String, back, scroll );
|
||||
}
|
||||
}
|
||||
if (def.Number > 0)
|
||||
{
|
||||
if (numberColor >= 0) // 5 bits per RGB component (15 bit RGB)
|
||||
g.AddHtmlLocalized(x, y, width, height, def.Number, numberColor, back, scroll);
|
||||
else
|
||||
g.AddHtmlLocalized(x, y, width, height, def.Number, back, scroll);
|
||||
}
|
||||
else if (def.String != null)
|
||||
{
|
||||
if (stringColor >= 0) // 8 bits per RGB component (24 bit RGB)
|
||||
g.AddHtml(x, y, width, height, $"<BASEFONT COLOR=#{stringColor:X6}>{def.String}</BASEFONT>", back,
|
||||
scroll);
|
||||
else
|
||||
g.AddHtml(x, y, width, height, def.String, back, scroll);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddHtmlText( Gump g, int x, int y, int width, int height, TextDefinition def, bool back, bool scroll )
|
||||
{
|
||||
AddHtmlText( g, x, y, width, height, def, back, scroll, -1, -1 );
|
||||
}
|
||||
public static void AddHtmlText(Gump g, int x, int y, int width, int height, TextDefinition def, bool back,
|
||||
bool scroll)
|
||||
{
|
||||
AddHtmlText(g, x, y, width, height, def, back, scroll, -1, -1);
|
||||
}
|
||||
|
||||
public static void SendMessageTo( Mobile m, TextDefinition def )
|
||||
{
|
||||
if ( def == null )
|
||||
return;
|
||||
public static void SendMessageTo(Mobile m, TextDefinition def)
|
||||
{
|
||||
if (def == null)
|
||||
return;
|
||||
|
||||
if ( def.Number > 0 )
|
||||
m.SendLocalizedMessage( def.Number );
|
||||
else if ( def.String != null )
|
||||
m.SendMessage( def.String );
|
||||
}
|
||||
if (def.Number > 0)
|
||||
m.SendLocalizedMessage(def.Number);
|
||||
else if (def.String != null)
|
||||
m.SendMessage(def.String);
|
||||
}
|
||||
|
||||
public static void SendMessageTo( Mobile m, TextDefinition def, int hue )
|
||||
{
|
||||
if ( def == null )
|
||||
return;
|
||||
public static void SendMessageTo(Mobile m, TextDefinition def, int hue)
|
||||
{
|
||||
if (def == null)
|
||||
return;
|
||||
|
||||
if ( def.Number > 0 )
|
||||
m.SendLocalizedMessage( def.Number, "", hue );
|
||||
else if ( def.String != null )
|
||||
m.SendMessage( hue, def.String );
|
||||
}
|
||||
if (def.Number > 0)
|
||||
m.SendLocalizedMessage(def.Number, "", hue);
|
||||
else if (def.String != null)
|
||||
m.SendMessage(hue, def.String);
|
||||
}
|
||||
|
||||
public static void PublicOverheadMessage( Mobile m, MessageType messageType, int hue, TextDefinition def )
|
||||
{
|
||||
if ( def == null )
|
||||
return;
|
||||
public static void PublicOverheadMessage(Mobile m, MessageType messageType, int hue, TextDefinition def)
|
||||
{
|
||||
if (def == null)
|
||||
return;
|
||||
|
||||
if ( def.Number > 0 )
|
||||
m.PublicOverheadMessage( messageType, hue, def.Number );
|
||||
else if ( def.String != null )
|
||||
m.PublicOverheadMessage( messageType, hue, false, def.String );
|
||||
}
|
||||
if (def.Number > 0)
|
||||
m.PublicOverheadMessage(messageType, hue, def.Number);
|
||||
else if (def.String != null)
|
||||
m.PublicOverheadMessage(messageType, hue, false, def.String);
|
||||
}
|
||||
|
||||
public static TextDefinition Parse( string value )
|
||||
{
|
||||
if ( value == null )
|
||||
return null;
|
||||
public static TextDefinition Parse(string value)
|
||||
{
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
int i;
|
||||
bool isInteger;
|
||||
int i;
|
||||
bool isInteger;
|
||||
|
||||
if ( value.StartsWith( "0x" ) )
|
||||
isInteger = int.TryParse( value.Substring( 2 ), NumberStyles.HexNumber, null, out i );
|
||||
else
|
||||
isInteger = int.TryParse( value, out i );
|
||||
if (value.StartsWith("0x"))
|
||||
isInteger = int.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i);
|
||||
else
|
||||
isInteger = int.TryParse(value, out i);
|
||||
|
||||
if ( isInteger )
|
||||
return new TextDefinition( i );
|
||||
return new TextDefinition( value );
|
||||
}
|
||||
if (isInteger)
|
||||
return new TextDefinition(i);
|
||||
return new TextDefinition(value);
|
||||
}
|
||||
|
||||
public static bool IsNullOrEmpty( TextDefinition def )
|
||||
{
|
||||
return ( def == null || def.IsEmpty );
|
||||
}
|
||||
}
|
||||
}
|
||||
public static bool IsNullOrEmpty(TextDefinition def)
|
||||
{
|
||||
return def == null || def.IsEmpty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,399 +1,406 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using Server.Mobiles;
|
||||
using Server.Engines.CannedEvil;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class Titles
|
||||
{
|
||||
public const int MinFame = 0;
|
||||
public const int MaxFame = 15000;
|
||||
public class Titles
|
||||
{
|
||||
public const int MinFame = 0;
|
||||
public const int MaxFame = 15000;
|
||||
|
||||
public static void AwardFame( Mobile m, int offset, bool message )
|
||||
{
|
||||
if ( offset > 0 )
|
||||
{
|
||||
if ( m.Fame >= MaxFame )
|
||||
return;
|
||||
public const int MinKarma = -15000;
|
||||
public const int MaxKarma = 15000;
|
||||
|
||||
offset -= m.Fame / 100;
|
||||
public static string[] HarrowerTitles =
|
||||
{
|
||||
"Spite", "Opponent", "Hunter", "Venom", "Executioner", "Annihilator", "Champion", "Assailant", "Purifier",
|
||||
"Nullifier"
|
||||
};
|
||||
|
||||
if ( offset < 0 )
|
||||
offset = 0;
|
||||
}
|
||||
else if ( offset < 0 )
|
||||
{
|
||||
if ( m.Fame <= MinFame )
|
||||
return;
|
||||
private static string[,] m_Levels =
|
||||
{
|
||||
{ "Neophyte", "Neophyte", "Neophyte" },
|
||||
{ "Novice", "Novice", "Novice" },
|
||||
{ "Apprentice", "Apprentice", "Apprentice" },
|
||||
{ "Journeyman", "Journeyman", "Journeyman" },
|
||||
{ "Expert", "Expert", "Expert" },
|
||||
{ "Adept", "Adept", "Adept" },
|
||||
{ "Master", "Master", "Master" },
|
||||
{ "Grandmaster", "Grandmaster", "Grandmaster" },
|
||||
{ "Elder", "Tatsujin", "Shinobi" },
|
||||
{ "Legendary", "Kengo", "Ka-ge" }
|
||||
};
|
||||
|
||||
offset -= m.Fame / 100;
|
||||
private static FameEntry[] m_FameEntries =
|
||||
{
|
||||
new FameEntry(1249, new[]
|
||||
{
|
||||
new KarmaEntry(-10000, "The Outcast {0}"),
|
||||
new KarmaEntry(-5000, "The Despicable {0}"),
|
||||
new KarmaEntry(-2500, "The Scoundrel {0}"),
|
||||
new KarmaEntry(-1250, "The Unsavory {0}"),
|
||||
new KarmaEntry(-625, "The Rude {0}"),
|
||||
new KarmaEntry(624, "{0}"),
|
||||
new KarmaEntry(1249, "The Fair {0}"),
|
||||
new KarmaEntry(2499, "The Kind {0}"),
|
||||
new KarmaEntry(4999, "The Good {0}"),
|
||||
new KarmaEntry(9999, "The Honest {0}"),
|
||||
new KarmaEntry(10000, "The Trustworthy {0}")
|
||||
}),
|
||||
new FameEntry(2499, new[]
|
||||
{
|
||||
new KarmaEntry(-10000, "The Wretched {0}"),
|
||||
new KarmaEntry(-5000, "The Dastardly {0}"),
|
||||
new KarmaEntry(-2500, "The Malicious {0}"),
|
||||
new KarmaEntry(-1250, "The Dishonorable {0}"),
|
||||
new KarmaEntry(-625, "The Disreputable {0}"),
|
||||
new KarmaEntry(624, "The Notable {0}"),
|
||||
new KarmaEntry(1249, "The Upstanding {0}"),
|
||||
new KarmaEntry(2499, "The Respectable {0}"),
|
||||
new KarmaEntry(4999, "The Honorable {0}"),
|
||||
new KarmaEntry(9999, "The Commendable {0}"),
|
||||
new KarmaEntry(10000, "The Estimable {0}")
|
||||
}),
|
||||
new FameEntry(4999, new[]
|
||||
{
|
||||
new KarmaEntry(-10000, "The Nefarious {0}"),
|
||||
new KarmaEntry(-5000, "The Wicked {0}"),
|
||||
new KarmaEntry(-2500, "The Vile {0}"),
|
||||
new KarmaEntry(-1250, "The Ignoble {0}"),
|
||||
new KarmaEntry(-625, "The Notorious {0}"),
|
||||
new KarmaEntry(624, "The Prominent {0}"),
|
||||
new KarmaEntry(1249, "The Reputable {0}"),
|
||||
new KarmaEntry(2499, "The Proper {0}"),
|
||||
new KarmaEntry(4999, "The Admirable {0}"),
|
||||
new KarmaEntry(9999, "The Famed {0}"),
|
||||
new KarmaEntry(10000, "The Great {0}")
|
||||
}),
|
||||
new FameEntry(9999, new[]
|
||||
{
|
||||
new KarmaEntry(-10000, "The Dread {0}"),
|
||||
new KarmaEntry(-5000, "The Evil {0}"),
|
||||
new KarmaEntry(-2500, "The Villainous {0}"),
|
||||
new KarmaEntry(-1250, "The Sinister {0}"),
|
||||
new KarmaEntry(-625, "The Infamous {0}"),
|
||||
new KarmaEntry(624, "The Renowned {0}"),
|
||||
new KarmaEntry(1249, "The Distinguished {0}"),
|
||||
new KarmaEntry(2499, "The Eminent {0}"),
|
||||
new KarmaEntry(4999, "The Noble {0}"),
|
||||
new KarmaEntry(9999, "The Illustrious {0}"),
|
||||
new KarmaEntry(10000, "The Glorious {0}")
|
||||
}),
|
||||
new FameEntry(10000, new[]
|
||||
{
|
||||
new KarmaEntry(-10000, "The Dread {1} {0}"),
|
||||
new KarmaEntry(-5000, "The Evil {1} {0}"),
|
||||
new KarmaEntry(-2500, "The Dark {1} {0}"),
|
||||
new KarmaEntry(-1250, "The Sinister {1} {0}"),
|
||||
new KarmaEntry(-625, "The Dishonored {1} {0}"),
|
||||
new KarmaEntry(624, "{1} {0}"),
|
||||
new KarmaEntry(1249, "The Distinguished {1} {0}"),
|
||||
new KarmaEntry(2499, "The Eminent {1} {0}"),
|
||||
new KarmaEntry(4999, "The Noble {1} {0}"),
|
||||
new KarmaEntry(9999, "The Illustrious {1} {0}"),
|
||||
new KarmaEntry(10000, "The Glorious {1} {0}")
|
||||
})
|
||||
};
|
||||
|
||||
if ( offset > 0 )
|
||||
offset = 0;
|
||||
}
|
||||
public static void AwardFame(Mobile m, int offset, bool message)
|
||||
{
|
||||
if (offset > 0)
|
||||
{
|
||||
if (m.Fame >= MaxFame)
|
||||
return;
|
||||
|
||||
if ( (m.Fame + offset) > MaxFame )
|
||||
offset = MaxFame - m.Fame;
|
||||
else if ( (m.Fame + offset) < MinFame )
|
||||
offset = MinFame - m.Fame;
|
||||
offset -= m.Fame / 100;
|
||||
|
||||
m.Fame += offset;
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
}
|
||||
else if (offset < 0)
|
||||
{
|
||||
if (m.Fame <= MinFame)
|
||||
return;
|
||||
|
||||
if ( message )
|
||||
{
|
||||
if ( offset > 40 )
|
||||
m.SendLocalizedMessage( 1019054 ); // You have gained a lot of fame.
|
||||
else if ( offset > 20 )
|
||||
m.SendLocalizedMessage( 1019053 ); // You have gained a good amount of fame.
|
||||
else if ( offset > 10 )
|
||||
m.SendLocalizedMessage( 1019052 ); // You have gained some fame.
|
||||
else if ( offset > 0 )
|
||||
m.SendLocalizedMessage( 1019051 ); // You have gained a little fame.
|
||||
else if ( offset < -40 )
|
||||
m.SendLocalizedMessage( 1019058 ); // You have lost a lot of fame.
|
||||
else if ( offset < -20 )
|
||||
m.SendLocalizedMessage( 1019057 ); // You have lost a good amount of fame.
|
||||
else if ( offset < -10 )
|
||||
m.SendLocalizedMessage( 1019056 ); // You have lost some fame.
|
||||
else if ( offset < 0 )
|
||||
m.SendLocalizedMessage( 1019055 ); // You have lost a little fame.
|
||||
}
|
||||
}
|
||||
offset -= m.Fame / 100;
|
||||
|
||||
public const int MinKarma = -15000;
|
||||
public const int MaxKarma = 15000;
|
||||
if (offset > 0)
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
public static void AwardKarma( Mobile m, int offset, bool message )
|
||||
{
|
||||
PlayerMobile pm = m as PlayerMobile;
|
||||
if (m.Fame + offset > MaxFame)
|
||||
offset = MaxFame - m.Fame;
|
||||
else if (m.Fame + offset < MinFame)
|
||||
offset = MinFame - m.Fame;
|
||||
|
||||
if ( offset > 0 )
|
||||
{
|
||||
if ( pm?.KarmaLocked == true )
|
||||
return;
|
||||
m.Fame += offset;
|
||||
|
||||
if ( m.Karma >= MaxKarma )
|
||||
return;
|
||||
if (message)
|
||||
{
|
||||
if (offset > 40)
|
||||
m.SendLocalizedMessage(1019054); // You have gained a lot of fame.
|
||||
else if (offset > 20)
|
||||
m.SendLocalizedMessage(1019053); // You have gained a good amount of fame.
|
||||
else if (offset > 10)
|
||||
m.SendLocalizedMessage(1019052); // You have gained some fame.
|
||||
else if (offset > 0)
|
||||
m.SendLocalizedMessage(1019051); // You have gained a little fame.
|
||||
else if (offset < -40)
|
||||
m.SendLocalizedMessage(1019058); // You have lost a lot of fame.
|
||||
else if (offset < -20)
|
||||
m.SendLocalizedMessage(1019057); // You have lost a good amount of fame.
|
||||
else if (offset < -10)
|
||||
m.SendLocalizedMessage(1019056); // You have lost some fame.
|
||||
else if (offset < 0)
|
||||
m.SendLocalizedMessage(1019055); // You have lost a little fame.
|
||||
}
|
||||
}
|
||||
|
||||
offset -= m.Karma / 100;
|
||||
public static void AwardKarma(Mobile m, int offset, bool message)
|
||||
{
|
||||
PlayerMobile pm = m as PlayerMobile;
|
||||
|
||||
if ( offset < 0 )
|
||||
offset = 0;
|
||||
}
|
||||
else if ( offset < 0 )
|
||||
{
|
||||
if ( m.Karma <= MinKarma )
|
||||
return;
|
||||
if (offset > 0)
|
||||
{
|
||||
if (pm?.KarmaLocked == true)
|
||||
return;
|
||||
|
||||
offset -= m.Karma / 100;
|
||||
if (m.Karma >= MaxKarma)
|
||||
return;
|
||||
|
||||
if ( offset > 0 )
|
||||
offset = 0;
|
||||
}
|
||||
offset -= m.Karma / 100;
|
||||
|
||||
if ( (m.Karma + offset) > MaxKarma )
|
||||
offset = MaxKarma - m.Karma;
|
||||
else if ( (m.Karma + offset) < MinKarma )
|
||||
offset = MinKarma - m.Karma;
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
}
|
||||
else if (offset < 0)
|
||||
{
|
||||
if (m.Karma <= MinKarma)
|
||||
return;
|
||||
|
||||
bool wasPositiveKarma = ( m.Karma >= 0 );
|
||||
offset -= m.Karma / 100;
|
||||
|
||||
m.Karma += offset;
|
||||
if (offset > 0)
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
if ( message )
|
||||
{
|
||||
if ( offset > 40 )
|
||||
m.SendLocalizedMessage( 1019062 ); // You have gained a lot of karma.
|
||||
else if ( offset > 20 )
|
||||
m.SendLocalizedMessage( 1019061 ); // You have gained a good amount of karma.
|
||||
else if ( offset > 10 )
|
||||
m.SendLocalizedMessage( 1019060 ); // You have gained some karma.
|
||||
else if ( offset > 0 )
|
||||
m.SendLocalizedMessage( 1019059 ); // You have gained a little karma.
|
||||
else if ( offset < -40 )
|
||||
m.SendLocalizedMessage( 1019066 ); // You have lost a lot of karma.
|
||||
else if ( offset < -20 )
|
||||
m.SendLocalizedMessage( 1019065 ); // You have lost a good amount of karma.
|
||||
else if ( offset < -10 )
|
||||
m.SendLocalizedMessage( 1019064 ); // You have lost some karma.
|
||||
else if ( offset < 0 )
|
||||
m.SendLocalizedMessage( 1019063 ); // You have lost a little karma.
|
||||
}
|
||||
if (m.Karma + offset > MaxKarma)
|
||||
offset = MaxKarma - m.Karma;
|
||||
else if (m.Karma + offset < MinKarma)
|
||||
offset = MinKarma - m.Karma;
|
||||
|
||||
if ( !Core.AOS && wasPositiveKarma && m.Karma < 0 && pm != null && !pm.KarmaLocked )
|
||||
{
|
||||
pm.KarmaLocked = true;
|
||||
m.SendLocalizedMessage( 1042511, "", 0x22 ); // Karma is locked. A mantra spoken at a shrine will unlock it again.
|
||||
}
|
||||
}
|
||||
bool wasPositiveKarma = m.Karma >= 0;
|
||||
|
||||
public static string[] HarrowerTitles = { "Spite", "Opponent", "Hunter", "Venom", "Executioner", "Annihilator", "Champion", "Assailant", "Purifier", "Nullifier" };
|
||||
m.Karma += offset;
|
||||
|
||||
public static string ComputeTitle( Mobile beholder, Mobile beheld )
|
||||
{
|
||||
StringBuilder title = new StringBuilder();
|
||||
if (message)
|
||||
{
|
||||
if (offset > 40)
|
||||
m.SendLocalizedMessage(1019062); // You have gained a lot of karma.
|
||||
else if (offset > 20)
|
||||
m.SendLocalizedMessage(1019061); // You have gained a good amount of karma.
|
||||
else if (offset > 10)
|
||||
m.SendLocalizedMessage(1019060); // You have gained some karma.
|
||||
else if (offset > 0)
|
||||
m.SendLocalizedMessage(1019059); // You have gained a little karma.
|
||||
else if (offset < -40)
|
||||
m.SendLocalizedMessage(1019066); // You have lost a lot of karma.
|
||||
else if (offset < -20)
|
||||
m.SendLocalizedMessage(1019065); // You have lost a good amount of karma.
|
||||
else if (offset < -10)
|
||||
m.SendLocalizedMessage(1019064); // You have lost some karma.
|
||||
else if (offset < 0)
|
||||
m.SendLocalizedMessage(1019063); // You have lost a little karma.
|
||||
}
|
||||
|
||||
int fame = beheld.Fame;
|
||||
int karma = beheld.Karma;
|
||||
if (!Core.AOS && wasPositiveKarma && m.Karma < 0 && pm != null && !pm.KarmaLocked)
|
||||
{
|
||||
pm.KarmaLocked = true;
|
||||
m.SendLocalizedMessage(1042511, "",
|
||||
0x22); // Karma is locked. A mantra spoken at a shrine will unlock it again.
|
||||
}
|
||||
}
|
||||
|
||||
bool showSkillTitle = beheld.ShowFameTitle && ( (beholder == beheld) || (fame >= 5000) );
|
||||
public static string ComputeTitle(Mobile beholder, Mobile beheld)
|
||||
{
|
||||
StringBuilder title = new StringBuilder();
|
||||
|
||||
/*if ( beheld.Kills >= 5 )
|
||||
{
|
||||
title.AppendFormat( beheld.Fame >= 10000 ? "The Murderer {1} {0}" : "The Murderer {0}", beheld.Name, beheld.Female ? "Lady" : "Lord" );
|
||||
}
|
||||
else*/if ( beheld.ShowFameTitle || (beholder == beheld) )
|
||||
{
|
||||
for ( int i = 0; i < m_FameEntries.Length; ++i )
|
||||
{
|
||||
FameEntry fe = m_FameEntries[i];
|
||||
int fame = beheld.Fame;
|
||||
int karma = beheld.Karma;
|
||||
|
||||
if ( fame <= fe.m_Fame || i == (m_FameEntries.Length - 1) )
|
||||
{
|
||||
KarmaEntry[] karmaEntries = fe.m_Karma;
|
||||
bool showSkillTitle = beheld.ShowFameTitle && (beholder == beheld || fame >= 5000);
|
||||
|
||||
for ( int j = 0; j < karmaEntries.Length; ++j )
|
||||
{
|
||||
KarmaEntry ke = karmaEntries[j];
|
||||
/*if ( beheld.Kills >= 5 )
|
||||
{
|
||||
title.AppendFormat( beheld.Fame >= 10000 ? "The Murderer {1} {0}" : "The Murderer {0}", beheld.Name, beheld.Female ? "Lady" : "Lord" );
|
||||
}
|
||||
else*/
|
||||
if (beheld.ShowFameTitle || beholder == beheld)
|
||||
for (int i = 0; i < m_FameEntries.Length; ++i)
|
||||
{
|
||||
FameEntry fe = m_FameEntries[i];
|
||||
|
||||
if ( karma <= ke.m_Karma || j == (karmaEntries.Length - 1) )
|
||||
{
|
||||
title.AppendFormat( ke.m_Title, beheld.Name, beheld.Female ? "Lady" : "Lord" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fame <= fe.m_Fame || i == m_FameEntries.Length - 1)
|
||||
{
|
||||
KarmaEntry[] karmaEntries = fe.m_Karma;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
title.Append( beheld.Name );
|
||||
}
|
||||
for (int j = 0; j < karmaEntries.Length; ++j)
|
||||
{
|
||||
KarmaEntry ke = karmaEntries[j];
|
||||
|
||||
if ( beheld is PlayerMobile mobile && mobile.DisplayChampionTitle )
|
||||
{
|
||||
PlayerMobile.ChampionTitleInfo info = mobile.ChampionTitles;
|
||||
if (karma <= ke.m_Karma || j == karmaEntries.Length - 1)
|
||||
{
|
||||
title.AppendFormat(ke.m_Title, beheld.Name, beheld.Female ? "Lady" : "Lord");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( info.Harrower > 0 )
|
||||
title.AppendFormat( ": {0} of Evil", HarrowerTitles[Math.Min( HarrowerTitles.Length, info.Harrower )-1] );
|
||||
else
|
||||
{
|
||||
int highestValue = 0, highestType = 0;
|
||||
for( int i = 0; i < ChampionSpawnInfo.Table.Length; i++ )
|
||||
{
|
||||
int v = info.GetValue( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
title.Append(beheld.Name);
|
||||
|
||||
if ( v > highestValue )
|
||||
{
|
||||
highestValue = v;
|
||||
highestType = i;
|
||||
}
|
||||
}
|
||||
if (beheld is PlayerMobile mobile && mobile.DisplayChampionTitle)
|
||||
{
|
||||
PlayerMobile.ChampionTitleInfo info = mobile.ChampionTitles;
|
||||
|
||||
int offset = 0;
|
||||
if ( highestValue > 800 )
|
||||
offset = 3;
|
||||
else if ( highestValue > 300 )
|
||||
offset = (int)(highestValue/300);
|
||||
if (info.Harrower > 0)
|
||||
{
|
||||
title.AppendFormat(": {0} of Evil", HarrowerTitles[Math.Min(HarrowerTitles.Length, info.Harrower) - 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int highestValue = 0, highestType = 0;
|
||||
for (int i = 0; i < ChampionSpawnInfo.Table.Length; i++)
|
||||
{
|
||||
int v = info.GetValue(i);
|
||||
|
||||
if ( offset > 0 )
|
||||
{
|
||||
ChampionSpawnInfo champInfo = ChampionSpawnInfo.GetInfo( (ChampionSpawnType)highestType );
|
||||
title.AppendFormat( ": {0} of the {1}", champInfo.LevelNames[Math.Min( offset, champInfo.LevelNames.Length ) -1], champInfo.Name );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (v > highestValue)
|
||||
{
|
||||
highestValue = v;
|
||||
highestType = i;
|
||||
}
|
||||
}
|
||||
|
||||
string customTitle = beheld.Title;
|
||||
int offset = 0;
|
||||
if (highestValue > 800)
|
||||
offset = 3;
|
||||
else if (highestValue > 300)
|
||||
offset = highestValue / 300;
|
||||
|
||||
if ( customTitle != null && (customTitle = customTitle.Trim()).Length > 0 )
|
||||
{
|
||||
title.AppendFormat( " {0}", customTitle );
|
||||
}
|
||||
else if ( showSkillTitle && beheld.Player )
|
||||
{
|
||||
string skillTitle = GetSkillTitle( beheld );
|
||||
if (offset > 0)
|
||||
{
|
||||
ChampionSpawnInfo champInfo = ChampionSpawnInfo.GetInfo((ChampionSpawnType)highestType);
|
||||
title.AppendFormat(": {0} of the {1}",
|
||||
champInfo.LevelNames[Math.Min(offset, champInfo.LevelNames.Length) - 1], champInfo.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( skillTitle != null ) {
|
||||
title.Append( ", " ).Append( skillTitle );
|
||||
}
|
||||
}
|
||||
string customTitle = beheld.Title;
|
||||
|
||||
return title.ToString();
|
||||
}
|
||||
if (customTitle != null && (customTitle = customTitle.Trim()).Length > 0)
|
||||
{
|
||||
title.AppendFormat(" {0}", customTitle);
|
||||
}
|
||||
else if (showSkillTitle && beheld.Player)
|
||||
{
|
||||
string skillTitle = GetSkillTitle(beheld);
|
||||
|
||||
public static string GetSkillTitle( Mobile mob ) {
|
||||
Skill highest = GetHighestSkill( mob );// beheld.Skills.Highest;
|
||||
if (skillTitle != null) title.Append(", ").Append(skillTitle);
|
||||
}
|
||||
|
||||
if ( highest != null && highest.BaseFixedPoint >= 300 )
|
||||
{
|
||||
string skillLevel = GetSkillLevel( highest );
|
||||
string skillTitle = highest.Info.Title;
|
||||
return title.ToString();
|
||||
}
|
||||
|
||||
if ( mob.Female && skillTitle.EndsWith( "man" ) )
|
||||
skillTitle = skillTitle.Substring( 0, skillTitle.Length - 3 ) + "woman";
|
||||
public static string GetSkillTitle(Mobile mob)
|
||||
{
|
||||
Skill highest = GetHighestSkill(mob); // beheld.Skills.Highest;
|
||||
|
||||
return string.Concat( skillLevel, " ", skillTitle );
|
||||
}
|
||||
if (highest != null && highest.BaseFixedPoint >= 300)
|
||||
{
|
||||
string skillLevel = GetSkillLevel(highest);
|
||||
string skillTitle = highest.Info.Title;
|
||||
|
||||
return null;
|
||||
}
|
||||
if (mob.Female && skillTitle.EndsWith("man"))
|
||||
skillTitle = skillTitle.Substring(0, skillTitle.Length - 3) + "woman";
|
||||
|
||||
private static Skill GetHighestSkill( Mobile m )
|
||||
{
|
||||
Skills skills = m.Skills;
|
||||
return string.Concat(skillLevel, " ", skillTitle);
|
||||
}
|
||||
|
||||
if ( !Core.AOS )
|
||||
return skills.Highest;
|
||||
return null;
|
||||
}
|
||||
|
||||
Skill highest = null;
|
||||
private static Skill GetHighestSkill(Mobile m)
|
||||
{
|
||||
Skills skills = m.Skills;
|
||||
|
||||
for ( int i = 0; i < m.Skills.Length; ++i )
|
||||
{
|
||||
Skill check = m.Skills[i];
|
||||
if (!Core.AOS)
|
||||
return skills.Highest;
|
||||
|
||||
if ( highest == null || check.BaseFixedPoint > highest.BaseFixedPoint )
|
||||
highest = check;
|
||||
else if ( highest != null && highest.Lock != SkillLock.Up && check.Lock == SkillLock.Up && check.BaseFixedPoint == highest.BaseFixedPoint )
|
||||
highest = check;
|
||||
}
|
||||
Skill highest = null;
|
||||
|
||||
return highest;
|
||||
}
|
||||
for (int i = 0; i < m.Skills.Length; ++i)
|
||||
{
|
||||
Skill check = m.Skills[i];
|
||||
|
||||
private static string[,] m_Levels = {
|
||||
{ "Neophyte", "Neophyte", "Neophyte" },
|
||||
{ "Novice", "Novice", "Novice" },
|
||||
{ "Apprentice", "Apprentice", "Apprentice" },
|
||||
{ "Journeyman", "Journeyman", "Journeyman" },
|
||||
{ "Expert", "Expert", "Expert" },
|
||||
{ "Adept", "Adept", "Adept" },
|
||||
{ "Master", "Master", "Master" },
|
||||
{ "Grandmaster", "Grandmaster", "Grandmaster" },
|
||||
{ "Elder", "Tatsujin", "Shinobi" },
|
||||
{ "Legendary", "Kengo", "Ka-ge" }
|
||||
};
|
||||
if (highest == null || check.BaseFixedPoint > highest.BaseFixedPoint)
|
||||
highest = check;
|
||||
else if (highest != null && highest.Lock != SkillLock.Up && check.Lock == SkillLock.Up &&
|
||||
check.BaseFixedPoint == highest.BaseFixedPoint)
|
||||
highest = check;
|
||||
}
|
||||
|
||||
private static string GetSkillLevel( Skill skill )
|
||||
{
|
||||
return m_Levels[GetTableIndex( skill ), GetTableType( skill )];
|
||||
}
|
||||
return highest;
|
||||
}
|
||||
|
||||
private static int GetTableType( Skill skill )
|
||||
{
|
||||
switch ( skill.SkillName )
|
||||
{
|
||||
default: return 0;
|
||||
case SkillName.Bushido: return 1;
|
||||
case SkillName.Ninjitsu: return 2;
|
||||
}
|
||||
}
|
||||
private static string GetSkillLevel(Skill skill)
|
||||
{
|
||||
return m_Levels[GetTableIndex(skill), GetTableType(skill)];
|
||||
}
|
||||
|
||||
private static int GetTableIndex( Skill skill )
|
||||
{
|
||||
int fp = Math.Min( skill.BaseFixedPoint, 1200 );
|
||||
private static int GetTableType(Skill skill)
|
||||
{
|
||||
switch (skill.SkillName)
|
||||
{
|
||||
default: return 0;
|
||||
case SkillName.Bushido: return 1;
|
||||
case SkillName.Ninjitsu: return 2;
|
||||
}
|
||||
}
|
||||
|
||||
return (fp - 300) / 100;
|
||||
}
|
||||
private static int GetTableIndex(Skill skill)
|
||||
{
|
||||
int fp = Math.Min(skill.BaseFixedPoint, 1200);
|
||||
|
||||
private static FameEntry[] m_FameEntries = {
|
||||
new FameEntry( 1249, new[]
|
||||
{
|
||||
new KarmaEntry( -10000, "The Outcast {0}" ),
|
||||
new KarmaEntry( -5000, "The Despicable {0}" ),
|
||||
new KarmaEntry( -2500, "The Scoundrel {0}" ),
|
||||
new KarmaEntry( -1250, "The Unsavory {0}" ),
|
||||
new KarmaEntry( -625, "The Rude {0}" ),
|
||||
new KarmaEntry( 624, "{0}" ),
|
||||
new KarmaEntry( 1249, "The Fair {0}" ),
|
||||
new KarmaEntry( 2499, "The Kind {0}" ),
|
||||
new KarmaEntry( 4999, "The Good {0}" ),
|
||||
new KarmaEntry( 9999, "The Honest {0}" ),
|
||||
new KarmaEntry( 10000, "The Trustworthy {0}" )
|
||||
} ),
|
||||
new FameEntry( 2499, new[]
|
||||
{
|
||||
new KarmaEntry( -10000, "The Wretched {0}" ),
|
||||
new KarmaEntry( -5000, "The Dastardly {0}" ),
|
||||
new KarmaEntry( -2500, "The Malicious {0}" ),
|
||||
new KarmaEntry( -1250, "The Dishonorable {0}" ),
|
||||
new KarmaEntry( -625, "The Disreputable {0}" ),
|
||||
new KarmaEntry( 624, "The Notable {0}" ),
|
||||
new KarmaEntry( 1249, "The Upstanding {0}" ),
|
||||
new KarmaEntry( 2499, "The Respectable {0}" ),
|
||||
new KarmaEntry( 4999, "The Honorable {0}" ),
|
||||
new KarmaEntry( 9999, "The Commendable {0}" ),
|
||||
new KarmaEntry( 10000, "The Estimable {0}" )
|
||||
} ),
|
||||
new FameEntry( 4999, new[]
|
||||
{
|
||||
new KarmaEntry( -10000, "The Nefarious {0}" ),
|
||||
new KarmaEntry( -5000, "The Wicked {0}" ),
|
||||
new KarmaEntry( -2500, "The Vile {0}" ),
|
||||
new KarmaEntry( -1250, "The Ignoble {0}" ),
|
||||
new KarmaEntry( -625, "The Notorious {0}" ),
|
||||
new KarmaEntry( 624, "The Prominent {0}" ),
|
||||
new KarmaEntry( 1249, "The Reputable {0}" ),
|
||||
new KarmaEntry( 2499, "The Proper {0}" ),
|
||||
new KarmaEntry( 4999, "The Admirable {0}" ),
|
||||
new KarmaEntry( 9999, "The Famed {0}" ),
|
||||
new KarmaEntry( 10000, "The Great {0}" )
|
||||
} ),
|
||||
new FameEntry( 9999, new[]
|
||||
{
|
||||
new KarmaEntry( -10000, "The Dread {0}" ),
|
||||
new KarmaEntry( -5000, "The Evil {0}" ),
|
||||
new KarmaEntry( -2500, "The Villainous {0}" ),
|
||||
new KarmaEntry( -1250, "The Sinister {0}" ),
|
||||
new KarmaEntry( -625, "The Infamous {0}" ),
|
||||
new KarmaEntry( 624, "The Renowned {0}" ),
|
||||
new KarmaEntry( 1249, "The Distinguished {0}" ),
|
||||
new KarmaEntry( 2499, "The Eminent {0}" ),
|
||||
new KarmaEntry( 4999, "The Noble {0}" ),
|
||||
new KarmaEntry( 9999, "The Illustrious {0}" ),
|
||||
new KarmaEntry( 10000, "The Glorious {0}" )
|
||||
} ),
|
||||
new FameEntry( 10000, new[]
|
||||
{
|
||||
new KarmaEntry( -10000, "The Dread {1} {0}" ),
|
||||
new KarmaEntry( -5000, "The Evil {1} {0}" ),
|
||||
new KarmaEntry( -2500, "The Dark {1} {0}" ),
|
||||
new KarmaEntry( -1250, "The Sinister {1} {0}" ),
|
||||
new KarmaEntry( -625, "The Dishonored {1} {0}" ),
|
||||
new KarmaEntry( 624, "{1} {0}" ),
|
||||
new KarmaEntry( 1249, "The Distinguished {1} {0}" ),
|
||||
new KarmaEntry( 2499, "The Eminent {1} {0}" ),
|
||||
new KarmaEntry( 4999, "The Noble {1} {0}" ),
|
||||
new KarmaEntry( 9999, "The Illustrious {1} {0}" ),
|
||||
new KarmaEntry( 10000, "The Glorious {1} {0}" )
|
||||
} )
|
||||
};
|
||||
}
|
||||
return (fp - 300) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
public class FameEntry
|
||||
{
|
||||
public int m_Fame;
|
||||
public KarmaEntry[] m_Karma;
|
||||
public class FameEntry
|
||||
{
|
||||
public int m_Fame;
|
||||
public KarmaEntry[] m_Karma;
|
||||
|
||||
public FameEntry( int fame, KarmaEntry[] karma )
|
||||
{
|
||||
m_Fame = fame;
|
||||
m_Karma = karma;
|
||||
}
|
||||
}
|
||||
public FameEntry(int fame, KarmaEntry[] karma)
|
||||
{
|
||||
m_Fame = fame;
|
||||
m_Karma = karma;
|
||||
}
|
||||
}
|
||||
|
||||
public class KarmaEntry
|
||||
{
|
||||
public int m_Karma;
|
||||
public string m_Title;
|
||||
public class KarmaEntry
|
||||
{
|
||||
public int m_Karma;
|
||||
public string m_Title;
|
||||
|
||||
public KarmaEntry( int karma, string title )
|
||||
{
|
||||
m_Karma = karma;
|
||||
m_Title = title;
|
||||
}
|
||||
}
|
||||
}
|
||||
public KarmaEntry(int karma, string title)
|
||||
{
|
||||
m_Karma = karma;
|
||||
m_Title = title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,105 +3,105 @@ using Server.Commands.Generic;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class ToggleItem : Item
|
||||
{
|
||||
public class ToggleCommand : BaseCommand
|
||||
{
|
||||
public ToggleCommand()
|
||||
{
|
||||
AccessLevel = AccessLevel.GameMaster;
|
||||
Supports = CommandSupport.AllItems;
|
||||
Commands = new[]{ "Toggle" };
|
||||
ObjectTypes = ObjectTypes.Items;
|
||||
Usage = "Toggle";
|
||||
Description = "Toggles a targeted ToggleItem.";
|
||||
}
|
||||
public class ToggleItem : Item
|
||||
{
|
||||
[Constructible]
|
||||
public ToggleItem(int inactiveItemID, int activeItemID, bool playersCanToggle = false)
|
||||
: base(inactiveItemID)
|
||||
{
|
||||
Movable = false;
|
||||
|
||||
public override void Execute( CommandEventArgs e, object obj )
|
||||
{
|
||||
if ( obj is ToggleItem item )
|
||||
{
|
||||
item.Toggle();
|
||||
AddResponse( "The item has been toggled." );
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFailure( "That is not a ToggleItem." );
|
||||
}
|
||||
}
|
||||
}
|
||||
InactiveItemID = inactiveItemID;
|
||||
ActiveItemID = activeItemID;
|
||||
PlayersCanToggle = playersCanToggle;
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
TargetCommands.Register( new ToggleCommand() );
|
||||
}
|
||||
public ToggleItem(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int InactiveItemID { get; set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int InactiveItemID{ get; set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int ActiveItemID { get; set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ActiveItemID{ get; set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool PlayersCanToggle { get; set; }
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool PlayersCanToggle{ get; set; }
|
||||
|
||||
[Constructible]
|
||||
public ToggleItem( int inactiveItemID, int activeItemID, bool playersCanToggle = false)
|
||||
: base( inactiveItemID )
|
||||
{
|
||||
Movable = false;
|
||||
public static void Initialize()
|
||||
{
|
||||
TargetCommands.Register(new ToggleCommand());
|
||||
}
|
||||
|
||||
InactiveItemID = inactiveItemID;
|
||||
ActiveItemID = activeItemID;
|
||||
PlayersCanToggle = playersCanToggle;
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
Toggle();
|
||||
}
|
||||
else if (PlayersCanToggle)
|
||||
{
|
||||
if (from.InRange(GetWorldLocation(), 1))
|
||||
Toggle();
|
||||
else
|
||||
from.SendLocalizedMessage(500446); // That is too far away.
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( from.AccessLevel >= AccessLevel.GameMaster )
|
||||
{
|
||||
Toggle();
|
||||
}
|
||||
else if ( PlayersCanToggle )
|
||||
{
|
||||
if ( from.InRange( GetWorldLocation(), 1 ) )
|
||||
Toggle();
|
||||
else
|
||||
from.SendLocalizedMessage( 500446 ); // That is too far away.
|
||||
}
|
||||
}
|
||||
public void Toggle()
|
||||
{
|
||||
ItemID = ItemID == ActiveItemID ? InactiveItemID : ActiveItemID;
|
||||
Visible = ItemID != 0x1;
|
||||
}
|
||||
|
||||
public void Toggle()
|
||||
{
|
||||
ItemID = ( ItemID == ActiveItemID ) ? InactiveItemID : ActiveItemID;
|
||||
Visible = ( ItemID != 0x1 );
|
||||
}
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
public ToggleItem( Serial serial )
|
||||
: base( serial )
|
||||
{
|
||||
}
|
||||
writer.Write(0); // version
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write(InactiveItemID);
|
||||
writer.Write(ActiveItemID);
|
||||
writer.Write(PlayersCanToggle);
|
||||
}
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
writer.Write( InactiveItemID );
|
||||
writer.Write( ActiveItemID );
|
||||
writer.Write( PlayersCanToggle );
|
||||
}
|
||||
int version = reader.ReadInt();
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
InactiveItemID = reader.ReadInt();
|
||||
ActiveItemID = reader.ReadInt();
|
||||
PlayersCanToggle = reader.ReadBool();
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
public class ToggleCommand : BaseCommand
|
||||
{
|
||||
public ToggleCommand()
|
||||
{
|
||||
AccessLevel = AccessLevel.GameMaster;
|
||||
Supports = CommandSupport.AllItems;
|
||||
Commands = new[] { "Toggle" };
|
||||
ObjectTypes = ObjectTypes.Items;
|
||||
Usage = "Toggle";
|
||||
Description = "Toggles a targeted ToggleItem.";
|
||||
}
|
||||
|
||||
InactiveItemID = reader.ReadInt();
|
||||
ActiveItemID = reader.ReadInt();
|
||||
PlayersCanToggle = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Execute(CommandEventArgs e, object obj)
|
||||
{
|
||||
if (obj is ToggleItem item)
|
||||
{
|
||||
item.Toggle();
|
||||
AddResponse("The item has been toggled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFailure("That is not a ToggleItem.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,73 +4,72 @@ using Server.Regions;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public class TreasureRegion : BaseRegion
|
||||
{
|
||||
private const int Range = 5; // No house may be placed within 5 tiles of the treasure
|
||||
public class TreasureRegion : BaseRegion
|
||||
{
|
||||
private const int Range = 5; // No house may be placed within 5 tiles of the treasure
|
||||
|
||||
public TreasureRegion( int x, int y, Map map ): base( null, map, DefaultPriority, new Rectangle2D( x - Range, y - Range, 1 + (Range * 2), 1 + (Range * 2) ) )
|
||||
{
|
||||
GoLocation = new Point3D( x, y, map.GetAverageZ( x, y ) );
|
||||
public TreasureRegion(int x, int y, Map map) : base(null, map, DefaultPriority,
|
||||
new Rectangle2D(x - Range, y - Range, 1 + Range * 2, 1 + Range * 2))
|
||||
{
|
||||
GoLocation = new Point3D(x, y, map.GetAverageZ(x, y));
|
||||
|
||||
Register();
|
||||
}
|
||||
Register();
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
string filePath = Path.Combine( Core.BaseDirectory, "Data/treasure.cfg" );
|
||||
int i = 0, x = 0, y = 0;
|
||||
public static void Initialize()
|
||||
{
|
||||
string filePath = Path.Combine(Core.BaseDirectory, "Data/treasure.cfg");
|
||||
int i = 0, x = 0, y = 0;
|
||||
|
||||
if ( File.Exists( filePath ) )
|
||||
{
|
||||
using ( StreamReader ip = new StreamReader( filePath ) )
|
||||
{
|
||||
string line;
|
||||
if (File.Exists(filePath))
|
||||
using (StreamReader ip = new StreamReader(filePath))
|
||||
{
|
||||
string line;
|
||||
|
||||
while ( (line = ip.ReadLine()) != null )
|
||||
{
|
||||
i++;
|
||||
while ((line = ip.ReadLine()) != null)
|
||||
{
|
||||
i++;
|
||||
|
||||
try
|
||||
{
|
||||
string[] split = line.Split( ' ' );
|
||||
try
|
||||
{
|
||||
string[] split = line.Split(' ');
|
||||
|
||||
x = Convert.ToInt32( split[0] );
|
||||
y = Convert.ToInt32( split[1] );
|
||||
x = Convert.ToInt32(split[0]);
|
||||
y = Convert.ToInt32(split[1]);
|
||||
|
||||
try
|
||||
{
|
||||
new TreasureRegion( x, y, Map.Felucca );
|
||||
new TreasureRegion( x, y, Map.Trammel );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
Console.WriteLine( "{0} {1} {2} {3}", i, x, y, e );
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine( "Warning: Error in Line '{0}' of Data/treasure.cfg", line );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
new TreasureRegion(x, y, Map.Felucca);
|
||||
new TreasureRegion(x, y, Map.Trammel);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("{0} {1} {2} {3}", i, x, y, e);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Warning: Error in Line '{0}' of Data/treasure.cfg", line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool AllowHousing( Mobile from, Point3D p )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public override bool AllowHousing(Mobile from, Point3D p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnEnter( Mobile m )
|
||||
{
|
||||
if ( m.AccessLevel > AccessLevel.Player )
|
||||
m.SendMessage( "You have entered a protected treasure map area." );
|
||||
}
|
||||
public override void OnEnter(Mobile m)
|
||||
{
|
||||
if (m.AccessLevel > AccessLevel.Player)
|
||||
m.SendMessage("You have entered a protected treasure map area.");
|
||||
}
|
||||
|
||||
public override void OnExit( Mobile m )
|
||||
{
|
||||
if ( m.AccessLevel > AccessLevel.Player )
|
||||
m.SendMessage( "You have left a protected treasure map area." );
|
||||
}
|
||||
}
|
||||
public override void OnExit(Mobile m)
|
||||
{
|
||||
if (m.AccessLevel > AccessLevel.Player)
|
||||
m.SendMessage("You have left a protected treasure map area.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,52 +4,50 @@ using System.Reflection;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public delegate void ValidationEventHandler();
|
||||
public delegate void ValidationEventHandler();
|
||||
|
||||
public static class ValidationQueue
|
||||
{
|
||||
public static event ValidationEventHandler StartValidation;
|
||||
public static class ValidationQueue
|
||||
{
|
||||
public static event ValidationEventHandler StartValidation;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
StartValidation?.Invoke();
|
||||
public static void Initialize()
|
||||
{
|
||||
StartValidation?.Invoke();
|
||||
|
||||
StartValidation = null;
|
||||
}
|
||||
}
|
||||
StartValidation = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidationQueue<T>
|
||||
{
|
||||
private static List<T> m_Queue;
|
||||
public static class ValidationQueue<T>
|
||||
{
|
||||
private static List<T> m_Queue;
|
||||
|
||||
static ValidationQueue()
|
||||
{
|
||||
m_Queue = new List<T>();
|
||||
ValidationQueue.StartValidation += ValidateAll;
|
||||
}
|
||||
static ValidationQueue()
|
||||
{
|
||||
m_Queue = new List<T>();
|
||||
ValidationQueue.StartValidation += ValidateAll;
|
||||
}
|
||||
|
||||
public static void Add( T obj )
|
||||
{
|
||||
m_Queue.Add( obj );
|
||||
}
|
||||
public static void Add(T obj)
|
||||
{
|
||||
m_Queue.Add(obj);
|
||||
}
|
||||
|
||||
private static void ValidateAll()
|
||||
{
|
||||
Type type = typeof( T );
|
||||
private static void ValidateAll()
|
||||
{
|
||||
Type type = typeof(T);
|
||||
|
||||
if ( type != null )
|
||||
{
|
||||
MethodInfo m = type.GetMethod( "Validate", BindingFlags.Instance | BindingFlags.Public );
|
||||
if (type != null)
|
||||
{
|
||||
MethodInfo m = type.GetMethod("Validate", BindingFlags.Instance | BindingFlags.Public);
|
||||
|
||||
if ( m != null )
|
||||
{
|
||||
for ( int i = 0; i < m_Queue.Count; ++i )
|
||||
m.Invoke( m_Queue[i], null );
|
||||
}
|
||||
}
|
||||
if (m != null)
|
||||
for (int i = 0; i < m_Queue.Count; ++i)
|
||||
m.Invoke(m_Queue[i], null);
|
||||
}
|
||||
|
||||
m_Queue.Clear();
|
||||
m_Queue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Queue.Clear();
|
||||
m_Queue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,522 +6,519 @@ using Server.Mobiles;
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public class VendorGenerator
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "VendorGen", AccessLevel.Administrator, VendorGen_OnCommand );
|
||||
}
|
||||
|
||||
private static Rectangle2D[] m_BritRegions = {
|
||||
new Rectangle2D( new Point2D( 250, 750 ), new Point2D( 775, 1330 ) ),
|
||||
new Rectangle2D( new Point2D( 525, 2095 ), new Point2D( 925, 2430 ) ),
|
||||
new Rectangle2D( new Point2D( 1025, 2155 ), new Point2D( 1265, 2310 ) ),
|
||||
new Rectangle2D( new Point2D( 1635, 2430 ), new Point2D( 1705, 2508 ) ),
|
||||
new Rectangle2D( new Point2D( 1775, 2605 ), new Point2D( 2165, 2975 ) ),
|
||||
new Rectangle2D( new Point2D( 1055, 3520 ), new Point2D( 1570, 4075 ) ),
|
||||
new Rectangle2D( new Point2D( 2860, 3310 ), new Point2D( 3120, 3630 ) ),
|
||||
new Rectangle2D( new Point2D( 2470, 1855 ), new Point2D( 3950, 3045 ) ),
|
||||
new Rectangle2D( new Point2D( 3425, 990 ), new Point2D( 3900, 1455 ) ),
|
||||
new Rectangle2D( new Point2D( 4175, 735 ), new Point2D( 4840, 1600 ) ),
|
||||
new Rectangle2D( new Point2D( 2375, 330 ), new Point2D( 3100, 1045 ) ),
|
||||
new Rectangle2D( new Point2D( 2100, 1090 ), new Point2D( 2310, 1450 ) ),
|
||||
new Rectangle2D( new Point2D( 1495, 1400 ), new Point2D( 1550, 1475 ) ),
|
||||
new Rectangle2D( new Point2D( 1085, 1520 ), new Point2D( 1415, 1910 ) ),
|
||||
new Rectangle2D( new Point2D( 1410, 1500 ), new Point2D( 1745, 1795 ) ),
|
||||
new Rectangle2D( new Point2D( 5120, 2300 ), new Point2D( 6143, 4095 ) )
|
||||
};
|
||||
|
||||
private static Rectangle2D[] m_IlshRegions = {
|
||||
new Rectangle2D( new Point2D( 0, 0 ), new Point2D( 288*8, 200*8 ) )
|
||||
};
|
||||
|
||||
[Usage( "VendorGen" )]
|
||||
[Description( "Generates vendors based on display cases and floor plans. Analyzes the map files, slow." )]
|
||||
private static void VendorGen_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
Process( Map.Trammel, m_BritRegions );
|
||||
Process( Map.Felucca, m_BritRegions );
|
||||
Process( Map.Ilshenar, m_IlshRegions );
|
||||
}
|
||||
|
||||
private static bool GetFloorZ( Map map, int x, int y, out int z )
|
||||
{
|
||||
LandTile lt = map.Tiles.GetLandTile( x, y );
|
||||
|
||||
if ( IsFloor( lt.ID ) && map.CanFit( x, y, lt.Z, 16, false, false ) )
|
||||
{
|
||||
z = lt.Z;
|
||||
return true;
|
||||
}
|
||||
|
||||
StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y );
|
||||
|
||||
for ( int i = 0; i < tiles.Length; ++i )
|
||||
{
|
||||
StaticTile t = tiles[i];
|
||||
ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue];
|
||||
|
||||
if ( IsStaticFloor( t.ID ) && map.CanFit( x, y, t.Z + (id.Surface ? id.CalcHeight : 0), 16, false, false ) )
|
||||
{
|
||||
z = t.Z + (id.Surface ? id.CalcHeight : 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
z = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsFloor( Map map, int x, int y, bool canFit )
|
||||
{
|
||||
LandTile lt = map.Tiles.GetLandTile( x, y );
|
||||
|
||||
if ( IsFloor( lt.ID ) && (canFit||CanFit( map, x, y, lt.Z )) )
|
||||
return true;
|
||||
|
||||
StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y );
|
||||
|
||||
for ( int i = 0; i < tiles.Length; ++i )
|
||||
{
|
||||
StaticTile t = tiles[i];
|
||||
ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue];
|
||||
|
||||
if ( IsStaticFloor( t.ID ) && (canFit||CanFit( map, x, y, t.Z + (id.Surface ? id.CalcHeight : 0) )) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsFloor( int itemID )
|
||||
{
|
||||
itemID &= TileData.MaxLandValue;
|
||||
|
||||
return ( itemID >= 0x406 && itemID <= 0x51A );
|
||||
}
|
||||
|
||||
private static bool IsStaticFloor( int itemID )
|
||||
{
|
||||
return ( itemID >= 0x495 && itemID <= 0x514 )
|
||||
|| ( itemID >= 0x519 && itemID <= 0x53A );
|
||||
}
|
||||
|
||||
private static bool IsDisplayCase( int itemID )
|
||||
{
|
||||
return ( itemID >= 0xB00 && itemID <= 0xB02 )
|
||||
|| ( itemID >= 0xB06 && itemID <= 0xB0A )
|
||||
|| ( itemID >= 0xB0D && itemID <= 0xB17 );
|
||||
}
|
||||
|
||||
private static void Process( Map map, Rectangle2D[] regions )
|
||||
{
|
||||
m_ShopTable = new Hashtable();
|
||||
m_ShopList = new ArrayList();
|
||||
|
||||
World.Broadcast( 0x35, true, "Generating vendor spawns for {0}, please wait.", map );
|
||||
|
||||
for ( int i = 0; i < regions.Length; ++i )
|
||||
for ( int x = 0; x < map.Width; ++x )
|
||||
for ( int y = 0; y < map.Height; ++y )
|
||||
CheckPoint( map, regions[i].X + x, regions[i].Y + y );
|
||||
|
||||
for ( int i = 0; i < m_ShopList.Count; ++i )
|
||||
{
|
||||
ShopInfo si = (ShopInfo)m_ShopList[i];
|
||||
|
||||
int xTotal = 0;
|
||||
int yTotal = 0;
|
||||
|
||||
bool hasSpawner = false;
|
||||
|
||||
for ( int j = 0; !hasSpawner && j < si.m_Floor.Count; ++j )
|
||||
{
|
||||
Point2D fp = (Point2D)si.m_Floor[j];
|
||||
|
||||
xTotal += fp.X;
|
||||
yTotal += fp.Y;
|
||||
public class VendorGenerator
|
||||
{
|
||||
private static Rectangle2D[] m_BritRegions =
|
||||
{
|
||||
new Rectangle2D(new Point2D(250, 750), new Point2D(775, 1330)),
|
||||
new Rectangle2D(new Point2D(525, 2095), new Point2D(925, 2430)),
|
||||
new Rectangle2D(new Point2D(1025, 2155), new Point2D(1265, 2310)),
|
||||
new Rectangle2D(new Point2D(1635, 2430), new Point2D(1705, 2508)),
|
||||
new Rectangle2D(new Point2D(1775, 2605), new Point2D(2165, 2975)),
|
||||
new Rectangle2D(new Point2D(1055, 3520), new Point2D(1570, 4075)),
|
||||
new Rectangle2D(new Point2D(2860, 3310), new Point2D(3120, 3630)),
|
||||
new Rectangle2D(new Point2D(2470, 1855), new Point2D(3950, 3045)),
|
||||
new Rectangle2D(new Point2D(3425, 990), new Point2D(3900, 1455)),
|
||||
new Rectangle2D(new Point2D(4175, 735), new Point2D(4840, 1600)),
|
||||
new Rectangle2D(new Point2D(2375, 330), new Point2D(3100, 1045)),
|
||||
new Rectangle2D(new Point2D(2100, 1090), new Point2D(2310, 1450)),
|
||||
new Rectangle2D(new Point2D(1495, 1400), new Point2D(1550, 1475)),
|
||||
new Rectangle2D(new Point2D(1085, 1520), new Point2D(1415, 1910)),
|
||||
new Rectangle2D(new Point2D(1410, 1500), new Point2D(1745, 1795)),
|
||||
new Rectangle2D(new Point2D(5120, 2300), new Point2D(6143, 4095))
|
||||
};
|
||||
|
||||
private static Rectangle2D[] m_IlshRegions =
|
||||
{
|
||||
new Rectangle2D(new Point2D(0, 0), new Point2D(288 * 8, 200 * 8))
|
||||
};
|
||||
|
||||
private static Hashtable m_ShopTable;
|
||||
private static ArrayList m_ShopList;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("VendorGen", AccessLevel.Administrator, VendorGen_OnCommand);
|
||||
}
|
||||
|
||||
[Usage("VendorGen")]
|
||||
[Description("Generates vendors based on display cases and floor plans. Analyzes the map files, slow.")]
|
||||
private static void VendorGen_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
Process(Map.Trammel, m_BritRegions);
|
||||
Process(Map.Felucca, m_BritRegions);
|
||||
Process(Map.Ilshenar, m_IlshRegions);
|
||||
}
|
||||
|
||||
private static bool GetFloorZ(Map map, int x, int y, out int z)
|
||||
{
|
||||
LandTile lt = map.Tiles.GetLandTile(x, y);
|
||||
|
||||
if (IsFloor(lt.ID) && map.CanFit(x, y, lt.Z, 16, false, false))
|
||||
{
|
||||
z = lt.Z;
|
||||
return true;
|
||||
}
|
||||
|
||||
StaticTile[] tiles = map.Tiles.GetStaticTiles(x, y);
|
||||
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
{
|
||||
StaticTile t = tiles[i];
|
||||
ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue];
|
||||
|
||||
if (IsStaticFloor(t.ID) && map.CanFit(x, y, t.Z + (id.Surface ? id.CalcHeight : 0), 16, false, false))
|
||||
{
|
||||
z = t.Z + (id.Surface ? id.CalcHeight : 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
z = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsFloor(Map map, int x, int y, bool canFit)
|
||||
{
|
||||
LandTile lt = map.Tiles.GetLandTile(x, y);
|
||||
|
||||
if (IsFloor(lt.ID) && (canFit || CanFit(map, x, y, lt.Z)))
|
||||
return true;
|
||||
|
||||
StaticTile[] tiles = map.Tiles.GetStaticTiles(x, y);
|
||||
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
{
|
||||
StaticTile t = tiles[i];
|
||||
ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue];
|
||||
|
||||
if (IsStaticFloor(t.ID) && (canFit || CanFit(map, x, y, t.Z + (id.Surface ? id.CalcHeight : 0))))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsFloor(int itemID)
|
||||
{
|
||||
itemID &= TileData.MaxLandValue;
|
||||
|
||||
return itemID >= 0x406 && itemID <= 0x51A;
|
||||
}
|
||||
|
||||
private static bool IsStaticFloor(int itemID)
|
||||
{
|
||||
return itemID >= 0x495 && itemID <= 0x514
|
||||
|| itemID >= 0x519 && itemID <= 0x53A;
|
||||
}
|
||||
|
||||
private static bool IsDisplayCase(int itemID)
|
||||
{
|
||||
return itemID >= 0xB00 && itemID <= 0xB02
|
||||
|| itemID >= 0xB06 && itemID <= 0xB0A
|
||||
|| itemID >= 0xB0D && itemID <= 0xB17;
|
||||
}
|
||||
|
||||
private static void Process(Map map, Rectangle2D[] regions)
|
||||
{
|
||||
m_ShopTable = new Hashtable();
|
||||
m_ShopList = new ArrayList();
|
||||
|
||||
World.Broadcast(0x35, true, "Generating vendor spawns for {0}, please wait.", map);
|
||||
|
||||
for (int i = 0; i < regions.Length; ++i)
|
||||
for (int x = 0; x < map.Width; ++x)
|
||||
for (int y = 0; y < map.Height; ++y)
|
||||
CheckPoint(map, regions[i].X + x, regions[i].Y + y);
|
||||
|
||||
for (int i = 0; i < m_ShopList.Count; ++i)
|
||||
{
|
||||
ShopInfo si = (ShopInfo)m_ShopList[i];
|
||||
|
||||
int xTotal = 0;
|
||||
int yTotal = 0;
|
||||
|
||||
bool hasSpawner = false;
|
||||
|
||||
IPooledEnumerable<Spawner> eable = map.GetItemsInRange<Spawner>( new Point3D( fp.X, fp.Y, 0 ), 0 );
|
||||
for (int j = 0; !hasSpawner && j < si.m_Floor.Count; ++j)
|
||||
{
|
||||
Point2D fp = (Point2D)si.m_Floor[j];
|
||||
|
||||
foreach ( Spawner item in eable )
|
||||
{
|
||||
hasSpawner = true;
|
||||
break;
|
||||
}
|
||||
xTotal += fp.X;
|
||||
yTotal += fp.Y;
|
||||
|
||||
eable.Free();
|
||||
IPooledEnumerable<Spawner> eable = map.GetItemsInRange<Spawner>(new Point3D(fp.X, fp.Y, 0), 0);
|
||||
|
||||
if ( hasSpawner )
|
||||
break;
|
||||
}
|
||||
foreach (Spawner item in eable)
|
||||
{
|
||||
hasSpawner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( hasSpawner )
|
||||
continue;
|
||||
|
||||
int xAvg = xTotal / si.m_Floor.Count;
|
||||
int yAvg = yTotal / si.m_Floor.Count;
|
||||
|
||||
ArrayList names = new ArrayList();
|
||||
ShopFlags flags = si.m_Flags;
|
||||
|
||||
if ( (flags & ShopFlags.Armor) != 0 )
|
||||
names.Add( "armorer" );
|
||||
|
||||
if ( (flags & ShopFlags.MetalWeapon) != 0 )
|
||||
names.Add( "weaponsmith" );
|
||||
|
||||
if ( (flags & ShopFlags.ArcheryWeapon) != 0 )
|
||||
names.Add( "bowyer" );
|
||||
|
||||
if ( (flags & ShopFlags.Scroll) != 0 )
|
||||
names.Add( "mage" );
|
||||
|
||||
if ( (flags & ShopFlags.Spellbook) != 0 )
|
||||
names.Add( "mage" );
|
||||
|
||||
if ( (flags & ShopFlags.Bread) != 0 )
|
||||
names.Add( "baker" );
|
||||
|
||||
if ( (flags & ShopFlags.Jewel) != 0 )
|
||||
names.Add( "jeweler" );
|
||||
|
||||
if ( (flags & ShopFlags.Potion) != 0 )
|
||||
{
|
||||
names.Add( "herbalist" );
|
||||
names.Add( "alchemist" );
|
||||
names.Add( "mage" );
|
||||
}
|
||||
|
||||
if ( (flags & ShopFlags.Reagent) != 0 )
|
||||
{
|
||||
names.Add( "mage" );
|
||||
names.Add( "herbalist" );
|
||||
}
|
||||
|
||||
if ( (flags & ShopFlags.Clothes) != 0 )
|
||||
{
|
||||
names.Add( "tailor" );
|
||||
names.Add( "weaver" );
|
||||
}
|
||||
|
||||
for ( int j = 0; j < names.Count; ++j )
|
||||
{
|
||||
Point2D cp = Point2D.Zero;
|
||||
int dist = 100000;
|
||||
int tz;
|
||||
|
||||
for ( int k = 0; k < si.m_Floor.Count; ++k )
|
||||
{
|
||||
Point2D fp = (Point2D)si.m_Floor[k];
|
||||
|
||||
int rx = fp.X - xAvg;
|
||||
int ry = fp.Y - yAvg;
|
||||
int fd = (int)Math.Sqrt( rx*rx + ry*ry );
|
||||
|
||||
if ( fd > 0 && fd < 5 )
|
||||
fd -= Utility.Random( 10 );
|
||||
|
||||
if ( fd < dist && GetFloorZ( map, fp.X, fp.Y, out tz ) )
|
||||
{
|
||||
dist = fd;
|
||||
cp = fp;
|
||||
}
|
||||
}
|
||||
eable.Free();
|
||||
|
||||
if ( cp == Point2D.Zero )
|
||||
continue;
|
||||
if (hasSpawner)
|
||||
break;
|
||||
}
|
||||
|
||||
int z;
|
||||
if (hasSpawner)
|
||||
continue;
|
||||
|
||||
if ( !GetFloorZ( map, cp.X, cp.Y, out z ) )
|
||||
continue;
|
||||
int xAvg = xTotal / si.m_Floor.Count;
|
||||
int yAvg = yTotal / si.m_Floor.Count;
|
||||
|
||||
new Spawner( 1, 1, 1, 0, 4, (string)names[j] ).MoveToWorld( new Point3D( cp.X, cp.Y, z ), map );
|
||||
}
|
||||
}
|
||||
ArrayList names = new ArrayList();
|
||||
ShopFlags flags = si.m_Flags;
|
||||
|
||||
World.Broadcast( 0x35, true, "Generation complete. {0} spawners generated.", m_ShopList.Count );
|
||||
}
|
||||
if ((flags & ShopFlags.Armor) != 0)
|
||||
names.Add("armorer");
|
||||
|
||||
private static void CheckPoint( Map map, int x, int y )
|
||||
{
|
||||
if ( IsFloor( map, x, y, true ) )
|
||||
CheckFloor( map, x, y );
|
||||
}
|
||||
if ((flags & ShopFlags.MetalWeapon) != 0)
|
||||
names.Add("weaponsmith");
|
||||
|
||||
private static void CheckFloor( Map map, int x, int y )
|
||||
{
|
||||
StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y );
|
||||
if ((flags & ShopFlags.ArcheryWeapon) != 0)
|
||||
names.Add("bowyer");
|
||||
|
||||
for ( int i = 0; i < tiles.Length; ++i )
|
||||
{
|
||||
if ( IsDisplayCase( tiles[i].ID ) )
|
||||
{
|
||||
ProcessDisplayCase( map, tiles, x, y );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((flags & ShopFlags.Scroll) != 0)
|
||||
names.Add("mage");
|
||||
|
||||
[Flags]
|
||||
private enum ShopFlags
|
||||
{
|
||||
None = 0x000,
|
||||
Armor = 0x001,
|
||||
MetalWeapon = 0x002,
|
||||
Jewel = 0x004,
|
||||
Reagent = 0x008,
|
||||
Potion = 0x010,
|
||||
Bread = 0x020,
|
||||
Clothes = 0x040,
|
||||
ArcheryWeapon = 0x080,
|
||||
Scroll = 0x100,
|
||||
Spellbook = 0x200
|
||||
}
|
||||
|
||||
private static bool IsClothes( int itemID )
|
||||
{
|
||||
if ( itemID >= 0x1515 && itemID <= 0x1518 )
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x152E && itemID <= 0x1531 )
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x1537 && itemID <= 0x154C )
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x1EFD && itemID <= 0x1F04 )
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x170B && itemID <= 0x171C )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsArmor( int itemID )
|
||||
{
|
||||
if ( itemID >= 0x13BB && itemID <= 0x13E2 )
|
||||
return true;
|
||||
if ((flags & ShopFlags.Spellbook) != 0)
|
||||
names.Add("mage");
|
||||
|
||||
if ( itemID >= 0x13E5 && itemID <= 0x13F2 )
|
||||
return true;
|
||||
if ((flags & ShopFlags.Bread) != 0)
|
||||
names.Add("baker");
|
||||
|
||||
if ( itemID >= 0x1408 && itemID <= 0x141A )
|
||||
return true;
|
||||
if ((flags & ShopFlags.Jewel) != 0)
|
||||
names.Add("jeweler");
|
||||
|
||||
if ( itemID >= 0x144E && itemID <= 0x1457 )
|
||||
return true;
|
||||
if ((flags & ShopFlags.Potion) != 0)
|
||||
{
|
||||
names.Add("herbalist");
|
||||
names.Add("alchemist");
|
||||
names.Add("mage");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if ((flags & ShopFlags.Reagent) != 0)
|
||||
{
|
||||
names.Add("mage");
|
||||
names.Add("herbalist");
|
||||
}
|
||||
|
||||
private static bool IsMetalWeapon( int itemID )
|
||||
{
|
||||
if ( itemID >= 0xF43 && itemID <= 0xF4E )
|
||||
return true;
|
||||
if ((flags & ShopFlags.Clothes) != 0)
|
||||
{
|
||||
names.Add("tailor");
|
||||
names.Add("weaver");
|
||||
}
|
||||
|
||||
if ( itemID >= 0xF51 && itemID <= 0xF52 )
|
||||
return true;
|
||||
for (int j = 0; j < names.Count; ++j)
|
||||
{
|
||||
Point2D cp = Point2D.Zero;
|
||||
int dist = 100000;
|
||||
int tz;
|
||||
|
||||
if ( itemID >= 0xF5C && itemID <= 0xF63 )
|
||||
return true;
|
||||
for (int k = 0; k < si.m_Floor.Count; ++k)
|
||||
{
|
||||
Point2D fp = (Point2D)si.m_Floor[k];
|
||||
|
||||
if ( itemID >= 0x13AF && itemID <= 0x13B0 )
|
||||
return true;
|
||||
int rx = fp.X - xAvg;
|
||||
int ry = fp.Y - yAvg;
|
||||
int fd = (int)Math.Sqrt(rx * rx + ry * ry);
|
||||
|
||||
if ( itemID >= 0x13B5 && itemID <= 0x13BA )
|
||||
return true;
|
||||
if (fd > 0 && fd < 5)
|
||||
fd -= Utility.Random(10);
|
||||
|
||||
if ( itemID >= 0x13FA && itemID <= 0x13FB )
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x13FE && itemID <= 0x1407 )
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x1438 && itemID <= 0x1443 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsArcheryWeapon( int itemID )
|
||||
{
|
||||
if ( itemID >= 0xF4F && itemID <= 0xF50 )
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0x13B1 && itemID <= 0x13B2 )
|
||||
return true;
|
||||
if (fd < dist && GetFloorZ(map, fp.X, fp.Y, out tz))
|
||||
{
|
||||
dist = fd;
|
||||
cp = fp;
|
||||
}
|
||||
}
|
||||
|
||||
if ( itemID >= 0x13FC && itemID <= 0x13FD )
|
||||
return true;
|
||||
if (cp == Point2D.Zero)
|
||||
continue;
|
||||
|
||||
return false;
|
||||
}
|
||||
int z;
|
||||
|
||||
private static ShopFlags ProcessDisplayedItem( int itemID )
|
||||
{
|
||||
itemID &= TileData.MaxItemValue;
|
||||
if (!GetFloorZ(map, cp.X, cp.Y, out z))
|
||||
continue;
|
||||
|
||||
ShopFlags res = ShopFlags.None;
|
||||
new Spawner(1, 1, 1, 0, 4, (string)names[j]).MoveToWorld(new Point3D(cp.X, cp.Y, z), map);
|
||||
}
|
||||
}
|
||||
|
||||
ItemData id = TileData.ItemTable[itemID];
|
||||
TileFlag flags = id.Flags;
|
||||
World.Broadcast(0x35, true, "Generation complete. {0} spawners generated.", m_ShopList.Count);
|
||||
}
|
||||
|
||||
if ( (flags & TileFlag.Wearable) != 0 )
|
||||
{
|
||||
if ( IsClothes( itemID ) )
|
||||
res |= ShopFlags.Clothes;
|
||||
else if ( IsArmor( itemID ) )
|
||||
res |= ShopFlags.Armor;
|
||||
else if ( IsMetalWeapon( itemID ) )
|
||||
res |= ShopFlags.MetalWeapon;
|
||||
else if ( IsArcheryWeapon( itemID ) )
|
||||
res |= ShopFlags.ArcheryWeapon;
|
||||
}
|
||||
private static void CheckPoint(Map map, int x, int y)
|
||||
{
|
||||
if (IsFloor(map, x, y, true))
|
||||
CheckFloor(map, x, y);
|
||||
}
|
||||
|
||||
if ( itemID == 0x98C || itemID == 0x103B || itemID == 0x103C )
|
||||
res |= ShopFlags.Bread;
|
||||
private static void CheckFloor(Map map, int x, int y)
|
||||
{
|
||||
StaticTile[] tiles = map.Tiles.GetStaticTiles(x, y);
|
||||
|
||||
if ( itemID >= 0xF0F && itemID <= 0xF30 )
|
||||
res |= ShopFlags.Jewel;
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
if (IsDisplayCase(tiles[i].ID))
|
||||
{
|
||||
ProcessDisplayCase(map, tiles, x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( itemID >= 0xEFB && itemID <= 0xF0D )
|
||||
res |= ShopFlags.Potion;
|
||||
private static bool IsClothes(int itemID)
|
||||
{
|
||||
if (itemID >= 0x1515 && itemID <= 0x1518)
|
||||
return true;
|
||||
|
||||
if ( itemID >= 0xF78 && itemID <= 0xF91 )
|
||||
res |= ShopFlags.Reagent;
|
||||
if (itemID >= 0x152E && itemID <= 0x1531)
|
||||
return true;
|
||||
|
||||
if ( (itemID >= 0xE35 && itemID <= 0xE3A) || (itemID >= 0xEF4 && itemID <= 0xEF9) || (itemID >= 0x1F2D && itemID <= 0x1F72) )
|
||||
res |= ShopFlags.Scroll;
|
||||
if (itemID >= 0x1537 && itemID <= 0x154C)
|
||||
return true;
|
||||
|
||||
if ( itemID == 0xE38 || itemID == 0xEFA )
|
||||
res |= ShopFlags.Spellbook;
|
||||
if (itemID >= 0x1EFD && itemID <= 0x1F04)
|
||||
return true;
|
||||
|
||||
return res;
|
||||
}
|
||||
if (itemID >= 0x170B && itemID <= 0x171C)
|
||||
return true;
|
||||
|
||||
private static void ProcessDisplayCase( Map map, StaticTile[] tiles, int x, int y )
|
||||
{
|
||||
ShopFlags flags = ShopFlags.None;
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < tiles.Length; ++i )
|
||||
flags |= ProcessDisplayedItem( tiles[i].ID );
|
||||
private static bool IsArmor(int itemID)
|
||||
{
|
||||
if (itemID >= 0x13BB && itemID <= 0x13E2)
|
||||
return true;
|
||||
|
||||
if ( flags != ShopFlags.None )
|
||||
{
|
||||
Point2D p = new Point2D( x, y );
|
||||
ShopInfo si = (ShopInfo)m_ShopTable[p];
|
||||
if (itemID >= 0x13E5 && itemID <= 0x13F2)
|
||||
return true;
|
||||
|
||||
if ( si == null )
|
||||
{
|
||||
ArrayList floor = new ArrayList();
|
||||
if (itemID >= 0x1408 && itemID <= 0x141A)
|
||||
return true;
|
||||
|
||||
RecurseFindFloor( map, x, y, floor );
|
||||
if (itemID >= 0x144E && itemID <= 0x1457)
|
||||
return true;
|
||||
|
||||
if ( floor.Count == 0 )
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
si = new ShopInfo();
|
||||
si.m_Flags = flags;
|
||||
si.m_Floor = floor;
|
||||
m_ShopList.Add( si );
|
||||
private static bool IsMetalWeapon(int itemID)
|
||||
{
|
||||
if (itemID >= 0xF43 && itemID <= 0xF4E)
|
||||
return true;
|
||||
|
||||
for ( int i = 0; i < floor.Count; ++i )
|
||||
m_ShopTable[(Point2D)floor[i]] = si;
|
||||
}
|
||||
else
|
||||
{
|
||||
si.m_Flags |= flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Hashtable m_ShopTable;
|
||||
private static ArrayList m_ShopList;
|
||||
|
||||
private class ShopInfo
|
||||
{
|
||||
public ShopFlags m_Flags;
|
||||
public ArrayList m_Floor;
|
||||
}
|
||||
|
||||
private static bool CanFit( Map map, int x, int y, int z )
|
||||
{
|
||||
bool hasSurface = false;
|
||||
if (itemID >= 0xF51 && itemID <= 0xF52)
|
||||
return true;
|
||||
|
||||
LandTile lt = map.Tiles.GetLandTile( x, y );
|
||||
int lowZ = 0, avgZ = 0, topZ = 0;
|
||||
|
||||
map.GetAverageZ( x, y, ref lowZ, ref avgZ, ref topZ );
|
||||
TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;
|
||||
|
||||
if ( (landFlags & TileFlag.Impassable) != 0 && topZ > z && (z + 16) > lowZ )
|
||||
return false;
|
||||
if ( (landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored )
|
||||
hasSurface = true;
|
||||
|
||||
StaticTile[] staticTiles = map.Tiles.GetStaticTiles( x, y );
|
||||
|
||||
bool surface, impassable;
|
||||
|
||||
for ( int i = 0; i < staticTiles.Length; ++i )
|
||||
{
|
||||
if ( IsDisplayCase( staticTiles[i].ID ) )
|
||||
continue;
|
||||
|
||||
ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue];
|
||||
|
||||
surface = id.Surface;
|
||||
impassable = id.Impassable;
|
||||
|
||||
if ( (surface || impassable) && (staticTiles[i].Z + id.CalcHeight) > z && (z + 16) > staticTiles[i].Z )
|
||||
return false;
|
||||
if ( surface && !impassable && z == (staticTiles[i].Z + id.CalcHeight) )
|
||||
hasSurface = true;
|
||||
}
|
||||
|
||||
Sector sector = map.GetSector( x, y );
|
||||
List<Item> items = sector.Items;
|
||||
|
||||
for ( int i = 0; i < items.Count; ++i )
|
||||
{
|
||||
Item item = items[i];
|
||||
|
||||
if ( item.AtWorldPoint( x, y ) )
|
||||
{
|
||||
ItemData id = item.ItemData;
|
||||
surface = id.Surface;
|
||||
impassable = id.Impassable;
|
||||
|
||||
if ( (surface || impassable) && (item.Z + id.CalcHeight) > z && (z + 16) > item.Z )
|
||||
return false;
|
||||
if ( surface && !impassable && z == (item.Z + id.CalcHeight) )
|
||||
hasSurface = true;
|
||||
}
|
||||
}
|
||||
|
||||
return hasSurface;
|
||||
}
|
||||
|
||||
private static void RecurseFindFloor( Map map, int x, int y, ArrayList floor )
|
||||
{
|
||||
Point2D p = new Point2D( x, y );
|
||||
|
||||
if ( floor.Contains( p ) )
|
||||
return;
|
||||
|
||||
floor.Add( p );
|
||||
|
||||
for ( int xo = -1; xo <= 1; ++xo )
|
||||
{
|
||||
for ( int yo = -1; yo <= 1; ++yo )
|
||||
{
|
||||
if ( (xo != 0 || yo != 0) && IsFloor( map, x + xo, y + yo, false ) )
|
||||
RecurseFindFloor( map, x + xo, y + yo, floor );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemID >= 0xF5C && itemID <= 0xF63)
|
||||
return true;
|
||||
|
||||
if (itemID >= 0x13AF && itemID <= 0x13B0)
|
||||
return true;
|
||||
|
||||
if (itemID >= 0x13B5 && itemID <= 0x13BA)
|
||||
return true;
|
||||
|
||||
if (itemID >= 0x13FA && itemID <= 0x13FB)
|
||||
return true;
|
||||
|
||||
if (itemID >= 0x13FE && itemID <= 0x1407)
|
||||
return true;
|
||||
|
||||
if (itemID >= 0x1438 && itemID <= 0x1443)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsArcheryWeapon(int itemID)
|
||||
{
|
||||
if (itemID >= 0xF4F && itemID <= 0xF50)
|
||||
return true;
|
||||
|
||||
if (itemID >= 0x13B1 && itemID <= 0x13B2)
|
||||
return true;
|
||||
|
||||
if (itemID >= 0x13FC && itemID <= 0x13FD)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ShopFlags ProcessDisplayedItem(int itemID)
|
||||
{
|
||||
itemID &= TileData.MaxItemValue;
|
||||
|
||||
ShopFlags res = ShopFlags.None;
|
||||
|
||||
ItemData id = TileData.ItemTable[itemID];
|
||||
TileFlag flags = id.Flags;
|
||||
|
||||
if ((flags & TileFlag.Wearable) != 0)
|
||||
{
|
||||
if (IsClothes(itemID))
|
||||
res |= ShopFlags.Clothes;
|
||||
else if (IsArmor(itemID))
|
||||
res |= ShopFlags.Armor;
|
||||
else if (IsMetalWeapon(itemID))
|
||||
res |= ShopFlags.MetalWeapon;
|
||||
else if (IsArcheryWeapon(itemID))
|
||||
res |= ShopFlags.ArcheryWeapon;
|
||||
}
|
||||
|
||||
if (itemID == 0x98C || itemID == 0x103B || itemID == 0x103C)
|
||||
res |= ShopFlags.Bread;
|
||||
|
||||
if (itemID >= 0xF0F && itemID <= 0xF30)
|
||||
res |= ShopFlags.Jewel;
|
||||
|
||||
if (itemID >= 0xEFB && itemID <= 0xF0D)
|
||||
res |= ShopFlags.Potion;
|
||||
|
||||
if (itemID >= 0xF78 && itemID <= 0xF91)
|
||||
res |= ShopFlags.Reagent;
|
||||
|
||||
if (itemID >= 0xE35 && itemID <= 0xE3A || itemID >= 0xEF4 && itemID <= 0xEF9 ||
|
||||
itemID >= 0x1F2D && itemID <= 0x1F72)
|
||||
res |= ShopFlags.Scroll;
|
||||
|
||||
if (itemID == 0xE38 || itemID == 0xEFA)
|
||||
res |= ShopFlags.Spellbook;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void ProcessDisplayCase(Map map, StaticTile[] tiles, int x, int y)
|
||||
{
|
||||
ShopFlags flags = ShopFlags.None;
|
||||
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
flags |= ProcessDisplayedItem(tiles[i].ID);
|
||||
|
||||
if (flags != ShopFlags.None)
|
||||
{
|
||||
Point2D p = new Point2D(x, y);
|
||||
ShopInfo si = (ShopInfo)m_ShopTable[p];
|
||||
|
||||
if (si == null)
|
||||
{
|
||||
ArrayList floor = new ArrayList();
|
||||
|
||||
RecurseFindFloor(map, x, y, floor);
|
||||
|
||||
if (floor.Count == 0)
|
||||
return;
|
||||
|
||||
si = new ShopInfo();
|
||||
si.m_Flags = flags;
|
||||
si.m_Floor = floor;
|
||||
m_ShopList.Add(si);
|
||||
|
||||
for (int i = 0; i < floor.Count; ++i)
|
||||
m_ShopTable[(Point2D)floor[i]] = si;
|
||||
}
|
||||
else
|
||||
{
|
||||
si.m_Flags |= flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CanFit(Map map, int x, int y, int z)
|
||||
{
|
||||
bool hasSurface = false;
|
||||
|
||||
LandTile lt = map.Tiles.GetLandTile(x, y);
|
||||
int lowZ = 0, avgZ = 0, topZ = 0;
|
||||
|
||||
map.GetAverageZ(x, y, ref lowZ, ref avgZ, ref topZ);
|
||||
TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;
|
||||
|
||||
if ((landFlags & TileFlag.Impassable) != 0 && topZ > z && z + 16 > lowZ)
|
||||
return false;
|
||||
if ((landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored)
|
||||
hasSurface = true;
|
||||
|
||||
StaticTile[] staticTiles = map.Tiles.GetStaticTiles(x, y);
|
||||
|
||||
bool surface, impassable;
|
||||
|
||||
for (int i = 0; i < staticTiles.Length; ++i)
|
||||
{
|
||||
if (IsDisplayCase(staticTiles[i].ID))
|
||||
continue;
|
||||
|
||||
ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue];
|
||||
|
||||
surface = id.Surface;
|
||||
impassable = id.Impassable;
|
||||
|
||||
if ((surface || impassable) && staticTiles[i].Z + id.CalcHeight > z && z + 16 > staticTiles[i].Z)
|
||||
return false;
|
||||
if (surface && !impassable && z == staticTiles[i].Z + id.CalcHeight)
|
||||
hasSurface = true;
|
||||
}
|
||||
|
||||
Sector sector = map.GetSector(x, y);
|
||||
List<Item> items = sector.Items;
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item item = items[i];
|
||||
|
||||
if (item.AtWorldPoint(x, y))
|
||||
{
|
||||
ItemData id = item.ItemData;
|
||||
surface = id.Surface;
|
||||
impassable = id.Impassable;
|
||||
|
||||
if ((surface || impassable) && item.Z + id.CalcHeight > z && z + 16 > item.Z)
|
||||
return false;
|
||||
if (surface && !impassable && z == item.Z + id.CalcHeight)
|
||||
hasSurface = true;
|
||||
}
|
||||
}
|
||||
|
||||
return hasSurface;
|
||||
}
|
||||
|
||||
private static void RecurseFindFloor(Map map, int x, int y, ArrayList floor)
|
||||
{
|
||||
Point2D p = new Point2D(x, y);
|
||||
|
||||
if (floor.Contains(p))
|
||||
return;
|
||||
|
||||
floor.Add(p);
|
||||
|
||||
for (int xo = -1; xo <= 1; ++xo)
|
||||
for (int yo = -1; yo <= 1; ++yo)
|
||||
if ((xo != 0 || yo != 0) && IsFloor(map, x + xo, y + yo, false))
|
||||
RecurseFindFloor(map, x + xo, y + yo, floor);
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum ShopFlags
|
||||
{
|
||||
None = 0x000,
|
||||
Armor = 0x001,
|
||||
MetalWeapon = 0x002,
|
||||
Jewel = 0x004,
|
||||
Reagent = 0x008,
|
||||
Potion = 0x010,
|
||||
Bread = 0x020,
|
||||
Clothes = 0x040,
|
||||
ArcheryWeapon = 0x080,
|
||||
Scroll = 0x100,
|
||||
Spellbook = 0x200
|
||||
}
|
||||
|
||||
private class ShopInfo
|
||||
{
|
||||
public ShopFlags m_Flags;
|
||||
public ArrayList m_Floor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,194 +1,185 @@
|
|||
#region References
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
using Server.Guilds;
|
||||
using Server.Network;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class StatusPage : Timer
|
||||
{
|
||||
public static readonly bool Enabled = false;
|
||||
public class StatusPage : Timer
|
||||
{
|
||||
public static readonly bool Enabled = false;
|
||||
|
||||
private static HttpListener _Listener;
|
||||
private static HttpListener _Listener;
|
||||
|
||||
private static string _StatusPage = string.Empty;
|
||||
private static byte[] _StatusBuffer = new byte[0];
|
||||
private static string _StatusPage = string.Empty;
|
||||
private static byte[] _StatusBuffer = new byte[0];
|
||||
|
||||
private static readonly object _StatusLock = new object();
|
||||
private static readonly object _StatusLock = new object();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public StatusPage()
|
||||
: base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(60.0))
|
||||
{
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
}
|
||||
|
||||
new StatusPage().Start();
|
||||
public static void Initialize()
|
||||
{
|
||||
if (!Enabled) return;
|
||||
|
||||
Listen();
|
||||
}
|
||||
new StatusPage().Start();
|
||||
|
||||
private static void Listen()
|
||||
{
|
||||
if (!HttpListener.IsSupported)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Listen();
|
||||
}
|
||||
|
||||
if (_Listener == null)
|
||||
{
|
||||
_Listener = new HttpListener();
|
||||
_Listener.Prefixes.Add("http://*:80/status/");
|
||||
_Listener.Start();
|
||||
}
|
||||
else if (!_Listener.IsListening)
|
||||
{
|
||||
_Listener.Start();
|
||||
}
|
||||
private static void Listen()
|
||||
{
|
||||
if (!HttpListener.IsSupported) return;
|
||||
|
||||
if (_Listener.IsListening)
|
||||
{
|
||||
_Listener.BeginGetContext(ListenerCallback, null);
|
||||
}
|
||||
}
|
||||
if (_Listener == null)
|
||||
{
|
||||
_Listener = new HttpListener();
|
||||
_Listener.Prefixes.Add("http://*:80/status/");
|
||||
_Listener.Start();
|
||||
}
|
||||
else if (!_Listener.IsListening)
|
||||
{
|
||||
_Listener.Start();
|
||||
}
|
||||
|
||||
private static void ListenerCallback(IAsyncResult result)
|
||||
{
|
||||
try
|
||||
{
|
||||
var context = _Listener.EndGetContext(result);
|
||||
if (_Listener.IsListening) _Listener.BeginGetContext(ListenerCallback, null);
|
||||
}
|
||||
|
||||
byte[] buffer;
|
||||
private static void ListenerCallback(IAsyncResult result)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpListenerContext context = _Listener.EndGetContext(result);
|
||||
|
||||
lock (_StatusLock)
|
||||
{
|
||||
buffer = _StatusBuffer;
|
||||
}
|
||||
byte[] buffer;
|
||||
|
||||
context.Response.ContentLength64 = buffer.Length;
|
||||
context.Response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||
context.Response.OutputStream.Close();
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
lock (_StatusLock)
|
||||
{
|
||||
buffer = _StatusBuffer;
|
||||
}
|
||||
|
||||
Listen();
|
||||
}
|
||||
context.Response.ContentLength64 = buffer.Length;
|
||||
context.Response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||
context.Response.OutputStream.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
private static string Encode(string input)
|
||||
{
|
||||
var sb = new StringBuilder(input);
|
||||
Listen();
|
||||
}
|
||||
|
||||
sb.Replace("&", "&");
|
||||
sb.Replace("<", "<");
|
||||
sb.Replace(">", ">");
|
||||
sb.Replace("\"", """);
|
||||
sb.Replace("'", "'");
|
||||
private static string Encode(string input)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(input);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
sb.Replace("&", "&");
|
||||
sb.Replace("<", "<");
|
||||
sb.Replace(">", ">");
|
||||
sb.Replace("\"", """);
|
||||
sb.Replace("'", "'");
|
||||
|
||||
public StatusPage()
|
||||
: base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(60.0))
|
||||
{
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (!Directory.Exists("web"))
|
||||
{
|
||||
Directory.CreateDirectory("web");
|
||||
}
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (!Directory.Exists("web")) Directory.CreateDirectory("web");
|
||||
|
||||
using (var op = new StreamWriter("web/status.html"))
|
||||
{
|
||||
op.WriteLine("<!DOCTYPE html>");
|
||||
op.WriteLine("<html>");
|
||||
op.WriteLine(" <head>");
|
||||
op.WriteLine(" <title>" + ServerList.ServerName + " Server Status</title>");
|
||||
op.WriteLine(" </head>");
|
||||
op.WriteLine(" <style type=\"text/css\">");
|
||||
op.WriteLine(" body { background: #999; }");
|
||||
op.WriteLine(" table { width: 100%; }");
|
||||
op.WriteLine(" tr.ruo-header td { background: #000; color: #FFF; }");
|
||||
op.WriteLine(" tr.odd td { background: #222; color: #DDD; }");
|
||||
op.WriteLine(" tr.even td { background: #DDD; color: #222; }");
|
||||
op.WriteLine(" </style>");
|
||||
op.WriteLine(" <body>");
|
||||
op.WriteLine(" <h1>RunUO Server Status</h1>");
|
||||
op.WriteLine(" <h3>Online clients</h3>");
|
||||
op.WriteLine(" <table cellpadding=\"0\" cellspacing=\"0\">");
|
||||
op.WriteLine(" <tr class=\"ruo-header\"><td>Name</td><td>Location</td><td>Kills</td><td>Karma/Fame</td></tr>");
|
||||
using (StreamWriter op = new StreamWriter("web/status.html"))
|
||||
{
|
||||
op.WriteLine("<!DOCTYPE html>");
|
||||
op.WriteLine("<html>");
|
||||
op.WriteLine(" <head>");
|
||||
op.WriteLine(" <title>" + ServerList.ServerName + " Server Status</title>");
|
||||
op.WriteLine(" </head>");
|
||||
op.WriteLine(" <style type=\"text/css\">");
|
||||
op.WriteLine(" body { background: #999; }");
|
||||
op.WriteLine(" table { width: 100%; }");
|
||||
op.WriteLine(" tr.ruo-header td { background: #000; color: #FFF; }");
|
||||
op.WriteLine(" tr.odd td { background: #222; color: #DDD; }");
|
||||
op.WriteLine(" tr.even td { background: #DDD; color: #222; }");
|
||||
op.WriteLine(" </style>");
|
||||
op.WriteLine(" <body>");
|
||||
op.WriteLine(" <h1>RunUO Server Status</h1>");
|
||||
op.WriteLine(" <h3>Online clients</h3>");
|
||||
op.WriteLine(" <table cellpadding=\"0\" cellspacing=\"0\">");
|
||||
op.WriteLine(
|
||||
" <tr class=\"ruo-header\"><td>Name</td><td>Location</td><td>Kills</td><td>Karma/Fame</td></tr>");
|
||||
|
||||
var index = 0;
|
||||
int index = 0;
|
||||
|
||||
foreach (var m in NetState.Instances.Where(state => state.Mobile != null).Select(state => state.Mobile))
|
||||
{
|
||||
++index;
|
||||
foreach (Mobile m in NetState.Instances.Where(state => state.Mobile != null).Select(state => state.Mobile))
|
||||
{
|
||||
++index;
|
||||
|
||||
var g = m.Guild as Guild;
|
||||
Guild g = m.Guild as Guild;
|
||||
|
||||
op.Write(" <tr class=\"ruo-result " + (index % 2 == 0 ? "even" : "odd") + "\"><td>");
|
||||
op.Write(" <tr class=\"ruo-result " + (index % 2 == 0 ? "even" : "odd") + "\"><td>");
|
||||
|
||||
if (g != null)
|
||||
{
|
||||
op.Write(Encode(m.Name));
|
||||
op.Write(" [");
|
||||
if (g != null)
|
||||
{
|
||||
op.Write(Encode(m.Name));
|
||||
op.Write(" [");
|
||||
|
||||
var title = m.GuildTitle;
|
||||
string title = m.GuildTitle;
|
||||
|
||||
title = title != null ? title.Trim() : string.Empty;
|
||||
title = title != null ? title.Trim() : string.Empty;
|
||||
|
||||
if (title.Length > 0)
|
||||
{
|
||||
op.Write(Encode(title));
|
||||
op.Write(", ");
|
||||
}
|
||||
if (title.Length > 0)
|
||||
{
|
||||
op.Write(Encode(title));
|
||||
op.Write(", ");
|
||||
}
|
||||
|
||||
op.Write(Encode(g.Abbreviation));
|
||||
op.Write(Encode(g.Abbreviation));
|
||||
|
||||
op.Write(']');
|
||||
}
|
||||
else
|
||||
{
|
||||
op.Write(Encode(m.Name));
|
||||
}
|
||||
op.Write(']');
|
||||
}
|
||||
else
|
||||
{
|
||||
op.Write(Encode(m.Name));
|
||||
}
|
||||
|
||||
op.Write("</td><td>");
|
||||
op.Write(m.X);
|
||||
op.Write(", ");
|
||||
op.Write(m.Y);
|
||||
op.Write(", ");
|
||||
op.Write(m.Z);
|
||||
op.Write(" (");
|
||||
op.Write(m.Map);
|
||||
op.Write(")</td><td>");
|
||||
op.Write(m.Kills);
|
||||
op.Write("</td><td>");
|
||||
op.Write(m.Karma);
|
||||
op.Write(" / ");
|
||||
op.Write(m.Fame);
|
||||
op.WriteLine("</td></tr>");
|
||||
}
|
||||
op.Write("</td><td>");
|
||||
op.Write(m.X);
|
||||
op.Write(", ");
|
||||
op.Write(m.Y);
|
||||
op.Write(", ");
|
||||
op.Write(m.Z);
|
||||
op.Write(" (");
|
||||
op.Write(m.Map);
|
||||
op.Write(")</td><td>");
|
||||
op.Write(m.Kills);
|
||||
op.Write("</td><td>");
|
||||
op.Write(m.Karma);
|
||||
op.Write(" / ");
|
||||
op.Write(m.Fame);
|
||||
op.WriteLine("</td></tr>");
|
||||
}
|
||||
|
||||
op.WriteLine(" <tr>");
|
||||
op.WriteLine(" </table>");
|
||||
op.WriteLine(" </body>");
|
||||
op.WriteLine("</html>");
|
||||
}
|
||||
op.WriteLine(" <tr>");
|
||||
op.WriteLine(" </table>");
|
||||
op.WriteLine(" </body>");
|
||||
op.WriteLine("</html>");
|
||||
}
|
||||
|
||||
lock (_StatusLock)
|
||||
{
|
||||
_StatusPage = File.ReadAllText("web/status.html");
|
||||
_StatusBuffer = Encoding.UTF8.GetBytes(_StatusPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
lock (_StatusLock)
|
||||
{
|
||||
_StatusPage = File.ReadAllText("web/status.html");
|
||||
_StatusBuffer = Encoding.UTF8.GetBytes(_StatusPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,124 +1,126 @@
|
|||
using System;
|
||||
using Server.Mobiles;
|
||||
using Server.Spells.Ninjitsu;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public enum DFAlgorithm
|
||||
{
|
||||
Standard,
|
||||
PainSpike
|
||||
}
|
||||
public enum DFAlgorithm
|
||||
{
|
||||
Standard,
|
||||
PainSpike
|
||||
}
|
||||
|
||||
public class WeightOverloading
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Movement += EventSink_Movement;
|
||||
}
|
||||
public class WeightOverloading
|
||||
{
|
||||
public const int OverloadAllowance = 4; // We can be four stones overweight without getting fatigued
|
||||
|
||||
public static DFAlgorithm DFA { get; set; }
|
||||
public static DFAlgorithm DFA{ get; set; }
|
||||
|
||||
public static void FatigueOnDamage( Mobile m, int damage )
|
||||
{
|
||||
double fatigue = 0.0;
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.Movement += EventSink_Movement;
|
||||
}
|
||||
|
||||
switch ( DFA )
|
||||
{
|
||||
case DFAlgorithm.Standard:
|
||||
{
|
||||
fatigue = (damage * (100.0 / m.Hits) * ((double)m.Stam / 100)) - 5.0;
|
||||
break;
|
||||
}
|
||||
case DFAlgorithm.PainSpike:
|
||||
{
|
||||
fatigue = (damage * ((100.0 / m.Hits) + ((50.0 + m.Stam) / 100) - 1.0)) - 5.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static void FatigueOnDamage(Mobile m, int damage)
|
||||
{
|
||||
double fatigue = 0.0;
|
||||
|
||||
if ( fatigue > 0 )
|
||||
m.Stam -= (int)fatigue;
|
||||
}
|
||||
switch (DFA)
|
||||
{
|
||||
case DFAlgorithm.Standard:
|
||||
{
|
||||
fatigue = damage * (100.0 / m.Hits) * ((double)m.Stam / 100) - 5.0;
|
||||
break;
|
||||
}
|
||||
case DFAlgorithm.PainSpike:
|
||||
{
|
||||
fatigue = damage * (100.0 / m.Hits + (50.0 + m.Stam) / 100 - 1.0) - 5.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public const int OverloadAllowance = 4; // We can be four stones overweight without getting fatigued
|
||||
if (fatigue > 0)
|
||||
m.Stam -= (int)fatigue;
|
||||
}
|
||||
|
||||
public static int GetMaxWeight( Mobile m )
|
||||
{
|
||||
//return ((( Core.ML && m.Race == Race.Human) ? 100 : 40 ) + (int)(3.5 * m.Str));
|
||||
//Moved to core virtual method for use there
|
||||
public static int GetMaxWeight(Mobile m)
|
||||
{
|
||||
//return ((( Core.ML && m.Race == Race.Human) ? 100 : 40 ) + (int)(3.5 * m.Str));
|
||||
//Moved to core virtual method for use there
|
||||
|
||||
return m.MaxWeight;
|
||||
}
|
||||
return m.MaxWeight;
|
||||
}
|
||||
|
||||
public static void EventSink_Movement( MovementEventArgs e )
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
public static void EventSink_Movement(MovementEventArgs e)
|
||||
{
|
||||
Mobile from = e.Mobile;
|
||||
|
||||
if ( !from.Alive || from.AccessLevel > AccessLevel.Player )
|
||||
return;
|
||||
if (!from.Alive || from.AccessLevel > AccessLevel.Player)
|
||||
return;
|
||||
|
||||
if ( !from.Player )
|
||||
{
|
||||
// Else it won't work on monsters.
|
||||
Spells.Ninjitsu.DeathStrike.AddStep( from );
|
||||
return;
|
||||
}
|
||||
if (!from.Player)
|
||||
{
|
||||
// Else it won't work on monsters.
|
||||
DeathStrike.AddStep(from);
|
||||
return;
|
||||
}
|
||||
|
||||
int maxWeight = GetMaxWeight( from ) + OverloadAllowance;
|
||||
int overWeight = (Mobile.BodyWeight + from.TotalWeight) - maxWeight;
|
||||
int maxWeight = GetMaxWeight(from) + OverloadAllowance;
|
||||
int overWeight = Mobile.BodyWeight + from.TotalWeight - maxWeight;
|
||||
|
||||
if ( overWeight > 0 )
|
||||
{
|
||||
from.Stam -= GetStamLoss( from, overWeight, (e.Direction & Direction.Running) != 0 );
|
||||
if (overWeight > 0)
|
||||
{
|
||||
from.Stam -= GetStamLoss(from, overWeight, (e.Direction & Direction.Running) != 0);
|
||||
|
||||
if ( from.Stam == 0 )
|
||||
{
|
||||
from.SendLocalizedMessage( 500109 ); // You are too fatigued to move, because you are carrying too much weight!
|
||||
e.Blocked = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (from.Stam == 0)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
500109); // You are too fatigued to move, because you are carrying too much weight!
|
||||
e.Blocked = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ((from.Stam * 100) / Math.Max( from.StamMax, 1 )) < 10 )
|
||||
--from.Stam;
|
||||
if (from.Stam * 100 / Math.Max(from.StamMax, 1) < 10)
|
||||
--from.Stam;
|
||||
|
||||
if ( from.Stam == 0 )
|
||||
{
|
||||
from.SendLocalizedMessage( 500110 ); // You are too fatigued to move.
|
||||
e.Blocked = true;
|
||||
return;
|
||||
}
|
||||
if (from.Stam == 0)
|
||||
{
|
||||
from.SendLocalizedMessage(500110); // You are too fatigued to move.
|
||||
e.Blocked = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( from is PlayerMobile pm )
|
||||
{
|
||||
int amt = ( pm.Mounted ? 48 : 16 );
|
||||
if (from is PlayerMobile pm)
|
||||
{
|
||||
int amt = pm.Mounted ? 48 : 16;
|
||||
|
||||
if ( (++pm.StepsTaken % amt) == 0 )
|
||||
--pm.Stam;
|
||||
}
|
||||
if (++pm.StepsTaken % amt == 0)
|
||||
--pm.Stam;
|
||||
}
|
||||
|
||||
Spells.Ninjitsu.DeathStrike.AddStep( from );
|
||||
}
|
||||
DeathStrike.AddStep(from);
|
||||
}
|
||||
|
||||
public static int GetStamLoss( Mobile from, int overWeight, bool running )
|
||||
{
|
||||
int loss = 5 + (overWeight / 25);
|
||||
public static int GetStamLoss(Mobile from, int overWeight, bool running)
|
||||
{
|
||||
int loss = 5 + overWeight / 25;
|
||||
|
||||
if ( from.Mounted )
|
||||
loss /= 3;
|
||||
if (from.Mounted)
|
||||
loss /= 3;
|
||||
|
||||
if ( running )
|
||||
loss *= 2;
|
||||
if (running)
|
||||
loss *= 2;
|
||||
|
||||
return loss;
|
||||
}
|
||||
return loss;
|
||||
}
|
||||
|
||||
public static bool IsOverloaded( Mobile m )
|
||||
{
|
||||
if ( !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player )
|
||||
return false;
|
||||
public static bool IsOverloaded(Mobile m)
|
||||
{
|
||||
if (!m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player)
|
||||
return false;
|
||||
|
||||
return ( (Mobile.BodyWeight + m.TotalWeight) > (GetMaxWeight( m ) + OverloadAllowance) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return Mobile.BodyWeight + m.TotalWeight > GetMaxWeight(m) + OverloadAllowance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,51 +2,52 @@ using System;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
/// <summary>
|
||||
/// This timer spouts some welcome messages to a user at a set interval. It is used on character creation and login.
|
||||
/// </summary>
|
||||
public class WelcomeTimer : Timer
|
||||
{
|
||||
private Mobile m_Mobile;
|
||||
private int m_State, m_Count;
|
||||
/// <summary>
|
||||
/// This timer spouts some welcome messages to a user at a set interval. It is used on character creation and login.
|
||||
/// </summary>
|
||||
public class WelcomeTimer : Timer
|
||||
{
|
||||
private static string[] m_Messages = TestCenter.Enabled
|
||||
? new[]
|
||||
{
|
||||
"Welcome to this test shard. You are able to customize your character's stats and skills at anytime to anything you wish. To see the commands to do this just say 'help'.",
|
||||
"You will find a bank check worth 1,000,000 gold in your bank!",
|
||||
"A spellbook and a bag of reagents has been placed into your bank box.",
|
||||
"Various tools have been placed into your bank.",
|
||||
"Various raw materials like ingots, logs, feathers, hides, bottles, etc, have been placed into your bank.",
|
||||
"5 unmarked recall runes, 5 Felucca moonstones and 5 Trammel moonstones have been placed into your bank box.",
|
||||
"One of each level of treasure map has been placed in your bank box.",
|
||||
"You will find 9000 silver pieces deposited into your bank box. Spend it as you see fit and enjoy yourself!",
|
||||
"You will find 9000 gold pieces deposited into your bank box. Spend it as you see fit and enjoy yourself!",
|
||||
"A bag of PowerScrolls has been placed in your bank box."
|
||||
}
|
||||
: new[]
|
||||
{
|
||||
//Yes, this message is a pathetic message, It's suggested that you change it.
|
||||
"Welcome to this shard.",
|
||||
"Please enjoy your stay."
|
||||
};
|
||||
|
||||
private static string[] m_Messages = ( TestCenter.Enabled ?
|
||||
new[]
|
||||
{
|
||||
"Welcome to this test shard. You are able to customize your character's stats and skills at anytime to anything you wish. To see the commands to do this just say 'help'.",
|
||||
"You will find a bank check worth 1,000,000 gold in your bank!",
|
||||
"A spellbook and a bag of reagents has been placed into your bank box.",
|
||||
"Various tools have been placed into your bank.",
|
||||
"Various raw materials like ingots, logs, feathers, hides, bottles, etc, have been placed into your bank.",
|
||||
"5 unmarked recall runes, 5 Felucca moonstones and 5 Trammel moonstones have been placed into your bank box.",
|
||||
"One of each level of treasure map has been placed in your bank box.",
|
||||
"You will find 9000 silver pieces deposited into your bank box. Spend it as you see fit and enjoy yourself!",
|
||||
"You will find 9000 gold pieces deposited into your bank box. Spend it as you see fit and enjoy yourself!",
|
||||
"A bag of PowerScrolls has been placed in your bank box."
|
||||
} :
|
||||
new[]
|
||||
{ //Yes, this message is a pathetic message, It's suggested that you change it.
|
||||
"Welcome to this shard.",
|
||||
"Please enjoy your stay."
|
||||
} );
|
||||
private Mobile m_Mobile;
|
||||
private int m_State, m_Count;
|
||||
|
||||
public WelcomeTimer( Mobile m ) : this( m, m_Messages.Length )
|
||||
{
|
||||
}
|
||||
public WelcomeTimer(Mobile m) : this(m, m_Messages.Length)
|
||||
{
|
||||
}
|
||||
|
||||
public WelcomeTimer( Mobile m, int count ) : base( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromSeconds( 10.0 ) )
|
||||
{
|
||||
m_Mobile = m;
|
||||
m_Count = count;
|
||||
}
|
||||
public WelcomeTimer(Mobile m, int count) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(10.0))
|
||||
{
|
||||
m_Mobile = m;
|
||||
m_Count = count;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if ( m_State < m_Count )
|
||||
m_Mobile.SendMessage( 0x35, m_Messages[m_State++] );
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (m_State < m_Count)
|
||||
m_Mobile.SendMessage(0x35, m_Messages[m_State++]);
|
||||
|
||||
if ( m_State == m_Count )
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
if (m_State == m_Count)
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,350 +1,350 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Mobiles;
|
||||
using Server.Commands;
|
||||
using Server.Mobiles;
|
||||
|
||||
// Version 0.8
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public class UOAMVendorGenerator
|
||||
{
|
||||
private static int m_Count;
|
||||
public class UOAMVendorGenerator
|
||||
{
|
||||
//configuration
|
||||
private const int
|
||||
NPCCount = 2; //2 npcs per type (so a mage spawner will spawn 2 npcs, a alchemist and herbalist spawner will spawn 4 npcs total)
|
||||
|
||||
//configuration
|
||||
private const int NPCCount = 2;//2 npcs per type (so a mage spawner will spawn 2 npcs, a alchemist and herbalist spawner will spawn 4 npcs total)
|
||||
private const int HomeRange = 5;//How far should they wander?
|
||||
private const bool TotalRespawn = true;//Should we spawn them up right away?
|
||||
private static TimeSpan MinTime = TimeSpan.FromMinutes( 2.5 );//min spawn time
|
||||
private static TimeSpan MaxTime = TimeSpan.FromMinutes( 10.0 );//max spawn time
|
||||
private const int Team = 0;//"team" the npcs are on
|
||||
private const int HomeRange = 5; //How far should they wander?
|
||||
private const bool TotalRespawn = true; //Should we spawn them up right away?
|
||||
private const int Team = 0; //"team" the npcs are on
|
||||
private static int m_Count;
|
||||
private static TimeSpan MinTime = TimeSpan.FromMinutes(2.5); //min spawn time
|
||||
private static TimeSpan MaxTime = TimeSpan.FromMinutes(10.0); //max spawn time
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "UOAMVendors", AccessLevel.Administrator, Generate_OnCommand );
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("UOAMVendors", AccessLevel.Administrator, Generate_OnCommand);
|
||||
}
|
||||
|
||||
[Usage( "UOAMVendors" )]
|
||||
[Description( "Generates vendor spawners from Data/Common.MAP (taken from UOAutoMap)" )]
|
||||
private static void Generate_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
Parse( e.Mobile );
|
||||
}
|
||||
[Usage("UOAMVendors")]
|
||||
[Description("Generates vendor spawners from Data/Common.MAP (taken from UOAutoMap)")]
|
||||
private static void Generate_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
Parse(e.Mobile);
|
||||
}
|
||||
|
||||
public static void Parse( Mobile from )
|
||||
{
|
||||
string vendor_path = Path.Combine( Core.BaseDirectory, "Data/Common.map" );
|
||||
m_Count = 0;
|
||||
public static void Parse(Mobile from)
|
||||
{
|
||||
string vendor_path = Path.Combine(Core.BaseDirectory, "Data/Common.map");
|
||||
m_Count = 0;
|
||||
|
||||
if ( File.Exists( vendor_path ) )
|
||||
{
|
||||
from.SendMessage( "Generating Vendors..." );
|
||||
if (File.Exists(vendor_path))
|
||||
{
|
||||
from.SendMessage("Generating Vendors...");
|
||||
|
||||
using ( StreamReader ip = new StreamReader( vendor_path ) )
|
||||
{
|
||||
string line;
|
||||
using (StreamReader ip = new StreamReader(vendor_path))
|
||||
{
|
||||
string line;
|
||||
|
||||
while ( (line = ip.ReadLine()) != null )
|
||||
{
|
||||
int indexOf = line.IndexOf( ':' );
|
||||
while ((line = ip.ReadLine()) != null)
|
||||
{
|
||||
int indexOf = line.IndexOf(':');
|
||||
|
||||
if ( indexOf == -1 )
|
||||
continue;
|
||||
if (indexOf == -1)
|
||||
continue;
|
||||
|
||||
string type = line.Substring( 0, ++indexOf ).Trim();
|
||||
string sub = line.Substring( indexOf ).Trim();
|
||||
string type = line.Substring(0, ++indexOf).Trim();
|
||||
string sub = line.Substring(indexOf).Trim();
|
||||
|
||||
string[] split = sub.Split( ' ' );
|
||||
string[] split = sub.Split(' ');
|
||||
|
||||
if ( split.Length < 3 )
|
||||
continue;
|
||||
if (split.Length < 3)
|
||||
continue;
|
||||
|
||||
split = new[]{ type, split[0], split[1], split[2] };
|
||||
split = new[] { type, split[0], split[1], split[2] };
|
||||
|
||||
switch(split[0].ToLower())
|
||||
{
|
||||
case "-healer:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Healer", "HealerGuildmaster" );
|
||||
break;
|
||||
case "-baker:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Baker" );
|
||||
break;
|
||||
case "-vet:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Veterinarian" );
|
||||
break;
|
||||
case "-gypsymaiden:":
|
||||
PlaceNPC( split[1], split[2], split[3], "GypsyMaiden" );
|
||||
break;
|
||||
case "-gypsybank:":
|
||||
PlaceNPC( split[1], split[2], split[3], "GypsyBanker" );
|
||||
break;
|
||||
case "-bank:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Banker", "Minter" );
|
||||
break;
|
||||
case "-inn:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Innkeeper" );
|
||||
break;
|
||||
case "-provisioner:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Provisioner", "Cobbler" );
|
||||
break;
|
||||
case "-tailor:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Tailor", "Weaver", "TailorGuildmaster" );
|
||||
break;
|
||||
case "-tavern:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Tavernkeeper", "Waiter", "Cook", "Barkeeper" );
|
||||
break;
|
||||
case "-reagents:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Herbalist", "Alchemist", "CustomHairstylist" );
|
||||
break;
|
||||
case "-fortuneteller:":
|
||||
PlaceNPC( split[1], split[2], split[3], "FortuneTeller" );
|
||||
break;
|
||||
case "-holymage:":
|
||||
PlaceNPC( split[1], split[2], split[3], "HolyMage" );
|
||||
break;
|
||||
case "-chivalrykeeper:":
|
||||
PlaceNPC( split[1], split[2], split[3], "KeeperOfChivalry" );
|
||||
break;
|
||||
case "-mage:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Mage", "Alchemist", "MageGuildmaster" );
|
||||
break;
|
||||
case "-arms:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Armorer", "Weaponsmith" );
|
||||
break;
|
||||
case "-tinker:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Tinker", "TinkerGuildmaster" );
|
||||
break;
|
||||
case "-gypsystable:":
|
||||
PlaceNPC( split[1], split[2], split[3], "GypsyAnimalTrainer" );
|
||||
break;
|
||||
case "-stable:":
|
||||
PlaceNPC( split[1], split[2], split[3], "AnimalTrainer" );
|
||||
break;
|
||||
case "-blacksmith:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Blacksmith", "BlacksmithGuildmaster" );
|
||||
break;
|
||||
case "-bowyer:":
|
||||
case "-fletcher:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Bowyer" );
|
||||
break;
|
||||
case "-carpenter:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Carpenter", "Architect", "RealEstateBroker" );
|
||||
break;
|
||||
case "-butcher:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Butcher" );
|
||||
break;
|
||||
case "-jeweler:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Jeweler" );
|
||||
break;
|
||||
case "-tanner:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Tanner", "Furtrader" );
|
||||
break;
|
||||
case "-bard:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Bard", "BardGuildmaster" );
|
||||
break;
|
||||
case "-market:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Butcher", "Farmer" );
|
||||
break;
|
||||
case "-library:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Scribe" );
|
||||
break;
|
||||
case "-shipwright:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Shipwright", "Mapmaker" );
|
||||
break;
|
||||
case "-docks:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Fisherman" );
|
||||
break;
|
||||
switch (split[0].ToLower())
|
||||
{
|
||||
case "-healer:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Healer", "HealerGuildmaster");
|
||||
break;
|
||||
case "-baker:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Baker");
|
||||
break;
|
||||
case "-vet:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Veterinarian");
|
||||
break;
|
||||
case "-gypsymaiden:":
|
||||
PlaceNPC(split[1], split[2], split[3], "GypsyMaiden");
|
||||
break;
|
||||
case "-gypsybank:":
|
||||
PlaceNPC(split[1], split[2], split[3], "GypsyBanker");
|
||||
break;
|
||||
case "-bank:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Banker", "Minter");
|
||||
break;
|
||||
case "-inn:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Innkeeper");
|
||||
break;
|
||||
case "-provisioner:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Provisioner", "Cobbler");
|
||||
break;
|
||||
case "-tailor:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Tailor", "Weaver", "TailorGuildmaster");
|
||||
break;
|
||||
case "-tavern:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Tavernkeeper", "Waiter", "Cook", "Barkeeper");
|
||||
break;
|
||||
case "-reagents:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Herbalist", "Alchemist", "CustomHairstylist");
|
||||
break;
|
||||
case "-fortuneteller:":
|
||||
PlaceNPC(split[1], split[2], split[3], "FortuneTeller");
|
||||
break;
|
||||
case "-holymage:":
|
||||
PlaceNPC(split[1], split[2], split[3], "HolyMage");
|
||||
break;
|
||||
case "-chivalrykeeper:":
|
||||
PlaceNPC(split[1], split[2], split[3], "KeeperOfChivalry");
|
||||
break;
|
||||
case "-mage:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Mage", "Alchemist", "MageGuildmaster");
|
||||
break;
|
||||
case "-arms:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Armorer", "Weaponsmith");
|
||||
break;
|
||||
case "-tinker:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Tinker", "TinkerGuildmaster");
|
||||
break;
|
||||
case "-gypsystable:":
|
||||
PlaceNPC(split[1], split[2], split[3], "GypsyAnimalTrainer");
|
||||
break;
|
||||
case "-stable:":
|
||||
PlaceNPC(split[1], split[2], split[3], "AnimalTrainer");
|
||||
break;
|
||||
case "-blacksmith:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Blacksmith", "BlacksmithGuildmaster");
|
||||
break;
|
||||
case "-bowyer:":
|
||||
case "-fletcher:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Bowyer");
|
||||
break;
|
||||
case "-carpenter:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Carpenter", "Architect", "RealEstateBroker");
|
||||
break;
|
||||
case "-butcher:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Butcher");
|
||||
break;
|
||||
case "-jeweler:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Jeweler");
|
||||
break;
|
||||
case "-tanner:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Tanner", "Furtrader");
|
||||
break;
|
||||
case "-bard:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Bard", "BardGuildmaster");
|
||||
break;
|
||||
case "-market:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Butcher", "Farmer");
|
||||
break;
|
||||
case "-library:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Scribe");
|
||||
break;
|
||||
case "-shipwright:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Shipwright", "Mapmaker");
|
||||
break;
|
||||
case "-docks:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Fisherman");
|
||||
break;
|
||||
|
||||
case "-beekeeper:":
|
||||
PlaceNPC( split[1], split[2], split[3], "Beekeeper" );
|
||||
break;
|
||||
|
||||
|
||||
// Guilds & Misc
|
||||
case "-tinkers guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "TinkerGuildmaster" );
|
||||
break;
|
||||
case "-blacksmiths guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "BlacksmithGuildmaster" );
|
||||
break;
|
||||
case "-sorcerors guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "MageGuildmaster" );
|
||||
break;
|
||||
case "-customs:": break;
|
||||
case "-painter:": break;
|
||||
case "-theater:": break;
|
||||
case "-warriors guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "WarriorGuildmaster" );
|
||||
break;
|
||||
case "-archers guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "RangerGuildmaster" );
|
||||
break;
|
||||
case "-thieves guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "ThiefGuildmaster" );
|
||||
break;
|
||||
case "-miners guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "MinerGuildmaster" );
|
||||
break;
|
||||
case "-fishermans guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "FisherGuildmaster" );
|
||||
break;
|
||||
case "-merchants guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "MerchantGuildmaster" );
|
||||
break;
|
||||
case "-illusionists guild:": break;
|
||||
case "-armourers guild:": break;
|
||||
case "-sorcerers guild:": break;
|
||||
case "-mages guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "MageGuildmaster" );
|
||||
break;
|
||||
case "-weapons guild:": break;
|
||||
case "-bardic guild:":
|
||||
PlaceNPC( split[1], split[2], split[3], "BardGuildmaster" );
|
||||
break;
|
||||
case "-rogues guild:":
|
||||
break;
|
||||
case "-beekeeper:":
|
||||
PlaceNPC(split[1], split[2], split[3], "Beekeeper");
|
||||
break;
|
||||
|
||||
// Skip
|
||||
case "+landmark:":
|
||||
case "-point of interest:":
|
||||
case "+shrine:":
|
||||
case "+moongate:":
|
||||
case "+dungeon:":
|
||||
case "+scenic:":
|
||||
case "-gate:":
|
||||
case "+Body of Water:":
|
||||
case "+ruins:":
|
||||
case "+teleporter:":
|
||||
case "+Terrain:":
|
||||
case "-exit:":
|
||||
case "-bridge:":
|
||||
case "-other:":
|
||||
case "+champion:":
|
||||
case "-stairs:":
|
||||
case "-guild:":
|
||||
case "+graveyard:":
|
||||
case "+Island:":
|
||||
case "+town:":
|
||||
break;
|
||||
/*default:
|
||||
Console.WriteLine(split[0]);
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
from.SendMessage( "Done, added {0} spawners",m_Count );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( "{0} not found!", vendor_path );
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlaceNPC( string sx, string sy, string sm, params string[] types )
|
||||
{
|
||||
if ( types.Length == 0 )
|
||||
return;
|
||||
// Guilds & Misc
|
||||
case "-tinkers guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "TinkerGuildmaster");
|
||||
break;
|
||||
case "-blacksmiths guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "BlacksmithGuildmaster");
|
||||
break;
|
||||
case "-sorcerors guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "MageGuildmaster");
|
||||
break;
|
||||
case "-customs:": break;
|
||||
case "-painter:": break;
|
||||
case "-theater:": break;
|
||||
case "-warriors guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "WarriorGuildmaster");
|
||||
break;
|
||||
case "-archers guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "RangerGuildmaster");
|
||||
break;
|
||||
case "-thieves guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "ThiefGuildmaster");
|
||||
break;
|
||||
case "-miners guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "MinerGuildmaster");
|
||||
break;
|
||||
case "-fishermans guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "FisherGuildmaster");
|
||||
break;
|
||||
case "-merchants guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "MerchantGuildmaster");
|
||||
break;
|
||||
case "-illusionists guild:": break;
|
||||
case "-armourers guild:": break;
|
||||
case "-sorcerers guild:": break;
|
||||
case "-mages guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "MageGuildmaster");
|
||||
break;
|
||||
case "-weapons guild:": break;
|
||||
case "-bardic guild:":
|
||||
PlaceNPC(split[1], split[2], split[3], "BardGuildmaster");
|
||||
break;
|
||||
case "-rogues guild:":
|
||||
break;
|
||||
|
||||
int x = Utility.ToInt32( sx );
|
||||
int y = Utility.ToInt32( sy );
|
||||
int map = Utility.ToInt32( sm );
|
||||
// Skip
|
||||
case "+landmark:":
|
||||
case "-point of interest:":
|
||||
case "+shrine:":
|
||||
case "+moongate:":
|
||||
case "+dungeon:":
|
||||
case "+scenic:":
|
||||
case "-gate:":
|
||||
case "+Body of Water:":
|
||||
case "+ruins:":
|
||||
case "+teleporter:":
|
||||
case "+Terrain:":
|
||||
case "-exit:":
|
||||
case "-bridge:":
|
||||
case "-other:":
|
||||
case "+champion:":
|
||||
case "-stairs:":
|
||||
case "-guild:":
|
||||
case "+graveyard:":
|
||||
case "+Island:":
|
||||
case "+town:":
|
||||
break;
|
||||
/*default:
|
||||
Console.WriteLine(split[0]);
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ( map )
|
||||
{
|
||||
case 0://Trammel and Felucca
|
||||
MakeSpawner( types, x, y, Map.Felucca );
|
||||
MakeSpawner( types, x, y, Map.Trammel );
|
||||
break;
|
||||
case 1://Felucca
|
||||
MakeSpawner( types, x, y, Map.Felucca );
|
||||
break;
|
||||
case 2:
|
||||
MakeSpawner( types, x, y, Map.Trammel );
|
||||
break;
|
||||
case 3:
|
||||
MakeSpawner( types, x, y, Map.Ilshenar );
|
||||
break;
|
||||
case 4:
|
||||
MakeSpawner( types, x, y, Map.Malas );
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine( "UOAM Vendor Parser: Warning, unknown map {0}", map );
|
||||
break;
|
||||
}
|
||||
}
|
||||
from.SendMessage("Done, added {0} spawners", m_Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("{0} not found!", vendor_path);
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetSpawnerZ( int x, int y, Map map )
|
||||
{
|
||||
int z = map.GetAverageZ( x, y );
|
||||
public static void PlaceNPC(string sx, string sy, string sm, params string[] types)
|
||||
{
|
||||
if (types.Length == 0)
|
||||
return;
|
||||
|
||||
if ( map.CanFit( x, y, z, 16, false, false, true ) )
|
||||
return z;
|
||||
int x = Utility.ToInt32(sx);
|
||||
int y = Utility.ToInt32(sy);
|
||||
int map = Utility.ToInt32(sm);
|
||||
|
||||
for ( int i = 1; i <= 20; ++i )
|
||||
{
|
||||
if ( map.CanFit( x, y, z + i, 16, false, false, true ) )
|
||||
return z + i;
|
||||
switch (map)
|
||||
{
|
||||
case 0: //Trammel and Felucca
|
||||
MakeSpawner(types, x, y, Map.Felucca);
|
||||
MakeSpawner(types, x, y, Map.Trammel);
|
||||
break;
|
||||
case 1: //Felucca
|
||||
MakeSpawner(types, x, y, Map.Felucca);
|
||||
break;
|
||||
case 2:
|
||||
MakeSpawner(types, x, y, Map.Trammel);
|
||||
break;
|
||||
case 3:
|
||||
MakeSpawner(types, x, y, Map.Ilshenar);
|
||||
break;
|
||||
case 4:
|
||||
MakeSpawner(types, x, y, Map.Malas);
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("UOAM Vendor Parser: Warning, unknown map {0}", map);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( map.CanFit( x, y, z - i, 16, false, false, true ) )
|
||||
return z - i;
|
||||
}
|
||||
public static int GetSpawnerZ(int x, int y, Map map)
|
||||
{
|
||||
int z = map.GetAverageZ(x, y);
|
||||
|
||||
return z;
|
||||
}
|
||||
if (map.CanFit(x, y, z, 16, false, false, true))
|
||||
return z;
|
||||
|
||||
public static void ClearSpawners( int x, int y, int z, Map map )
|
||||
{
|
||||
IPooledEnumerable<Spawner> eable = map.GetItemsInRange<Spawner>( new Point3D( x, y, z ), 0 );
|
||||
Queue<Spawner> m_ToDelete = new Queue<Spawner>();
|
||||
for (int i = 1; i <= 20; ++i)
|
||||
{
|
||||
if (map.CanFit(x, y, z + i, 16, false, false, true))
|
||||
return z + i;
|
||||
|
||||
foreach ( Spawner item in eable )
|
||||
{
|
||||
if ( item.Z == z )
|
||||
m_ToDelete.Enqueue( item );
|
||||
}
|
||||
if (map.CanFit(x, y, z - i, 16, false, false, true))
|
||||
return z - i;
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
return z;
|
||||
}
|
||||
|
||||
while ( m_ToDelete.Count > 0 )
|
||||
((Item)m_ToDelete.Dequeue()).Delete();
|
||||
}
|
||||
public static void ClearSpawners(int x, int y, int z, Map map)
|
||||
{
|
||||
IPooledEnumerable<Spawner> eable = map.GetItemsInRange<Spawner>(new Point3D(x, y, z), 0);
|
||||
Queue<Spawner> m_ToDelete = new Queue<Spawner>();
|
||||
|
||||
private static void MakeSpawner( string[] types, int x, int y, Map map )
|
||||
{
|
||||
if ( types.Length == 0 )
|
||||
return;
|
||||
foreach (Spawner item in eable)
|
||||
if (item.Z == z)
|
||||
m_ToDelete.Enqueue(item);
|
||||
|
||||
int z = GetSpawnerZ( x, y, map );
|
||||
eable.Free();
|
||||
|
||||
ClearSpawners( x, y, z, map );
|
||||
while (m_ToDelete.Count > 0)
|
||||
m_ToDelete.Dequeue().Delete();
|
||||
}
|
||||
|
||||
for ( int i = 0; i < types.Length; ++i )
|
||||
{
|
||||
bool isGuildmaster = ( types[i].EndsWith( "Guildmaster" ) );
|
||||
private static void MakeSpawner(string[] types, int x, int y, Map map)
|
||||
{
|
||||
if (types.Length == 0)
|
||||
return;
|
||||
|
||||
Spawner sp = new Spawner( types[i] );
|
||||
int z = GetSpawnerZ(x, y, map);
|
||||
|
||||
if ( isGuildmaster )
|
||||
sp.Count = 1;
|
||||
else
|
||||
sp.Count = NPCCount;
|
||||
ClearSpawners(x, y, z, map);
|
||||
|
||||
sp.MinDelay = MinTime;
|
||||
sp.MaxDelay = MaxTime;
|
||||
sp.Team = Team;
|
||||
sp.HomeRange = HomeRange;
|
||||
for (int i = 0; i < types.Length; ++i)
|
||||
{
|
||||
bool isGuildmaster = types[i].EndsWith("Guildmaster");
|
||||
|
||||
sp.MoveToWorld( new Point3D( x, y, z ), map );
|
||||
Spawner sp = new Spawner(types[i]);
|
||||
|
||||
if ( TotalRespawn )
|
||||
{
|
||||
sp.Respawn();
|
||||
sp.BringToHome();
|
||||
}
|
||||
if (isGuildmaster)
|
||||
sp.Count = 1;
|
||||
else
|
||||
sp.Count = NPCCount;
|
||||
|
||||
++m_Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sp.MinDelay = MinTime;
|
||||
sp.MaxDelay = MaxTime;
|
||||
sp.Team = Team;
|
||||
sp.HomeRange = HomeRange;
|
||||
|
||||
sp.MoveToWorld(new Point3D(x, y, z), map);
|
||||
|
||||
if (TotalRespawn)
|
||||
{
|
||||
sp.Respawn();
|
||||
sp.BringToHome();
|
||||
}
|
||||
|
||||
++m_Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue