2767mr's code pearls
A simple hello world mod:
export default class HelloWorld extends Plugin {
prestart() {
console.log('Hello world!');
}
}
How to get your mod directory:
export default class ModFolder extends Plugin {
constructor(mod) {
this.dir = mod.baseDirectory;
}
prestart() {
console.log(`Your mod directory is ${this.dir}`);
}
}
Check if code is running in the browser:
ig.platform === ig.PLATFORM_TYPES.BROWSER
Double all CP gain:
sc.PlayerModel.inject({
addSkillPoints(points, element, all, extra) {
this.parent(points*2, element, all, extra);
}
});
Register preupdate calls:
export default class UpdateCall extends Plugin {
prestart() {
const self = this;
sc.CrossCode.inject({
init(...args) {
this.parent(...args);
this.addons.preUpdate.push(self);
}
})
}
onPreUpdate() {
//...
}
}
Enable new game+ early:
sc.TitleScreenButtonGui.inject({
checkClearSaveFiles: function() {
return true;
}
});
Open devtools for a background page:
chrome.developerPrivate.openDevTools({
renderViewId: -1,
renderProcessId: -1,
extensionId: chrome.runtime.id
});
Instant respawn for enemies:
ig.ENTITY.EnemySpawner.inject({
update(...args) {
this.respawnTimer = 0;
return this.parent(...args);
}
});
A lot of trophy points:
sc.TrophyManager.inject({
getTotalPoints() {
return 100000000;
}
});
Enables witch times for all controlled characters:
ig.ENTITY.Player.inject({
onPerfectDash() {
this.parent();
if (!this.dashPerfect && this.model.name != "Lea"
&& this.model.name == sc.model.player.name && sc.newgame.get("witch-time") && !ig.vars.get("tmp.slowMotionActive")) {
sc.combat.showPerfectDashEffect(this);
const proxy = sc.ProxyTools.getProxy("evadeSloMo", this);
if (proxy)
proxy.spawn(this.coll.pos.x, this.coll.pos.y, this.coll.pos.z, this, this.face, true);
this.invincibleTimer = 4;
}
}
});
Changes game ratio from 16:9 to 21:9:
export default class Widescreen {
prestart() {
const factor = 21 / 16;
window.IG_WIDTH *= factor;
}
}