From e621909adcb6a0731979954d85c30ec0ced155a5 Mon Sep 17 00:00:00 2001 From: Lajos Meszaros Date: Thu, 23 May 2024 20:16:17 +0200 Subject: [PATCH] add tutorials for the backrooms --- assets/i18n.json | 12 +++++-- src/entities/TrashBag.ts | 2 +- src/entities/WetFloorSign.ts | 2 +- src/gameStateManager.ts | 67 +++++++++++++++++++++++++++++++++++- src/rooms/backrooms.ts | 12 +++++-- 5 files changed, 88 insertions(+), 7 deletions(-) diff --git a/assets/i18n.json b/assets/i18n.json index 881c51d..ff91ad4 100644 --- a/assets/i18n.json +++ b/assets/i18n.json @@ -107,12 +107,20 @@ "english": "Fire Ex!t", "german": "Notausgan9" }, - "trash_bag": { + "trash-bag": { "english": "A smelly bag of trash", "german": "Ein stinkender Müllsack" }, - "wet_floor_sign": { + "wet-floor-sign": { "english": "Wet floor sign", "german": "Nassbodenschild" + }, + "tutorial--backrooms-1": { + "english": "Uh oh, you went out of bounds and landed in the backrooms. Find an unmarked fire exit door to return to the map.", + "german": "Oh oh, du hast die Levelgrenzen überschritten und bist in den Hinterräumen gelandet. Finde eine unmarkierte Notausgangstür um zurückzukehren. " + }, + "tutorial--backrooms-2": { + "english": "Almost all lights have lost their power, but you can restore electricity by shooting the ceiling lamps with a lightning bolt spell.", + "german": "Fast alle Lichter sind ausgefallen, aber du kannst die Elektrizität wiederherstellen indem du die Lampen mit einem Blitzzauber beschießt." } } \ No newline at end of file diff --git a/src/entities/TrashBag.ts b/src/entities/TrashBag.ts index 2b14881..6117809 100644 --- a/src/entities/TrashBag.ts +++ b/src/entities/TrashBag.ts @@ -45,7 +45,7 @@ export class TrashBag extends Entity { this.withScript() - this.script?.properties.push(new Label('[trash_bag]')) + this.script?.properties.push(new Label('[trash-bag]')) const oneInFour = new Variable('int', 'one_in_four', 0) diff --git a/src/entities/WetFloorSign.ts b/src/entities/WetFloorSign.ts index 4dc29e0..5e6546b 100644 --- a/src/entities/WetFloorSign.ts +++ b/src/entities/WetFloorSign.ts @@ -30,6 +30,6 @@ export class WetFloorSign extends Entity { this.withScript() - this.script?.properties.push(new Label('[wet_floor_sign]'), Collision.on) + this.script?.properties.push(new Label('[wet-floor-sign]')) } } diff --git a/src/gameStateManager.ts b/src/gameStateManager.ts index 6e3a453..e17b75b 100644 --- a/src/gameStateManager.ts +++ b/src/gameStateManager.ts @@ -29,6 +29,20 @@ const tutorialGaveGameToGoblin = new ScriptSubroutine('tutorial_gave_game_to_gob quest [tutorial--gave-game-to-goblin] ` }) +const tutorialLandedInBackrooms = new ScriptSubroutine('tutorial_landed_in_backrooms', () => { + return ` + ${notification.play()} + herosay [tutorial--backrooms-1] + quest [tutorial--backrooms-1] + ` +}) +const tutorialBackroomsLights = new ScriptSubroutine('tutorial_backrooms_light', () => { + return ` + ${notification.play()} + herosay [tutorial--backrooms-2] + quest [tutorial--backrooms-2] + ` +}) const achievementListenSmall = new ScriptSubroutine('achievement_found_games_small', () => { return ` @@ -76,13 +90,32 @@ export const createGameStateManager = (settings: Settings) => { const isGoblinReadyForSuicide = new Variable('bool', 'is_goblin_ready_for_suicide', false) const isGoblinDead = new Variable('bool', 'is_goblin_dead', false) const haveLittered = new Variable('bool', 'player_littered', false) + const landedInBackroomsFirstTime = new Variable('bool', 'landed_in_backrooms_first_time', true) + + const gotAam = new Variable('bool', 'got_aam', false) + const gotFolgora = new Variable('bool', 'got_folgora', false) + const gotTaar = new Variable('bool', 'got_taar', false) + const backroomsLightTutorialDone = new Variable('bool', 'backrooms_light_tutorial_done', false) - manager.script?.properties.push(numberOfCollectedGames, playerFoundAnyGames, isGoblinReadyForSuicide, isGoblinDead) + manager.script?.properties.push( + numberOfCollectedGames, + playerFoundAnyGames, + isGoblinReadyForSuicide, + isGoblinDead, + haveLittered, + landedInBackroomsFirstTime, + gotAam, + gotFolgora, + gotTaar, + backroomsLightTutorialDone, + ) manager.script?.subroutines.push( tutorialWelcome, tutorialFoundAGame, tutorialGaveGameToGoblin, + tutorialLandedInBackrooms, + tutorialBackroomsLights, achievementListenSmall, achievementListenMedium, achievementListenLarge, @@ -191,6 +224,38 @@ export const createGameStateManager = (settings: Settings) => { .on('player_leaves_backrooms', () => { return `sendevent send_to_spawn player nop` }) + .on('landed_in_backrooms', () => { + return ` + if (${landedInBackroomsFirstTime.name} == 1) { + set ${landedInBackroomsFirstTime.name} 0 + ${tutorialLandedInBackrooms.invoke()} + } + ` + }) + .on('got_rune', () => { + return ` + if (^$param1 == "aam") { + set ${gotAam.name} 1 + } + if (^$param1 == "folgora") { + set ${gotFolgora.name} 1 + } + if (^$param1 == "taar") { + set ${gotTaar.name} 1 + } + + if (${gotAam.name} == 1) { + if (${gotFolgora.name} == 1) { + if (${gotTaar.name} == 1) { + if (${backroomsLightTutorialDone.name} == 0) { + set ${backroomsLightTutorialDone.name} 1 + ${tutorialBackroomsLights.invoke()} + } + } + } + } + ` + }) return manager } diff --git a/src/rooms/backrooms.ts b/src/rooms/backrooms.ts index 824b314..9ae6ecd 100644 --- a/src/rooms/backrooms.ts +++ b/src/rooms/backrooms.ts @@ -30,12 +30,21 @@ export const createBackrooms = async ( const aam = new Rune('aam', { position: roomOrigin.clone().add(new Vector3(randomBetween(-200, 200), 0, randomBetween(-200, 200))), }) + aam.script?.on('inventoryuse', () => { + return `sendevent got_rune ${gameStateManager.ref} aam` + }) const folgora = new Rune('folgora', { position: roomOrigin.clone().add(new Vector3(randomBetween(-200, 200), 0, randomBetween(-200, 200))), }) + folgora.script?.on('inventoryuse', () => { + return `sendevent got_rune ${gameStateManager.ref} folgora` + }) const taar = new Rune('taar', { position: roomOrigin.clone().add(new Vector3(randomBetween(-200, 200), 0, randomBetween(-200, 200))), }) + taar.script?.on('inventoryuse', () => { + return `sendevent got_rune ${gameStateManager.ref} taar` + }) contents.entities.push(aam, folgora, taar) const entryZone = createZone({ @@ -54,8 +63,7 @@ export const createBackrooms = async ( }) entry.script?.properties.push(new ControlZone(entryZone)) entry.script?.on('controlledzone_enter', () => { - // TODO: do lightning effect on the ceiling lamp that turns it on - return '' + return `sendevent landed_in_backrooms ${gameStateManager.ref} nop` }) contents.entities.push(entry) contents._.entry = entry