Author Topic: [c# and scriptSDK] looting  (Read 178 times)

0 Members and 1 Guest are viewing this topic.

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    2.2%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
[c# and scriptSDK] looting
« on: November 25, 2017, 11:00:05 PM »
0
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.
Code: [Select]
        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...
Code: [Select]
        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);
        }

« Last Edit: November 26, 2017, 05:01:44 PM by smitty »

Offline Tidus

  • RebirthUO - Developer
  • Administrator
  • *
  • *
  • Posts: 1145
  • Activity:
    1.6%
  • Reputation Power: 12
  • Tidus barely matters.Tidus barely matters.
  • Gender: Male
  • Self Proclaimed crème de la crème
  • Respect: +2
  • Referrals: 2
    • View Profile
    • Ultimate Apparel
Re: [c# and scriptSDK] looting
« Reply #1 on: November 27, 2017, 06:08:44 AM »
0
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.
For those who have fought for it, freedom has a taste the protected will never know – Anonymous, Vietnam, 1968

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    2.2%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [c# and scriptSDK] looting
« Reply #2 on: November 27, 2017, 03:20:44 PM »
0
Code: [Select]
        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
Code: [Select]
            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...
« Last Edit: November 27, 2017, 03:22:44 PM by smitty »

Offline Tidus

  • RebirthUO - Developer
  • Administrator
  • *
  • *
  • Posts: 1145
  • Activity:
    1.6%
  • Reputation Power: 12
  • Tidus barely matters.Tidus barely matters.
  • Gender: Male
  • Self Proclaimed crème de la crème
  • Respect: +2
  • Referrals: 2
    • View Profile
    • Ultimate Apparel
Re: [c# and scriptSDK] looting
« Reply #3 on: November 27, 2017, 03:30:53 PM »
0
Code: [Select]
        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
Code: [Select]
            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). 



For those who have fought for it, freedom has a taste the protected will never know – Anonymous, Vietnam, 1968

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    2.2%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [c# and scriptSDK] looting
« Reply #4 on: November 27, 2017, 03:34:39 PM »
0
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!

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    2.2%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [c# and scriptSDK] looting
« Reply #5 on: November 27, 2017, 03:54:19 PM »
0
OH MY GOD I JUST MOVED ITEMS FROM A CORPSE INTO MY BACKPACK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Offline Crome969

  • RebirthUO - Developer
  • Moderator
  • *
  • *****
  • Posts: 2067
  • Activity:
    0.6%
  • Reputation Power: 24
  • Crome969 might someday be someone...Crome969 might someday be someone...Crome969 might someday be someone...Crome969 might someday be someone...
  • Gender: Male
  • StealthUO - Developer
  • Respect: 0
  • Referrals: 9
    • View Profile
    • RebirthUO - UO Freeshard
Re: [c# and scriptSDK] looting
« Reply #6 on: November 27, 2017, 11:15:49 PM »
0
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*

Offline bendel

  • Full Member
  • ***
  • Posts: 154
  • Activity:
    2.2%
  • Reputation Power: 3
  • bendel has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [c# and scriptSDK] looting
« Reply #7 on: November 28, 2017, 11:33:20 AM »
0
Hey !

Hello again!!!
I have a very interesting project that starting to really come together!

what are you cooking for us ?   

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    2.2%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [c# and scriptSDK] looting
« Reply #8 on: December 01, 2017, 01:53:13 PM »
0
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.

Offline Tidus

  • RebirthUO - Developer
  • Administrator
  • *
  • *
  • Posts: 1145
  • Activity:
    1.6%
  • Reputation Power: 12
  • Tidus barely matters.Tidus barely matters.
  • Gender: Male
  • Self Proclaimed crème de la crème
  • Respect: +2
  • Referrals: 2
    • View Profile
    • Ultimate Apparel
Re: [c# and scriptSDK] looting
« Reply #9 on: December 06, 2017, 08:50:03 AM »
0
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.
For those who have fought for it, freedom has a taste the protected will never know – Anonymous, Vietnam, 1968

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    2.2%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [c# and scriptSDK] looting
« Reply #10 on: December 06, 2017, 03:04:55 PM »
0
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:
Code: [Select]
            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
« Last Edit: December 11, 2017, 06:32:32 PM by smitty »

Tags: