Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Looting items
Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Looting items

  1. #1
    Member
    Join Date
    May 2013
    Location
    Florida
    Posts
    54

    Looting items

    Code:
    Private Sub Lootitems()
            For Each body As Container In inventory.GetContainers
                For Each loooot As Item In inventory.GetItems
                    For Each poo As LootItem In ListBox3.Items
                        If poo.Text = loooot.Id Then
                            For Each bp As Container In inventory.GetContainers
                                If poo.BP = bp.Name Then
                                    tobp.ContainerId = bp.Id
                                    loooot.Move(tobp)
                                End If
                            Next
                        End If
                    Next
                Next
            Next
        End Sub
    What do I change to make the looter move the items into the selected backpack, and also, what do I do to make the bot open bodies when a creature is killed?

  2. #2
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723
    I was going to try to help, but your code...I don't know what's going on.

  3. #3
    Senior Member
    Join Date
    Dec 2011
    Posts
    249
    Well the way I see it you're heading in the right way. Consider skipping the "body" containers which does not contain 'dead', 'slain' etc. in their container names. Cause of right now you will get stuck trying to move a item which has already been looted.

    To find corpses to open loop through the Battlelist checking for creatures which have 0 health, save their last known location and open it using the input method of your choice.

  4. #4

  5. #5
    Member
    Join Date
    May 2013
    Location
    Florida
    Posts
    54
    Quote Originally Posted by ottizy View Post
    Well the way I see it you're heading in the right way. Consider skipping the "body" containers which does not contain 'dead', 'slain' etc. in their container names. Cause of right now you will get stuck trying to move a item which has already been looted.

    To find corpses to open loop through the Battlelist checking for creatures which have 0 health, save their last known location and open it using the input method of your choice.
    Well, at least you know what's going on :P
    I'll try that. I also have a problem with moving the items to the selected bp, even when it's not a dead body or anything.
    For Jo3 and Farsa, I guess I'll comment my code:

    Quote Originally Posted by poopsiedoodle View Post
    Code:
    Private Sub Lootitems()
            For Each body As Container In inventory.GetContainers
    'checks for dead bodies
                For Each loooot As Item In inventory.GetItems
    'used pretty soon to check for items in the dead bodies
                    For Each poo As LootItem In ListBox3.Items
    'LootItem is an item in the listbox which I made a custom class for so I could give it a tag, which stores the bp name to put the item in
                        If poo.Text = loooot.Id Then
    'checks to see if the itemid is the same as the text property of the lootitem
                            For Each bp As Container In inventory.GetContainers
    'checks for open backpacks
                                If poo.BP = bp.Name Then
    'checks to see if the name of the backpack is the same as the tag of the lootitem
                                    tobp.ContainerId = bp.Id
    'sets the id of the bp
                                    loooot.Move(tobp)
    'moves the item
                                End If 'lots of end ifs and nexts
                            Next
                        End If
                    Next
                Next
            Next
        End Sub

  6. #6
    Senior Member
    Join Date
    Dec 2011
    Posts
    249
    Quote Originally Posted by poopsiedoodle View Post
    Well, at least you know what's going on :P
    I'll try that. I also have a problem with moving the items to the selected bp, even when it's not a dead body or anything.
    Is your Move method working?

  7. #7
    Member
    Join Date
    May 2013
    Location
    Florida
    Posts
    54
    Quote Originally Posted by ottizy View Post
    Is your Move method working?
    probably; I think I know the problem with it. I put a number before the bp name when I assign the bp to the item, but I don't change the actual bp's name. So, that's probably why it's not moving. And, would something like this work?

    Code:
    Private Function Lootitems()
            My.Settings.deadlocs.Clear()
            For Each dead As Creature In c.BattleList.GetCreatures
                If dead.HPBar = 0 Then
                    My.Settings.deadlocs.Add(dead.Location.ToString)
                    For Each bodyloc As String In My.Settings.deadlocs
                        For Each square As Tile In c.Map.GetTiles
                            If square.Location.ToString = bodyloc Then
                                For Each deadbody As Item In square.Items
                                    If deadbody.Name.Contains("Dead") Or deadbody.Name.Contains("Slain") Or deadbody.Name.Contains("Remains") Then
                                        p.Walk(bodyloc)
                                        c.Inventory.UseItemOnTile(deadbody.Id, square)
                                    End If
                                Next
                            End If
                        Next
                    Next
                End If
            Next
    
            For Each body As Container In inventory.GetContainers
                If body.Name.Contains("Dead") Or body.Name.Contains("Slain") Or body.Name.Contains("Remains") Then
                    For Each loooot As Item In body.GetItems
                        For Each poo As LootItem In ListBox3.Items
                            If poo.Text = loooot.Id Then
                                For Each bp As Container In inventory.GetContainers
                                    If poo.BP = bp.Name Then
                                        tobp.ContainerId = bp.Id
                                        loooot.Move(tobp)
                                    End If
                                Next
                            End If
                        Next
                    Next
                End If
            Next
            Return True
        End Function

  8. #8
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723
    I mean, I know what each line/loop is doing, but it doesn't make sense. Too many unnecessary loops.

    Note that I'm doing this from memory, so I may get something wrong.
    Code:
    Private Sub LootItems()
        For Each body As Container In inventory.GetContainers().Where(Function(x) x.Name.ToLower().StartsWith("dead ") Or x.Name.ToLower().StartsWith("remains ") Or x.Name.ToLower().StartsWith("slain "))
            For Each loot As Item In body.GetItems()
                Dim lootItem as LootItem = ListBox3.Items.FirstOrDefault(Function(x) x.Text = loot.Id)
                If lootItem IsNot Nothing Then
                    lootBP = inventory.GetContainers().FirstOrDefault(Function(x) x.Name = lootItem.BP)
                    If lootBP IsNot Nothing Then
                        lootItem.Move(lootBP.GetItems().First().Location)
                    End If
                End If
            Next
        Next
    End Sub

  9. #9
    Member
    Join Date
    May 2013
    Location
    Florida
    Posts
    54
    Code:
    Error	1	'FirstOrDefault' is not a member of 'System.Windows.Forms.ListBox.ObjectCollection'.	C:\Documents and Settings\matt and steve\My Documents\Downloads\Bot (1)\Bot\Bot\Form2.vb	472	44	Bot

  10. #10
    Senior Member
    Join Date
    Dec 2011
    Posts
    249
    include System.Linq

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •