loop:
enemy = self.findNearestEnemy()
item = self.findNearestItem()
if enemy:
if enemy.type is 'sand-yak' or enemy.type is 'burl':
# Don't fight Sand Yaks or Burls! Just keep collecting coins.
pass
if enemy:
self.attack(enemy)
# But if the enemy is a 'thrower' or an 'ogre', fight them.
elif item:
pos = item.pos
a = pos.x
b = pos.y
self.moveXY(a, b)
My issue is that for if enemy.type is 'sand-yak' or enemy.type is 'burl':
I don’t know how to not attack the sand-yak and the burl.
Any suggestions on how to fix this? thank you in advance.
Good question. The sample code already avoids attacking sand-yaks and burls. (The pass statement does nothing.) You need to add an else clause in there to say what to do when you see an enemy that isn’t one of those two types. Does that make any sense?
Is there any resource on here that lists all the different enemy types in perfect syntax? I’m trying to avoid a sand-yak, but my code isn’t recognizing the type.
usually if you click on the mob on the screen it will switch who you are “focused” on and it then shows “name - type” (the real type is all lowercase and hyphenated if more than one word) and/or you can try say(enemy.type) to get it yourself. I thought there was a message where someone listed a bunch of them but I couldn’t find it. so here is my attempt (off the top of my head)
I’m sure there are more but as I said that is off the top of my head (to much hair to find any others).
(I can never remember if it is head-hunter or headhunter, I think no ‘-’, but…)
What will give you this “enemy.type” Will the glasses called kithgard workers give you “enemy.type” due to skills granted “find by type” I"m also trying to avoid attacking a herd of sand yaks.
FindByType is not needed for this case, because you should have an array of all enemies, including the yaks with the herof.findEnemies() function
Lets say you have your array of enemies, called enemies.
you can check each array member through a loop, and then check if that specific variable, lets say i in this case, is of type “sand-yak” I dont think you need a specific glasses to check for enemy type. I believe it is either included in the game already, or its in the same equipment needed to check for gold, position, value, etc.