Skip to content

Instantly share code, notes, and snippets.

@AnastasiaDunbar
Last active July 15, 2018 00:27
Show Gist options
  • Save AnastasiaDunbar/7cff2cba32150f5e40c30bd5cea868cc to your computer and use it in GitHub Desktop.
Save AnastasiaDunbar/7cff2cba32150f5e40c30bd5cea868cc to your computer and use it in GitHub Desktop.
Stopping right here.
//1-(The Mighty Sand Yak)
for(;;){var e=this.findNearest(this.findEnemies());if(this.distanceTo(e)<10){this.moveXY(this.pos.x+10,this.pos.y);}}
//2-(Oasis)
for(;;){var e=this.findNearest(this.findEnemies());if(e&&this.distanceTo(e)<10){this.moveXY(this.pos.x-10,this.pos.y);}else{this.moveXY(this.pos.x+10,this.pos.y);}}
//3-(Basin Stampede)
for(;;){var e=this.findNearest(this.findEnemies());var X=this.pos.x+5;var Y=17;if(e){if(e.pos.y>this.pos.y){Y-=10;}else if(e.pos.y<this.pos.y){Y+=10;}}this.moveXY(X,Y);}
//4-(Sarven Road)
for(;;){var e=this.findNearest(this.findEnemies());if(e){this.attack(e);}else{this.moveXY(this.pos.x+7,this.pos.y+9);}}
//5-(Crossroads)
var x=this.pos.x,y=this.pos.y;for(;;){var e=this.findNearestEnemy();if(e){if(e.pos.x<this.pos.x){this.buildXY("fire-trap",x-15,y);}else if(e.pos.x>this.pos.x){this.buildXY("fire-trap",x+15,y);}else if(e.pos.y<this.pos.y){this.buildXY("fire-trap",x,y-15);}else if(e.pos.y>this.pos.y){this.buildXY("fire-trap",x,y+15);}}this.moveXY(x,y);}
//6-(Thunderhooves)
for(;;){var x=this.pos.x,y=this.pos.y;var e=this.findNearestEnemy();if(e){this.buildXY("fence",x,y+(5*Math.sign(e.pos.y-y)));}else{this.moveXY(x+10,y);}}
//7-(Medical Attention)
var t=this.maxHealth/2;while(true){var h=this.health;if(h<t){this.moveXY(65,46);this.say("heal");}else{var e=this.findNearest(this.findEnemies());if(e){this.attack(e);}}}
//8-(Operation 'Killdeer')
for(;;){var e=this.findNearest(this.findEnemies());this.health>this.maxHealth/2?e&&this.attack(e):this.moveXY(75,37);}
//9-(Sarven Sentry)
for(;;){var a=this.findFlag("green"),c=this.findFlag("black");a?(this.buildXY("fence",a.pos.x,a.pos.y),this.removeFlag(a)):c?(this.buildXY("fire-trap",c.pos.x,c.pos.y),this.removeFlag(c)):this.moveXY(43,31);}
//10-(Keeping Time)
for(;;){if(this.now()>10&&this.now()<35){var c=this.findNearest(this.findItems());if(this.isReady("power-up")){this.powerUp();}if(c){this.moveXY(c.pos.x,c.pos.y);}}else{if(this.health>100){var e=this.findNearest(this.findEnemies());if(e){this.attack(e);}else{this.moveXY(52,50);}}else{this.moveXY(4,22);}}}
//11-(Hoarding Gold)
for(;;){var c=this.findNearest(this.findItems());if(this.gold<25&&c){this.moveXY(c.pos.x,c.pos.y);}else{break;}}hero.moveXY(58,33);this.say(this.gold);
//12-(Decoy Drill)
var b=0;while(b<4){var i=this.findNearest(this.findItems());if(i){this.moveXY(i.pos.x,i.pos.y);}if(this.gold>=25){this.buildXY("decoy",this.pos.x,this.pos.y);b++;}}hero.moveXY(14,36);hero.say(b);
//13-(Bookkeeper)
//What? I can't use while(this.now()<val)? Crashing for no reason just for me to use break statements?
this.TellMaria=function(str){this.moveXY(58,33);this.say(str);};
var EnemiesDefeated=0;
while(this.now()<15){
var e=this.findNearest(this.findEnemies());
if(e){this.attack(e);EnemiesDefeated++;} //Why does it skip EnemiesDefeated++?
}
this.TellMaria(EnemiesDefeated);
var CoinsCollected=0;
while(this.now()<30){
var c=this.findNearest(this.findItems());
if(c){this.moveXY(c.pos.x,c.pos.y);CoinsCollected++;}
}
this.TellMaria(CoinsCollected);
while(this.now()<45){
var e=this.findNearest(this.findEnemies());
if(e){this.attack(e);EnemiesDefeated++;}
}
this.TellMaria(EnemiesDefeated);
//Double Gaps
var range=2,buildDistance=10,avoid,list;
for(;;){
hero.moveXY(40,hero.pos.y-12);
avoid=undefined;
list=[hero.findNearestEnemy(),hero.findNearestItem()];
for(var i=0;i<list.length;i++){
if(list[i]&&Math.abs(list[i].pos.y-hero.pos.y)<=range){
avoid=list[i];
break;
}
}
if(avoid){hero.buildXY("fence",hero.pos.x+(hero.pos.x<avoid.pos.x?buildDistance:-buildDistance),hero.pos.y);}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment