Skip to content

Commit e04b318

Browse files
Implement level split type
Merges #4 Co-Authored-By: EpicYoshiMaster <32598419+EpicYoshiMaster@users.noreply.github.com>
1 parent cc8560f commit e04b318

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,20 @@ The `"start"` split may include a condition that causes the run to start.
145145
}
146146
```
147147

148+
### Level
149+
150+
`"level"` checks for the start of a level up animation for a particular level. Levels can be bounded with `"above"`, `"below"`, and/or `"equal"`.
151+
152+
#### Example
153+
```json
154+
{
155+
"splits": [{
156+
"type": "level",
157+
"equal": 15
158+
}]
159+
}
160+
```
161+
148162
### Preset
149163

150164
`"preset"` checks if a specific preset was loaded (see [CCPresetRevival](https://github.com/CCDirectLink/CCPresetRevival)). `"name"` will be checked against the `"title"` property of the loaded preset.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"start": "esbuild --target=es2018 --format=esm --platform=node --bundle --sourcemap=inline --outfile=plugin.js src/plugin.js",
88
"watch": "esbuild --target=es2018 --format=esm --platform=node --bundle --sourcemap=inline --watch --outfile=plugin.js src/plugin.js"
99
},
10-
"version": "2.6.0",
10+
"version": "3.0.0",
1111
"ccmodDependencies": {
1212
"ccloader": "^2.19.0",
1313
"Simplify": "^2.9.0"

src/eventManager.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class EventManager {
2222
Hook.startPresetButton((preset, slotIndex) => this._onStartPresetButton(preset, slotIndex));
2323
Hook.update(() => this._update());
2424
Hook.enemyHP((name, hp) => { this._check({ type: 'damage', name, hp }) });
25+
Hook.levelUp((level) => { this._check({ type: 'level', level })});
2526
Hook.teleport((mapName) => { this._check({ type: 'teleport', mapName }) });
2627
Hook.varChanged(() => { this._check({ type: 'vars' }) });
2728
window.addEventListener('unload', () => this.onunload());
@@ -182,6 +183,20 @@ export class EventManager {
182183
}
183184
break;
184185
}
186+
case 'level': {
187+
if(action && action.type === 'level') {
188+
if(typeof event.below === 'number' && action.level > event.below) {
189+
break;
190+
}
191+
if(typeof event.above === 'number' && action.level < event.above) {
192+
break;
193+
}
194+
if(typeof event.equal === 'number' && action.level !== event.equal) {
195+
break;
196+
}
197+
return [true, event.once];
198+
}
199+
}
185200
case 'preset': {
186201
if(action && action.type === 'preset' && action.presetName === event.name) {
187202
return [true, event.once];

src/hooks.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,14 @@ export class Hook {
8585
}
8686
});
8787
}
88+
89+
static levelUp(callback) {
90+
ig.GUI.LevelUpHud.inject({
91+
init: function(...args) {
92+
const result = this.parent(...args);
93+
callback(sc.model.player.level);
94+
return result;
95+
}
96+
});
97+
}
8898
}

0 commit comments

Comments
 (0)