diff --git a/_docs/event.md b/_docs/event.md
index 700a835f..bb18169f 100644
--- a/_docs/event.md
+++ b/_docs/event.md
@@ -441,7 +441,7 @@ value是一个表达式,将通过这个表达式计算出的结果赋值给nam
另外注意一点的是,如果hp被设置成了0或以下,将触发lose事件,直接死亡。
-### setValue2:增减勇士的某个属性、道具个数,或某个变量/Flag的值
+### addValue:增减勇士的某个属性、道具个数,或某个变量/Flag的值
和`{"type": "setValue"}`的写法完全相同,不过此项是可以直接将值加减到原始数值上。
@@ -450,11 +450,11 @@ value是一个表达式,将通过这个表达式计算出的结果赋值给nam
``` js
"x,y": [ // 实际执行的事件列表
{"type": "setValue", "name": "status:atk", "value": "status:atk+10" } // 攻击提高10点
- {"type": "setValue2", "name": "status:atk", "value": "10" } // 和上面写法等价
+ {"type": "addVakue", "name": "status:atk", "value": "10" } // 和上面写法等价
{"type": "setValue", "name": "item:yellowKey", "value": "item:yellowKey-3" } // 黄钥匙个数-3
- {"type": "setValue2", "name": "item:yellowKey", "value": "-3" } // 和上面写法等价
+ {"type": "addValue", "name": "item:yellowKey", "value": "-3" } // 和上面写法等价
{"type": "setValue", "name": "flag:door2", "value": "flag:door2+1" } // 将变量door值+1
- {"type": "setValue2", "name": "flag:door2", "value": "01" } // 和上面写法等价
+ {"type": "addValue", "name": "flag:door2", "value": "01" } // 和上面写法等价
]
```
diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4
index bd5e3f4a..1b2005b3 100644
--- a/_server/blockly/MotaAction.g4
+++ b/_server/blockly/MotaAction.g4
@@ -228,7 +228,7 @@ action
| setText_s
| tip_s
| setValue_s
- | setValue2_s
+ | addValue_s
| setFloor_s
| setGlobalAttribute_s
| setGlobalValue_s
@@ -465,15 +465,15 @@ var code = '{"type": "setValue", "name": "'+idString_e_0+'", "value": "'+express
return code;
*/;
-setValue2_s
+addValue_s
: '数值增减' ':' '名称' idString_e '+=' expression Newline
-/* setValue2_s
-tooltip : setValue2:增减勇士的某个属性、道具个数, 或某个变量/Flag的值
-helpUrl : https://h5mota.com/games/template/docs/#/event?id=setValue2%ef%bc%9a%e5%a2%9e%e5%87%8f%e5%8b%87%e5%a3%ab%e7%9a%84%e6%9f%90%e4%b8%aa%e5%b1%9e%e6%80%a7%e3%80%81%e9%81%93%e5%85%b7%e4%b8%aa%e6%95%b0%ef%bc%8c%e6%88%96%e6%9f%90%e4%b8%aa%e5%8f%98%e9%87%8f%2fFlag%e7%9a%84%e5%80%bc
+/* addValue_s
+tooltip : addValue:增减勇士的某个属性、道具个数, 或某个变量/Flag的值
+helpUrl : https://h5mota.com/games/template/docs/#/event?id=addValue%ef%bc%9a%e5%a2%9e%e5%87%8f%e5%8b%87%e5%a3%ab%e7%9a%84%e6%9f%90%e4%b8%aa%e5%b1%9e%e6%80%a7%e3%80%81%e9%81%93%e5%85%b7%e4%b8%aa%e6%95%b0%ef%bc%8c%e6%88%96%e6%9f%90%e4%b8%aa%e5%8f%98%e9%87%8f%2fFlag%e7%9a%84%e5%80%bc
colour : this.dataColor
-var code = '{"type": "setValue2", "name": "'+idString_e_0+'", "value": "'+expression_0+'"},\n';
+var code = '{"type": "addValue", "name": "'+idString_e_0+'", "value": "'+expression_0+'"},\n';
return code;
*/;
@@ -2372,14 +2372,13 @@ ActionParser.prototype.parseAction = function() {
break
case "setValue":
this.next = MotaActionBlocks['setValue_s'].xmlText([
- // MotaActionBlocks['idString_e'].xmlText([data.name]),
this.tryToUseEvFlag_e('idString_e', [data.name]),
MotaActionBlocks['evalString_e'].xmlText([data.value]),
this.next]);
break;
case "setValue2":
- this.next = MotaActionBlocks['setValue2_s'].xmlText([
- // MotaActionBlocks['idString_e'].xmlText([data.name]),
+ case "addValue":
+ this.next = MotaActionBlocks['addValue_s'].xmlText([
this.tryToUseEvFlag_e('idString_e', [data.name]),
MotaActionBlocks['evalString_e'].xmlText([data.value]),
this.next]);
diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js
index e1db7827..5cc6747a 100644
--- a/_server/editor_blockly.js
+++ b/_server/editor_blockly.js
@@ -75,7 +75,7 @@ editor_blockly = function () {
MotaActionBlocks['setValue_s'].xmlText([
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
]),
- MotaActionBlocks['setValue2_s'].xmlText([
+ MotaActionBlocks['addValue_s'].xmlText([
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
]),
MotaActionBlocks['setFloor_s'].xmlText(),
@@ -157,7 +157,7 @@ editor_blockly = function () {
MotaActionBlocks['setValue_s'].xmlText([
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
]),
- MotaActionBlocks['setValue2_s'].xmlText([
+ MotaActionBlocks['addValue_s'].xmlText([
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
]),
MotaActionBlocks['expression_arithmetic_0'].xmlText(),
@@ -184,8 +184,8 @@ editor_blockly = function () {
{"text": "黄钥匙(\${9+flag:shop_times}金币)", "color": [255,255,0,1], "action": [
{"type": "if", "condition": "status:money>=9+flag:shop_times",
"true": [
- {"type": "setValue2", "name": "status:money", "value": "-(9+flag:shop_times)"},
- {"type": "setValue2", "name": "item:yellowKey", "value": "1"},
+ {"type": "addValue", "name": "status:money", "value": "-(9+flag:shop_times)"},
+ {"type": "addValue", "name": "item:yellowKey", "value": "1"},
],
"false": [
"\t[老人,man]你的金钱不足!",
@@ -200,7 +200,7 @@ editor_blockly = function () {
]}
]
},
- {"type": "setValue2", "name": "flag:shop_times", "value": "1"},
+ {"type": "addValue", "name": "flag:shop_times", "value": "1"},
{"type": "revisit"}
], 'event'),
'',
@@ -223,7 +223,7 @@ editor_blockly = function () {
],'afterBattle'),
'',
MotaActionFunctions.actionParser.parse([
- {"type": "setValue2", "name": "flag:__door__", "value": "1"},
+ {"type": "addValue", "name": "flag:__door__", "value": "1"},
{"type": "if", "condition": "flag:__door__==2",
"true": [
{"type": "openDoor", "loc": [10,5]}
diff --git a/libs/control.js b/libs/control.js
index b88921fd..44475dc2 100644
--- a/libs/control.js
+++ b/libs/control.js
@@ -951,13 +951,13 @@ control.prototype._checkBlock_ambush = function (ambush) {
}
////// 更新全地图显伤 //////
-control.prototype.updateDamage = function (floorId, canvas) {
+control.prototype.updateDamage = function (floorId, ctx) {
floorId = floorId || core.status.floorId;
- if (!core.isset(floorId)) return;
+ if (!core.isset(floorId) || core.status.gameOver) return;
if (core.status.gameOver) return;
var refreshCheckBlock = true;
- if (!core.isset(canvas)) {
- canvas = core.canvas.damage;
+ if (!core.isset(ctx)) {
+ ctx = core.canvas.damage;
core.clearMap('damage');
refreshCheckBlock = false;
}
@@ -966,58 +966,46 @@ control.prototype.updateDamage = function (floorId, canvas) {
var mapBlocks = core.status.maps[floorId].blocks;
// 没有怪物手册
if (!core.hasItem('book')) return;
- canvas.font = "bold 11px Arial";
+ core.setFont(ctx, "bold 11px Arial");
+ this._updateDamage_damage(floorId, ctx);
+ this._updateDamage_extraDamage(floorId, ctx, refreshCheckBlock);
+}
- if (core.flags.displayEnemyDamage || core.flags.displayCritical) {
- canvas.textAlign = 'left';
-
- for (var b = 0; b < mapBlocks.length; b++) {
- var x = mapBlocks[b].x, y = mapBlocks[b].y;
- if (core.isset(mapBlocks[b].event) && mapBlocks[b].event.cls.indexOf('enemy')==0
- && !mapBlocks[b].disable) {
-
- // 判定是否显伤
- if (mapBlocks[b].event.displayDamage === false)
- continue;
-
- var id = mapBlocks[b].event.id;
-
- if (core.flags.displayEnemyDamage) {
- var damageString = core.enemys.getDamageString(id, x, y, floorId);
- var damage = damageString.damage, color = damageString.color;
- core.fillBoldText(canvas, damage, 32*x+1, 32*(y+1)-1, color);
- }
-
- // 临界显伤
- if (core.flags.displayCritical) {
- var critical = core.enemys.nextCriticals(id, 1, x, y, floorId);
- if (critical.length>0) critical=critical[0];
- critical = core.formatBigNumber(critical[0], true);
- if (critical == '???') critical = '?';
- core.fillBoldText(canvas, critical, 32*x+1, 32*(y+1)-11, '#FFFFFF');
- }
-
- }
+control.prototype._updateDamage_damage = function (floorId, ctx) {
+ core.setTextAlign(ctx, 'left');
+ core.status.maps[floorId].blocks.forEach(function (block) {
+ var x = block.x, y = block.y;
+ if (!block.disable && block.event.cls.indexOf('enemy') == 0 && block.event.displayDamage !== false) {
+ if (core.flags.displayEnemyDamage) {
+ var damageString = core.enemys.getDamageString(block.event.id, x, y, floorId);
+ var damage = damageString.damage, color = damageString.color;
+ core.fillBoldText(ctx, damage, 32*x+1, 32*(y+1)-1, color);
+ }
+ if (core.flags.displayCritical) {
+ var critical = core.enemys.nextCriticals(block.event.id, 1, x, y, floorId);
+ critical = core.formatBigNumber((critical[0]||[])[0], true);
+ if (critical == '???') critical = '?';
+ core.fillBoldText(ctx, critical, 32*x+1, 32*(y+1)-11, '#FFFFFF');
+ }
}
- }
- // 如果是领域&夹击
- if (core.flags.displayExtraDamage && core.isset((core.status.checkBlock||{}).damage)) {
- canvas.textAlign = 'center';
-
- if (refreshCheckBlock)
- this.updateCheckBlock(floorId);
+ });
+}
+control.prototype._updateDamage_extraDamage = function (floorId, ctx, refresh) {
+ core.setTextAlign(ctx, 'center');
+ if (refresh) this.updateCheckBlock(floorId);
+ if (core.flags.displayExtraDamage) {
var width = core.floors[floorId].width, height = core.floors[floorId].height;
for (var x=0;x0) { // 该点伤害
damage = core.formatBigNumber(damage, true);
- core.fillBoldText(canvas, damage, 32*x+16, 32*(y+1)-14, '#FF7F00');
+ core.fillBoldText(ctx, damage, 32*x+16, 32*(y+1)-14, '#FF7F00');
}
else { // 检查捕捉
if (core.status.checkBlock.ambush[x+","+y]) {
- core.fillBoldText(canvas, '!', 32*x+16, 32*(y+1)-14, '#FF7F00');
+ core.fillBoldText(ctx, '!', 32*x+16, 32*(y+1)-14, '#FF7F00');
}
}
}
@@ -1025,26 +1013,7 @@ control.prototype.updateDamage = function (floorId, canvas) {
}
}
-////// 执行一个表达式的effect操作 //////
-control.prototype.doEffect = function (effect, need, times) {
- effect.split(";").forEach(function (expression) {
- var arr = expression.split("+=");
- if (arr.length!=2) return;
- var name=arr[0], value=core.calValue(arr[1], null, need, times);
- if (name.indexOf("status:")==0) {
- var status=name.substring(7);
- core.setStatus(status, core.getStatus(status)+value);
- }
- else if (name.indexOf("item:")==0) {
- var itemId=name.substring(5);
- core.setItem(itemId, core.itemCount(itemId)+value);
- }
- else if (name.indexOf("flag:")==0) {
- var flag=name.substring(5);
- core.setFlag(flag, core.getFlag(flag, 0)+value);
- }
- });
-}
+// ------ 录像相关 ------ //
////// 选择录像文件 //////
control.prototype.chooseReplayFile = function () {
diff --git a/libs/events.js b/libs/events.js
index 6dba790c..7dfa9a27 100644
--- a/libs/events.js
+++ b/libs/events.js
@@ -1213,7 +1213,11 @@ events.prototype._action_setValue = function (data, x, y, prefix) {
}
events.prototype._action_setValue2 = function (data, x, y, prefix) {
- this.setValue2(data.name, data.value, prefix);
+ this._action_addValue(data, x, y, prefix);
+}
+
+events.prototype._action_addValue = function (data, x, y, prefix) {
+ this.addValue(data.name, data.value, prefix);
core.doAction();
}
@@ -1592,10 +1596,20 @@ events.prototype._setValue_setSwitch = function (name, value, prefix) {
}
////// 数值增减 //////
-events.prototype.setValue2 = function (name, value, prefix) {
+events.prototype.addValue = function (name, value, prefix) {
this.setValue(name, value, prefix, true);
}
+////// 执行一个表达式的effect操作 //////
+events.prototype.doEffect = function (effect, need, times) {
+ effect.split(";").forEach(function (expression) {
+ var arr = expression.split("+=");
+ if (arr.length != 2) return;
+ var name=arr[0], value=core.calValue(arr[1], null, need, times);
+ core.addValue(name, value);
+ });
+}
+
////// 设置楼层属性 //////
events.prototype.setFloorInfo = function (name, value, floorId, prefix) {
floorId = floorId || data.floorId;
diff --git a/project/events.js b/project/events.js
index f9b4d108..63924e63 100644
--- a/project/events.js
+++ b/project/events.js
@@ -102,12 +102,12 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
"text": ">=1:直接扣数值"
},
{
- "type": "setValue2",
+ "type": "addValue",
"name": "status:atk",
"value": "-core.values.weakValue"
},
{
- "type": "setValue2",
+ "type": "addValue",
"name": "status:def",
"value": "-core.values.weakValue"
}