This code is used in Multiplayer Treasure Grove, I use a goliath, and my enemy can use invisibility. My problem is that I cannot use my special attacks as goliath with my code, but I can still use my base attacks and collect coins when the enemy is invisible. However, if I edit my code so that I can use my special attacks, my character eventually walks in one direction and doesn’t attack the enemy or collect coins. May I have any tips to avoid being “Invisibled” (aka walks in one direction and doing nothing) and also use my special attacks?
This is my code at the bottom.
This one can still use base attacks and collect coins when the enemy is invisible, but cannot use any special attacks.
totalGold = 0
def main():
enemy = hero.findNearestEnemy()
if enemy and hero.distanceTo(enemy) < 15:
fight()
return
else:
findItem()
return
def fight():
enemy = hero.findNearestEnemy()
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
if enemy.health < 200:
hero.attack(enemy)
else:
if enemy:
if enemy:
hero.attack(enemy)
elif hero.isReady("stomp"):
hero.stomp()
elif hero.isReady("throw"):
hero.throw(enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.isReady("hurl"):
hero.hurl(enemy)
else:
hero.move(enemy.pos)
return
def findItem():
item = hero.findNearestItem()
if item:
hero.move(item.pos)
totalGold += item.value
else:
return
while True:
if hero.gold >= 100:
hero.say("2 EZ")
else:
main()
This one can use my special attacks, but my character eventually walks in one direction and doesn’t attack the enemy or collect coins.
totalGold = 0
def main():
enemy = hero.findNearestEnemy()
if enemy and hero.distanceTo(enemy) < 15:
fight()
return
else:
findItem()
return
def fight():
enemy = hero.findNearestEnemy()
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
if enemy.health < 200:
hero.attack(enemy)
else:
if enemy:
if enemy:
hero.attack(enemy)
if hero.isReady("stomp"):
hero.stomp()
elif hero.isReady("throw"):
hero.throw(enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.isReady("hurl"):
hero.hurl(enemy)
else:
return
return
def findItem():
item = hero.findNearestItem()
if item:
hero.move(item.pos)
totalGold += item.value
else:
return
while True:
if hero.gold >= 100:
hero.say("2 EZ")
else:
main()
Also shoutout to Chronist Gilverbrind, my opponent. GG WP
Enemy hides during an attack function, so attack function cannot attack null, so the hero is confused. The checking function doesn’t ID the “hide” because the “hide” always happens when my hero is using the attack function. Thanks though
interesting he execute invi after you select him as target
invi cast time is 0.5
so my strategy move near
for example attack take 0.25
you can execute 2 attack
while he casting
working good enough
totalGold = 0
def main():
enemy = hero.findNearestEnemy()
if enemy and hero.distanceTo(enemy) < 15:
fight()
return
else:
findItem()
return
def fight():
enemy = hero.findNearestEnemy()
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
if enemy.health < 200:
hero.attack(enemy)
else:
if enemy:
if ( enemy
and not enemy.hasEffect( "hide" ) ):
while ( hero.distanceTo( enemy ) > 5 ):
hero.move( enemy.pos )
hero.attack( enemy )
hero.attack( enemy )
if ( hero.isReady("stomp")
and not enemy.hasEffect( "hide" ) ):
hero.stomp()
elif ( hero.isReady("throw")
and not enemy.hasEffect( "hide" ) ):
hero.throw(enemy)
elif ( hero.canCast("chain-lightning", enemy)
and not enemy.hasEffect( "hide" ) ):
hero.cast("chain-lightning", enemy)
elif ( hero.isReady("hurl")
and not enemy.hasEffect( "hide" ) ):
hero.hurl(enemy)
else:
return
return
def findItem():
item = hero.findNearestItem()
if item:
hero.move(item.pos)
totalGold += item.value
else:
return
while True:
if hero.gold >= 100:
hero.say("2 EZ")
else:
main()
Tnkas for helping me with the “Invisibled” Problem. However, I see that I am only able to use one of my specials. Is there a reason why that is happening?
PS, I see you on dueling grounds global, GG
if ( enemy.target == hero ):
hero.cast( "invisibility" )
i think
about skill
looks like something like this :
2 cases
1 you attack him he execute invi – end of story
2 you attack him then stomp
cos all other skills at elif
we go to the another cycle
at this moment he out of 15 m – end of story
before execution of skill
you must be sure
you at skill execution range
it will execute faster than he execute invi