So i’m starting to get used to the PvP and so far my character is smokin’ the competition with other more noobish players, but what i don’t understand is that, my character always seems to have problem with focusing on the enemy around him and instead he keeps going for the door, and no matter what i do, he always comes back to the door and take it down without any hesitation whatsoever.
I know that i can prevent his by using the flags, but then this is PvP, so i can’t do that when my code is being played back by other player, and when he fought with another player that has better armor and stronger weaponry, he always loses the fight, and that’s irritating considering i’m confident that he could win the match if only he avoided the door like the other player character would.
So anyway here’s my coding:
loop:
enemy = self.findNearest(self.findEnemies())
newX = self.pos.x - 15
newY = self.pos.y
if enemy:
distance = self.distanceTo(enemy)
self.findByType("door")
if enemy.type is "door":
self.moveXY(40, 86)
if distance <8:
self.attack(enemy)
self.attack(enemy)
self.findByType("headhunter")
if enemy.type is "headhunter":
if self.isReady("bash"):
self.bash(enemy)
else:
self.shield()
I’ll keep trying to fix this, meanwhile you guys can help fixing it by giving me a string of code that would make him avoid the door. Thanks for reading beforehand
you’re attacking one enemy in your elif distance < 8:
And one in your if enemy.
Which will attack the nearest enemy.
Which is…
THE DOOR! ba-dum-tish
Sorry for the bad sense of humour there.
put BOTH attack enemy’s
in the elif distance < 8:
Use elif.
Yes, the topic you were posting about.
like this.
OR you could use nested ifs and elses.
Which work way more reliably.
It’s a mouthful, I assure you.