private Composite CreateTradeSkillCast() { return(new PrioritySelector( new Decorator(ctx => _numOfCasts >= NumOfTimes, new Action(ctx => _isBehaviorDone = true)), new Decorator(ret => StyxWoW.Me.IsCasting, new ActionAlwaysSucceed()), new Sequence( // check we have the material to craft recipe new DecoratorContinue(ctx => GetMaxRepeat(_recipeSpell) == 0, new Action( ctx => { _isBehaviorDone = true; return RunStatus.Failure; })), new Action(ctx => _recipeSpell.Cast()), // check if we're casting on an item. new DecoratorContinue(ctx => CastOnItemId.HasValue, new Sequence(ctx => StyxWoW.Me.CarriedItems.FirstOrDefault(i => i.Entry == CastOnItemId.Value), new DecoratorContinue(ctx => ctx == null, new Action(ctx => QBCLog.Fatal("Could not find ItemId({0}).", CastOnItemId.Value))), new Action(ctx => ((WoWItem)ctx).Use()), new Sleep(Delay.BeforeButtonClick), // click the enchant confirmation botton. new Action(ctx => Lua.DoString("local _,frame = StaticPopup_Visible('REPLACE_ENCHANT') if frame then StaticPopup_OnClick(frame, 1) end")))), new WaitContinue(TimeSpan.FromMilliseconds(2000), ctx => StyxWoW.Me.IsCasting, new ActionAlwaysSucceed()), new Action(ctx => _numOfCasts++), // wait for cast to finish. new WaitContinue(TimeSpan.FromMilliseconds(6000), ctx => !StyxWoW.Me.IsCasting, new ActionAlwaysSucceed())))); }
public override void OnTick() { switch (CurrentState) { case FishingState.Lure: //if (!HasBait) //{ // // Implement applying lure //} CurrentState = FishingState.Cast; break; case FishingState.Cast: Print("Casting Fishing Pole"); Fishing.Cast(); CurrentState = FishingState.Fishing; Sleep(500); // Force a sleep for the cast break; case FishingState.Fishing: if (IsFishing) { if (IsBobbing) { CurrentState = FishingState.Loot; } } else { CurrentState = FishingState.Lure; } break; case FishingState.Loot: Print("Getting Fishing Bobber"); Bobber.Interact(); LootTimer = DateTime.Now; CurrentState = FishingState.Looting; break; case FishingState.Looting: var span = DateTime.Now - LootTimer; if (span.TotalSeconds > 3) { Print("No loot? Back to fishing then!"); CurrentState = FishingState.Lure; } break; case FishingState.Combat: if (Manager.LocalPlayer.IsDead) { OnTerminate(); } // Not much we can do but wait :( break; } Sleep(200); }
public static void CastOnItem(this WoWSpell spell, WoWItem item) { using (new FrameLock()) { spell.Cast(); Lua.DoString("UseContainerItem({0}, {1})", item.BagIndex + 1, item.BagSlot + 1); } }
public static void CastOnItem(this WoWSpell spell, WoWItem item) { using (StyxWoW.Memory.AcquireFrame()) { spell.Cast(); Lua.DoString("UseContainerItem({0}, {1})", item.BagIndex + 1, item.BagSlot + 1); } }
public static bool CallTotem(Totem totem) { WoWSpell spell = Manager.Spellbook[((uint)totem)]; if (spell.IsValid && spell.IsReady) { Log.WriteLine("Calling {0} totem", totem.ToString()); spell.Cast(); return(true); } return(false); }
public static bool CallTotems() { WoWSpell CotE = Manager.Spellbook["Call of the Elements"]; if (CotE.IsValid && CotE.IsReady) { Log.WriteLine("Call of the Elements"); CotE.Cast(); return(true); } return(false); }
public void ResurrectPets() { try { WoWSpell spell = WoWSpell.FromId(125439); if (spell != null && spell.CanCast) { Logger.Write("Casting 'Revive Battle Pets'..."); spell.Cast(); } } catch { } }
public static bool RecallTotems() { if (NeedToRecall) { WoWSpell tr = Manager.Spellbook["Totemic Recall"]; if (tr.IsValid && tr.IsReady) { Log.WriteLine("Recalling totems"); tr.Cast(); return(true); } } return(false); }
protected override void OnBeforeAction(RoutineAction action) { if (!_totemsSet) { SetTotems(); _totemsSet = true; } if (Helper.InCombat && Manager.LocalPlayer.Totems.Count() == 0) { if (TotemHelper.CallTotems()) { Sleep(600); } } // TODO: fix //var ft = Manager.Spellbook["Flametongue Weapon"]; //if (ft != null && ft.IsValid && ft.IsReady) // 5 appears to be flametongue weapon //{ // var mainhand = Manager.LocalPlayer.GetEquippedItem(EquipSlot.MainHand); // if (mainhand.IsValid && mainhand.Enchants.Count(x => x.Id == (uint)WeaponEnchantments.Flametongue) == 0) // { // Log.WriteLine("Applying Flametongue Weapon to Main Hand weapon"); // ft.Cast(); // Sleep(600); // } //} // Instant Lava Burst if (action is HarmfulSpellRoutine) { var haction = action as HarmfulSpellRoutine; if (haction.SpellName == "Lava Burst") { WoWSpell cd = Manager.Spellbook["Elemental Mastery"]; if (cd != null && cd.IsValid && cd.IsReady) { Log.WriteLine("Popping Elemental Mastery for instant Lava Burst"); cd.Cast(); Sleep(600); } } } }
private void btnSpellCast_Click(object sender, EventArgs e) { try { if (Manager.LocalPlayer.Class != WoWClass.Shaman) { return; } WoWSpell healingWave = Manager.Spellbook["Healing Wave"]; if (healingWave == null || !healingWave.IsValid) { return; } Manager.ExecutionQueue.AddExececution(() => { healingWave.Cast(); }); } catch { } }
public override void OnStart() { if (!ObjectManager.IsInGame) { return; } var spells = GeneralHelper.SpellManager.KnownSpells; Print("Number of known spells {0}", spells.Count); uint FrostboltID = 126201; WoWSpell tempSpell = GeneralHelper.SpellManager.GetWoWSpellFromId(FrostboltID); Print("Frostbolt local name: {0}", tempSpell.Name); uint sealID = 20154; WoWSpell tempSpell2 = GeneralHelper.SpellManager.GetWoWSpellFromId(sealID); tempSpell2.Cast(); Stop(); }
protected void CheckForAndApplyBuff(WoWUnit target, string name, bool sleep = true) { WoWAura buff = target.Auras[name]; if (buff != null && buff.IsValid) { return; } WoWSpell spell = Manager.Spellbook[name]; if (spell == null || !spell.IsValid) { return; } Print("Buffing {0} with {1}", target.Name, name); spell.Cast(target); if (sleep) { Sleep(1000); } }
private static void DisenchantItem() { List <WoWItem> targetItems = ObjectManager.Me.BagItems; for (int a = targetItems.Count - 1; a >= 0; a--) { if (ignoreItems.Contains(targetItems[a].Entry) || SkipDisenchant.Contains(targetItems[a])) { targetItems.RemoveAt(a); } else if (targetItems[a].IsSoulbound || targetItems[a].IsAccountBound || ignoreItems.Contains(targetItems[a].Entry) || targetItems[a].Quality != WoWItemQuality.Uncommon) // targetItems[a].Quality != WoWItemQuality.Common && // && item.ItemInfo.Level , required level { SkipDisenchant.Add(targetItems[a]); targetItems.RemoveAt(a); } } if (Equals(null, targetItems)) { return; } foreach (WoWItem deItem in targetItems) { if (deItem.BagSlot != -1) { Styx.Helpers.Logging.Write(Color.FromName("DarkRed"), "[LiquidDisenchant]: {0} (Entry:{1}).", deItem.Name, deItem.Entry); WoWSpell spell = WoWSpell.FromId(13262); // ANG using (new Styx.FrameLock()) { spell.Cast(); Lua.DoString("UseContainerItem({0}, {1})", deItem.BagIndex + 1, deItem.BagSlot + 1); } // Lua.DoString("CastSpellByName(\"Disenchant\")"); // Thread.Sleep(500); // Lua.DoString("UseItemByName(\"" + deItem.Name + "\")"); Thread.Sleep(300); while (ObjectManager.Me.IsCasting) { Thread.Sleep(3100); } Thread.Sleep(2500); // wait for lootframe to close Stopwatch timer = new Stopwatch(); timer.Start(); while (Styx.Logic.LootTargeting.LootFrameIsOpen) { Thread.Sleep(250); if (timer.ElapsedMilliseconds >= 6000) { break; } } if (!ObjectManager.Me.Combat) { Thread.Sleep(1500); SkipDisenchant.Add(deItem); } } } return; }
public static void DoDestroyJunk() { if (LastUpdate + 2000 < (uint)Environment.TickCount) { LastUpdate = (uint)Environment.TickCount; } else { return; } WoWSpell mount = null; uint FNBS = Me.FreeNormalBagSlots; // Logging.Write("SpellManager.HasSpell(61425):" + SpellManager.HasSpell(61425)); if (Mount.CanMount() && ((uint)Environment.TickCount - LastSellTry > 30000) && (FNBS <= 2)) { if (Me.Mounted) // optional { Mount.Dismount(); Thread.Sleep(4400); // Gnimo does not disappear instantly } // if () // Sell to mamoth { mount = WoWSpell.FromId(61425); mount.Cast(); Thread.Sleep(500); if (Me.IsCasting) { Thread.Sleep(2500); ObjectManager.Update(); } } LastSellTry = (uint)Environment.TickCount; if (Me.Mounted) { // todo: debug sell procedure IsDone = false; SellDone = false; while (!SellDone && ((uint)Environment.TickCount - LastSellTry < 8000)) { Logging.Write("attempting trade..." + (uint)Environment.TickCount); SellDone = InteractAndSell(32639, SellItemActionType.Whites, 0, 0); // SellItemActionType.Whites Thread.Sleep(1000); } } } else { List <WoWItem> targetItems = ObjectManager.Me.BagItems; uint TotalCount = 0; for (int a = targetItems.Count - 1; a >= 0; a--) { if (targetItems[a] != null && targetItems[a].IsValid) { ItemInfo info = ItemInfo.FromId(targetItems[a].Entry); WoWItemQuality quality = targetItems[a].Quality; if (!ProtectedItems.Contains(targetItems[a].Entry) && (quality == WoWItemQuality.Uncommon && (info.Level < 290) || quality == WoWItemQuality.Common || quality == WoWItemQuality.Poor)) { WoWMovement.MoveStop(); Logging.Write("[Allrounder] Destroying " + targetItems[a].Entry + " \"" + targetItems[a].Name + "\"..."); Lua.DoString("UseItemByName(\"" + targetItems[a].Name + "\")"); // Lua.DoString("UseContainerItem({0}, {1})", targetItems[a].BagIndex + 1, targetItems[a].BagSlot + 1); Lua.DoString("PickupContainerItem({0}, {1})", targetItems[a].BagIndex + 1, targetItems[a].BagSlot + 1); Thread.Sleep(900); Lua.DoString("DeleteCursorItem();"); } } } } }
protected async override Task Run() { if (Me.IsFlying && await CommonCoroutines.Dismount("Crafting an item")) { return; } if (!IsRecipe) { CheckTradeskillList(); } if (Casted >= CalculatedRepeat) { Finished(); return; } // can't make recipe so stop trying. if (IsRecipe && Recipe.CanRepeatNum2 <= 0) { Finished("Not enough material."); return; } if (Me.IsCasting && Me.CastingSpellId != Entry) { SpellManager.StopCasting(); } // we should confirm the last recipe in list so we don't make an axtra if (Casted + 1 < CalculatedRepeat || (Casted + 1 == CalculatedRepeat && (Confimed || !_spamControl.IsRunning || (_spamControl.ElapsedMilliseconds >= (_recastTime + (_recastTime / 2)) + _waitTime && !StyxWoW.Me.IsCasting)))) { if (!_spamControl.IsRunning || Me.IsCasting && Me.CurrentCastTimeLeft <= TimeSpan.FromMilliseconds(250) || (!StyxWoW.Me.IsCasting && _spamControl.ElapsedMilliseconds >= _waitTime)) { if (StyxWoW.Me.IsMoving) { WoWMovement.MoveStop(); } if (!QueueIsRunning) { Lua.Events.AttachEvent("UNIT_SPELLCAST_SUCCEEDED", OnUnitSpellCastSucceeded); QueueIsRunning = true; TreeRoot.StatusText = string.Format("Casting: {0}", IsRecipe ? Recipe.Name : Entry.ToString()); } WoWSpell spell = WoWSpell.FromId((int)Entry.Value); if (spell == null) { PBLog.Warn("{0}: {1}", Strings["Error_UnableToFindSpellWithEntry"], Entry.Value.ToString(CultureInfo.InvariantCulture)); return; } _recastTime = spell.CastTime; ProfessionbuddyBot.Debug("Casting {0}, recast :{1}", spell.Name, _recastTime); if (CastOnItem) { WoWItem item = TargetedItem; if (item != null) { spell.CastOnItem(item); } else { PBLog.Warn( "{0}: {1}", Strings["Error_UnableToFindItemToCastOn"], IsRecipe ? Recipe.Name : Entry.Value.ToString(CultureInfo.InvariantCulture)); IsDone = true; } } else { spell.Cast(); } _waitTime = Util.WowWorldLatency * 3 + 50; Confimed = false; _spamControl.Reset(); _spamControl.Start(); } } }
/// <summary> /// Safe spell casting. Wait for it to be done or if anything wrong happened return failed. /// </summary> /// <param name="spell"></param> /// <returns></returns> internal static async Task<ActionResult> CastSpell(WoWSpell spell) { if (Me.Mounted) { await CommonCoroutines.Dismount("Dismounting to cast " + spell.Name + "."); await CommonCoroutines.SleepForLagDuration(); } if (Me.IsMoving) { WoWMovement.MoveStop(); await CommonCoroutines.SleepForLagDuration(); } if (Me.IsCasting) { GarrisonButler.Diagnostic("Error casting {0}, already casting at the moment.", spell.Name); return ActionResult.Failed; } try { spell.Cast(); await CommonCoroutines.SleepForLagDuration(); var timeOutLimit = (int) spell.CastTime + 10000; if (!await Buddy.Coroutines.Coroutine.Wait(timeOutLimit, () => !Me.IsCasting)) { GarrisonButler.Diagnostic("Timed out while waiting for spell={0}, castTime={1}, timeOutLimit={2}.", spell.Name, spell.CastTime, timeOutLimit); return ActionResult.Failed; } await CommonCoroutines.SleepForLagDuration(); } catch (Exception e) { GarrisonButler.Diagnostic(e.ToString()); GarrisonButler.Log("Failed casting {0}.", spell.Name); return ActionResult.Failed; } GarrisonButler.Log("Successful cast of {0}.", spell.Name); return ActionResult.Done; }
protected override RunStatus Run(object context) { if (!IsDone) { if (!IsRecipe) { CheckTradeskillList(); } if (Casted >= CalculatedRepeat) { if (ObjectManager.Me.IsCasting && ObjectManager.Me.CastingSpell.Id == Entry) { SpellManager.StopCasting(); } _spamControl.Stop(); _spamControl.Reset(); Lua.Events.DetachEvent("UNIT_SPELLCAST_SUCCEEDED", OnUnitSpellCastSucceeded); IsDone = true; return(RunStatus.Failure); } // can't make recipe so stop trying. if (IsRecipe && Recipe.CanRepeatNum2 <= 0) { Professionbuddy.Debug("{0} doesn't have enough material to craft.", SpellName); IsDone = true; return(RunStatus.Failure); } if (Me.IsCasting && Me.CastingSpellId != Entry) { SpellManager.StopCasting(); } // we should confirm the last recipe in list so we don't make an axtra if (!Me.IsFlying && Casted + 1 < CalculatedRepeat || (Casted + 1 == CalculatedRepeat && (Confimed || !_spamControl.IsRunning || (_spamControl.ElapsedMilliseconds >= (_recastTime + (_recastTime / 2)) + _waitTime && !ObjectManager.Me.IsCasting)))) { if (!_spamControl.IsRunning || _spamControl.ElapsedMilliseconds >= _recastTime || (!ObjectManager.Me.IsCasting && _spamControl.ElapsedMilliseconds >= _waitTime)) { if (ObjectManager.Me.IsMoving) { WoWMovement.MoveStop(); } if (!QueueIsRunning) { Lua.Events.AttachEvent("UNIT_SPELLCAST_SUCCEEDED", OnUnitSpellCastSucceeded); QueueIsRunning = true; TreeRoot.StatusText = string.Format("Casting: {0}", IsRecipe ? Recipe.Name : Entry.ToString(CultureInfo.InvariantCulture)); } WoWSpell spell = WoWSpell.FromId((int)Entry); if (spell == null) { Professionbuddy.Err("{0}: {1}", Pb.Strings["Error_UnableToFindSpellWithEntry"], Entry); return(RunStatus.Failure); } _recastTime = spell.CastTime; Professionbuddy.Debug("Casting {0}, recast :{1}", spell.Name, _recastTime); if (CastOnItem) { WoWItem item = TargetedItem; if (item != null) { spell.CastOnItem(item); } else { Professionbuddy.Err("{0}: {1}", Pb.Strings["Error_UnableToFindItemToCastOn"], IsRecipe ? Recipe.Name : Entry.ToString(CultureInfo.InvariantCulture)); IsDone = true; } } else { spell.Cast(); } _waitTime = StyxWoW.WoWClient.Latency * 2; Confimed = false; _spamControl.Reset(); _spamControl.Start(); } } if (!IsDone) { return(RunStatus.Success); } } return(RunStatus.Failure); }
public override void OnTick() { if (!Manager.ObjectManager.IsInGame) { return; } if ((DateTime.Now - SleepTimer).TotalMilliseconds < 200) { return; } SleepTimer = DateTime.Now; switch (CurrentState) { case FishingState.Lure: //if (!HasBait) //{ // // Implement applying lure //} ProfessionInfo fish = API.Profession.Fishing; if (fish != null) { if (fish.Level >= (fish.MaxLevel - 25) && fish.MaxLevel < 450) { CurrentState = FishingState.Training; return; } } CurrentState = FishingState.Cast; break; case FishingState.Cast: Print("Casting Fishing Pole"); Fishing.Cast(); CurrentState = FishingState.Fishing; break; case FishingState.Fishing: if (IsFishing) { if (IsBobbing) { CurrentState = FishingState.Loot; } } else { CurrentState = FishingState.Lure; } break; case FishingState.Loot: Print("Getting Fishing Bobber"); Bobber.Interact(); LootTimer = DateTime.Now; CurrentState = FishingState.Looting; break; case FishingState.Looting: TimeSpan span = DateTime.Now - LootTimer; if (span.TotalSeconds > 3) { Print("No loot? Back to fishing then!"); CurrentState = FishingState.Lure; } break; // TODO: Clean up, add dynamic fishing trainer locator. case FishingState.Training: if (Trainer == null || !Trainer.IsValid) { // Marcia Chase, Dalaran - Neutral. Trainer = Manager.ObjectManager.Objects.Where(x => x.IsValid && x.IsUnit) .OfType <WoWUnit>() .FirstOrDefault(u => u.Entry == 28742); return; } if (Trainer.Distance > 6f) { if (Manager.Movement.Destination == Trainer.Location) { Sleep(100); } Manager.Movement.PathTo(Trainer.Location); return; } if (!API.Gossip.IsShown && !API.Trainer.IsShown) { Trainer.Interact(); return; } if (API.Gossip.IsShown) { GossipOption opt = API.Gossip.Options.FirstOrDefault(g => g.Gossip == GossipType.Trainer); if (opt != null) { opt.Select(); } return; } if (API.Trainer.IsShown) { API.Trainer.BuyAllAvailable(); Fishing = null; Manager.Spellbook.Update = true; CurrentState = FishingState.Lure; return; } CurrentState = FishingState.Lure; break; } }