What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal
RebornBuddy Forums

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

GetInventoryById/Slot Can i extract this from WorldItem?

alcor75

Community Developer
Joined
Nov 22, 2012
Messages
376
Tring to build a primitive autoequip, i was wandering if we have a way to extract LokiPoe.InGameState.InventoryPanel.PlaceCursorInto.... from WorldItem information, before i build my Enum or Dictionary for it.

(This Code is been leech fro darkbluefirefly QuestPlugin, with little name mod to suit my project)
Code:
Private EquipItem(WorldItem _item)
{
    var InvSlot = LokiPoe.InGameState.InventoryPanel.GetInventoryBySlot(_item.????);        [COLOR="#FF0000"]<----------- How to select the right InventoryPanel from WorldItem proprety?[/COLOR]
    if(!InvSlot .Items.Any())
    {
         var itemtoEquip = LokiPoe.InGameState.InventoryPanel.MainInventory.ContainsItem(_item.Name);
         if itemtoEquip )
         {
             await Coroutines.OpenInventoryPanel();
             var item = LokiPoe.InGameState.InventoryPanel.MainInventory.FindItemByName(_item.Name);
             await Coroutine.Sleep(250);
             LokiPoe.InGameState.InventoryPanel.PickupMainToCursor(item);
             await Coroutine.Sleep(250);
             LokiPoe.InGameState.InventoryPanel.????????     [COLOR="#FF0000"]<----------- How to select the right PlaceCursorOnto from WorldItem proprety?[/COLOR]
             await Coroutine.Sleep(250);
        }
    }
}

I'm still experimenting with this and stealing code here and there to try to learn and craft my code.

In the hope this question will serve other coders too, i thx anyone who share some knowledge.

/hat
 
Tring to build a primitive autoequip, i was wandering if we have a way to extract LokiPoe.InGameState.InventoryPanel.PlaceCursorInto.... from WorldItem information, before i build my Enum or Dictionary for it.

(This Code is been leech fro darkbluefirefly QuestPlugin, with little name mod to suit my project)
Code:
Private EquipItem(WorldItem _item)
{
    var InvSlot = LokiPoe.InGameState.InventoryPanel.GetInventoryBySlot(_item.????);        [COLOR="#FF0000"]<----------- How to select the right InventoryPanel from WorldItem proprety?[/COLOR]
    if(!InvSlot .Items.Any())
    {
         var itemtoEquip = LokiPoe.InGameState.InventoryPanel.MainInventory.ContainsItem(_item.Name);
         if itemtoEquip )
         {
             await Coroutines.OpenInventoryPanel();
             var item = LokiPoe.InGameState.InventoryPanel.MainInventory.FindItemByName(_item.Name);
             await Coroutine.Sleep(250);
             LokiPoe.InGameState.InventoryPanel.PickupMainToCursor(item);
             await Coroutine.Sleep(250);
             LokiPoe.InGameState.InventoryPanel.????????     [COLOR="#FF0000"]<----------- How to select the right PlaceCursorOnto from WorldItem proprety?[/COLOR]
             await Coroutine.Sleep(250);
        }
    }
}

I'm still experimenting with this and stealing code here and there to try to learn and craft my code.

In the hope this question will serve other coders too, i thx anyone who share some knowledge.

/hat

Not sure you need the WorldItem wrapper for this, since you're searching it by name.

You're looking for the property that will return the Item Slot? (like Hands, Chest, etc...) it should be visible in the API (supposing you're using VS :x)

Also, I remember that something in the API looks like .PlaceIntoInventorySlot(invSlot, item) just look for that, it's gonna be way easier like this (you're gonna need the hash of the item for that)
 
toNyx, you'r a light in the myst, tnx alot.
As soon as i get home, il browser the API and see what i find.
\hat
 
Not sure you need the WorldItem wrapper for this, since you're searching it by name.

You're looking for the property that will return the Item Slot? (like Hands, Chest, etc...) it should be visible in the API (supposing you're using VS :x)

Also, I remember that something in the API looks like .PlaceIntoInventorySlot(invSlot, item) just look for that, it's gonna be way easier like this (you're gonna need the hash of the item for that)
Hey toNyx,
The Hash won't cut it, it changes when it's equipped and yea.
 
Not sure you need the WorldItem wrapper for this, since you're searching it by name.

You're looking for the property that will return the Item Slot? (like Hands, Chest, etc...) it should be visible in the API (supposing you're using VS :x)

Also, I remember that something in the API looks like .PlaceIntoInventorySlot(invSlot, item) just look for that, it's gonna be way easier like this (you're gonna need the hash of the item for that)

Back home i rushed to seek this call but luckless, i cant find anything like that in the API.

I can find all short of .PlaceCursorIntoRightRing() , .PlaceCursorIntoNeck(), .PlaceCursorIntoChest() ecc ecc..

So i ended up with this Ugliness... writing here for reference and to see if you guys have better ideas.

Code:
public void EuipRightSlot(Item _item, string _ringSide = "Left")
        {
            switch (_item.ItemType)
            {
                case InventoryType.Belt:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoBelt();
                    break;
                case InventoryType.Boots:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoBoots();
                    break;
                case InventoryType.Chest:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoChest();
                    break;
                case InventoryType.Cursor:
                    break;
                case InventoryType.Flasks:
                    break;
                case InventoryType.Gloves:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoGloves();
                    break;
                case InventoryType.Head:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoHead();
                    break;
                case InventoryType.LeftHand:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoLeftHand();
                    break;
                case InventoryType.Main:
                    break;
                case InventoryType.MapDevice:
                    break;
                case InventoryType.Neck:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoNeck();
                    break;
                case InventoryType.RightHand:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoRightHand();
                    break;
                case InventoryType.Rings:
                    if (_ringSide.ToLower() == "left")
                        LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoLeftRing();
                    else
                        LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoRightRing();
                    break;
                case InventoryType.Stash:
                    break;
                default:
                    break;
            }
        }

I'll try to test it tonight and see.

/hat
 
So i found the time to test my code, and everything look working to the point i loot the item i want, open the inventory, pick the item on the coursor....and boom, explode when is time to execute, for example:

Code:
LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoLeftHand();
await Coroutine.Sleep(250);

This command fail and the Log say:
Code:
[OpenInventoryPanel]
[OpenInventoryPanel] The InventoryPanel is not opened. Now opening it.
[ClearCursorTask]
[OpenInventoryPanel]
[ClearCursorTask] The item Rusted Sword needs to be placed into the inventory.
[OpenInventoryPanel]
[ClearCursorTask]
[OpenInventoryPanel]
[ClearCursorTask] The item Rusted Sword needs to be placed into the inventory.
[OpenInventoryPanel]
[ClearCursorTask]
[OpenInventoryPanel]
[ClearCursorTask] The item Rusted Sword needs to be placed into the inventory.
[OpenInventoryPanel]
[ClearCursorTask]

To make sure i was doing it right i tried to Disable Auto-Equip in the Game Setting and launched Quest plugin with a new char, well, the plugin fail the same way, indicating that the weapon is equiped by the Autoequip of the Game Client, not by the API call.

Should i Open i Bug Report?

The entire chunk of code:
Code:
string type = item.Item.ItemType.ToString();
var _objectWeapontoEquip = LokiPoe.InGameState.InventoryPanel.MainInventory.ContainsItem(name);
                    if (_objectWeapontoEquip)
                    {
                        await Coroutines.OpenInventoryPanel();
                        var itemtoeq = LokiPoe.InGameState.InventoryPanel.MainInventory.FindItemByName(name);
                        await Coroutine.Sleep(50);
                        LokiPoe.InGameState.InventoryPanel.PickupMainToCursor(itemtoeq);
                        await Coroutine.Sleep(50);
                        InventoryType _type = (InventoryType)Enum.Parse(typeof(InventoryType), type, true);
                        LevelAssist.Log.InfoFormat("[EquipItem] Put item into inveslot: {0}.", _type.ToString());         [COLOR="#FF0000"]<---- Get to here no problem[/COLOR]
                        EuipRightSlot(_type, RingSide);    [COLOR="#FF0000"]<--- any PlaceCursorIntoxxxx() fail with no error;[/COLOR]
                        await Coroutine.Sleep(250);
                        return false;
                    }
....
public void EuipRightSlot(InventoryType _itemType, string _ringSide = "Left")
        {
            switch (_itemType)
            {
                case InventoryType.Belt:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoBelt();
                    break;
                case InventoryType.Boots:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoBoots();
                    break;
                case InventoryType.Chest:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoChest();
                    break;
                case InventoryType.Cursor:
                    break;
                case InventoryType.Flasks:
                    break;
                case InventoryType.Gloves:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoGloves();
                    break;
                case InventoryType.Head:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoHead();
                    break;
                case InventoryType.LeftHand:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoLeftHand();
                    break;
                case InventoryType.Main:
                    break;
                case InventoryType.MapDevice:
                    break;
                case InventoryType.Neck:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoNeck();
                    break;
                case InventoryType.RightHand:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoRightHand();
                    break;
                case InventoryType.Rings:
                    if (_ringSide.ToLower() == "left")
                        LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoLeftRing();
                    else
                        LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoRightRing();
                    break;
                case InventoryType.Stash:
                    break;
                default:
                    break;
            }
        }


Or i'm i doing it wrong?

pls help.

/hat
 
So i found the time to test my code, and everything look working to the point i loot the item i want, open the inventory, pick the item on the coursor....and boom, explode when is time to execute, for example:

Code:
LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoLeftHand();
await Coroutine.Sleep(250);

This command fail and the Log say:
Code:
[OpenInventoryPanel]
[OpenInventoryPanel] The InventoryPanel is not opened. Now opening it.
[ClearCursorTask]
[OpenInventoryPanel]
[ClearCursorTask] The item Rusted Sword needs to be placed into the inventory.
[OpenInventoryPanel]
[ClearCursorTask]
[OpenInventoryPanel]
[ClearCursorTask] The item Rusted Sword needs to be placed into the inventory.
[OpenInventoryPanel]
[ClearCursorTask]
[OpenInventoryPanel]
[ClearCursorTask] The item Rusted Sword needs to be placed into the inventory.
[OpenInventoryPanel]
[ClearCursorTask]

To make sure i was doing it right i tried to Disable Auto-Equip in the Game Setting and launched Quest plugin with a new char, well, the plugin fail the same way, indicating that the weapon is equiped by the Autoequip of the Game Client, not by the API call.

Should i Open i Bug Report?

The entire chunk of code:
Code:
string type = item.Item.ItemType.ToString();
var _objectWeapontoEquip = LokiPoe.InGameState.InventoryPanel.MainInventory.ContainsItem(name);
                    if (_objectWeapontoEquip)
                    {
                        await Coroutines.OpenInventoryPanel();
                        var itemtoeq = LokiPoe.InGameState.InventoryPanel.MainInventory.FindItemByName(name);
                        await Coroutine.Sleep(50);
                        LokiPoe.InGameState.InventoryPanel.PickupMainToCursor(itemtoeq);
                        await Coroutine.Sleep(50);
                        InventoryType _type = (InventoryType)Enum.Parse(typeof(InventoryType), type, true);
                        LevelAssist.Log.InfoFormat("[EquipItem] Put item into inveslot: {0}.", _type.ToString());         [COLOR="#FF0000"]<---- Get to here no problem[/COLOR]
                        EuipRightSlot(_type, RingSide);    [COLOR="#FF0000"]<--- any PlaceCursorIntoxxxx() fail with no error;[/COLOR]
                        await Coroutine.Sleep(250);
                        return false;
                    }
....
public void EuipRightSlot(InventoryType _itemType, string _ringSide = "Left")
        {
            switch (_itemType)
            {
                case InventoryType.Belt:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoBelt();
                    break;
                case InventoryType.Boots:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoBoots();
                    break;
                case InventoryType.Chest:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoChest();
                    break;
                case InventoryType.Cursor:
                    break;
                case InventoryType.Flasks:
                    break;
                case InventoryType.Gloves:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoGloves();
                    break;
                case InventoryType.Head:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoHead();
                    break;
                case InventoryType.LeftHand:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoLeftHand();
                    break;
                case InventoryType.Main:
                    break;
                case InventoryType.MapDevice:
                    break;
                case InventoryType.Neck:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoNeck();
                    break;
                case InventoryType.RightHand:
                    LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoRightHand();
                    break;
                case InventoryType.Rings:
                    if (_ringSide.ToLower() == "left")
                        LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoLeftRing();
                    else
                        LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoRightRing();
                    break;
                case InventoryType.Stash:
                    break;
                default:
                    break;
            }
        }


Or i'm i doing it wrong?

pls help.

/hat

Do you code in VS? if so, just run with breakpoints, and see how it goes step by step.

Are you calling those methods in the Tick() or Pulse() ?

if so You should consider using tasks.
 
Tnx again for your time toNyx.

Yes, that code is the execute logic in my equip Task.
I spent the evening setting up the debugger and trying few breakpoints and my conclusion is:
LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoxxxx(); Fail miserably, it literally do nothing, also the error reported is:
[EquipItem] Place cursor Error: UnableToEquip

in my exemple this is the result of

Code:
var res = LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoBoots();
LevelAssist.Log.InfoFormat("[EquipItem] Place cursor Error: {0} .", res);

My Task loot the item(work), open the inventory(work), pick the item in the cursor(work), place the item in the right slot(Fail).

I tested it with a new char and with only a weapon in main hand, and with a pair of "Iron Greaves".

You can ease test it using the Questplugin, Try disabling the Auto Equip Option in the game client, and run the plugin with a new char, It fail to equip the first weapon and hang there (i copied most of my code from that task).

Also i see you guys talking about the new version of the Questplugin, and i remember reading about a aotuequip almost ready and missing gem logic (I can feel your pain, really), pls pls how you equip items? can i have a idea pls?

I ask myself if i should open a bug report or not...

/hat
 
Last edited:
Another Exemple of this not working is:

Open EB, goto Dev tab, take the item you have in the boot slot to the cursor and run this code:

Code:
using Loki.Utilities;
using log4net;
using Loki.Game;
using Loki.Bot;

public class RuntimeCode
{
	private static readonly ILog Log = Logger.GetLoggerInstanceForType();

	public void Execute()
	{
		using(LokiPoe.AcquireFrame())
		{
			Loki.Game.LokiPoe.ProcessHookManager.Enable();
			var err = LokiPoe.InGameState.InventoryPanel.PlaceCursorIntoBoots();                  
                        Log.InfoFormat("[EquipItem] Place cursor Error: {0} .", err);
			Loki.Game.LokiPoe.ProcessHookManager.Disable();
		}
	}
}

[EquipItem] Place cursor Error: UnableToEquip .

If i hear nothing when i get back from work i'll open a bug report, i really wish i can continue my plugin and this is indeed a key function.

/hat
 
Last edited:
Update

Sent a PM to pushedx..... 10 mins later the problem is been solved, now my example work perfect, tnx to him.

/hat
 
Update

Sent a PM to pushedx..... 10 mins later the problem is been solved, now my example work perfect, tnx to him.

/hat
Any chance of a quick explanation of where you went wrong and how to fix this issue? Might be useful in the future :) Thanks in advance.
 
Any chance of a quick explanation of where you went wrong and how to fix this issue? Might be useful in the future :) Thanks in advance.

Hi Infinite Monkeys

Basically the code i posted in first and fifth post are both working, now that pushedx fixed the bug.

Now my code is a task (2 task actually, 1 that run while in the wild, equip and upgrade flasks and equip and upgrade obvious items, and one that run after the ID task in town and examine more complex, already identified items) that equip "Better equipment" (i had to make arbitrary decision there but it work pretty well now).

Beside the small code i posted, what i had to fight with really, was all the check i had to do to decide, if i was able to equip the item, still able to use other items and gems once equipped, able to move the gems in the item to remove to some other item or to the item to equip (do it if necessary) ecc ecc.

I offered darkbluefirefly my code to help improve quest plugin and help me debug my code (and maybe enter the quest plugin beta), i'm not a coder in real life (a lumberjack to be true), but recieved no answer for now, probably he is discussing with other testers.

If you need help with a particular part of the code, ill offer my help, ask away, but i'll not release my code to public (made many modifications to many plugins to have my char pattern to level up without my intervention, and it work up to lev 50 (just spending few passive) pretty good now.)

/hat
Alcor75
 
Last edited:
Hi Infinite Monkeys

Basically the code i posted in first and fifth post are both working, now that pushedx fixed the bug.

Now my code is a task (2 task actually, 1 that run while in the wild, equip and upgrade flasks and equip and upgrade obvious items, and one that run after the ID task in town and examine more complex, already identified items) that equip "Better equipment" (i had to make arbitrary decision there but it work pretty well now).

Beside the small code i posted, what i had to fight with really, was all the check i had to do to decide, if i was able to equip the item, still able to use other items and gems once equipped, able to move the gems in the item to remove to some other item or to the item to equip (do it if necessary) ecc ecc.

I offered darkbluefirefly my code to help improve quest plugin and help me debug my code (and maybe enter the quest plugin beta), i'm not a coder in real life (a lumberjack to be true), but recieved no answer for now, probably he is discussing with other testers.

If you need help with a particular part of the code, ill offer my help, ask away, but i'll not release my code to public (made many modifications to many plugins to have my char pattern to level up without my intervention, and it work up to lev 50 (just spending few passive) pretty good now.)

/hat
Alcor75

I offered the solution for a better and "configurable" auto-equip system, based on a scoring method.
It requires someone with a good theorycraftig about the game to make it work fully tho, and afterwards releasing it.
I may start working on something kind of experimental about that kind of behaviors, and do some testing. If you're interested in sharing your code, just lemme know in MP, maybe it could be a good start to be improved & hardened.
 
Back
Top