diff --git a/public/project/floors/MT17.js b/public/project/floors/MT17.js index 6fceb63..3a01dda 100644 --- a/public/project/floors/MT17.js +++ b/public/project/floors/MT17.js @@ -52,7 +52,14 @@ main.floors.MT17= ] } }, - "afterBattle": {}, + "afterBattle": { + "12,6": [ + { + "type": "function", + "function": "function(){\nif (core.status.hero.hp - flags.hphphp >= 150000) {\n\tcore.completeAchievement('normal', 1);\n\tdelete flags.hphphp;\n}\n}" + } + ] + }, "afterGetItem": {}, "afterOpenDoor": {}, "autoEvent": {}, @@ -94,7 +101,15 @@ main.floors.MT17= "fgmap": [ ], - "beforeBattle": {}, + "beforeBattle": { + "12,6": [ + { + "type": "setValue", + "name": "flag:hphphp", + "value": "core.status.hero.hp" + } + ] + }, "bg2map": [ ], diff --git a/public/project/floors/MT6.js b/public/project/floors/MT6.js index 0bf9665..8d4395f 100644 --- a/public/project/floors/MT6.js +++ b/public/project/floors/MT6.js @@ -120,7 +120,14 @@ main.floors.MT6= ] } }, - "afterBattle": {}, + "afterBattle": { + "4,12": [ + { + "type": "function", + "function": "function(){\nif (core.status.hero.hp === 1) {\n\tcore.completeAchievement('normal', 0);\n}\n}" + } + ] + }, "afterGetItem": { "4,4": [ { diff --git a/src/plugin/chase/chase.ts b/src/plugin/chase/chase.ts index 17837d2..35f1a00 100644 --- a/src/plugin/chase/chase.ts +++ b/src/plugin/chase/chase.ts @@ -1,4 +1,5 @@ import { Animation, sleep, TimingFn } from 'mutate-animate'; +import { completeAchievement } from '../ui/achievement'; import { has } from '../utils'; import { ChaseCameraData, ChasePath, getChaseDataByIndex } from './data'; @@ -30,6 +31,8 @@ export class Chase { */ showPath: boolean = false; + endFn?: () => void; + /** * 开始一个追逐战 * @param index 追逐战索引 @@ -203,6 +206,14 @@ export class Chase { this.showPath = show; } + /** + * 当追逐战结束后执行函数 + * @param fn 执行的函数 + */ + onEnd(fn: () => void) { + this.endFn = fn; + } + /** * 结束这个追逐战 */ @@ -215,6 +226,7 @@ export class Chase { delete flags.chaseIndex; flags.__lockViewport__ = false; core.deleteCanvas('chasePath'); + if (this.endFn) this.endFn(); } } @@ -223,10 +235,20 @@ export async function startChase(index: number) { flags.chaseIndex = index; flags.onChase = true; await sleep(20); - flags.chase = new Chase( + const chase = new Chase( data.path, data.fns, data.camera, flags.chaseHard === 0 ); + flags.chase = chase; + + // 成就 + chase.onEnd(() => { + if (flags.chaseHard === 1) { + if (index === 1) { + completeAchievement('challenge', 0); + } + } + }); }