ScriptUO
Scripting Resources & Utilities => Stealth Client => Topic started by: smitty on November 25, 2017, 11:00:05 PM
-
Hello again!!!
I have a very interesting project that starting to really come together! I am having a real issue with looting certain items from containers (corpses or secures)
does anyone have a class or some examples for looting?
p.s. sorry for 2 posts in a row.
update:
ok after spending a lot of time on this, this is what i have found from my own script, and drabadans autokiller:
so it looks like drabadan uses this event handler to loot the container.
private async void Client_DrawContainer(object sender, DrawContainerEventArgs e)
{
if(e.ModelGump == 9)
{
await Loot(e.ContainerId);
}
}
down in loot the loot function is where im running into issues...
private async Task Loot(uint corpseId)
{
Stealth.Client.FindTypeEx(0xFFFF, 0xFFFF, corpseId, true);
var itemsFound = Stealth.Client.GetFindList();
foreach(var item in itemsFound)
{
bool transfer = false;
if (LootTypes.Contains(Stealth.Client.GetType(item)))
{
transfer = true;
}
if (!transfer)
{
var tooltip = Stealth.Client.GetTooltip(item);
foreach(var tooltipValue in LootTooltipValues)
{
if (tooltip.ToLower().Contains(tooltipValue.ToLower()))
{
transfer = true;
break;
}
}
}
if(transfer)
{
ct = new CancellationTokenSource();
_currMovingItem = item;
await Task.Delay(1000);
//Does not really seem to move items...
Stealth.Client.MoveItem(item, 0, _backpackId, 0, 0, 0);
try
{
await Task.Delay(5000, ct.Token);
}
catch (TaskCanceledException) { }
}
}
lootingQueue.Remove(corpseId);
}
-
in all of that, this is actually what moves the item. Stealth.Client.MoveItem(item, 0, _backpackId, 0, 0, 0); Understand that alot of those variables are set up somewhere else. So just look at the .MoveItem parameter and see what it needs to move the item.
-
public bool MoveItem(uint itemId, int count, uint moveIntoId, int x, int y, int z)
{
if (DragItem(itemId, count))
return DropItem(moveIntoId, x, y, z);
return false;
}
I have a list of uints representing items that i want to loot, we will use Zoogi as an example. The way that i thought you would look for the item is by using 0x26B7. So I added 0x26B7 into the list. Then down in the loot function i have
Stealth.Client.FindTypeEx(0xFFFF, 0xFFFF, corpseId, true);
var itemsFound = Stealth.Client.GetFindList();
if (itemsFound.Count < 1)
{
_messanger.Invoke($"Nothing found in container");
Stealth.Client.Ignore(corpseId);
lootingQueue.Remove(corpseId);
return;
}
_messanger.Invoke($"looting..." + itemsFound.Count);
foreach (var item in itemsFound)
{
bool transfer = false;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (LootTypes.Contains(Stealth.Client.GetType(item)))
{
_messanger.Invoke($"loot type not in list");
transfer = true;
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
.
.
if (transfer)
{
ct = new CancellationTokenSource();
_currMovingItem = item;
_messanger.Invoke($"attempting loot item");
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//try to make item into an Item
Item thisItem = new Item(item);
thisItem.MoveItem(backpack);
//^^^^^^^^^^^^^^^^^^^^^
//Stealth.Client.MoveItem(item, 0, _backpackId, 0, 0, 0);
}
Maybe im getting confused about what uint itemId is...
-
public bool MoveItem(uint itemId, int count, uint moveIntoId, int x, int y, int z)
{
if (DragItem(itemId, count))
return DropItem(moveIntoId, x, y, z);
return false;
}
I have a list of uints representing items that i want to loot, we will use Zoogi as an example. The way that i thought you would look for the item is by using 0x26B7. So I added 0x26B7 into the list. Then down in the loot function i have
Stealth.Client.FindTypeEx(0xFFFF, 0xFFFF, corpseId, true);
var itemsFound = Stealth.Client.GetFindList();
if (itemsFound.Count < 1)
{
_messanger.Invoke($"Nothing found in container");
Stealth.Client.Ignore(corpseId);
lootingQueue.Remove(corpseId);
return;
}
_messanger.Invoke($"looting..." + itemsFound.Count);
foreach (var item in itemsFound)
{
bool transfer = false;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (LootTypes.Contains(Stealth.Client.GetType(item)))
{
_messanger.Invoke($"loot type not in list");
transfer = true;
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
.
.
if (transfer)
{
ct = new CancellationTokenSource();
_currMovingItem = item;
_messanger.Invoke($"attempting loot item");
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//try to make item into an Item
Item thisItem = new Item(item);
thisItem.MoveItem(backpack);
//^^^^^^^^^^^^^^^^^^^^^
//Stealth.Client.MoveItem(item, 0, _backpackId, 0, 0, 0);
}
Maybe im getting confused about what uint itemId is...
This is your finditem Stealth.Client.FindTypeEx(0xFFFF, 0xFFFF, corpseId, true);
So it is looking in the corpse ID for ANYTHING currently. One of the 0xFFFF need to change for a specific item (dont remember which off hand).
-
The way i understood it from drabadans autokiller, Stealth.Client.FindTypeEx(0xFFFF, 0xFFFF, corpseId, true); is searching the corpse for all items, then using a foreach loop to check each item and see if it matches any items in the lootTypes list
thanks for working with me to understand this. I really appreciate the help!
-
OH MY GOD I JUST MOVED ITEMS FROM A CORPSE INTO MY BACKPACK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
Why making it hard? Use Scanner (https://github.com/Crome696/ScriptSDK/blob/master/ScriptSDK/Engines/Scanner.cs) to find Items and then iterate through list and use Move commands (https://github.com/Crome696/ScriptSDK/blob/master/ScriptSDK/Model/Items/Item.cs).
That way it also subchecks certain things and handle most stuff fully automaticly. I actually dont understand why people use the stealth.client logics when there is a full framework of objects and models, enginges, parser and components to handle stuff dynamicly
*facepalm*
-
Hey !
Hello again!!!
I have a very interesting project that starting to really come together!
what are you cooking for us ?
-
Currently working on something that fully automates all parts of trans powder / bags of sending / zoogi collecting. Future plans for doom gauntlet automation. I wrote the gauntlet script for easyuo ... stealth can make it much much nicer, I just have to learn everything about stealth (dont know that ill release any of these) heheh.
-
Currently working on something that fully automates all parts of trans powder / bags of sending / zoogi collecting. Future plans for doom gauntlet automation. I wrote the gauntlet script for easyuo ... stealth can make it much much nicer, I just have to learn everything about stealth (dont know that ill release any of these) heheh.
ahhhhh sad. We are in need of more Stealth Scripts in the library. Totally understand why such a script would be held closer to the chest though.
-
Well I am doing everything I can do to learn. Suggest some things for me and ill take a look at things i can try to share!
Also... I've been working on some stuff in my free time, and i think i am starting to really get the hang of this looting stuff! I am running into a slight error though
this is the body of my loot function:
var itemsInCorpse = Scanner.Find<Item>(LootTypes, corpse.Serial.Value, true);
if(!(itemsInCorpse.Count < 1))
{
for (int i = 0; i < itemsInCorpse.Count; i++)
{
if (itemsInCorpse[i] == null)
continue;
_messanger.Invoke($"looting {itemsInCorpse[i].Serial.Value}");
if (itemsInCorpse[i].Amount > 0)
{
//moving stackable items
_messanger.Invoke($"looting {itemsInCorpse[i].Amount}");
itemsInCorpse[i].MoveItem(_player.Backpack, itemsInCorpse[i].Amount);
Stealth.Client.Wait(900);
}
else
{
//moving single item
itemsInCorpse[i].MoveItem(_player.Backpack);
}
Stealth.Client.Wait(1000);
}
}
Im running into a warning in the StealthClient.cs file while running in debug mode on line 243: packet = _replyes.Dequeue();
after each item looted i get this warning. When i view the details, its saying that the queue is empty
An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll
details: {"Queue empty."}
forgot to mention i am using stealth v8.5.4