/Scripts/Mobiles/PlayerMobile.cs
https://bitbucket.org/servuo/servuo · C# · 6246 lines · 5156 code · 1060 blank · 30 comment · 1277 complexity · 9dac92646eb6963edc8dc6bb52ee9bbb MD5 · raw file
Large files are truncated click here to view the full file
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Server.Accounting;
- using Server.ContextMenus;
- using Server.Engines.CannedEvil;
- using Server.Engines.Craft;
- using Server.Engines.Help;
- using Server.Engines.PartySystem;
- using Server.Engines.Quests;
- using Server.Engines.XmlSpawner2;
- using Server.Factions;
- using Server.Gumps;
- using Server.Items;
- using Server.Misc;
- using Server.Multis;
- using Server.Network;
- using Server.Regions;
- using Server.Spells;
- using Server.Spells.Bushido;
- using Server.Spells.Fifth;
- using Server.Spells.Necromancy;
- using Server.Spells.Ninjitsu;
- using Server.Spells.Seventh;
- using Server.Spells.Spellweaving;
- using Server.Targeting;
- namespace Server.Mobiles
- {
- #region Enums
- [Flags]
- public enum PlayerFlag // First 16 bits are reserved for default-distro use, start custom flags at 0x00010000
- {
- None = 0x00000000,
- Glassblowing = 0x00000001,
- Masonry = 0x00000002,
- SandMining = 0x00000004,
- StoneMining = 0x00000008,
- ToggleMiningStone = 0x00000010,
- KarmaLocked = 0x00000020,
- AutoRenewInsurance = 0x00000040,
- UseOwnFilter = 0x00000080,
- PublicMyRunUO = 0x00000100,
- PagingSquelched = 0x00000200,
- Young = 0x00000400,
- AcceptGuildInvites = 0x00000800,
- DisplayChampionTitle = 0x00001000,
- HasStatReward = 0x00002000,
- Bedlam = 0x00010000,
- LibraryFriend = 0x00020000,
- Spellweaving = 0x00040000,
- GemMining = 0x00080000,
- ToggleMiningGem = 0x00100000,
- BasketWeaving = 0x00200000,
- AbyssEntry = 0x00400000,
- ToggleClippings = 0x00800000,
- ToggleCutClippings = 0x01000000,
- ToggleCutReeds = 0x02000000,
- MechanicalLife = 0x04000000
- }
- public enum NpcGuild
- {
- None,
- MagesGuild,
- WarriorsGuild,
- ThievesGuild,
- RangersGuild,
- HealersGuild,
- MinersGuild,
- MerchantsGuild,
- TinkersGuild,
- TailorsGuild,
- FishermensGuild,
- BardsGuild,
- BlacksmithsGuild
- }
- public enum SolenFriendship
- {
- None,
- Red,
- Black
- }
- #endregion
- public partial class PlayerMobile : Mobile, IHonorTarget
- {
- #region Mount Blocking
- public void SetMountBlock(BlockMountType type, TimeSpan duration, bool dismount)
- {
- if (dismount)
- {
- BaseMount.Dismount(this, this, type, duration, false);
- }
- else
- {
- BaseMount.SetMountPrevention(this, type, duration);
- }
- }
- #endregion
- #region Stygian Abyss
- public override void ToggleFlying()
- {
- if (this.Race != Race.Gargoyle)
- return;
- else if (this.Flying)
- {
- this.Freeze(TimeSpan.FromSeconds(1));
- this.Animate(61, 10, 1, true, false, 0);
- this.Flying = false;
- BuffInfo.RemoveBuff(this, BuffIcon.Fly);
- this.SendMessage("You have landed.");
- BaseMount.Dismount(this);
- return;
- }
- BlockMountType type = BaseMount.GetMountPrevention(this);
- if (!this.Alive)
- this.SendLocalizedMessage(1113082); // You may not fly while dead.
- else if (this.IsBodyMod && !(this.BodyMod == 666 || this.BodyMod == 667))
- this.SendLocalizedMessage(1112453); // You can't fly in your current form!
- else if (type != BlockMountType.None)
- {
- switch (type)
- {
- case BlockMountType.Dazed:
- this.SendLocalizedMessage(1112457);
- break; // You are still too dazed to fly.
- case BlockMountType.BolaRecovery:
- this.SendLocalizedMessage(1112455);
- break; // You cannot fly while recovering from a bola throw.
- case BlockMountType.DismountRecovery:
- this.SendLocalizedMessage(1112456);
- break; // You cannot fly while recovering from a dismount maneuver.
- }
- return;
- }
- else if (this.Hits < 25) // TODO confirm
- this.SendLocalizedMessage(1112454); // You must heal before flying.
- else
- {
- if (!this.Flying)
- {
- // No message?
- if (this.Spell is FlySpell)
- {
- FlySpell spell = (FlySpell)this.Spell;
- spell.Stop();
- }
- new FlySpell(this).Cast();
- }
- else
- {
- this.Flying = false;
- BuffInfo.RemoveBuff(this, BuffIcon.Fly);
- }
- }
- }
- #endregion
- private class CountAndTimeStamp
- {
- private int m_Count;
- private DateTime m_Stamp;
- public CountAndTimeStamp()
- {
- }
- public DateTime TimeStamp
- {
- get
- {
- return this.m_Stamp;
- }
- }
- public int Count
- {
- get
- {
- return this.m_Count;
- }
- set
- {
- this.m_Count = value;
- this.m_Stamp = DateTime.Now;
- }
- }
- }
- private DesignContext m_DesignContext;
- private NpcGuild m_NpcGuild;
- private DateTime m_NpcGuildJoinTime;
- private DateTime m_NextBODTurnInTime;
- private TimeSpan m_NpcGuildGameTime;
- private PlayerFlag m_Flags;
- private int m_StepsTaken;
- private int m_Profession;
- private bool m_IsStealthing; // IsStealthing should be moved to Server.Mobiles
- private bool m_IgnoreMobiles; // IgnoreMobiles should be moved to Server.Mobiles
- private int m_NonAutoreinsuredItems; // number of items that could not be automaitically reinsured because gold in bank was not enough
- private bool m_NinjaWepCooldown;
- /*
- * a value of zero means, that the mobile is not executing the spell. Otherwise,
- * the value should match the BaseMana required
- */
- private int m_ExecutesLightningStrike; // move to Server.Mobiles??
- private DateTime m_LastOnline;
- private Server.Guilds.RankDefinition m_GuildRank;
- private int m_GuildMessageHue, m_AllianceMessageHue;
- private List<Mobile> m_AutoStabled;
- private List<Mobile> m_AllFollowers;
- private List<Mobile> m_RecentlyReported;
- #region Guantlet Points
- private double m_GauntletPoints;
- [CommandProperty(AccessLevel.Administrator)]
- public double GauntletPoints
- {
- get
- {
- return this.m_GauntletPoints;
- }
- set
- {
- this.m_GauntletPoints = value;
- }
- }
- #endregion
- #region Getters & Setters
- public List<Mobile> RecentlyReported
- {
- get
- {
- return this.m_RecentlyReported;
- }
- set
- {
- this.m_RecentlyReported = value;
- }
- }
- public List<Mobile> AutoStabled
- {
- get
- {
- return this.m_AutoStabled;
- }
- }
- public bool NinjaWepCooldown
- {
- get
- {
- return this.m_NinjaWepCooldown;
- }
- set
- {
- this.m_NinjaWepCooldown = value;
- }
- }
- public List<Mobile> AllFollowers
- {
- get
- {
- if (this.m_AllFollowers == null)
- this.m_AllFollowers = new List<Mobile>();
- return this.m_AllFollowers;
- }
- }
- public Server.Guilds.RankDefinition GuildRank
- {
- get
- {
- if (this.AccessLevel >= AccessLevel.GameMaster)
- return Server.Guilds.RankDefinition.Leader;
- else
- return this.m_GuildRank;
- }
- set
- {
- this.m_GuildRank = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public int GuildMessageHue
- {
- get
- {
- return this.m_GuildMessageHue;
- }
- set
- {
- this.m_GuildMessageHue = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public int AllianceMessageHue
- {
- get
- {
- return this.m_AllianceMessageHue;
- }
- set
- {
- this.m_AllianceMessageHue = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public int Profession
- {
- get
- {
- return this.m_Profession;
- }
- set
- {
- this.m_Profession = value;
- }
- }
- public int StepsTaken
- {
- get
- {
- return this.m_StepsTaken;
- }
- set
- {
- this.m_StepsTaken = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool IsStealthing // IsStealthing should be moved to Server.Mobiles
- {
- get
- {
- return this.m_IsStealthing;
- }
- set
- {
- this.m_IsStealthing = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool IgnoreMobiles // IgnoreMobiles should be moved to Server.Mobiles
- {
- get
- {
- return this.m_IgnoreMobiles;
- }
- set
- {
- if (this.m_IgnoreMobiles != value)
- {
- this.m_IgnoreMobiles = value;
- this.Delta(MobileDelta.Flags);
- }
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public NpcGuild NpcGuild
- {
- get
- {
- return this.m_NpcGuild;
- }
- set
- {
- this.m_NpcGuild = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public DateTime NpcGuildJoinTime
- {
- get
- {
- return this.m_NpcGuildJoinTime;
- }
- set
- {
- this.m_NpcGuildJoinTime = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public DateTime NextBODTurnInTime
- {
- get
- {
- return this.m_NextBODTurnInTime;
- }
- set
- {
- this.m_NextBODTurnInTime = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public DateTime LastOnline
- {
- get
- {
- return this.m_LastOnline;
- }
- set
- {
- this.m_LastOnline = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public DateTime LastMoved
- {
- get
- {
- return this.LastMoveTime;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public TimeSpan NpcGuildGameTime
- {
- get
- {
- return this.m_NpcGuildGameTime;
- }
- set
- {
- this.m_NpcGuildGameTime = value;
- }
- }
- private int m_ToTItemsTurnedIn;
- [CommandProperty(AccessLevel.GameMaster)]
- public int ToTItemsTurnedIn
- {
- get
- {
- return this.m_ToTItemsTurnedIn;
- }
- set
- {
- this.m_ToTItemsTurnedIn = value;
- }
- }
- private int m_ToTTotalMonsterFame;
- [CommandProperty(AccessLevel.GameMaster)]
- public int ToTTotalMonsterFame
- {
- get
- {
- return this.m_ToTTotalMonsterFame;
- }
- set
- {
- this.m_ToTTotalMonsterFame = value;
- }
- }
- public int ExecutesLightningStrike
- {
- get
- {
- return this.m_ExecutesLightningStrike;
- }
- set
- {
- this.m_ExecutesLightningStrike = value;
- }
- }
- private int m_VASTotalMonsterFame;
- [CommandProperty(AccessLevel.GameMaster)]
- public int VASTotalMonsterFame
- {
- get
- {
- return this.m_VASTotalMonsterFame;
- }
- set
- {
- this.m_VASTotalMonsterFame = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public int ToothAche
- {
- get
- {
- return CandyCane.GetToothAche(this);
- }
- set
- {
- CandyCane.SetToothAche(this, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool MechanicalLife
- {
- get
- {
- return this.GetFlag(PlayerFlag.MechanicalLife);
- }
- set
- {
- this.SetFlag(PlayerFlag.MechanicalLife, value);
- }
- }
- #endregion
- #region PlayerFlags
- public PlayerFlag Flags
- {
- get
- {
- return this.m_Flags;
- }
- set
- {
- this.m_Flags = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool PagingSquelched
- {
- get
- {
- return this.GetFlag(PlayerFlag.PagingSquelched);
- }
- set
- {
- this.SetFlag(PlayerFlag.PagingSquelched, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool Glassblowing
- {
- get
- {
- return this.GetFlag(PlayerFlag.Glassblowing);
- }
- set
- {
- this.SetFlag(PlayerFlag.Glassblowing, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool Masonry
- {
- get
- {
- return this.GetFlag(PlayerFlag.Masonry);
- }
- set
- {
- this.SetFlag(PlayerFlag.Masonry, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool SandMining
- {
- get
- {
- return this.GetFlag(PlayerFlag.SandMining);
- }
- set
- {
- this.SetFlag(PlayerFlag.SandMining, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool StoneMining
- {
- get
- {
- return this.GetFlag(PlayerFlag.StoneMining);
- }
- set
- {
- this.SetFlag(PlayerFlag.StoneMining, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool GemMining
- {
- get
- {
- return this.GetFlag(PlayerFlag.GemMining);
- }
- set
- {
- this.SetFlag(PlayerFlag.GemMining, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool BasketWeaving
- {
- get
- {
- return this.GetFlag(PlayerFlag.BasketWeaving);
- }
- set
- {
- this.SetFlag(PlayerFlag.BasketWeaving, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool ToggleMiningStone
- {
- get
- {
- return this.GetFlag(PlayerFlag.ToggleMiningStone);
- }
- set
- {
- this.SetFlag(PlayerFlag.ToggleMiningStone, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool AbyssEntry
- {
- get
- {
- return this.GetFlag(PlayerFlag.AbyssEntry);
- }
- set
- {
- this.SetFlag(PlayerFlag.AbyssEntry, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool ToggleMiningGem
- {
- get
- {
- return this.GetFlag(PlayerFlag.ToggleMiningGem);
- }
- set
- {
- this.SetFlag(PlayerFlag.ToggleMiningGem, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool KarmaLocked
- {
- get
- {
- return this.GetFlag(PlayerFlag.KarmaLocked);
- }
- set
- {
- this.SetFlag(PlayerFlag.KarmaLocked, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool AutoRenewInsurance
- {
- get
- {
- return this.GetFlag(PlayerFlag.AutoRenewInsurance);
- }
- set
- {
- this.SetFlag(PlayerFlag.AutoRenewInsurance, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool UseOwnFilter
- {
- get
- {
- return this.GetFlag(PlayerFlag.UseOwnFilter);
- }
- set
- {
- this.SetFlag(PlayerFlag.UseOwnFilter, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool PublicMyRunUO
- {
- get
- {
- return this.GetFlag(PlayerFlag.PublicMyRunUO);
- }
- set
- {
- this.SetFlag(PlayerFlag.PublicMyRunUO, value);
- this.InvalidateMyRunUO();
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool AcceptGuildInvites
- {
- get
- {
- return this.GetFlag(PlayerFlag.AcceptGuildInvites);
- }
- set
- {
- this.SetFlag(PlayerFlag.AcceptGuildInvites, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool HasStatReward
- {
- get
- {
- return this.GetFlag(PlayerFlag.HasStatReward);
- }
- set
- {
- this.SetFlag(PlayerFlag.HasStatReward, value);
- }
- }
- #region QueensLoyaltySystem
- private long m_LevelExp; // Experience Needed for next Experience Level
- [CommandProperty(AccessLevel.Owner)]
- public long LevelExp
- {
- get
- {
- return this.m_LevelExp;
- }
- set
- {
- this.m_LevelExp = value;
- this.InvalidateProperties();
- }
- }
- private long m_Exp; // Experience at the current Experience Level
- [CommandProperty(AccessLevel.GameMaster)]
- public long Exp
- {
- get
- {
- return this.m_Exp;
- }
- set
- {
- this.m_Exp = value;
- this.InvalidateProperties();
- }
- }
- private int m_Level; // Experience Level
- [CommandProperty(AccessLevel.GameMaster)]
- public int Level
- {
- get
- {
- return this.m_Level;
- }
- set
- {
- this.m_Level = value;
- this.InvalidateProperties();
- }
- }
- public string m_ExpTitle; // Title based on both levels
- [CommandProperty(AccessLevel.Owner)]
- public string ExpTitle
- {
- get
- {
- return this.m_ExpTitle;
- }
- set
- {
- this.m_ExpTitle = value;
- this.InvalidateProperties();
- }
- }
- #endregion
- #region Plant system
- [CommandProperty(AccessLevel.GameMaster)]
- public bool ToggleClippings
- {
- get
- {
- return this.GetFlag(PlayerFlag.ToggleClippings);
- }
- set
- {
- this.SetFlag(PlayerFlag.ToggleClippings, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool ToggleCutReeds
- {
- get
- {
- return this.GetFlag(PlayerFlag.ToggleCutReeds);
- }
- set
- {
- this.SetFlag(PlayerFlag.ToggleCutReeds, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool ToggleCutClippings
- {
- get
- {
- return this.GetFlag(PlayerFlag.ToggleCutClippings);
- }
- set
- {
- this.SetFlag(PlayerFlag.ToggleCutClippings, value);
- }
- }
- private DateTime m_SSNextSeed;
- [CommandProperty(AccessLevel.GameMaster)]
- public DateTime SSNextSeed
- {
- get
- {
- return this.m_SSNextSeed;
- }
- set
- {
- this.m_SSNextSeed = value;
- }
- }
- private DateTime m_SSSeedExpire;
- [CommandProperty(AccessLevel.GameMaster)]
- public DateTime SSSeedExpire
- {
- get
- {
- return this.m_SSSeedExpire;
- }
- set
- {
- this.m_SSSeedExpire = value;
- }
- }
- private Point3D m_SSSeedLocation;
- public Point3D SSSeedLocation
- {
- get
- {
- return this.m_SSSeedLocation;
- }
- set
- {
- this.m_SSSeedLocation = value;
- }
- }
- private Map m_SSSeedMap;
- public Map SSSeedMap
- {
- get
- {
- return this.m_SSSeedMap;
- }
- set
- {
- this.m_SSSeedMap = value;
- }
- }
- #endregion
- #endregion
- #region Auto Arrow Recovery
- private Dictionary<Type, int> m_RecoverableAmmo = new Dictionary<Type, int>();
- public Dictionary<Type, int> RecoverableAmmo
- {
- get
- {
- return this.m_RecoverableAmmo;
- }
- }
- public void RecoverAmmo()
- {
- if (Core.SE && this.Alive)
- {
- foreach (KeyValuePair<Type, int> kvp in this.m_RecoverableAmmo)
- {
- if (kvp.Value > 0)
- {
- Item ammo = null;
- try
- {
- ammo = Activator.CreateInstance(kvp.Key) as Item;
- }
- catch
- {
- }
- if (ammo != null)
- {
- string name = ammo.Name;
- ammo.Amount = kvp.Value;
- if (name == null)
- {
- if (ammo is Arrow)
- name = "arrow";
- else if (ammo is Bolt)
- name = "bolt";
- }
- if (name != null && ammo.Amount > 1)
- name = String.Format("{0}s", name);
- if (name == null)
- name = String.Format("#{0}", ammo.LabelNumber);
- this.PlaceInBackpack(ammo);
- this.SendLocalizedMessage(1073504, String.Format("{0}\t{1}", ammo.Amount, name)); // You recover ~1_NUM~ ~2_AMMO~.
- }
- }
- }
- this.m_RecoverableAmmo.Clear();
- }
- }
- #endregion
- private DateTime m_AnkhNextUse;
- [CommandProperty(AccessLevel.GameMaster)]
- public DateTime AnkhNextUse
- {
- get
- {
- return this.m_AnkhNextUse;
- }
- set
- {
- this.m_AnkhNextUse = value;
- }
- }
- #region Mondain's Legacy
- [CommandProperty(AccessLevel.GameMaster)]
- public bool Bedlam
- {
- get
- {
- return this.GetFlag(PlayerFlag.Bedlam);
- }
- set
- {
- this.SetFlag(PlayerFlag.Bedlam, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool LibraryFriend
- {
- get
- {
- return this.GetFlag(PlayerFlag.LibraryFriend);
- }
- set
- {
- this.SetFlag(PlayerFlag.LibraryFriend, value);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public bool Spellweaving
- {
- get
- {
- return this.GetFlag(PlayerFlag.Spellweaving);
- }
- set
- {
- this.SetFlag(PlayerFlag.Spellweaving, value);
- }
- }
- #endregion
- [CommandProperty(AccessLevel.GameMaster)]
- public TimeSpan DisguiseTimeLeft
- {
- get
- {
- return DisguiseTimers.TimeRemaining(this);
- }
- }
- private DateTime m_PeacedUntil;
- [CommandProperty(AccessLevel.GameMaster)]
- public DateTime PeacedUntil
- {
- get
- {
- return this.m_PeacedUntil;
- }
- set
- {
- this.m_PeacedUntil = value;
- }
- }
- #region Scroll of Alacrity
- private DateTime m_AcceleratedStart;
- [CommandProperty(AccessLevel.GameMaster)]
- public DateTime AcceleratedStart
- {
- get
- {
- return this.m_AcceleratedStart;
- }
- set
- {
- this.m_AcceleratedStart = value;
- }
- }
- private SkillName m_AcceleratedSkill;
- [CommandProperty(AccessLevel.GameMaster)]
- public SkillName AcceleratedSkill
- {
- get
- {
- return this.m_AcceleratedSkill;
- }
- set
- {
- this.m_AcceleratedSkill = value;
- }
- }
- #endregion
- public static Direction GetDirection4(Point3D from, Point3D to)
- {
- int dx = from.X - to.X;
- int dy = from.Y - to.Y;
- int rx = dx - dy;
- int ry = dx + dy;
- Direction ret;
- if (rx >= 0 && ry >= 0)
- ret = Direction.West;
- else if (rx >= 0 && ry < 0)
- ret = Direction.South;
- else if (rx < 0 && ry < 0)
- ret = Direction.East;
- else
- ret = Direction.North;
- return ret;
- }
- public override bool OnDroppedItemToWorld(Item item, Point3D location)
- {
- if (!base.OnDroppedItemToWorld(item, location))
- return false;
- if (Core.AOS)
- {
- IPooledEnumerable mobiles = this.Map.GetMobilesInRange(location, 0);
- foreach (Mobile m in mobiles)
- {
- if (m.Z >= location.Z && m.Z < location.Z + 16)
- {
- mobiles.Free();
- return false;
- }
- }
- mobiles.Free();
- }
- BounceInfo bi = item.GetBounce();
- if (bi != null)
- {
- Type type = item.GetType();
- if (type.IsDefined(typeof(FurnitureAttribute), true) || type.IsDefined(typeof(DynamicFlipingAttribute), true))
- {
- object[] objs = type.GetCustomAttributes(typeof(FlipableAttribute), true);
- if (objs != null && objs.Length > 0)
- {
- FlipableAttribute fp = objs[0] as FlipableAttribute;
- if (fp != null)
- {
- int[] itemIDs = fp.ItemIDs;
- Point3D oldWorldLoc = bi.m_WorldLoc;
- Point3D newWorldLoc = location;
- if (oldWorldLoc.X != newWorldLoc.X || oldWorldLoc.Y != newWorldLoc.Y)
- {
- Direction dir = GetDirection4(oldWorldLoc, newWorldLoc);
- if (itemIDs.Length == 2)
- {
- switch ( dir )
- {
- case Direction.North:
- case Direction.South:
- item.ItemID = itemIDs[0];
- break;
- case Direction.East:
- case Direction.West:
- item.ItemID = itemIDs[1];
- break;
- }
- }
- else if (itemIDs.Length == 4)
- {
- switch ( dir )
- {
- case Direction.South:
- item.ItemID = itemIDs[0];
- break;
- case Direction.East:
- item.ItemID = itemIDs[1];
- break;
- case Direction.North:
- item.ItemID = itemIDs[2];
- break;
- case Direction.West:
- item.ItemID = itemIDs[3];
- break;
- }
- }
- }
- }
- }
- }
- }
- return true;
- }
- public override int GetPacketFlags()
- {
- int flags = base.GetPacketFlags();
- if (this.m_IgnoreMobiles)
- flags |= 0x10;
- return flags;
- }
- public override int GetOldPacketFlags()
- {
- int flags = base.GetOldPacketFlags();
- if (this.m_IgnoreMobiles)
- flags |= 0x10;
- return flags;
- }
- public bool GetFlag(PlayerFlag flag)
- {
- return ((this.m_Flags & flag) != 0);
- }
- public void SetFlag(PlayerFlag flag, bool value)
- {
- if (value)
- this.m_Flags |= flag;
- else
- this.m_Flags &= ~flag;
- }
- public DesignContext DesignContext
- {
- get
- {
- return this.m_DesignContext;
- }
- set
- {
- this.m_DesignContext = value;
- }
- }
- public static void Initialize()
- {
- if (FastwalkPrevention)
- PacketHandlers.RegisterThrottler(0x02, new ThrottlePacketCallback(MovementThrottle_Callback));
- EventSink.Login += new LoginEventHandler(OnLogin);
- EventSink.Logout += new LogoutEventHandler(OnLogout);
- EventSink.Connected += new ConnectedEventHandler(EventSink_Connected);
- EventSink.Disconnected += new DisconnectedEventHandler(EventSink_Disconnected);
- if (Core.SE)
- {
- Timer.DelayCall(TimeSpan.Zero, new TimerCallback(CheckPets));
- }
- }
- private static void CheckPets()
- {
- foreach (Mobile m in World.Mobiles.Values)
- {
- if (m is PlayerMobile)
- {
- PlayerMobile pm = (PlayerMobile)m;
- if (((!pm.Mounted || (pm.Mount != null && pm.Mount is EtherealMount)) && (pm.AllFollowers.Count > pm.AutoStabled.Count)) ||
- (pm.Mounted && (pm.AllFollowers.Count > (pm.AutoStabled.Count + 1))))
- {
- pm.AutoStablePets(); /* autostable checks summons, et al: no need here */
- }
- }
- }
- }
- public override void OnSkillInvalidated(Skill skill)
- {
- if (Core.AOS && skill.SkillName == SkillName.MagicResist)
- this.UpdateResistances();
- }
- public override int GetMaxResistance(ResistanceType type)
- {
- if (this.IsStaff())
- return int.MaxValue;
- int max = base.GetMaxResistance(type);
- if (type != ResistanceType.Physical && 60 < max && Spells.Fourth.CurseSpell.UnderEffect(this))
- max = 60;
- if (Core.ML && this.Race == Race.Elf && type == ResistanceType.Energy)
- max += 5; //Intended to go after the 60 max from curse
- return max;
- }
- protected override void OnRaceChange(Race oldRace)
- {
- this.ValidateEquipment();
- this.UpdateResistances();
- }
- public override int MaxWeight
- {
- get
- {
- return (((Core.ML && this.Race == Race.Human) ? 100 : 40) + (int)(3.5 * this.Str));
- }
- }
- private int m_LastGlobalLight = -1, m_LastPersonalLight = -1;
- public override void OnNetStateChanged()
- {
- this.m_LastGlobalLight = -1;
- this.m_LastPersonalLight = -1;
- }
- public override void ComputeBaseLightLevels(out int global, out int personal)
- {
- global = LightCycle.ComputeLevelFor(this);
- bool racialNightSight = (Core.ML && this.Race == Race.Elf);
- if (this.LightLevel < 21 && (AosAttributes.GetValue(this, AosAttribute.NightSight) > 0 || racialNightSight))
- personal = 21;
- else
- personal = this.LightLevel;
- }
- public override void CheckLightLevels(bool forceResend)
- {
- NetState ns = this.NetState;
- if (ns == null)
- return;
- int global, personal;
- this.ComputeLightLevels(out global, out personal);
- if (!forceResend)
- forceResend = (global != this.m_LastGlobalLight || personal != this.m_LastPersonalLight);
- if (!forceResend)
- return;
- this.m_LastGlobalLight = global;
- this.m_LastPersonalLight = personal;
- ns.Send(GlobalLightLevel.Instantiate(global));
- ns.Send(new PersonalLightLevel(this, personal));
- }
- public override int GetMinResistance(ResistanceType type)
- {
- int magicResist = (int)(this.Skills[SkillName.MagicResist].Value * 10);
- int min = int.MinValue;
- if (magicResist >= 1000)
- min = 40 + ((magicResist - 1000) / 50);
- else if (magicResist >= 400)
- min = (magicResist - 400) / 15;
- if (min > MaxPlayerResistance)
- min = MaxPlayerResistance;
- int baseMin = base.GetMinResistance(type);
- if (min < baseMin)
- min = baseMin;
- return min;
- }
- public override void OnManaChange(int oldValue)
- {
- base.OnManaChange(oldValue);
- if (this.m_ExecutesLightningStrike > 0)
- {
- if (this.Mana < this.m_ExecutesLightningStrike)
- {
- LightningStrike.ClearCurrentMove(this);
- }
- }
- }
- private static void OnLogin(LoginEventArgs e)
- {
- Mobile from = e.Mobile;
- CheckAtrophies(from);
- if (AccountHandler.LockdownLevel > AccessLevel.VIP)
- {
- string notice;
- Accounting.Account acct = from.Account as Accounting.Account;
- if (acct == null || !acct.HasAccess(from.NetState))
- {
- if (from.IsPlayer())
- notice = "The server is currently under lockdown. No players are allowed to log in at this time.";
- else
- notice = "The server is currently under lockdown. You do not have sufficient access level to connect.";
- Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(Disconnect), from);
- }
- else if (from.AccessLevel >= AccessLevel.Administrator)
- {
- notice = "The server is currently under lockdown. As you are an administrator, you may change this from the [Admin gump.";
- }
- else
- {
- notice = "The server is currently under lockdown. You have sufficient access level to connect.";
- }
- from.SendGump(new NoticeGump(1060637, 30720, notice, 0xFFC000, 300, 140, null, null));
- return;
- }
- if (from is PlayerMobile)
- ((PlayerMobile)from).ClaimAutoStabledPets();
- }
- private bool m_NoDeltaRecursion;
- public void ValidateEquipment()
- {
- if (this.m_NoDeltaRecursion || this.Map == null || this.Map == Map.Internal)
- return;
- if (this.Items == null)
- return;
- this.m_NoDeltaRecursion = true;
- Timer.DelayCall(TimeSpan.Zero, new TimerCallback(ValidateEquipment_Sandbox));
- }
- private void ValidateEquipment_Sandbox()
- {
- try
- {
- if (this.Map == null || this.Map == Map.Internal)
- return;
- List<Item> items = this.Items;
- if (items == null)
- return;
- bool moved = false;
- int str = this.Str;
- int dex = this.Dex;
- int intel = this.Int;
- #region Factions
- int factionItemCount = 0;
- #endregion
- Mobile from = this;
- #region Ethics
- Ethics.Ethic ethic = Ethics.Ethic.Find(from);
- #endregion
- for (int i = items.Count - 1; i >= 0; --i)
- {
- if (i >= items.Count)
- continue;
- Item item = items[i];
- #region Ethics
- if ((item.SavedFlags & 0x100) != 0)
- {
- if (item.Hue != Ethics.Ethic.Hero.Definition.PrimaryHue)
- {
- item.SavedFlags &= ~0x100;
- }
- else if (ethic != Ethics.Ethic.Hero)
- {
- from.AddToBackpack(item);
- moved = true;
- continue;
- }
- }
- else if ((item.SavedFlags & 0x200) != 0)
- {
- if (item.Hue != Ethics.Ethic.Evil.Definition.PrimaryHue)
- {
- item.SavedFlags &= ~0x200;
- }
- else if (ethic != Ethics.Ethic.Evil)
- {
- from.AddToBackpack(item);
- moved = true;
- continue;
- }
- }
- #endregion
- if (item is BaseWeapon)
- {
- BaseWeapon weapon = (BaseWeapon)item;
- bool drop = false;
- if (dex < weapon.DexRequirement)
- drop = true;
- else if (str < AOS.Scale(weapon.StrRequirement, 100 - weapon.GetLowerStatReq()))
- drop = true;
- else if (intel < weapon.IntRequirement)
- drop = true;
- else if (weapon.RequiredRace != null && weapon.RequiredRace != this.Race)
- drop = true;
- if (drop)
- {
- string name = weapon.Name;
- if (name == null)
- name = String.Format("#{0}", weapon.LabelNumber);
- from.SendLocalizedMessage(1062001, name); // You can no longer wield your ~1_WEAPON~
- from.AddToBackpack(weapon);
- moved = true;
- }
- }
- else if (item is BaseArmor)
- {
- BaseArmor armor = (BaseArmor)item;
- bool drop = false;
- if (!armor.AllowMaleWearer && !from.Female && from.AccessLevel < AccessLevel.GameMaster)
- {
- drop = true;
- }
- else if (!armor.AllowFemaleWearer && from.Female && from.AccessLevel < AccessLevel.GameMaster)
- {
- drop = true;
- }
- else if (armor.RequiredRace != null && armor.RequiredRace != this.Race)
- {
- drop = true;
- }
- else
- {
- int strBonus = armor.ComputeStatBonus(StatType.Str), strReq = armor.ComputeStatReq(StatType.Str);
- int dexBonus = armor.ComputeStatBonus(StatType.Dex), dexReq = armor.ComputeStatReq(StatType.Dex);
- int intBonus = armor.ComputeStatBonus(StatType.Int), intReq = armor.ComputeStatReq(StatType.Int);
- if (dex < dexReq || (dex + dexBonus) < 1)
- drop = true;
- else if (str < strReq || (str + strBonus) < 1)
- drop = true;
- else if (intel < intReq || (intel + intBonus) < 1)
- drop = true;
- }
- if (drop)
- {
- string name = armor.Name;
- if (name == null)
- name = String.Format("#{0}", armor.LabelNumber);
- if (armor is BaseShield)
- from.SendLocalizedMessage(1062003, name); // You can no longer equip your ~1_SHIELD~
- else
- from.SendLocalizedMessage(1062002, name); // You can no longer wear your ~1_ARMOR~
- from.AddToBackpack(armor);
- moved = true;
- }
- }
- else if (item is BaseClothing)
- {
- BaseClothing clothing = (BaseClothing)item;
- bool drop = false;
- if (!clothing.AllowMaleWearer && !from.Female && from.AccessLevel < AccessLevel.GameMaster)
- {
- drop = true;
- }
- else if (!clothing.AllowFemaleWearer && from.Female && from.AccessLevel < AccessLevel.GameMaster)
- {
- drop = true;
- }
- else if (clothing.RequiredRace != null && clothing.RequiredRace != this.Race)
- {
- drop = true;
- }
- else
- {
- int strBonus = clothing.ComputeStatBonus(StatType.Str);
- int strReq = clothing.ComputeStatReq(StatType.Str);
- if (str < strReq || (str + strBonus) < 1)
- drop = true;
- }
- if (drop)
- {
- string name = clothing.Name;
- if (name == null)
- name = String.Format("#{0}", clothing.LabelNumber);
- from.SendLocalizedMessage(1062002, name); // You can no longer wear your ~1_ARMOR~
- from.AddToBackpack(clothing);
- moved = true;
- }
- }
- FactionItem factionItem = FactionItem.Find(item);
- if (factionItem != null)
- {
- bool drop = false;
- Faction ourFaction = Faction.Find(this);
- if (ourFaction == null || ourFaction != factionItem.Faction)
- drop = true;
- else if (++factionItemCount > FactionItem.GetMaxWearables(this))
- drop = true;
- if (drop)
- {
- from.AddToBackpack(item);
- moved = true;
- }
- }
- }
- if (moved)
- from.SendLocalizedMessage(500647); // Some equipment has been moved to your backpack.
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- }
- finally
- {
- this.m_NoDeltaRecursion = false;
- }
- }
- public override void Delta(MobileDelta flag)
- {
- base.Delta(flag);
- if ((flag & MobileDelta.Stat) != 0)
- this.ValidateEquipment();
- if ((flag & (MobileDelta.Name | MobileDelta.Hue)) != 0)
- this.InvalidateMyRunUO();
- }
- private static void Disconnect(object state)
- {
- NetState ns = ((Mobile)state).NetState;
- if (ns != null)
- ns.Dispose();
- }
- private static void OnLogout(LogoutEventArgs e)
- {
- if (e.Mobile is PlayerMobile)
- ((PlayerMobile)e.Mobile).AutoStablePets();
- #region Scroll of Alacrity
- if (((PlayerMobile)e.Mobile).AcceleratedStart > DateTime.Now)
- {
- ((PlayerMobile)e.Mobile).AcceleratedStart = DateTime.Now;
- Server.Items.ScrollofAlacrity.AlacrityEnd((PlayerMobile)e.Mobile);
- }
- #endregion
- }
- private static void EventSink_Connected(ConnectedEventArgs e)
- {
- PlayerMobile pm = e.Mobile as PlayerMobile;
- if (pm != null)
- {
- pm.m_SessionStart = DateTime.Now;
- if (pm.m_Quest != null)
- pm.m_Quest.StartTimer();
- #region Mondain's Legacy
- QuestHelper.StartTimer(pm);
- #endregion
- pm.BedrollLogout = false;
- pm.LastOnline = DateTime.Now;
- }
- DisguiseTimers.StartTimer(e.Mobile);
- Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ClearSpecialMovesCallback), e.Mobile);
- }
- private static void ClearSpecialMovesCallback(object state)
- {
- Mobile from = (Mobile)state;
- SpecialMove.ClearAllMoves(from);
- }
- private static void EventSink_Disconnected(DisconnectedEventArgs e)
- {
- Mobile from = e.Mobile;
- DesignContext context = DesignContext.Find(from);
- if (context != null)
- {
- /* Client disconnected
- * - Remove design context
- * - Eject all from house
- * - Restore relocated entities
- */
- // Remove design context
- DesignContext.Remove(from);
- // Eject all from house
- from.RevealingAction();
- foreach (Item item in context.Foundation.GetItems())
- item.Location = context.Foundation.BanLocation;
- foreach (Mobile mobile in context.Foundation.GetMobiles())
- mobile.Location = context.Foundation.BanLocation;
- // Restore relocated entities
- context.Foundation.RestoreRelocatedEntities();
- }
- PlayerMobile pm = e.Mobile as PlayerMobile;
- if (pm != null)
- {
- pm.m_GameTime += (DateTime.Now - pm.m_SessionStart);
- if (pm.m_Quest != null)
- pm.m_Quest.StopTimer();
- #region Mondain's Legacy
- QuestHelper.StopTimer(pm);
- #endregion
- pm.m_SpeechLog = null;
- pm.LastOnline = DateTime.Now;
- }
- DisguiseTimers.StopTimer(from);
- }
- public override void RevealingAction()
- {
- if (this.m_DesignContext != null)
- return;
- Spells.Sixth.InvisibilitySpell.RemoveTimer(this);
- base.RevealingAction();
- this.m_IsStealthing = false; // IsStealthing should be moved to Server.Mobiles
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public override bool Hidden
- {
- get
- {
- return base.Hidden;
- }
- set
- {
- base.Hidden = value;
- this.RemoveBuff(BuffIcon.Invisibility); //Always remove, default to the hiding icon EXCEPT in the invis spell where it's explicitly set
- if (!this.Hidden)
- {
- this.RemoveBuff(BuffIcon.HidingAndOrStealth);
- }
- else // if( !InvisibilitySpell.HasTimer( this ) )
- {
- BuffInfo.AddBuff(this, new BuffInfo(BuffIcon.HidingAndOrStealth, 1075655)); //Hidden/Stealthing & You Are Hidden
- }
- }
- }
- public override void OnSubItemAdded(Item item)
- {
- if (this.AccessLevel < AccessLevel.GameMaster && item.IsChildOf(this.Backpack))
- {
- int maxWeight = WeightOverloading.GetMaxWeight(this);
- int curWeight = Mobile.BodyWeight + this.TotalWeight;
- if (curWeight > maxWeight)
- this.SendLocalizedMessage(1019035, true, String.Format(" : {0} / {1}", curWeight, maxWeight));
- }
- }
- public override bool CanBeHarmful(Mobile target, bool message, bool ignoreOurBlessedness)
- {
- if (this.m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null))
- return false;
- #region Mondain's Legacy
- if (this.Peaced)
- {
- //!+ TODO: message
- return false;
- }
- #endregion
- if ((target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier)
- {
- if (message)
- {
- if (target.Title == null)
- this.SendMessage("{0} the vendor cannot be harmed.", target.Name);
- else
- this.SendMessage("{0} {1} cannot be harmed.", target.Name, target.Title);
- }
- return false;
- }
- return base.CanBeHarmful(target, message, ignoreOurBlessedness);
- }
- public override bool CanBeBeneficial(Mobile target, bool message, bool allowDead)
- {
- if (this.m_DesignContext != null || (target is PlayerMobile && ((PlayerMobile)target).m_DesignContext != null))
- return false;
- return base.CanBeBeneficial(target, message, allowDead);
- }
- public override bool CheckContextMenuDisplay(IEntity target)
- {
- return (this.m_DesignContext == null);
- }
- public override void OnItemAdded(Item item)
- {
- base.OnItemAdded(item);
- if (item is BaseArmor || item is BaseWeapon)
- {
- this.Hits = this.Hits;
- this.Stam = this.Stam;
- this.Mana = this.Mana;
- }
- if (this.NetState != null)
- this.CheckLightLevels(false);
- this.InvalidateMyRunUO();
- }
- public override void OnItemRemoved(Item item)
- {
- base.OnItemRemoved(item);
- if (item is BaseArmor || item is BaseWeapon)
- {
- this.Hits = this.Hits;
- this.Stam = this.Stam;
- this.Mana = this.Mana;
- }
- if (this.NetState != null)
- this.CheckLightLevels(false);
- this.InvalidateMyRunUO();
- }
- public override double ArmorRating
- {
- get
- {
- //BaseArmor ar;
- double rating = 0.0;
- this.AddArmorRating(ref rating, this.NeckArmor);
- this.AddArmorRating(ref rating, this.HandArmor);
- this.AddArmorRating(ref rating, this.HeadArmor);
- this.AddArmorRating(ref rating, this.ArmsArmor);
- this.AddArmorRating(ref rating, this.LegsArmor);
- this.AddArmorRating(ref rating, this.ChestArmor);
- this.AddArmorRating(ref rating, this.ShieldArmor);
- return this.VirtualArmor + this.VirtualArmorMod + rating;
- }
- }
- private void AddArmorRating(ref double rating, Item armor)
- {
- BaseArmor ar = armor as BaseArmor;
- if (ar != null && (!Core.AOS || ar.ArmorAttributes.MageArmor == 0))
- rating += ar.ArmorRatingScaled;
- }
- #region [Stats]Max
- [CommandProperty(AccessLevel.GameMaster)]
- public override int HitsMax
- {
- get
- {
- int strBase;
- int strOffs = this.GetStatOffset(StatType.Str);
- if (Core.AOS)
- {
- strBase = this.Str; //this.Str already includes GetStatOffset/str
- strOffs = AosAttributes.GetValue(this, AosAttribute.BonusHits);
- if (Core.ML && strOffs > 25 && this.IsPlayer())
- strOffs = 25;
- if (AnimalForm.UnderTransformation(this, typeof(BakeKitsune)) || AnimalForm.UnderTransformation(this, typeof(GreyWolf)))
- strOffs += 20;
- }
- else
- {
- strBase = this.RawStr;
- }
- return (strBase / 2) + 50 + strOffs;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public override int StamMax
- {
- get
- {
- return base.StamMax + AosAttributes.GetValue(this, AosAttribute.BonusStam);
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public override int ManaMax
- {
- get
- {
- return base.ManaMax + AosAttributes.GetValue(this, AosAttribute.BonusMana) + ((Core.ML && this.Race == Race.Elf) ? 20 : 0);
- }
- }
- #endregion
- #region Stat Getters/Setters
- [CommandProperty(AccessLevel.GameMaster)]
- public override int Str
- {
- get
- {
- if (Core.ML && this.IsPlayer())
- return Math.Min(base.Str, 150);
- return base.Str;
- }
- set
- {
- base.Str = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public override int Int
- {
- get
- {
- if (Core.ML && this.IsPlayer())
- return Math.Min(base.Int, 150);
- return base.Int;
- }
- set
- {
- base.Int = value;
- }
- }
- [CommandProperty(AccessLevel.GameMaster)]
- public override int Dex
- {
- get
- {
- if (Core.ML && this.IsPlayer())
- return Math.Min(base.Dex, 150);
- return base.Dex;
- }
- set
- {
- base.Dex = value;
- }
- }
- #endregion
- public override bool Move(Direction d)
- {
- NetState ns = this.NetState;
- if (ns != null)
- {
- if (this.HasGump(typeof(ResurrectGump)))
- {
- if (this.Alive)
- {
- this.CloseGump(typeof(ResurrectGump));
- }
- else
- {
- this.SendLocalizedMessage(500111); // You are frozen and cannot move.
- return false;
- }
- }
- }
- TimeSpan speed = this.ComputeMovementSpeed(d);
- bool res;
- if (!this.Alive)
- Server.Movement.MovementImpl.IgnoreMovableImpassables = true;
- res = base.Move(d);
- Server.Movement.MovementImpl.IgnoreMovableImpassables = false;
- if (!res)
- return false;
- this.m_NextMovementTime += speed;
- return true;
- }
- public override bool CheckMovement(Direction d, out int newZ)
- {
- DesignContext context = this.m_DesignContext;
- if (context == null)
- return base.CheckMovement(d, out newZ);
- HouseFoundation foundation = context.Foundation;
- newZ = foundation.Z + HouseFoundation.GetLevelZ(context.Level, context.Foundation);
- int newX = this.X, newY = this.Y;
- Movement.Movement.Offset(d, ref newX, ref newY);
- int startX = foundation.X + foundation.Components.Min.X + 1;
- int startY = foundation.Y + foundation.Components.Min.Y + 1;
- int endX = startX + foundation.Components.Width - 1;
- int endY = startY + foundation.Components.Height - 2;
- return (newX >= startX && newY >= startY && newX < endX && newY < endY && this.Map == foundation.Map);
- }
- public override bool AllowItemUse(Item item)
- {
- #region Dueling
- if (this.m_DuelContext != null && !this.m_DuelContext.AllowItemUse(this, item))
- return false;
- #endregion
- return DesignContext.Check(this);
- }
- public SkillName[] AnimalFormRestrictedSkills
- {
- get
- {
- return this.m_AnimalFormRestrictedSkills;
- }
- }
- private SkillName[] m_AnimalFormRestrictedSkills = new SkillName[]
- {
- SkillName.ArmsLore, SkillName.Begging, SkillName.Discordance, SkillName.Forensics,
- SkillName.Inscribe, SkillName.ItemID, SkillName.Meditation, SkillName.Peacemaking,
- SkillName.Provocation, SkillName.RemoveTrap, SkillName.SpiritSpeak, SkillName.Stealing,
- SkillName.TasteID
- };
- public override bool AllowSkillUse(SkillName skill)
- {
- if (AnimalForm.UnderTransformation(this))
- {
- for (int i = 0; i < this.m_AnimalFormRestrictedSkills.Length; i++)
- {
- if (this.m_AnimalFormRestrictedSkills[i] == skill)
- {
- #region Mondain's Legacy
- AnimalFormContext context = AnimalForm.GetContext(this);
- if (skill == SkillName.Stealing && context.StealingMod.Value > 0)
- continue;
- #endregion
- this.SendLocalizedMessage(1070771); // You cannot use that skill in this form.
- return false;
- }
- }
- }
- #region Dueling
- if (this.m_DuelContext != null && !this.m_DuelContext.AllowSkillUse(this, skill))
- return false;
- #endregion
- return DesignContext.Check(this);
- }
- private bool m_LastProtectedMessage;
- private int m_NextProtectionCheck = 10;
- public virtual void RecheckTownProtection()
- {
- this.m_NextProtectionCheck = 10;
- Regions.GuardedRegion reg = (Regions.GuardedRegion)this.Region.GetRegion(typeof(Regions.GuardedRegion));
- bool isProtected = (reg != null && !reg.IsDisabled());
- if (isProtected != this.m_LastProtectedMessage)
- {
- if (isProtected)
- this.SendLocalizedMessage(500112); // You are now under the protection of the town guards.
- else
- this.SendLocalizedMessage(500113); // You have left the protection of the town guards.
- this.m_LastProtectedMessage = isProtected;
- }
- }
- public override void MoveToWorld(Point3D loc, Map map)
- {
- base.MoveToWorld(loc, map);
- this.RecheckTownProtection();
- }
- public override void SetLocation(Point3D loc, bool isTeleport)
- {
- if (!isTeleport && this.IsPlayer())
- {
- // moving, not teleporting
- int zDrop = (this.Location.Z - loc.Z);
- if (zDrop > 20) // we fell more than one story
- this.Hits -= ((zDrop / 20) * 10) - 5; // deal some damage; does not kill, disrupt, etc
- }
- base.SetLocation(loc, isTeleport);
- if (isTeleport || --this.m_NextProtectionCheck == 0)
- this.RecheckTownProtection();
- }
- public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
- {
- base.GetContextMenuEntries(from, list);
- if (from == this)
- {
- if (this.m_Quest != null)
- this.m_Quest.GetContextMenuEntries(list);
- if (this.Alive && InsuranceEnabled)
- {
- list.Add(new CallbackEntry(6201, new ContextCallback(ToggleItemInsurance)));
- if (this.AutoRenewInsurance)
- list.Add(new CallbackEntry(6202, new ContextCallback(CancelRenewInventoryInsurance)));
- else
- list.Add(new CallbackEntry(6200, new ContextCallback(AutoRenewInventoryInsurance)));
- }
- BaseHouse house = BaseHouse.FindHouseAt(this);
- if (house != null)
- {
- if (this.Alive && house.InternalizedVendors.Count > 0 && house.IsOwner(this))
- list.Add(new CallbackEntry(6204, new ContextCallback(GetVendor)));
- if (house.IsAosRules && !this.Region.IsPartOf(typeof(Engines.ConPVP.SafeZone))) // Dueling
- list.Add(new CallbackEntry(6207, new ContextCallback(LeaveHouse)));
- }
- if (this.m_JusticeProtectors.Count > 0)
- list.Add(new CallbackEntry(6157, new ContextCallback(CancelProtection)));
- if (this.Alive)
- list.Add(new CallbackEntry(6210, new ContextCallback(ToggleChampionTitleDisplay)));
- #region Mondain's Legacy
- if (this.Alive)
- {
- QuestHelper.GetContextMenuEntries(list);
- if (this.m_CollectionTitles.Count > 0)
- list.Add(new CallbackEntry(6229, new ContextCallback(ShowChangeTitle)));
- }
- #endregion
- }
- if (from != this)
- {
- if (this.Alive && Core.Expansion >= Expansion.AOS)
- {
- Party theirParty = from.Party as Party;
- Party ourParty = this.Party as Party;
- if (theirParty == null && ourParty == null)
- {
- list.Add(new AddToPartyEntry(from, this));
- }
- else if (theirParty != null && theirParty.Leader == from)
- {
- if (ourParty == null)
- {
- list.Add(new AddToPartyEntry(from, this));
- }
- else if (ourParty == theirParty)
- {
- list.Add(new RemoveFromPartyEntry(from, this));
- }
- }
- }
- BaseHouse curhouse = BaseHouse.FindHouseAt(this);
- if (curhouse != null)
- {
- if (this.Alive && Core.Expansion >= Expansion.AOS && curhouse.IsAosRules && curhouse.IsFriend(from))
- list.Add(new EjectPlayerEntry(from, this));
- }
- }
- }
- private void CancelProtection()
- {
- for (int i = 0; i < this.m_JusticeProtectors.Count; ++i)
- {
- Mobile prot = this.m_JusticeProtectors[i];
- string args = String.Format("{0}\t{1}", this.Name, prot.Name);
- prot.SendLocalizedMessage(1049371, args); // The protective relationship between ~1_PLAYER1~ and ~2_PLAYER2~ has been ended.
- this.SendLocalizedMessage(1049371, args); // The protective relationship between ~1_PLAYER1~ and ~2_PLAYER2~ has been ended.
- }
- this.m_JusticeProtectors.Clear();
- }
- #region Insurance
- private void ToggleItemInsurance()
- {
- if (!this.CheckAlive())
- return;
- this.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(ToggleItemInsurance_Callback));
- this.SendLocalizedMessage(1060868); // Target the item you wish to toggle insurance status on <ESC> to cancel
- }
- private bool CanInsure(Item item)
- {
- #region Mondain's Legacy
- if (item is BaseQuiver && item.LootType == LootType.Regular)
- return true;
- #endregion
- if (((item is Container) && !(item is BaseQuiver)) || item is BagOfSending || item is KeyRing)
- return false;
- if ((item is Spellbook && item.LootType == LootType.Blessed) || item is Runebook || item is PotionKeg || item is Sigil)
- return false;
- if (item.Stackable)
- return false;
- if (item.LootType == LootType.Cursed)
- return false;
- if (item.ItemID == 0x204E) // death shroud
- return false;
- return true;
- }
- private void ToggleItemInsurance_Callback(Mobile from, object obj)
- {
- if (!this.CheckAlive())
- return;
- Item item = obj as Item;
- if (item == null || !item.IsChildOf(this))
- {
- this.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(ToggleItemInsurance_Callback));
- this.SendLocalizedMessage(1060871, "", 0x23); // You can only insure items that you have equipped or that are in your backpack
- }
- else if (item.Insured)
- {
- item.Insured = false;
- this.SendLocalizedMessage(1060874, "", 0x35); // You cancel the insurance on the item
- this.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(ToggleItemInsurance_Callback));
- this.SendLocalizedMessage(1060868, "", 0x23); // Target the item you wish to toggle insurance status on <ESC> to cancel
- }
- else if (!this.CanInsure(item))
- {
- this.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(ToggleItemInsurance_Callback));
- this.SendLocalizedMessage(1060869, "", 0x23); // You cannot insure th…