fs2open.github.com icon indicating copy to clipboard operation
fs2open.github.com copied to clipboard

Cheat framework allowing for custom cheats, sexp for cheat used and On Cheat lua hook

Open Kiloku opened this issue 3 years ago • 2 comments

I saw #2351 and went a bit overboard. Blame covid, I got bored on sick leave.

This brings a new table type (cheats.tbl and *-cht.tbm). Adding a ship to spawn is optional, as a modder might want to just use the Sexp or lua hook to check if the player used the cheat.

The table looks like this:

#CUSTOM CHEATS

$Cheat:
	+Code: puppyy
	+Message: It followed me home
	+SpawnShip: 
		+Name: Puppy
		+Class: SJ Sathanas
$Cheat:
	+Code: foo
	+Message: bar
	+RequireCheats: YES

#END

If a cheat has RequireCheats as true, then the player needs to enable cheats first, by typing www.freespace2.com (Now that I think about it, maybe I should add the option of using another string for that too...) The table parsing checks if the ship class exists, and pops up a warning if it doesn't, but allows the game to continue.

I had to mess with the original cheat code a bit, the biggest change being that now the Bravos was moved out of that list into the new framework. All original cheat codes still function as usual, as far as I can tell.

Kiloku avatar Jun 11 '22 02:06 Kiloku

A quick re-read makes me realize that his needs a few cleanups. Bad variable names, commented out code from previous attempts that should just be removed, probably more. I'll change it into a draft for now.

Kiloku avatar Jul 04 '22 20:07 Kiloku

Requested by MediaVPs to add the HLP Bravos!

Kiloku avatar Sep 16 '22 23:09 Kiloku