伤害弹出

This commit is contained in:
草莓 2025-02-25 10:49:54 +08:00
parent e0ed30be3b
commit 9d2c199a1e
3 changed files with 1386 additions and 858 deletions

View File

@ -1140,7 +1140,8 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"flags": {
"itemDetail": true,
"useBetweenLight": true,
"__mdef_buff__": 0
"__mdef_buff__": 0,
"popmove": true
},
"followers": [],
"steps": 0,

View File

@ -1888,12 +1888,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
core.bigmap.width * 32 === core.bigmap.height * 32 &&
core.bigmap.width * 32 === core.__PIXELS__
)
core.addPopMove(
32 * core.status.hero.loc.x + 16,
32 * core.status.hero.loc.y + 16,
32 * x + 16,
32 * y + 16
);
if (core.getFlag('popmove')) core.addPopMove(32 * core.status.hero.loc.x + 16, 32 * core.status.hero.loc.y + 16, 32 * x + 16, 32 * y + 16);
// 获得勇士最后的朝向
var lastDirection = core.status.route[core.status.route.length - 1];
if (["left", "right", "up", "down"].indexOf(lastDirection) >= 0)
@ -1916,7 +1911,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
return true;
}
return false;
},
},
"parallelDo": function (timestamp) {
// 并行事件处理,可以在这里写任何需要并行处理的脚本或事件
// 该函数将被系统反复执行每次执行间隔视浏览器或设备性能而定一般约为16.6ms一次

View File

@ -4345,6 +4345,117 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
this.afterBattle(id, x, y);
if (callback) callback();
};
actions.prototype._sys_ondown_lockControl = function (x, y, px, py) {
if (core.status.played && !core.status.lockControl) return false;
switch (core.status.event.id) {
case 'battle':
core.plugin.battle_onclick(x, y, px, py);
break;
case 'centerFly':
this._clickCenterFly(x, y, px, py);
break;
case 'book':
this._clickBook(x, y, px, py);
break;
case 'book-detail':
this._clickBookDetail(x, y, px, py);
break;
case 'fly':
this._clickFly(x, y, px, py);
break;
case 'viewMaps':
this._clickViewMaps(x, y, px, py);
break;
case 'switchs':
this._clickSwitchs(x, y, px, py);
break;
case 'switchs-sounds':
this._clickSwitchs_sounds(x, y, px, py);
break;
case 'switchs-display':
this._clickSwitchs_display(x, y, px, py);
break;
case 'switchs-action':
this._clickSwitchs_action(x, y, px, py);
break;
case 'settings':
this._clickSettings(x, y, px, py);
break;
case 'selectShop':
this._clickQuickShop(x, y, px, py);
break;
case 'equipbox':
this._clickEquipbox(x, y, px, py);
break;
case 'toolbox':
this._clickToolbox(x, y, px, py);
break;
case 'save':
case 'load':
case 'replayLoad':
case 'replayRemain':
case 'replaySince':
this._clickSL(x, y, px, py);
break;
case 'confirmBox':
this._clickConfirmBox(x, y, px, py);
break;
case 'keyBoard':
this._clickKeyBoard(x, y, px, py);
break;
case 'action':
this._clickAction(x, y, px, py);
break;
case 'text':
core.drawText();
break;
case 'notes':
this._clickNotes(x, y, px, py);
break;
case 'syncSave':
this._clickSyncSave(x, y, px, py);
break;
case 'syncSelect':
this._clickSyncSelect(x, y, px, py);
break;
case 'localSaveSelect':
this._clickLocalSaveSelect(x, y, px, py);
break;
case 'storageRemove':
this._clickStorageRemove(x, y, px, py);
break;
case 'cursor':
this._clickCursor(x, y, px, py);
break;
case 'replay':
this._clickReplay(x, y, px, py);
break;
case 'gameInfo':
this._clickGameInfo(x, y, px, py);
break;
case 'about':
case 'help':
core.ui.closePanel();
break;
}
// --- 长按判定
if (core.timeout.onDownTimeout == null) {
core.timeout.onDownTimeout = setTimeout(function () {
if (core.interval.onDownInterval == null) {
core.interval.onDownInterval = setInterval(function () {
if (!core.actions.longClick(x, y, px, py)) {
clearInterval(core.interval.onDownInterval);
core.interval.onDownInterval = null;
}
}, 40)
}
}, 500);
}
return true;
}
core.registerAction('ondown', '_sys_ondown_lockControl', core.actions._sys_ondown_lockControl, 30);;
},
"额外信息": function () {
/*
@ -4503,6 +4614,171 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}
}
},
"跳伤": function () {
// 在此增加新插件
/**
函数使用说明
Dove.MorePerform.ShowDamagePop.PopDamage(
'ui', // 画布名称或画布2d上下文对象
100, 200, // 位置 (x, y)
-50, // 伤害值
24, // 字体大小
'#FF0000', // 字体颜色
'#000000', // 描边颜色
0.5, // 水平速度 (speedX)
-10, // 垂直速度 (speedY)
0.5, // 重力 (gravity)
120 // 显示时长(帧数)
*/
if (!core.registerAnimationFrame) {
throw new Error('require 2.6.1 or higher version');
}
window.Dove = window.Dove || {};
Dove.MorePerform = Dove.MorePerform || {};
Dove.MorePerform.ShowDamagePop = {};
Dove.MorePerform.ShowDamagePop.version = 1.0;
Dove.MorePerform.ShowDamagePop.AllPopingCanvas = [];
// 每帧的处理
Dove.MorePerform.ShowDamagePop.Update = function () {
this.AllPopingCanvas = this.AllPopingCanvas.filter(function (spr) {
spr.update();
return spr.isAlive();
});
if (!this.AllPopingCanvas.length) PopSprite._count = 0;
};
// 弹出伤害气泡
Dove.MorePerform.ShowDamagePop.PopDamage = function (canvasName, x, y, damageValue, fontSize, fontColor, outlineColor, speedX, speedY, gravity, duration) {
if (damageValue) {
var poper = new PopSprite(canvasName, x, y, damageValue, fontSize, fontColor, outlineColor, speedX, speedY, gravity, duration);
Dove.MorePerform.ShowDamagePop.AllPopingCanvas.push(poper);
}
};
// 战斗发生前后记录生命值并处理
Dove.MorePerform.ShowDamagePop.OnBattle = core.events.battle;
core.events.battle = function () {
var hpBeforeBattle = core.status.hero.hp;
Dove.MorePerform.ShowDamagePop.OnBattle.apply(core.events, arguments);
Dove.MorePerform.ShowDamagePop.PopDamage(
'ui', // 默认画布名称
core.getHeroLoc('x') * 32, // 英雄位置 x
core.getHeroLoc('y') * 32, // 英雄位置 y
Math.floor(core.status.hero.hp - hpBeforeBattle), // 伤害值
16, // 默认字体大小
null, // 默认颜色
null, // 默认描边颜色
null, // 默认水平速度
null, // 默认垂直速度
null, // 默认重力
180 // 默认显示时长(帧数)
);
};
let time = 0
// 注册每帧事件
core.registerAnimationFrame("ShowDamagePop", true,
(temptime) => {
if (temptime - time > 1000 / 60) {
time = temptime
Dove.MorePerform.ShowDamagePop.Update.bind(Dove.MorePerform.ShowDamagePop)()
}
}
);
// 弹出精灵类
function PopSprite(canvasName, x, y, damage, fontSize, fontColor, outlineColor, speedX, speedY, gravity, duration) {
this.initialize.apply(this, arguments);
}
PopSprite.prototype = Object.create(Object.prototype);
PopSprite.prototype.constructor = PopSprite;
// 常量
PopSprite._count = 0;
PopSprite._baseZOrder = 50;
PopSprite._floorDis = 20;
// 初始化
PopSprite.prototype.initialize = function (canvasName, x, y, damage, fontSize, fontColor, outlineColor, speedX, speedY, gravity, duration) {
this._canvasName = canvasName ?? 'ui'; // 默认画布名称
this._x = x;
this._y = y;
this._damage = damage;
this._fontSize = fontSize ?? 16; // 默认字体大小
this._fontColor = fontColor ?? (damage > 0 ? '#22FF44' : '#FF2244'); // 默认颜色
this._outlineColor = outlineColor ?? '#000000'; // 默认描边颜色
this._speedX = speedX ?? (-2 + Math.random() * 3); // 水平速度,默认随机
this._speedY = speedY ?? (-3 - Math.random() * 4); // 垂直速度,默认随机
this._gravity = gravity ?? 0.3; // 重力加速度,默认 0.5
this._duration = duration ?? 180; // 显示时长(帧数),默认 180 帧
this.initAllMembers();
this.requestCanvas();
};
// 自更新
PopSprite.prototype.update = function () {
if (this._timer < this._duration) { // 使用传入的显示时长
this._x += this._vx;
this._y += this._vy;
this._vy += this._gravity;
if (this._y >= this._floorY) {
this._y = this._floorY;
this._vy *= -0.75; // 反弹衰减
}
core.relocateCanvas(this._symbol, this._x, this._y);
core.setOpacity(this._symbol, 1 - this._timer / this._duration); // 根据显示时长设置透明度
} else {
this.dispose();
}
this._timer++;
};
// 申请并描绘canvas
PopSprite.prototype.requestCanvas = function () {
core.createCanvas(this._symbol, this._x, this._y, this._width, this._height, this._z);
var canvas = core.ui.getContextByName(this._symbol);
canvas.font = this._fontSize + 'px pala'; // 动态设置字体大小
canvas.fillStyle = this._fontColor; // 动态设置字体颜色
canvas.strokeStyle = this._outlineColor; // 动态设置描边颜色
canvas.strokeText(this._text, 2, this._height);
canvas.fillText(this._text, 2, this._height);
};
// 初始化所有成员变量
PopSprite.prototype.initAllMembers = function () {
this._text = String(this._damage);
var uiContext = core.ui.getContextByName(this._canvasName); // 使用指定画布
uiContext.font = this._fontSize + 'px pala'; // 动态设置字体大小
var textRect = uiContext.measureText(this._text);
this._width = Math.round(textRect.width + 4);
this._height = this._fontSize + 4; // 动态设置高度
this._z = PopSprite._baseZOrder + PopSprite._count;
this._symbol = 'popSprite' + PopSprite._count++;
this._alive = true;
this._vx = this._speedX; // 使用传入的水平速度
this._vy = this._speedY; // 使用传入的垂直速度
this._floorY = this._y + PopSprite._floorDis;
this._timer = 0;
};
// 判断是否存活
PopSprite.prototype.isAlive = function () {
return this._alive;
};
// 释放
PopSprite.prototype.dispose = function () {
this._alive = false;
core.deleteCanvas(this._symbol);
};
},
"编辑器显伤": function () {
// 在此增加新插件
/////// 用户设置 ///////
@ -5647,7 +5923,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
var compare2;
if (item.equipCls === "双手剑")
compare2 = core.compareEquipment(null, core.getEquip(1));
if (item.equipCls === "盾牌" && core.material.items[core.getEquip(0)].equipCls === "双手剑")
if (item.equipCls === "盾牌" && core.material.items[core.getEquip(0)]?.equipCls === "双手剑")
compare2 = core.compareEquipment(null, core.getEquip(0));
if (info.select.action == "unload")
compare = core.compareEquipment(null, item.id);
@ -12453,7 +12729,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
else core.status.popMove.push(data);
}
};
},
},
"墓碑(编辑器)": function () {
// 在此增加新插件
if (main.mode != "editor") return; // 编辑器模式下使用
@ -16061,8 +16337,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
image,
memory,
hidetime = 30,
list = [
{
list = [{
text: "",
sound: "",
time: 50,
@ -16070,8 +16345,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
boldColor: "#000000",
font: "bold 48px Verdana",
frame: 0,
},
]
}, ]
) {
if (!core.isPlaying()) {
return core.doAction();
@ -16448,7 +16722,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
break;
}
};
},
},
"回合制boss战": function () {
// 在此增加新插件
const boss = document.createElement("canvas"); //boss战画布设置
@ -20081,6 +20355,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
const ctx = animateAttack.getContext("2d");
core.plugin.playingattack = new Set()
const ctx6 = main.dom.animate2.getContext('2d')
let easy = false
function playanimate(name, x, y, scalex = 1, scaley = 1) {
const data = {
@ -20226,7 +20501,36 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
})
}
core.plugin.battle_onclick = function (x, y, px, py) {
const makeBox = ([x, y], [w, h]) => {
return [
[x, y],
[x + w, y + h],
];
};
const inRect = ([x, y], [
[sx, sy],
[dx, dy]
]) => {
return sx <= x && x <= dx && sy <= y && y <= dy;
};
const pos = [px, py];
const easybox = makeBox([90, 212], [80, 22]),
easyclosebox = makeBox([290, 212], [40, 22]),
uneasybox = makeBox([250, 300], [80, 22]),
uneasyclosebox = makeBox([290, 325], [40, 22]);
if (inRect(pos, easybox) && easy) {
easy = false
} else if (inRect(pos, uneasybox) && !easy) {
easy = true
} else if ((inRect(pos, easyclosebox) && easy) || (inRect(pos, uneasyclosebox) && !easy)) {
core.status.event.id = ''
core.unregisterAnimationFrame("attackAnimate")
core.clearMap(ctx)
core.closePanel()
}
}
main.dom.gameDraw.appendChild(animateAttack);
const { lcm, gcd } = core.plugin.utils
@ -20239,6 +20543,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
damageInfo,
onegcd
) {
core.lockControl()
core.status.event.id = 'battle'
let attack = false;
if (heroInfo.isAttack) attack = true;
if (enemyInfo.isAttack) attack = true;
@ -20247,6 +20554,201 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
});
core.clearMap(ctx);
let animate = Math.floor(farme / 30);
if (easy) {
core.fillRect(ctx, 64, 64, 288, 180, "rgba(0,0,0,0.5)");
core.strokeRect(ctx, 64, 64, 288, 180, "rgba(255,255,255,0.5)", 4);
core.setTextAlign(ctx, "center");
core.fillBoldText(
ctx,
hero.name,
127,
128,
"#FFFFFF",
"#000000",
"bold 14px pala"
);
core.setTextAlign(ctx, "left");
core.drawIcon(ctx, "hp", 70, 190, 16, 16);
core.fillBoldText(
ctx,
"生命 " + core.formatBigNumber(heroInfo.hp, true),
90,
205,
"#FFFFFF",
"#000000",
"bold 14px pala"
);
core.fillBoldText(
ctx,
"详细模式",
90,
230,
"#FFFF60",
"#000000",
"bold 18px pala"
);
core.strokeRect(ctx, 112, 139, 32, 48, "rgba(255,255,255,1)", 1);
core.drawImage(
ctx,
"hero.webp",
32 * (animate % 4),
0,
32,
48,
112,
139,
32,
48
);
core.setTextAlign(ctx, "center");
core.fillBoldText(
ctx,
enemyInfo.name,
289,
128,
"#FFFFFF",
"#000000",
"bold 14px pala"
);
core.setTextAlign(ctx, "right");
if (enemyInfo.cls === "enemys") {
core.strokeRect(ctx, 272, 155, 32, 32, "rgba(255,255,255,1)", 1);
core.drawImage(
ctx,
core.getBlockInfo(enemyInfo.id).image,
32 * (animate % 2),
core.getBlockInfo(enemyInfo.id).posY * 32,
32,
32,
272,
155,
32,
32
);
} else {
core.strokeRect(ctx, 272, 139, 32, 48, "rgba(255,255,255,1)", 1);
core.drawImage(
ctx,
core.getBlockInfo(enemyInfo.id).image,
32 * (animate % 4),
core.getBlockInfo(enemyInfo.id).posY * 48,
32,
48,
272,
139,
32,
48
);
}
core.drawIcon(ctx, "hp", 330, 190, 16, 16);
core.fillBoldText(
ctx,
core.formatBigNumber(enemyInfo.hp, true) + " 生命",
330,
205,
"#FFFFFF",
"#000000",
"bold 14px pala"
);
core.fillBoldText(
ctx,
"跳过",
330,
230,
"#FFFF60",
"#000000",
"bold 18px pala"
);
core.fillBoldText(
ctx,
"V",
219,
163,
"#FFFFFF",
"#000000",
"bold 48px pala"
);
core.fillBoldText(
ctx,
"s",
231,
163,
"#FFFFFF",
"#000000",
"bold 36px pala"
);
if (!attack) enemyInfo.now += enemyInfo.speed / onegcd;
let enemynow = Math.min(100 + enemyInfo.now / oneTurn * 215, 315);
ctx.fillStyle = "#FFFFFF";
ctx.beginPath();
ctx.moveTo(enemynow, 100);
ctx.lineTo(enemynow + 5, 90);
ctx.lineTo(enemynow - 5, 90);
ctx.closePath();
ctx.fill();
if (enemyInfo.cls === "enemys") {
core.drawImage(
ctx,
core.getBlockInfo(enemyInfo.id).image,
32,
core.getBlockInfo(enemyInfo.id).posY * 32,
32,
32,
enemynow - 16,
64,
32,
32
);
} else {
core.drawImage(
ctx,
core.getBlockInfo(enemyInfo.id).image,
32,
core.getBlockInfo(enemyInfo.id).posY * 48,
32,
19,
enemynow - 16,
70,
32,
19
);
}
core.drawLine(ctx, 100, 105, 315, 105, "#FFFFFF", 5);
equipInfo.forEach(function (v) {
if (!attack) v.now += v.speed / onegcd;
let vnow = Math.min(100 + v.now / oneTurn * 215, 315);
ctx.beginPath();
ctx.moveTo(vnow, 100);
ctx.lineTo(vnow + 5, 90);
ctx.lineTo(vnow - 5, 90);
ctx.closePath();
ctx.fill();
core.drawIcon(ctx, v.id, vnow - 16, 64, 32, 32);
});
if (!attack) heroInfo.now += hero.speed / onegcd;
let heronow = Math.min(100 + heroInfo.now / oneTurn * 215, 315);
ctx.beginPath();
ctx.moveTo(heronow, 100);
ctx.lineTo(heronow + 5, 90);
ctx.lineTo(heronow - 5, 90);
ctx.closePath();
ctx.fill();
core.drawImage(ctx, "hero.webp", 0, 0, 32, 19, heronow - 16, 70, 32, 19);
} else {
core.fillRect(ctx, 64, 64, 288, 288, "rgba(0,0,0,0.5)");
core.strokeRect(ctx, 64, 64, 288, 288, "rgba(255,255,255,0.5)", 4);
core.setTextAlign(ctx, "center");
@ -20270,14 +20772,14 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.drawIcon(ctx, "jumpShoes", 70, 330, 16, 16);
core.fillBoldText(
ctx,
"生命 " +
core.formatBigNumber(heroInfo.hp, true) +
"生命 " + core.formatBigNumber(heroInfo.hp, true),
90,
205,
"#FFFFFF",
"#000000",
"bold 14px pala"
);
core.fillBoldText(
ctx,
"攻击 " + core.formatBigNumber(heroInfo.atk),
@ -20458,6 +20960,25 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
"#000000",
"bold 14px pala"
);
core.fillBoldText(
ctx,
"简易模式",
330,
315,
"#FFFF60",
"#000000",
"bold 18px pala"
);
core.fillBoldText(
ctx,
"跳过",
330,
340,
"#FFFF60",
"#000000",
"bold 18px pala"
);
core.fillBoldText(
ctx,
"V",
@ -20538,6 +21059,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
ctx.fill();
core.drawImage(ctx, "hero.webp", 0, 0, 32, 19, heronow - 16, 70, 32, 19);
}
let nowattacking = false
if (heroInfo.now >= oneTurn && !heroInfo.isAttack) {
@ -20596,7 +21118,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
])
if (heroInfo.hp <= 0 || enemyInfo.hp <= 0) {
core.status.event.id = ''
core.unregisterAnimationFrame("attackAnimate")
core.clearMap(ctx)
core.closePanel()
}
}
};