装备同时支持数值和百分比属性
This commit is contained in:
parent
d1edf27dde
commit
7b54f0d3d3
@ -358,6 +358,60 @@ var code = '{"title": "'+EvalString_0+'", "name": "'+EvalString_1+'", "hard": '+
|
||||
return code;
|
||||
*/;
|
||||
|
||||
// equip 事件编辑器入口之一
|
||||
equip_m
|
||||
: '装备' '类型' EvalString '装备动画(第一个装备格有效)' IdString? BGNL? '数值提升项' equipList+ '百分比提升项' equipList+ BEND
|
||||
|
||||
|
||||
/* equip_m
|
||||
tooltip : 装备
|
||||
default : ['0', '']
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event
|
||||
if (!/^\d+$/.test(EvalString_0)) {
|
||||
EvalString_0 = '"' + EvalString_0 + '"';
|
||||
}
|
||||
IdString_0 = IdString_0 && (', "animate": "'+IdString_0+'"');
|
||||
var code = '{"type": '+EvalString_0+IdString_0+', "value": {\n'+equipList_0+'\n}, "percentage": {\n'+equipList_1+'\n}}';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
equipList
|
||||
: equipKnown
|
||||
| equipUnknown
|
||||
| equipEmpty;
|
||||
|
||||
|
||||
equipKnown
|
||||
: Equip_List ':' Number BEND
|
||||
|
||||
|
||||
/* equipKnown
|
||||
tooltip : 装备项
|
||||
default : ['atk', 10]
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event
|
||||
return '"'+Equip_List_0+'": '+Number_0+', ';
|
||||
*/;
|
||||
|
||||
equipUnknown
|
||||
: EvalString ':' Number BEND
|
||||
|
||||
|
||||
/* equipUnknown
|
||||
tooltip : 装备项
|
||||
default : ['speed', 10]
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event
|
||||
return '"'+EvalString_0+'": '+Number_0+', ';
|
||||
*/;
|
||||
|
||||
|
||||
equipEmpty
|
||||
: Newline
|
||||
|
||||
/* equipEmpty
|
||||
var code = ' \n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
|
||||
//为了避免关键字冲突,全部加了_s
|
||||
//动作
|
||||
@ -2908,8 +2962,8 @@ IdString
|
||||
;
|
||||
|
||||
FixedId_List
|
||||
: '生命'|'攻击'|'防御'|'护盾'|'黄钥匙'|'蓝钥匙'|'红钥匙'|'金币'|'经验'
|
||||
/*FixedId_List ['status:hp','status:atk','status:def','status:mdef','item:yellowKey','item:blueKey','item:redKey','status:money','status:exp']*/;
|
||||
: '生命'|'生命上限'|'攻击'|'防御'|'护盾'|'黄钥匙'|'蓝钥匙'|'红钥匙'|'金币'|'经验'|'魔力'|'魔力上限'
|
||||
/*FixedId_List ['status:hp','status:hpmax','status:atk','status:def','status:mdef','item:yellowKey','item:blueKey','item:redKey','status:money','status:exp','status:mana','status:manamax']*/;
|
||||
|
||||
Id_List
|
||||
: '变量' | '状态' | '物品' | '独立开关' | '临时变量' |'全局存储'
|
||||
@ -2919,6 +2973,10 @@ EnemyId_List
|
||||
: '生命'|'攻击'|'防御'|'金币'|'经验'|'加点'|'属性'|'名称'|'映射名'|'value'|'atkValue'|'defValue'|'notBomb'|'zoneSquare'|'range'|'n'|'add'|'damage'
|
||||
/*EnemyId_List ['hp','atk','def','money','exp','point','special','name','displayInBook','value','atkValue','defValue','notBomb','zoneSquare','range','n','add','damage']*/;
|
||||
|
||||
Equip_List
|
||||
: '生命'|'生命上限'|'攻击'|'防御'|'护盾'|'魔力'|'魔力上限'
|
||||
/*Equip_List ['hp','hpmax','atk','def','mdef','mana','manamax']*/;
|
||||
|
||||
//转blockly后不保留需要加"
|
||||
EvalString
|
||||
: Equote_double (ESC_double | ~["\\])* Equote_double
|
||||
|
||||
@ -58,6 +58,22 @@ ActionParser.prototype.parse = function (obj,type) {
|
||||
}
|
||||
return MotaActionBlocks['levelChoose_m'].xmlText([text_choices]);
|
||||
|
||||
case 'equip':
|
||||
if(!obj) obj={};
|
||||
var buildEquip = function (obj) {
|
||||
obj = obj || {};
|
||||
var text_choices = null;
|
||||
var knownKeys = MotaActionBlocks.equipKnown.json.args0[0].options.map(function (one) {return one[1];})
|
||||
Object.keys(obj).sort().forEach(function (key) {
|
||||
var one = knownKeys.indexOf(key) >= 0 ? 'equipKnown' : 'equipUnknown';
|
||||
text_choices = MotaActionBlocks[one].xmlText([
|
||||
key, obj.key, text_choices
|
||||
]);
|
||||
})
|
||||
return text_choices;
|
||||
}
|
||||
return MotaActionBlocks['equip_m'].xmlText([obj.type, obj.animate, buildEquip(obj.value), buildEquip(obj.percentage)]);
|
||||
|
||||
case 'shop':
|
||||
var buildsub = function(obj,parser,next){
|
||||
var text_choices = null;
|
||||
|
||||
@ -75,6 +75,9 @@ editor_blockly = function () {
|
||||
{"type": "comment", "text": "在这里写该难度需执行的事件"}
|
||||
]}
|
||||
], 'levelChoose'),
|
||||
MotaActionFunctions.actionParser.parse({
|
||||
"type": 0, "value": {"atk": 10}, "percentage": {"speed": 10},
|
||||
}, 'equip'),
|
||||
],
|
||||
'显示文字':[
|
||||
MotaActionBlocks['text_0_s'].xmlText(),
|
||||
@ -1067,7 +1070,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
}
|
||||
|
||||
// 对动画进行补全
|
||||
if (type == 'animate_s' && name == 'IdString_0') {
|
||||
if ((type == 'animate_s' && name == 'IdString_0') || (type == 'equip_m' && name == 'IdString_0')) {
|
||||
return filter(allAnimates, content);
|
||||
}
|
||||
|
||||
|
||||
@ -49,9 +49,9 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
},
|
||||
"equip": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_docs": "道具的装备属性",
|
||||
"_data": "装备属性设置,仅对cls为equips有效。\n如果此项不为null,需要是一个对象,里面可含\"type\",\"atk\",\"def\",\"mdef\",\"animate\"五项,分别对应装备部位、攻防护盾和动画。\n具体详见文档(元件说明-装备)和已有的几个装备的写法。"
|
||||
"_type": "event",
|
||||
"_event": "equip",
|
||||
"_docs": "道具的装备属性"
|
||||
},
|
||||
"hideInReplay": {
|
||||
"_leaf": true,
|
||||
|
||||
@ -218,6 +218,7 @@
|
||||
<option value="commonEvent">commonEvent</option>
|
||||
<option value="item">item</option>
|
||||
<option value="levelChoose">levelChoose</option>
|
||||
<option value="equip">equip</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||
|
||||
@ -214,6 +214,7 @@
|
||||
<option value="commonEvent">commonEvent</option>
|
||||
<option value="item">item</option>
|
||||
<option value="levelChoose">levelChoose</option>
|
||||
<option value="equip">equip</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button id='blocklyParse' onclick="editor_blockly.parse()">解析</button>
|
||||
|
||||
@ -292,53 +292,41 @@ items.prototype.unloadEquip = function (equipType, callback) {
|
||||
}
|
||||
|
||||
items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId) {
|
||||
var result = {};
|
||||
var result = {"value": {}, "percentage": {}};
|
||||
var first = core.material.items[compareEquipId], second = core.material.items[beComparedEquipId];
|
||||
for (var name in core.status.hero) {
|
||||
if (typeof core.status.hero[name] == 'number') {
|
||||
var ans = 0;
|
||||
if (first) ans += (first.equip || {})[name] || 0;
|
||||
if (second) ans -= (second.equip || {})[name] || 0;
|
||||
if (ans != 0) result[name] = ans;
|
||||
for (var one in result) {
|
||||
for (var name in core.status.hero) {
|
||||
if (typeof core.status.hero[name] == 'number') {
|
||||
var ans = 0;
|
||||
if (first) ans += ((first.equip || {})[one] || {})[name] || 0;
|
||||
if (second) ans -= ((second.equip || {})[one] || {})[name] || 0;
|
||||
if (ans != 0) result[one][name] = ans;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
////// 实际换装的效果 //////
|
||||
items.prototype._loadEquipEffect = function (equipId, unloadEquipId, isPercentage) {
|
||||
items.prototype._loadEquipEffect = function (equipId, unloadEquipId) {
|
||||
// 比较能力值
|
||||
var result = core.compareEquipment(equipId, unloadEquipId);
|
||||
|
||||
if (isPercentage) {
|
||||
for (var name in result)
|
||||
core.addBuff(name, result[name] / 100);
|
||||
}
|
||||
else {
|
||||
for (var name in result)
|
||||
core.status.hero[name] += result[name];
|
||||
}
|
||||
for (var name in result.percentage)
|
||||
core.addBuff(name, result.percentage[name] / 100);
|
||||
|
||||
for (var name in result.value)
|
||||
core.status.hero[name] += result.value[name];
|
||||
}
|
||||
|
||||
items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) {
|
||||
var loadEquip = core.material.items[loadId] || {}, unloadEquip = core.material.items[unloadId] || {};
|
||||
loadEquip.equip = loadEquip.equip || {};
|
||||
unloadEquip.equip = unloadEquip.equip || {}
|
||||
|
||||
var loadPercentage = loadEquip.equip.percentage, unloadPercentage = unloadEquip.equip.percentage;
|
||||
|
||||
if (loadId && unloadId && (loadPercentage || false) != (unloadPercentage || false)) {
|
||||
this.unloadEquip(type);
|
||||
this.loadEquip(loadId);
|
||||
if (callback) callback();
|
||||
return;
|
||||
}
|
||||
|
||||
// --- 音效
|
||||
this._realLoadEquip_playSound();
|
||||
|
||||
// --- 实际换装
|
||||
this._loadEquipEffect(loadId, unloadId, loadPercentage == null ? unloadPercentage : loadPercentage);
|
||||
this._loadEquipEffect(loadId, unloadId);
|
||||
|
||||
// --- 加减
|
||||
if (loadId) core.removeItem(loadId);
|
||||
|
||||
40
libs/ui.js
40
libs/ui.js
@ -2459,23 +2459,17 @@ ui.prototype._drawEquipbox_description = function (info, max_height) {
|
||||
}
|
||||
|
||||
ui.prototype._drawEquipbox_getStatusChanged = function (info, equip, equipType, y) {
|
||||
var compare, differentMode = null;
|
||||
if (info.index < this.LAST) compare = core.compareEquipment(null, info.selectId);
|
||||
else {
|
||||
if (equipType<0) differentMode = '<当前没有该装备的空位,请先卸下装备>';
|
||||
else {
|
||||
var last = core.material.items[info.equipEquipment[equipType]]||{};
|
||||
if (last.equip && (last.equip.percentage || false) != (equip.equip.percentage || false))
|
||||
differentMode = '<数值和比例模式之间的切换不显示属性变化>';
|
||||
else
|
||||
compare = core.compareEquipment(info.selectId, info.equipEquipment[equipType]);
|
||||
}
|
||||
if (info.index < this.LAST) {
|
||||
// 光标在装备栏上:查询卸下装备属性
|
||||
return core.compareEquipment(null, info.selectId);
|
||||
}
|
||||
if (differentMode != null) {
|
||||
core.fillText('ui', differentMode, 10, y, '#CCCCCC', this._buildFont(14, false));
|
||||
return;
|
||||
if (equipType < 0) {
|
||||
// 没有空位
|
||||
core.fillText('ui', '<当前没有该装备的空位,请先卸下装备>', 10, y, '#CCCCCC', this._buildFont(14, false));
|
||||
return null;
|
||||
}
|
||||
return compare;
|
||||
// 光标在装备上:查询装上后的属性变化
|
||||
return core.compareEquipment(info.selectId, info.equipEquipment[equipType]);
|
||||
}
|
||||
|
||||
ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipType) {
|
||||
@ -2485,19 +2479,19 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy
|
||||
|
||||
// --- 变化值...
|
||||
core.setFont('ui', this._buildFont(14, true));
|
||||
for (var name in compare) {
|
||||
for (var name in core.status.hero) {
|
||||
if (typeof core.status.hero[name] != 'number') continue;
|
||||
var nowValue = core.getRealStatus(name);
|
||||
// 查询新值
|
||||
var newValue = (core.getStatus(name) + (compare.value[name] || 0))
|
||||
* (core.getBuff(name) + (compare.percentage[name] || 0) / 100);
|
||||
if (nowValue == newValue) continue;
|
||||
var text = this._drawEquipbox_getStatusName(name);
|
||||
this._drawEquipbox_drawStatusChanged_draw(text + " ", '#CCCCCC', obj);
|
||||
var nowValue = core.getStatus(name) * core.getBuff(name), newValue = (core.getStatus(name) + compare[name]) * core.getBuff(name);
|
||||
if (equip.equip.percentage) {
|
||||
var nowBuff = core.getBuff(name), newBuff = nowBuff + compare[name] / 100;
|
||||
nowValue = Math.floor(nowBuff * core.getStatus(name));
|
||||
newValue = Math.floor(newBuff * core.getStatus(name));
|
||||
}
|
||||
nowValue = core.formatBigNumber(nowValue);
|
||||
newValue = core.formatBigNumber(newValue);
|
||||
this._drawEquipbox_drawStatusChanged_draw(nowValue+"->", '#CCCCCC', obj);
|
||||
this._drawEquipbox_drawStatusChanged_draw(newValue, compare[name]>0?'#00FF00':'#FF0000', obj);
|
||||
this._drawEquipbox_drawStatusChanged_draw(newValue, newValue>nowValue?'#00FF00':'#FF0000', obj);
|
||||
obj.drawOffset += 8;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +65,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一把已经生锈的剑",
|
||||
"equip": {
|
||||
"type": 0,
|
||||
"atk": 0,
|
||||
"animate": "sword"
|
||||
"animate": "sword",
|
||||
"value": {
|
||||
"atk": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"sword1": {
|
||||
@ -75,8 +77,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一把很普通的铁剑",
|
||||
"equip": {
|
||||
"type": 0,
|
||||
"atk": 10,
|
||||
"animate": "sword"
|
||||
"animate": "sword",
|
||||
"value": {
|
||||
"atk": 10
|
||||
}
|
||||
}
|
||||
},
|
||||
"sword2": {
|
||||
@ -85,8 +89,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一把很普通的银剑",
|
||||
"equip": {
|
||||
"type": 0,
|
||||
"atk": 20,
|
||||
"animate": "sword"
|
||||
"animate": "sword",
|
||||
"value": {
|
||||
"atk": 20
|
||||
}
|
||||
}
|
||||
},
|
||||
"sword3": {
|
||||
@ -95,8 +101,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一把很普通的骑士剑",
|
||||
"equip": {
|
||||
"type": 0,
|
||||
"atk": 40,
|
||||
"animate": "sword"
|
||||
"animate": "sword",
|
||||
"value": {
|
||||
"atk": 40
|
||||
}
|
||||
}
|
||||
},
|
||||
"sword4": {
|
||||
@ -105,8 +113,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一把很普通的圣剑",
|
||||
"equip": {
|
||||
"type": 0,
|
||||
"atk": 80,
|
||||
"animate": "sword"
|
||||
"animate": "sword",
|
||||
"value": {
|
||||
"atk": 80
|
||||
}
|
||||
}
|
||||
},
|
||||
"sword5": {
|
||||
@ -115,8 +125,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一把很普通的神圣剑",
|
||||
"equip": {
|
||||
"type": 0,
|
||||
"atk": 100,
|
||||
"animate": "sword"
|
||||
"animate": "sword",
|
||||
"value": {
|
||||
"atk": 160
|
||||
}
|
||||
}
|
||||
},
|
||||
"shield0": {
|
||||
@ -125,7 +137,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一个很破旧的铁盾",
|
||||
"equip": {
|
||||
"type": 1,
|
||||
"def": 0
|
||||
"value": {
|
||||
"def": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"shield1": {
|
||||
@ -134,7 +148,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一个很普通的铁盾",
|
||||
"equip": {
|
||||
"type": 1,
|
||||
"def": 10
|
||||
"value": {
|
||||
"def": 10
|
||||
}
|
||||
}
|
||||
},
|
||||
"shield2": {
|
||||
@ -143,7 +159,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一个很普通的银盾",
|
||||
"equip": {
|
||||
"type": 1,
|
||||
"def": 20
|
||||
"value": {
|
||||
"def": 20
|
||||
}
|
||||
}
|
||||
},
|
||||
"shield3": {
|
||||
@ -152,7 +170,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一个很普通的骑士盾",
|
||||
"equip": {
|
||||
"type": 1,
|
||||
"def": 40
|
||||
"value": {
|
||||
"def": 40
|
||||
}
|
||||
}
|
||||
},
|
||||
"shield4": {
|
||||
@ -161,7 +181,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一个很普通的圣盾",
|
||||
"equip": {
|
||||
"type": 1,
|
||||
"def": 80
|
||||
"value": {
|
||||
"def": 80
|
||||
}
|
||||
}
|
||||
},
|
||||
"shield5": {
|
||||
@ -170,8 +192,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "一个很普通的神圣盾",
|
||||
"equip": {
|
||||
"type": 1,
|
||||
"def": 100,
|
||||
"mdef": 100
|
||||
"value": {
|
||||
"def": 100,
|
||||
"mdef": 100
|
||||
}
|
||||
}
|
||||
},
|
||||
"superPotion": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user