[vb.net code] Target Closest Mob (mouse&keyboard style) menu

Shout-Out

User Tag List

Results 1 to 3 of 3
  1. #1
    abuckau907's Avatar Active Member
    Reputation
    49
    Join Date
    May 2009
    Posts
    225
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [vb.net code] Target Closest Mob (mouse&keyboard style)

    Ok..most of this is pretty easy stuff for anyone who made it past the 'whoa..what's the objMgr stage' but I don't use LUA at all, only memory_read and mouse/keybd, so..
    code to find if there is a mob in a specific range of a specific point
    Ie. Are there any mobs within a 25u radius of 123,456,-789.
    Code:
       Private Function FindClosestMobBase(ByVal centerPos As pathPoint, ByVal maxRange As UInt32) As UInt32
            Dim tempObj As New wowBasicObject(FirstObjectAddress)
            Dim mobObj As New wowMobObject(FirstObjectAddress)
            Dim closestDistance As UInt32 = UInt32.MaxValue
            Dim returnMobObjBase As UInt32 = 0
            'Dim hasMobAlready As Boolean = False
    
    
            While tempObj.BaseAddress <> 0
    
                If tempObj.Type = enumBasicObjectType.NPC Then ' ==3
                    mobObj.BaseAddress = tempObj.BaseAddress
    
                    If wowBasicObject.GetDistanceBetweenObjects(centerPos.x, centerPos.y, mobObj.XPos, mobObj.YPos) < maxRange Then 'in-distance
                        If mobObj.Level > 1 And mobObj.HP > 1 Then
                            'it's alive and not a lvl 1 'critter' (note: this bugs if you're atctually trying to fight lvl 1 mobs..doesn't work..or, shouldn't.)
    
                            If wowBasicObject.GetDistanceBetweenObjects(centerPos.x, centerPos.y, mobObj.XPos, mobObj.YPos) < closestDistance Then
                                'is closest so far..record it.
                                If Math.Abs(LocalPlayer.ZPos - mobObj.ZPos) <= 20 Then ' 20??
                                    If theWowWorld.combat.IsBlackListed(mobObj.Guid) = False Then
                                        returnMobObjBase = mobObj.BaseAddress
                                        closestDistance = wowBasicObject.GetDistanceBetweenObjects(centerPos.x, centerPos.y, mobObj.XPos, mobObj.YPos)
                                        'else
                                        'is blacklisted, ignore it --> currently not used
                                    End If
    
                                    ' Else
                                    'probably too far above/below
                                End If
                                'else
                                'not closer than closest object so far
                            End If
                            ' Else
                            'is dead or a lvl. 1 critter
                        End If
                        'Else
                        'is really far away
                    End If
                    'Else
                    'curscanobj wasn't an NPC
                End If
    
                Try
                    If memReader.ReadUInt32(New IntPtr(tempObj.BaseAddress + EnumOffsets.wowBasicObjectOffsets.NextObjectPointer)) = FirstObjectAddress Then
                        'we've reached the end of the loop..exit while
                        'if we got here..mob.guid not found!
                        Exit While
                    ElseIf memReader.ReadUInt32(New IntPtr(tempObj.BaseAddress + EnumOffsets.wowBasicObjectOffsets.NextObjectPointer)) = 0 Then
                        'NBP is invalid...leave
                        'Unknown error?
                        Exit While
                    Else
                        'should be a good NBP,keep looping
                        tempObj.BaseAddress = memReader.ReadUInt32(New IntPtr(tempObj.BaseAddress + EnumOffsets.wowBasicObjectOffsets.NextObjectPointer))
                    End If
                Catch ex As Exception
                    'DoOutput("FindClosestMobBase::" & ex.Message)
                    Exit While
                End Try
    
    
            End While
    
            If closestDistance = UInt32.MaxValue Then
                'closest_distance hasn't change..no mob found in range
                Return 0 ' INDICATES FAIL
            Else
                'we found one..return it's baseaddress
                Return returnMobObjBase ' SUCCESS
            End If
        End Function
    Then here is my code to actually target the mob (run to it, and press tab key) ..I don't have a 'pathing system' yet, as of now it's super reliant on setting up path points w/ attack radiuses(ii?) ..so in this code it just runs a straight line to the target (ie. you set up points that are semi-far away from objects, and set a semi-small atk_radius..it works for now, I think)

    Code:
        Private Sub TargetClosestMob(ByVal maxDistance As UInt32)
            ''check if any mobs near lp
            Dim xx As UInt32 = FindClosestMobBase(LocalPlayer.PosAsPathPoint, maxDistance)
            If xx = 0 Then
                'no mobs found that close
            Else
                'mob(s) found in range!
    
                Dim tempTargMob As New wowMobObject(xx)
                'tempTargMob now == closest mob found, as mob object
                If tempTargMob.DistanceFromLocalPlayer > 35 Then
                    theWowWorld.runPath.RunPlayerToPoint(tempTargMob.XPos, tempTargMob.YPos, 35) 'TODO 35 = bow_max_range..should be max_spell_distance or..something non-static.
                End If
                Dim mPoint As New wowGamePoint
                mPoint.x = tempTargMob.XPos
                mPoint.y = tempTargMob.YPos
    
                theWowWorld.runPath.RightClickTurn(mPoint, 0.08)
                'mob should be in front of us
                'press tab key
                keybd_event(&H9, 0, &H1, 0)
                Threading.Thread.Sleep(300 + Rnd(200))
                keybd_event(&H9, 0, &H2, 0)
                'should have target now?
                Threading.Thread.Sleep(1250)
                'sleep to account for lag
                'If HasAliveTarget() = True then
                'DoOutput("Target Successful")
                'Else
                'DoOutput("Target Failed??")
                'End If
                End If
        End Sub
    Anyway, maybe this should be in vb.net section..but not many ppl in that section to wow stuff: A few of you use vb too..so, any comments?

    ps. I left out the code for .RunToPoint and .RightClickTurn() those are semi-private. And the classes themselves..again, private..but my names are semi-obvious..you should get the general idea? Any helpful suggestions?

    [vb.net code] Target Closest Mob (mouse&amp;keyboard style)
  2. #2
    ~Unknown~'s Avatar Contributor
    Reputation
    193
    Join Date
    Jan 2009
    Posts
    211
    Thanks G/R
    0/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's alright if you like it for what your doing. However, for one your critter check just for level ones doesn't exactly work since there are critters above level 1. Second you should add a check to your targeting method. Just because the mob you picked is the closest and you tab you will always get the right one. It only takes a small switch of positions in a really crowded botting area and you have the wrong mob, but I mean thats only if it matters for the bot's purposes. You can always check GUIDs for that though.

    Otherwise great little layout. Some tweaking and improvement and it looks good.

  3. #3
    abuckau907's Avatar Active Member
    Reputation
    49
    Join Date
    May 2009
    Posts
    225
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya, as far as actually botting, I'll have a minLevelToAttack and max..but I know
    what you mean.

    And, I have a check in my real TargetWithTab() code..I don't want to post it all here tho..that was kind of a pain..cuz at first it wasn't a problem, but then I tried to keep track of it..ended up typing the wrong variable name and kept targeting the wrong mob..long story short, I do now (takes ByVal TargetGUid) and compared to Localplayer.targetGuid() .. actually I turned it off because, I don't plan to kill more than 1-3 mobs at a time..preferably 1 :P and as long as my RightClickTurn() works good, target success is like 95% correct the first time..if not...it can handle running past a mob and getting attacked, then going into 'self defense' mode and killing all attackers..so, for now it works..I definatly have a todo of re-writing it tho.

Similar Threads

  1. casting pet freeze on target w/o mouse click HELP
    By jed2 in forum WoW Bots Questions & Requests
    Replies: 0
    Last Post: 10-05-2014, 01:20 PM
  2. Text File with Alot of VB.NET Codes
    By Mitron in forum Programming
    Replies: 0
    Last Post: 07-06-2009, 09:46 AM
  3. Obfuscating VB.NET code...
    By Ryoushi. in forum Programming
    Replies: 11
    Last Post: 06-08-2009, 12:09 PM
  4. About targetting a mob.
    By DrPieper in forum World of Warcraft General
    Replies: 2
    Last Post: 01-19-2009, 08:04 AM
  5. [Release] Inject Managed .Net Code!
    By bigtimt in forum WoW Memory Editing
    Replies: 6
    Last Post: 10-12-2008, 03:52 PM
All times are GMT -5. The time now is 06:52 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search