updateDamage, addValue
This commit is contained in:
parent
a0538670a5
commit
911c2c5159
@ -441,7 +441,7 @@ value是一个表达式,将通过这个表达式计算出的结果赋值给nam
|
|||||||
|
|
||||||
另外注意一点的是,如果hp被设置成了0或以下,将触发lose事件,直接死亡。
|
另外注意一点的是,如果hp被设置成了0或以下,将触发lose事件,直接死亡。
|
||||||
|
|
||||||
### setValue2:增减勇士的某个属性、道具个数,或某个变量/Flag的值
|
### addValue:增减勇士的某个属性、道具个数,或某个变量/Flag的值
|
||||||
|
|
||||||
和`{"type": "setValue"}`的写法完全相同,不过此项是可以直接将值加减到原始数值上。
|
和`{"type": "setValue"}`的写法完全相同,不过此项是可以直接将值加减到原始数值上。
|
||||||
|
|
||||||
@ -450,11 +450,11 @@ value是一个表达式,将通过这个表达式计算出的结果赋值给nam
|
|||||||
``` js
|
``` js
|
||||||
"x,y": [ // 实际执行的事件列表
|
"x,y": [ // 实际执行的事件列表
|
||||||
{"type": "setValue", "name": "status:atk", "value": "status:atk+10" } // 攻击提高10点
|
{"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": "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": "setValue", "name": "flag:door2", "value": "flag:door2+1" } // 将变量door值+1
|
||||||
{"type": "setValue2", "name": "flag:door2", "value": "01" } // 和上面写法等价
|
{"type": "addValue", "name": "flag:door2", "value": "01" } // 和上面写法等价
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -228,7 +228,7 @@ action
|
|||||||
| setText_s
|
| setText_s
|
||||||
| tip_s
|
| tip_s
|
||||||
| setValue_s
|
| setValue_s
|
||||||
| setValue2_s
|
| addValue_s
|
||||||
| setFloor_s
|
| setFloor_s
|
||||||
| setGlobalAttribute_s
|
| setGlobalAttribute_s
|
||||||
| setGlobalValue_s
|
| setGlobalValue_s
|
||||||
@ -465,15 +465,15 @@ var code = '{"type": "setValue", "name": "'+idString_e_0+'", "value": "'+express
|
|||||||
return code;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
setValue2_s
|
addValue_s
|
||||||
: '数值增减' ':' '名称' idString_e '+=' expression Newline
|
: '数值增减' ':' '名称' idString_e '+=' expression Newline
|
||||||
|
|
||||||
|
|
||||||
/* setValue2_s
|
/* addValue_s
|
||||||
tooltip : setValue2:增减勇士的某个属性、道具个数, 或某个变量/Flag的值
|
tooltip : addValue:增减勇士的某个属性、道具个数, 或某个变量/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
|
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
|
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;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
@ -2372,14 +2372,13 @@ ActionParser.prototype.parseAction = function() {
|
|||||||
break
|
break
|
||||||
case "setValue":
|
case "setValue":
|
||||||
this.next = MotaActionBlocks['setValue_s'].xmlText([
|
this.next = MotaActionBlocks['setValue_s'].xmlText([
|
||||||
// MotaActionBlocks['idString_e'].xmlText([data.name]),
|
|
||||||
this.tryToUseEvFlag_e('idString_e', [data.name]),
|
this.tryToUseEvFlag_e('idString_e', [data.name]),
|
||||||
MotaActionBlocks['evalString_e'].xmlText([data.value]),
|
MotaActionBlocks['evalString_e'].xmlText([data.value]),
|
||||||
this.next]);
|
this.next]);
|
||||||
break;
|
break;
|
||||||
case "setValue2":
|
case "setValue2":
|
||||||
this.next = MotaActionBlocks['setValue2_s'].xmlText([
|
case "addValue":
|
||||||
// MotaActionBlocks['idString_e'].xmlText([data.name]),
|
this.next = MotaActionBlocks['addValue_s'].xmlText([
|
||||||
this.tryToUseEvFlag_e('idString_e', [data.name]),
|
this.tryToUseEvFlag_e('idString_e', [data.name]),
|
||||||
MotaActionBlocks['evalString_e'].xmlText([data.value]),
|
MotaActionBlocks['evalString_e'].xmlText([data.value]),
|
||||||
this.next]);
|
this.next]);
|
||||||
|
|||||||
@ -75,7 +75,7 @@ editor_blockly = function () {
|
|||||||
MotaActionBlocks['setValue_s'].xmlText([
|
MotaActionBlocks['setValue_s'].xmlText([
|
||||||
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
|
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
|
||||||
]),
|
]),
|
||||||
MotaActionBlocks['setValue2_s'].xmlText([
|
MotaActionBlocks['addValue_s'].xmlText([
|
||||||
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
|
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
|
||||||
]),
|
]),
|
||||||
MotaActionBlocks['setFloor_s'].xmlText(),
|
MotaActionBlocks['setFloor_s'].xmlText(),
|
||||||
@ -157,7 +157,7 @@ editor_blockly = function () {
|
|||||||
MotaActionBlocks['setValue_s'].xmlText([
|
MotaActionBlocks['setValue_s'].xmlText([
|
||||||
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
|
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
|
||||||
]),
|
]),
|
||||||
MotaActionBlocks['setValue2_s'].xmlText([
|
MotaActionBlocks['addValue_s'].xmlText([
|
||||||
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
|
MotaActionBlocks['idString_1_e'].xmlText(['status','hp'])
|
||||||
]),
|
]),
|
||||||
MotaActionBlocks['expression_arithmetic_0'].xmlText(),
|
MotaActionBlocks['expression_arithmetic_0'].xmlText(),
|
||||||
@ -184,8 +184,8 @@ editor_blockly = function () {
|
|||||||
{"text": "黄钥匙(\${9+flag:shop_times}金币)", "color": [255,255,0,1], "action": [
|
{"text": "黄钥匙(\${9+flag:shop_times}金币)", "color": [255,255,0,1], "action": [
|
||||||
{"type": "if", "condition": "status:money>=9+flag:shop_times",
|
{"type": "if", "condition": "status:money>=9+flag:shop_times",
|
||||||
"true": [
|
"true": [
|
||||||
{"type": "setValue2", "name": "status:money", "value": "-(9+flag:shop_times)"},
|
{"type": "addValue", "name": "status:money", "value": "-(9+flag:shop_times)"},
|
||||||
{"type": "setValue2", "name": "item:yellowKey", "value": "1"},
|
{"type": "addValue", "name": "item:yellowKey", "value": "1"},
|
||||||
],
|
],
|
||||||
"false": [
|
"false": [
|
||||||
"\t[老人,man]你的金钱不足!",
|
"\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"}
|
{"type": "revisit"}
|
||||||
], 'event'),
|
], 'event'),
|
||||||
'<label text="战前剧情"></label>',
|
'<label text="战前剧情"></label>',
|
||||||
@ -223,7 +223,7 @@ editor_blockly = function () {
|
|||||||
],'afterBattle'),
|
],'afterBattle'),
|
||||||
'<label text="打怪开门"></label>',
|
'<label text="打怪开门"></label>',
|
||||||
MotaActionFunctions.actionParser.parse([
|
MotaActionFunctions.actionParser.parse([
|
||||||
{"type": "setValue2", "name": "flag:__door__", "value": "1"},
|
{"type": "addValue", "name": "flag:__door__", "value": "1"},
|
||||||
{"type": "if", "condition": "flag:__door__==2",
|
{"type": "if", "condition": "flag:__door__==2",
|
||||||
"true": [
|
"true": [
|
||||||
{"type": "openDoor", "loc": [10,5]}
|
{"type": "openDoor", "loc": [10,5]}
|
||||||
|
|||||||
@ -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;
|
floorId = floorId || core.status.floorId;
|
||||||
if (!core.isset(floorId)) return;
|
if (!core.isset(floorId) || core.status.gameOver) return;
|
||||||
if (core.status.gameOver) return;
|
if (core.status.gameOver) return;
|
||||||
var refreshCheckBlock = true;
|
var refreshCheckBlock = true;
|
||||||
if (!core.isset(canvas)) {
|
if (!core.isset(ctx)) {
|
||||||
canvas = core.canvas.damage;
|
ctx = core.canvas.damage;
|
||||||
core.clearMap('damage');
|
core.clearMap('damage');
|
||||||
refreshCheckBlock = false;
|
refreshCheckBlock = false;
|
||||||
}
|
}
|
||||||
@ -966,58 +966,46 @@ control.prototype.updateDamage = function (floorId, canvas) {
|
|||||||
var mapBlocks = core.status.maps[floorId].blocks;
|
var mapBlocks = core.status.maps[floorId].blocks;
|
||||||
// 没有怪物手册
|
// 没有怪物手册
|
||||||
if (!core.hasItem('book')) return;
|
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) {
|
control.prototype._updateDamage_damage = function (floorId, ctx) {
|
||||||
canvas.textAlign = 'left';
|
core.setTextAlign(ctx, 'left');
|
||||||
|
core.status.maps[floorId].blocks.forEach(function (block) {
|
||||||
for (var b = 0; b < mapBlocks.length; b++) {
|
var x = block.x, y = block.y;
|
||||||
var x = mapBlocks[b].x, y = mapBlocks[b].y;
|
if (!block.disable && block.event.cls.indexOf('enemy') == 0 && block.event.displayDamage !== false) {
|
||||||
if (core.isset(mapBlocks[b].event) && mapBlocks[b].event.cls.indexOf('enemy')==0
|
if (core.flags.displayEnemyDamage) {
|
||||||
&& !mapBlocks[b].disable) {
|
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 (mapBlocks[b].event.displayDamage === false)
|
}
|
||||||
continue;
|
if (core.flags.displayCritical) {
|
||||||
|
var critical = core.enemys.nextCriticals(block.event.id, 1, x, y, floorId);
|
||||||
var id = mapBlocks[b].event.id;
|
critical = core.formatBigNumber((critical[0]||[])[0], true);
|
||||||
|
if (critical == '???') critical = '?';
|
||||||
if (core.flags.displayEnemyDamage) {
|
core.fillBoldText(ctx, critical, 32*x+1, 32*(y+1)-11, '#FFFFFF');
|
||||||
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');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
// 如果是领域&夹击
|
}
|
||||||
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;
|
var width = core.floors[floorId].width, height = core.floors[floorId].height;
|
||||||
for (var x=0;x<width;x++) {
|
for (var x=0;x<width;x++) {
|
||||||
for (var y=0;y<height;y++) {
|
for (var y=0;y<height;y++) {
|
||||||
var damage = core.status.checkBlock.damage[x+","+y];
|
var damage = core.status.checkBlock.damage[x+","+y]||0;
|
||||||
if (damage>0) { // 该点伤害
|
if (damage>0) { // 该点伤害
|
||||||
damage = core.formatBigNumber(damage, true);
|
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 { // 检查捕捉
|
else { // 检查捕捉
|
||||||
if (core.status.checkBlock.ambush[x+","+y]) {
|
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 () {
|
control.prototype.chooseReplayFile = function () {
|
||||||
|
|||||||
@ -1213,7 +1213,11 @@ events.prototype._action_setValue = function (data, x, y, prefix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
events.prototype._action_setValue2 = 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();
|
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);
|
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) {
|
events.prototype.setFloorInfo = function (name, value, floorId, prefix) {
|
||||||
floorId = floorId || data.floorId;
|
floorId = floorId || data.floorId;
|
||||||
|
|||||||
@ -102,12 +102,12 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
|
|||||||
"text": ">=1:直接扣数值"
|
"text": ">=1:直接扣数值"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "setValue2",
|
"type": "addValue",
|
||||||
"name": "status:atk",
|
"name": "status:atk",
|
||||||
"value": "-core.values.weakValue"
|
"value": "-core.values.weakValue"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "setValue2",
|
"type": "addValue",
|
||||||
"name": "status:def",
|
"name": "status:def",
|
||||||
"value": "-core.values.weakValue"
|
"value": "-core.values.weakValue"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user