2020-04-07 06:21:17 +00:00
|
|
|
package doodle
|
|
|
|
|
2021-10-03 04:12:57 +00:00
|
|
|
import (
|
2022-03-06 06:44:54 +00:00
|
|
|
"time"
|
|
|
|
|
2021-10-03 04:12:57 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/balance"
|
2022-03-06 06:44:54 +00:00
|
|
|
"git.kirsle.net/apps/doodle/pkg/modal/loadscreen"
|
2021-10-03 04:12:57 +00:00
|
|
|
)
|
2021-08-16 00:01:18 +00:00
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
// IsDefaultPlayerCharacter checks whether the DefaultPlayerCharacter doodad has
|
|
|
|
// been modified
|
|
|
|
|
2022-04-30 04:27:07 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-07 06:21:17 +00:00
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// Returns true if a cheat was intercepted, false if the command is not a cheat.
|
|
|
|
func (c Command) cheatCommand(d *Doodle) bool {
|
|
|
|
// Some cheats only work in Play Mode.
|
|
|
|
playScene, isPlay := d.Scene.(*PlayScene)
|
|
|
|
|
2022-04-09 21:41:24 +00:00
|
|
|
// If a character cheat is used during Play Mode, replace the player NOW.
|
|
|
|
var setPlayerCharacter bool
|
|
|
|
|
2020-04-07 06:21:17 +00:00
|
|
|
// Cheat codes
|
|
|
|
switch c.Raw {
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatUncapFPS:
|
2020-04-07 06:21:17 +00:00
|
|
|
if fpsDoNotCap {
|
|
|
|
d.Flash("Reset frame rate throttle to factory default FPS")
|
|
|
|
} else {
|
|
|
|
d.Flash("Unleashing as many frames as we can render!")
|
|
|
|
}
|
|
|
|
fpsDoNotCap = !fpsDoNotCap
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatEditDuringPlay:
|
2020-04-07 06:21:17 +00:00
|
|
|
if isPlay {
|
|
|
|
playScene.drawing.Editable = true
|
2022-01-03 00:28:43 +00:00
|
|
|
playScene.SetCheated()
|
2020-04-07 06:21:17 +00:00
|
|
|
d.Flash("Level canvas is now editable. Don't edit and drive!")
|
|
|
|
} else {
|
2021-10-08 01:24:18 +00:00
|
|
|
d.FlashError("Use this cheat in Play Mode to make the level canvas editable.")
|
2020-04-07 06:21:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatScrollDuringPlay:
|
2020-04-07 06:21:17 +00:00
|
|
|
if isPlay {
|
|
|
|
playScene.drawing.Scrollable = true
|
2022-01-03 00:28:43 +00:00
|
|
|
playScene.SetCheated()
|
2020-04-07 06:21:17 +00:00
|
|
|
d.Flash("Level canvas is now scrollable with the arrow keys.")
|
|
|
|
} else {
|
2021-10-08 01:24:18 +00:00
|
|
|
d.FlashError("Use this cheat in Play Mode to make the level scrollable.")
|
2020-04-07 06:21:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatAntigravity:
|
2020-04-07 06:21:17 +00:00
|
|
|
if isPlay {
|
2022-01-03 00:28:43 +00:00
|
|
|
playScene.SetCheated()
|
|
|
|
|
2020-04-07 06:21:17 +00:00
|
|
|
playScene.antigravity = !playScene.antigravity
|
|
|
|
playScene.Player.SetGravity(!playScene.antigravity)
|
|
|
|
|
|
|
|
if playScene.antigravity {
|
|
|
|
d.Flash("Gravity disabled for player character.")
|
|
|
|
} else {
|
|
|
|
d.Flash("Gravity restored for player character.")
|
|
|
|
}
|
|
|
|
} else {
|
2021-10-08 01:24:18 +00:00
|
|
|
d.FlashError("Use this cheat in Play Mode to disable gravity for the player character.")
|
2020-04-07 06:21:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatNoclip:
|
2020-04-07 06:21:17 +00:00
|
|
|
if isPlay {
|
2022-01-03 00:28:43 +00:00
|
|
|
playScene.SetCheated()
|
|
|
|
|
2020-04-07 06:21:17 +00:00
|
|
|
playScene.noclip = !playScene.noclip
|
|
|
|
playScene.Player.SetNoclip(playScene.noclip)
|
|
|
|
|
|
|
|
playScene.antigravity = playScene.noclip
|
|
|
|
playScene.Player.SetGravity(!playScene.antigravity)
|
|
|
|
|
|
|
|
if playScene.noclip {
|
|
|
|
d.Flash("Clipping disabled for player character.")
|
|
|
|
} else {
|
|
|
|
d.Flash("Clipping and gravity restored for player character.")
|
|
|
|
}
|
|
|
|
} else {
|
2021-10-08 01:24:18 +00:00
|
|
|
d.FlashError("Use this cheat in Play Mode to disable clipping for the player character.")
|
2020-04-07 06:21:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatShowAllActors:
|
2021-10-03 04:12:57 +00:00
|
|
|
if isPlay {
|
2022-01-03 00:28:43 +00:00
|
|
|
playScene.SetCheated()
|
2021-10-03 04:12:57 +00:00
|
|
|
for _, actor := range playScene.drawing.Actors() {
|
|
|
|
actor.Show()
|
|
|
|
}
|
|
|
|
d.Flash("All invisible actors made visible.")
|
|
|
|
} else {
|
2021-10-08 01:24:18 +00:00
|
|
|
d.FlashError("Use this cheat in Play Mode to show hidden actors, such as technical doodads.")
|
2021-10-03 04:12:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatGiveKeys:
|
2020-04-07 06:21:17 +00:00
|
|
|
if isPlay {
|
2022-01-03 00:28:43 +00:00
|
|
|
playScene.SetCheated()
|
2020-04-07 06:21:17 +00:00
|
|
|
playScene.Player.AddItem("key-red.doodad", 0)
|
|
|
|
playScene.Player.AddItem("key-blue.doodad", 0)
|
|
|
|
playScene.Player.AddItem("key-green.doodad", 0)
|
|
|
|
playScene.Player.AddItem("key-yellow.doodad", 0)
|
2021-01-04 01:06:33 +00:00
|
|
|
playScene.Player.AddItem("small-key.doodad", 99)
|
2020-04-07 06:21:17 +00:00
|
|
|
d.Flash("Given all keys to the player character.")
|
|
|
|
} else {
|
2021-10-08 01:24:18 +00:00
|
|
|
d.FlashError("Use this cheat in Play Mode to get all colored keys.")
|
2020-04-07 06:21:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatDropItems:
|
2020-04-07 06:21:17 +00:00
|
|
|
if isPlay {
|
2022-01-03 00:28:43 +00:00
|
|
|
playScene.SetCheated()
|
2020-04-07 06:21:17 +00:00
|
|
|
playScene.Player.ClearInventory()
|
|
|
|
d.Flash("Cleared inventory of player character.")
|
|
|
|
} else {
|
2021-10-08 01:24:18 +00:00
|
|
|
d.FlashError("Use this cheat in Play Mode to clear your inventory.")
|
2020-04-07 06:21:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatPlayAsBird:
|
2021-08-16 00:01:18 +00:00
|
|
|
balance.PlayerCharacterDoodad = "bird-red.doodad"
|
2022-04-09 21:41:24 +00:00
|
|
|
setPlayerCharacter = true
|
2021-08-16 00:01:18 +00:00
|
|
|
d.Flash("Set default player character to Bird (red)")
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatPlayAsBoy:
|
2021-08-16 00:01:18 +00:00
|
|
|
balance.PlayerCharacterDoodad = "boy.doodad"
|
2022-04-09 21:41:24 +00:00
|
|
|
setPlayerCharacter = true
|
2021-08-16 00:01:18 +00:00
|
|
|
d.Flash("Set default player character to Boy")
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatPlayAsAzuBlue:
|
2021-08-16 00:01:18 +00:00
|
|
|
balance.PlayerCharacterDoodad = "azu-blu.doodad"
|
2022-04-09 21:41:24 +00:00
|
|
|
setPlayerCharacter = true
|
2021-08-16 00:01:18 +00:00
|
|
|
d.Flash("Set default player character to Blue Azulian")
|
|
|
|
|
2022-01-09 02:27:37 +00:00
|
|
|
case balance.CheatPlayAsThief:
|
2021-08-16 00:01:18 +00:00
|
|
|
balance.PlayerCharacterDoodad = "thief.doodad"
|
2022-04-09 21:41:24 +00:00
|
|
|
setPlayerCharacter = true
|
2021-08-16 00:01:18 +00:00
|
|
|
d.Flash("Set default player character to Thief")
|
|
|
|
|
2022-02-20 19:48:36 +00:00
|
|
|
case balance.CheatPlayAsAnvil:
|
|
|
|
balance.PlayerCharacterDoodad = "anvil.doodad"
|
2022-04-09 21:41:24 +00:00
|
|
|
setPlayerCharacter = true
|
2022-02-20 19:48:36 +00:00
|
|
|
d.Flash("Set default player character to the Anvil")
|
|
|
|
|
2022-01-18 06:02:27 +00:00
|
|
|
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.")
|
|
|
|
}
|
|
|
|
|
2022-03-06 06:44:54 +00:00
|
|
|
case balance.CheatDebugLoadScreen:
|
|
|
|
loadscreen.ShowWithProgress()
|
|
|
|
loadscreen.SetSubtitle("Loading: /dev/null", "Loadscreen testing.")
|
|
|
|
go func() {
|
|
|
|
var i float64
|
|
|
|
for i = 0; i < 100; i++ {
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
loadscreen.SetProgress(i / 100)
|
|
|
|
}
|
|
|
|
loadscreen.Hide()
|
|
|
|
}()
|
|
|
|
|
2022-03-26 20:55:06 +00:00
|
|
|
case balance.CheatUnlockLevels:
|
|
|
|
balance.CheatEnabledUnlockLevels = !balance.CheatEnabledUnlockLevels
|
|
|
|
if balance.CheatEnabledUnlockLevels {
|
|
|
|
d.Flash("All locked Story Mode levels can now be played.")
|
|
|
|
} else {
|
|
|
|
d.Flash("All locked Story Mode levels are again locked.")
|
|
|
|
}
|
|
|
|
|
2020-04-07 06:21:17 +00:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-04-09 21:41:24 +00:00
|
|
|
// If we're setting the player character and in Play Mode, do it.
|
|
|
|
if setPlayerCharacter && isPlay {
|
|
|
|
playScene.SetPlayerCharacter(balance.PlayerCharacterDoodad)
|
|
|
|
}
|
|
|
|
|
2020-04-07 06:21:17 +00:00
|
|
|
return true
|
|
|
|
}
|