i know how to code this thing, but i want to figure out how to do it without doing 200 loc
im trying to see if thereās simpler solutions, so i dont spend 24 hours beating this level
btw why is the discourse so slo today
I created this code so my soldiers in Kelvintaph defiler can free the archer so they can free the paladin together
def findEnemy(name, friend):
enemies = friend.findEnemies()
id = name
i = 0
for i in range(len(enemies)):
enemy = enemies[i]
if id == enemy.id:
return i
else:
i += 1
Iām inputting āDrunā for name and the soldierās variable for friend.
But when i run my full code, it wonāt attack its enemyā¦ Why?
def CommandSoldier(soldier):
if step < 4:
target = findEnemy("Drun", soldier)
if "Drun".health > 0:
hero.command(soldier, "attack", "Drun")
elif soldier.pos.x < 74:
moveStep = 0
if moveStep == 0:
hero.command(soldier, "move", {"x": 6, "y": 74})
moveStep += 1
target = findEnemy("Drun", soldier)
if target:
while target.health > 0:
hero.command(soldier, "attack", target)
if moveStep == 1:
hero.command(soldier, "move", {"x": 22, "y": 67})
moveStep += 1
target = findEnemy("Drun", soldier)
if target:
while target.health > 0:
hero.command(soldier, "attack", target)
if moveStep == 2:
hero.command(soldier, "move", {"x": 39, "y": 62})
moveStep += 1
target = findEnemy("Drun", soldier)
if target:
while target.health > 0:
hero.command(soldier, "attack", target)
else:
enemy = soldier.findNearestEnemy()
if enemy:
hero.command(soldier, "attack", enemy)
Never mindā¦
I finally beated the level!!
but i canāt figure out how to keep my entire squad aliveā¦
itās weird!!
i can finish the level if i sacrifice my soldiers to the yeti, but i cant if i dont sacrifice themā¦
If you are talking about the moment when Nalfar flees from you.
It is relatively easy.
Just think where is the yeti came from and what you can do about it beforehand.
basically, i get my archers freed so they can free the soldiers.
Before Nalfar even got close to fleeing, i have to sacrafice my soldiersā¦
so likeā¦ when the soldiers get freed, i sacrifice them to the yeti, then i get my 2 archers to nalfar, and get him to swap.
and that = success.
But if i get my soldiers to stay at a specific point without sacrificing them for nothing, the level fails.
Interesting
I just take care of the yeti beforehand.
So no one hurt.
Could you please send that version of your code:
āBut if i get my soldiers to stay at a specific point without sacrificing them for nothing, the level fails.ā
nah itās okay
i figured it out
i changed it so that instead of 2 archers fighting the necromancer, i send the 2 soldiers to attack him with the paladin helping.
the archers basically just sit there and do nothing