Jump to content

Help detecting multiple attacking enemies


Recommended Posts

Ok. I have a general use bot for a small game I use when I have to go afk to do something quick. I need better functionality with a certain aspect of it. I do not know how to achieve this as arrays have never been my strong point...

I have the bot set to detect a memory address that holds the attacking creature ID if I'm getting aggro'd. Problem is I've been dying when multiples attack me because it only attacks the first monster that aggro'd it and just sits there.

The variable can change as in this instance:

monster 1 hits me

aggro = 1234

monster 2 hits me

aggro = 4231

monster 1 hits me

aggro = 1234

and it will alternate depending upon which hits me at the time. I need something (an array?) that will constantly monitor this variable and list every number monster that hits me so I can make an attack list and cycle through until it no longer has aggro on me (dead), If that makes sense.

Here's a snippet of the function I'd like to tie it to:

Func _CheckHPInfight()
        If $CharachterHP <= $RegHP And TimerDiff($initPotCooldown) >= $PotCooldown * 1000 Then      
            ControlSend($GAME, "", "", "{F5 Down}") ;Target Self
            Sleep(250)
            ControlSend($GAME, "", "", "{F5 Up}")
            ControlSend($GAME, "", "", "{F4 Down}") ;Cast Heal
            Sleep(250)
            ControlSend($GAME, "", "", "{F4 Up}")       
            $initPotCooldown = TimerInit()
            Sleep(1000)
            If _Aggro() = True Then

                                _Attack($Aggro)
                ;Need aggro detection list here if numbers change

            EndIf
        EndIf   
EndFunc

Func _Aggro()
    If _Memoryread("0x" & $PointerAggro, $Game1,'dword') <> 0 And _Memoryread("0x" & $PointerAggro, $Game1,'dword') <> 131072 Then
        _MemoryWrite("0x" & hex($PointerTarget + $OffsetTarget), $Game1,_Memoryread("0x" & $PointerAggro, $Game1,'dword'))
        ControlSend($GAME, "", "", "{F1}") ;Attack Target
        Return True
    Else
        Return False
    EndIf
EndFunc

$Aggro is what just hit me and $Target is what I'm targeting.

Please help if you can I don't know how I'd do this and I don't know how to use arrays well.

Edited by niph
Link to comment
Share on other sites

It is for Drakensang. That is a single player role playing game but Ive been finding it hard to level my character Quickly. I use this for when I have to go to the bathroom and still want to keep going on my progress. I tend to replay this game with different charcters because I'd like to play all the roles and there are many choices one can make in the game.

Link to comment
Share on other sites

Not if you're trying to keep leveling, lol. I also have a toddler sometimes my trips to the bathroom include afterwords too when he's screaming about having things he can't have and I come back to a dead me. Not fun. Well the one I have now kind of works. It at least keeps me alive when something attacks me. Just not from multiples. I'll just use it as it is till I figure this array thing out. I just need to add different values from the same variable to an array and use something to check it is not already added, I think. It's also handy for increasing sums of money to buy better armor.

Arrays will be the death of me, lmao I can't use them in C either.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...