TheSmokie 242 Posted September 8, 2020 Share Posted September 8, 2020 (edited) Hello, this is just thread where i post miscellaneous Code to help others get idea or fix to there problems. Note some code works, some doesnt. its mainly for educational perspectives. Quest Checker private static bool IsQuestCompleted(int questID) { Lua.LuaDoString("ExpandQuestHeader(0)"); int QuestCount = Lua.LuaDoString<int>(@"return select(1, GetNumQuestLogEntries())"); for (int i = 1; i <= QuestCount; i++) { var QuestInfo = Lua.LuaDoString<List<string>>(string.Format(@"return GetQuestLogTitle(" + i + ")")); if (QuestInfo[4] == "1" || QuestInfo[5] == "1") continue; string QuestStatus = null; if (QuestInfo[6] == "1") QuestStatus = "completed"; else if (QuestInfo[6] == "-1") QuestStatus = "failed"; else QuestStatus = "in progress"; if (QuestInfo[8] == Convert.ToString(questID) && QuestStatus == "completed") { return true; } } return false; } Edited September 8, 2020 by TheSmokie Link to comment https://wrobot.eu/forums/topic/12492-miscellaneous-code-idea-developers-only/ Share on other sites More sharing options...
TheSmokie 242 Posted October 14, 2020 Author Share Posted October 14, 2020 This code i made for running normal instances, come out to sell items to "traveler's tundra mammoth" Quester > Custom Script. using robotManager.Helpful; using wManager.Wow.Helpers; using wManager.Wow.Bot.Tasks; using wManager.Wow.ObjectManager; using System.Linq; using System.Threading; using System.Collections.Generic; using wManager.Wow.Enums; using System; using System.ComponentModel; using System.IO; using System.Configuration; public static class Main_Thread { public static List<string> Sellitems = new List<string>(); public static WoWPlayer Me = ObjectManager.Me; public static void Start() { wManager.wManagerSetting.CurrentSetting.CloseIfPlayerTeleported = false; wManager.wManagerSetting.CurrentSetting.Save(); Lua.LuaDoString(@"SetDungeonDifficulty(1);"); } public static void OnSeemStuck() { if (!wManager.wManagerSetting.IsBlackListedZone(new Vector3(Me.Position.X, Me.Position.Y, Me.Position.Z, "None"))) { wManager.wManagerSetting.AddBlackListZone(new Vector3(Me.Position.X, Me.Position.Y, Me.Position.Z, "None"), 2.00f, true); Logging.Write("[Unstuck Blacklisting]: " + Me.Position.X.ToString() + Me.Position.Y.ToString() + Me.Position.Z.ToString()); } } public static void ToPosition(Vector3 vector) { GoToTask.ToPosition(vector); } public static void MoveWhileDead() { var badCorpsePos = new Vector3(-3361.787f, 4665.568f, -22.70184f); var enterDungeonPos = new Vector3(-3361.623f, 4643.492f, -101.047f); Logging.Write("[EnterCorpse] Started."); wManager.Events.OthersEvents.OnPathFinderFindPathResult += (from, to, path, mpq, success) => { if (ObjectManager.Me.IsDead && to.DistanceTo(badCorpsePos) < 10) { path.Clear(); path.AddRange(PathFinder.FindPath(enterDungeonPos)); } }; } public static void Mammoth() { string Mount_Name = "Traveler's Tundra Mammoth"; if (GoToTask.ToPosition(new Vector3(-3361.868f, 4759.114f, -101.3954f))) { if (!ObjectManager.Me.HaveBuff(Mount_Name)) { SpellManager.CastSpellByNameLUA(Mount_Name); Usefuls.WaitIsCasting(); } } } public static void Sellingitems() { List<WoWItemQuality> quality = new List<WoWItemQuality> { WoWItemQuality.Common, WoWItemQuality.Poor, WoWItemQuality.Rare, WoWItemQuality.Epic, WoWItemQuality.Uncommon }; int Mount_Vendor_ID = 32641; var Mount_Vendor = ObjectManager.GetWoWUnitByEntry(Mount_Vendor_ID).FirstOrDefault(i => i.Entry == Mount_Vendor_ID); if (Mount_Vendor.IsValid && Mount_Vendor != null) { Interact.InteractGameObject(Mount_Vendor.GetBaseAddress); foreach (WoWItem item in Bag.GetBagItem()) { if (!Selling_Settings.CurrentSetting.DONOT.Contains(item.GetItemInfo.ItemName)) { Sellitems.Add(item.GetItemInfo.ItemName); Vendor.SellItems(Sellitems, Selling_Settings.CurrentSetting.DONOT, quality); Thread.Sleep(100); } } Thread.Sleep(10); } } public static void DoNotSellITems(string item) { Selling_Settings.Load(); if(!Selling_Settings.CurrentSetting.DONOT.Contains(item)) { Selling_Settings.CurrentSetting.DONOT.Add(item); Selling_Settings.CurrentSetting.Save(); } } } [Serializable] public class Selling_Settings : Settings { [Setting] [DefaultValue(null)] [Category("C:_Other Functions_")] [DisplayName("Items to delete")] [Description("It will attempt to DELETE the Items in interval")] public List<string> DONOT { get; set; } private Selling_Settings() { DONOT = new List<string>(); } public static Selling_Settings CurrentSetting { get; set; } public bool Save() { try { return Save(AdviserFilePathAndName("Selling_Settings", ObjectManager.Me.Name + "." + Usefuls.RealmName)); } catch (Exception e) { Logging.WriteError("Selling_Settings > Save(): " + e); return false; } } public static bool Load() { try { if (File.Exists(AdviserFilePathAndName("Selling_Settings", ObjectManager.Me.Name + "." + Usefuls.RealmName))) { CurrentSetting = Load<Selling_Settings>( AdviserFilePathAndName("Selling_Settings", ObjectManager.Me.Name + "." + Usefuls.RealmName)); return true; } CurrentSetting = new Selling_Settings(); } catch (Exception e) { Logging.WriteError("Selling_Settings > Load(): " + e); } return false; } } Link to comment https://wrobot.eu/forums/topic/12492-miscellaneous-code-idea-developers-only/#findComment-60240 Share on other sites More sharing options...
TheSmokie 242 Posted October 16, 2020 Author Share Posted October 16, 2020 Note : this is not the code used in selector, the reward selection in selector is more advanced, but i think this will help make the whole quest reward problem go away for a lot of devs. enjoy. using wManager.Wow.Helpers; using System.ComponentModel; using System.Threading; public static class Quester_rewards { public static void Select() { wManager.Events.OthersEvents.OnSelectQuestRewardItem += delegate (CancelEventArgs cancelable) { cancelable.Cancel = true; gossip(); Thread.Sleep(100); if (Lua.LuaDoString<bool>("if QuestFrameRewardPanel:IsVisible() then return true else return false end")) Selecter(); }; } public static void Selecter() { int questRewards = Lua.LuaDoString<int>("return GetNumQuestChoices()"); if (questRewards == 0) { Lua.LuaDoString("QuestFrameCompleteQuestButton:Click();"); Thread.Sleep(100); } else RunLua(); } public static void gossip() { Lua.LuaDoString(@" if ( not QuestFrameRewardPanel:IsVisible() or QuestFrameRewardPanel:IsVisible() == nil ) then local gossipTable = {GetGossipActiveQuests()} local numOptions = table.getn(gossipTable)/4 local nameIndex, completeIndex = 1, 4 for i=1,numOptions do if gossipTable[completeIndex] == 1 then SelectGossipActiveQuest(i) CompleteQuest(); end nameIndex, completeIndex = nameIndex + 4, completeIndex + 4 end return"); } public static void RunLua() { Lua.LuaDoString(@" local numberOfQuestRewards = GetNumQuestChoices() local mostValuableQuestItemIndex, mostValuableQuestItemValue, bestQuestItemIndex, bestQuestItemArmorWeight = 1, 0, -1, -1 local armorWeights = { Plate = 4, Mail = 2, Leather = 1, Cloth = 0 } local equipmentSlotLookup = { INVTYPE_HEAD = {""HeadSlot"", nil}, INVTYPE_NECK = {""NeckSlot"", nil}, INVTYPE_SHOULDER = {""ShoulderSlot"", nil}, INVTYPE_CLOAK = {""BackSlot"", nil}, INVTYPE_CHEST = {""ChestSlot"", nil}, INVTYPE_WRIST = {""WristSlot"", nil}, INVTYPE_HAND = {""HandsSlot"", nil}, INVTYPE_WAIST = {""WaistSlot"", nil}, INVTYPE_LEGS = {""LegsSlot"", nil}, INVTYPE_FEET = {""FeetSlot"", nil}, INVTYPE_SHIELD = {""SecondaryHandSlot"", nil}, INVTYPE_ROBE = {""ChestSlot"", nil}, INVTYPE_2HWEAPON = {""MainHandSlot"", ""SecondaryHandSlot""}, INVTYPE_WEAPONMAINHAND = {""MainHandSlot"", nil}, INVTYPE_WEAPONOFFHAND = {""SecondaryHandSlot"", ""MainHandSlot""}, INVTYPE_WEAPON = {""MainHandSlot"",""SecondaryHandSlot""}, INVTYPE_THROWN = {""RangedSlot"", nil}, INVTYPE_RANGED = {""RangedSlot"", nil}, INVTYPE_RANGEDRIGHT = {""RangedSlot"", nil}, INVTYPE_FINGER = {""Finger0Slot"", ""Finger1Slot""}, INVTYPE_HOLDABLE = {""SecondaryHandSlot"", ""MainHandSlot""}, INVTYPE_TRINKET = {""Trinket0Slot"", ""Trinket1Slot""} } for questItemIndex = 1, numberOfQuestRewards do local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(GetQuestItemLink(""choice"", questItemIndex)) if itemRarity >= 3 then return end local itemId = itemLink:match(""|Hitem:(%d+)"") local isItemEquippable = IsEquippableItem(itemId) local _, _, _, _, isItemUsable = GetQuestItemInfo(""choice"", questItemIndex) if itemSellPrice > mostValuableQuestItemValue then -- Keep track of which item is most valuable: mostValuableQuestItemIndex = questItemIndex mostValuableQuestItemValue = itemSellPrice end if isItemEquippable == 1 and isItemUsable ~= nil then -- NPC is offering us an item we can actually wear: local currentEquippedItemLinksInSlots = {} local currentWorstEquippedItemInSlot = nil -- Figure out what we already have equipped: for _, itemSlot in ipairs(equipmentSlotLookup[itemEquipLoc]) do if itemSlot ~= nil then local currentEquippedItemLinkInSlot = GetInventoryItemLink(""player"", GetInventorySlotInfo(itemSlot)) if currentEquippedItemLinkInSlot == nil then -- Of the n item slots available, at least one of them has nothing equipped. Ergo, it is the worst: currentWorstEquippedItemInSlot = nil break else local _, _, _, currentEquippedItemLevelInSlot, _, _, currentEquippedItemSubTypeInSlot = GetItemInfo(currentEquippedItemLinkInSlot) if currentWorstEquippedItemInSlot == nil or currentWorstEquippedItemInSlot.itemLevel > currentEquippedItemLevelInSlot then currentWorstEquippedItemInSlot = { itemLink = currentEquippedItemLinkInSlot, itemLevel = currentEquippedItemLevelInSlot, itemSubType = currentEquippedItemSubTypeInSlot } end end end end if currentWorstEquippedItemInSlot == nil then bestQuestItemIndex = questItemIndex else if itemLevel > currentWorstEquippedItemInSlot.itemLevel then if armorWeights[itemSubType] ~= nil then if armorWeights[itemSubType] > bestQuestItemArmorWeight then bestQuestItemIndex = questItemIndex bestQuestItemArmorWeight = armorWeights[itemSubType] end elseif currentWorstEquippedItemInSlot.itemSubType == itemSubType then bestQuestItemIndex = questItemIndex bestQuestItemArmorWeight = -1 end end end end end if bestQuestItemIndex < 0 then bestQuestItemIndex = mostValuableQuestItemIndex end GetQuestReward(bestQuestItemIndex) "); } } Link to comment https://wrobot.eu/forums/topic/12492-miscellaneous-code-idea-developers-only/#findComment-60258 Share on other sites More sharing options...
Sye 1 Posted March 22, 2021 Share Posted March 22, 2021 Faster way of getting people to sigh your guild charter. var PlayersAroundMe = ObjectManager.GetObjectWoWPlayer().Where(c => c.Position.DistanceTo(ObjectManager.Me.Position) < 30 && c.Faction == ObjectManager.Me.Faction && c.IsAlive); ItemsManager.UseItem("Guild Charter"); foreach (var Toon in PlayersAroundMe) { ObjectManager.Me.Target = Toon.Guid; bool PlayerHasNoGuild = Lua.LuaDoString<bool>(@" local GuildName = GetGuildInfo('target'); if GuildName == nil then return true; else return false; end"); Thread.Sleep(100); if (PlayerHasNoGuild) { Chat.SendChatMessageWhisper("Can you please sigh my guild Chart, pretty please :)", Toon.Name); Thread.Sleep(100); Lua.LuaDoString("OfferPetition();"); Thread.Sleep(100); Logging.Write("Petition Offered to :" + Toon.Name); } } Link to comment https://wrobot.eu/forums/topic/12492-miscellaneous-code-idea-developers-only/#findComment-61595 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now