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

0 Members and 1 Guest are viewing this topic.

Offline unisharpTopic starter

  • Full Member
  • ***
  • Posts: 189
  • Activity:
    0.4%
  • 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 #15 on: December 21, 2020, 05:28:03 AM »
0
I'll make a snippet example for gold/sending in another thread when it's ready.

Offline unisharpTopic starter

  • Full Member
  • ***
  • Posts: 189
  • Activity:
    0.4%
  • 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 #16 on: December 21, 2020, 09:41:04 AM »
0
12-21-20 Changes:
  • If bag of sending exists in backpack, enable good looting
  • If weight is equal to or over limit, send gold to bank

Commits:
https://github.com/unisharpUO/StealthUO-Scripts/commit/8222629a4fabbd68fbccf6a5ff77e07a805c7714
https://github.com/unisharpUO/StealthUO-Scripts/commit/9cb81e70c2f2e25cceb28cab1fe8aef4839f80b3
« Last Edit: December 21, 2020, 09:44:20 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 #17 on: December 21, 2020, 10:29:23 AM »
0
i need to change name of sending bag to

Code: [Select]
if __name__ == '__main__':
    global BagofSendingBag

but still not looting gold to backpack from corpose.
« Last Edit: December 21, 2020, 10:31:58 AM by dawids212 »

Offline unisharpTopic starter

  • Full Member
  • ***
  • Posts: 189
  • Activity:
    0.4%
  • 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 #18 on: December 21, 2020, 12:02:24 PM »
0
i need to change name of sending bag to

Code: [Select]
if __name__ == '__main__':
    global BagofSendingBag

but still not looting gold to backpack from corpose.

Just remove that delete that line alltogether

delete 'global BafofSendingBag'
« Last Edit: December 21, 2020, 12:05:24 PM 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 #19 on: December 21, 2020, 12:45:06 PM »
0
i have errors.

Code: [Select]
22:41:25:992 []: Traceback (most recent call last):

22:41:25:994 []:   File "C:\Users\pc\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main

22:41:25:994 []:     return _run_code(code, main_globals, None,

22:41:25:995 []:   File "C:\Users\pc\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code

22:41:25:995 []:     exec(code, run_globals)

22:41:25:996 []:   File "C:\Users\pc\Desktop\stelth\py_stealth\__main__.py", line 80, in <module>

22:41:25:998 []:     main()

22:41:25:998 []:   File "C:\Users\pc\Desktop\stelth\py_stealth\__main__.py", line 59, in main

22:41:25:999 []:     module = __import__(os.path.splitext(filename)[0])

22:41:25:999 []:   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load

22:41:26:000 []:   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked

22:41:26:001 []:   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked

22:41:26:002 []:   File "C:\Users\pc\Desktop\stelth\py_stealth\py34.py", line 33, in exec_module

22:41:26:003 []:     exec(code, module.__dict__)

22:41:26:004 []:   File "C:\Users\pc\Desktop\DancerDojo.py", line 167, in <module>

22:41:26:004 []:     LootCorpse(_corpse)

22:41:26:005 []:   File "C:\Users\pc\Desktop\DancerDojo.py", line 55, in LootCorpse

22:41:26:005 []:     _count = Count(_loot)

22:41:26:007 []:   File "C:\Users\pc\Desktop\stelth\py_stealth\methods.py", line 3022, in Count

22:41:26:008 []:     FindType(ObjType, Backpack())

22:41:26:008 []:   File "C:\Users\pc\Desktop\stelth\py_stealth\methods.py", line 1480, in FindType

22:41:26:010 []:     return _find_graphic(ObjType, 0xFFFF, Container, False)

22:41:26:011 []:   File "C:\Users\pc\Desktop\stelth\py_stealth\_protocol.py", line 171, in __call__

22:41:26:011 []:     data += cls(val).serialize()

22:41:26:012 []:   File "C:\Users\pc\Desktop\stelth\py_stealth\_datatypes.py", line 32, in serialize

22:41:26:014 []:     return struct.pack(self.fmt, self)

22:41:26:015 []: struct.error: ushort format requires 0 <= number <= 0xffff


and this is my whole script.

Code: [Select]
from py_stealth import *
from helpers import *
from datetime import datetime


Confidence = False
FanDancer = 0x0F7
Corpse = 0x2006
LootBag = 0
SendingBag = 0
PlayerTypes = [183, 184, 185, 186, 400, 401, 402, 403, 605, 606, 607, 608, 666,
               667, 694, 695, 750, 751, 970]


# entrance 79, 97, 326, 344 - bloodyroom 104, 115, 640, 660
def OnDrawObject(_objID):
    if _objID != Self():
        if GetType(_objID) in PlayerTypes:
            _tooltipRec = GetTooltipRec(_objID)
            if len(_tooltipRec) > 0:
                if _tooltipRec[0]['Cliloc_ID'] == 1050045:
                    _name = _tooltipRec[0]['Params'][1]
                    _now = datetime.now()
                    _now = _now.strftime("%m/%d/%Y %H:%M:%S")
                    AddToSystemJournal(f'Player Found: {_name} at {_now}')
    return


def OnClilocSpeech(_param1, _param2, _param3, _message):
    global Confidence
    if 'exude' in _message:
        Confidence = True
    elif 'wanes' in _message:
        Confidence = False
    return


def CheckWeight():
    if (Weight() >= MaxWeight()) and (SendingBag != 0):
        if FindTypeEx(0x0EED, 0xFFFF, Backpack(), True):
            _gold = GetFoundList()
            UseObject(SendingBag)
            Wait(1500)
            WaitTargetObject(_gold[0])
        else:
            AddToSystemJournal("I'm overweight and I can't find gold to send..")


def LootCorpse(_corpse):
    UseObject(_corpse)
    Wait(1500)
    _lootList = NewFind([0xFFFF], [0xFFFF], [_corpse], True)
    for _loot in _lootList:
        if (GetType(_loot) == 0x0EED) and (SendingBag != 0):
            _count = Count(_loot)
            MoveItem(_loot, _count, LootBag, 0, 0, 0)
        else:
            _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], [0xFFFF], [_corpse], True)
    for _loot1 in _lootList1:
        _tooltipRec = GetTooltipRec(_loot1)
        if GetParam(_tooltipRec, 1060411) >= 20 and not\
                ClilocIDExists(_tooltipRec, 1049643):
            AddToSystemJournal(f'Looting Item: {_loot1}')
            MoveItem(_loot1, 1, LootBag, 0, 0, 0)
            InsureItem(_loot1)
    return


def InsureItem(_item):
    Wait(250)
    RequestContextMenu(Self())
    _i = 0
    for _menuItem in GetContextMenu().splitlines():
        if "Toggle Item Insurance" in _menuItem:
            SetContextMenuHook(Self(), _i)
            Wait(250)
            WaitTargetObject(_item)
            Wait(250)
            CancelMenu()
        else:
            _i += 1
            AddToSystemJournal("Couldn't find insure menu item.")
    CancelAllMenuHooks()
    CancelTarget()
    return


if __name__ == '__main__':
   
    SetEventProc('evclilocspeech', OnClilocSpeech)
    SetEventProc('evdrawobject', OnDrawObject)
    SetFindDistance(20)
    SetFindVertical(20)
    SetDropDelay(850)
    UseObject(Backpack())
    Wait(850)
    if FindTypesArrayEx([0x0E76], [0xFFFF], [Backpack()], True):
        _bags = GetFindedList()
        for _bag in _bags:
            # make sure they are bags of sending
            if 'sending' in GetTooltip(_bag).split('|')[0]:
                AddToSystemJournal("Found bag of sending...")
                SendingBag = _bag
    Wait(850)
    _ignoreList = NewFind([0xFFFF], [0xFFFF], [Backpack()], True)
    for _ignoreItem in _ignoreList:
        Ignore(_ignoreItem)
    AddToSystemJournal('Target your loot bag...')
    LootBag = RequestTarget()
    UseObject(LootBag)
    _monsters = []
    _corpses = []
    _currentTarget = 0

    while True:
        ClearBadLocationList()

        while not Connected():
            Connect()
            Wait(10000)

        CheckWeight()

        _monsters = NewFind([FanDancer], [0xFFFF], [0x0], False)

        # entrance 79, 97, 326, 344 - bloodyroom 104, 115, 640, 660
        if (_currentTarget == 0 and len(_monsters) > 0) or\
                (len(_monsters) > 0 and _currentTarget != 0 and
                 not IsObjectExists(_currentTarget)):
            if 79 <= GetX(_monsters[0]) <= 97 and\
                    326 <= GetY(_monsters[0]) <= 344:
                _currentTarget = _monsters[0]
                AddToSystemJournal(f'Current Target: {_currentTarget}')
                ReqVirtuesGump()
                UseVirtue('honor')
                WaitTargetObject(_currentTarget)
                Attack(_currentTarget)

        if _currentTarget != 0 and IsObjectExists(_currentTarget):
            NewMoveXY(GetX(_currentTarget), GetY(_currentTarget), False, 1,
                      True)
            Attack(_currentTarget)

        if GetHP(Self()) <= 90 and not Confidence:
            Cast('Confidence')

        if GetMana(Self()) >= 40:
            UsePrimaryAbility()

        _corpses = NewFind([Corpse], [0xFFFF], [0x0], False)
        if len(_corpses) > 0:
            for _corpse in _corpses:
                if GetDistance(_corpse) < 3:
                    LootCorpse(_corpse)
                    Ignore(_corpse)
                else:
                    if 79 <= GetX(_corpse) <= 97 and\
                            326 <= GetY(_corpse) <= 344:
                        NewMoveXY(GetX(_corpse), GetY(_corpse), True, 0, True)
                        LootCorpse(_corpse)
                        Ignore(_corpse)
        Wait(1000)
« Last Edit: December 21, 2020, 12:48:52 PM by dawids212 »

Offline unisharpTopic starter

  • Full Member
  • ***
  • Posts: 189
  • Activity:
    0.4%
  • 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 #20 on: December 22, 2020, 04:52:27 AM »
0
12/22/20 - Updated Find methods, added corpse ignore list, fixed quantity error

- Tested

Commit pushed to Github

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 #21 on: December 22, 2020, 10:02:15 AM »
0
Tested! Work!

Big Thanks :)


« Last Edit: December 22, 2020, 10:32:44 AM by dawids212 »

Tags: