protected override void OnTick() { Mobile from = m_Item.Parent as Mobile; if (from == null) { Stop(); return; } if (m_Item.SpellCharges <= 0) { Stop(); m_Item.m_Timer = null; m_Item.SpellEffect = SpellEffect.None; return; } if (from.Player && from.Map == Map.Internal) { return; } if (SpellCastEffect.InvokeEffect(m_Item.SpellEffect, from, from)) { m_Item.SpellCharges--; if (m_Item.SpellCharges <= 0) { Stop(); m_Item.m_Timer = null; m_Item.SpellEffect = SpellEffect.None; from.SendAsciiMessage("This magic item is out of charges."); } } }
public virtual void OnTarget(Mobile from, object targeted) { if (SpellEffect == SpellEffect.None || SpellCharges <= 0) { return; } bool ok = false; if (targeted is Mobile) { ok = SpellCastEffect.InvokeEffect(SpellEffect, from, (Mobile)targeted); } else if (targeted is Item) { ok = SpellCastEffect.InvokeEffect(SpellEffect, from, (Item)targeted); } if (ok) { if (SpellEffect != SpellEffect.ItemID) { from.NextActionTime = DateTime.Now + TimeSpan.FromSeconds(1.5); } SpellCharges--; if (SpellCharges == 0) { from.SendAsciiMessage("This magic item is out of charges."); } } }
public virtual string BuildMagicSingleClick() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); if (AppendLootType(sb)) { sb.Append(", "); } if (m_Quality == CraftQuality.Exceptional) { sb.Append("exceptional, "); } if (sb.Length > 2) { sb.Remove(sb.Length - 2, 2); sb.Append(' '); } AppendClickName(sb); InsertNamePrefix(sb); if (IsMagic) { sb.AppendFormat(" of {0} with {1} charge{2}", SpellCastEffect.GetName(m_Effect), m_EffectCharges, m_EffectCharges != 1 ? "s" : ""); } if (m_Crafter != null && !m_Crafter.Deleted) { sb.AppendFormat(" (crafted by {0})", m_Crafter.Name); } return(sb.ToString()); }
public static void MutateLoot(int maxInt, BaseWeapon weapon) { double dr = Utility.RandomDouble() * 100.0; if (dr < 2 && maxInt >= 80) { weapon.SpellEffect = SpellEffect.Lightning; } else if (dr < 8 && maxInt >= 80) { weapon.SpellEffect = SpellEffect.ManaDrain; } else if (dr < 13 && maxInt >= 60) { weapon.SpellEffect = SpellEffect.Curse; } else if (dr < 18 && maxInt >= 60) { weapon.SpellEffect = SpellEffect.Fireball; } else if (dr < 28 && maxInt >= 40) { weapon.SpellEffect = SpellEffect.Paralyze; } else if (dr < 38 && maxInt >= 40) { weapon.SpellEffect = SpellEffect.Harm; } else if (dr < 48 && maxInt >= 20) { weapon.SpellEffect = SpellEffect.Weaken; } else if (dr < 58 && maxInt >= 20) { weapon.SpellEffect = SpellEffect.MagicArrow; } else if (dr < 68) { weapon.SpellEffect = SpellEffect.Feeblemind; } else //if ( dr < 78 ) { weapon.SpellEffect = SpellEffect.Clumsy; } if (weapon.SpellEffect != SpellEffect.None) { weapon.SpellCharges = SpellCastEffect.GetChargesFor(weapon.SpellEffect); } }
public static void MutateLoot(int maxInt, MagicWand wand) { double dr = Utility.RandomDouble() * 100.0; if (dr < 2 && maxInt >= 80) { wand.SpellEffect = SpellEffect.ManaDrain; } else if (dr < 8 && maxInt >= 80) { wand.SpellEffect = SpellEffect.Lightning; } else if (dr < 13 && maxInt >= 60) { wand.SpellEffect = SpellEffect.Fireball; } else if (dr < 18 && maxInt >= 60) { wand.SpellEffect = SpellEffect.GHeal; } else if (dr < 28 && maxInt >= 40) { wand.SpellEffect = SpellEffect.Harm; } else if (dr < 38 && maxInt >= 40) { wand.SpellEffect = SpellEffect.MagicArrow; } else if (dr < 48 && maxInt >= 20) { wand.SpellEffect = SpellEffect.Feeblemind; } else if (dr < 58 && maxInt >= 20) { wand.SpellEffect = SpellEffect.Clumsy; } else if (dr < 68 && maxInt >= 20) { wand.SpellEffect = SpellEffect.MiniHeal; } else { wand.SpellEffect = SpellEffect.ItemID; } if (wand.SpellEffect != SpellEffect.None) { wand.SpellCharges = SpellCastEffect.GetChargesFor(wand.SpellEffect); } }
public override void OnDoubleClick(Mobile from) { if (from.Alive && !from.Deleted && m_Effect != SpellEffect.None && m_EffectCharges > 0) { if (!SpellCastEffect.IsRepeatingEffect(m_Effect) && SpellCastEffect.InvokeEffect(m_Effect, from, from)) { SpellCharges--; if (SpellCharges <= 0) { m_Effect = SpellEffect.None; from.SendAsciiMessage("This magic item is out of charges."); } } } base.OnDoubleClick(from); }
public override bool OnEquip(Mobile from) { if (base.OnEquip(from)) { if (SpellEffectOnEquip && from.Alive && !from.Deleted && m_Effect != SpellEffect.None && m_EffectCharges > 0) { if (SpellCastEffect.InvokeEffect(m_Effect, from, from)) { SpellCharges--; if (SpellCharges <= 0) { if (m_Timer != null) { m_Timer.Stop(); m_Timer = null; } m_Effect = SpellEffect.None; from.SendAsciiMessage("This magic item is out of charges."); } } if (SpellCharges > 0 && SpellCastEffect.IsRepeatingEffect(m_Effect)) { if (m_Timer == null) { m_Timer = new CheckTimer(this); } if (!m_Timer.Running) { m_Timer.Start(); } } } return(true); } else { return(false); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 5: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.SpellEffect)) { m_Identified = reader.ReadBool(); m_Effect = (SpellEffect)reader.ReadEncodedInt(); m_EffectCharges = reader.ReadEncodedInt(); } else { m_Identified = false; m_Effect = SpellEffect.None; m_EffectCharges = 0; } if (GetSaveFlag(flags, SaveFlag.Resource)) { m_Resource = (CraftResource)reader.ReadEncodedInt(); } else { m_Resource = DefaultResource; } if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes = new AosAttributes(this, reader); } else { m_AosAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) { m_AosClothingAttributes = new AosArmorAttributes(this, reader); } else { m_AosClothingAttributes = new AosArmorAttributes(this); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses = new AosSkillBonuses(this, reader); } else { m_AosSkillBonuses = new AosSkillBonuses(this); } if (GetSaveFlag(flags, SaveFlag.Resistances)) { m_AosResistances = new AosElementAttributes(this, reader); } else { m_AosResistances = new AosElementAttributes(this); } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { m_MaxHitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { m_HitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (ClothingQuality)reader.ReadEncodedInt(); } else { m_Quality = ClothingQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.StrReq)) { m_StrReq = reader.ReadEncodedInt(); } else { m_StrReq = -1; } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = true; } break; } case 4: { m_Resource = (CraftResource)reader.ReadInt(); goto case 3; } case 3: { m_AosAttributes = new AosAttributes(this, reader); m_AosClothingAttributes = new AosArmorAttributes(this, reader); m_AosSkillBonuses = new AosSkillBonuses(this, reader); m_AosResistances = new AosElementAttributes(this, reader); goto case 2; } case 2: { m_PlayerConstructed = reader.ReadBool(); goto case 1; } case 1: { m_Crafter = reader.ReadMobile(); m_Quality = (ClothingQuality)reader.ReadInt(); break; } case 0: { m_Crafter = null; m_Quality = ClothingQuality.Regular; break; } } if (version < 2) { m_PlayerConstructed = true; // we don't know, so, assume it's crafted } if (version < 3) { m_AosAttributes = new AosAttributes(this); m_AosClothingAttributes = new AosArmorAttributes(this); m_AosSkillBonuses = new AosSkillBonuses(this); m_AosResistances = new AosElementAttributes(this); } if (version < 4) { m_Resource = DefaultResource; } if (m_MaxHitPoints == 0 && m_HitPoints == 0) { m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); } Mobile parent = Parent as Mobile; if (parent != null) { if (Core.AOS) { m_AosSkillBonuses.AddTo(parent); } AddStatBonuses(parent); parent.CheckStatTimers(); if (m_Effect != SpellEffect.None && m_EffectCharges > 0 && SpellCastEffect.IsRepeatingEffect(m_Effect)) { m_Timer = new CheckTimer(this); m_Timer.Start(); } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 4: { m_Identified = reader.ReadMobileList(); goto case 3; } case 3: { m_Effect = (SpellEffect)reader.ReadInt(); m_EffectCharges = reader.ReadInt(); if (version < 4) { /*m_Identified = */ reader.ReadBool(); } goto case 2; } case 2: { m_PlayerConstructed = reader.ReadBool(); goto case 1; } case 1: { m_Crafter = reader.ReadMobile(); m_Quality = (CraftQuality)reader.ReadInt(); break; } case 0: { m_Crafter = null; m_Quality = CraftQuality.Regular; break; } } if (version < 2) { m_PlayerConstructed = false; } if (Parent is Mobile && m_Effect != SpellEffect.None && m_EffectCharges > 0 && SpellCastEffect.IsRepeatingEffect(m_Effect)) { m_Timer = new CheckTimer(this); m_Timer.Start(); } }
public static void MutateLoot(int maxInt, BaseClothing clothes) { double dr = Utility.RandomDouble() * 100.0; if (dr < 2 && maxInt >= 90) { clothes.SpellEffect = SpellEffect.Reflect; } else if (dr < 3 && maxInt >= 90) { clothes.SpellEffect = SpellEffect.Invis; } else if (dr < 8 && maxInt >= 80) { clothes.SpellEffect = SpellEffect.Curse; } else if (dr < 13 && maxInt >= 80) { clothes.SpellEffect = SpellEffect.Bless; } else if (dr < 28 && maxInt >= 60) { clothes.SpellEffect = SpellEffect.Weaken; } else if (dr < 38 && maxInt >= 60) { clothes.SpellEffect = SpellEffect.Clumsy; } else if (dr < 48 && maxInt >= 60) { clothes.SpellEffect = SpellEffect.Feeblemind; } else if (dr < 58 && maxInt >= 20) { clothes.SpellEffect = SpellEffect.Strength; } else if (dr < 68 && maxInt >= 20) { clothes.SpellEffect = SpellEffect.Cunning; } else if (dr < 78 && maxInt >= 20) { clothes.SpellEffect = SpellEffect.Agility; } else if (dr < 88) { clothes.SpellEffect = SpellEffect.Protection; } else { clothes.SpellEffect = SpellEffect.NightSight; } if (clothes is GoldRing && dr < 2 && maxInt >= 99) { if (Utility.RandomBool()) { clothes.SpellEffect = SpellEffect.Teleportation; } else { clothes.SpellEffect = SpellEffect.Invis; } } if (clothes.SpellEffect != SpellEffect.None) { clothes.SpellCharges = SpellCastEffect.GetChargesFor(clothes.SpellEffect); } }