public static void RemoveEffects(Mobile m) { if (m_Table.ContainsKey(m)) { ConsecratedWeaponContext context = m_Table[m]; context.Expire(); m_Table.Remove(m); } }
public override void OnCast() { BaseWeapon weapon = this.Caster.Weapon as BaseWeapon; if (weapon == null || weapon is Fists) { this.Caster.SendLocalizedMessage(501078); // You must be holding a weapon. } else if (this.CheckSequence()) { /* Temporarily enchants the weapon the caster is currently wielding. * The type of damage the weapon inflicts when hitting a target will * be converted to the target's worst Resistance type. * Duration of the effect is affected by the caster's Karma and lasts for 3 to 11 seconds. */ int itemID, soundID; switch (weapon.Skill) { case SkillName.Macing: itemID = 0xFB4; soundID = 0x232; break; case SkillName.Archery: itemID = 0x13B1; soundID = 0x145; break; default: itemID = 0xF5F; soundID = 0x56; break; } this.Caster.PlaySound(0x20C); this.Caster.PlaySound(soundID); this.Caster.FixedParticles(0x3779, 1, 30, 9964, 3, 3, EffectLayer.Waist); IEntity from = new Entity(Serial.Zero, new Point3D(this.Caster.X, this.Caster.Y, this.Caster.Z), this.Caster.Map); IEntity to = new Entity(Serial.Zero, new Point3D(this.Caster.X, this.Caster.Y, this.Caster.Z + 50), this.Caster.Map); Effects.SendMovingParticles(from, to, itemID, 1, 0, false, false, 33, 3, 9501, 1, 0, EffectLayer.Head, 0x100); double seconds = this.ComputePowerValue(20); // TODO: Should caps be applied? int pkarma = this.Caster.Karma; if (pkarma > 5000) { seconds = 11.0; } else if (pkarma >= 4999) { seconds = 10.0; } else if (pkarma >= 3999) { seconds = 9.00; } else if (pkarma >= 2999) { seconds = 8.0; } else if (pkarma >= 1999) { seconds = 7.0; } else if (pkarma >= 999) { seconds = 6.0; } else { seconds = 5.0; } TimeSpan duration = TimeSpan.FromSeconds(seconds); ConsecratedWeaponContext context; if (IsUnderEffects(Caster)) { context = m_Table[Caster]; if (context.Timer != null) { context.Timer.Stop(); context.Timer = null; } context.Weapon = weapon; } else { context = new ConsecratedWeaponContext(Caster, weapon); } weapon.ConsecratedContext = context; context.Timer = Timer.DelayCall <Mobile>(duration, RemoveEffects, Caster); m_Table[Caster] = context; BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.ConsecrateWeapon, 1151385, 1151386, duration, Caster, String.Format("{0}\t{1}", context.ConsecrateProcChance, context.ConsecrateDamageBonus))); } this.FinishSequence(); }