Jump to content

sowelu

Members
  • Posts

    58
  • Joined

  • Last visited

Reputation Activity

  1. Like
    sowelu reacted to Yayybo in Quester Profiles in C#   
    Well its doable but dunno if its worth the hassle to rewrite an existing product just for the sake of not using the profile editor :D Still i guess you could tweak the movement, approaching vendors/questgivers/trainers/flightmasters more easily with predefined pathes. Like if you are near a vendor that is inside a house swap to a predefined path instead of generating a new one with recast and detour...which gets stucked or hugs the wall like crazy.
    Hacked a small example together which is despite the name not very 'advanced' haha... . I've included two quest examples for Valley of Trials. Tested on TBC. Kinda wonky and not 100% working right now :/ Most of the included classes are empty as i've added them cuz i thought those features might be handy or must be included to work properly... . Atleast it was more convenient to write the quest profiles and a lot faster than with the profile editor x)
     
    AdvancedQuester.rar
  2. Like
    sowelu reacted to reapler in Bag.GetBagItem()   
    Not fully tested, but this should work:
    /// <summary> /// Used to get the item quantity by name. /// </summary> /// <param name="itemName">The item name.</param> /// <remarks>Replacement for GetItemCount in vanilla.</remarks> /// <returns></returns> public static int GetItemQuantity(string itemName) { var execute = "local itemCount = 0; " + "for b=0,4 do " + "if GetBagName(b) then " + "for s=1, GetContainerNumSlots(b) do " + "local itemLink = GetContainerItemLink(b, s) " + "if itemLink then " + "local _, stackCount = GetContainerItemInfo(b, s)\t " + "if string.find(itemLink, \"" + itemName + "\") then " + "itemCount = itemCount + stackCount; " + "end " + "end " + "end " + "end " + "end; " + "return itemCount; "; return Lua.LuaDoString<int>(execute); } /// <summary> /// Used to delete all items by name. /// </summary> /// <param name="itemName">The item to delete.</param> /// <param name="leaveAmount">The amount of items which remain in the bag.</param> /// <remarks>Bug at links with "-"</remarks> public static void DeleteItems(string itemName, int leaveAmount) { var itemQuantity = GetItemQuantity(itemName) - leaveAmount; if (string.IsNullOrWhiteSpace(itemName) || itemQuantity <= 0) return; var execute = "local itemCount = "+itemQuantity+"; " + "local deleted = 0; " + "for b=0,4 do " + "if GetBagName(b) then " + "for s=1, GetContainerNumSlots(b) do " + "local itemLink = GetContainerItemLink(b, s) " + "if itemLink then " + "local _, stackCount = GetContainerItemInfo(b, s)\t " + "local leftItems = itemCount - deleted; " + "if string.find(itemLink, \""+ itemName + "\") and leftItems > 0 then " + "if stackCount <= 1 then " + "PickupContainerItem(b, s); " + "DeleteCursorItem(); " + "deleted = deleted + 1; " + "else " + "if (leftItems > stackCount) then " + "SplitContainerItem(b, s, stackCount); " + "DeleteCursorItem(); " + "deleted = deleted + stackCount; " + "else " + "SplitContainerItem(b, s, leftItems); " + "DeleteCursorItem(); " + "deleted = deleted + leftItems; " + "end " + "end " + "end " + "end " + "end " + "end " + "end; "; Lua.LuaDoString(execute); } Usage:
    DeleteItems("Soul Shard", 20);  
  3. Like
    sowelu reacted to Avvi in Add custom dll   
    Not stupid questions! Thanks for updating us with how you resolved the issue :D
  4. Like
    sowelu got a reaction from Avvi in Add custom dll   
    Yes, I have put to /wrobot /bin and /plugins, nothing, but also, all my plugins have .cs extension, not .dll
     
    UPD I have put Xtest.dll, (not .cs) to /plugins and it seems fine! And sorry for my stupid questions.
     
  5. Like
    sowelu reacted to Droidz in Add custom dll   
    Do you have put Wmod dll in same folder than your plugin dll
  6. Like
    sowelu reacted to reapler in Radar3D How to use it?   
    Hello, you can subscribe your method to the event on initialize and unsubscribe on dispose:
    public void Initialize() { Radar3D.Pulse(); Radar3D.OnDrawEvent += Radar3DOnDrawEvent; } public void Dispose() { Radar3D.OnDrawEvent -= Radar3DOnDrawEvent; Radar3D.Stop(); } private static void Radar3DOnDrawEvent() { if (ObjectManager.Target.IsValid) Radar3D.DrawLine(ObjectManager.Me.Position, ObjectManager.Target.Position, Color.Chocolate); Radar3D.DrawCircle(ObjectManager.Me.Position, 5, Color.Chocolate); }  
  7. Thanks
    sowelu reacted to reapler in How to get angle or rotation info?   
    This should finally do the desired work while the other method was just for calculating :)
    /// <summary> /// Used to get the facing from two positions based on the origin rotation. /// </summary> /// <param name="from">The 1. position.</param> /// <param name="to">The 2. position.</param> /// <param name="originRotation">The origin rotation.</param> /// <returns>Negative radian on the right; positive on the left.</returns> public float FacingCenter(Vector3 from, Vector3 to, float originRotation) { var face = NormalizeRadian(Atan2Rotation(from, to) - originRotation); if (face < System.Math.PI) return -face; return NormalizeRadian(originRotation-Atan2Rotation(from, to)); } /// <summary> /// Used to normalize the input radian. /// </summary> /// <param name="radian">The radians to normalize.</param> public float NormalizeRadian(float radian) { if (radian < 0.0) return (float) (-(- radian % (2.0 * System.Math.PI)) + 2.0 * System.Math.PI); return radian % 6.283185f; } /// <summary> /// Used to calculate atan2 of to positions. /// </summary> /// <param name="from">The 1. position.</param> /// <param name="to">The 2. position.</param> /// <param name="addRadian">Radians to add.</param> /// <returns></returns> public float Atan2Rotation(Vector3 from, Vector3 to, float addRadian = 0) { return (float) System.Math.Atan2(to.Y - from.Y, to.X - from.X) + addRadian; }  
    Usage:
    var rot = FacingCenter(ObjectManager.Me.Position, ObjectManager.Target.Position, ObjectManager.Me.Rotation); if (rot < 0) Logging.Write("Facing to right: "+rot); Logging.Write("Facing to left: "+rot);  
  8. Like
    sowelu reacted to reapler in How to get id or name of item from bagslot   
    Yes, it's also possible. You need to change ""local _, stackCount = GetContainerItemInfo(b, s)\t" +" with GetItemInfo, add your conditions and return a list with a struct of the bag position & its slot.
     
    The struct:
    public struct BagInfo { public int Bag; public int Slot; public BagInfo(int bag, int slot) { Bag = bag; Slot = slot; } public override string ToString() { return "Bag = " + Bag + " ; Slot = " + Slot; } }  
    The disenchant list:
    /// <summary> /// Used to get a list of all disenchantable items as bag and slot position. /// </summary> /// <param name="maxItemLevel">The maximum item level.</param> /// <param name="interactions">The amount of interactions.</param> /// <returns></returns> public static List<BagInfo> DisenchantList(int maxItemLevel = int.MaxValue, int interactions = int.MaxValue)//parameter list can be extended { var execute = "local counter = 0; " + "local leftStacks = 0; " + "local bs = {}" + "for b=0,4 do " + "if GetBagName(b) then " + "for s=1, GetContainerNumSlots(b) do " + "local itemLink = GetContainerItemLink(b, s) " + "if itemLink then " + "local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(itemLink) \t" + "if itemRarity > 1 and itemRarity < 5 " + "and itemLevel <= " + maxItemLevel + " " + "and (itemType == 'Armor' or itemType == 'Weapon') "; execute = execute + "then " + "if (counter < "+interactions+") then " + "table.insert(bs, b); " + "table.insert(bs, s); " + "counter = counter + 1; " + "else " + "leftStacks = leftStacks + 1;" + "end " + "\tend\tend\tend end end return unpack(bs);"; var bs = Lua.LuaDoString<List<int>>(execute); var list = new List<BagInfo>(); for (var i = 0; i < bs.Count; i += 2) { list.Add(new BagInfo(bs[i], bs[i+1])); } return list; }  
    The final method to execute:
    /// <summary> /// Disenchant all items depend on the itemLevel. /// </summary> /// <param name="maxItemLevel">The maximum item level.</param> /// <remarks>AutoLoot must be enabled to work properly.</remarks> public void Disenchant(int maxItemLevel = int.MaxValue) { var disenchant = new Spell("Disenchant"); foreach (var bagInfo in DisenchantList()) { disenchant.Launch(); Thread.Sleep(100); Lua.LuaDoString("UseContainerItem("+bagInfo.Bag+", "+bagInfo.Slot+");"); Thread.Sleep((int)disenchant.CastTime+800); } } Not fully tested, but it should work.
     
    And
    I think you let it compile by WRobot or using a lower framework version, so new additions over the course of the years like this example doesn't support it.
  9. Like
    sowelu reacted to reapler in How to get id or name of item from bagslot   
    In my other post, i've written a method to interact with the items: https://wrobot.eu/forums/topic/7064-check-distance/?tab=comments#comment-32142
    You can also use this to right clicking your items to the mail attachment.
    I've rewritten abit, so it returns the left stacks:
    /// <summary> /// Interact with all listed item names. /// </summary> /// <param name="itemNames">The itemNames to interact with.</param> /// <param name="interactions">The amount of interactions.</param> /// <returns>The amount of itemNames / stacks blocked by "interactions".</returns> /// <remarks>Bug at links with "-"</remarks> public static int InteractItems(List<string> itemNames, int interactions = int.MaxValue) { if (!itemNames.Any()) return -1; var execute = "local counter = 0; " + "local leftStacks = 0; " + "for b=0,4 do " + "if GetBagName(b) then " + "for s=1, GetContainerNumSlots(b) do " + "local itemLink = GetContainerItemLink(b, s) " + "if itemLink then " + "local _, stackCount = GetContainerItemInfo(b, s)\t" + "if string.find(itemLink, \""+ itemNames.FirstOrDefault() + "\") "; if (itemNames.Count > 1) { execute = itemNames.Where(obj => itemNames.FirstOrDefault() != obj).Aggregate(execute, (current, obj) => current + "or string.find(itemLink, \"" + obj + "\") "); } execute = execute + "then " + "if (counter < "+interactions+") then " + "UseContainerItem(b, s); " + "counter = counter + 1; " + "else " + "leftStacks = leftStacks + 1;" + "end " + "\tend\tend\tend end end return leftStacks;"; return Lua.LuaDoString<int>(execute); } /// <summary> /// Sends a mail to a recipient. /// </summary> /// <param name="recipient">The recipient.</param> /// <param name="subject">The subject.</param> /// <param name="itemNames">The items to send as names.</param> /// <returns>true if successful ; false if no mailbox available or stacks are left.</returns> public bool SendItems(string recipient, string subject, List<string> itemNames) { var mailBox = ObjectManager.GetObjectWoWGameObject().FirstOrDefault(i => i.IsMailbox && i.GetDistance <= 5); if (mailBox == null || string.IsNullOrWhiteSpace(recipient)) return false; if (subject.Length == 0) subject = "-"; if (mailBox) { const int delayMs = 800; var timeOut = DateTime.Now.AddSeconds(40); Interact.InteractGameObject(mailBox.GetBaseAddress); Thread.Sleep(delayMs); Lua.LuaDoString("RunMacroText('/click MailFrameTab2');"); Thread.Sleep(delayMs); var leftStack = InteractItems(itemNames, 12); Thread.Sleep(delayMs); Lua.LuaDoString($"SendMail(\"{recipient}\",\"{subject}\",\" \");"); Thread.Sleep(delayMs*3); while (leftStack != 0 && DateTime.Now < timeOut) { leftStack = InteractItems(itemNames, 12); Thread.Sleep(delayMs); Lua.LuaDoString($"SendMail(\"{recipient}\",\"{subject}\",\" \");"); Thread.Sleep(delayMs*3); } Lua.LuaDoString("CloseMail();"); if (leftStack != 0) return false; } return true; }  
    Usage:
    SendItems("Reapler", "items for you", new List<string> { "Super Healing Potion", "Heavy Netherweave Bandage", "Super Mana Potion", });  
  10. Like
    sowelu reacted to reapler in check distance   
    If you run the instances of WRobot on the same pc, you can checkout my CacheManager here.
    Yes, i recommend to use the "Quester" product and add a quest with "FollowPath" in "Quests Editor" window. It also supports C#.
    I think, you know how to calculate the position, so you could use this:
    //replace "new Vector3()" with your desired position SpellManager.CastSpellByIDAndPosition(1725, new Vector3());  
    To open trade with current target:
    Lua.LuaDoString("RunMacroText('/trade');");  
    Put items to the trade window(another solution, forgot the exact reason why it was in some ways better then the WRobot's method):
    /// <summary> /// Interact with all listed item names. /// </summary> /// <param name="items">Item list</param> /// <remarks>Bug at links with "-"</remarks> public static void InteractItems(List<string> items) { if (!items.Any()) return; var execute = "for b=0,4 do " + "if GetBagName(b) then " + "for s=1, GetContainerNumSlots(b) do " + "local itemLink = GetContainerItemLink(b, s) " + "if itemLink then " + "local _, stackCount = GetContainerItemInfo(b, s)\t" + "if string.find(itemLink, \""+ items.FirstOrDefault() + "\")"; if (items.Count > 1) { execute = items.Where(obj => items.FirstOrDefault() != obj).Aggregate(execute, (current, obj) => current + "or string.find(itemLink, \"" + obj + "\") "); } execute = execute + "then UseContainerItem(b, s)\tend\tend\tend end end"; Lua.LuaDoString(execute); }  
    To press the trade button:
    Lua.LuaDoString("RunMacroText('/click TradeFrameTradeButton');"); Take also a look at https://wrobot.eu/forums/topic/6826-frame-stack-on-wow-tbc-243/ or type "/fstack" in Wow if you have wotlk or above, to get other related frame stuff.
     
    And If you mention a new topic, just open a new thread ;)
     
  11. Like
    sowelu reacted to Droidz in Is player offline? GetParty() doesent work.   
    Hello, try to use 
     Logging.Write(Lua.LuaDoString<bool>("return UnitIsConnected('" + "PlayerName" + "')") + "");  
  12. Like
    sowelu reacted to iMod in check distance   
    You should not using the index because if there is no chest you will get a out of range exception.
    // Search for a chest List<WoWGameObject> chest = ObjectManager.GetWoWGameObjectByyId(123456).FirstOrDefault(); // Found? if(chest != null) { // Open Interact.InteractGameObject(chest.GetBaseAddress); }  
  13. Like
    sowelu reacted to Avvi in Is player offline? GetParty() doesent work.   
    I posted same thing in bug tracker: I'm pretty sure that there is an issue with the 
    wManager.Wow.ObjectManager.ObjectManager.GetObjectByGuid That the .GetParty() function uses.
     
  14. Like
    sowelu reacted to iMod in check distance   
    public class Ninja { private Spell _vanish = new Spell("Vanish"); int chestId = 42; void LookingForTheChest() { if (ObjectManager.Me.InCombat && Lua.LuaDoString<bool>("IsShiftKeyDown()")) { //use vanish. How can send to game some bind like "shift + V"? //sleep 2000 Thread.Sleep(2000); // Cast vanish this._vanish.Launch(); } if (ObjectManager.Me.InCombat == false && _vanish.IsSpellUsable && IsAnyoneNearMe() == false && ObjectManager.Me.IsCast == false) { LootTheChest(); } } void LootTheChest() { //lets check chest, maybe it looted already //if no chest i need to go to the next step } bool IsAnyoneNearMe() { //get mobs around List<WoWUnit> mobsNearMe = ObjectManager.GetWoWUnitHostile(); //anyone near me? foreach (WoWUnit u in mobsNearMe) { if (ObjectManager.Me.Position.DistanceTo2D(u.Position) < 30) { return true; } } // ok, fine, there are no mobs near me, lets check where is patrol foreach (WoWUnit u in mobsNearMe) { //how to check by id? im using DisplayID, dont know what is it, but i hope you will help if (u.DisplayId == 2017 && ObjectManager.Me.Position.DistanceTo2D(u.Position) < 100) { return true; } } //so cool, patrol are so far and no one near me, time to loot the chest return false; } }  
×
×
  • Create New...