Page 1 of 1

Adding cheat codes

Posted: Sun May 23, 2021 12:45 pm
by Korni27
Can you add your own cheat godes to GZDoom? If yes then how?

Re: Adding cheat codes

Posted: Tue Jun 01, 2021 8:38 am
by Player701
As far as I know, it is not possible to add, change or remove any of the "classic" cheat codes (like IDDQD, IDKFA etc). You also cannot add new console commands, but you can leverage stuff like network events to implement a cheat-like command that would have the form of netevent <mycommand>. You can even check in your handler if cheating is currently disabled and refuse to run the command if that's the case. For example:

Code: Select all

class TestHandler : EventHandler
{
    override void NetworkProcess(ConsoleEvent e)
    {
        if (e.Name ~== "mycheat")
        {
            if ((G_SkillPropertyInt(SKILLP_DisableCheats) || netgame || deathmatch) && (!sv_cheats))
            {
                if (e.Player == consoleplayer)
                {
                    // print this message for the local player only
                    Console.Printf("sv_cheats must be true to enable this command.");
                }
            }
            else
            {
                // TODO: Do something
            }
        }
    }
}
Code to check for cheat mode taken from here.

Upd: You can also use KEYCONF to create an alias for your netevent command, e.g.

Code: Select all

alias mycheat "netevent mycheat"
So, technically, it's almost as a new console command, so what I said about not being able to add new ones wasn't entirely true.

Re: Adding cheat codes

Posted: Thu Jun 03, 2021 2:13 am
by ramon.dexter
If I can add my two cents, I've achieved this with ACS. I'm following the quake paradigm "impulse #", but instead of 'impulse', I use 'puke' and simply call numbered scripts with required content.

Not the full "cheat" like the IDDQD, but it works.

Re: Adding cheat codes

Posted: Thu Jun 03, 2021 5:43 am
by MartinHowe
I forget the syntax off the top of my head, but you can also include a basic check for cheating enabled as part of the alias.