修改装备属性
This commit is contained in:
parent
ead6e596f7
commit
ceffe0d3b5
10
_docs/api.md
10
_docs/api.md
@ -1320,6 +1320,16 @@ index: 套装编号,自然数
|
|||||||
removeItem: fn(itemId?: string, itemNum?: number)
|
removeItem: fn(itemId?: string, itemNum?: number)
|
||||||
删除某个物品
|
删除某个物品
|
||||||
|
|
||||||
|
setEquip: fn(equipId: string, valueType: string, name: string, value: ?, operator?: string, prefix?: string)
|
||||||
|
设置某个装备的属性并计入存档
|
||||||
|
例如:core.setEquip('sword1', 'value', 'atk', 300, '+='); // 设置铁剑的攻击力数值再加300
|
||||||
|
equipId: 装备id
|
||||||
|
valueType: 增幅类型,只能是value(数值)或percentage(百分比)
|
||||||
|
name: 要修改的属性名称,如atk
|
||||||
|
value: 要修改到的属性数值
|
||||||
|
operator: 操作符,可选,如+=表示在原始值上增加
|
||||||
|
prefix: 独立开关前缀,一般不需要
|
||||||
|
|
||||||
setItem: fn(itemId: string, itemNum?: number)
|
setItem: fn(itemId: string, itemNum?: number)
|
||||||
设置某种道具的持有量
|
设置某种道具的持有量
|
||||||
例如:core.setItem('yellowKey', 3) // 设置黄钥匙为3把
|
例如:core.setItem('yellowKey', 3) // 设置黄钥匙为3把
|
||||||
|
|||||||
@ -2212,6 +2212,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
|||||||
"!doc": "暂停背景音乐的播放",
|
"!doc": "暂停背景音乐的播放",
|
||||||
"!type": "fn()"
|
"!type": "fn()"
|
||||||
},
|
},
|
||||||
|
"setBgmSpeed": {
|
||||||
|
"!doc": "设置背景音乐的播放速度和音调<br/>speed: 播放速度,必须为30-300中间的值。100为正常速度。<br/>usePitch: 是否同时改变音调(部分设备可能不支持)",
|
||||||
|
"!type": "fn(speed: number, usePitch?: bool)"
|
||||||
|
},
|
||||||
"setReplaySpeed": {
|
"setReplaySpeed": {
|
||||||
"!doc": "设置播放速度",
|
"!doc": "设置播放速度",
|
||||||
"!type": "fn(speed: number)"
|
"!type": "fn(speed: number)"
|
||||||
@ -2709,6 +2713,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
|||||||
"canEquip": {
|
"canEquip": {
|
||||||
"!doc": "检查能否穿上某件装备<br/>例如:core.canEquip('sword5', true) // 主角可以装备神圣剑吗,如果不能会有提示<br/>equipId: 装备id<br/>hint: 无法穿上时是否提示(比如是因为未持有还是别的什么原因)<br/>返回值:true表示可以穿上,false表示无法穿上",
|
"!doc": "检查能否穿上某件装备<br/>例如:core.canEquip('sword5', true) // 主角可以装备神圣剑吗,如果不能会有提示<br/>equipId: 装备id<br/>hint: 无法穿上时是否提示(比如是因为未持有还是别的什么原因)<br/>返回值:true表示可以穿上,false表示无法穿上",
|
||||||
"!type": "fn(equipId: string, hint?: bool) -> bool"
|
"!type": "fn(equipId: string, hint?: bool) -> bool"
|
||||||
|
},
|
||||||
|
"setEquip": {
|
||||||
|
"!doc": "设置某个装备的属性并计入存档<br/>例如:core.setEquip('sword1', 'value', 'atk', 300, '+='); // 设置铁剑的攻击力数值再加300<br/>equipId: 装备id<br/>valueType: 增幅类型,只能是value(数值)或percentage(百分比)<br/>name: 要修改的属性名称,如atk<br/>value: 要修改到的属性数值<br/>operator: 操作符,可选,如+=表示在原始值上增加<br/>prefix: 独立开关前缀,一般不需要",
|
||||||
|
"!type": "fn(equipId: string, valueType: string, name: string, value: ?, operator?: string, prefix?: string)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"utils": {
|
"utils": {
|
||||||
|
|||||||
@ -752,6 +752,7 @@ action
|
|||||||
| setEnemyOnPoint_s
|
| setEnemyOnPoint_s
|
||||||
| resetEnemyOnPoint_s
|
| resetEnemyOnPoint_s
|
||||||
| moveEnemyOnPoint_s
|
| moveEnemyOnPoint_s
|
||||||
|
| setEquip_s
|
||||||
| setFloor_s
|
| setFloor_s
|
||||||
| setGlobalAttribute_s
|
| setGlobalAttribute_s
|
||||||
| setGlobalValue_s
|
| setGlobalValue_s
|
||||||
@ -1149,6 +1150,25 @@ return code;
|
|||||||
*/;
|
*/;
|
||||||
|
|
||||||
|
|
||||||
|
setEquip_s
|
||||||
|
: '设置装备属性' ':' '装备ID' IdString EquipValueType_List '的' EvalString AssignOperator_List expression Newline
|
||||||
|
|
||||||
|
|
||||||
|
/* setEquip_s
|
||||||
|
tooltip : setEquip:设置某个怪物的属性
|
||||||
|
helpUrl : /_docs/#/instruction
|
||||||
|
default : ["sword1", "value", "atk", "="]
|
||||||
|
allEquips : ['IdString_0']
|
||||||
|
colour : this.dataColor
|
||||||
|
EquipValueType_List_0 = EquipValueType_List_0 == 'percentage' ? ', "valueType": "percentage"' : ', "valueType": "value"';
|
||||||
|
if (AssignOperator_List_0 && AssignOperator_List_0 != '=') {
|
||||||
|
AssignOperator_List_0 = ', "operator": "' + AssignOperator_List_0 + '"';
|
||||||
|
} else AssignOperator_List_0 = '';
|
||||||
|
var code = '{"type": "setEquip", "id": "'+IdString_0+'"'+EquipValueType_List_0+', "name": "'+EvalString_0+'"'+AssignOperator_List_0+', "value": "'+expression_0+'"},\n';
|
||||||
|
return code;
|
||||||
|
*/;
|
||||||
|
|
||||||
|
|
||||||
setEnemyOnPoint_s
|
setEnemyOnPoint_s
|
||||||
: '设置某点怪物属性' ':' 'x' PosString? ',' 'y' PosString? '楼层' IdString? '的' EnemyId_List AssignOperator_List expression Newline
|
: '设置某点怪物属性' ':' 'x' PosString? ',' 'y' PosString? '楼层' IdString? '的' EnemyId_List AssignOperator_List expression Newline
|
||||||
|
|
||||||
@ -1904,7 +1924,7 @@ tooltip : loadEquip: 装上装备
|
|||||||
helpUrl : /_docs/#/instruction
|
helpUrl : /_docs/#/instruction
|
||||||
colour : this.dataColor
|
colour : this.dataColor
|
||||||
default : ["sword1"]
|
default : ["sword1"]
|
||||||
allItems : ['IdString_0']
|
allEquips : ['IdString_0']
|
||||||
var code = '{"type": "loadEquip", "id": "'+IdString_0+'"},\n';
|
var code = '{"type": "loadEquip", "id": "'+IdString_0+'"},\n';
|
||||||
return code;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
@ -3826,6 +3846,10 @@ NextXY_List
|
|||||||
: '横坐标'|'纵坐标'
|
: '横坐标'|'纵坐标'
|
||||||
/*NextXY_List ['nextX','nextY']*/;
|
/*NextXY_List ['nextX','nextY']*/;
|
||||||
|
|
||||||
|
EquipValueType_List
|
||||||
|
: '数值项'|'百分比项'
|
||||||
|
/*EquipValueType_List ['value','percentage']*/;
|
||||||
|
|
||||||
Colour
|
Colour
|
||||||
: 'sdeirughvuiyasdeb'+ //为了被识别为复杂词法规则
|
: 'sdeirughvuiyasdeb'+ //为了被识别为复杂词法规则
|
||||||
;
|
;
|
||||||
|
|||||||
@ -707,6 +707,10 @@ ActionParser.prototype.parseAction = function() {
|
|||||||
this.next = MotaActionBlocks['moveEnemyOnPoint_s'].xmlText([
|
this.next = MotaActionBlocks['moveEnemyOnPoint_s'].xmlText([
|
||||||
data.from[0], data.from[1], data.to[0], data.to[1], data.floorId||'',this.next]);
|
data.from[0], data.from[1], data.to[0], data.to[1], data.floorId||'',this.next]);
|
||||||
break;
|
break;
|
||||||
|
case "setEquip":
|
||||||
|
this.next = MotaActionBlocks['setEquip_s'].xmlText([
|
||||||
|
MotaActionFunctions.replaceToName_token(data.id), data.valueType||'value', data.name, data["operator"]||'=', this.expandEvalBlock([data.value]), this.next]);
|
||||||
|
break;
|
||||||
case "setFloor":
|
case "setFloor":
|
||||||
this.next = MotaActionBlocks['setFloor_s'].xmlText([
|
this.next = MotaActionBlocks['setFloor_s'].xmlText([
|
||||||
data.name, data.floorId||null, JSON.stringify(data.value), this.next]);
|
data.name, data.floorId||null, JSON.stringify(data.value), this.next]);
|
||||||
|
|||||||
@ -669,14 +669,18 @@ editor_blockly = function () {
|
|||||||
namesObj.allEnemys = Object.keys(core.material.enemys);
|
namesObj.allEnemys = Object.keys(core.material.enemys);
|
||||||
if (MotaActionFunctions && !MotaActionFunctions.disableReplace) {
|
if (MotaActionFunctions && !MotaActionFunctions.disableReplace) {
|
||||||
namesObj.allEnemys = namesObj.allEnemys.concat(MotaActionFunctions.pattern.replaceEnemyList.map(function (x) {
|
namesObj.allEnemys = namesObj.allEnemys.concat(MotaActionFunctions.pattern.replaceEnemyList.map(function (x) {
|
||||||
return x[1];
|
return x[1];
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
namesObj.allItems = Object.keys(core.material.items);
|
namesObj.allItems = Object.keys(core.material.items);
|
||||||
|
namesObj.allEquips = namesObj.allItems.filter(function (one) { return core.material.items[one].cls == 'equips' });
|
||||||
if (MotaActionFunctions && !MotaActionFunctions.disableReplace) {
|
if (MotaActionFunctions && !MotaActionFunctions.disableReplace) {
|
||||||
namesObj.allItems = namesObj.allItems.concat(MotaActionFunctions.pattern.replaceItemList.map(function (x) {
|
namesObj.allItems = namesObj.allItems.concat(MotaActionFunctions.pattern.replaceItemList.map(function (x) {
|
||||||
return x[1];
|
return x[1];
|
||||||
}))
|
}))
|
||||||
|
namesObj.allEquips = namesObj.allEquips.concat(MotaActionFunctions.pattern.replaceItemList.map(function (x) {
|
||||||
|
return x[1];
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
namesObj.allAnimates = Object.keys(core.material.animates)
|
namesObj.allAnimates = Object.keys(core.material.animates)
|
||||||
.concat(Object.keys(main.nameMap).filter(function (one) {return core.material.animates[main.nameMap[one]];}));
|
.concat(Object.keys(main.nameMap).filter(function (one) {return core.material.animates[main.nameMap[one]];}));
|
||||||
@ -710,7 +714,7 @@ editor_blockly = function () {
|
|||||||
// 对音效进行补全
|
// 对音效进行补全
|
||||||
// 对全局商店进行补全
|
// 对全局商店进行补全
|
||||||
// 对楼层名进行补全
|
// 对楼层名进行补全
|
||||||
for(var ii=0,names;names=['allIds','allEnemys','allItems','allImages','allAnimates','allBgms','allSounds','allShops','allFloorIds','allDoors','allEvents'][ii];ii++){
|
for(var ii=0,names;names=['allIds','allEnemys','allItems','allEquips','allImages','allAnimates','allBgms','allSounds','allShops','allFloorIds','allDoors','allEvents'][ii];ii++){
|
||||||
if (MotaActionBlocks[type][names] && eval(MotaActionBlocks[type][names]).indexOf(name)!==-1) {
|
if (MotaActionBlocks[type][names] && eval(MotaActionBlocks[type][names]).indexOf(name)!==-1) {
|
||||||
return filter(namesObj[names], content);
|
return filter(namesObj[names], content);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,6 +124,7 @@ editor_blocklyconfig=(function(){
|
|||||||
MotaActionBlocks['setEnemyOnPoint_s'].xmlText(),
|
MotaActionBlocks['setEnemyOnPoint_s'].xmlText(),
|
||||||
MotaActionBlocks['resetEnemyOnPoint_s'].xmlText(),
|
MotaActionBlocks['resetEnemyOnPoint_s'].xmlText(),
|
||||||
MotaActionBlocks['moveEnemyOnPoint_s'].xmlText(),
|
MotaActionBlocks['moveEnemyOnPoint_s'].xmlText(),
|
||||||
|
MotaActionBlocks['setEquip_s'].xmlText(),
|
||||||
MotaActionBlocks['setFloor_s'].xmlText(),
|
MotaActionBlocks['setFloor_s'].xmlText(),
|
||||||
MotaActionBlocks['setGlobalAttribute_s'].xmlText(),
|
MotaActionBlocks['setGlobalAttribute_s'].xmlText(),
|
||||||
MotaActionBlocks['setGlobalValue_s'].xmlText(),
|
MotaActionBlocks['setGlobalValue_s'].xmlText(),
|
||||||
|
|||||||
@ -1208,7 +1208,7 @@ events.prototype.__precompile_getArray = function () {
|
|||||||
"closeDoor", "battle", "trigger", "insert", "setEnemyOnPoint", "resetEnemyOnPoint"
|
"closeDoor", "battle", "trigger", "insert", "setEnemyOnPoint", "resetEnemyOnPoint"
|
||||||
];
|
];
|
||||||
var values = [
|
var values = [
|
||||||
"setValue", "setEnemy", "setFloor", "setGlobalValue",
|
"setValue", "setEnemy", "setEnemyOnPoint", "setEquip", "setFloor", "setGlobalValue",
|
||||||
];
|
];
|
||||||
var uievents = [
|
var uievents = [
|
||||||
"clearMap", "fillText", "fillBoldText", "fillRect", "strokeRect", "fillEllipse", "strokeEllipse",
|
"clearMap", "fillText", "fillBoldText", "fillRect", "strokeRect", "fillEllipse", "strokeEllipse",
|
||||||
@ -1795,6 +1795,11 @@ events.prototype._action_moveEnemyOnPoint = function (data, x, y, prefix) {
|
|||||||
core.doAction();
|
core.doAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events.prototype._action_setEquip = function (data, x, y, prefix) {
|
||||||
|
core.setEquip(data.id, data.valueType, data.name, data.value, data.operator, prefix);
|
||||||
|
core.doAction();
|
||||||
|
}
|
||||||
|
|
||||||
events.prototype._action_setFloor = function (data, x, y, prefix) {
|
events.prototype._action_setFloor = function (data, x, y, prefix) {
|
||||||
this.setFloorInfo(data.name, data.value, data.floorId, prefix);
|
this.setFloorInfo(data.name, data.value, data.floorId, prefix);
|
||||||
core.doAction();
|
core.doAction();
|
||||||
|
|||||||
@ -16,7 +16,14 @@ items.prototype._init = function () {
|
|||||||
|
|
||||||
////// 获得所有道具 //////
|
////// 获得所有道具 //////
|
||||||
items.prototype.getItems = function () {
|
items.prototype.getItems = function () {
|
||||||
return core.clone(this.items);
|
var items = core.clone(this.items);
|
||||||
|
var equipInfo = core.getFlag('equipInfo');
|
||||||
|
if (equipInfo) {
|
||||||
|
for (var id in equipInfo) {
|
||||||
|
items[id].equip = core.clone(equipInfo[id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
////// “即捡即用类”道具的使用效果 //////
|
////// “即捡即用类”道具的使用效果 //////
|
||||||
@ -404,3 +411,25 @@ items.prototype.quickLoadEquip = function (index) {
|
|||||||
|
|
||||||
core.drawTip("成功换上" + index + "号套装");
|
core.drawTip("成功换上" + index + "号套装");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// 设置装备属性 //////
|
||||||
|
items.prototype.setEquip = function (equipId, valueType, name, value, operator, prefix) {
|
||||||
|
var equip = core.material.items[equipId];
|
||||||
|
if (!equip || equip.cls != 'equips') return;
|
||||||
|
var equipInfo = equip.equip || {};
|
||||||
|
if (!equipInfo[valueType]) equipInfo[valueType] = {};
|
||||||
|
var toEquipInfo = core.clone(equipInfo);
|
||||||
|
toEquipInfo[valueType][name] = core.events._updateValueByOperator(core.calValue(value, prefix), equipInfo[valueType][name], operator);
|
||||||
|
// 如果是穿上状态,则还需要直接修改当前数值
|
||||||
|
if (core.hasEquip(equipId)) {
|
||||||
|
// 设置一个临时装备,然后模拟换装操作
|
||||||
|
var tempId = 'temp:' + equipId;
|
||||||
|
core.material.items[tempId] = {'cls': 'equips', 'equip': core.clone(toEquipInfo)};
|
||||||
|
this._loadEquipEffect(tempId, equipId);
|
||||||
|
delete core.material.items[tempId];
|
||||||
|
core.updateStatusBar();
|
||||||
|
}
|
||||||
|
equip.equip = core.clone(toEquipInfo);
|
||||||
|
flags.equipInfo = flags.equipInfo || {};
|
||||||
|
flags.equipInfo[equipId] = core.clone(toEquipInfo);
|
||||||
|
}
|
||||||
|
|||||||
12
runtime.d.ts
vendored
12
runtime.d.ts
vendored
@ -2032,6 +2032,18 @@ declare class items {
|
|||||||
|
|
||||||
/** 根据类型获得一个可用的装备孔 */
|
/** 根据类型获得一个可用的装备孔 */
|
||||||
getEquipTypeByName(name?: string): void
|
getEquipTypeByName(name?: string): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置某个装备的属性并计入存档
|
||||||
|
* @example core.setEquip('sword1', 'value', 'atk', 300, '+='); // 设置铁剑的攻击力数值再加300
|
||||||
|
* @param equipId 装备id
|
||||||
|
* @param valueType 增幅类型,只能是value(数值)或percentage(百分比)
|
||||||
|
* @param name 要修改的属性名称,如atk
|
||||||
|
* @param value 要修改到的属性数值
|
||||||
|
* @param operator 操作符,可选,如+=表示在原始值上增加
|
||||||
|
* @param prefix 独立开关前缀,一般不需要
|
||||||
|
*/
|
||||||
|
setEquip(equipId: string, valueType: string, name: string, value: any, operator?: string, prefix?: string): void
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @file ui.js 主要用来进行UI窗口的绘制,如对话框、怪物手册、楼传器、存读档界面等等。*/
|
/** @file ui.js 主要用来进行UI窗口的绘制,如对话框、怪物手册、楼传器、存读档界面等等。*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user