public override double GetControlChance(Mobile m, bool useBaseSkill) { if (PetTrainingHelper.Enabled) { var profile = PetTrainingHelper.GetAbilityProfile(this); if (profile != null && profile.HasCustomized()) { return(base.GetControlChance(m, useBaseSkill)); } } return(1.0); }
public void AddToPlan(object tp, int value, int cost) { PlanningEntry entry = null; for (var index = 0; index < Entries.Count; index++) { var e = Entries[index]; if (e.TrainPoint == tp) { entry = e; break; } } if (entry != null) { Entries.Remove(entry); } Entries.Add(new PlanningEntry(tp, value, cost)); if (tp is MagicalAbility ability && ability <= MagicalAbility.WrestlingMastery) { TrainingPoint trainingPoint = PetTrainingHelper.GetTrainingPoint(ability); for (var index = 0; index < Entries.Count; index++) { PlanningEntry en = Entries[index]; if (trainingPoint.Requirements != null && trainingPoint.Requirements.Length > 0) { for (var i = 0; i < trainingPoint.Requirements.Length; i++) { TrainingPointRequirement req = trainingPoint.Requirements[i]; if (req != null && (req.Requirement is WeaponAbility && en.TrainPoint is WeaponAbility || req.Requirement is SpecialAbility && en.TrainPoint is SpecialAbility || req.Requirement is AreaEffect && en.TrainPoint is AreaEffect)) { en.Value = 0; en.Cost = 0; } } } } } }
public virtual bool Validate(BaseCreature attacker, Mobile defender) { if (RequiredSchool != MagicalAbility.None) { var profile = PetTrainingHelper.GetAbilityProfile(attacker); if (profile == null || !profile.HasAbility(RequiredSchool)) { return(false); } } return(defender != null && defender.Alive && !defender.Deleted && !defender.IsDeadBondedPet && attacker.Alive && !attacker.IsDeadBondedPet && defender.InRange(attacker.Location, MaxRange) && defender.Map == attacker.Map && attacker.InLOS(defender) && !attacker.BardPacified); }
public override bool OnMoveOver(Mobile m) { if (m is BaseCreature bc) { TrainingProfile profile = PetTrainingHelper.GetTrainingProfile(bc); if (bc.Controlled && bc.ControlMaster != null && bc.ControlMaster.InRange(bc.Location, 25) && !bc.IsBonded) { bc.IsBonded = true; bc.FixedEffect(0x375A, 10, 30); } } return(true); }
public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) { return; } if (Registry.ContainsKey(attacker)) { if (m_Registry[attacker] != null) { m_Registry[attacker].Stop(); } Registry.Remove(attacker); } bool creature = attacker is BaseCreature; ClearCurrentAbility(attacker); attacker.SendLocalizedMessage(1063360); // You baffle your target with a feint! defender.SendLocalizedMessage(1063361); // You were deceived by an attacker's feint! attacker.FixedParticles(0x3728, 1, 13, 0x7F3, 0x962, 0, EffectLayer.Waist); attacker.PlaySound(0x525); double skill = creature ? attacker.Skills[SkillName.Bushido].Value : Math.Max(attacker.Skills[SkillName.Ninjitsu].Value, attacker.Skills[SkillName.Bushido].Value); int bonus = (int)(20.0 + 3.0 * (skill - 50.0) / 7.0); FeintTimer t = new FeintTimer(attacker, defender, bonus); //20-50 % decrease t.Start(); m_Registry[attacker] = t; string args = String.Format("{0}\t{1}", defender.Name, bonus); BuffInfo.AddBuff(attacker, new BuffInfo(BuffIcon.Feint, 1151308, 1151307, TimeSpan.FromSeconds(6), attacker, args)); if (creature) { PetTrainingHelper.OnWeaponAbilityUsed((BaseCreature)attacker, SkillName.Bushido); } }
public override void DoEffects(BaseCreature creature, Mobile defender, ref int damage) { IPooledEnumerable eable = creature.GetMobilesInRange(3); List <Mobile> list = new List <Mobile>(); list.Add(defender); foreach (Mobile m in eable) { if (AreaEffect.ValidTarget(creature, m)) { list.Add(m); } } eable.Free(); Poison p = creature.GetHitPoison(); if (p == null) { return; } foreach (var m in list) { defender.PlaySound(0xDD); defender.FixedParticles(0x3728, 244, 25, 9941, 1266, 0, EffectLayer.Waist); m.SendLocalizedMessage(1008097, false, creature.Name); // : poisoned you! m.ApplyPoison(creature, p); } if (creature.Controlled && list.Count > 0) { var profile = PetTrainingHelper.GetAbilityProfile(creature); if ((profile != null && profile.HasAbility(MagicalAbility.Poisoning)) || 0.2 > Utility.RandomDouble()) { creature.CheckSkill(SkillName.Poisoning, 0, creature.Skills[SkillName.Poisoning].Cap); } } ColUtility.Free(list); }
public static bool CheckThinkTrigger(BaseCreature bc) { var combatant = bc.Combatant; var profile = PetTrainingHelper.GetAbilityProfile(bc); if (combatant is Mobile) { if (profile != null) { SpecialAbility ability = null; var abilties = profile.EnumerateSpecialAbilities().Where(m => m.TriggerOnThink && !m.IsInCooldown(bc)).ToArray(); if (abilties != null && abilties.Length > 0) { ability = abilties[Utility.Random(abilties.Length)]; } if (ability != null) { int d = 0; ability.Trigger(bc, (Mobile)combatant, ref d); } } } else { SpecialAbility ability = null; var abilties = profile.EnumerateSpecialAbilities().Where(m => m.TriggerOnThink && !m.IsInCooldown(bc) && !m.RequiresCombatant).ToArray(); if (abilties != null && abilties.Length > 0) { ability = abilties[Utility.Random(abilties.Length)]; } if (ability != null) { int d = 0; return(ability.Trigger(bc, bc, ref d)); } } return(false); }
public void OnAddAbility(object newAbility, bool advancement) { if (advancement) { AddPetAdvancement(newAbility); } if (newAbility is MagicalAbility ability) { AddMagicalAbility(ability); } TrainingPoint trainPoint = PetTrainingHelper.GetTrainingPoint(newAbility); if (trainPoint != null && trainPoint.Requirements != null) { for (var index = 0; index < trainPoint.Requirements.Length; index++) { TrainingPointRequirement req = trainPoint.Requirements[index]; if (req != null) { if (req.Requirement is SkillName name) { double skill = Creature.Skills[name].Base; double toAdd = req.Cost == 100 ? 20 : 40; if (name == SkillName.Hiding) { toAdd = 100; } if (skill < toAdd) { Creature.Skills[name].Base = toAdd; } } else if (req.Requirement is WeaponAbility requirement) { AddAbility(requirement); } } } } }
public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!this.Validate(attacker) || !this.CheckMana(attacker, true)) { return; } ClearCurrentAbility(attacker); bool immune = Server.Items.ParalyzingBlow.IsImmune(defender); bool doEffects = false; AOS.Damage(defender, attacker, (int)(15.0 * (attacker.Skills[SkillName.Bushido].Value - 50.0) / 70.0 + Utility.Random(10)), true, 100, 0, 0, 0, 0); //0-25 if (!immune && ((150.0 / 7.0 + (4.0 * attacker.Skills[SkillName.Bushido].Value) / 7.0) / 100.0) > Utility.RandomDouble()) { defender.Paralyze(TimeSpan.FromSeconds(2.0)); doEffects = true; } if (attacker is BaseCreature) { PetTrainingHelper.OnWeaponAbilityUsed((BaseCreature)attacker, SkillName.Bushido); } if (!immune) { attacker.SendLocalizedMessage(1063356); // You cripple your target with a nerve strike! defender.SendLocalizedMessage(1063357); // Your attacker dealt a crippling nerve strike! } else { attacker.SendLocalizedMessage(1070804); // Your target resists paralysis. defender.SendLocalizedMessage(1070813); // You resist paralysis. } if (doEffects) { attacker.PlaySound(0x204); defender.FixedEffect(0x376A, 9, 32); defender.FixedParticles(0x37C4, 1, 8, 0x13AF, 0, 0, EffectLayer.Waist); } Server.Items.ParalyzingBlow.BeginImmunity(defender, Server.Items.ParalyzingBlow.FreezeDelayDuration); }
public IEnumerable <AreaEffect> EnumerateAreaEffects() { if (AreaEffects == null) { yield break; } var profile = PetTrainingHelper.GetAbilityProfile(Creature); if (profile == null) { yield break; } foreach (var ability in AreaEffects) { yield return(ability); } }
public IEnumerable <SpecialAbility> EnumerateSpecialAbilities() { if (SpecialAbilities == null) { yield break; } var profile = PetTrainingHelper.GetAbilityProfile(Creature); if (profile == null) { yield break; } foreach (var ability in SpecialAbilities) { yield return(ability); } }
public void OnAddAbility(object newAbility, bool advancement) { if (advancement) { AddPetAdvancement(newAbility); } if (newAbility is MagicalAbility) { AddMagicalAbility((MagicalAbility)newAbility); } var trainPoint = PetTrainingHelper.GetTrainingPoint(newAbility); if (trainPoint != null && trainPoint.Requirements != null) { foreach (var req in trainPoint.Requirements.Where(r => r != null)) { if (req.Requirement is SkillName) { double skill = Creature.Skills[(SkillName)req.Requirement].Base; double toAdd = req.Cost == 100 ? 20 : 40; if ((SkillName)req.Requirement == SkillName.Hiding) { toAdd = 100; } if (skill < toAdd) { Creature.Skills[(SkillName)req.Requirement].Base = toAdd; } } else if (req.Requirement is WeaponAbility) { AddAbility((WeaponAbility)req.Requirement); } } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); if (version < 1 && PetTrainingHelper.Enabled && ControlSlots <= 3) { var profile = PetTrainingHelper.GetAbilityProfile(this); if (profile == null || !profile.HasCustomized()) { MinTameSkill = 98.7; ControlSlotsMin = 1; ControlSlots = 1; } if ((ControlMaster != null || IsStabled) && Int < 500) { SetInt(500); } } }
public override int LabelNumber => 1075084; // This statuette will be destroyed when its trapped creature is summoned. The creature will be bonded to you but will disappear if released. <br><br>Do you wish to proceed? public override void Confirm(Mobile from) { if (m_Item == null || m_Item.Deleted) { return; } BaseCreature m = null; if (m_Item is ICreatureStatuette) { m = Activator.CreateInstance(((ICreatureStatuette)m_Item).CreatureType) as BaseCreature; } if (m != null) { if ((from.Followers + m.ControlSlots) > from.FollowersMax) { m.Delete(); from.SendLocalizedMessage(1114321); // You have too many followers to control that pet. } else { m.SetControlMaster(from); m.IsBonded = true; m.MoveToWorld(from.Location, from.Map); m_Item.Delete(); PetTrainingHelper.GetAbilityProfile(m, true).OnTame(); Timer.DelayCall(TimeSpan.FromSeconds(1), () => { m.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502799, from.NetState); // It seems to accept you as master. from.SendLocalizedMessage(1049666); // Your pet has bonded with you! }); } } }
public override int LabelNumber => 1075084; // This statuette will be destroyed when its trapped creature is summoned. The creature will be bonded to you but will disappear if released. <br><br>Do you wish to proceed? public override void Confirm(Mobile from) { if (m_Item == null || m_Item.Deleted) { return; } BaseCreature summon = m_Item.Summon; if (summon != null) { if (!summon.SetControlMaster(from)) { summon.Delete(); } else { summon.MoveToWorld(from.Location, from.Map); summon.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502799, from.NetState); // It seems to accept you as master. summon.IsBonded = true; from.SendLocalizedMessage(1049666); // Your pet has bonded with you! summon.Skills.Wrestling.Base = 100; summon.Skills.Tactics.Base = 100; summon.Skills.MagicResist.Base = 100; summon.Skills.Anatomy.Base = 100; PetTrainingHelper.GetAbilityProfile(summon, true).OnTame(); Effects.PlaySound(summon.Location, summon.Map, summon.BaseSoundID); Effects.SendLocationParticles(EffectItem.Create(summon.Location, summon.Map, EffectItem.DefaultDuration), 0x3728, 1, 10, 0x26B6); m_Item.Release(from, summon); m_Item.Delete(); } } }
public static bool CheckThinkTrigger(BaseCreature bc) { var profile = PetTrainingHelper.GetAbilityProfile(bc); if (profile != null) { AreaEffect effect = null; var effects = profile.GetAreaEffects().Where(a => !a.IsInCooldown(bc)).ToArray(); if (effects != null && effects.Length > 0) { effect = effects[Utility.Random(effects.Length)]; } if (effect != null) { return(effect.Trigger(bc, bc.Combatant as Mobile)); } } return(false); }
public static bool CheckThinkTrigger(BaseCreature bc) { AbilityProfile profile = PetTrainingHelper.GetAbilityProfile(bc); if (profile != null) { AreaEffect effect = null; List <AreaEffect> list = new List <AreaEffect>(); var af = profile.GetAreaEffects(); for (var index = 0; index < af.Length; index++) { var a = af[index]; if (!a.IsInCooldown(bc)) { list.Add(a); } } AreaEffect[] effects = list.ToArray(); if (effects.Length > 0) { effect = effects[Utility.Random(effects.Length)]; } if (effect != null) { return(effect.Trigger(bc, bc.Combatant as Mobile)); } } return(false); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); if (version < 2 && Controlled && RawStr >= 300 && ControlSlots == ControlSlotsMin) { Server.SkillHandlers.AnimalTaming.ScaleStats(this, 0.5); } if (PetTrainingHelper.Enabled && version == 2) { if (version < 1 && PetTrainingHelper.Enabled && ControlSlots <= 3) { var profile = PetTrainingHelper.GetAbilityProfile(this); if (profile == null || !profile.HasCustomized()) { MinTameSkill = 98.7; ControlSlotsMin = 1; ControlSlots = 1; } if ((ControlMaster != null || IsStabled) && Int < 500) { SetInt(500); } } } if (version == 0) { Hue = 0x489; } }
protected override void OnTick() { m_Count++; DamageEntry de = m_Creature.FindMostRecentDamageEntry(false); bool alreadyOwned = m_Creature.Owners.Contains(m_Tamer); if (!m_Tamer.InRange(m_Creature, Core.AOS ? 7 : 6)) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = Core.TickCount; m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502795, m_Tamer.NetState); // You are too far away to continue taming. Stop(); } else if (!m_Tamer.CheckAlive()) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = Core.TickCount; m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502796, m_Tamer.NetState); // You are dead, and cannot continue taming. Stop(); } else if (!m_Tamer.CanSee(m_Creature) || !m_Tamer.InLOS(m_Creature) || !CanPath()) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = Core.TickCount; m_Tamer.SendLocalizedMessage(1049654); // You do not have a clear path to the animal you are taming, and must cease your attempt. Stop(); } else if (!m_Creature.Tamable) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = Core.TickCount; m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049655, m_Tamer.NetState); // That creature cannot be tamed. Stop(); } else if (m_Creature.Controlled) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = Core.TickCount; m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502804, m_Tamer.NetState); // That animal looks tame already. Stop(); } else if (m_Creature.Owners.Count >= BaseCreature.MaxOwners && !m_Creature.Owners.Contains(m_Tamer)) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = Core.TickCount; m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1005615, m_Tamer.NetState); // This animal has had too many owners and is too upset for you to tame. Stop(); } else if (MustBeSubdued(m_Creature)) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = Core.TickCount; m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1054025, m_Tamer.NetState); // You must subdue this creature before you can tame it! Stop(); } else if (de != null && de.LastDamage > m_StartTime) { m_BeingTamed.Remove(m_Creature); m_Tamer.NextSkillTime = Core.TickCount; m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502794, m_Tamer.NetState); // The animal is too angry to continue taming. Stop(); } else if (m_Count < m_MaxCount) { m_Tamer.RevealingAction(); switch (Utility.Random(3)) { case 0: m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(502790, 4)); break; case 1: m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1005608, 6)); break; case 2: m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1010593, 4)); break; } if (!alreadyOwned) // Passively check animal lore for gain { m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0); } if (m_Creature.Paralyzed) { m_Paralyzed = true; } } else { m_Tamer.RevealingAction(); m_Tamer.NextSkillTime = Core.TickCount; m_BeingTamed.Remove(m_Creature); if (m_Creature.Paralyzed) { m_Paralyzed = true; } if (!alreadyOwned) // Passively check animal lore for gain { m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0); } double minSkill = m_Creature.CurrentTameSkill + (m_Creature.Owners.Count * 6.0); if (minSkill > -24.9 && CheckMastery(m_Tamer, m_Creature)) { minSkill = -24.9; // 50% at 0.0? } minSkill += 24.9; if (CheckMastery(m_Tamer, m_Creature) || alreadyOwned || m_Tamer.CheckTargetSkill(SkillName.AnimalTaming, m_Creature, minSkill - 25.0, minSkill + 25.0)) { if (m_Creature.Owners.Count == 0) // First tame { if (m_Creature is GreaterDragon) { ScaleSkills(m_Creature, 0.72, 0.90); // 72% of original skills trainable to 90% m_Creature.Skills[SkillName.Magery].Base = m_Creature.Skills[SkillName.Magery].Cap; // Greater dragons have a 90% cap reduction and 90% skill reduction on magery } else if (m_Paralyzed) { ScaleSkills(m_Creature, 0.86); // 86% of original skills if they were paralyzed during the taming } else { ScaleSkills(m_Creature, 0.90); // 90% of original skills } } else { ScaleSkills(m_Creature, 0.90); // 90% of original skills } if (alreadyOwned) { m_Tamer.SendLocalizedMessage(502797); // That wasn't even challenging. } else { m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502799, m_Tamer.NetState); // It seems to accept you as master. } m_Creature.SetControlMaster(m_Tamer); m_Creature.IsBonded = false; m_Creature.OnAfterTame(m_Tamer); if (!m_Creature.Owners.Contains(m_Tamer)) { m_Creature.Owners.Add(m_Tamer); } PetTrainingHelper.GetAbilityProfile(m_Creature, true).OnTame(); } else { m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502798, m_Tamer.NetState); // You fail to tame the creature. } } }
public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker)) //Mana check after check that there are targets { return; } ClearCurrentAbility(attacker); Map map = attacker.Map; if (map == null) { return; } BaseWeapon weapon = attacker.Weapon as BaseWeapon; if (weapon == null) { return; } List <Mobile> targets = new List <Mobile>(); targets.Add(defender); IPooledEnumerable eable = attacker.GetMobilesInRange(2); foreach (Mobile m in eable) { if (m != attacker && SpellHelper.ValidIndirectTarget(attacker, m)) { if (m == null || m.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.CanSee(m) || !attacker.CanBeHarmful(m) || !attacker.InLOS(m)) { continue; } if (m is PlayerMobile) { BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.SplinteringEffect, 1153804, 1028852, TimeSpan.FromSeconds(2.0), m)); } targets.Add(m); } } eable.Free(); if (targets.Count > 0) { if (!CheckMana(attacker, true)) { return; } attacker.FixedEffect(0x3728, 10, 15); attacker.PlaySound(0x2A1); if (m_Registry.ContainsKey(attacker)) { RemoveFromRegistry(attacker); } m_Registry[attacker] = new InternalTimer(attacker, targets); if (defender is PlayerMobile && attacker is PlayerMobile) { defender.SendSpeedControl(SpeedControlType.WalkSpeed); BuffInfo.AddBuff(defender, new BuffInfo(BuffIcon.SplinteringEffect, 1153804, 1152144, TimeSpan.FromSeconds(2.0), defender)); Timer.DelayCall <Mobile>(TimeSpan.FromSeconds(2), mob => mob.SendSpeedControl(SpeedControlType.Disable), defender); } if (attacker is BaseCreature) { PetTrainingHelper.OnWeaponAbilityUsed((BaseCreature)attacker, SkillName.Ninjitsu); } } }
public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker)) //Mana check after check that there are targets { return; } ClearCurrentAbility(attacker); Map map = attacker.Map; if (map == null) { return; } BaseWeapon weapon = attacker.Weapon as BaseWeapon; if (weapon == null) { return; } List <Mobile> targets = new List <Mobile>(); foreach (IDamageable target in SpellHelper.AcquireIndirectTargets(attacker, attacker.Location, attacker.Map, 2)) { if (target is Mobile mobile) { targets.Add(mobile); } } if (targets.Count > 0) { if (!CheckMana(attacker, true)) { return; } attacker.FixedEffect(0x3728, 10, 15); attacker.PlaySound(0x2A1); if (m_Registry.ContainsKey(attacker)) { RemoveFromRegistry(attacker); } m_Registry[attacker] = new InternalTimer(attacker, targets); for (var index = 0; index < targets.Count; index++) { Mobile target = targets[index]; if (target is PlayerMobile pm) { BuffInfo.AddBuff(pm, new BuffInfo(BuffIcon.SplinteringEffect, 1153804, 1028852, TimeSpan.FromSeconds(2.0), pm)); } } if (defender is PlayerMobile && attacker is PlayerMobile) { defender.SendSpeedControl(SpeedControlType.WalkSpeed); BuffInfo.AddBuff(defender, new BuffInfo(BuffIcon.SplinteringEffect, 1153804, 1152144, TimeSpan.FromSeconds(2.0), defender)); Timer.DelayCall(TimeSpan.FromSeconds(2), mob => mob.SendSpeedControl(SpeedControlType.Disable), defender); } if (attacker is BaseCreature bc) { PetTrainingHelper.OnWeaponAbilityUsed(bc, SkillName.Ninjitsu); } } }
public static bool CheckCombatTrigger(Mobile attacker, Mobile defender, ref int damage, DamageType type) { if (defender == null) { return(false); } if (attacker is BaseCreature && !((BaseCreature)attacker).Summoned) { var bc = attacker as BaseCreature; var profile = PetTrainingHelper.GetAbilityProfile(bc); if (profile != null) { SpecialAbility ability = null; var abilties = profile.EnumerateSpecialAbilities().Where(m => (type == DamageType.Melee && m.TriggerOnDoMeleeDamage) || (type >= DamageType.Spell && m.TriggerOnDoSpellDamage) && !m.IsInCooldown(attacker)).ToArray(); if (abilties != null && abilties.Length > 0) { ability = abilties[Utility.Random(abilties.Length)]; } if (ability != null) { return(ability.Trigger(bc, defender, ref damage)); } } return(false); } if (defender is BaseCreature && !((BaseCreature)defender).Summoned) { var bc = defender as BaseCreature; var profile = PetTrainingHelper.GetAbilityProfile(bc); if (profile != null) { SpecialAbility ability = null; var abilties = profile.EnumerateSpecialAbilities().Where(m => (type == DamageType.Melee && m.TriggerOnGotMeleeDamage) || (type >= DamageType.Spell && m.TriggerOnGotSpellDamage) && !m.IsInCooldown(attacker)).ToArray(); if (abilties != null && abilties.Length > 0) { ability = abilties[Utility.Random(abilties.Length)]; } if (ability != null) { int d = 0; return(ability.Trigger(bc, attacker, ref d)); } } } return(false); }
public override bool OnBeforeSwing(Mobile attacker, Mobile defender) { if (!Validate(attacker) || !CheckMana(attacker, false)) { return(false); } int ran = -1; if (attacker is BaseCreature && PetTrainingHelper.CheckSecondarySkill((BaseCreature)attacker, SkillName.Bushido)) { ran = Utility.Random(9); } else { bool canfeint = attacker.Skills[WeaponAbility.Feint.GetSecondarySkill(attacker)].Value >= WeaponAbility.Feint.GetRequiredSecondarySkill(attacker); bool canblock = attacker.Skills[WeaponAbility.Block.GetSecondarySkill(attacker)].Value >= WeaponAbility.Block.GetRequiredSecondarySkill(attacker); if (canfeint && canblock) { ran = Utility.Random(9); } else if (canblock) { ran = Utility.Random(8); } else { ran = Utility.RandomList(0, 1, 2, 3, 4, 5, 6, 8); } } switch (ran) { case 0: m_NewAttack[attacker] = new BladeWeaveRedirect(WeaponAbility.ArmorIgnore, 1028838); break; case 1: m_NewAttack[attacker] = new BladeWeaveRedirect(WeaponAbility.BleedAttack, 1028839); break; case 2: m_NewAttack[attacker] = new BladeWeaveRedirect(WeaponAbility.ConcussionBlow, 1028840); break; case 3: m_NewAttack[attacker] = new BladeWeaveRedirect(WeaponAbility.CrushingBlow, 1028841); break; case 4: m_NewAttack[attacker] = new BladeWeaveRedirect(WeaponAbility.DoubleStrike, 1028844); break; case 5: m_NewAttack[attacker] = new BladeWeaveRedirect(WeaponAbility.MortalStrike, 1028846); break; case 6: m_NewAttack[attacker] = new BladeWeaveRedirect(WeaponAbility.ParalyzingBlow, 1028848); break; case 7: m_NewAttack[attacker] = new BladeWeaveRedirect(WeaponAbility.Block, 1028853); break; case 8: m_NewAttack[attacker] = new BladeWeaveRedirect(WeaponAbility.Feint, 1028857); break; default: // should never happen return(false); } return(m_NewAttack[attacker].NewAbility.OnBeforeSwing(attacker, defender)); }