diff --git a/editor.html b/editor.html
index bfdcc48b..6b5aa4ef 100644
--- a/editor.html
+++ b/editor.html
@@ -246,11 +246,11 @@
- 图层:
- 前景
- 事件
- 背景
+
+
+ 背景层
+ 事件层
+ 前景层
diff --git a/libs/control.js b/libs/control.js
index c8c9c5a3..5181700e 100644
--- a/libs/control.js
+++ b/libs/control.js
@@ -1183,116 +1183,7 @@ control.prototype.updateFollowers = function () {
////// 更新领域、夹击、阻击的伤害地图 //////
control.prototype.updateCheckBlock = function() {
- core.status.checkBlock = {};
- if (!core.isset(core.status.thisMap)) return;
- var blocks = core.status.thisMap.blocks;
-
- // Step1: 更新怪物地图
- core.status.checkBlock.map = []; // 记录怪物地图
- for (var n=0;n=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue;
- if (!zoneSquare && Math.abs(dx)+Math.abs(dy)>range) continue;
- core.status.checkBlock.damage[nx+ny*core.bigmap.width]+=enemy.value||0;
- }
- }
- }
- // 存在激光
- if (core.enemys.hasSpecial(enemy.special, 24)) {
- for (var nx=0;nx=core.bigmap.width || ny<0 || ny>=core.bigmap.height || Math.abs(dx)+Math.abs(dy)>1) continue;
- core.status.checkBlock.damage[nx+ny*core.bigmap.width]+=enemy.value||0;
- }
- }
- }
- }
- }
- }
-
-
- // Step3: 更新夹击点坐标,并将夹击伤害加入到damage中
- core.status.checkBlock.betweenAttack = []; // 记录(x,y)点是否有夹击
- for (var x=0;x0 && x0 && y1)
- core.status.checkBlock.damage[x+core.bigmap.width*y] += Math.floor((leftHp+(core.flags.betweenAttackCeil?0:1))/2);
- }
- }
- }
+ return core.enemys.updateCheckBlock();
}
////// 检查并执行领域、夹击、阻击事件 //////
@@ -1944,23 +1835,25 @@ control.prototype.replay = function () {
if (core.canUseItem(itemId)) {
var tools = Object.keys(core.status.hero.items.tools).sort();
var constants = Object.keys(core.status.hero.items.constants).sort();
- var index;
+ var index=-1;
if ((index=tools.indexOf(itemId))>=0) {
- core.status.event.data = {"toolsPage":Math.floor(index/12)+1, "constantsPage":1, "selectId":null}
+ core.status.event.data = {"toolsPage":Math.floor(index/12)+1, "constantsPage":1, "selectId":null};
index = index%12;
}
else if (index=constants.indexOf(itemId)>=0) {
- core.status.event.data = {"toolsPage":1, "constantsPage":Math.floor(index/12)+1, "selectId":null}
+ core.status.event.data = {"toolsPage":1, "constantsPage":Math.floor(index/12)+1, "selectId":null};
index = index%12+12;
}
- core.ui.drawToolbox(index);
+ if (index>=0) {
+ core.ui.drawToolbox(index);
setTimeout(function () {
core.ui.closePanel();
core.useItem(itemId, function () {
core.replay();
});
}, 750 / Math.max(1, core.status.replay.speed));
- return;
+ return;
+ }
}
}
else if (action.indexOf("unEquip:")==0) {
@@ -1979,16 +1872,18 @@ control.prototype.replay = function () {
var equipId = action.substring(6);
var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
var index = ownEquipment.indexOf(equipId);
- core.status.event.data = {"page":Math.floor(index/12)+1, "selectId":null}
- index = index%12+12;
- core.ui.drawEquipbox(index);
- setTimeout(function () {
- core.ui.closePanel();
- core.loadEquip(equipId, function () {
- core.replay();
- });
- }, 750 / Math.max(1, core.status.replay.speed));
- return;
+ if (index>=0) {
+ core.status.event.data = {"page":Math.floor(index/12)+1, "selectId":null};
+ index = index%12+12;
+ core.ui.drawEquipbox(index);
+ setTimeout(function () {
+ core.ui.closePanel();
+ core.loadEquip(equipId, function () {
+ core.replay();
+ });
+ }, 750 / Math.max(1, core.status.replay.speed));
+ return;
+ }
}
else if (action.indexOf("fly:")==0) {
var floorId=action.substring(4);
@@ -2691,7 +2586,7 @@ control.prototype.clearStatusBar = function() {
core.statusBar[e].innerHTML = " ";
});
core.statusBar.image.book.style.opacity = 0.3;
- if (!core.flags.equipboxBotton) {
+ if (!core.flags.equipboxButton) {
core.statusBar.image.fly.style.opacity = 0.3;
}
}
@@ -2769,7 +2664,7 @@ control.prototype.updateStatusBar = function () {
core.statusBar.image.book.src = core.statusBar.icons.book.src;
core.statusBar.image.book.style.opacity = core.hasItem('book')?1:0.3;
- if (!core.flags.equipboxBotton) {
+ if (!core.flags.equipboxButton) {
core.statusBar.image.fly.src = core.statusBar.icons.fly.src;
core.statusBar.image.fly.style.opacity = core.hasItem('fly')?1:0.3;
}
diff --git a/libs/enemys.js b/libs/enemys.js
index d7e0d5d0..b9ab7499 100644
--- a/libs/enemys.js
+++ b/libs/enemys.js
@@ -221,6 +221,11 @@ enemys.prototype.updateEnemys = function () {
return this.enemydata.updateEnemys();
}
+////// 计算领域、夹击、阻击的伤害值 //////
+enemys.prototype.updateCheckBlock = function () {
+ return this.eventdata.updateCheckBlock();
+}
+
////// 获得当前楼层的怪物列表 //////
enemys.prototype.getCurrentEnemys = function (floorId) {
floorId=floorId||core.status.floorId;
diff --git a/libs/events.js b/libs/events.js
index 748782ae..f1a585a0 100644
--- a/libs/events.js
+++ b/libs/events.js
@@ -988,12 +988,7 @@ events.prototype.getItem = function (itemId, itemNum, itemX, itemY, callback) {
core.canvas.event.clearRect(itemX * 32, itemY * 32, 32, 32);
core.updateStatusBar();
- // 检查处理后的事件。
- var event = core.floors[core.status.floorId].afterGetItem[itemX+","+itemY];
- if (core.isset(event)) {
- core.events.doEvents(event, itemX, itemY, callback);
- }
- else if (core.isset(callback)) callback();
+ this.eventdata.afterGetItem(itemId, itemX, itemY, callback);
}
////// 开门 //////
@@ -1087,17 +1082,17 @@ events.prototype.battle = function (id, x, y, force, callback) {
}
else {
+ var nowEquipment = 'hand';
if (core.flags.equipment) {
- var equipId = core.status.hero.equipment[0];
- if (core.isset(equipId))
- if (core.isset(core.material.items[equipId].equip.animate))
- core.drawAnimate(core.material.items[equipId].equip.animate, x, y);
- }
- else {
- core.playSound('attack.mp3');
- core.drawAnimate('hand', x, y);
+ var equipId = (core.status.hero.equipment||[])[0];
+ if (core.isset(equipId) && core.isset(core.material.items[equipId])
+ && core.isset(core.material.items[equipId].equip.animate))
+ nowEquipment = core.material.items[equipId].equip.animate;
}
+ core.playSound('attack.mp3');
+ core.drawAnimate(nowEquipment, x, y);
+
core.events.afterBattle(id, x, y, callback);
}
}
diff --git a/libs/items.js b/libs/items.js
index 4b477361..fe052929 100644
--- a/libs/items.js
+++ b/libs/items.js
@@ -98,8 +98,12 @@ items.prototype.hasItem = function (itemId) {
////// 是否装备某件装备 //////
items.prototype.hasEquip = function (equipId) {
+
+ if (!core.isset(equipId)) return null;
+ if (!core.isset((core.material.items[equipId]||{}).equip)) return null;
+
var equiptype = core.material.items[equipId].equip.type;
- return core.status.hero.equipment[equiptype] == equipId;
+ return equipId == (core.status.hero.equipment||[])[equiptype];
}
////// 设置某个物品的个数 //////
@@ -149,10 +153,16 @@ items.prototype.addItem = function (itemId, itemNum) {
////// 换上 //////
items.prototype.loadEquip = function (equipId, callback) {
-
+
+ if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
+
core.playSound('equip.mp3');
var loadEquip = core.material.items[equipId];
+ if (!core.isset(loadEquip)) {
+ if (core.isset(callback)) callback();
+ return;
+ }
var loadEquipType = loadEquip.equip.type;
var unloadEquipId = core.status.hero.equipment[loadEquipType];
@@ -171,23 +181,29 @@ items.prototype.loadEquip = function (equipId, callback) {
core.status.route.push("equip:"+equipId);
// 装备更换完毕:删除换上的装备
- core.status.hero.items["equips"][equipId]--;
- if (core.status.hero.items["equips"][equipId]==0)
- delete core.status.hero.items["equips"][equipId];
+ core.removeItem(equipId);
// 装备更换完毕:增加卸下的装备
if (core.isset(unloadEquipId))
core.addItem(unloadEquipId, 1);
+ core.log("已装备上"+loadEquip.name, core.material.icons.items[equipId]);
+
if (core.isset(callback)) callback();
}
////// 卸下 //////
items.prototype.unloadEquip = function (equipType, callback) {
-
+
+ if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
+
core.playSound('equip.mp3');
var unloadEquipId = core.status.hero.equipment[equipType];
+ if (!core.isset(unloadEquipId)) {
+ if (core.isset(callback)) callback();
+ return;
+ }
var unloadEquip = core.material.items[unloadEquipId];
// 处理能力值改变
@@ -206,6 +222,8 @@ items.prototype.unloadEquip = function (equipType, callback) {
// 装备更换完毕:增加卸下的装备
core.addItem(unloadEquipId, 1);
+ core.drawTip("已卸下"+unloadEquip.name, core.material.icons.items[unloadEquipId]);
+
if (core.isset(callback)) callback();
}
@@ -213,15 +231,15 @@ items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId)
var compareAtk = 0, compareDef = 0, compareMdef = 0;
if (core.isset(compareEquipId)) {
var compareEquip = core.material.items[compareEquipId];
- compareAtk += compareEquip.equip.atk || 0;
- compareDef += compareEquip.equip.def || 0;
- compareMdef += compareEquip.equip.mdef || 0;
+ compareAtk += (compareEquip.equip||{}).atk || 0;
+ compareDef += (compareEquip.equip||{}).def || 0;
+ compareMdef += (compareEquip.equip||{}).mdef || 0;
}
if (core.isset(beComparedEquipId)) {
var beComparedEquip = core.material.items[beComparedEquipId];
- compareAtk -= beComparedEquip.equip.atk || 0;
- compareDef -= beComparedEquip.equip.def || 0;
- compareMdef -= beComparedEquip.equip.mdef || 0;
+ compareAtk -= (beComparedEquip.equip||{}).atk || 0;
+ compareDef -= (beComparedEquip.equip||{}).def || 0;
+ compareMdef -= (beComparedEquip.equip||{}).mdef || 0;
}
return {"atk":compareAtk,"def":compareDef,"mdef":compareMdef};
}
\ No newline at end of file
diff --git a/main.js b/main.js
index 53ef15ce..7a31642e 100644
--- a/main.js
+++ b/main.js
@@ -397,7 +397,7 @@ main.statusBar.image.fly.onclick = function () {
}
if (main.core.isPlaying()) {
- if (!main.core.flags.equipboxBotton) {
+ if (!main.core.flags.equipboxButton) {
main.core.useFly(true);
}
else {
diff --git a/mota-js b/mota-js
deleted file mode 160000
index 45645884..00000000
--- a/mota-js
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 45645884940c700b6121ffdd3624f9ed0ed062cb
diff --git a/project/data.js b/project/data.js
index 42dafb53..ce29702f 100644
--- a/project/data.js
+++ b/project/data.js
@@ -72,10 +72,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"mdef": 100,
"money": 100,
"experience": 0,
- "equipment": [
- null,
- null
- ],
+ "equipment": [],
"items": {
"keys": {
"yellowKey": 0,
@@ -204,7 +201,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"snowFourDirections": false,
"bigKeyIsBox": false,
"equipment": true,
- "equipboxBotton": false,
+ "equipboxButton": false,
"enableAddPoint": false,
"enableNegativeDamage": false,
"hatredDecrease": true,
diff --git a/project/functions.js b/project/functions.js
index 8d6468b0..ecba7c1c 100644
--- a/project/functions.js
+++ b/project/functions.js
@@ -16,7 +16,7 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
if (core.flags.snowFourDirections)
core.material.items.bomb.text = "可以将四周的熔岩变成平地";
// 是否启用装备栏
- if (core.flags.equipboxBotton) {
+ if (core.flags.equipboxButton) {
core.statusBar.image.fly.src = core.statusBar.icons.equipbox.src;
core.flags.equipment = true;
}
@@ -221,9 +221,9 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 在这里增加其他的自定义事件需求
/*
if (enemyId=='xxx') {
- core.unshift(todo, [
- {"type": "...", ...},
- ]);
+ core.unshift(todo, [
+ {"type": "...", ...},
+ ]);
}
*/
@@ -266,6 +266,24 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
}
if (core.isset(callback)) callback();
},
+////// 获得一个道具后触发的事件 //////
+"afterGetItem" : function(itemId,x,y,callback) {
+ // 获得一个道具后触发的事件
+
+ var todo = [];
+ if (core.isset(x) && core.isset(y)) {
+ var event = core.floors[core.status.floorId].afterGetItem[x+","+y];
+ if (core.isset(event)) {
+ core.unshift(todo, event);
+ }
+ }
+
+ if (todo.length>0) {
+ core.events.insertAction(todo,x,y);
+ }
+
+ if (core.isset(callback)) callback();
+},
////// 改变亮灯之后,可以触发的事件 //////
"afterChangeLight" : function(x,y) {
// 改变亮灯之后,可以触发的事件
@@ -449,6 +467,125 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
"damage": damage
};
},
+"updateCheckBlock": function () {
+ // 领域、夹击、阻击等的伤害值计算
+
+ core.status.checkBlock = {};
+ if (!core.isset(core.status.thisMap)) return;
+ var blocks = core.status.thisMap.blocks;
+
+ // Step1: 更新怪物地图
+ core.status.checkBlock.map = []; // 记录怪物地图
+ for (var n=0;n=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue;
+ if (!zoneSquare && Math.abs(dx)+Math.abs(dy)>range) continue;
+ core.status.checkBlock.damage[nx+ny*core.bigmap.width]+=enemy.value||0;
+ }
+ }
+ }
+ // 存在激光
+ // 如果要防止激光伤害,可以直接简单的将 flag:no_laser 设为true
+ if (core.enemys.hasSpecial(enemy.special, 24) && !core.hasFlag("no_laser")) {
+ for (var nx=0;nx=core.bigmap.width || ny<0 || ny>=core.bigmap.height || Math.abs(dx)+Math.abs(dy)>1) continue;
+ core.status.checkBlock.damage[nx+ny*core.bigmap.width]+=enemy.value||0;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Step3: 更新夹击点坐标,并将夹击伤害加入到damage中
+ core.status.checkBlock.betweenAttack = []; // 记录(x,y)点是否有夹击
+ // 如果要防止夹击伤害,可以简单的将 flag:no_betweenAttack 设为true
+ if (!core.hasFlag('no_betweenAttack')) {
+ for (var x=0;x0 && x0 && y1)
+ core.status.checkBlock.damage[x+core.bigmap.width*y] += Math.floor((leftHp+(core.flags.betweenAttackCeil?0:1))/2);
+ }
+ }
+ }
+ }
+},
"updateEnemys" : function () {
// 更新怪物数据,可以在这里对怪物属性和数据进行动态更新,详见文档——事件——怪物数据的动态修改
// 比如下面这个例子,如果flag:xxx为真,则将绿头怪的攻击设为100,金币设为20
diff --git a/project/icons.js b/project/icons.js
index 98e69bb6..314c671a 100644
--- a/project/icons.js
+++ b/project/icons.js
@@ -203,12 +203,13 @@ icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
'greenPotion': 22,
'yellowPotion': 23,
'lifeWand': 33,
- 'blank': 60,
+ "sword0": 60,
'sword1': 50,
'sword2': 51,
'sword3': 52,
'sword4': 53,
'sword5': 54,
+ "shield0": 61,
'shield1': 55,
'shield2': 56,
'shield3': 57,
diff --git a/project/images/items.png b/project/images/items.png
index 4979dc24..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 08fa5407..a3ee85b7 100644
--- a/project/items.js
+++ b/project/items.js
@@ -45,8 +45,18 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "items",
"name": "绿血瓶"
},
+ "sword0": {
+ "cls": "items",
+ "name": "破旧的剑",
+ "text": "一把已经生锈的剑",
+ "equip": {
+ "type": 0,
+ "atk": 0,
+ "animate": "sword"
+ }
+ },
"sword1": {
- "cls": "item",
+ "cls": "items",
"name": "铁剑",
"text": "一把很普通的铁剑",
"equip":{
@@ -95,6 +105,15 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"animate": "sword"
}
},
+ "shield0": {
+ "cls": "items",
+ "name": "破旧的盾",
+ "text": "一个很破旧的铁盾",
+ "equip": {
+ "type": 1,
+ "def": 0
+ }
+ },
"shield1": {
"cls": "items",
"name": "铁盾",
@@ -279,11 +298,13 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"bluePotion": "core.status.hero.hp += core.values.bluePotion * ratio",
"yellowPotion": "core.status.hero.hp += core.values.yellowPotion * ratio",
"greenPotion": "core.status.hero.hp += core.values.greenPotion * ratio",
+ "sword0": "core.status.hero.atk += 0",
"sword1": "core.status.hero.atk += 10",
"sword2": "core.status.hero.atk += 20",
"sword3": "core.status.hero.atk += 40",
"sword4": "core.status.hero.atk += 80",
"sword5": "core.status.hero.atk += 100",
+ "shield0": "core.status.hero.def += 0",
"shield1": "core.status.hero.def += 10",
"shield2": "core.status.hero.def += 20",
"shield3": "core.status.hero.def += 40",
@@ -302,16 +323,18 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"bluePotion": "',生命+'+core.values.bluePotion * ratio",
"yellowPotion": "',生命+'+core.values.yellowPotion * ratio",
"greenPotion": "',生命+'+core.values.greenPotion * ratio",
- "sword1": ",攻击+10",
- "sword2": ",攻击+20",
- "sword3": ",攻击+40",
- "sword4": ",攻击+80",
- "sword5": ",攻击+100",
- "shield1": ",防御+10",
- "shield2": ",防御+20",
- "shield3": ",防御+40",
- "shield4": ",防御+80",
- "shield5": ",防御+100,魔防+100",
+ "sword0": "',攻击+0'",
+ "sword1": "',攻击+10'",
+ "sword2": "',攻击+20'",
+ "sword3": "',攻击+40'",
+ "sword4": "',攻击+80'",
+ "sword5": "',攻击+100'",
+ "shield0": "',防御+0'",
+ "shield1": "',防御+10'",
+ "shield2": "',防御+20'",
+ "shield3": "',防御+40'",
+ "shield4": "',防御+80'",
+ "shield5": "',防御+100,魔防+100'",
"bigKey": "',全钥匙+1'",
"superPotion": "',生命值翻倍'",
"moneyPocket": "',金币+'+core.values.moneyPocket"