Hello friends!
I'm thinking about making my own bot for client 7.7~ in C# and I've got some questions regarding Cavebot, targeting and how it's done (logically).
What I've thought so far regarding the cavebot is to run it on an own thread that starts when activating the cavebot.
Walking:
Have a list of waypoints with X Y Z and iterate through them.
So when it's gonna walk to a specific I gotta set gotoX, Y and Z respectively and then set isWalking to true, right?
Checking if it's arrived or not, should that be checked like this?
Psuedocode:
Code:
bool pauseForTargeting = false //used later for pausing the walker when targeting?
if !Walking //the client has stopped walking (possible reasons, path blocked/arrived/disconnected/dead or whatever
if(myX, myY, myZ) != goToX, goToY, goToZ) //check if its not walking and if thats true, retry walking
retryWalking()
else if (myX, myY, myZ) == goToX, goToY, goToZ) //check if the the characters position is the same as the goto position (hence it has arrived)
startWalkNextWaypoint() //Start going towards the next waypoint
In my head, that logic seems fine and should work alright for walking!
So to the targeting part. This I'm not that sure on how to do it. First of all, I'm not sure how to attack something by writing memory so I'd like some info about that (please =))
I guess it's about looping the battlelist and check if the names of targets is in that list, and if they are, write the creatureID somewhere in the client and set Attacking to true somewhere. I've head about isVisible in battlelist, but Im not sure when it sets to visible or not. (maybe when its on screen and is alive? Used for autologout?)
I'm also not sure how to check if the target creature has died or not.
The targeting part (modified into the walker code) something like this?
Code:
bool pauseForTargeting = false //used later for pausing the walker when targeting?
if !Walking && !pauseForTargeting //the client is not walking and its not paused for attacking (possible reasons, path blocked/arrived/disconnected/dead or whatever
if(myX, myY, myZ) != goToX, goToY, goToZ) //if my pos != gotoPos and if thats true, retry walking
retryWalking()
else if (myX, myY, myZ) == goToX, goToY, goToZ) //check if the the characters position is the same as the goto position (hence it has arrived)
startWalkNextWaypoint() //Start going towards the next waypoint
else //its walking and its not attacking
if(!isAttacking) //check if the bot is already attacking something
target = FindTarget() //a method to loop through battlelist and look for a creature to attack, returns creature ID
StartAttack(target) // attacks the target using creature ID
isAttacking = true //sets isAttacking bool to true
pauseForTargeting = true //pauses the walker
That's what I can come up with regarding Cavebot logic. I wan't to make all this work first before I get to looting.
What do you guys think? Is the logic good for a simple follow and attack cavebot for Tibia? It's my first time developing a cavebot so im not so sure how it works in Tibia. Any tips is much appreciated!