loop:
enemy = self.findNearestEnemy()
item = self.findNearestItem()
if item:
pos = item.pos
x = pos.x
y = pos.y
self.moveXY(x, y)
if enemy:
if self.isReady("cleave"):
self.cleave(enemy)
if self.isReady("bash"):
self.bash(enemy)
else:
self.attack(enemy)
This is my code for the 2 brawl levels before this and It works fine. This works on sarven brawl most of the time, but after a while it targets the yaks. how should I fix this?
loop:
enemy = self.findNearestEnemy()
item = self.findNearestItem()
if item:
pos = item.pos
x = pos.x
y = pos.y
self.moveXY(x, y)
while enemy.type != "sand-yak":
if enemy:
if self.isReady("cleave"):
self.cleave(enemy)
if self.isReady("bash"):
self.bash(enemy)
else:
self.attack(enemy)
I changed my code to this and now it says âenemyâ was null on line 9.
Change the order of your âwhile enemy.typeâ and âif enemyâ statements
Your while enemy.type line has not verified that the variable âenemyâ is pointing to anything (it might be null) so do the âif enemyâ check first.
while enemy:
if enemy.type != "sand-yak":
if self.isReady("cleave"):
self.cleave(enemy)
if self.isReady("bash"):
self.bash(enemy)
else:
self.attack(enemy)
loop:
enemy = self.findNearestEnemy()
item = self.findNearestItem()
if item:
pos = item.pos
x = pos.x
y = pos.y
self.moveXY(x, y)
if enemy:
if enemy.type != "sand-yak":
if self.isReady("cleave"):
self.cleave(enemy)
if self.isReady("bash"):
self.bash(enemy)
else:
self.attack(enemy)
Now I have this. It works fine, but I donât have enough health. I can almost get the Enameled Dragonplate though
Actually, the Sword of the Temple Guard has a cooldown of 0.26 seconds, which means you will have nearly four attacks per second with it at 53.58 damage per attackâmore damage, of course, if you are using Tharin or Ayna. The Sword of the Forgotten, as @Wiilli pointed out, though it has a slightly higher DPS, is very slow, at about two attacks per second. Iâd definitely save up for the Sword of the Temple Guard, even though it does cost another thousand gems.