/CoreNew/Server/Mobile.cs
C# | 9790 lines | 8788 code | 821 blank | 181 comment | 1936 complexity | 95deb2282523021adef688f83ac1f495 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- namespace Server
- {
- using Server.Accounting;
- using Server.ContextMenus;
- using Server.Guilds;
- using Server.Gumps;
- using Server.HuePickers;
- using Server.Items;
- using Server.Menus;
- using Server.Mobiles;
- using Server.Movement;
- using Server.Network;
- using Server.Prompts;
- using Server.Targeting;
- using System;
- using System.Collections;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Collections.Generic;
- public delegate bool AllowBeneficialHandler(Mobile from, Mobile target);
- public delegate bool AllowHarmfulHandler(Mobile from, Mobile target);
- public class Mobile : IEntity, IPoint3D, IPoint2D, IHued
- {
- internal int m_TypeRef;
- private Server.AccessLevel m_AccessLevel;
- private static string[] m_AccessLevelNames = new string[] { "a player", "a counselor", "a game master", "a seer", "an administrator" };
- private IAccount m_Account;
- private static TimeSpan m_ActionMessageDelay = TimeSpan.FromSeconds(0.125);
- private ArrayList m_Actions;
- private ArrayList m_Aggressed;
- private ArrayList m_Aggressors;
- private static Server.AllowBeneficialHandler m_AllowBeneficialHandler;
- private int m_AllowedStealthSteps;
- private static Server.AllowHarmfulHandler m_AllowHarmfulHandler;
- private static bool m_AsciiClickMessage = true;
- private static TimeSpan m_AutoManifestTimeout = TimeSpan.FromSeconds(5.0);
- private Timer m_AutoManifestTimer;
- private bool m_AutoPageNotify;
- private int m_BAC;
- private Container m_Backpack;
- private Server.Items.BankBox m_BankBox;
- private int m_BaseSoundID;
- private bool m_Blessed;
- private Server.Body m_Body;
- private Server.Body m_BodyMod;
- private static int m_BodyWeight = 14;
- private bool m_CanHearGhosts;
- private bool m_CanSwim;
- private bool m_CantWalk;
- private int m_ChangingCombatant;
- private Mobile m_Combatant;
- private Timer m_CombatTimer;
- private Server.ContextMenus.ContextMenu m_ContextMenu;
- private Container m_Corpse;
- private static Server.CreateCorpseHandler m_CreateCorpse;
- private DateTime m_CreationTime;
- private bool m_Criminal;
- private ArrayList m_DamageEntries;
- private static TimeSpan m_DefaultHitsRate;
- private static TimeSpan m_DefaultManaRate;
- private static TimeSpan m_DefaultStamRate;
- private static IWeapon m_DefaultWeapon;
- private bool m_Deleted;
- private MobileDelta m_DeltaFlags;
- private static Queue m_DeltaQueue = new Queue();
- private int m_Dex;
- private StatLockType m_DexLock;
- private Server.Direction m_Direction;
- private static bool m_DisableDismountInWarmode;
- private static bool m_DisableHiddenSelfClick = true;
- private bool m_DisarmReady;
- private bool m_DisplayGuildTitle;
- private static bool m_DragEffects = true;
- private int m_EmoteHue;
- private DateTime m_EndQueue;
- private Timer m_ExpireAggrTimer;
- private Timer m_ExpireCombatant;
- private Timer m_ExpireCriminal;
- private static TimeSpan m_ExpireCriminalDelay = TimeSpan.FromMinutes(2.0);
- private int m_Fame;
- private bool m_Female;
- private int m_Followers;
- private int m_FollowersMax;
- private bool m_Frozen;
- private FrozenTimer m_FrozenTimer;
- private static Server.AccessLevel m_FwdAccessOverride = Server.AccessLevel.GameMaster;
- private static bool m_FwdEnabled = true;
- private static int m_FwdMaxSteps = 4;
- private static bool m_FwdUOTDOverride = false;
- private static char[] m_GhostChars = new char[] { 'o', 'O' };
- private static object m_GhostMutateContext = new object();
- private BaseGuild m_Guild;
- private static bool m_GuildClickMessage = true;
- private Mobile m_GuildFealty;
- private string m_GuildTitle;
- private static string[] m_GuildTypes = new string[] { "", " (Chaos)", " (Order)" };
- private static ArrayList m_Hears;
- private bool m_Hidden;
- private int m_Hits;
- private static RegenRateHandler m_HitsRegenRate;
- private Timer m_HitsTimer;
- private Item m_Holding;
- private int m_Hue;
- private int m_HueMod;
- private int m_Hunger;
- private bool m_InDeltaQueue;
- private static bool m_InsuranceEnabled;
- private int m_Int;
- private StatLockType m_IntLock;
- private static int[] m_InvalidBodies = new int[] { 0x20, 0x5f, 0x9c, 0xa9, 0xc4, 0xc5, 0xc6, 0xc7 };
- private ArrayList m_Items;
- private int m_Karma;
- private int m_Kills;
- private string m_Language;
- private Mobile m_LastKiller;
- private DateTime m_LastMoveTime;
- private DateTime m_LastStatGain;
- private int m_LightLevel;
- private Point3D m_Location;
- private Point3D m_LogoutLocation;
- private Server.Map m_LogoutMap;
- private Timer m_LogoutTimer;
- private int m_MagicDamageAbsorb;
- private int m_Mana;
- private static RegenRateHandler m_ManaRegenRate;
- private Timer m_ManaTimer;
- private Server.Map m_Map;
- private static int m_MaxPlayerResistance = 70;
- private bool m_Meditating;
- private int m_MeleeDamageAbsorb;
- private Item m_MountItem;
- private static ArrayList m_MoveList = new ArrayList();
- private Queue m_MoveRecords;
- private static MobileMoving[] m_MovingPacketCache = new MobileMoving[8];
- private string m_Name;
- protected string m_RealName;
- private int m_NameHue;
- private string m_NameMod;
- private Server.Network.NetState m_NetState;
- private DateTime m_NextActionMessage;
- private DateTime m_NextActionTime;
- private DateTime m_NextCombatTime;
- private DateTime m_NextSkillTime;
- private DateTime m_NextSpellTime;
- private DateTime m_NextWarmodeChange;
- private static bool m_NoSpeechLOS;
- private static ArrayList m_OnSpeech;
- private Packet m_OPLPacket;
- private bool m_Paralyzed;
- private ParalyzedTimer m_ParaTimer;
- private object m_Party;
- private bool m_Player;
- private Server.Poison m_Poison;
- private Timer m_PoisonTimer;
- private string m_Profile;
- private bool m_ProfileLocked;
- private Server.Prompts.Prompt m_Prompt;
- private ObjectPropertyList m_PropertyList;
- private bool m_Pushing;
- private Server.QuestArrow m_QuestArrow;
- private Server.Region m_Region;
- private Packet m_RemovePacket;
- private int[] m_Resistances;
- private ArrayList m_ResistMods;
- private static TimeSpan m_RunFoot = TimeSpan.FromSeconds(0.2);
- private static TimeSpan m_RunMount = TimeSpan.FromSeconds(0.1);
- private Server.Serial m_Serial;
- private int m_ShortTermMurders;
- private static Server.SkillCheckDirectLocationHandler m_SkillCheckDirectLocationHandler;
- private static Server.SkillCheckDirectTargetHandler m_SkillCheckDirectTargetHandler;
- private static Server.SkillCheckLocationHandler m_SkillCheckLocationHandler;
- private static Server.SkillCheckTargetHandler m_SkillCheckTargetHandler;
- private ArrayList m_SkillMods;
- private Server.Skills m_Skills;
- private int m_SolidHueOverride;
- private int m_SpeechHue;
- private ISpell m_Spell;
- private bool m_Squelched;
- private ArrayList m_Stabled;
- private int m_Stam;
- private static RegenRateHandler m_StamRegenRate;
- private Timer m_StamTimer;
- private int m_StatCap;
- private ArrayList m_StatMods;
- private int m_Str;
- private StatLockType m_StrLock;
- private DateTime[] m_StuckMenuUses;
- private bool m_StunReady;
- private Server.Targeting.Target m_Target;
- private bool m_TargetLocked;
- private int m_Thirst;
- private int m_TithingPoints;
- private string m_Title;
- private int m_TotalGold;
- private int m_TotalWeight;
- private int m_VirtualArmor;
- private int m_VirtualArmorMod;
- private VirtueInfo m_Virtues;
- private static Server.VisibleDamageType m_VisibleDamageType;
- private static TimeSpan m_WalkFoot = TimeSpan.FromSeconds(0.4);
- private static TimeSpan m_WalkMount = TimeSpan.FromSeconds(0.2);
- private bool m_Warmode;
- private int m_WarmodeChanges;
- private WarmodeTimer m_WarmodeTimer;
- private IWeapon m_Weapon;
- private int m_WhisperHue;
- private int m_YellHue;
- private bool m_YellowHealthbar;
- private const int WarmodeCatchCount = 4;
- private static TimeSpan WarmodeSpamCatch = TimeSpan.FromSeconds(0.5);
- private static TimeSpan WarmodeSpamDelay = TimeSpan.FromSeconds(2.0);
- #region RunUO 2 Stuff
- // Pre-7.0.0.0 Packet Flags
- public virtual int GetOldPacketFlags()
- {
- int flags = 0x0;
- if (m_Female)
- flags |= 0x02;
- if (m_Poison != null)
- flags |= 0x04;
- if (m_Blessed || m_YellowHealthbar)
- flags |= 0x08;
- if (m_Warmode)
- flags |= 0x40;
- if (m_Hidden)
- flags |= 0x80;
- return flags;
- }
- #region Hair
- private HairInfo m_Hair;
- private FacialHairInfo m_FacialHair;
- public void ConvertHair()
- {
- Item hair;
- if ((hair = FindItemOnLayer(Layer.Hair)) != null)
- {
- HairItemID = hair.ItemID;
- HairHue = hair.Hue;
- hair.Delete();
- }
- if ((hair = FindItemOnLayer(Layer.FacialHair)) != null)
- {
- FacialHairItemID = hair.ItemID;
- FacialHairHue = hair.Hue;
- hair.Delete();
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public int HairItemID
- {
- get
- {
- if (m_Hair == null)
- return 0;
- return m_Hair.ItemID;
- }
- set
- {
- if (m_Hair == null && value > 0)
- m_Hair = new HairInfo(value);
- else if (value <= 0)
- m_Hair = null;
- else
- m_Hair.ItemID = value;
- Delta(MobileDelta.Hair);
- }
- }
- // [CommandProperty( AccessLevel.GameMaster )]
- // public int HairSerial { get { return HairInfo.FakeSerial( this ); } }
- [CommandProperty(AccessLevel.GameMaster)]
- public int FacialHairItemID
- {
- get
- {
- if (m_FacialHair == null)
- return 0;
- return m_FacialHair.ItemID;
- }
- set
- {
- if (m_FacialHair == null && value > 0)
- m_FacialHair = new FacialHairInfo(value);
- else if (value <= 0)
- m_FacialHair = null;
- else
- m_FacialHair.ItemID = value;
- Delta(MobileDelta.FacialHair);
- }
- }
- // [CommandProperty( AccessLevel.GameMaster )]
- // public int FacialHairSerial { get { return FacialHairInfo.FakeSerial( this ); } }
- [CommandProperty(AccessLevel.GameMaster)]
- public int HairHue
- {
- get
- {
- if (m_Hair == null)
- return 0;
- return m_Hair.Hue;
- }
- set
- {
- if (m_Hair != null)
- {
- m_Hair.Hue = value;
- Delta(MobileDelta.Hair);
- }
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public int FacialHairHue
- {
- get
- {
- if (m_FacialHair == null)
- return 0;
- return m_FacialHair.Hue;
- }
- set
- {
- if (m_FacialHair != null)
- {
- m_FacialHair.Hue = value;
- Delta(MobileDelta.FacialHair);
- }
- }
- }
- #endregion
- public void ClearProperties()
- {
- Packet.Release(ref m_PropertyList);
- Packet.Release(ref m_OPLPacket);
- }
- public virtual void GetChildNameProperties(ObjectPropertyList list, Item item)
- {
- }
- public virtual void UpdateTotal(Item sender, TotalType type, int delta)
- {
- if (delta == 0 || sender.IsVirtualItem)
- return;
- switch (type)
- {
- case TotalType.Gold:
- m_TotalGold += delta;
- Delta(MobileDelta.Gold);
- break;
- case TotalType.Items:
- //m_TotalItems += delta;
- break;
- case TotalType.Weight:
- m_TotalWeight += delta;
- Delta(MobileDelta.Weight);
- OnWeightChange(m_TotalWeight - delta);
- break;
- }
- }
- public virtual void OnItemBounceCleared(Item item)
- {
- }
- public virtual void OnSubItemBounceCleared( Item item )
- {
- }
- public static Item LiftItemDupe(Item oldItem, int amount)
- {
- Item item;
- try
- {
- item = (Item)Activator.CreateInstance(oldItem.GetType());
- }
- catch
- {
- Console.WriteLine("Warning: 0x{0:X}: Item must have a zero paramater constructor to be separated from a stack. '{1}'.", oldItem.Serial.Value, oldItem.GetType().Name);
- return null;
- }
- item.Visible = oldItem.Visible;
- item.Movable = oldItem.Movable;
- item.LootType = oldItem.LootType;
- item.Direction = oldItem.Direction;
- item.Hue = oldItem.Hue;
- item.ItemID = oldItem.ItemID;
- item.Location = oldItem.Location;
- item.Layer = oldItem.Layer;
- item.Name = oldItem.Name;
- item.Weight = oldItem.Weight;
- item.Amount = oldItem.Amount - amount;
- item.Map = oldItem.Map;
- oldItem.Amount = amount;
- oldItem.OnAfterDuped(item);
- if (oldItem.Parent is Mobile)
- {
- ((Mobile)oldItem.Parent).AddItem(item);
- }
- else if (oldItem.Parent is Item)
- {
- ((Item)oldItem.Parent).AddItem(item);
- }
- item.Delta(ItemDelta.Update);
- return item;
- }
- #endregion
- public Mobile()
- {
- this.m_NameHue = -1;
- this.m_WarmodeChanges = 0;
- this.m_SkillMods = new ArrayList(1);
- this.m_HueMod = -1;
- this.m_SolidHueOverride = -1;
- this.m_Region = Server.Map.Internal.DefaultRegion;
- this.m_Serial = Server.Serial.NewMobile;
- this.DefaultMobileInit();
- World.AddMobile(this);
- Type ourType = this.GetType();
- m_TypeRef = World.m_MobileTypes.IndexOf(ourType);
- if (m_TypeRef == -1)
- m_TypeRef = World.m_MobileTypes.Add(ourType);
- }
- public Mobile(Server.Serial serial)
- {
- this.m_NameHue = -1;
- this.m_WarmodeChanges = 0;
- this.m_SkillMods = new ArrayList(1);
- this.m_HueMod = -1;
- this.m_SolidHueOverride = -1;
- this.m_Region = Server.Map.Internal.DefaultRegion;
- this.m_Serial = serial;
- this.m_ExpireCombatant = new ExpireCombatantTimer(this);
- this.m_ExpireCriminal = new ExpireCriminalTimer(this);
- this.m_CombatTimer = new CombatTimer(this);
- this.m_Aggressors = new ArrayList(1);
- this.m_Aggressed = new ArrayList(1);
- this.m_NextSkillTime = DateTime.MinValue;
- this.m_DamageEntries = new ArrayList(1);
- this.m_LogoutTimer = new LogoutTimer(this);
- Type ourType = this.GetType();
- m_TypeRef = World.m_MobileTypes.IndexOf(ourType);
- if (m_TypeRef == -1)
- m_TypeRef = World.m_MobileTypes.Add(ourType);
- }
- public void AddItem(Item item)
- {
- if (((item != null) && !item.Deleted) && (item.Parent != this))
- {
- if (item.Parent is Mobile)
- {
- ((Mobile) item.Parent).RemoveItem(item);
- }
- else if (item.Parent is Item)
- {
- ((Item) item.Parent).RemoveItem(item);
- }
- else
- {
- item.SendRemovePacket();
- }
- item.Parent = this;
- item.Map = this.m_Map;
- this.m_Items.Add(item);
- if (!(item is Server.Items.BankBox))
- {
- this.TotalWeight += item.TotalWeight + item.PileWeight;
- this.TotalGold += item.TotalGold;
- }
- item.Delta(ItemDelta.Update);
- item.OnAdded(this);
- this.OnItemAdded(item);
- if (((item.PhysicalResistance != 0) || (item.FireResistance != 0)) || (((item.ColdResistance != 0) || (item.PoisonResistance != 0)) || (item.EnergyResistance != 0)))
- {
- this.UpdateResistances();
- }
- }
- }
- public virtual void AddNameProperties(ObjectPropertyList list)
- {
- string name = this.Name;
- if (name == null)
- {
- name = string.Empty;
- }
- string str2 = "";
- if ((this.ShowFameTitle && (this.m_Player || this.m_Body.IsHuman)) && (this.m_Fame >= 0x2710))
- {
- str2 = this.m_Female ? "Lady" : "Lord";
- }
- string title = "";
- if ((this.ClickTitle && (this.Title != null)) && (this.Title.Length > 0))
- {
- title = this.Title;
- }
- BaseGuild guild = this.m_Guild;
- if ((guild != null) && (this.m_Player || this.m_DisplayGuildTitle))
- {
- if (title.Length > 0)
- {
- title = string.Format("{0} [{1}]", title, Utility.FixHtml(guild.Abbreviation));
- }
- else
- {
- title = string.Format("[{0}]", Utility.FixHtml(guild.Abbreviation));
- }
- }
- list.Add(0x1005bd, "{0} \t{1}\t {2}", str2, name, title);
- if ((guild != null) && (this.m_DisplayGuildTitle || (this.m_Player && (guild.Type != GuildType.None))))
- {
- string str4;
- if ((guild.Type >= GuildType.None) && ((int)guild.Type < m_GuildTypes.Length))
- {
- str4 = m_GuildTypes[(int) guild.Type];
- }
- else
- {
- str4 = "";
- }
- string guildTitle = this.GuildTitle;
- if (guildTitle == null)
- {
- guildTitle = "";
- }
- else
- {
- guildTitle = guildTitle.Trim();
- }
- if (guildTitle.Length > 0)
- {
- list.Add("{0}, {1} Guild{2}", Utility.FixHtml(guildTitle), Utility.FixHtml(guild.Name), str4);
- }
- else
- {
- list.Add(Utility.FixHtml(guild.Name));
- }
- }
- }
- public virtual void AddResistanceMod(ResistanceMod toAdd)
- {
- if (this.m_ResistMods == null)
- {
- this.m_ResistMods = new ArrayList(2);
- }
- this.m_ResistMods.Add(toAdd);
- this.UpdateResistances();
- }
- public virtual void AddSkillMod(SkillMod mod)
- {
- if (mod != null)
- {
- this.ValidateSkillMods();
- if (!this.m_SkillMods.Contains(mod))
- {
- this.m_SkillMods.Add(mod);
- mod.Owner = this;
- Skill skill = this.m_Skills[mod.Skill];
- if (skill != null)
- {
- skill.Update();
- }
- }
- }
- }
- private void AddSpeechItemsFrom(ArrayList list, Container cont)
- {
- for (int i = 0; i < cont.Items.Count; i++)
- {
- Item item = (Item) cont.Items[i];
- if (item.HandlesOnSpeech)
- {
- list.Add(item);
- }
- if (item is Container)
- {
- this.AddSpeechItemsFrom(list, (Container) item);
- }
- }
- }
- public void AddStatMod(StatMod mod)
- {
- for (int i = 0; i < this.m_StatMods.Count; i++)
- {
- StatMod mod2 = (StatMod) this.m_StatMods[i];
- if (mod2.Name == mod.Name)
- {
- this.Delta(MobileDelta.Stat);
- this.m_StatMods.RemoveAt(i);
- break;
- }
- }
- this.m_StatMods.Add(mod);
- this.Delta(MobileDelta.Stat);
- this.CheckStatTimers();
- }
- public bool AddToBackpack(Item item)
- {
- if (item.Deleted)
- {
- return false;
- }
- if (!this.PlaceInBackpack(item))
- {
- item.MoveToWorld(this.Location, this.Map);
- return false;
- }
- return true;
- }
- public virtual void AggressiveAction(Mobile aggressor)
- {
- this.AggressiveAction(aggressor, false);
- }
- public virtual void AggressiveAction(Mobile aggressor, bool criminal)
- {
- if (aggressor != this)
- {
- AggressiveActionEventArgs e = AggressiveActionEventArgs.Create(this, aggressor, criminal);
- EventSink.InvokeAggressiveAction(e);
- e.Free();
- if (this.Combatant == aggressor)
- {
- this.m_ExpireCombatant.Stop();
- this.m_ExpireCombatant.Start();
- }
- bool flag = true;
- ArrayList aggressors = this.m_Aggressors;
- for (int i = 0; i < aggressors.Count; i++)
- {
- AggressorInfo info = (AggressorInfo) aggressors[i];
- if (info.Attacker == aggressor)
- {
- info.Refresh();
- info.CriminalAggression = criminal;
- info.CanReportMurder = criminal;
- flag = false;
- }
- }
- aggressors = aggressor.m_Aggressors;
- for (int j = 0; j < aggressors.Count; j++)
- {
- AggressorInfo info2 = (AggressorInfo) aggressors[j];
- if (info2.Attacker == this)
- {
- info2.Refresh();
- flag = false;
- }
- }
- bool flag2 = true;
- aggressors = this.m_Aggressed;
- for (int k = 0; k < aggressors.Count; k++)
- {
- AggressorInfo info3 = (AggressorInfo) aggressors[k];
- if (info3.Defender == aggressor)
- {
- info3.Refresh();
- flag2 = false;
- }
- }
- aggressors = aggressor.m_Aggressed;
- for (int m = 0; m < aggressors.Count; m++)
- {
- AggressorInfo info4 = (AggressorInfo) aggressors[m];
- if (info4.Defender == this)
- {
- info4.Refresh();
- info4.CriminalAggression = criminal;
- info4.CanReportMurder = criminal;
- flag2 = false;
- }
- }
- bool flag3 = false;
- if (flag)
- {
- this.m_Aggressors.Add(AggressorInfo.Create(aggressor, this, criminal));
- if (this.CanSee(aggressor) && (this.m_NetState != null))
- {
- this.m_NetState.Send(new MobileIncoming(this, aggressor));
- }
- if (this.Combatant == null)
- {
- flag3 = true;
- }
- this.UpdateAggrExpire();
- }
- if (flag2)
- {
- aggressor.m_Aggressed.Add(AggressorInfo.Create(aggressor, this, criminal));
- if (this.CanSee(aggressor) && (this.m_NetState != null))
- {
- this.m_NetState.Send(new MobileIncoming(this, aggressor));
- }
- if (this.Combatant == null)
- {
- flag3 = true;
- }
- this.UpdateAggrExpire();
- }
- if (flag3)
- {
- this.Combatant = aggressor;
- }
- this.Region.OnAggressed(aggressor, this, criminal);
- }
- }
- public virtual bool AllowItemUse(Item item)
- {
- return true;
- }
- public virtual bool AllowSkillUse(SkillName name)
- {
- return true;
- }
- public virtual void Animate(int action, int frameCount, int repeatCount, bool forward, bool repeat, int delay)
- {
- Server.Map map = this.m_Map;
- if (map != null)
- {
- this.ProcessDelta();
- Packet p = null;
- IPooledEnumerable clientsInRange = map.GetClientsInRange(this.m_Location);
- foreach (Server.Network.NetState state in clientsInRange)
- {
- if (state.Mobile.CanSee(this))
- {
- state.Mobile.ProcessDelta();
- if (p == null)
- {
- p = new MobileAnimation(this, action, frameCount, repeatCount, forward, repeat, delay);
- }
- state.Send(p);
- }
- }
- clientsInRange.Free();
- }
- }
- public virtual ApplyPoisonResult ApplyPoison(Mobile from, Server.Poison poison)
- {
- if (poison == null)
- {
- this.CurePoison(from);
- return ApplyPoisonResult.Cured;
- }
- if (this.CheckHigherPoison(from, poison))
- {
- this.OnHigherPoison(from, poison);
- return ApplyPoisonResult.HigherPoisonActive;
- }
- if (this.CheckPoisonImmunity(from, poison))
- {
- this.OnPoisonImmunity(from, poison);
- return ApplyPoisonResult.Immune;
- }
- Server.Poison oldPoison = this.m_Poison;
- this.Poison = poison;
- this.OnPoisoned(from, poison, oldPoison);
- return ApplyPoisonResult.Poisoned;
- }
- public virtual void Attack(Mobile m)
- {
- if (this.CheckAttack(m))
- {
- this.Combatant = m;
- }
- }
- public bool BeginAction(object toLock)
- {
- if (this.m_Actions == null)
- {
- this.m_Actions = new ArrayList(2);
- this.m_Actions.Add(toLock);
- return true;
- }
- if (!this.m_Actions.Contains(toLock))
- {
- this.m_Actions.Add(toLock);
- return true;
- }
- return false;
- }
- public Server.Targeting.Target BeginTarget(int range, bool allowGround, TargetFlags flags, TargetCallback callback)
- {
- Server.Targeting.Target target = new SimpleTarget(range, flags, allowGround, callback);
- this.Target = target;
- return target;
- }
- public Server.Targeting.Target BeginTarget(int range, bool allowGround, TargetFlags flags, TargetStateCallback callback, object state)
- {
- Server.Targeting.Target target = new SimpleStateTarget(range, flags, allowGround, callback, state);
- this.Target = target;
- return target;
- }
- public virtual bool BeneficialCheck(Mobile target)
- {
- if (this.CanBeBeneficial(target, true))
- {
- this.DoBeneficial(target);
- return true;
- }
- return false;
- }
- public void BoltEffect(int hue)
- {
- Effects.SendBoltEffect(this, true, hue);
- }
- public virtual bool CanBeBeneficial(Mobile target)
- {
- return this.CanBeBeneficial(target, true, false);
- }
- public virtual bool CanBeBeneficial(Mobile target, bool message)
- {
- return this.CanBeBeneficial(target, message, false);
- }
- public virtual bool CanBeBeneficial(Mobile target, bool message, bool allowDead)
- {
- if (target != null)
- {
- if (((this.m_Deleted || target.m_Deleted) || (!this.Alive || this.IsDeadBondedPet)) || (!allowDead && (!target.Alive || this.IsDeadBondedPet)))
- {
- if (message)
- {
- this.SendLocalizedMessage(0xf4639);
- }
- return false;
- }
- if (target == this)
- {
- return true;
- }
- if (this.Region.AllowBenificial(this, target))
- {
- return true;
- }
- if (message)
- {
- this.SendLocalizedMessage(0xf4639);
- }
- }
- return false;
- }
- public virtual bool CanBeDamaged()
- {
- return !this.m_Blessed;
- }
- public bool CanBeginAction(object toLock)
- {
- if (this.m_Actions != null)
- {
- return !this.m_Actions.Contains(toLock);
- }
- return true;
- }
- public virtual bool CanBeHarmful(Mobile target)
- {
- return this.CanBeHarmful(target, true);
- }
- public virtual bool CanBeHarmful(Mobile target, bool message)
- {
- return this.CanBeHarmful(target, message, false);
- }
- public virtual bool CanBeHarmful(Mobile target, bool message, bool ignoreOurBlessedness)
- {
- if (target != null)
- {
- if ((this.m_Deleted || (!ignoreOurBlessedness && this.m_Blessed)) || (((target.m_Deleted || target.m_Blessed) || (!this.Alive || this.IsDeadBondedPet)) || (!target.Alive || target.IsDeadBondedPet)))
- {
- if (message)
- {
- this.SendLocalizedMessage(0xf463a);
- }
- return false;
- }
- if (target == this)
- {
- return true;
- }
- if (this.Region.AllowHarmful(this, target))
- {
- return true;
- }
- if (message)
- {
- this.SendLocalizedMessage(0xf463a);
- }
- }
- return false;
- }
- public virtual bool CanBeRenamedBy(Mobile from)
- {
- return (from.m_AccessLevel > this.m_AccessLevel);
- }
- public virtual bool CanPaperdollBeOpenedBy(Mobile from)
- {
- if (!this.Body.IsHuman && !this.Body.IsGhost)
- {
- return this.IsBodyMod;
- }
- return true;
- }
- public virtual bool CanSee(Item item)
- {
- if (this.m_Map == Server.Map.Internal)
- {
- return false;
- }
- if (item.Map == Server.Map.Internal)
- {
- return false;
- }
- if (item.Parent != null)
- {
- if (item.Parent is Item)
- {
- if (!this.CanSee((Item) item.Parent))
- {
- return false;
- }
- }
- else if ((item.Parent is Mobile) && !this.CanSee((Mobile) item.Parent))
- {
- return false;
- }
- }
- if (item is Server.Items.BankBox)
- {
- Server.Items.BankBox box = item as Server.Items.BankBox;
- if (((box != null) && (this.m_AccessLevel <= Server.AccessLevel.Counselor)) && ((box.Owner != this) || !box.Opened))
- {
- return false;
- }
- }
- else if (item is SecureTradeContainer)
- {
- SecureTrade trade = ((SecureTradeContainer) item).Trade;
- if (((trade != null) && (trade.From.Mobile != this)) && (trade.To.Mobile != this))
- {
- return false;
- }
- }
- if (item.Deleted || (item.Map != this.m_Map))
- {
- return false;
- }
- if (!item.Visible)
- {
- return (this.m_AccessLevel > Server.AccessLevel.Counselor);
- }
- return true;
- }
- public virtual bool CanSee(Mobile m)
- {
- if ((this.m_Deleted || m.m_Deleted) || ((this.m_Map == Server.Map.Internal) || (m.m_Map == Server.Map.Internal)))
- {
- return false;
- }
- if (this != m)
- {
- if ((m.m_Map != this.m_Map) || (m.Hidden && (this.m_AccessLevel <= m.AccessLevel)))
- {
- return false;
- }
- if ((!m.Alive && this.Alive) && (this.m_AccessLevel <= Server.AccessLevel.Player))
- {
- return m.Warmode;
- }
- }
- return true;
- }
- public virtual bool CanSee(object o)
- {
- if (o is Item)
- {
- return this.CanSee((Item) o);
- }
- if (o is Mobile)
- {
- return this.CanSee((Mobile) o);
- }
- return true;
- }
- public bool CanUseStuckMenu()
- {
- if (this.m_StuckMenuUses == null)
- {
- return true;
- }
- for (int i = 0; i < this.m_StuckMenuUses.Length; i++)
- {
- if ((DateTime.Now - this.m_StuckMenuUses[i]) > TimeSpan.FromDays(1.0))
- {
- return true;
- }
- }
- return false;
- }
- private void CheckAggrExpire()
- {
- for (int i = this.m_Aggressors.Count - 1; i >= 0; i--)
- {
- if (i < this.m_Aggressors.Count)
- {
- AggressorInfo info = (AggressorInfo) this.m_Aggressors[i];
- if (info.Expired)
- {
- Mobile attacker = info.Attacker;
- attacker.RemoveAggressed(this);
- this.m_Aggressors.RemoveAt(i);
- info.Free();
- if (((this.m_NetState != null) && this.CanSee(attacker)) && Utility.InUpdateRange(this.m_Location, attacker.m_Location))
- {
- this.m_NetState.Send(new MobileIncoming(this, attacker));
- }
- }
- }
- }
- for (int j = this.m_Aggressed.Count - 1; j >= 0; j--)
- {
- if (j < this.m_Aggressed.Count)
- {
- AggressorInfo info2 = (AggressorInfo) this.m_Aggressed[j];
- if (info2.Expired)
- {
- Mobile defender = info2.Defender;
- defender.RemoveAggressor(this);
- this.m_Aggressed.RemoveAt(j);
- info2.Free();
- if (((this.m_NetState != null) && this.CanSee(defender)) && Utility.InUpdateRange(this.m_Location, defender.m_Location))
- {
- this.m_NetState.Send(new MobileIncoming(this, defender));
- }
- }
- }
- }
- this.UpdateAggrExpire();
- }
- public bool CheckAlive()
- {
- return this.CheckAlive(true);
- }
- public bool CheckAlive(bool message)
- {
- if (this.Alive)
- {
- return true;
- }
- if (message)
- {
- this.LocalOverheadMessage(MessageType.Regular, 0x3b2, 0xf8ca8);
- }
- return false;
- }
- public virtual bool CheckAttack(Mobile m)
- {
- return ((Utility.InUpdateRange(this, m) && this.CanSee(m)) && this.InLOS(m));
- }
- public virtual bool CheckContextMenuDisplay(IEntity target)
- {
- return true;
- }
- public virtual bool CheckCure(Mobile from)
- {
- return true;
- }
- public virtual bool CheckEquip(Item item)
- {
- for (int i = 0; i < this.m_Items.Count; i++)
- {
- if (((Item) this.m_Items[i]).CheckConflictingLayer(this, item, item.Layer) || item.CheckConflictingLayer(this, (Item) this.m_Items[i], ((Item) this.m_Items[i]).Layer))
- {
- return false;
- }
- }
- return true;
- }
- public virtual bool CheckHearsMutatedSpeech(Mobile m, object context)
- {
- return ((context != m_GhostMutateContext) || (m.Alive && !m.CanHearGhosts));
- }
- public virtual bool CheckHigherPoison(Mobile from, Server.Poison poison)
- {
- return ((this.m_Poison != null) && (this.m_Poison.Level >= poison.Level));
- }
- public virtual bool CheckItemUse(Mobile from, Item item)
- {
- return true;
- }
- public virtual bool CheckLift(Mobile from, Item item, ref LRReason reject)
- {
- return true;
- }
- public virtual void CheckLightLevels(bool forceResend)
- {
- }
- public virtual bool CheckMovement(Server.Direction d, out int newZ)
- {
- return Server.Movement.Movement.CheckMovement(this, d, out newZ);
- }
- public virtual bool CheckNonlocalDrop(Mobile from, Item item, Item target)
- {
- if ((from != this) && ((from.AccessLevel <= this.AccessLevel) || (from.AccessLevel < Server.AccessLevel.GameMaster)))
- {
- return false;
- }
- return true;
- }
- public virtual bool CheckNonlocalLift(Mobile from, Item item)
- {
- if ((from != this) && ((from.AccessLevel <= this.AccessLevel) || (from.AccessLevel < Server.AccessLevel.GameMaster)))
- {
- return false;
- }
- return true;
- }
- public virtual bool CheckPoisonImmunity(Mobile from, Server.Poison poison)
- {
- return false;
- }
- public virtual bool CheckResurrect()
- {
- return true;
- }
- public bool CheckSkill(SkillName skill, double chance)
- {
- if (m_SkillCheckDirectLocationHandler == null)
- {
- return false;
- }
- return m_SkillCheckDirectLocationHandler(this, skill, chance);
- }
- public bool CheckSkill(SkillName skill, double minSkill, double maxSkill)
- {
- if (m_SkillCheckLocationHandler == null)
- {
- return false;
- }
- return m_SkillCheckLocationHandler(this, skill, minSkill, maxSkill);
- }
- public virtual bool CheckSpeechManifest()
- {
- if (this.Alive)
- {
- return false;
- }
- TimeSpan autoManifestTimeout = m_AutoManifestTimeout;
- if ((autoManifestTimeout <= TimeSpan.Zero) || (this.Warmode && (this.m_AutoManifestTimer == null)))
- {
- return false;
- }
- this.Manifest(autoManifestTimeout);
- return true;
- }
- public virtual bool CheckSpellCast(ISpell spell)
- {
- return true;
- }
- public virtual void CheckStatTimers()
- {
- if (this.Hits < this.HitsMax)
- {
- if (this.m_HitsTimer == null)
- {
- this.m_HitsTimer = new HitsTimer(this);
- }
- this.m_HitsTimer.Start();
- }
- else
- {
- this.Hits = this.HitsMax;
- }
- if (this.Stam < this.StamMax)
- {
- if (this.m_StamTimer == null)
- {
- this.m_StamTimer = new StamTimer(this);
- }
- this.m_StamTimer.Start();
- }
- else
- {
- this.Stam = this.StamMax;
- }
- if (this.Mana < this.ManaMax)
- {
- if (this.m_ManaTimer == null)
- {
- this.m_ManaTimer = new ManaTimer(this);
- }
- this.m_ManaTimer.Start();
- }
- else
- {
- this.Mana = this.ManaMax;
- }
- }
- public virtual bool CheckTarget(Mobile from, Server.Targeting.Target targ, object targeted)
- {
- return true;
- }
- public bool CheckTargetSkill(SkillName skill, object target, double chance)
- {
- if (m_SkillCheckDirectTargetHandler == null)
- {
- return false;
- }
- return m_SkillCheckDirectTargetHandler(this, skill, target, chance);
- }
- public bool CheckTargetSkill(SkillName skill, object target, double minSkill, double maxSkill)
- {
- if (m_SkillCheckTargetHandler == null)
- {
- return false;
- }
- return m_SkillCheckTargetHandler(this, skill, target, minSkill, maxSkill);
- }
- public virtual void ClearFastwalkStack()
- {
- if ((this.m_MoveRecords != null) && (this.m_MoveRecords.Count > 0))
- {
- this.m_MoveRecords.Clear();
- }
- this.m_EndQueue = DateTime.Now;
- }
- public virtual void ClearHand(Item item)
- {
- if (((item != null) && item.Movable) && !item.AllowEquipedCast(this))
- {
- this.AddToBackpack(item);
- }
- }
- public virtual void ClearHands()
- {
- this.ClearHand(this.FindItemOnLayer(Layer.FirstValid));
- this.ClearHand(this.FindItemOnLayer(Layer.TwoHanded));
- }
- public void ClearQuestArrow()
- {
- this.m_QuestArrow = null;
- }
- public void ClearScreen()
- {
- Server.Network.NetState netState = this.m_NetState;
- if ((this.m_Map != null) && (netState != null))
- {
- IPooledEnumerable objectsInRange = this.m_Map.GetObjectsInRange(this.m_Location, Core.GlobalMaxUpdateRange);
- foreach (object obj2 in objectsInRange)
- {
- if (obj2 is Mobile)
- {
- Mobile mobile = (Mobile) obj2;
- if ((mobile != this) && Utility.InUpdateRange(this.m_Location, mobile.m_Location))
- {
- netState.Send(mobile.RemovePacket);
- }
- }
- else if (obj2 is Item)
- {
- Item item = (Item) obj2;
- if (this.InRange(item.Location, item.GetUpdateRange(this)))
- {
- netState.Send(item.RemovePacket);
- }
- }
- }
- objectsInRange.Free();
- }
- }
- public void ClearTarget()
- {
- this.m_Target = null;
- }
- public bool CloseAllGumps()
- {
- return this.CloseAllGumps(false);
- }
- public bool CloseAllGumps(bool throwOnOffline)
- {
- Server.Network.NetState netState = this.m_NetState;
- if (netState != null)
- {
- var gumps = netState.Gumps;
- foreach(Gump gump in gumps)
- {
- netState.Send(new Server.Network.CloseGump(gump.TypeID, 0));
- }
- return true;
- }
- if (throwOnOffline)
- {
- throw new MobileNotConnectedException(this, "Gump close packets could not be sent.");
- }
- return false;
- }
- public bool CloseGump(Type type)
- {
- return this.CloseGump(type, 0, false);
- }
- public bool CloseGump(Type type, int buttonID)
- {
- return this.CloseGump(type, buttonID, false);
- }
- public bool CloseGump(Type type, int buttonID, bool throwOnOffline)
- {
- if (this.m_NetState != null)
- {
- this.m_NetState.Send(new Server.Network.CloseGump(Gump.GetTypeID(type), buttonID));
- return true;
- }
- if (throwOnOffline)
- {
- throw new MobileNotConnectedException(this, "Gump close packet could not be sent.");
- }
- return false;
- }
- public virtual void ComputeBaseLightLevels(out int global, out int personal)
- {
- global = 0;
- personal = this.m_LightLevel;
- }
- public virtual void ComputeLightLevels(out int global, out int personal)
- {
- this.ComputeBaseLightLevels(out global, out personal);
- if (this.m_Region != null)
- {
- this.m_Region.AlterLightLevel(this, ref global, ref personal);
- }
- }
- public virtual void ComputeResistances()
- {
- int[] numArray;
- if (this.m_Resistances == null)
- {
- this.m_Resistances = new int[] { -2147483648, -2147483648, -2147483648, -2147483648, -2147483648 };
- }
- for (int i = 0; i < this.m_Resistances.Length; i++)
- {
- this.m_Resistances[i] = 0;
- }
- (numArray = this.m_Resistances)[0] = numArray[0] + this.BasePhysicalResistance;
- (numArray = this.m_Resistances)[1] = numArray[1] + this.BaseFireResistance;
- (numArray = this.m_Resistances)[2] = numArray[2] + this.BaseColdResistance;
- (numArray = this.m_Resistances)[3] = numArray[3] + this.BasePoisonResistance;
- (numArray = this.m_Resistances)[4] = numArray[4] + this.BaseEnergyResistance;
- for (int j = 0; (this.m_ResistMods != null) && (j < this.m_ResistMods.Count); j++)
- {
- ResistanceMod mod = (ResistanceMod) this.m_ResistMods[j];
- int type = (int) mod.Type;
- if ((type >= 0) && (type < this.m_Resistances.Length))
- {
- IntPtr ptr;
- (numArray = this.m_Resistances)[(int) (ptr = (IntPtr) type)] = numArray[(int) ptr] + mod.Offset;
- }
- }
- for (int k = 0; k < this.m_Items.Count; k++)
- {
- Item item = (Item) this.m_Items[k];
- if (!item.CheckPropertyConfliction(this))
- {
- (numArray = this.m_Resistances)[0] = numArray[0] + item.PhysicalResistance;
- (numArray = this.m_Resistances)[1] = numArray[1] + item.FireResistance;
- (numArray = this.m_Resistances)[2] = numArray[2] + item.ColdResistance;
- (numArray = this.m_Resistances)[3] = numArray[3] + item.PoisonResistance;
- (numArray = this.m_Resistances)[4] = numArray[4] + item.EnergyResistance;
- }
- }
- for (int m = 0; m < this.m_Resistances.Length; m++)
- …
Large files files are truncated, but you can click here to view the full file