fix:还原MT0为空

This commit is contained in:
ShakeFlower 2025-02-14 20:13:24 +08:00
parent b209a114f4
commit ba7202d1ad
5 changed files with 1399 additions and 1212 deletions

View File

@ -75,7 +75,7 @@ var plugins_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "typeof(thiseval)=='string' || thiseval==null",
"_data": "物品数据显示"
},
"autoGet": {
"autoClear": {
"_leaf": true,
"_type": "textarea",
"_range": "typeof(thiseval)=='string' || thiseval==null",
@ -85,7 +85,7 @@ var plugins_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_leaf": true,
"_type": "textarea",
"_range": "typeof(thiseval)=='string' || thiseval==null",
"_data": "新版道具栏"
"_data": "自绘道具栏"
},
"scrollingText": {
"_leaf": true,
@ -93,6 +93,18 @@ var plugins_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "typeof(thiseval)=='string' || thiseval==null",
"_data": "接收&发送弹幕"
},
"autoChangeEquip": {
"_leaf": true,
"_type": "textarea",
"_range": "typeof(thiseval)=='string' || thiseval==null",
"_data": "自动切装"
},
"setting": {
"_leaf": true,
"_type": "textarea",
"_range": "typeof(thiseval)=='string' || thiseval==null",
"_data": "自绘设置界面"
},
}
if (obj[key]) return obj[key];
return {

View File

@ -84,3 +84,4 @@ _initDetachedBlock返回三个canvas的对象 {headCanvas,bodyCanvas,damageCanva
_moveDetachedBlock疑似是通过该函数不断移动实现移动效果
模板字符串居然不能随意填字符串,逆天
arguments对象是 JavaScript 中的一个特殊对象,它自动提供给每一个函数作为局部变量。它是类数组对象,但缺少真正数组的许多方法。

View File

@ -1,6 +1,6 @@
var enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 =
{
"greenSlime": {"name":"绿头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[28]},
"greenSlime": {"name":"绿头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]},
"redSlime": {"name":"红头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]},
"blackSlime": {"name":"青头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0},
"slimelord": {"name":"怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]},

View File

@ -11,11 +11,11 @@ main.floors.MT0=
"images": [],
"ratio": 2,
"map": [
[201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0,201, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0,201, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0,202, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@ -25,40 +25,7 @@ main.floors.MT0=
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
],
"firstArrive": [
{
"type": "setValue",
"name": "item:wand",
"value": "99"
},
{
"type": "setValue",
"name": "item:silverCoin",
"value": "99"
},
{
"type": "setEnemyOnPoint",
"loc": [
[
5,
2
]
],
"name": "hp",
"value": "123"
},
{
"type": "setEnemyOnPoint",
"loc": [
[
5,
4
]
],
"name": "hp",
"value": "1234"
}
],
"firstArrive": null,
"parallelDo": "",
"events": {},
"changeFloor": {},

View File

@ -1901,7 +1901,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}
}
},
"autoGet": function () {
"autoClear": function () {
// 在此增加新插件
/**
* --------------- 使用说明 ---------------
@ -2192,49 +2192,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.updateStatusBar();
};
},
"FloatingText": function () {
// 本插件定义了一些字符绘制相关效果
return;
// 有待调试
const { Animation, linear } = core.plugin.animate;
const ctx = 'scrollingText';
if (!main.replayChecking) {
// new Animation().ticker.add(() => {
// core.createCanvas(ctx, 0, 0, core.__PIXELS__, core.__PIXELS__, 136); //每帧重绘该画布
// });
}
/**
* 绘制弹幕
* @example
* core.plugin.drawCommentStr('OK', 450, 200, 0.1);
* @param {string} content 弹幕的内容
* @param {number} x 弹幕的初始x坐标
* @param {number} y 弹幕的初始y坐标
* @param {number} vx 弹幕的横向滚动速度
*/
this.drawCommentStr = function (content, x, y, vx) {
if (core.isReplaying()) return;
const ani = new Animation();
ani.ticker.add(() => {
core.fillText(ctx, content, x + ani.x, y, 'white', '16px Verdana');
})
ani.mode(linear())
.time(600 / vx)
.absolute()
.move(-600, 0)
ani.all().then(() => { ani.ticker.destroy(); });
}
},
"scrollingText": function () {
// 本插件用于绘制在线留言
// 说明https://h5mota.com/bbs/thread/?tid=1017
// 目前使用core.http代替帖子中提到的axios
/** 塔的英文名 */
const towerName = 'slmwarbyshadow' || core.firstData.name;
const towerName = core.firstData.name;
let [W, H] = [core.__SIZE__, core.__SIZE__];
let [WIDTH, HEIGHT] = [core.__PIXELS__, core.__PIXELS__];
@ -3612,6 +3576,249 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.registerReplayAction("equip", core.control._replayAction_equip);
core.registerReplayAction("unEquip", core.control._replayAction_unEquip);
},
"autoChangeEquip":
function () {
// 调用方法在合适的位置调用函数figureEquip即可例如在脚本编辑-按键处理加入case 89: core.plugin.figureEquip(); break;
// 即按Y键进入切装模式
let compareMode = false;
let equipStatus = [];
let equipIncluded;
////// 请在[]中填好不参与换装的装备孔的序号。
// 例如0号4号装备孔不参与换装则 ignoreList 应设为[0,4]
// 所有装备孔都参与换装,则 ignoreList 应设为[]
let ignoreList = [];
////// 请在{}中根据装备的穿脱事件手动填写装备穿脱时要执行的函数,没有则不填。只填写有效的数值变化即可。
// 例如:{'sword3':{'equip':function(){core.setFlag('mms3',1);},'unequip':function(){core.setFlag('mms3',0);}}}
let equipEvents = {};
function compareEquip() {
return new Promise(function (res) {
const canvas = 'compareEquip',
width = core._PX_ || core.__PIXELS__,
height = core._PY_ || core.__PIXELS__;
core.lockControl();
function finish() {
compareMode = false;
core.unregisterAction('onclick', 'bestEquip');
core.deleteCanvas(canvas);
res();
}
core.createCanvas(canvas, 0, 0, width, height, 160);
core.setTextAlign(canvas, 'center');
core.fillText(canvas, '点击选择一个怪物,点击非怪物图块自动退出', width / 2, 20, 'red', '18px Arial');
core.registerAction('onclick', 'bestEquip', function (x, y, px, py) {
const cls = core.getBlockCls(x, y),
id = core.getBlockId(x, y);
if (!(cls === 'enemys' || cls === "enemy48")) {
finish();
return false;
}
figureBestEquip(id, x, y);
core.updateDamage();
finish();
}, 100);
})
}
function figureBestEquip(id, x, y) {
compareMode = true;
const equipNum = core.status.globalAttribute.equipName.length; // 装备总数量
// 角色初始各项数值,用于推算出最优切装后复原初始状态
const oriEffect = {
'value': { 'atk': core.status.hero.atk, 'def': core.status.hero.def, 'mdef': core.status.hero.mdef, },
'percentage': { 'atk': core.getBuff('atk'), 'def': core.getBuff('def'), 'mdef': core.getBuff('mdef'), },
'equipment': core.clone(core.status.hero.equipment),
}
if (!equipIncluded) equipIncluded = getEquipIncluded(equipNum);
const equipIncludedNum = equipIncluded.length;
const equipNameList = core.status.globalAttribute.equipName.filter((ele, i) => { return !ignoreList.includes(i); });
equipStatus = equipIncluded.map((ele) => core.getEquip(ele)); //当前参与计算的各个装备孔的装备
const equipOwned = getEquipOwned(equipNum);
let equipList = getEquipList(equipIncludedNum, equipOwned, equipNameList);
const equipCombination = traverseSetCombinations(equipList);
const bestCombination = findBestEquipComb(equipCombination, equipOwned, id, x, y);
['atk', 'def', 'mdef'].forEach((ele) => {
core.setStatus(ele, oriEffect.value[ele]);
core.setBuff(ele, oriEffect.percentage[ele]);
});
core.status.hero.equipment = core.clone(oriEffect.equipment);
equipBestComb(bestCombination, equipIncluded, equipNameList);
}
// 返回一个包含所有参与切装计算的装备孔的序号的数组。
// 例如024号装备孔参与切装计算则本函数返回[0,2,4]
function getEquipIncluded(equipNum) {
let equipIncluded = [];
for (let i = 0; i < equipNum; i++) {
if (!ignoreList.includes(i)) equipIncluded.push(i);
}
return equipIncluded;
}
function getEquipOwned(equipNum) {
// equipOwned:当前拥有的所有装备的数量
// 形如{sword1: 2, sword2: 1}
let equipOwned = core.clone(core.status.hero.items.equips);
for (let i = 0; i < equipNum; i++) {
if (ignoreList.includes(i)) continue;
const currEquip = core.getEquip(i);
if (currEquip !== null)
if (equipOwned.hasOwnProperty(currEquip)) equipOwned[currEquip]++;
else equipOwned[currEquip] = 1;
}
return equipOwned;
}
// 生成切装列表,为一个二维数组
function getEquipList(equipNum, equipOwned, equipNameList) {
// equipNameList:计入切装计算的装备格子的名称列表,可重复
// 形如['武器', '武器', '盾牌']
let equipList = Array(equipNameList.length).fill().map(() => new Set([null]));
//对每个装备孔展开
for (let i = 0, l = equipNameList.length; i < l; i++) {
for (let j in equipOwned) {
let equipType = core.material.items[j].equip.type;
switch (typeof equipType) {
case 'number':
for (let k = 0, l = equipOwned[j]; k < l; k++) { equipList[equipIncluded.indexOf(equipType)].add(j); }
break;
case 'string':
if (equipType === equipNameList[i])
for (let k = 0, l = equipOwned[j]; k < l; k++) { equipList[i].add(j); }
break;
}
}
}
return equipList;
}
function traverseSetCombinations(arr) {
const result = [];
const currentCombination = [];
function backtrack(index) {
if (index === arr.length) {
result.push([...currentCombination]);
return;
}
const currentSet = Array.from(arr[index]);
for (let value of currentSet) {
currentCombination[index] = value;
backtrack(index + 1);
}
}
backtrack(0);
return result;
}
function getEleCount(ele, arr) {
let count = 0;
for (let i = 0, l = arr.length; i < l; i++) {
if (arr[i] === ele) count++;
}
return count;
}
function hasEnoughEquip(currComb, equipOwned) {
for (let i in equipOwned) {
const equipNeed = getEleCount(i, currComb);
if (equipOwned[i] < equipNeed) return false;
}
return true;
}
// 按照给定的列表aimStatus形如['sword1','sword2',null,'sword1'],修改equipStatus进行模拟切装
function simulateEquip(equipStatus, aimStatus) {
equipIncluded.forEach((ele, i) => { core.status.hero.equipment[ele] = aimStatus[i]; })
for (let i = 0, l = equipStatus.length; i < l; i++) {
if (equipStatus[i] !== aimStatus[i]) {
if (aimStatus[i] === null) {
const unequipId = equipStatus[i];
if (equipEvents.hasOwnProperty(unequipId) &&
equipEvents[unequipId].hasOwnProperty('unequip'))
equipEvents[unequipId].unequip();
core.items._loadEquipEffect(null, unequipId);
} else {
const equipId = aimStatus[i];
if (equipEvents.hasOwnProperty(equipId) &&
equipEvents[equipId].hasOwnProperty('equip'))
equipEvents[equipId].equip();
core.items._loadEquipEffect(equipId, equipStatus[i]);
}
equipStatus[i] = aimStatus[i];
}
}
}
function findBestEquipComb(equipCombination, equipOwned, id, x, y) {
let minDamage = core.getDamage(id, x, y),
bestCombination = core.clone(equipStatus);
for (let i = 0, l = equipCombination.length; i < l; i++) {
const currComb = equipCombination[i];
if (!hasEnoughEquip(currComb, equipOwned)) continue;
simulateEquip(equipStatus, currComb);
let damage = core.getDamage(id, x, y);
if (damage !== null && (minDamage === null || damage < minDamage)) {
minDamage = damage;
bestCombination = core.clone(equipStatus);
}
}
return bestCombination;
}
function equipBestComb(bestCombination, equipIncluded, equipNameList) {
const duplicatedName = new Set([]),
name = core.status.globalAttribute.equipName;
// 脱下重复装备
equipNameList.forEach((ele) => {
if (getEleCount(ele, equipNameList) > 1) duplicatedName.add(ele);
})
equipIncluded.forEach((ele) => {
if (duplicatedName.has(name[ele]) && core.getEquip(ele) !== null) {
core.unloadEquip(ele);
core.status.route.push("unEquip:" + ele.toString());
}
})
for (let i = 0, l = bestCombination.length; i < l; i++) {
const currEquip = bestCombination[i],
pos = equipIncluded[i];
if (core.getEquip(pos) === currEquip) continue;
else if (currEquip === null) {
core.unloadEquip(pos);
core.status.route.push("unEquip:" + pos.toString());
} else {
core.loadEquip(currEquip);
core.status.route.push("equip:" + currEquip.toString());
}
}
}
this.figureEquip = function () {
compareEquip().then(function (confirm) {
core.unlockControl();
})
}
},
"setting": function () {
// 自绘设置界面
// 请保持本插件在所有插件的最下方
@ -4163,7 +4370,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
'攻击': 'atk', '攻': 'atk', '防御': 'def', '防': 'def',
'魔防': 'mdef', '护盾': 'mdef', 'mf': 'mdef',
'金币': 'money', '金钱': 'money', '钱': 'money', '经验': 'exp',
'魔力': 'mana', '蓝': 'mana',
'魔力': 'mana', '魔': 'mana', '蓝': 'mana',
}
core.utils.myprompt('输入要修改的属性名称', null, (value) => {
const heroStatus = core.status.hero;