oh!! Thanks for the help!
I can get past the first round of combat and collect all the mushroom and every thing but canât get to the next trial here is my code
loop {
var flag = this.findFlag();
var enemy = this.findNearestEnemy();
if (flag) {
this.pickUpFlag(flag);
this.cast(âsummon-undeadâ);
} else if (enemy) {
this.cast(âdrain-lifeâ, enemy);
}
}
can someone telll me what I am doing wrong
Why are you not just simply attacking instead of throwing complicated spells?
Hi, i am success this level using loop break and wait 
I beat it, but I have 1100 + health. Iâm using the Great Sword, Enameled Dragonplate and the Steel Striker, and I beat it first try. Hereâs my code.
while (true){
var enemy = hero.findNearestEnemy();
var item = hero.findNearestItem();
if (enemy) {
if (hero.isReady("bash")) {
hero.bash(enemy);
} else {
hero.attack(enemy);
}
} else if (item) {
hero.moveXY(item.pos.x, item.pos.y);
}
var flag = hero.findFlag();
if(flag){
hero.pickUpFlag(flag);
}
}
This is a dead topic from 2015. Please do not reply as this will bump this up to the front page
Also please do not give out the code. It makes it easier for a person to just get the code. and pass the level without learning anything. Codecombat is a learning game. Read the FAQ before further posting!!
help! i canât solve this!!!
here is my code:
enemy_types = {}
enemy_types[âoasis-guardianâ] = {âdangerâ: 10, âfocusâ: 315}
enemy_types[âshamanâ] = {âdangerâ: 10, âfocusâ: 10}
enemy_types[âwarlockâ] = {âdangerâ: 10, âfocusâ: 10}
enemy_types[âarrow-towerâ] = {âdangerâ: 10, âfocusâ: 10}
enemy_types[âburlâ] = {âdangerâ: 10, âfocusâ: 5}
enemy_types[âwitchâ] = {âdangerâ: 8, âfocusâ: 10}
enemy_types[âbrawlerâ] = {âdangerâ: 7, âfocusâ: 10}
enemy_types[âogreâ] = {âdangerâ: 5, âfocusâ: 10}
enemy_types[âchieftainâ] = {âdangerâ: 6, âfocusâ: 10}
enemy_types[âfangriderâ] = {âdangerâ: 4, âfocusâ: 22}
enemy_types[âskeletonâ] = {âdangerâ: 5, âfocusâ: 22}
enemy_types[âscoutâ] = {âdangerâ: 4, âfocusâ: 22}
enemy_types[âthrowerâ] = {âdangerâ: 3, âfocusâ: 22}
enemy_types[âmunchkinâ] = {âdangerâ: 2, âfocusâ: 15}
if hero.team == âhumansâ:
team = âhumansâ
else:
team = âogresâ
def findTarget():
danger = 0
enemy_return = None
for type in enemy_types.keys():
if enemy_types[type] and enemy_types[type].danger > danger:
enemy = hero.findNearest(hero.findByType(type))
if enemy and enemy.team != team and hero.distanceTo(enemy) < enemy_types[type].focus:
enemy_return = enemy
danger = enemy_types[type].danger
if enemy_return is None:
enemy_return = hero.findNearestEnemy()
return enemy_return
summonTypes = [ âpaladinâ, âpaladinâ, âpaladinâ, âgriffin-riderâ, âgriffin-riderâ]
def moveTo(position, fast=True):
if (hero.isReady(âjumpâ) and hero.distanceTo(position) > 10 and fast):
hero.jumpTo(position)
else:
hero.move(position)
def summonTroops():
type = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold > hero.costOf(type):
hero.summon(type)
def commandTroops():
for friend in hero.findFriends():
if friend.type == âpaladinâ:
CommandPaladin(friend)
elif friend.type == âsoldierâ or friend.type == âarcherâ or friend.type == âgriffin-riderâ:
CommandSoldier(friend)
elif friend.type == âpeasantâ:
CommandPeasant(friend)
def CommandSoldier(soldier):
hero.command(soldier, âdefendâ, hero)
def CommandPeasant(soldier):
item = soldier.findNearestItem()
if item:
hero.command(soldier, âmoveâ, item.pos)
def CommandPaladin(paladin):
lowestFriend = lowestHealthFriend()
if (paladin.canCast(âhealâ) and hero.health < hero.maxHealth / 5):
hero.command(paladin, âcastâ, âhealâ, self)
elif lowestFriend and lowestFriend.health < lowestFriend.maxHealth / 3:
hero.command(paladin, âcastâ, âhealâ, lowestFriend)
else:
hero.command(paladin, âdefendâ, hero)
def lowestHealthFriend():
lowestHealth = 99999
lowestFriend = None
friends = hero.findFriends()
for f in friends:
if f.health < lowestHealth and f.health < f.maxHealth:
lowestHealth = f.health
lowestFriend = f
return lowestFriend
def attack(target):
if not target:
target = findTarget()
if target:
if (hero.distanceTo(target) > 50):
moveTo(target.pos)
elif hero.isReady(âchain-lightningâ):
hero.cast(âchain-lightningâ, target)
elif hero.isReady(âbashâ):
hero.bash(target)
else:
hero.attack(target)
enemyHero = [e for e in self.findEnemies() if e.id in [âHero Placeholderâ, âHero Placeholder 1â]][0]
while True:
summonTroops()
commandTroops()
e = hero.findNearestEnemy()
item = hero.findNearestItem()
if e and hero.distanceTo(e) < 50:
attack(e)
elif item:
moveTo(item.pos)
elif hero.now() < 80:
moveTo({âxâ:110, âyâ:23})
elif hero.now() < 145:
moveTo({âxâ:37, âyâ:129})
elif hero.now() < 190:
moveTo({âxâ:116, âyâ:116})
else:
moveTo({âxâ:96, âyâ:63})
how do you make your code look normal???
when you post your code click this icon and follow the instruction
the icon
![]()