codecombat之边远地区的森林1-11关及地牢38关代码分享

codecombat中国游戏网址:http://www.codecombat.cn/

全部代码为javascript代码分享

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1、Boom! and Bust

// Use your buildXY hammer to build two "fire-trap"s near the gate.

// They will detonate when you move back to a safe distance!

// Then, make a run for the forest!

this.buildXY("fire-trap", 35, 35);

this.buildXY("fire-trap", 35, 30);

this.moveLeft(1);

this.moveRight(3);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2、森林保卫战

// 建立两个围栏保护村民

// 把鼠标放在地图上得到X,Y坐标

this.buildXY("fence", 40, 52);

this.buildXY("fence", 40, 20);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3、羊肠小道

// 到小路的尽头去,并在那儿修一个栅栏。

// 利用你的 moveXY(x, y)坐标移动功能。

this.moveXY(34, 45);

this.moveXY(36, 59);

this.moveXY(36, 42);

this.moveXY(48, 22);

this.moveXY(36, 13);

this.moveXY(71, 17);

this.moveXY(73, 63);

this.moveXY(71, 17);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

4、咬手指的人

// 仅仅有当 if 条件为真的时候,if 语句以下的命令才会运行。

// 在条件中。==表示左右两边相等

if (2 + 2 == 4) {

this.say("Hey!");

}

if (2 + 2 == 5) {

this.say("Yes, you!");

}

// 改变这里的条件让你的英雄说『来找我!』

if (1) {  // ? Make this true.

this.say("Come at me!");

}

if (1) {  // ? Make this true.

// 加入一句或者很多其它骂人的话来吸引食人魔,来点有创意的!

this.say("fuck you bitch !");

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

5、宝石或者死亡

// 在 if 条件下的命令仅仅有在条件为真的时候执行。

// 修复全部的 if 条件判定来赢得本关

// ==的意思是等于

if (1 + 1 + 1 == 4) {  // ?

Make this false.

this.moveXY(5, 15);  // 移动到第一个地雷位置

}

if (2 + 2 == 4) {  // ? Make this true.

this.moveXY(15, 41);  // 移动到第一个宝石的位置。

}

// !=的意思是不等于

if (2 + 2 != 3) {  // ?

Make this true.

this.moveXY(25, 16);  // 移动到第二个宝石的位置

}

// <的意思是比什么小

if (2 + 2 < 5) {  // ?

Make this true.

var enemy = this.findNearestEnemy();

this.attack(enemy);

}

if (2 < 1) {  // ? Make this false.

this.moveXY(40, 55);

}

if (false) {  // ? Make this false.

this.moveXY(50, 10);

}

if (true) {  // ? Make this true.

this.moveXY(55, 26);

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

6、边远伏击

// 移动到各个节点。并消灭每个食人魔。

this.moveXY(24, 42);

var enemy1 = this.findNearestEnemy();

// 在攻击之前。使用if语句来确保当前有敌人存在。

if (enemy1) {

this.attack(enemy1);

this.attack(enemy1);

}

this.moveXY(27, 60);

var enemy2 = this.findNearestEnemy();

if (enemy2) {

this.attack(enemy2);

this.attack(enemy2);

}

this.moveXY(42, 50);

// 再使用一个if语句并攻击!

var enemy3 = this.findNearestEnemy();

if(enemy3){

this.attack(enemy3);

this.attack(enemy3);

}

// 移动到下一个节点并消灭剩余的食人魔。

this.moveXY(39, 24);

var enemy4 = this.findNearestEnemy();

if(enemy4){

this.attack(enemy4);

this.attack(enemy4);

}

this.moveXY(55, 29);

var enemy5 = this.findNearestEnemy();

if(enemy5){

this.attack(enemy5);

this.attack(enemy5);

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7、巡逻兵克星

//记得提升自己的装备水平

// 记得敌人可能还不存在。

loop {

enemy = this.findNearestEnemy();

// 假设是敌人。攻击它!

if(enemy){

this.attack(enemy);

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

8、濒危树林之战

// 仅仅攻击幼小食人魔和投掷者食人魔。

// 别攻击树榴,遇到食人魔快跑。

loop {

var enemy = this.findNearestEnemy();

// 记住:别攻击树榴『burl』

if (enemy.type == "burl") {

this.say("我不攻击树榴『burl』");

}

// type 属性告诉你它是什么种类的生物

if (enemy.type == "munchkin") {

this.attack(enemy);

}

// 使用『if』来攻击投掷者『thrower』

if (enemy.type == "thrower") {

this.attack(enemy);

}

// 假设它是一个食人魔『ogre』,跑到村口去!

if (enemy.type == "ogre") {

this.moveXY(20, 40);

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

9、村庄守护者

// 在村口巡逻。

// 假设发现敌人,击杀他们。

loop {

this.moveXY(35, 34);

var leftEnemy = this.findNearestEnemy();

if (leftEnemy) {

this.attack(leftEnemy);

this.attack(leftEnemy);

}

// 如今移动到右側。

this.moveXY(60, 34);

// 使用if指令推断是否有敌人。有的话,击杀他们。

var rightEnemy = this.findNearestEnemy();

if (rightEnemy) {

this.attack(rightEnemy);

this.attack(rightEnemy);

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

10、荆棘农场

// 在村口巡逻。

// 当你见到食人魔。建立一个火焰陷阱。

// 不要让不论什么农民受到伤害。

loop {

this.moveXY(43, 50);

var topEnemy = this.findNearestEnemy();

if (topEnemy) {

this.buildXY("fire-trap", 43, 50);

}

this.moveXY(25, 34);

var leftEnemy = this.findNearestEnemy();

if (leftEnemy) {

this.buildXY("fire-trap", 25, 34);

}

this.moveXY(43, 20);

var buttomEnemy = this.findNearestEnemy();

if (buttomEnemy) {

this.buildXY("fire-trap", 43, 20);

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

11、背靠背

// 呆在中间防守

loop {

var enemy = this.findNearestEnemy();

if (enemy) {

// 主动出击

this.attack(enemy);

}

else {

// 回到你的阵地防守

this.moveXY(40, 34);

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

番外:地牢第38关~~毁灭天使

this.moveDown();

// 妈妈总对我说,随便吃点你在地牢里找到的蘑菇。

this.moveRight();

this.moveDown();

this.moveUp();

this.moveLeft();

this.moveDown(2);

this.moveRight(4);

this.moveUp();

this.moveLeft();

this.moveUp();

this.moveRight();

this.moveUp();

this.moveLeft();

this.moveDown();

// 找到你去地牢守卫者的路。

loop {

var enemy = this.findNearestEnemy();

if (enemy) {

this.attack(enemy);

}

}

时间: 2024-08-01 22:41:00

codecombat之边远地区的森林1-11关及地牢38关代码分享的相关文章

codecombat之边远地区的森林31-44关代码分享

codecombat中国游戏网址: http://www.codecombat.cn/ 所有代码为javascript代码分享 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 31.为援兵坚持住 // 食人魔正在爬悬崖 // 为集结民兵组织保护足够长时间的农民. loop { var flag = this.findFlag(); var enemy = this.findNearestEnemy(); if (flag) { // 捡旗子 this.pickUpFla

codecombat之边远地区的森林12-22关及地牢39关代码分享

codecombat中国游戏网址: http://www.codecombat.cn/ 所有代码为javascript代码分享 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12.兽人营地 // 如果有敌人,则攻击之 // 如果没有敌人,则攻击财宝箱 loop { // 使用if/else语句 var enemy = this.findNearestEnemy(); if (enemy) { this.attack(enemy); } else { this.atta

codecombat之边远地区的森林23-30关及地牢40\41关代码分享

codecombat中国游戏网址: http://www.codecombat.cn/ 所有代码为javascript代码分享 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23.Agrippa防守 loop { var enemy = this.findNearestEnemy(); if(enemy) { // 用 distanceTo 获取与敌人的距离. var distance = this.distanceTo(enemy); // 如果距离小于5米...

codecombat安息之云山峰11-21关及沙漠38关代码分享

codecombat中国游戏网址: http://www.codecombat.cn/ 所有代码为javascript代码分享 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 11.零和 // 在两分钟内击败敌方英雄. loop { var enemies = this.findEnemies(); var nearestEnemy = this.findNearest(enemies); var item = this.findNearest(this.findIte

codecombat安息之云山峰37-40关及地牢42关代码分享

codecombat中国游戏网址: http://www.codecombat.cn/ 所有代码为javascript代码分享 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 37.Deadly Discs //要有足够的钱买新英雄,大约是4800左右 // If the ogre takes damage, she'll wake up and smash the peasant. // You've got these razor-discs you can throw(). M

【codecombat 中国】攻略--边远地区的深林--深林保卫战

CodeCombat 是一款学习编程的网游,个人觉得这个游戏还是可以的,下面我想分享一下个人玩的经验,希望能够给大家提供参考. 注:我用的JavaScript语言玩的游戏. 游戏链接:codecombat.cn [边远地区的深林--深林保卫战] 这一关卡还是比较简单的,按照提示就可以轻松过关了. 参考代码(JavaScript): // 建立两个围栏保护村民// 把鼠标放在地图上得到X,Y坐标this.buildXY("fence", 40, 52);this.buildXY(&quo

codecombat安息之云山峰1-10关及森林47/48关代码分享

codecombat中国游戏网址: http://www.codecombat.cn/ 所有代码为javascript代码分享 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1.峭壁追逐 // 抓住 Pender Spellbane 去了解她的秘密. loop { // Pender是这里唯一的朋友,所以她总是在最近的位置. pender = this.findNearest(this.findFriends()); if (pender) { // moveXY()

codecombat安息之云山峰32-36关及森林49关代码分享

codecombat中国游戏网址: http://www.codecombat.cn/ 所有代码为javascript代码分享 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32.Sowing Fire // Goal: build three rows of nine fire-traps. // Returns "retreat", "attack", "start-next-trap-column", or "bui

codecombat之Sarven沙漠13-24关及森林45/46关代码分享

codecombat中国游戏网址:http://www.codecombat.cn/ 所有代码为javascript代码分享 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 13.诱饵钻 // 我们在测试一个新的战斗单位:诱饵. // 创建4个诱饵,然后汇报给 Naria var decoysBuilt = 0; loop { var item = this.findNearest(this.findItems()); // 掠夺金币! var x = item.pos