Skip to content

Commit d508ec1

Browse files
committed
start work on colored chests
1 parent 02bc671 commit d508ec1

2 files changed

Lines changed: 40 additions & 11 deletions

File tree

15.2 KB
Loading

src/plugin.ts

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,29 +188,58 @@ export default class MwRandomizer {
188188
let plugin = this;
189189

190190
ig.ENTITY.Chest.inject({
191-
_reallyOpenUp() {
191+
init(...args) {
192+
this.parent(...args);
193+
192194
const map = maps[ig.game.mapName];
193-
194195
if (!map) {
195-
console.warn('Chest not in logic');
196-
return this.parent();
196+
return;
197+
}
198+
199+
this.check = map.chests?.[this.mapId];
200+
if (!this.check) {
201+
return;
202+
}
203+
204+
let newOffY = 0;
205+
let flags = sc.multiworld.locationInfo[this.check.mwids[0]].flags;
206+
if (flags & (ap.ITEM_FLAGS.NEVER_EXCLUDE | ap.ITEM_FLAGS.TRAP)) {
207+
// USEFUL and TRAP items get a blue chest
208+
newOffY = 80;
209+
} else if (flags & ap.ITEM_FLAGS.PROGRESSION) {
210+
// PROGRESSION items get a green chest
211+
newOffY = 136;
212+
}
213+
214+
if (newOffY == 0) {
215+
return;
216+
}
217+
218+
for (const name of Object.keys(this.animSheet.anims)) {
219+
if (name.startsWith("idle")) {
220+
this.animSheet.anims[name].animations[0].sheet.offY = newOffY;
221+
}
222+
if (name == "open" || name == "end") {
223+
this.animSheet.anims[name].animations[0].sheet.offY = newOffY + 24;
224+
}
197225
}
226+
},
198227

199-
const check = map.chests?.[this.mapId];
228+
_reallyOpenUp() {
200229
if (
201-
check === undefined ||
202-
check.mwids === undefined ||
203-
check.mwids.length == 0 ||
204-
sc.multiworld.locationInfo[check.mwids[0]] === undefined
230+
this.check === undefined ||
231+
this.check.mwids === undefined ||
232+
this.check.mwids.length == 0 ||
233+
sc.multiworld.locationInfo[this.check.mwids[0]] === undefined
205234
) {
206235
console.warn('Chest not in logic');
207236
return this.parent();
208237
}
209238

210239
const old = sc.ItemDropEntity.spawnDrops;
211240
try {
212-
if (check) {
213-
sc.multiworld.reallyCheckLocations(check.mwids);
241+
if (this.check) {
242+
sc.multiworld.reallyCheckLocations(this.check.mwids);
214243
}
215244

216245
this.amount = 0;

0 commit comments

Comments
 (0)