hi,
i am playing the level siege of stonehold. I have made up this code that makes my soldier follow the flag and attack enemies when nearby. Its working fine until i want to make me soldier cleave. i know the cleave command BUT i want to make it cleave when it is near the soldiers. While i was playing i would make my soldier walk toward the enemies but it would sometimes cleave along the way and not cleave when i wanted it to.
heres my code:
# You'll need great equipment and strategy to win.
loop:
enemy = self.findNearestEnemy()
flag = self.findFlag("green")
target = enemy
if flag:
flagpos = flag.pos
fx = flag.pos.x
fy = flag.pos.y
self.pickUpFlag(flag)
elif enemy:
self.distanceTo(target)
self.findNearestEnemy()
self.attack(enemy)
elif enemy:
enemy = self.findNearestEnemy()
distance = self.distanceTo(enemy.pos)
if distance < 4: self.isReady("cleave")
self.cleave(enemy)
I need help on this last code ^^^^^ i want to know what is the best way to make my soldier cleave when near an enemy. I tried putting that same code for cleave on the code above it that was for attacking but it didnāt work out well so i just made an individual code. Am i doing it right though? It says it is right but the soldier doesnt even cleave or maybe im not getting close enough? Im not sureā¦
**I just started the game yesterday and iām on the same lvl as u , idk why u used the variable target it doesnāt have any sense , another thing the last code **
if distance < 4: self.isReady("cleave")
self.cleave(enemy)
Shouldnāt be ?
if distance < 4:
self.isReady("cleave")
self.cleave(enemy)
one more thing flag colour isnāt needed in your code since youāre using 1 flag
OK, a couple things with this. First, you can do distanceTo(enemy) instead of (enemy.pos) I donāt think this will be an issue, just a point.
Secondly, your self.isReady(ācleaveā) is really doing nothing. I think you are wanting to check if cleave is ready and only cleave if it is. Instead, you are checking if it is ready, then cleaving no matter what.
(Like asking your mom if you can have a cookie, then after she answers you go get a cookie regardless of her answer) You need something like:
enemy = self.findNearestEnemy()
distance = self.distanceTo(enemy)
if distance < 4:
if self.isReady("cleave"):
self.cleave(enemy)
You could even combine those two if statements:
enemy = self.findNearestEnemy()
distance = self.distanceTo(enemy)
if distance < 4 and self.isReady("cleave"):
self.cleave(enemy)
Iām guessing what was happening is that you would run to the enemy position, cleave wasnāt ready so youād wait til it was ready, then by that time the enemy was gone.
Iāve been trying to beat this level and my code is super simple atm but it keeps giving me the Fix your Code: Find the distance to a target unit error. Is there something wrong with my code?
loop:
enemy = self.findNearestEnemy()
distance = self.distanceTo(enemy)
if distance < 20 and self.isReady("cleave"):
self.cleave(enemy)
else:
self.attack(enemy)
I altered the code to this and Iām not sure why itās working nowā¦ @_@
loop:
enemy = self.findNearestEnemy()
flag = self.findFlag()
# If there is an enemy, attack it!
if flag:
flagpos = flag.pos
fx = flagpos.x
fy = flagpos.y
self.moveXY(fx, fy)
self.pickUpFlag(flag)
if enemy:
distance = self.distanceTo(enemy)
if distance < 10:
self.isReady("cleave")
self.cleave(enemy)
elif enemy:
if distance < 10:
self.attack(enemy)
HELP! I canāt get past this level. It seems impossible. This is my code:
loop:
enemy = self.findNearestEnemy()
flag = self.findFlag(āgreenā)
if flag:
self.pickUpFlag(flag)
elif enemy:
if self.isReady(ācleaveā):
self.cleave(enemy)
else:
self.attack(enemy)
Whenever I place a flag, I mean for my player to go to it and pick it up, but it doesnāt. Do I need to start fresh? I have over 600 health and the long sword. PLEASE HELP!
You use some sort of find command and hunt the doctor down and use it, or if the doctor never moves, then you can just manually set it and be done.
If I remember correctly, you go to the mouth of the āvillage/keep/whateverā to get healed so point your mouse there to get the coords and set it manually.
Your code gets translated in to javascript usable by āAetherā (the code that controls the processing of the game). This process rewrites and wraps your code up so it can be run in a controlled fashion (catch infinite loops, take turns, etc). It assigns a ātmp#ā variable to everything (yes, essentially EVERYTHING). So āpos = doctor.posā becomes something like: ātmp14 = tmp16[tmp17]ā.
I think there is a major bug with this level now.
Thoktar constantly resurrect already dead ogres!
So level cannot be completed with any gear.
FYI: Iām using Chrome.