A Full Beginner Guide For CoCo

Many friends are telling me to list out some armor and pairings to help them complete levels, and some sample codes of loops, and also some ogre-info, so I created this guide. In this guide, I will basically list out a full guide for CodeCombat.

Hero Choose

If you are a subscriber but you only have limited gems, and you want a good hero. I will list out the good and bad heroes for you. For non-subscribers, there are still two heroes that can be unlocked for you.

Warriors

Good Warriors
Ned Fulmer - Excellent for surviving, and free. He comes with the ability heartShield() which is amazing, lasts for 2 seconds, and only with a 4-second cooldown. Excellent for brawls. This is just a gift for the non-subcribers.
Price: join this team

Okar Stompfoot - A walking tank, 200% health, 160% damage, and an AoE stomp ability that does 300 damage and a throw ability that does 120 damage. What more do you want? Hurl also does 50 damage. Good for PvP, PvE, and Survival, but slow. Really worth it. Very cost effective.
Price: 12K

Arryn Stonewall - This hero is underrated in my opinion, it doesn’t do well in PvP alone, but a great support unit. Warcry increases knockback a lot, and throw does roughly ~125 damage. It also has big speed, is useful for speedrunning, and is good for levels like Harrowland and Sarven Treasure. Tip: Summon griffin-riders then warcry. They’ll do a lot of knockback.
Price: 4.6K

Bad Warriors
Gordon the Stalwart - Even though it has high health, it has VERY low damage of only 83%. Even though it’s good for surviving, Ned can replace him, and Ned has a shield ability that blocks every damage, and higher damage than Gordon. This hero isn’t worth it.
Price: 2.1K

Hattori Hanzo - Health is way too low, you get it. Damage muliplyer can be replaced with Okar, also, when your subscription ends, you cannot use it anymore. But good for running levels with “Damage Dealt” option.
Price: Subscribe

Illia Shieldsmith - Very nice hero, but this is a beginner guide. Useful for surviving with shieldBubble, but other abilities are way too complex to use. If you didn’t complete Glacier, don’t buy this hero. Instead of using a hero that you don’t know how to use, get some other heroes that do about the same, like Okar.
Price: 16K

Armando Hoyos - It is basically the same thing as the free heroes. The magnet ability can pull you in by accident, and also deal no damage. Ogres will get pulled into a crowd and therefore making it a bigger threat. Also ogres can still attack when pulled.
Price: join this team

Rangers

Good Rangers
Senick Steelclaw - A great hero, and probably the best for cost-effectiveness. 1400 gems, 180% health, 140% damage. These stats are just amazing, goes well for PvP, and PvE with his healing ability. This hero is a monster when used with speed ring and invisibility ring.
Price: 1.4K

Naria of the Leaf - This hero is a little weaker than Senick, but remember, she has a built-in hide() ability. 160% health multiplyer is also pretty high. She has an envenom ability, which powers her up, and now she has a ~125% damage multiplyer! While her double invisibility and enonvom conbined with backstab() is deadly in PvP, she is more of a Surviving hero because of her double invisibility instead of doing AoE attacks.
Price: 2.5K

Ritic the Cold - His abilities aren’t that confusing, instead of the arguments for moveXY(x, y), you point out a position with [{'x': x, 'y': y}] (or [Vector(x, y)] or in JS: [new Vector(x, y)], or [{x: x, y: y}]), he is often referred as the best hero for codecombat, 4 deadly abilities that are strong and defensive at the same time, what more do you want? Only one problem, he’s expensive, so think before you buy him.
Price: 29K

Bad Rangers
Amara Arrowhead - It’s pretty noticeable, Ritic is an upgraded form of her, with 40% more damage, and 4 abilities. Also, like Hattori, you cannot use this hero when your subcription ends. Her damage points are just way too low, and her speed isn’t that fast.
Price: Subscribe

Zana Woodheart - This hero is great for PvP with her abilies that stun the target. But this hero is terrible for PvE and for Survival. She only has 100% health multiplyer and her damage is just too low. Unless you want this hero for multiplayer, don’t buy her, it’s a waste of 8500 gems.
Price: 8.5K

Wizards

Good Wizards
Nalfar Cryptor - What can I say? This hero is the best wizard in my opinion, with his sacrifice ability with a short cooldown, using the vine staff, and sacrificing only one burl basically buffs his damage multiplyer to ~145%, which is more than most wizards. Or use lightning twig, sacrifice a skeleton, then the DPS for the twig will be 4x the amount. Remember that sacrifice also buffs health, and you can raise the deads you sacrificed. Also, devour also buffs damage points.
Price: 6.3K

Miss Hushbrum - Even though this hero doesn’t last when subscription ends, she is a good start hero when you get touched with wizards. Her stats are pretty balanced, and she has more health than most wizards. But remember to switch to stronger wizards when you continue the campign.
Price: Subscribe

Omarn Brewstone - All of his ‘buff’ abilities for brew() lasts for 5 seconds and gives out a 1.5x multiplyer, but also, his cooldown for brew is also 5 seconds! What this means is that if you brew speed, you will always get the speed effect if you continue brewing when ready, the speed-brew will buff your speed to 16.5m/s , which is already faster than all heroes. When combined with haste, his speed will turn to 33m/s , which is totally insane. When you brew damage, your 83% damage multiplyer will turn to 125%, and that is amazing. Remember he also has a throw() AoE ability that does 75 damage in a 10m radius for a cooldown of 5 seconds.
Price: 1.8K

Usara Master Wizard - Her summon-yeti ability when combined with the boss-star, summon-burl, summon-undead, can easily swarm enemies. Since she has a highest damage multiplyer, she can use allies to swarm enemies then picking them off from far.
Her magnet field and summon-robobomb is a great combo that does 1000 AoE damage if used correctly, use magnet field to pull enemies then bomb them with the robos, you can also use archers to snipe people when they are pulled in the field.
Price: 21K

Bad Wizards
Pender Spellbane - This is only wizard that I counts as bad, the main problem is that her health is too low. Also, her speed stat can be replaced with Omarn which is even faster with his brew() . Her damage can be replaced with Usara which deals more damage and has about 3x more health than her.
Price: 3.4K

Armor Tips

If you want to complete the campaign, you definitely need good armor, here is some armor that I recommend.

Warriors

Rookie Set:
Obsidian Set - Cost-effective and high health boost.
Steel Striker - Big bash damage, knockback, and high health boost.
Morning’s Edge - Very fast, built in with a flash ability with more damage than cleave and more radius, blinds enemies too, a good-choice sword.
Quartz Sense Stone - This sense stone will get you through all levels.
Engraved Wristwatch - This watch will get you through all levels, and the wait() method is pretty useful.
Ring of Speed - Since most warriors are slow, you sometimes might need a speed boost, this is the best equipment for warriors I believe.
Thornprick - This ring often lets you get by easier levels without that much effort and it reduces the threat of swarms of munchkins.
Dynamic Flags - These Flags will get you through all levels, including the ones in glacier with removeFlags
Crude Telephoto Glasses - Big range boost, and the abilities will get you through all levels.

Advanced Set
Worn Dragon Armor Set - Cost-effective, and insane health-boost, will get you past 2000 hp just by themself.
Deflector - Best shield in-game.
Sword of the Temple Guard - Insane DPS and power-up ability will give out a 10x knockback, really useful for PvP and Munchkin, Scout slaying.
Fire Opal Sense Stone - target check can detect what are you attacking, useful for commanding allies.
Gilt Wristwatch - Get the cooldown of an ability - useful when you are casting multiple abilities.
Ring of Speed - Same description as the rookie set.
Advanced Flags - An array can help you a lot, tip: use flag = flags[index] (put let in front for JS) for a single flag.
Infinity Lenses - Infinity range is just great.

Rangers

Riveted Dragon Set - Ranger Sets aren’t that cost-effective, you might as well get the best ones.
Sparkbomb - Awesome AoE damage.
The Shredder - You can use throwPos with some advanced code to throw at a place even if the enemy is greater than your attack range.

[The rest of the items on the Warrior Advanced Set]

Wizards

Griffin Wool Hat - Great cost-effectiveness, the enbroidered version is just too expensive.
Enbroidered Griffin Wool Robe - Best armor for wizard.

Golden Wand - Very fast, and you can summon coins to summon allies (if you have a boss star).
or
Lightning Twig - Does high AoE damage, and constantly damages enemies, counts as the fastest wand.
or
Vine Staff - The highest damage wand, and allows you to summon a mighty burl that fights for you.

Unholy Tome V - Allows you to summon-undead and to raise dead, very useful for surviving. Poison cloud does AoE damage, and fear is good for PvP.

[The rest of the items on the Warrior Advanced Set]

Units Introduction

Here’s a list of units and their stats, so you will know the best units to command, and the worst units to defeat (ogres).
There are three teams, and each team has different units. They’re "humans" , "ogres" , and "neutral" .
P. S. Units that do area damage have a “(AoE)” besides the damage points.

Ogres

Ogres are units on the team “ogres”, they are colored blue and attack everyone that’s not on the same team as them. They are programmed to attack the nearest enemy.

Melee Ogres
These are the most common ogres, most of them can only attack, and they are not so smart so it’s quite easy to defeat them. But it’s quite a problem when you get swarmed by them.

|    Name    | Damage | DPS | Health | Speed | Abilities 
|       Peon |    0   |  0  |    7   | 12m/s | collect, flee
|   Munchkin |    2   |  4  |   14   | 12m/s | None 
|      Scout |   12   | 24  |   75   | 12m/s | None 
|     Ogre M |   18   | 36  |  120   |  5m/s | None 
|     Ogre F |   30   | 60  |  250   |  7m/s | None 
| Headhunter |  100   | 100 |  180   |  7m/s | bash  
|    Brawler |   75   | 150 |  500   |  4m/s | None  
|  Chieftain |   75   | 225 |  800   |  8m/s | warcry, command
|   Palisade |    0   |  0  |  500   |  0m/s | None 

Notes: When you are checking the types of ogres, remember to lower-case the capital letters and add hyphens to connect words instead of spaces. For example, when you are checking the Ogre F, instead of "Ogre F", check "ogre-f". Ogre M’s type is just "ogre"
Headhunters have a attack range of 30 meters, and he does 100 bash damage with a cooldown of 0.5 seconds.
Chieftains’ warcry hastes ogres by 1.3x for a duration of 4 seconds, the cooldown is 7 seconds and it’s haste-range is 20 meters.
Peon’s can collect items and dropItem , pickUpItem . They can be commanded by Chieftains.
Palisade is just like a fence with 500 health, they can be built by the same team peasants and cost 15 gold.

Ranged Ogres

|    Name    | Damage | DPS | Range | Health | Speed |
|    Thrower |   11   |  19 |  25m  |    7   | 11m/s |
|  Fangrider |   30   |  50 |  20m  |   100  | 30m/s |
| Beam Tower | 20(AoE)|  60 |  35m  |  2000  |  0m/s |
|   Catapult |800(AoE)| 265 |  80m  |   100  |  5m/s |

Notes: Beam Towers constantly damages units. It acts basically like the ranger’s lightning stick.
Fangriders can fly over hazards (Fire-traps, bear-traps, etc.).
Catapults damages ogres too. Basically counts as friendly-fire.

Wizard Ogres

|    Name    | Damage | DPS | Range | Health | Speed | Abilities
|     Shaman | 25(AoE)|  33 |  30m  |   60   | 10m/s | castGrow
|      Witch | 40(AoE)|  40 |  35m  |  120   |  8m/s | castDispel, castSlow, castHeal
|    Warlock |  200   |  67 |  45m  |  240   | 10m/s | castGrow, castWindstorm, castSummonUndead, castRaiseDead, suicideExplosion
|    Thoktar |250(AoE)| 125 |  60m  |  1000  | 12m/s | castGrow, castFear, castFling, castPoisonCloud, castShockwave, castWindstorm, 
castTeleport, castSummonUndead, castRaiseDead

Notes: Thoktar can command all types of ogres, including Chieftains.
Shaman’s growth is 2x, while Thoktar’s and Warlock’s is 4x.
Thoktar’s raise dead has a radius of 130 meters. The warlock’s raise dead only has 20 meters.
Witch’s heal only heal 100 health, but they have a short cooldown.

Thoktars and beam towers are unsummonable in levels. They have to be hand-placed (or at least the levels in the campaign).

A list in my opinion: (most dangerous to least dangerous)
Witch > Catapult > Warlock > Headhunter > Chieftain > Brawler > Fangrider > Ogre Female > Shaman > Ogre Male > Scout > Thrower > Peon > Munchkin

Witches can heal, and they have the most powerful AoE attack (the radius is the biggest), and their heal ability’s cooldown is less than 2 seconds. Catapult’s 800 damage is deadly. Warlocks have a lot a abilities and it has regen. Even though headhunter’s health is low, but he’s strong and has bash, so you can kill him first. Vice versa.

Neutral Units

|     Name     | Damage  | DPS | Range | Health | Speed | Abilities
|     Skeleton |    15   |  38 |   3m  |   300  |  7m/s | flee
|     Sand Yak |   150   | 150 |   3m  |   500  | 20m/s | None
|      Ice Yak |   600   | 450 |   4m  |   900  | 16m/s | None
|     Robobomb |1000(AoE)|  3  |   1m  |   180  | 10m/s | suicideExplosion
| Robot Walker |  9001   |3000 |  50m  |  5000  |  6m/s | castSummonRobobomb
|  Robot Tower |  9001   |3000 |  50m  |  5000  |  0m/s | None
|         Yeti |    80   | 240 |   3m  |   675  | 24m/s | bash
| Armored Yeti | 80(AoE) | 240 |   3m  |   675  | 24m/s | bash
| Dungeon Door |    0    |  0  |   0m  |   40   |  0m/s | None

Notes: The robot tower and the armored yeti cannot be naturally summoned in the levels in the campaign. They have to be hand-placed with the level editor.
Armored yeti is still under-development.
The robobombs can only be summoned by the robot walker.
Skeleton’s default team is neutral, but they can be summoned by warlocks and thoktars.
The yaks will not attack unless provoked or the “Hero Placeholder” gets in their way.
Robobombs can attack, but they mainly do damage out of their explosion, the damage point is 3 with a cooldown of 1 second.

Human Units

|      Name     | Damage | DPS | Range | Health | Speed | Cost | Abilities
|       Soldier |    6   | 12  |   3m  |  200   |  6m/s |  20  | None
|        Archer |   13   | 26  |  25m  |   30   |  9m/s |  25  | None
| Griffin Rider |   20   | 40  |  20m  |  160   | 20m/s |  50  | None
|       Peasant |    0   |  0  |   0m  |    6   |  8m/s |  50  | flee, collect, build
|       Paladin |   20   | 50  |   3m  |  600   |  8m/s |  80  | castHeal, shield
|   Arrow Tower |   70   | 70  |  30m  |  600   |  0m/s |  75  | None
|     Artillery |  250   | 70  |  65m  |  100   |  4m/s | 100  | None
|         Decoy |    0   |  0  |   0m  |  500   |  5m/s |  25  | decoyTarget, collect
|      Palisade |    0   |  0  |   0m  |  500   |  0m/s |  15  | None
|          Kith |    0   |  0  |   0m  |   10   |  4m/s |   0  | None

Notes: Decoys lure targets in a 30m radius.
Palisades can only be built by peasants.
Caltrops damage units when they step on them, they don’t have health.
Artilleries cannot be summoned, because BS5 isn’t released.
Griffin-riders can fly over hazards.
Fire-traps are default on the human team (They are colored red or blue), but they friendly-fire so the team doesn’t matter.
Kiths cannot be naturally summoned, but they appear in the late levels of Kithgard Dungeon

When you cast raise-dead on dead units, they will be revived at half health and half speed, they will help you kill units on other teams, but their original team is still the same. hero.cast("raise-dead")

Buildables

Buildables are all types of things that can be built by thangs with the buildXY method, some thangs (units) can build more things than others. When building is used in hero.command you should use "build", not "buildXY". (Although buildXY is also possible usually) Better buildables costs more gold than others. Heroes can only build using hammers, or belts.

 Build Types |  Cost  | Can be built by #{type} 
       fence |    0   | "peasant", "Hero Placeholder"
   fire-trap |    0   | "peasant", "Hero Placeholder"
   bear-trap |    0   | "Hero Placeholder"
    palisade |   15   | "peasant"
       decoy |   25   | "peasant", "Hero Placeholder"
    caltrops |   35   | "Hero Placeholder"
 arrow-tower |   75   | "Hero Placeholder"

Collectables

These are the things that can be collected and gives out gold or effects. I will list the things you will get when you collect them. Decoys and peasants can collect these items, peons can too.

Potion: large - heals 1000 health; medium - heals 300 health; small - heals 100 health
Lightstone: scares undeads away.
Mushroom: Does 50 DPS to you for 3 seconds when collected. But on default, it does no effect unless coded to.
Bronze Coin: 1 gold
Silver Coin: 2 gold
Gold Coin: 3 gold
Blue Gem: 5 gold
Gem Pile Small: 15 gold
Gem Pile Medium: 40 gold
Chest of Gems: 100 gold
Locked Chest: 150 gold, but only gives when someone attacks it.
Additional - Red Gem: 15 gold (Cannot be spawned, must be color-coded)

Items Combo

In this list, I listed out the good combos when using items, usually rings, but armor too. Hope this list can help you.

Speed Combo: [Ring of Speed, Boots of Leaping] - Excellent for speed, and boots of leaping has a super-duper jumpTo ability that jumps fast and far. This combo can be even taken to the next step when you combine it with the invisibility ring.

Surviving Combo: [Ring of Earth, The Order of Paladins] - Very good in levels like harrowland or cavern survivals, because you will have a large army so it’s good to use consecrate() heals at a rate of 50 DPS, so it’s very nice. Ring of Earth’s castEarthskin() 's effect can conduct the effect to allies too, and it lasts for 5 seconds, so in a quick battle, use this combo. Also not to mention this is probably the best combo for Cloudrip Siege as there are warlocks that can summon undead and the ability can damage undead too. Flowers have each 200 health and can also be healed!
The string is "Flower West" and "Flower East", and you can select it by hero.findFriends too!

The combo above is the two main ones, and below, I will list out the bad combos or at least the bad items.

Bad Items:
Charge Belt - What a surprise, even the charge belt is a bad item, why though? First, it friendly fires. Second, the damage radius is way too small, why not save 300 gems and then get the Sparkbomb? Third, the action name is "throw", so when checking it when you already have a throwing item, you cannot throw twice. For Example, if you have the charge belt and the glitterbomb, you can only throw the charge belt and not the glitterbomb, because the action name is the same and you can only check it once. Note that checking if hero.isReady("throwAt") doesn’t work.

Potion Belt - This new item is a waste of gold and gems, 2100 gems are gone and you know you got scammed. The potions cost 35 gold and only give a 1.5x multiplier and also have a 5-sec cooldown. You can get a Codex or Tome that gives out effects for a 2x multiplier for no gold. But if you want to survive in brawls, this belt is ideal. Remember that you cannot build or summon troops as you are consuming your gold for potions.

Enameled Dragonplate Helm - This item has nothing bad, but its cost-effectiveness is way too low. While the worn version of this helm only costs 1900 gems, this one costs 6600, even more than the chestplate.

Ragged Silk Hat - This only costs 10 gems less than the upgraded version, this item really needs improvements (Health boost) or less gem cost.

Edge of Darkness - Well, to prove this sword is trash, compare it to the Kithsteel Blade, which costs 400 gems less than this sword and has more DPS, and attack range.

Stone Builder’s Hammer - Many people might disagree, but think about it, how much time in the campaign will you even use arrow-towers? And it lacks the ability to build fences, which is a problem. It shouldn’t cost 1100 gems, nerf the price devs.

Iron Defender / Deadeye Crossbow / Reinforced Crossbow - Compare the iron defender and the deadeye with the Rapidfire Rifle, the DPS is much higher than both of the bows. Then compare the reinforced crossbow with the Precision Rifle, the rifle is better than the crossbow in all ways, and the price difference isn’t too high, just around ~100 gems.

Loops, statements, definitions

Starting with the easiest one, then moving and stacking to the hardest one. Code examples will be included. Codes are in python.

if-statement

The if statement is easy to understand, ask yourself, if this is true, then do that. The codes in an if-statement will only run when the if-statement returns True.

#1 Example

isAlive = hero.health > 0  # defines the condition is true or false.
# The value returned by isAlive MUST be true, or false.
if isAlive:  # checks if the hero is alive (true/false).
    hero.say("I'M ALIVE!!!")  # code in a if-statement must be intented.

#2 Example

answer = 1 + 2  # You can use math representations when defining variables.
if 1 + 2 == answer:  # if 1+2==answer returns True, then the code will run.
    hero.say("Three!")
# Note: The equal sign is '==' in python

#3 Example

enemy = hero.findNearestEnemy()
if enemy:  # if the existance of enemy returns True...
    hero.attack(enemy)  # ...then attack the enemy

elif / else statement

else
This is what you do when the value of the if-statement returned false. Start with the else statement.

if 1 + 2 == 99999:
    hero.say("I am such a genius! :D")
else:  # if 1+2==99999 is False...
    hero.say("I'm dumb")  # ...I'm dumb!

elif
Elif statement is stuck inside an if and else, you can have as many elifs as you want, but you can only have one if, and one else. You process elifs usually with two conditions, and one is true the other is false.

if 1+1==11 and 9+10==21 and 3+3==6:  # if all three conditions are True...
    hero.say("I'm SO SMAAART~~~!!")
elif 9+10==21 and 3+3==6:  # 1+1 is not 11, so check if the other two are true.
    hero.say("I made ONE mistake!")
elif 3+3==6  # even 9+10 is not 21! Check if 3+3==6 is true.
    hero.say("I made TWO mistakes!")
else:  # if 1+1==11, 9+10==21, 3+3==6 are ALL False...
    hero.get_defeated_by_teacher()  # ...your teacher is mad xD

In the elif example above, your hero will execute the second elif, in which you say you made two mistakes.

while-True loop

There are two understandings of this loop. One for newbies, and one for the upper-leveled.

  1. When you put this loop, all code inside will run forever. Unless you use a break statement inside, it will never stop.
  2. For the upper-leveled, think of it like this. While this is true, then the code inside will run. But there are no conditions to detect whether or not it is true, so it’s always true, therefore your code will run forever.
    Note: while False also works in code, but there’s no point doing so as the code in it will never run as the condition is already False.

#1 Example

while True:  # code below runs forever.
    hero.attack("Milfshake")  # attack the target named Milfshake.

#2 Example

i = True
while i:  # i is always True.
    print("Hello World!")

while-loop

A while-loop is similar to the while-True loop, but will only run forever when the condition is True and will stop running once the condition turns False.

while I_am_being_a_goodboy:
    hero.say("I am a good boy!")
hero.get_punished()  # This will NEVER run unless I turn into a bad boy >:)
enemies = hero.findEnemies()  # For example, there are 3 enemies
index = 0
while index < len(enemies):  # Keep attacking when the index is less than 3
    enemy = enemies[index]  # The enemy is the 'index' element of the array
    while enemy.health > 0:  # check the health to focus on a single target
        hero.attack(enemy)
    index += 1  # Attack the next enemy in the array (enemies[1])
hero.say("All Defeated!")

break-statement

This is one kind of loop-control statement. As its name says, it breaks from statements before the code normally ends, they are usually used in while-loops, and sometimes in for-loops.

#1 Example

while hero.isAlive():
    hero.say("Good morning!")
    hero.eat()
    hero.sleep()
    if I_get_ill():  # if the hero gets ill...
        break  # ...break out of the while-loop, hero dies.
mom.getSad()  # Once you die, your mom will be sad.

#2 Example

for index in range(10):  # repeat 10 times
    hero.eatCookie("Chocolate Flavored")  # eats the chocolate flavored cookie
    if I_am_full():  # when you can't eat anymore...
        break  # Stop eating, break out instead of eating all 10.
hero.burp()

continue-statement

The continue-statement is the opposite of the break statement, instead of breaking, it continues to the next code inside the loop.

while True:
    if mom.isHappy():
        mom.reward(hero)
    else:
        continue  # doesn't do anything, continue to see if dad is happy
    if dad.isHappy():
        dad.buy("Xbox", hero)
    else:
        continue  # continue up to see if mom is happy

pass-statement

The pass statement is used as a placeholder for future code, pass doesn’t do anything, but you avoid getting an error when empty code is not allowed in loops and statements.

while True:
    pass  # This will avoid you getting an error for empty while-loop

for-loop

The for loop uses the loop array which allows the body of the loop to know the exact sequencing of each iteration. Again, it runs as long as the condition is met (value is True), break statements can be used in for-loops. For-loops have two parts: for X in Y, while the X is the index or the variable, the Y is the loop array.

enemies = ["MilkShake", "Watachinao", "Watamelon"]
for enemy in enemies:  # for each enemy in the enemies array...
    while enemy.health > 0:  # ...attack the enemy until it's dead.
        hero.attack(enemy)
# Note that the variable will automatically increment in the for-loop.

for-in-loop

Like the for-loop, but this one uses an index in the LENGTH of the loop array to loop over. And this one doesn’t define your variable, so you will have to set up the index element of the array for the variable.

codeText = ["qwerty", "aswd", "xyz", "abcd"]
for index in range(len(codeText)):  # Use the index to loop over the length of the codetext (4)
    text = codeText[index]  # Define 'text' as the 'index' element of codeText
    print(text)  # print the text
    event.wait(1)  # wait one second
print("Finished printing code texts")

for-enumerate-loop

This loop, you can think of it as a COMBINED version of the for-loop and the for-in-loop. It uses both the index and the variable.

enemies = hero.findEnemies()
enemyAtkPoints = [{'x': 2, 'y': 2}, {'x': 100, 'y': 40}]
for index, enemy in enumerate(enemies):  # gives both the index and defines 'enemy'
    point = enemyAtkPoints[index]  # Define the point using 'index'
    hero.moveXY(point.x, point.y)  # Move to the point...
    while enemy.health > 0:
        hero.attack(enemy) # ...then kill the enemy

Nested-statements

As the name says, it’s a statement nested inside another bigger statement.

if 1:
    hero.say("One is here!")
    if 2:  # This if-statement is nested inside another if-statement.
        hero.say("Two is here too!")
        if 3:  # 1 and 2 are here, check if the last '3' is here or not.
            hero.say("Everyone is here! Party time!")
        else:  # 1 and 2 are here, but 3 is not.
            hero.say("Three is gone!")
    else:  # If 1 is here, but not 2
        hero.say("No two, rip")
        if 3:  # If 1 and 3 are here...
            hero.say("Three is here to make me feel better!")
        else:  # Only 1 is here
            hero.say("I am a lonely One")
elif 2:
    hero.say("One isn't here, but two is here!")
    if 3:  # If 2 and 3 are here...
        hero.say("3 is here to accompany me!")
    else:  # Only 2 is here
        hero.say("I am a lonely Two")
elif 3:  # Only 3 is here, we've checked 1 and 2 already
    hero.say("I am a lonely Three")
else:  # No one is here
    hero.say("I'M DOOMED!!")

definition

This is used to define a certain variable or a function, with methods or code pieces. You can double define a variable with a defined function that returns a value.

#1 Example (defining variable)

enemy = hero.findNearestEnemy()  # define the 'enemy' with the findNearestEnemy() method
item = hero.findNearestItem() # define the 'item' as the nearest item.
myAge = 999999 # defines myAge as a number

#2 Example (defining method)

[No Parameter]

def count():  # define the count() method, remember codes inside needs to be indented
    hero.say("1, 2, 3")
    hero.say("4, 5, 6")
    hero.say("7, 8, 9, 10")

count()  # call the count() method
# Note that you can use a while-true inside a definition, but it will go forever.

[With Parameter]

def countTo(n):  # use 'n' as parameter, passed later in an argument when this function is called
    for index in range(n):
        print(index)

countTo(10)  # 10 is the argument stored as the parameter when the function is called

It’s over. That’s the Beginner Guide to CodeCombat. Please drop a :heart: if you liked it. Hopes this guide helps new players!

Advanced Guide will pull off in about 2~3 months.

17 Likes

Damn this is good. Imma put all the attention to myself. :smiley:
Jk.

https://discourse.codecombat.com/t/advanced-level-editor-guide/29485/8
Also, Witches have 120 health.

Hmmm, has Zana’s cost increased, or do I just remember it wrong? I remember buying her for 7500

Oh also, if you use while loops with a condition in CodeCombat it gives an infinite loop for whatever reason, so do

while True:
    if not condition:
        break
    do stuff
2 Likes

You can use throwPos with degreesToRadians() to throw at a place even if the enemy is greater than your attack range. Did you take that from me?

The nested statements are really funny xD

Use is instead of ==, is is native while == isn’t, and with is there are even things like is not which makes the code more readable :]

I reviewed the levels in glaciers and made it up with Vectors
I came up with the code below, and it works pretty nice!

throwPos = Vector.subtract(enemy.pos, hero.pos)
throwPos = Vector.normalize(throwPos)
throwPos = Vector.multiply(throwPos, 10)
throwPos = Vector.add(hero.pos, throwPos)
throwX = throwPos.x
throwY = throwPos.y
hero.attackPos(throwX, throwY)

Changelog:
Updated on May 3

  • Added the price of heroes (gems) for a clearer reference.
  • Added the links to the clans to help people to get the exclusive heroes (Ned, Armando)
  • Fixed witch’s health to 120, thanks to @RangerGrant9307!
  • Will add “buildables” list before May 7th, which shows a list of things that you can be build, this is to differ them from summonable units. Will change caltrops’ team to None.

P. S. @nick, is it possible to make this guide a wiki? :eyes:
The parts are “Hero Choose”, “Armor Tips”, “Unit introduction”, “Collectables”, “Items Combo”, and “Loops, statements, definitions”

2 Likes

Done :+1:

Fantastic guide - Lots of useful and detailed information that’ll help a lot of users starting out!

4 Likes

Thanks so much! (20 chars)

1 Like

Cool guide! There are a couple of things I don’t agree with (about heroes) but in total it’s great!

Wow! It’s really awesome. Thank you for the guide.

1 Like

I absolutely love this! Super well done! Thanks so much, @Watamelon!

1 Like

@Watamelon Ogre-F has 250 health. :slight_smile:

1 Like

Thanks for pointing it out!

Also, maybe talk about the other wizard spellbooks?

Sure, working on it.

1 Like

hmm made an edit i hope its ok. the thorn prick is way underrated though it helped me cheese half of all the backwoods forest levels.

1 Like

Changelog:
Updated on May 6

  • Added a separate list “Buildables” from the unit class, this will avoid people getting the units and buildables messed up
  • Fixed some grammar issues.
  • Beautified the format of the guide
  • More works in the progress. @RangerGrant9307, thanks for your idea!
1 Like

I really think this guide is awesome (I haven’t read through it all as a i didnt have the time) and im really sure it will help a lot of new programmers

A small suggestion is that you can make it a table of contents, if you click on the gear icon while editing it, it should give you this option called insert table of contents or something of that sort and then after updating the post, you can click on a title and it would take you to that point :slight_smile:

1 Like

I just noticed:


lol, even the devs want a guide to their own game (I mean this as a joke)

2 Likes