feat:增加即捡即用道具效果的事件块
This commit is contained in:
parent
fbb28f8c69
commit
15f6ed2a83
@ -616,6 +616,59 @@ var code = ' \n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
// itemEffect 事件编辑器入口之一
|
||||
itemEffect_m
|
||||
: '拾取即捡即用物品的效果' BGNL? '数值提升项' itemEffectList+ '此道具cls须为items' BEND
|
||||
|
||||
|
||||
/* itemEffect_m
|
||||
tooltip : 道具效果
|
||||
default : []
|
||||
helpUrl : /_docs/#/instruction
|
||||
var code = '{"value": {\n'+itemEffectList_0+'\n}}';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
itemEffectList
|
||||
: itemEffectKnown
|
||||
| itemEffectUnknown
|
||||
| itemEffectEmpty;
|
||||
|
||||
|
||||
itemEffectKnown
|
||||
: ItemEffect_List ':' EvalString '增加值乘以地图倍率' Bool BEND
|
||||
|
||||
|
||||
/* itemEffectKnown
|
||||
tooltip : 数值增加项
|
||||
default : ['atk', 10]
|
||||
helpUrl : /_docs/#/instruction
|
||||
if (Bool_0) ItemEffect_List_0 += ':o';
|
||||
if (!/^[+-]?\d+(\.\d+)?$/.test(EvalString_0)) EvalString_0 = '"' + EvalString_0 + '"';
|
||||
return '"'+ItemEffect_List_0+'": '+EvalString_0+', ';
|
||||
*/;
|
||||
|
||||
itemEffectUnknown
|
||||
: EvalString ':' EvalString '需要但不消耗' Bool BEND
|
||||
|
||||
|
||||
/* itemEffectUnknown
|
||||
tooltip : 数值增加项
|
||||
default : ['speed', 10]
|
||||
helpUrl : /_docs/#/instruction
|
||||
if (Bool_0) EvalString_0 += ':o';
|
||||
if (!/^[+-]?\d+(\.\d+)?$/.test(EvalString_1)) EvalString_1 = '"' + EvalString_1 + '"';
|
||||
return '"'+EvalString_0+'": '+EvalString_1+', ';
|
||||
*/;
|
||||
|
||||
|
||||
itemEffectEmpty
|
||||
: Newline
|
||||
|
||||
/* itemEffectEmpty
|
||||
var code = ' \n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
faceIds_m
|
||||
: '行走图朝向:' BGNL? Newline '向下ID' IdString? '向左ID' IdString? '向右ID' IdString? '向上ID' IdString? BEND
|
||||
@ -4150,6 +4203,10 @@ Equip_List
|
||||
: '生命'|'生命上限'|'攻击'|'防御'|'护盾'|'魔力'|'魔力上限'
|
||||
/*Equip_List ['hp','hpmax','atk','def','mdef','mana','manamax']*/;
|
||||
|
||||
ItemEffect_List
|
||||
: '生命'|'生命上限'|'攻击'|'防御'|'护盾'|'魔力'|'魔力上限'|'金币'|'经验'
|
||||
/*ItemEffect_List ['hp','hpmax','atk','def','mdef','mana','manamax','money','exp']*/;
|
||||
|
||||
Key_List
|
||||
: '黄钥匙'|'蓝钥匙'|'红钥匙'|'绿钥匙'|'铁门钥匙'
|
||||
/*Key_List ['yellowKey','blueKey','redKey','greenKey','steelKey']*/;
|
||||
|
||||
@ -85,6 +85,24 @@ ActionParser.prototype.parse = function (obj,type) {
|
||||
return MotaActionBlocks['equip_m'].xmlText([obj.type, obj.animate, buildEquip(obj.value), buildEquip(obj.percentage),
|
||||
this.parseList(obj.equipEvent), this.parseList(obj.unequipEvent)]);
|
||||
|
||||
case 'itemEffect':
|
||||
if (!obj) obj = {};
|
||||
var buildItemEffect = function (obj) {
|
||||
obj = obj || {};
|
||||
var text_choices = null;
|
||||
var knownItemListKeys = MotaActionBlocks['ItemEffect_List'].options.map(function (one) { return one[1]; })
|
||||
Object.keys(obj).sort().forEach(function (key) {
|
||||
var noNeed = key.endsWith(':o');
|
||||
if (noNeed) key = key.substring(0, key.length - 2);
|
||||
var one = knownItemListKeys.indexOf(key) >= 0 ? 'itemEffectKnown' : 'itemEffectUnknown';
|
||||
text_choices = MotaActionBlocks[one].xmlText([
|
||||
key, obj[key], noNeed, text_choices
|
||||
]);
|
||||
})
|
||||
return text_choices;
|
||||
}
|
||||
return MotaActionBlocks['itemEffect_m'].xmlText([buildItemEffect(obj.value)]);
|
||||
|
||||
case 'doorInfo':
|
||||
if(!obj) obj={};
|
||||
var buildKeys = function (obj) {
|
||||
|
||||
@ -80,6 +80,9 @@ editor_blocklyconfig=(function(){
|
||||
MotaActionFunctions.actionParser.parse({
|
||||
"type": 0, "value": {"atk": 10}, "percentage": {"speed": 10},
|
||||
}, 'equip'),
|
||||
MotaActionFunctions.actionParser.parse({
|
||||
"value": {"atk": 10},
|
||||
}, 'itemEffect'),
|
||||
MotaActionFunctions.actionParser.parse([{
|
||||
"name": "bg.jpg", "x": 0, "y": 0, "canvas": "bg"
|
||||
}], 'floorImage'),
|
||||
|
||||
@ -62,13 +62,20 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
"_docs": "回放不绘制道具栏",
|
||||
"_data": "此项建议在会频繁连续多次使用的道具开启(如开启技能,或者《镜子》那样的镜像切换等等)"
|
||||
},
|
||||
"itemEffectEvent": {
|
||||
"_leaf": true,
|
||||
"_type": "event",
|
||||
"_event": "itemEffect",
|
||||
"_docs": "即捡即用效果",
|
||||
"_data": "即捡即用类物品的效果,仅对cls为items有效。"
|
||||
},
|
||||
"itemEffect": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_string": true,
|
||||
"_lint": true,
|
||||
"_docs": "即捡即用效果",
|
||||
"_data": "即捡即用类物品的效果,仅对cls为items有效。"
|
||||
"_docs": "即捡即用脚本",
|
||||
"_data": "即捡即用类物品在获得时执行的脚本,仅对cls为items有效。"
|
||||
},
|
||||
"itemEffectTip": {
|
||||
"_leaf": true,
|
||||
|
||||
@ -28,11 +28,36 @@ items.prototype.getItems = function () {
|
||||
|
||||
////// “即捡即用类”道具的使用效果 //////
|
||||
items.prototype.getItemEffect = function (itemId, itemNum) {
|
||||
var itemCls = core.material.items[itemId].cls;
|
||||
const itemCls = core.material.items[itemId].cls;
|
||||
// 消耗品
|
||||
if (itemCls === 'items') {
|
||||
var curr_hp = core.status.hero.hp;
|
||||
var itemEffect = core.material.items[itemId].itemEffect;
|
||||
const curr_hp = core.status.hero.hp;
|
||||
const itemEffectEvent = core.material.items[itemId].itemEffectEvent;
|
||||
if (itemEffectEvent) {
|
||||
const { value } = itemEffectEvent;
|
||||
for (var i = 0; i < itemNum; ++i) {
|
||||
for (let statusName in value) {
|
||||
let statusValue, ratio, needRatio;
|
||||
const effect = value[statusName];
|
||||
if (statusName.endsWith(':o')) {
|
||||
needRatio = true;
|
||||
statusName = statusName.slice(0, -2);
|
||||
}
|
||||
if (core.status.hero.hasOwnProperty(statusName)) {
|
||||
try {
|
||||
ratio = core.status.thisMap.ratio || 1;
|
||||
statusValue = eval(effect);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (needRatio) statusValue *= ratio;
|
||||
core.addStatus(statusName, statusValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const itemEffect = core.material.items[itemId].itemEffect;
|
||||
if (itemEffect) {
|
||||
try {
|
||||
for (var i = 0; i < itemNum; ++i)
|
||||
|
||||
@ -25,7 +25,12 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"itemEffect": "core.status.hero.atk += core.values.redGem * core.status.thisMap.ratio",
|
||||
"itemEffectTip": ",攻击+${core.values.redGem * core.status.thisMap.ratio}",
|
||||
"useItemEffect": "core.status.hero.atk += core.values.redGem",
|
||||
"canUseItemEffect": "true"
|
||||
"canUseItemEffect": "true",
|
||||
"itemEffectEvent": {
|
||||
"value": {
|
||||
"atk:o": "core.values.redGem"
|
||||
}
|
||||
}
|
||||
},
|
||||
"blueGem": {
|
||||
"cls": "items",
|
||||
|
||||
@ -3475,13 +3475,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
},
|
||||
"setting": function () {
|
||||
// 自绘设置界面
|
||||
// 抽象的不好,很后悔,还是功底太差
|
||||
|
||||
const { ButtonBase, MenuBase, MenuPage } = this.MenuBase;
|
||||
|
||||
class Setting {
|
||||
/**
|
||||
* @param {(ctx:string, x:number, y:number, w:number, h:number)=>void} draw
|
||||
* @param {(ctx:string)=>void} draw
|
||||
*/
|
||||
constructor(name, effect, text, replay, draw) {
|
||||
/** 获取选项界面显示的名称 */
|
||||
@ -3495,7 +3494,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
*/
|
||||
this.replay = replay;
|
||||
/** 除名称外的绘制内容
|
||||
* @type {(ctx:string, x:number, y:number, w:number, h:number)=>void}
|
||||
* @type {(ctx:string)=>void}
|
||||
*/
|
||||
this.draw = draw;
|
||||
}
|
||||
@ -4284,7 +4283,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
settingMenu.init();
|
||||
}
|
||||
|
||||
// todolist 自定义设置界面添加键盘支持
|
||||
// todolist 自定义设置界面添加键盘支持 √
|
||||
// todolist 剧情全skip功能 文字-文字+演出(跳跃)
|
||||
// todolist 批量使用:您当前选定了:xxx。请勿选定不适合批量使用的道具,请勿输入过大的数字。
|
||||
// todolist 道具栏分页,可设定隐藏的道具,及自动查看显隐藏
|
||||
|
||||
Loading…
Reference in New Issue
Block a user