Jump to content

[ToolBox][Vanilla - WOTLK] Many Useful Functions (Custom script)


Recommended Posts

first off (ive been learning frames last few days, never use a frame for buying stuff. 2nd there is no wow function 

itemCount

 

 

Nothing wrong in using lua, if I get the food in my inventory then Tool.HasItem will find it regardless of the method I'm using to obtain it, and I think it's a very good method to obtain the item. I mean the C# for HasItem is even using lua to return item amount. The problem I'm having has nothing to do with this at all ? the bot is not even approaching the NPC to interact.

The condition for NPC interaction is this:

return Tool.HasItem("Graccu's Mince Meat Fruitcake") < 0;

 

Naturally, a newly made character will fill this condition as it has none of that food. I don't understand why is the bot not moving to interact with the NPC?

---

itemCount() is my own custom function, it returns how many of particular item I have in my bag. As I said, everything works flawlessly, I am not new to using LUA or making LUA functions for WoW ?

--

I want to clear some confusion, my addon has Nothing to do with WRobot. It just buys me food when I right click (interact) with the NPC, the addon does this regardless whether I have WRobot running or not. It works 100% fine.

All I want WRobot to do, is to right click (interact) with the NPC. When I don't have food in my inventory, which return I am trying to get with Tool.HasItem - that's really all! ?

using frames like that one is everything SINGLE TIME you try go to vender it will run, which can cause problems. use this instead, use overridepulse to go buy stuff from venders.

if(wManager.Wow.Bot.Tasks.GoToTask.ToPositionAndIntecractWithNpc(new Vector3(1,1,1), 55 , 1)) // vectors of the npc, npc ID, Gossip
        {
            Tool.BuyItem("itemName", Amount);
        }
        return true;

 

Thank you! This is exactly what I was looking to forwards ? . I took the npc coordinates and npc entry - I'm 100% sure this info is correct!

When I launch bot, there is no error -- but still no moving to the npc / interacting which is the main issue.

 

QuestType: OverridePulseCSharpCode

Quest Order: ActionType: Pulse

 

  if(wManager.Wow.Bot.Tasks.GoToTask.ToPositionAndIntecractWithNpc(new Vector3(4895.55, -2842.65 , 1442.897), 25024, 1)) // vectors of the npc, npc ID, Gossip
        {
            Vendor.BuyItem(ItemsManager.GetNameById(21215), 1);
        }
        return true;

I got a error with Tool.BuyItem for some reason so I tried using the buy code from the other thread

InteractWithNPC.xml

  • 2 months later...
  • 1 month later...

Csharp LoadProfile 

public class Load
{
	public static void LoadProfile(string ProfileName)
	{
		var p = Quest.QuesterCurrentContext.Profile as QuesterProfile;
		if (p != null)
		{
			p.QuestsSorted.Add(new wManager.Wow.Class.QuestsSorted { Action = wManager.Wow.Class.QuestAction.LoadProfile, NameClass = ProfileName });
		}
	}
}

 

Use Item By Name

public static void UseItemByName(string ItemName)
    {
        var useItem = string.Format(@"
                        for bag = 0,4 do
                            for slot = 1,GetContainerNumSlots(bag) do
                                local item = GetContainerItemLink(bag,slot)
                                if item and item:find('{0}') then
                                    local startTime = GetItemCooldown(GetContainerItemID(bag,slot))
                                    if startTime <= 0 then
                                        UseItemByName('{0}')
                                        break;
                                    end
                                end
                            end
                        end", ItemName);

        Lua.LuaDoString(useItem);
    }

 

Crafting Function with a Wait while Player is Casting.

public static void Crafting(string profession, string itemName, int quantity = 0)
    {
        MovementManager.StopMoveTo(false, 1000);
        var ItemToCraft = Lua.LuaDoString<int>(string.Format(@"
                if not TradeSkillFrame or TradeSkillFrame:IsVisible() == nil then
                    CastSpellByName('{0}')
                end
                for i=1, GetNumTradeSkills() do
                    Quantity = {2};
                    local skillName, _, numAvailable = GetTradeSkillInfo(i);
                    if (skillName == '{1}') then
                        SelectTradeSkill(i);
                        if Quantity == 0 then
                            Quantity = numAvailable;
                        end
                        DoTradeSkill(i, Quantity);
                        break;
                    end
                end
              return Quantity;", profession, itemName, quantity)
        );
        if (ItemToCraft > 0)
        {
            Logging.Write("Player is Crafting " + itemName);
            int Time = (3000 + Usefuls.LatencyReal) * ItemToCraft;
            MovementManager.StopMoveTo(false, Time);
            DateTime time = DateTime.Now.AddMilliseconds(Time);
            while (DateTime.Now < time && !ObjectManager.Me.InCombatFlagOnly && !ObjectManager.Me.InCombat)
            {
                Thread.Sleep(300);
            }
            Logging.Write("Crafting Has Came to a End.");
            Lua.LuaDoString("HideUIPanel(TradeSkillFrame)");
        }
    }

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...