Author Topic: [py] PVE Bot with Zone Restrictions (Fan Dancer example)  (Read 11091 times)

0 Members and 1 Guest are viewing this topic.

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
[py] PVE Bot with Zone Restrictions (Fan Dancer example)
« on: October 02, 2020, 08:31:52 AM »
0
SOURCE:
Located under repo https://github.com/unisharpUO/StealthUO-Scripts
  • DancerDojo.py
  • helpers.py
  • py_stealth

DancerDojo Example:
This script will sit within given coordinates, use Honor virtue and kill Fan Dancers, alert when a player is near, use confidence when needed, use primary ability when plenty of mana is available, loot corpses for +20 splintering non-cursed non-antique weapons.  It also insures the item.

Line 14 DancerDojo.py (commented)
Code: [Select]
# entrance 79, 97, 326, 344 - bloodyroom 104, 115, 640, 660These are 2 different zone examples, the "bloody room" is like 3rd floor. 

There are 2 coordinate checks:

Line 101 DancerDojo.py
Code: [Select]
            if 79 <= GetX(_monsters[0]) <= 97 and\
                    326 <= GetY(_monsters[0]) <= 344:
This part tells the bot to only set targets to monsters within this range.  If an already set target roams without this range, the bot will continue to follow it and kill it.

Line 128 DancerDojo.py
Code: [Select]
                    if 79 <= GetX(_corpse) <= 97 and\
                            326 <= GetY(_corpse) <= 344:
Unfortunatley if something roams out of the box and dies, it's not looted.  I added this because someone was farming in a room near me and the bot would run over to him periodically and try and loot his corpses.  This ensures that only corpses looted are those within the zone.

LOOTING:
This is rather easy to change.
Code: [Select]
def LootCorpse(_corpse):
    UseObject(_corpse)
    Wait(1500)
    _lootList = NewFind([0xFFFF], [0xFFFF], [_corpse], True)
    for _loot in _lootList:
        _tooltipRec = GetTooltipRec(_loot)
        if GetParam(_tooltipRec, 1112857) >= 20 and not\
                ClilocIDExists(_tooltipRec, 1152714) and not\
                ClilocIDExists(_tooltipRec, 1049643):
            AddToSystemJournal(f'Looting Item: {_loot}')
            MoveItem(_loot, 1, LootBag, 0, 0, 0)
            InsureItem(_loot)
    return

Those ClilocID's - 1112857, 11152714, 1049643 represent splintering, antique, cursed - respectively.

You can pull codes from here: https://github.com/unisharpUO/XScript/blob/6e885f0bb4b763d599b10ed0ca71e9b3e3da8aa1/XScript/Core/Attributes/WeaponAttributes.cs and here https://github.com/unisharpUO/XScript/blob/6e885f0bb4b763d599b10ed0ca71e9b3e3da8aa1/XScript/Core/Extensions/Extensions.cs and here https://github.com/unisharpUO/XScript/blob/6e885f0bb4b763d599b10ed0ca71e9b3e3da8aa1/XScript/Core/Attributes/MagicalAttributes.cs

With this information you should be able to easily create your own loot filters.


HEALING:
The only method I added was for confidence:

Line 115 DancerDojo.py
Code: [Select]
        if GetHP(Self()) <= 90 and not Confidence:
            Cast('Confidence')

Line 28 DancerDojo.py
Code: [Select]
def OnClilocSpeech(_param1, _param2, _param3, _message):
    global Confidence
    if 'exude' in _message:
        Confidence = True
    elif 'wanes' in _message:
        Confidence = False
    return

This checks for when confidence is actually up/down and will use confidence if it's not already up (and below 90 hp)

I'll add more areas upon request.

Offline daymorn

  • Jr. Member
  • **
  • Posts: 21
  • Activity:
    0%
  • Reputation Power: 1
  • daymorn has no influence.
  • Respect: +3
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #1 on: October 05, 2020, 11:17:55 AM »
+1
This is great. I've been hoping for a current, python based script and this has tons of different examples that could be used for different use cases in it. Thank you.

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #2 on: October 07, 2020, 06:22:47 AM »
0

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #3 on: October 13, 2020, 10:14:35 AM »
0
commit pushed 10/13 - updated monster search

Offline dawids212

  • Restricted
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • dawids212 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #4 on: December 05, 2020, 11:37:48 AM »
0
is possible to add section for loot jewelery with ssi or other atributes?

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #5 on: December 14, 2020, 08:40:38 AM »
0
is possible to add section for loot jewelery with ssi or other atributes?

It's 100% possible with the short documentation posted above and a little bit of python knowledge.  What are you having trouble with?

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #6 on: December 14, 2020, 08:51:27 AM »
0
Let's break down the loot method

Code: [Select]
    UseObject(_corpse)
    Wait(1500)
Opens the corpse and waits (for the corpse to open, and using object timers)

Code: [Select]
_lootList = NewFind([0xFFFF], [0xFFFF], [_corpse], True)Find every item on the corpse

Code: [Select]
    for _loot in _lootList:
        _tooltipRec = GetTooltipRec(_loot)
Loop through every item and get its tooltip records

Code: [Select]
        if GetParam(_tooltipRec, 1112857) >= 20 and not\
                ClilocIDExists(_tooltipRec, 1152714) and not\
                ClilocIDExists(_tooltipRec, 1049643):
Each ClilocID represents a property on the item.  Use the links in post 1 to determine what ClilocIDs you want to filter.  This one in particular is filtering for 20 or greater splintering, not antique, not cursed

You can use 2 methods here: GetParam to get the property value of the ClilocID, if the property has a value.  If the property has no value, such as Cursed or Brittle, then you can use ClilocIDExists.

Code: [Select]
            AddToSystemJournal(f'Looting Item: {_loot}')
            MoveItem(_loot, 1, LootBag, 0, 0, 0)
            InsureItem(_loot)
Log the item in the system journal for notification, move the item to your loot bag and insure it.

With this information, you should be able to create your own loot filters.

Code: [Select]
    UseObject(_corpse)
    Wait(1500)
    _lootList = NewFind([0xFFFF], [0xFFFF], [_corpse], True)
    for _loot in _lootList:
        _tooltipRec = GetTooltipRec(_loot)
        if GetParam(_tooltipRec, 1060486) >= 10:
            AddToSystemJournal(f'Looting Item: {_loot}')
            MoveItem(_loot, 1, LootBag, 0, 0, 0)
            InsureItem(_loot)
This will loot anything with 10 SSI or greater, for example.
« Last Edit: December 14, 2020, 08:59:46 AM by unisharp »

Offline dawids212

  • Restricted
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • dawids212 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #7 on: December 15, 2020, 10:22:45 AM »
0
Thank you for your answer.  To loot every item I was edited by self. Its not very complicated.

But is possible that one parte of script looking for 20% weapon and second part of script looking for only jewelery ? with for example ssi and enchanced potions except cursed  ?

in this part of code, script looking for any item. How change it to looking for jewels only ?
Code: [Select]
_lootList = NewFind([0xFFFF], [0xFFFF], [_corpse], True)
where i can find item id of rings bracelets like this
Code: [Select]
([0xFFFF]
For splintering weapon script work great. Sometimes i died but its normal.
With connection with easyuo gold looter + bag of sending its perfect.

You did good job.

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #8 on: December 16, 2020, 07:46:44 AM »
0
Yes, you can do this with a bit of work.  The problem is there is no pre-existing definition of armor types, weapon types, jewelry types, etc.  You have to collect them and store them in an array.

What you'd need to do is collect every object type identifier and store them in an array, then you can use that in the find function:

Code: [Select]
ArmorTypes = [0x1415, 0x1416, 0x13db, 0x13e2]

_lootList = NewFind(ArmorTypes, [0xFFFF], [_corpse], True)

0x1415, 0x1416 = Plate Chest facing either direction
0x13db, 0x13e2 = Studded Chest facing either direction

etc...

To make things easier you can grab item types from either the ServUO Github repository or my XScript repo:
https://github.com/unisharpUO/XScript/blob/cd06adcb83a5626f5f9c51b1c9f2bca805628639/XScript/Distro/Items/Armor/BaseChest.cs
for example...
« Last Edit: December 16, 2020, 07:48:37 AM by unisharp »

Offline daymorn

  • Jr. Member
  • **
  • Posts: 21
  • Activity:
    0%
  • Reputation Power: 1
  • daymorn has no influence.
  • Respect: +3
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #9 on: December 16, 2020, 01:46:52 PM »
0
I remember jewelry pissing me off because I didn't want to make a list of every type ID, and I never could find a pattern in the name parameter that easily covered every ring & bracelet due to the magic prefix & suffix crap.

If you check parameters, like Unisharp is doing
Code: [Select]
if GetParam(_tooltipRec, 1112857) >= 20 and not\, but use it for both accepting and filtering properties you can end up selecting jewelry by making sure it doesn't have the strength requirement parameter. No jewelry will ever have that parameter.

So you can end up making loot lists like this.
Code: [Select]
"ssi jewelry": {                                                                                                       
    "props": {
        "ssi 10": {"1060486": ["10"]},
        "stam 8": {"1060484": ["8"]}
    }, 
    "filters": {
        "antique": {"1152714": []},
        "cursed": {"1049643": []},
        "strength req": {"1061170": []}
    }                                                                                                 
},                                                                                                },

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #10 on: December 17, 2020, 06:30:53 AM »
0
There are not that many object types for jewelry...

We can see here...
https://github.com/unisharpUO/XScript/blob/cd06adcb83a5626f5f9c51b1c9f2bca805628639/XScript/Distro/Items/Jewels/BaseJewel.cs

Code: [Select]
[QueryType(typeof (BaseNecklace), typeof (BaseRing), typeof (BaseEarring), typeof (BaseBracelet))]
    public class BaseJewel : Item, IJewel

BaseJewel has nested types BaseNecklace, BaseRing, BaseEarring, and BaseBracelet.  All we need is BaseRing and BaseBracelet, so let's look at those....

https://github.com/unisharpUO/XScript/blob/cd06adcb83a5626f5f9c51b1c9f2bca805628639/XScript/Distro/Items/Jewels/Rings.cs

Code: [Select]
[QueryType(typeof (HumanRing), typeof (GargishRing))]
    public class BaseRing : BaseJewel

BaseRing has nested types HumanRing and Gargish Ring....

Code: [Select]
    [QuerySearch(new ushort[] {0x108A, 0x1F09})]
    public class HumanRing : BaseRing

HumanRing has types 0x108A, 0x1F09

Code: [Select]
    [QuerySearch(0x4212)]
    public class GargishRing : BaseRing

GargishRing has types 0x4212

Rings = [0x108A, 0x1F09, 0x4212]
done

let's do bracelets now
https://github.com/unisharpUO/XScript/blob/cd06adcb83a5626f5f9c51b1c9f2bca805628639/XScript/Distro/Items/Jewels/Bracelet.cs

Code: [Select]
[QueryType(typeof (HumanBracelet), typeof (GargishBrace))]
    public class BaseBracelet : BaseJewel

Same thing... HumanBracelet and GargishBrace

Code: [Select]
    [QuerySearch(new ushort[] {0x1086, 0x1F06})]
    public class HumanBracelet : BaseBracelet

Code: [Select]
    [QuerySearch(0x4211)]
    public class GargishBrace : BaseBracelet

Braclets = [0x1086, 0x1F06, 0x4211]

now combine them

Jewlery = [0x108A, 0x1F09, 0x4212, 0x1086, 0x1F06, 0x4211]

Now you have a set of jewelry types to search for.

It's just going to be harder with armor/weapons because there are more types.

There are now links in this thread that will help you:
  • Find the required ClilocIDs needed for parsing parameters
  • Find object types to parse
« Last Edit: December 17, 2020, 06:33:16 AM by unisharp »

Offline daymorn

  • Jr. Member
  • **
  • Posts: 21
  • Activity:
    0%
  • Reputation Power: 1
  • daymorn has no influence.
  • Respect: +3
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #11 on: December 17, 2020, 07:59:55 AM »
0
"It's just going to be harder with armor/weapons because there are more types." <== This sums up the whole problem. You start doing it for one type, then you start doing it for everything. You are right though, since the more complex the script gets, the more likely you will need a giant list of all the type IDs.

Offline dawids212

  • Restricted
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • dawids212 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #12 on: December 21, 2020, 05:06:49 AM »
0
Thx for answers.

Im not programmer so is hard to edit for me.

im tried something like this. Client not showing error but script not loot rings not cursed enhancepotions 20+

Part with loot looks like this. Im trying many combinations _loot, _lootlist1, _loot, lootlist, etc. but not work. (part with splintering work well)

Code: [Select]
def LootCorpse(_corpse):
    UseObject(_corpse)
    Wait(1500)
    _lootList = NewFind([0xFFFF], [0xFFFF], [_corpse], True)
    for _loot in _lootList:
        _tooltipRec = GetTooltipRec(_loot)
        if GetParam(_tooltipRec, 1112857) >= 20 and not\
                ClilocIDExists(_tooltipRec, 1152714) and not\
                ClilocIDExists(_tooltipRec, 1049643):
            AddToSystemJournal(f'Looting Item: {_loot}')
            MoveItem(_loot, 1, LootBag, 0, 0, 0)
            InsureItem(_loot)
    _lootList1 = NewFind([0x108A, 0x1F09, 0x4212, 0x1086, 0x1F06, 0x4211], [0x108A, 0x1F09, 0x4212, 0x1086, 0x1F06, 0x4211], [_corpse], True)
    for _loot1 in _lootList1:
        _tooltipRec = GetTooltipRec(_loot1)
        if GetParam(_tooltipRec, 1060411) >= 20 and not\
                ClilocIDExists(_tooltipRec, 1049643):
            AddToSystemJournal(f'Looting Item: {_loot}')
            MoveItem(_loot1, 1, LootBag, 0, 0, 0)
            InsureItem(_loot1)
    return


if is not problem for you, could you show me how to edit this without programing knowlege ?

My another proposition is add to this script gold looter with automatic send when it reach 95% max weight by "bag of sending"

With this addons your script will be total afk gold and item farmer :) But i dont know if is possible.

Waiting for your reply.

Merry Christmas!

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #13 on: December 21, 2020, 05:17:02 AM »
0
Code: [Select]
_lootList1 = NewFind([0x108A, 0x1F09, 0x4212, 0x1086, 0x1F06, 0x4211], [0xFFFF], [_corpse], True)
Merry Christmas


NewFind(Array of types, Array of colors, Array of containers, Search Subcontainers?)


0xFFFF specifies anything/everything.
« Last Edit: December 21, 2020, 05:18:53 AM by unisharp »

Offline dawids212

  • Restricted
  • *
  • Posts: 9
  • Activity:
    0%
  • Reputation Power: 1
  • dawids212 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [py] PVE Bot with Zone Restrictions (Fan Dancer example)
« Reply #14 on: December 21, 2020, 05:26:20 AM »
0
Code: [Select]
_lootList1 = NewFind([0x108A, 0x1F09, 0x4212, 0x1086, 0x1F06, 0x4211], [0xFFFF], [_corpse], True)
Merry Christmas


NewFind(Array of types, Array of colors, Array of containers, Search Subcontainers?)


0xFFFF specifies anything/everything.

It is work!! Thanks :)

Tags: