From 302506eda9e16e474058f1d8f55c9d02cc219aad Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Fri, 29 Apr 2022 21:27:07 -0700 Subject: [PATCH] Cheat: $ d.SetPlayerCharacter("anything.doodad") Too restricted by the cheat codes to play as certain characters on-demand? Use the JS shell in the developer console to set any doodad you want: $ d.SetPlayerCharacter("key-blue") $ d.SetPlayerCharacter("anvil") $ d.SetPlayerCharacter("box.doodad") The .doodad suffix is optional. Interesting behaviors when playing as odd doodads: * Most non-mobile doodads don't collide with each other, so you can pass through doors and not activate buttons if you play as a key or a trapdoor. Non-mobile doodads also generally have antigravity so you can fly freely around the map. * Non-mobile doodads can not open Warp Doors or interact with the Exit Flag. You'll have to change back to a creature such as "boy" or "azu-blue" to win the level. * If you are a key, the Thief can collect you! This removes your player doodad from the level and soft locks the game. No worries, another call to d.SetPlayerCharacter() will put you back on the map! * If the doodad name isn't found, you'll play as the built-in fallback doodad, which is just a red "X" shape. It has anti-gravity and does not generally interact with any doodad (can not push buttons or collect keys - but it can pass through doors and other obstacles. Can not win the level goal flag, though!) --- pkg/cheats.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/cheats.go b/pkg/cheats.go index 535be43..937d592 100644 --- a/pkg/cheats.go +++ b/pkg/cheats.go @@ -10,6 +10,17 @@ import ( // IsDefaultPlayerCharacter checks whether the DefaultPlayerCharacter doodad has // been modified +// SetPlayerCharacter -- this is designed to be called in-game with the developer +// console. Sets your player character to whatever doodad you want, not just the +// few that have cheat codes. If you set an invalid filename, you become the +// dummy default doodad sprite (a red "X"). +func (d *Doodle) SetPlayerCharacter(filename string) { + balance.PlayerCharacterDoodad = filename + if playScene, isPlay := d.Scene.(*PlayScene); isPlay { + playScene.SetPlayerCharacter(balance.PlayerCharacterDoodad) + } +} + // cheatCommand is a subroutine of the Command.Run() method of the Doodle // developer shell (commands.go). It looks for special cheat codes entered // into the command shell and executes them.