Adding cheat codes

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Adding cheat codes

Postby Korni27 » Sun May 23, 2021 12:45 pm

Can you add your own cheat godes to GZDoom? If yes then how?
User avatar
Korni27
 
Joined: 31 Jan 2021
Location: Poland

Re: Adding cheat codes

Postby Player701 » Tue Jun 01, 2021 8:38 am

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 allExpand view
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 allExpand view
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.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Adding cheat codes

Postby ramon.dexter » Thu Jun 03, 2021 2:13 am

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.
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Adding cheat codes

Postby MartinHowe » Thu Jun 03, 2021 5:43 am

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.
User avatar
MartinHowe
In space, no-one can hear you KILL an ALIEN
 
Joined: 11 Aug 2003
Location: Waveney, United Kingdom


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests