diff --git a/docs/api.md b/docs/api.md index 77c03049..e2a9fd86 100644 --- a/docs/api.md +++ b/docs/api.md @@ -138,12 +138,12 @@ localStorage core.js实际上是所有API的入口(路由),核心API的实现在其他几个文件中,core.js主要进行转发操作。 -core.nextX() -获得勇士面向的下一个位置的x坐标 +core.nextX(n) +获得勇士面向的第n个位置的x坐标,n可以省略默认为1(即正前方) -core.nextY() -获得勇士面向的下一个位置的y坐标 +core.nextY(n) +获得勇士面向的第n个位置的y坐标,n可以省略默认为1(即正前方) core.openDoor(id, x, y, needKey, callback) [异步] diff --git a/libs/control.js b/libs/control.js index f1b2c5b6..33bcab03 100644 --- a/libs/control.js +++ b/libs/control.js @@ -990,25 +990,25 @@ control.prototype.getHeroLoc = function (itemName) { } ////// 获得勇士面对位置的x坐标 ////// -control.prototype.nextX = function() { +control.prototype.nextX = function(n) { var scan = { 'up': {'x': 0, 'y': -1}, 'left': {'x': -1, 'y': 0}, 'down': {'x': 0, 'y': 1}, 'right': {'x': 1, 'y': 0} }; - return core.getHeroLoc('x')+scan[core.getHeroLoc('direction')].x; + return core.getHeroLoc('x')+scan[core.getHeroLoc('direction')].x*(n||1); } ////// 获得勇士面对位置的y坐标 ////// -control.prototype.nextY = function () { +control.prototype.nextY = function (n) { var scan = { 'up': {'x': 0, 'y': -1}, 'left': {'x': -1, 'y': 0}, 'down': {'x': 0, 'y': 1}, 'right': {'x': 1, 'y': 0} }; - return core.getHeroLoc('y')+scan[core.getHeroLoc('direction')].y; + return core.getHeroLoc('y')+scan[core.getHeroLoc('direction')].y*(n||1); } ////// 更新领域、夹击、阻击的伤害地图 ////// diff --git a/libs/core.js b/libs/core.js index 2015a97b..ed43bd8a 100644 --- a/libs/core.js +++ b/libs/core.js @@ -499,13 +499,13 @@ core.prototype.getHeroLoc = function (itemName) { } ////// 获得勇士面对位置的x坐标 ////// -core.prototype.nextX = function() { - return core.control.nextX(); +core.prototype.nextX = function(n) { + return core.control.nextX(n); } ////// 获得勇士面对位置的y坐标 ////// -core.prototype.nextY = function () { - return core.control.nextY(); +core.prototype.nextY = function (n) { + return core.control.nextY(n); } /////////// 自动行走 & 行走控制 END /////////// diff --git a/libs/events.js b/libs/events.js index d69b7a4c..06ec8646 100644 --- a/libs/events.js +++ b/libs/events.js @@ -850,7 +850,7 @@ events.prototype.getNextItem = function() { ////// 获得某个物品 ////// events.prototype.getItem = function (itemId, itemNum, itemX, itemY, callback) { - // core.getItemAnimate(itemId, itemNum, itemX, itemY); + itemNum=itemNum||1; core.playSound('item.mp3'); var itemCls = core.material.items[itemId].cls; core.items.getItemEffect(itemId, itemNum); diff --git a/libs/items.js b/libs/items.js index 6e0e0665..82ee9204 100644 --- a/libs/items.js +++ b/libs/items.js @@ -123,6 +123,7 @@ items.prototype.removeItem = function (itemId) { ////// 增加某个物品的个数 ////// items.prototype.addItem = function (itemId, itemNum) { + itemNum=itemNum||1; var itemData = core.material.items[itemId]; var itemCls = itemData.cls; if (itemCls == 'items') return; diff --git a/project/icons.js b/project/icons.js index b7461654..2d7e35df 100644 --- a/project/icons.js +++ b/project/icons.js @@ -235,7 +235,8 @@ icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = 'knife': 42, 'moneyPocket': 46, 'shoes': 47, - 'hammer': 48 + 'hammer': 48, + 'jumpShoes': 49 }, 'autotile': { // 所有的Autotile列表;后面的index简单取0即可 'autotile': 0, diff --git a/project/images/items.png b/project/images/items.png index 626b63b7..cce829cc 100644 Binary files a/project/images/items.png and b/project/images/items.png differ diff --git a/project/items.js b/project/items.js index 772b13e0..94d4f2d3 100644 --- a/project/items.js +++ b/project/items.js @@ -227,6 +227,11 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "cls": "tools", "name": "生命魔杖", "text": "可以恢复100点生命值" + }, + "jumpShoes": { + "cls": "tools", + "name": "跳跃靴", + "text": "能跳跃到前方两格处" } }, "itemEffect": { @@ -304,7 +309,8 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "shield3": "core.plugin.useEquipment(itemId)", "shield4": "core.plugin.useEquipment(itemId)", "shield5": "core.plugin.useEquipment(itemId)", - "lifeWand": "core.insertAction([\n\t{\"type\": \"input\", \"text\": \"请输入生命魔杖使用次数:(0-${item:lifeWand})\"},\n\t{\"type\": \"if\", \"condition\": \"flag:input<=item:lifeWand\",\n\t\t\"true\": [\n\t\t\t{\"type\": \"setValue\", \"name\": \"item:lifeWand\", \"value\": \"item:lifeWand-flag:input\"},\n\t\t\t{\"type\": \"setValue\", \"name\": \"status:hp\", \"value\": \"status:hp+flag:input*100\"},\n\t\t\t\"成功使用${flag:input}次生命魔杖,恢复${flag:input*100}点生命。\"\n\t\t],\n\t\t\"false\": [\"输入不合法!\"]\n\t},\n]);\ncore.setItem('lifeWand', core.itemCount('lifeWand')+1);" + "lifeWand": "core.insertAction([\n\t{\"type\": \"input\", \"text\": \"请输入生命魔杖使用次数:(0-${item:lifeWand})\"},\n\t{\"type\": \"if\", \"condition\": \"flag:input<=item:lifeWand\",\n\t\t\"true\": [\n\t\t\t{\"type\": \"setValue\", \"name\": \"item:lifeWand\", \"value\": \"item:lifeWand-flag:input\"},\n\t\t\t{\"type\": \"setValue\", \"name\": \"status:hp\", \"value\": \"status:hp+flag:input*100\"},\n\t\t\t\"成功使用${flag:input}次生命魔杖,恢复${flag:input*100}点生命。\"\n\t\t],\n\t\t\"false\": [\"输入不合法!\"]\n\t},\n]);\ncore.setItem('lifeWand', core.itemCount('lifeWand')+1);", + "jumpShoes": "core.insertAction({\"type\":\"jumpHero\",\"loc\":[core.nextX(2),core.nextY(2)]});" }, "canUseItemEffect": { "book": "true", @@ -336,6 +342,7 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "shield4": "true", "shiled5": "true", "shield5": "true", - "lifeWand": "true" + "lifeWand": "true", + "jumpShoes": "var nx=core.nextX(2),ny=core.nextY(2);nx>=0&&nx<=12&&ny>=0&&ny<=12&&core.getBlock(core.nextX(2), core.nextY(2))==null" } } \ No newline at end of file diff --git a/project/maps.js b/project/maps.js index c410b9d0..afaaaa8c 100644 --- a/project/maps.js +++ b/project/maps.js @@ -80,6 +80,7 @@ maps_90f36752_8815_4be8_b32b_d7fad1d0542e = '66':{'cls': 'items', 'id': 'sword0'}, // 空剑 '67':{'cls': 'items', 'id': 'shield0'}, // 空盾 '68':{'cls': 'items', 'id': 'lifeWand'}, // 生命魔杖 + '69':{'cls': 'items', 'id': 'jumpShoes'}, // 生命魔杖 ////////////////////////// 门、楼梯、传送点部分 //////////////////////////