Jump to content

Smelting


sakado

Recommended Posts

If this code is useful, I think there are things that need to be completed. I didn't check this. I don't know much about coding, can anyone with knowledge help me? Can you edit this code exactly?

 

using wManager.Wow.Enums;
using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;

public static void CheckAndProcessOre()
{
    string oreName = "Copper Ore";
    int requiredAmount = 10;

    if (IsBagFull())
    {
        WoWGameObject smeltingNPC = FindNearestSmeltingNPC();
        if (smeltingNPC != null)
        {
            Navigator.GoTo(smeltingNPC.Position);
        }
    }
    else
    {
        MineOre(oreName, requiredAmount);
    }
}

public static bool IsBagFull()
{
    List<WoWItem> bags = Bag.GetBagItem();

    foreach (WoWItem bag in bags)
    {
        if (bag != null && bag.IsValid && bag.ItemInfo != null)
        {
            int freeSlots = bag.ItemInfo.MaxCount - bag.StackCount;
            if (freeSlots == 0)
            {
                return true;
            }
        }
    }

    return false;
}

public static void MineOre(string oreName, int requiredAmount)
{
    WoWGameObject oreNode = FindNearestOreNode(oreName);
    if (oreNode != null)
    {
        Navigator.GoTo(oreNode.Position);
        oreNode.Interact();
        wManager.wManagerSetting.WaitLocalPlayerIsIdleMS = 2000;
        int currentAmount = GetItemCount(oreName);
        if (currentAmount >= requiredAmount)
        {
            WoWGameObject smeltingNPC = FindNearestSmeltingNPC();
            if (smeltingNPC != null)
            {
                Navigator.GoTo(smeltingNPC.Position);
            }
        }
    }
}

public static WoWGameObject FindNearestOreNode(string oreName)
{
    return ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntryList(Mining.OreEntryList).FindAll(node => node.Name == oreName && !node.InUse && node.IsValid && node.IsAlive));
}

public static int GetItemCount(string itemName)
{
    WoWItem[] items = Bag.GetBagItem().ToArray();
    return items.Sum(item => item.ItemInfo.Name == itemName ? item.StackCount : 0);
}

public static WoWGameObject FindNearestSmeltingNPC()
{
    return ObjectManager.GetNearestWoWGameObject(ObjectManager.GetWoWGameObjectByEntryList(Mining.SmeltingEntryList).FindAll(npc => npc.IsValid && npc.Is
Alive));
}

public static int[] SmeltingEntryList = { /* Smelting NPC'ID */ };
 

Link to comment
Share on other sites

2 minutes ago, Droidz said:

Hello,

I don't know where you got this code, but it can't work, it's missing a lot of methods (did you use chatgpt?).

I was thinking the same thing. 

Link to comment
Share on other sites

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...