fix: 跳跃录像错误

This commit is contained in:
unanmed 2024-11-28 20:50:36 +08:00
parent 3f8e52706e
commit fc8b995e59
4 changed files with 79 additions and 37 deletions

View File

@ -2746,11 +2746,8 @@ actions.prototype._clickReplay = function (x, y) {
actions.prototype._clickReplay_fromBeginning = function () { actions.prototype._clickReplay_fromBeginning = function () {
core.ui.closePanel(); core.ui.closePanel();
core.startGame( const route = core.status.route.slice();
core.status.hard, core.startGame(core.status.hard, core.getFlag('__seed__'), route);
core.getFlag('__seed__'),
core.cloneArray(core.status.route)
);
}; };
actions.prototype._clickReplay_fromLoad = function () { actions.prototype._clickReplay_fromLoad = function () {

View File

@ -46,12 +46,17 @@ type KeyUsing = [Hotkey, symbol];
/** /**
* *
* @param noScope
*/ */
export function useKey(): KeyUsing { export function useKey(noScope: boolean = false): KeyUsing {
const sym = Symbol(); if (noScope) {
gameKey.use(sym); return [gameKey, gameKey.scope];
onUnmounted(() => { } else {
gameKey.dispose(); const sym = Symbol();
}); gameKey.use(sym);
return [gameKey, sym]; onUnmounted(() => {
gameKey.dispose();
});
return [gameKey, sym];
}
} }

View File

@ -152,7 +152,10 @@ export function init() {
!core.status.floorId.startsWith('tower') && !core.status.floorId.startsWith('tower') &&
HeroSkill.learnedSkill(HeroSkill.Jump) HeroSkill.learnedSkill(HeroSkill.Jump)
) { ) {
Mota.Plugin.require('skill_g').jumpSkill(); const success = Mota.Plugin.require('skill_g').jumpSkill();
core.status.route.push(`useSkill:${toEmit}`);
if (!success) core.replay();
return true;
} else { } else {
if (core.hasItem('pickaxe')) { if (core.hasItem('pickaxe')) {
core.useItem('pickaxe'); core.useItem('pickaxe');

View File

@ -51,14 +51,21 @@ export const jumpIgnoreFloor: Set<FloorIds> = new Set([
'MT93' 'MT93'
]); ]);
// 跳跃 // 跳跃
export function jumpSkill() { export function jumpSkill(callback?: () => void) {
if (core.status.floorId.startsWith('tower')) { if (core.status.floorId.startsWith('tower')) {
return core.drawTip('当前无法使用该技能'); callback?.();
core.drawTip('当前无法使用该技能');
return false;
} }
if (jumpIgnoreFloor.has(core.status.floorId) || flags.onChase) { if (jumpIgnoreFloor.has(core.status.floorId) || flags.onChase) {
return core.drawTip('当前楼层无法使用该技能'); callback?.();
core.drawTip('当前楼层无法使用该技能');
return false;
}
if (!HeroSkill.learnedSkill(HeroSkill.Jump)) {
callback?.();
return false;
} }
if (!HeroSkill.learnedSkill(HeroSkill.Jump)) return;
if (!flags['jump_' + core.status.floorId]) if (!flags['jump_' + core.status.floorId])
flags['jump_' + core.status.floorId] = 0; flags['jump_' + core.status.floorId] = 0;
if (core.status.floorId == 'MT14') { if (core.status.floorId == 'MT14') {
@ -67,11 +74,16 @@ export function jumpSkill() {
flags.MT14Jump = true; flags.MT14Jump = true;
} }
if (flags.jump_MT14 === 2 && !flags.MT14Jump) { if (flags.jump_MT14 === 2 && !flags.MT14Jump) {
return core.drawTip('该地图还有一个必跳的地方,你还没有跳'); callback?.();
core.drawTip('该地图还有一个必跳的地方,你还没有跳');
return false;
} }
} }
if (flags['jump_' + core.status.floorId] >= 3) if (flags['jump_' + core.status.floorId] >= 3) {
return core.drawTip('当前地图使用次数已用完'); callback?.();
core.drawTip('当前地图使用次数已用完');
return false;
}
var direction = core.status.hero.loc.direction; var direction = core.status.hero.loc.direction;
var loc = core.status.hero.loc; var loc = core.status.hero.loc;
var checkLoc = {}; var checkLoc = {};
@ -106,13 +118,19 @@ export function jumpSkill() {
cls == 'items' || cls == 'items' ||
(id.startsWith('X') && !ignoreInJump.event.includes(id)) || (id.startsWith('X') && !ignoreInJump.event.includes(id)) ||
(bgId.startsWith('X') && !ignoreInJump.bg.includes(bgId)) (bgId.startsWith('X') && !ignoreInJump.bg.includes(bgId))
) ) {
return core.drawTip('当前无法使用技能'); callback?.();
core.drawTip('当前无法使用技能');
return false;
}
// debugger; // debugger;
// 不是怪物且不可以通行 // 不是怪物且不可以通行
if (noPass && !(cls == 'enemys' || cls == 'enemy48')) { if (noPass && !(cls == 'enemys' || cls == 'enemy48')) {
var toLoc = checkNoPass(direction, checkLoc.x, checkLoc.y, true); var toLoc = checkNoPass(direction, checkLoc.x, checkLoc.y, true);
if (!toLoc) return; if (!toLoc) {
callback?.();
return false;
}
core.autosave(); core.autosave();
if (flags.chapter <= 1) core.status.hero.hp -= 200 * flags.hard; if (flags.chapter <= 1) core.status.hero.hp -= 200 * flags.hard;
core.updateStatusBar(); core.updateStatusBar();
@ -121,16 +139,25 @@ export function jumpSkill() {
core.status.hero.hp = 0; core.status.hero.hp = 0;
core.updateStatusBar(); core.updateStatusBar();
core.events.lose('你跳死了'); core.events.lose('你跳死了');
callback?.();
return false;
} }
core.playSound('015-Jump01.ogg'); core.playSound('015-Jump01.ogg');
core.insertAction([ core.insertAction(
{ type: 'jumpHero', loc: [toLoc.x, toLoc.y], time: 500 } [{ type: 'jumpHero', loc: [toLoc.x, toLoc.y], time: 500 }],
]); void 0,
void 0,
callback
);
return true;
} }
// 是怪物 // 是怪物
if (cls == 'enemys' || cls == 'enemy48') { if (cls == 'enemys' || cls == 'enemy48') {
var firstNoPass = checkNoPass(direction, checkLoc.x, checkLoc.y, false); var firstNoPass = checkNoPass(direction, checkLoc.x, checkLoc.y, false);
if (!firstNoPass) return; if (!firstNoPass) {
callback?.();
return false;
}
core.autosave(); core.autosave();
if (flags.chapter <= 1) core.status.hero.hp -= 200 * flags.hard; if (flags.chapter <= 1) core.status.hero.hp -= 200 * flags.hard;
core.updateStatusBar(); core.updateStatusBar();
@ -139,18 +166,27 @@ export function jumpSkill() {
core.status.hero.hp = 0; core.status.hero.hp = 0;
core.updateStatusBar(); core.updateStatusBar();
core.events.lose('你跳死了'); core.events.lose('你跳死了');
callback?.();
return false;
} }
core.playSound('015-Jump01.ogg'); core.playSound('015-Jump01.ogg');
core.insertAction([ core.insertAction(
{ [
type: 'jump', {
from: [checkLoc.x, checkLoc.y], type: 'jump',
to: [firstNoPass.x, firstNoPass.y], from: [checkLoc.x, checkLoc.y],
time: 500, to: [firstNoPass.x, firstNoPass.y],
keep: true time: 500,
} keep: true
]); }
],
void 0,
void 0,
callback
);
return true;
} }
return false;
// 检查一条线上的不可通过 // 检查一条线上的不可通过
function checkNoPass(direction, x, y, startNo) { function checkNoPass(direction, x, y, startNo) {
@ -174,8 +210,9 @@ export function jumpSkill() {
y > core.status.thisMap.height - 1 || y > core.status.thisMap.height - 1 ||
x < 0 || x < 0 ||
y < 0 y < 0
) ) {
return core.drawTip('当前无法使用技能'); return core.drawTip('当前无法使用技能');
}
var id = core.getBlockId(x, y) || ''; var id = core.getBlockId(x, y) || '';
if (core.getBgNumber(x, y)) if (core.getBgNumber(x, y))
var bgId = var bgId =