-
Posts
1215 -
Joined
Reputation Activity
-
-
TheSmokie got a reaction from zakchef in buy item
i use this function to buy stuff from venders if it helps.
public static void BuyItem(string name, int amount) { Lua.LuaDoString(string.Format(@" local itemName = ""{0}"" local quantity = {1} for i=1, GetMerchantNumItems() do local name = GetMerchantItemInfo(i) if name and name == itemName then BuyMerchantItem(i, quantity) end end", name, amount)); }
-
TheSmokie reacted to Matenia in [Suggestion] allow custom scripts into reward item
This is great. Now I don't have to use a Lua hook anymore.
Otherwise you can use a Lua hook to create a race condition between your selection code and ANY code turning in the quest:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Security.Cryptography; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using DatabaseManager.Enums; using robotManager.Events; using robotManager.FiniteStateMachine; using robotManager.Helpful; using robotManager.Products; using wManager; using wManager.Wow.Bot.Tasks; using wManager.Wow.Class; using wManager.Wow.Enums; using wManager.Wow.Helpers; using wManager.Wow.ObjectManager; public class QuestRewardSelector { public static string TooltipName = "QuestItemCompareTooltip"; public static void Start() { TooltipName = LuaVariableSettings.CurrentSetting.QuestToolTipName; RegisterHook(); CreateTooltip(); EventsLua.AttachEventLua((LuaEventsId) Enum.Parse(typeof(LuaEventsId), "QUEST_COMPLETE"), QuestCompleteHandler); } public static void Stop() { } public static void CreateTooltip() { Lua.LuaDoString($@" if not {TooltipName} then {TooltipName} = CreateFrame('GameTooltip', '{TooltipName}', nil, 'GameTooltipTemplate'); {TooltipName}:SetOwner(UIParent, 'ANCHOR_NONE'); end "); } public static void RegisterHook() { Lua.LuaDoString($@" if (not {LuaVariableSettings.CurrentSetting.QuestHookName}) then _OriginalQuestCompleteOnClick = QuestFrameCompleteQuestButton:GetScript(""OnClick""); function hook_QuestComplete(self, button, arg2, arg3) self = this; if (button == ""FORCE"") then --DEFAULT_CHAT_FRAME:AddMessage('Forcing quest acceptance!'); _OriginalQuestCompleteOnClick(self, button); else C_Timer.After(2500, function() --DEFAULT_CHAT_FRAME:AddMessage('Delay quest turn in by 2500ms'); _OriginalQuestCompleteOnClick(self, button); end); end end QuestFrameCompleteQuestButton:SetScript(""OnClick"", hook_QuestComplete); _GetQuestReward = GetQuestReward; function GetQuestReward(index, force) if(force) then return _GetQuestReward(index); else C_Timer.After(2500, function() --DEFAULT_CHAT_FRAME:AddMessage('Delay quest turn in by 2500ms'); return _GetQuestReward(index); end); end end --DEFAULT_CHAT_FRAME:AddMessage('Quest hook initiated'); {LuaVariableSettings.CurrentSetting.QuestHookName} = true; end "); } private static void QuestCompleteHandler(object context) { Lua.LuaDoString("QuestFrameCompleteQuestButton:Disable();"); PluginLog.Log("About to complete quest - INTERCEPT!"); SelectQuestItem(); Lua.LuaDoString("QuestFrameCompleteQuestButton:Enable();"); //fallback Lua.LuaDoString($"_GetQuestReward(1);"); } private static void SelectQuestItem() { try { int questRewards = Lua.LuaDoString<int>("return GetNumQuestChoices()"); if (questRewards == 0) { return; } Dictionary<ParsedItem, int> itemRewards = new Dictionary<ParsedItem, int>(); for (int i = 1; i <= questRewards; i++) { Lua.LuaDoString($@" {TooltipName}:Hide(); {TooltipName}:SetOwner(UIParent, 'ANCHOR_NONE'); {TooltipName}:ClearLines(); {TooltipName}:SetQuestItem(""choice"", {i}); "); ParsedItem item = ItemParser.ParseCurrentTooltip(TooltipName, true); if (item.isUsable) { itemRewards.Add(item, i); } } ItemComparator comparator = new ItemComparator(StatWeights.ForClass(ObjectManager.Me.WowClass)); ParsedItem bestItem = comparator.FindBestItem(itemRewards.Keys.ToList()); int index = itemRewards[bestItem]; PluginLog.Log("Found best item " + bestItem.name + " as reward number: " + index); Lua.LuaDoString($@" --QuestFrameCompleteQuestButton:Enable(); _GetQuestReward({index}); "); Thread.Sleep(1000); } catch (Exception e) { Logging.WriteError("" + e); } } private static async void SelectQuestItemAsync() { await Task.Run(() => { SelectQuestItem(); }); } }
-
TheSmokie got a reaction from Pudge in Wizard's Sanctum Mesh (Stormwind)
I’ve been working on this offmesh for over 3 hours, no matter what it keeps looping from in and out of the portal
-
TheSmokie reacted to Droidz in Add event handler or hook to add new state safely
and code like:
Engine lastEngine = null; robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += delegate(Engine engine, State state, CancelEventArgs cancelable) { try { if (engine == null || engine.States == null) return; if (engine != lastEngine) { if (engine.States.Any(s => s is Idle)) { lastEngine = engine; engine.AddState(new MyCustomState()); // or engine.States.Insert(X, new MyCustomState()); // cancelable.Cancel = true; ?? } } } catch { } };
-
-
TheSmokie reacted to Matenia in Add Fight.StopFight(); to anti-drown
//This is how I handle it in my very own fight mechanism: _fightStartTs = DateTime.Now; // chase target if necessary, otherwise wait while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && _target.IsAlive && _fightTrigger && !_target.IsTapDenied) { KeepTarget(_targetGuid); //MoveAwayFromEnemies(); // needs to know if enemy is caster KiteIfNecessary(_target); SwimUpForAir(); PotionUser.UsePotions(); ChaseTarget(_target, () => ClassRotation.Range); HandleEvade(_target); EscapeIfNecessary(); Thread.Sleep(150); } private static void SwimUpForAir() { if (AntiDrown.NeedsAirInCombat) { AntiDrown.GaspForAir(); } } using System; using System.Collections.Generic; using System.Threading; using robotManager.FiniteStateMachine; using SmartRobot.Bot.Helpers; using wManager.Wow.Enums; using wManager.Wow.Helpers; using wManager.Wow.ObjectManager; namespace SmartRobot.Bot.States { public class AntiDrown : State { private static DateTime _breathExpires = DateTime.MaxValue; static AntiDrown() { EventsLuaWithArgs.OnEventsLuaStringWithArgs += AntiDrownEventHandler; } public override string DisplayName => "AntiDrown"; private bool NeedsAir => DateTime.Now.AddSeconds(30) > _breathExpires; public static bool NeedsAirInCombat => DateTime.Now.AddSeconds(15) > _breathExpires; public static bool IsBreathing => _breathExpires != DateTime.MaxValue; public override bool NeedToRun => Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && ObjectManager.Me.IsSwimming && NeedsAir; ~AntiDrown() { EventsLuaWithArgs.OnEventsLuaStringWithArgs -= AntiDrownEventHandler; } private static void AntiDrownEventHandler(string id, List<string> args) { if ((id == "MIRROR_TIMER_START") & (args[0] == "BREATH")) { //sets BreathExpires to be in the future by x milliseconds var expiryDate = DateTime.Now.AddMilliseconds(double.Parse(args[1])); _breathExpires = expiryDate; if (!ObjectManager.Me.HaveBuff("Water Breathing")) { ItemsManager.UseItem(5996); } } if (id == "MIRROR_TIMER_STOP") { _breathExpires = DateTime.MaxValue; } } public override void Run() { GaspForAir(); } public static void GaspForAir() { Logger.Info("Swimming up for air"); MovementManager.StopMove(); while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && IsBreathing && ObjectManager.Me.IsSwimming) { Move.JumpOrAscend(Move.MoveAction.DownKey, 1000); Thread.Sleep(500); } // wait at surface while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && IsBreathing && !Common.IsAttackedByNpc) { Thread.Sleep(500); } } } } Hope it helps for inspiration.
-
TheSmokie reacted to Pudge in ClearTarget
Interact.ClearTarget(); Works fine in latest version, thanks ❤️
-
-
-
-
-
-
-
TheSmokie got a reaction from Varan in Vehicle options
@Droidz I don’t wish to sound crude or ungreatful for the bot but are you adding mire options to use vehicles Ingame like a shooting method? Only reason I ask if you confirmed it.
-
TheSmokie got a reaction from Varan in Vehicle options
@Droidz
idk if this will help you dev the vehicle api but here is what honorbuddy used.
https://github.com/BosslandGmbH/Honorbuddy-Quest-Behaviors/blob/master/Quest Behaviors/Vehicles/VehicleMover.cs
-
-
-
-
TheSmokie got a reaction from bio33 in Vehicle options
@Droidz
idk if this will help you dev the vehicle api but here is what honorbuddy used.
https://github.com/BosslandGmbH/Honorbuddy-Quest-Behaviors/blob/master/Quest Behaviors/Vehicles/VehicleMover.cs
-
TheSmokie got a reaction from bio33 in Vehicle options
@Droidz I don’t wish to sound crude or ungreatful for the bot but are you adding mire options to use vehicles Ingame like a shooting method? Only reason I ask if you confirmed it.
-
-
-
-