<<

Ace of Coders 2016 Quickstart

The Battle of Sky Span

CodeCombat Outline

API Reference summon command Basics

Unit Overview Wizard Soldier / Archer Griffin Rider / Paladin / Goliath Trapper / Ninja Librarian / Necromancer

Cheat Sheet API Reference

The has access many methods. Understanding what they do and what they return is important. In-game API references are provided underneath the code editor. A sampling of methods available for thangs:

I distanceTo(target) returns a number of the distance to target unit.

I findByType(stringType[, arrayToSearch]) returns an array of units that have type stringType. If the optional argument arrayToSearch is provided, it filters through the given array.

I findEnemies() returns an array of all alive units on the enemy team.

I findFriends() returns an array of all alive units on your team.

I findNearest(arrayToSearch) returns the nearest unit from a provided array.

I findNearestEnemy() returns the nearest alive unit on the enemy team.

I findNearestFriend() returns the nearest alive unit on your team.

I findEnemyMissiles() returns an array of projectiles fired by enemy units. A sampling of properties available for thangs:

I id is the unit identifier and name of a unit.

I health is the amount of health a unit currently has.

I pos an object of with x and y properties which represents the unit’s position.

I target what the unit is currently targeting with an ability or attack or casting.

I type the unit’s type.

I team which team the unit is on "humans" and "ogres" are the two teams.

I maxHealth the max amount of health a unit can have.

I attackRange the distance in meters a unit can attack.

I attackDamage how much damage a unit deals

I rotation is the direction a unit is facing in radians. hero.summon(stringType)

The method hero.summon(stringType) will attempt to summon a unit based on what string is passed in. Possible types are:

I "soldier"

I "archer"

I "griffin-rider"

I "paladin"

I "knight"

I "goliath"

I "trapper"

I "ninja"

I "librarian"

I "necromancer" Note: Each unit costs a certain amount of gold. Be sure to compare the cost of a unit against the amount of gold the hero has. Attempting to summon a unit will cause the hero to pause until they have the required amount of gold.

// Summona soldier if the hero has enough gold to afford one. if(hero.gold >= hero.costOf("soldier")) { hero.summon("soldier"); } hero.command(unit, stringMethodName, arg1, arg2, arg3) Basics

hero.command(unit, stringCommand, arg1, arg2, arg3) is used to command a unit. The unit must be on the hero’s team and must be alive. It performs the stringMethodName on target unit and passes arg1, arg2, and arg3 as arguments.

I unit should be an alive unit under your control, or you may error out.

I stringMethod is a relevant command for the unit to perform. The three commands shared by all units are:

I "move"

I "attack"

I "defend"

I arg1, arg2, and arg3 are the first, second, and third arguments to be passed into the unit’s stringMethodName. These are method specific, so each function will be different.

// Tell the nearest friend to attack the nearest enemy. var friend= hero.findNearestFriend(); var enemy= hero.findNearestEnemy(); hero.command(friend,"attack", enemy); Unit Overview Wizard

Type HP Dmg AtkSpd AtkRng Spd Cost "wizard-thorn" 1834hp — — — 4m/s — This is the hero. Can be red, or blue. Keep yours alive to come out victorious!

Be sure to mouse over the APIs below the code area. Unit Overview Soldier / Archer

Type HP Dmg AtkSpd AtkRng Spd Cost Type HP Dmg AtkSpd AtkRng Spd Cost "soldier" 200hp 6hp 0.5s 3m 6m/s 20gold "archer" 30hp 13hp 0.5s 25m 9m/s 25gold The humble foot soldier. Do not underestimate his usefulness on the Archers are long-range damage-dealing units. With a proper front line battlefield! With 200 health for 20 gold, the Soldier is great at filling out the established, Archers can tear through the enemy line if left undisturbed. front lines. However, with 30 health, they run the risk of a strong wind knocking them out. Unit Overview Griffin Rider / Paladin

Type HP Dmg AtkSpd AtkRng Spd Cost Type HP Dmg AtkSpd AtkRng Spd Cost "griffin-rider" 160hp 20hp 0.5s 20m 20m/s 65gold "paladin" 600hp 20hp 0.4s 3m 8m/s 85gold Griffin Riders are powerful aerial units capable of throwing a spear hard Paladins are defenders of light! High health, high damage units that have enough to knock units around. With their immense speed and high damage, unique utility. They can cast "heal" and use the ability "shield". However, they are great at taking out high-value targets. such benefits are not without cost, and their price in gold is great!

"shield" - Reduces incoming damage by 50% while shielding. "heal" - Heals target unit for 200hp. 5s cooldown. 30m range.

// Commandinga paladin to heal their nearest friend var friends= hero.findFriends(); var paladin= hero.findNearest(hero.findByType("paladin", friends)); var friend= paladin.findNearest(friends) if(paladin&& friend&& paladin.canCast("heal")) { if(friend.health< friend.maxHealth - 200) { hero.command(paladin,"heal", friend); } }

// Shielding against attacking enemies var paladin= hero.findByType("paladin", hero.findFriends())[0]; if(paladin){ var enemy= paladin.findNearestEnemy(); if(enemy.target == paladin){ hero.command(paladin,"shield"); } } Unit Overview Knight / Goliath

Type HP Dmg AtkSpd AtkRng Spd Cost Type HP Dmg AtkSpd AtkRng Spd Cost "knight" 800hp 20hp 0.5s 3m 6m/s 100gold "goliath" 600hp 60hp 1s 5m 4m/s 100gold The noble Knight! A true hero with the highest potential health and many The mighty Goliath from the depths of the desert is a capable warrior. Able abilities to help the frontline. Capable of being commanded to: "shield", to use "warcry", "stomp", "hurl" the massive hero can turn the tide of "cleave", and "bash", he is great for anchoring down and preventing all from battle. passing. "warcry" - Nearby units within 10m get +30% haste factor for 5s. "shield" - Reduces incoming damage by 75% while shielding. Movement and attacking increased. 10s cooldown. "cleave" - Deal 65 damage to all enemy units in a 15m radius. 10s "stomp" - A high-knockback AoE attack that damages enemy units. Deals cooldown. up to 75 damage to nearby units in a 15m radius. 10s cooldown. "bash" - Strike a unit for 100 damage, with high knockback. 6s cooldown. "hurl" - Grab, deal 50 damage, and toss a unit behind the Goliath. 5s cooldown. // Commanda knight to bash and cleave when ready: var friends= hero.findFriends(); // Hurl enemiesa lot: var knight= hero.findByType("knight", friends)[0]; var goliaths= hero.findByType("goliath", hero.findFriends()); if(knight){ for(vari = 0;i< goliaths.length;i++) { var enemy= knight.findNearestEnemy(); var goliath= goliaths[i]; if(enemy){ var enemy= goliath.findNearestEnemy(); if(knight.isReady("bash")) { if(enemy&& goliath.isReady("hurl")) { hero.command(knight,"bash", enemy); hero.command(goliath,"hurl", enemy); } else if(knight.isReady("cleave")) { } hero.command(knight,"cleave", enemy); } } else{ hero.command(knight,"attack", enemy); } } } Unit Overview Trapper / Ninja

Type HP Dmg AtkSpd AtkRng Spd Cost Type HP Dmg AtkSpd AtkRng Spd Cost "trapper" 250hp 12hp 1s 45m 6m/s 100gold "ninja" 150hp 20hp 0.7s 25m 10m/s 100gold The long range Trapper is a deadly sniper. Capable of dealing damage from The Ninja is a fast, high-damage hero. Employing a dangerous backstabbing incredible distances. But a trapper wouldn’t be a trapper without being able dagger, and bouncy razordiscs she is a terror in the shadows. Be sure to use to build traps! Use "throw", "buildXY","beartrap" , and "scattershot" to "throw", "backstab", and "dash". help on the battlefield. "throw" - Throws a razordisc which damages the first enemy unit it touches. "throw" - Throws an explosive potion which deals area of effect damage to Can bounce off walls. 80m range, deals 200 damage, 5s cooldown. all units in the blast radius. 30m throw range, 35 damage, 7.5s cooldown, "backstab" - A melee attack that does massive damage when behind a unit. 15m blast radius. Deals 500 damage when behind a unit, 5s cooldown. "buildXY" - "beartrap" can trap a unit that steps on it. Takes 4s to build a "dash" - Quickly move towards a target position. 5s cooldown. trap. // Dash ina random direction. "scattershot" - Fires 10 bullets in 45 degree arc towards target unit, var friends= hero.findFriends(); position, or just in front of the trapper. 7.5s cooldown. for(vari = 0;i< friends.length;i++) { // Build lots of bear traps, forever. var friend= friends[i]; hero.summon("trapper"); if(friend.type =="ninja"){ var trapper= hero.findByType("trapper", hero.findFriends()); var xRand = -1 + Math.random() * 2; while(true){ var yRand = -1 + Math.random() * 2; if(trapper){ hero.command(friend,"dash",{x:xRand,y:yRand}); var xPos= trapper.pos.x; } var yPos= trapper.pos.y; } hero.command(trapper,"buildXY","bear-trap", xPos, yPos); } } Unit Overview Librarian / Necromancer

Type HP Dmg AtkSpd AtkRng Spd Cost Type HP Dmg AtkSpd AtkRng Spd Cost "librarian" 150hp 8hp 0.5s 30m 7m/s 100gold "necromancer" 100hp 8hp 0.5s 20m 10m/s 100gold The Librarian is a useful support hero capable of buffing heroes and shooting The nefarious Necromancer is a master of the dead. Able to tap into the very massive force-bolts. All of her abilities are spells so be sure to use "cast" life force of units and mangle it in unspeakable ways. Being a caster, all his when commanding her: "grow", "haste", and "force-bolt". abilities must be "cast", such as: "soul-link", "summon-undead", and "sacrifice". "grow" - Increases a unit’s health by 3x, slows their speed down to 1/3 their Spd. 5s duration, 10s cooldown, 30m cast range. "soul-link" - Links two units health together, so they split damage evenly. "haste" - Increases a unit’s haste factor by 2. 5s duration, 9s cooldown, 30m 10s cooldown, 25m range. cast range. "summon-undead" - Summons a merciless skeleton which cannot be "force-bolt" - Fires a massive projectile with high-knockback towards a commanded by the hero. 10s cooldown. unit. 30 damage, 3s cooldown, 30m range. "sacrifice" - Redistributes the power by killing a friendly unit. The receiver gains part of the powers of the slain unit. 2s cooldown, 20m range. // Buff an ally var friends= hero.findFriends(); // Consume the nearest soldier and give the power to the hero. var librarian= hero.findByType("librarian", friends); var necro= hero.findByType("necromancer", hero.findFriends())[0]; if(librarian){ var soldier= necro.findNearest(hero.findByType("soldier", if(librarian.canCast("grow")) { hero.findFriends())); hero.command(librarian,"cast","grow", friends[0]); if(necro&& soldier){ } else if(librarian.castGrow("haste")) { hero.command(necro,"sacrifice", soldier, hero); hero.command(librarian,"cast","haste", friends[0]); } } } // Soul link two units together var friends= hero.findFriends(); var necro= hero.findByType("necromancer", friends)[0]; if(friends.length > 2) { var friend1= friends[0]; var friend2= friends[0]; hero.command(necro,"cast","soul-link", friend1, friend2); } Cheat Sheet

Name Type HP Dmg AtkSpd AtkRng Spd Cost commands Hero "wizard-thorn" 1834hp — — — 4m/s — commander Soldier "soldier" 200hp 6hp 0.5s 3m 6m/s 20gold default Archer "archer" 30hp 13hp 0.5s 25m 9m/s 25gold default Griffin Rider "griffin-rider" 160hp 20hp 0.5s 20m 20m/s 65gold default ("cast","heal", target) Paladin "paladin" 600hp 20hp 0.4s 3m 8m/s 85gold ("shield") ("cleave"[, target]) Knight "knight" 800hp 20hp 0.5s 3m 6m/s 100gold ("bash", target) ("shield") ("stomp") Goliath "goliath" 600hp 60hp 1s 5m 4m/s 100gold ("warcry") ("hurl", target) ("throw", target) Trapper "trapper" 250hp 12hp 1s 45m 6m/s 100gold ("buildXY","bear-trap", xPos, yPos) ("scattershot"[, target || targetPos]) ("dash", target || targetPos) Ninja "ninja" 150hp 20hp 0.7s 25m 10m/s 100gold ("throw", target) ("backstab", target) ("cast","grow", target) Librarian "librarian" 150hp 8hp 0.5s 30m 7m/s 100gold ("cast","haste", target) ("cast","force-bolt", target) ("cast","soul-link", target1[, target2]) Necromancer "necromancer" 100hp 8hp 0.5s 20m 10m/s 100gold ("cast","sacrifice", target[, receiver]) ("cast","summon-undead") Skeleton "skeleton" 300hp 15hp 0.4s 3m 7m/s — —