From 3f7e384633565300042f0773ccd25a277a5caeb4 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Mon, 17 Jan 2022 22:02:27 -0800 Subject: [PATCH] Invincibility Cheat Add cheat `god mode` that toggles invincibility. Fire pixels and hostile mobs can't fail the level for you. --- Changes.md | 51 +++++++++++++++++++++++++++++++++++++++++++ pkg/balance/cheats.go | 1 + pkg/cheats.go | 14 ++++++++++++ pkg/play_scene.go | 4 ++++ 4 files changed, 70 insertions(+) diff --git a/Changes.md b/Changes.md index 7a711ee..10f8387 100644 --- a/Changes.md +++ b/Changes.md @@ -1,5 +1,56 @@ # Changes +## v0.11.0 (TBD) + +New features: + +* The **JavaScript Engine** for the game has been switched from + github.com/robertkrimen/otto to github.com/dop251/goja which helps + "modernize" the experience of writing doodads. Goja supports many + common ES6 functions already, such as: + * Arrow functions + * `let` and `const` keywords + * Promises + * for-of loops +* The **JavaScript API** has been expanded with new functions and + many of the built-in Creatures have gotten an A.I. update. +* For full versions of the game, the **Publish Level** function is now + more streamlined to just a checkbox for automatically bundling your + doodads next time you save the level. + +Some of the built-in doodads have updates to their A.I. and creatures +are becoming more dangerous: + +* The **Bird** now searches for the player diagonally in front of + it for about 240px or so. If spotted it will dive toward you and + it is dangerous when diving! +* The **Azulians** will start to follow the player when you get + close and they are dangerous when they touch you -- but not if + you're the **Thief.** The red Azulian has a wider search radius, + higher jump and faster speed than the blue Azulian. + +New functions are available on the JavaScript API for doodads: + +* `Actors.At(Point) []*Actor`: returns actors intersecting a point +* `Actors.FindPlayer() *Actor`: returns the nearest player character +* `Actors.New(filename string)`: create a new actor (NOT TESTED YET!) +* `Self.Grounded() bool`: query the grounded status of current actor + +New cheat code: + +* `god mode`: toggle invincibility. When on, fire pixels and hostile + mobs can't make you fail the level. + +Other changes: + +* The draw order of actors on a level is now deterministic: the most + recently added actor will always draw on top when overlapping another, + and the player actor is always on top. +* When the game checks if there's an update available via + it will send a user + agent header like: "Sketchy Maze v0.10.2 on linux/amd64" sending only + static data about the version and OS. + ## v0.10.1 (Jan 9 2022) New features: diff --git a/pkg/balance/cheats.go b/pkg/balance/cheats.go index 8c0016a..e2cb474 100644 --- a/pkg/balance/cheats.go +++ b/pkg/balance/cheats.go @@ -29,4 +29,5 @@ var ( CheatPlayAsBoy = "pinocchio" CheatPlayAsAzuBlue = "the cell" CheatPlayAsThief = "play as thief" + CheatGodMode = "god mode" ) diff --git a/pkg/cheats.go b/pkg/cheats.go index a1ef05e..b3806f5 100644 --- a/pkg/cheats.go +++ b/pkg/cheats.go @@ -128,6 +128,20 @@ func (c Command) cheatCommand(d *Doodle) bool { balance.PlayerCharacterDoodad = "thief.doodad" d.Flash("Set default player character to Thief") + case balance.CheatGodMode: + if isPlay { + d.Flash("God mode toggled") + playScene.SetCheated() + playScene.godMode = !playScene.godMode + if playScene.godMode { + d.FlashError("God mode enabled.") + } else { + d.Flash("God mode disabled.") + } + } else { + d.FlashError("Use this cheat in Play Mode to toggle invincibility.") + } + default: return false } diff --git a/pkg/play_scene.go b/pkg/play_scene.go index 15e0105..afc1238 100644 --- a/pkg/play_scene.go +++ b/pkg/play_scene.go @@ -69,6 +69,7 @@ type PlayScene struct { playerLastDirection float64 // player's heading last tick antigravity bool // Cheat: disable player gravity noclip bool // Cheat: disable player clipping + godMode bool // Cheat: player can't die playerJumpCounter int // limit jump length // Inventory HUD. Impl. in play_inventory.go @@ -420,6 +421,9 @@ func (s *PlayScene) BeatLevel() { // FailLevel handles a level failure triggered by a doodad. func (s *PlayScene) FailLevel(message string) { + if s.godMode { + return + } s.SetImperfect() s.d.FlashError(message) s.ShowEndLevelModal(