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 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); }