Hello! This is my first time creating a topic, so I’ll probably accidently violate 100 rules or something(I did try the read to guide…)
Recently, I decided to try my hand at dueling grounds again. Before, I had code which involved a sword, but now, looking at non-subscriber players, most of them seem to favor hammers. I tried it out, and it seems very clever, so I wanted to create a basic strategy. Essentially, I turn invisible, then I try to build a bear-trap on my enemy, then I rotate between trapping them, spamming decoys, bashing them, and using chain-lightning them. It’s very simple code. The problem is, when my code runs, I want to build a bear-trap on the enemy. However, if the enemy moves, I can’t update the enemy’s location, so my hero moves to the old location and builds a bear-trap there.
Unfortunately, I can only buildXY(bear-trap). I can not use build(bear-trap). I tried using hero.move(enemy.pos) and then building the bear trap once I get there, but for some reason my hero always tries to build at the enemy’s old position. Here is my code
hero.cast("invisibility", hero)
enemies = hero.findEnemies()
def enemyHero():
for enemy in enemies:
if enemy.id=="Hero Placeholder" or "Hero Placeholder 1":
hero.move(enemy.pos)
hero.buildXY("bear-trap", enemy.pos.x, enemy.pos.y)
if hero.isReady("bash"):
hero.bash(enemy)
def arrowTower():
if hero.gold>hero.costOf("decoy"):
hero.buildXY("decoy", hero.pos.x, hero.pos.y)
def punch():
for enemy in enemies:
if enemy.type=="Hero Placeholder" or "Hero Placeholder 1":
if hero.canCast("chain-lightning"):
hero.cast("chain-lightning", enemy)
enemyHero()
while True:
enemies = hero.findEnemies()
enemyHero()
punch()
arrowTower()
It seems like I have to update enemies=hero.findEnemies() by putting it into a while loop, but I’m not quite sure how to do that.
Please tell me how I can update the enemies position so that even if they are moving I can place the bear-trap on them. Thank you!
Also, please don’t judge my variables…