/// <summary> /// <para>Casts the PETACTIONNAME on WOWUNIT.</para> /// <para>Notes:<list type="bullet"> /// <item><description><para>* The PETACTIONNAME spell must be hot-barred! Existence in the spellbook /// is insufficient. This is a limitation of the WoWclient and HB APIs.</para></description></item> /// <item><description><para>* If PETACTIONNAME doesn't exist, or is not hot-barred /// an error message is emitted. To avoid this, use CanCastPetAction() as an entry condition to use of this method.</para></description></item> /// <item><description><para>* If PETACTIONNAME is on cooldown, no action is performed.</para></description></item> /// </list></para> /// </summary> /// <param name="petActionName">may not be null. Examples include: "Follow", "Attack", "Passive", "Growl".</param> /// <param name="wowUnit">may not be null</param> // 24Feb2013-07:42UTC chinajade public static void CastPetAction(WoWPetSpell petAction, WoWUnit wowUnit = null) { if (petAction != null) { var petActionName = GetPetActionName(petAction); if (wowUnit == null) { QBCLog.DeveloperInfo("Instructing pet to \"{0}\".", petActionName); Lua.DoString("CastPetAction({0})", petAction.ActionBarIndex + 1); } else if (wowUnit.IsValid) { QBCLog.DeveloperInfo("Instructing pet \"{0}\" on {1}.", petActionName, wowUnit.SafeName); var originalFocus = Me.FocusedUnitGuid; StyxWoW.Me.SetFocus(wowUnit); Lua.DoString("CastPetAction({0}, 'focus')", petAction.ActionBarIndex + 1); StyxWoW.Me.SetFocus(originalFocus); } else { QBCLog.DeveloperInfo("Attempt to instruct pet to \"{0}\" failed--WoWUnit is not valid.", petActionName); } } }
private static void SetStance_Internal(WoWPetSpell petStance) { if (!IsPetActionActive(petStance) && CanCastPetAction(petStance)) { CastPetAction(petStance); } }
public static bool CanCastPetAction(string action) { if (StyxWoW.Me.Level < 10) { return(false); } WoWPetSpell petAction = PetSpells.FirstOrDefault(p => p.ToString() == action); if (petAction == null) { return(false); } if (petAction.Cooldown) { return(false); } if (petAction.Spell != null) { return(petAction.Spell.CanCast); } return(Lua.GetReturnVal <bool>(string.Format("return GetPetActionSlotUsable({0})", petAction.ActionBarIndex + 1), 0)); }
public static bool CanWeCheckAutoCastForAnyOfThese(params string[] spells) { if (!StyxWoW.Me.GotAlivePet) { return(false); } if (spells == null || !spells.Any()) { return(false); } if (StyxWoW.Me.PetSpells == null) { return(false); } HashSet <string> taunt = new HashSet <string>(spells); WoWPetSpell ps = StyxWoW.Me.PetSpells.FirstOrDefault(s => s.Spell != null && taunt.Contains(s.Spell.Name)); if (ps == null) { return(false); } bool allowed; bool active = PetManager.IsAutoCast(ps, out allowed); if (!allowed) { return(false); } return(true); }
/// <summary> /// <para>Returns true if the pet is executing the PETACTIONNAME.</para> /// <para>The way the WoWclient works, because a PetAction is active doesn't necessarily mean it is being immediately obeyed.</para> /// <para>For instance, a pet's "Passive" ability may be active, but the pet may be attacking due to an explicit "Attack" command temporarily overriding it.</para> /// <para>During the attack, the "Passive" ability still shows active.</para> /// <para>Notes:<list type="bullet"> /// <item><description><para>* The PETACTIONNAME spell must be hot-barred! Existence in the spellbook /// is insufficient. This is a limitation of the WoWclient and HB APIs.</para></description></item> /// <item><description><para>* If PETACTIONNAME doesn't exist, or is not hot-barred, 'false' is returned.</para></description></item> /// </list></para> /// </summary> /// <param name="petAction">may not be null. Examples include: "Follow", "Attack", "Passive"</param> /// <returns></returns> // 24Feb2013-07:42UTC chinajade public static bool IsPetActionActive(WoWPetSpell petAction) { if (petAction == null) { return(false); } return(Lua.GetReturnVal <bool>(string.Format("return GetPetActionInfo({0})", petAction.ActionBarIndex + 1), 4)); }
/// <summary>Returns true if the pet spell can be cast</summary> /// <param name="name">the name of the spell to check</param> /// <returns>The can cast pet spell.</returns> public static bool CanCastPetSpell(string name) { WoWPetSpell petAction = Me.PetSpells.FirstOrDefault(p => p.ToString() == name); if (petAction == null || petAction.Spell == null) { return(false); } return(!petAction.Spell.Cooldown); }
/// <summary> /// Check to see if our pet has a spell /// </summary> /// <param name="name">the spell name in english to check for</param> /// <returns>true if the pet has the spell</returns> public static bool HasSpellPet(string name) { WoWPetSpell petAction = Me.PetSpells.FirstOrDefault(p => p.ToString() == name); if (petAction == null || petAction.Spell == null) { CLULogger.TroubleshootLog(String.Format("[PetManager] Pet does not have the spell {0}", name)); return(false); } return(true); }
/// <summary> /// <para>Instructs the user's pet to follow its owner.</para> /// <para>Notes:<list type="bullet"> /// <item><description><para>* This behavior performs all appropriate checks: pet exists and is alive, etc.</para></description></item> /// <item><description><para>* If the pet is attacking a mob, the 'follow' command will continue to be issued until the pet obeys.</para></description></item> /// <item><description><para>* The pet's "Follow" command must be hot-barred! Existence in the spellbook /// is insufficient. This is a limitation of the WoWclient and HB APIs.</para></description></item> /// <item><description><para>* The returned Composite is suitable for use in a behavior tree (Priority)Selector container /// (i.e., placing it in a Sequence container will not yield the desired results).</para></description></item> /// </list></para> /// </summary> /// <returns>a behavior tree Composite suitable for use in a (Priority)Selector container</returns> public static void Follow() { WoWPetSpell followAction = s_petActionFollow ?? (s_petActionFollow = FindPetActionByName("Follow")); if (Me.GotAlivePet && (!IsPetActionActive(followAction) || Me.Pet.GotTarget) && CanCastPetAction(followAction)) { CastPetAction(followAction); } }
public static bool CanCastPetAction(string action) { WoWPetSpell petAction = Me.PetSpells.FirstOrDefault(p => p.ToString() == action); if (petAction == null || petAction.Spell == null) { return(false); } Logging.Write("Action Not on Cooldown"); return(!petAction.Spell.Cooldown); }
/// <summary> /// <para>Sends the user's pet to attack the target identified by WOWUNITDELEGATE.</para> /// <para>Notes:<list type="bullet"> /// <item><description><para>* This behavior performs all appropriate checks: pet exists and is alive, target is viable and not friendly, etc.</para></description></item> /// <item><description><para>* The 'attack' command will continue to be issued until the pet obeys (by targeting the mob).</para></description></item> /// <item><description><para>* The pet's "Attack" command must be hot-barred! Existence in the spellbook /// is insufficient. This is a limitation of the WoWclient and HB APIs.</para></description></item> /// <item><description><para>* The returned Composite is suitable for use in a behavior tree (Priority)Selector container /// (i.e., placing it in a Sequence container will not yield the desired results).</para></description></item> /// </list></para> /// </summary> /// <param name="wowUnit">may not be null</param> /// <returns>a behavior tree Composite suitable for use in a (Priority)Selector container</returns> public static void Attack(WoWUnit wowUnit) { WoWPetSpell attackAction = s_petActionAttack ?? (s_petActionAttack = FindPetActionByName("Attack")); if (Me.GotAlivePet && (Me.Pet.CurrentTarget != wowUnit) && Query.IsViableForFighting(wowUnit) && CanCastPetAction(attackAction)) { CastPetAction(attackAction, wowUnit); } }
public static void CastPetAction(string action) { WoWPetSpell spell = PetSpells.FirstOrDefault(p => p.ToString() == action); if (spell == null) { return; } Logger.Write(Color.DeepSkyBlue, "*Pet:{0}", action); Lua.DoString("CastPetAction({0})", spell.ActionBarIndex + 1); }
/*-------------------------------------------------------- * Spells *-------------------------------------------------------- */ /// <summary>Returns the Pet spell cooldown using Timespan (00:00:00.0000000) /// gtfo if the Pet dosn't have the spell.</summary> /// <param name="name">the name of the spell to check for</param> /// <returns>The spell cooldown.</returns> public static TimeSpan PetSpellCooldown(string name) { WoWPetSpell petAction = PetSpells.FirstOrDefault(p => p.ToString() == name); if (petAction == null || petAction.Spell == null) { return(TimeSpan.Zero); } CLULogger.DiagnosticLog(" [PetSpellCooldown] {0} : {1}", name, petAction.Spell.CooldownTimeLeft); return(petAction.Spell.CooldownTimeLeft); }
public static void CastPetAction(string action) { WoWPetSpell spell = PetSpells.FirstOrDefault(p => p.ToString() == action); if (spell == null) { return; } Logger.Write(string.Format("[Pet] Casting {0}", action)); Lua.DoString("CastPetAction({0})", spell.ActionBarIndex + 1); }
/// <summary> /// <para>Returns true if the pet is executing the PETACTIONNAME.</para> /// <para>The way the WoWclient works, because a PetAction is active doesn't necessarily mean it is being immediately obeyed.</para> /// <para>For instance, a pet's "Passive" ability may be active, but the pet may be attacking due to an explicit "Attack" command temporarily overriding it.</para> /// <para>During the attack, the "Passive" ability still shows active.</para> /// <para>Notes:<list type="bullet"> /// <item><description><para>* The PETACTIONNAME spell must be hot-barred! Existence in the spellbook /// is insufficient. This is a limitation of the WoWclient and HB APIs.</para></description></item> /// <item><description><para>* If PETACTIONNAME doesn't exist, or is not hot-barred, 'false' is returned.</para></description></item> /// </list></para> /// </summary> /// <param name="petActionName">may not be null. Examples include: "Follow", "Attack", "Passive"</param> /// <returns></returns> // 24Feb2013-07:42UTC chinajade public bool IsPetActionActive(string petActionName) { ContractRequires(!string.IsNullOrEmpty(petActionName), context => "petActionName may not be null or empty"); WoWPetSpell petAction = Me.PetSpells.FirstOrDefault(p => p.ToString() == petActionName); if (petAction == null) { return(false); } return(Lua.GetReturnVal <bool>(string.Format("return GetPetActionInfo({0})", petAction.ActionBarIndex + 1), 4)); }
private static bool HandleAutoCastForSpell(string spellName) { WoWPetSpell ps = StyxWoW.Me.PetSpells.FirstOrDefault(s => s.ToString() == spellName); // Disable pet growl in instances but enable it outside. if (ps == null) { Logger.WriteDebug("PetManager: '{0}' is NOT an ability known by this Pet", spellName); } else { bool allowed; bool active = PetManager.IsAutoCast(ps, out allowed); if (!allowed) { Logger.Write(LogColor.Hilite, "PetManager: '{0}' is NOT an auto-cast ability for this Pet", spellName); } else { if (SingularRoutine.CurrentWoWContext == WoWContext.Instances) { if (!active) { Logger.Write(LogColor.Hilite, "PetManager: '{0}' Auto-Cast Already Disabled", spellName); } else { Logger.Write(LogColor.Hilite, "PetManager: Disabling '{0}' Auto-Cast", spellName); Lua.DoString("DisableSpellAutocast(GetSpellInfo(" + ps.Spell.Id + "))"); } } else { if (active) { Logger.Write(LogColor.Hilite, "PetManager: '{0}' Auto-Cast Already Enabled", spellName); } else { Logger.Write(LogColor.Hilite, "PetManager: Enabling '{0}' Auto-Cast", spellName); Lua.DoString("EnableSpellAutocast(GetSpellInfo(" + ps.Spell.Id + "))"); } } return(true); } } return(false); }
public static void CastPetAction(string action, WoWUnit on) { WoWPetSpell spell = PetSpells.FirstOrDefault(p => p.ToString() == action); if (spell == null) { return; } Logger.Write(string.Format("[Pet] Casting {0} on {1}", action, on.SafeName())); StyxWoW.Me.SetFocus(on); Lua.DoString("CastPetAction({0}, 'focus')", spell.ActionBarIndex + 1); StyxWoW.Me.SetFocus(0); }
// 11Mar2013-04:41UTC chinajade protected WoWPetSpell FindVehicleAbility() { if (!Query.IsVehicleActionBarShowing()) { // assignment intentional, we want it to become null again when we exit vehicle... return(_vehicleAbility = null); } return (_vehicleAbility ?? (_vehicleAbility = Me.PetSpells .FirstOrDefault(petSpell => s_vehicleAbilityTypes.Contains(petSpell.SpellType) && ((petSpell.ActionBarIndex + 1) == AbilityIndex)))); }
/// <summary> /// <para>Casts the PETACTIONNAME.</para> /// <para>Notes:<list type="bullet"> /// <item><description><para>* The PETACTIONNAME spell must be hot-barred! Existence in the spellbook /// is insufficient. This is a limitation of the WoWclient and HB APIs.</para></description></item> /// <item><description><para>* If PETACTIONNAME doesn't exist, or is not hot-barred /// an error message is emitted. To avoid this, use CanCastPetAction() as an entry condition to use of this method.</para></description></item> /// <item><description><para>* If PETACTIONNAME is on cooldown, no action is performed.</para></description></item> /// </list></para> /// </summary> /// <param name="petActionName">may not be null. Examples include: "Follow", "Attack", "Passive", "Growl".</param> // 24Feb2013-07:42UTC chinajade public void CastPetAction(string petActionName) { ContractRequires(!string.IsNullOrEmpty(petActionName), context => "petActionName may not be null or empty"); WoWPetSpell petAction = Me.PetSpells.FirstOrDefault(p => p.ToString() == petActionName); if (petAction == null) { LogMaintenanceError("or [USER ERROR]: PetAction('{0}') is either not known, or not hot-barred.", petActionName); return; } LogDeveloperInfo("Instructing pet to \"{0}\"", petActionName); Lua.DoString("CastPetAction({0})", petAction.ActionBarIndex + 1); }
public static bool IsAutoCast(WoWPetSpell ps, out bool allowed) { allowed = false; if (ps != null) { // action bar index base 0 in HB but base 1 in LUA, so adjust List <string> svals = Lua.GetReturnValues("return GetPetActionInfo(" + (ps.ActionBarIndex + 1) + ");"); if (svals != null && svals.Count >= 7) { allowed = ("1" == svals[5]); bool active = ("1" == svals[6]); return(active); } } return(false); }
// 30Jun2013-07:42UTC chinajade public static string GetPetActionName(WoWPetSpell petAction) { if (petAction != null) { switch (petAction.SpellType) { case WoWPetSpell.PetSpellType.Action: return(petAction.Action.ToString()); case WoWPetSpell.PetSpellType.Spell: return(petAction.Spell.Name); case WoWPetSpell.PetSpellType.Stance: return(petAction.Stance.ToString()); } return("WoWPetSpell(UNKNOWN)"); } return("WoWPetSpell(NULL)"); }
/// <summary> /// <para>Returns true if you can cast the PETACTIONNAME; otherwise, false.</para> /// <para>This method checks for both spell existence, and if the spell is on cooldown.</para> /// <para>Notes:<list type="bullet"> /// /// <item><description><para>* To return 'true', the PETACTIONNAME spell must be hot-barred! Existence in the spellbook /// is insufficient. This is a limitation of the WoWclient and HB APIs.</para></description></item> /// </list></para> /// </summary> /// <param name="petActionName">may not be null. Examples include: "Follow", "Attack", "Passive", "Growl".</param> /// <returns></returns> // 24Feb2013-07:42UTC chinajade public bool CanCastPetAction(string petActionName) { ContractRequires(!string.IsNullOrEmpty(petActionName), context => "petActionName may not be null or empty"); WoWPetSpell petAction = Me.PetSpells.FirstOrDefault(p => p.ToString() == petActionName); if (petAction == null) { return(false); } if ((petAction.SpellType == WoWPetSpell.PetSpellType.Spell) && (petAction.Spell == null)) { return(false); } return((petAction.SpellType == WoWPetSpell.PetSpellType.Spell) ? !petAction.Spell.Cooldown : true); }
/// <summary> /// <para>Returns true if you can cast the PETACTIONNAME; otherwise, false.</para> /// <para>This method checks for both spell existence, and if the spell is on cooldown.</para> /// <para>Notes:<list type="bullet"> /// /// <item><description><para>* To return 'true', the PETACTIONNAME spell must be hot-barred! Existence in the spellbook /// is insufficient. This is a limitation of the WoWclient and HB APIs.</para></description></item> /// </list></para> /// </summary> /// <param name="petActionName">may not be null. Examples include: "Follow", "Attack", "Passive", "Growl".</param> /// <returns></returns> // 24Feb2013-07:42UTC chinajade public static bool CanCastPetAction(WoWPetSpell petAction) { if (petAction == null) { return(false); } if ((petAction.SpellType == WoWPetSpell.PetSpellType.Spell) && (petAction.Spell == null)) { return(false); } // NB: We can't issue pet directives while mounted, so don't try... if (Me.Mounted) { return(false); } return((petAction.SpellType == WoWPetSpell.PetSpellType.Spell) ? !petAction.Spell.Cooldown : true); }
/// <summary> /// <para>Casts the PETACTIONNAME on WOWUNIT.</para> /// <para>Notes:<list type="bullet"> /// <item><description><para>* The PETACTIONNAME spell must be hot-barred! Existence in the spellbook /// is insufficient. This is a limitation of the WoWclient and HB APIs.</para></description></item> /// <item><description><para>* If PETACTIONNAME doesn't exist, or is not hot-barred /// an error message is emitted. To avoid this, use CanCastPetAction() as an entry condition to use of this method.</para></description></item> /// <item><description><para>* If PETACTIONNAME is on cooldown, no action is performed.</para></description></item> /// </list></para> /// </summary> /// <param name="petActionName">may not be null. Examples include: "Follow", "Attack", "Passive", "Growl".</param> /// <param name="wowUnit">may not be null</param> // 24Feb2013-07:42UTC chinajade public void CastPetAction(string petActionName, WoWUnit wowUnit) { ContractRequires(!string.IsNullOrEmpty(petActionName), context => "petActionName may not be null or empty"); ContractRequires(wowUnit != null, context => "wowUnit may not be null"); WoWPetSpell petAction = Me.PetSpells.FirstOrDefault(p => p.ToString() == petActionName); if (petAction == null) { LogMaintenanceError("or [USER ERROR]: PetAction('{0}') is either not known, or not hot-barred.", petActionName); return; } LogDeveloperInfo("Instructing pet \"{0}\" on {1}", petActionName, wowUnit.Name); uint originalFocus = Me.CurrentFocus; StyxWoW.Me.SetFocus(wowUnit); Lua.DoString("CastPetAction({0}, 'focus')", petAction.ActionBarIndex + 1); StyxWoW.Me.SetFocus(originalFocus); }
public static bool OnPetCooldown(string spellname) { string fnname = "FTWCore.OnPetCooldown"; MyTimer.Start(fnname); bool retval = false; WoWPetSpell spell = null; foreach (WoWPetSpell sp in StyxWoW.Me.PetSpells) { if (sp.Spell != null && sp.Spell.Name == spellname) { spell = sp; break; } } if (spell == null) { retval = false; } else if (spell.Cooldown) { retval = true; } else if (!FTWProps.spellWasLastCast.ContainsKey(spellname)) { retval = false; } else { int elapsedtime = (DateTime.Now - FTWProps.spellWasLastCast[spellname]).Seconds; if (FTWProps.fakePetCooldownTimes.ContainsKey(spellname) && (elapsedtime < FTWProps.fakePetCooldownTimes[spellname])) { retval = true; } } MyTimer.Stop(fnname); return(retval); }
public static bool IsAnySpellOnPetToolbar(params string[] spells) { if (!StyxWoW.Me.GotAlivePet) { return(false); } if (spells == null || !spells.Any()) { return(false); } if (StyxWoW.Me.PetSpells == null) { return(false); } HashSet <string> taunt = new HashSet <string>(spells); WoWPetSpell ps = StyxWoW.Me.PetSpells.FirstOrDefault(s => s.Spell != null && taunt.Contains(s.Spell.Name)); return(ps != null); }
// 9Mar2013-07:55UTC chinajade public static string ToString_FullInfo(this WoWPetSpell wowPetSpell, bool useCompactForm = false, int indentLevel = 0) { StringBuilder tmp = new StringBuilder(); if (wowPetSpell != null) { var indent = string.Empty.PadLeft(indentLevel); var fieldSeparator = useCompactForm ? " " : string.Format("\n {0}", indent); tmp.AppendFormat("<WoWPetSpell Key_ActionBarIndex=\"{0}\"", wowPetSpell.ActionBarIndex); tmp.AppendFormat("{0}Action=\"{1}\"", fieldSeparator, wowPetSpell.Action); tmp.AppendFormat("{0}Cooldown=\"{1}\"", fieldSeparator, wowPetSpell.Cooldown); tmp.AppendFormat("{0}Spell=\"{1}\"", fieldSeparator, (wowPetSpell.Spell == null) ? "NONE" : ToString_FullInfo(wowPetSpell.Spell, useCompactForm, indentLevel + 4)); tmp.AppendFormat("{0}SpellType=\"{1}\"", fieldSeparator, wowPetSpell.SpellType); tmp.AppendFormat("{0}Stance=\"{1}\"", fieldSeparator, wowPetSpell.Stance); tmp.AppendFormat("{0}/>", fieldSeparator); } return(tmp.ToString()); }
public static void CastPetAction(string action, WoWUnit on) { // target is currenttarget, then use simplified version (to avoid setfocus/setfocus if (on == StyxWoW.Me.CurrentTarget) { CastPetAction(action); return; } WoWPetSpell spell = PetSpells.FirstOrDefault(p => p.ToString() == action); if (spell == null) { return; } Logging.Write(string.Format("[Pet] Casting {0} on {1}", action, on.SafeName())); //Logger.Write(string.Format("[Pet] Casting {0} on {1}", action, on.SafeName())); WoWUnit save = StyxWoW.Me.FocusedUnit; StyxWoW.Me.SetFocus(on); Lua.DoString("CastPetAction({0}, 'focus')", spell.ActionBarIndex + 1); StyxWoW.Me.SetFocus(save == null ? 0 : save.Guid); }
public static void CastPetAction(string action, WoWUnit on) { WoWPetSpell spell = PetSpells.FirstOrDefault(p => p.ToString() == action); if (spell == null) { return; } Logger.Write(Color.DeepSkyBlue, "*Pet:{0} on {1} @ {2:F1} yds", action, on.SafeName(), on.SpellDistance()); if (on.Guid == StyxWoW.Me.CurrentTargetGuid) { Logger.WriteDebug("CastPetAction: cast [{0}] specifying CurrentTarget", action); Lua.DoString("CastPetAction({0}, 'target')", spell.ActionBarIndex + 1); } else { WoWUnit save = StyxWoW.Me.FocusedUnit; StyxWoW.Me.SetFocus(on); Logger.WriteDebug("CastPetAction: cast [{0}] specifying FocusTarget {1}", action, on.SafeName()); Lua.DoString("CastPetAction({0}, 'focus')", spell.ActionBarIndex + 1); StyxWoW.Me.SetFocus(save == null ? WoWGuid.Empty : save.Guid); } }
/// <summary> The vehicle as a wowunit </summary> public static void CastPetAction(WoWPetSpell spell) { Lua.DoString("CastPetAction({0})", spell.ActionBarIndex + 1); }
public static bool IsAutoCast(WoWPetSpell ps, out bool allowed) { allowed = false; if (ps != null) { // action bar index base 0 in HB but base 1 in LUA, so adjust List<string> svals = Lua.GetReturnValues("return GetPetActionInfo(" + (ps.ActionBarIndex+1) + ");"); if (svals != null && svals.Count >= 7) { allowed = ("1" == svals[5]); bool active = ("1" == svals[6]); return active; } } return false; }
public static bool IsAutoCast(string action, out bool allowed) { WoWPetSpell ps = StyxWoW.Me.PetSpells.FirstOrDefault(s => s.ToString() == action); return(IsAutoCast(ps, out allowed)); }
public static bool IsAutoCast(int id, out bool allowed) { WoWPetSpell ps = StyxWoW.Me.PetSpells.FirstOrDefault(s => s.Spell != null && s.Spell.Id == id); return(IsAutoCast(ps, out allowed)); }