Detect if cheats are on

Detect if cheats are on

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Detect if cheats are on

Post by Jools »

I want to make my games detect if cheatmode has been enabled, and in case it is maybe not send any replays to the spring replays site. Is this possible?

I know there's one Spring.IsCheatingEnabled function in synced read, but there must be a better way than to process that in each gameframe. Is there a specific callin that can be used to catch that cheating has been enabled?

Or is spads aware if this somehow?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Detect if cheats are on

Post by gajop »

Don't think there is a callin. If you really want you could make your own in your widgethandler.
Don't know anything about spads.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Detect if cheats are on

Post by Silentwings »

Just check Spring.IsCheatingEnabled when you need to know it? (In your case, at game over)
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Detect if cheats are on

Post by Jools »

What if someone enables cheats, gives 100 krogs and then disables cheats and continues to play?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Detect if cheats are on

Post by gajop »

I don't see why you can't just do:

Code: Select all

local cheatingWasEnabled = false
function gadget:GameFrame()
    cheatingWasEnabled = cheatingWasEnabled or Spring.IsCheatingEnabled()
end
And then use it when you need to?
Stop premature optimization.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Detect if cheats are on

Post by Google_Frog »

What if they cheat only while the game is paused? Then a game frame check would not detect cheats.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Detect if cheats are on

Post by Jools »

I thought of checking if cheats are enabled after each time you press return. Is it possible to enable cheats without return? Maybe with new uikeys.txt it is with a keystroke.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Detect if cheats are on

Post by Silentwings »

You can send a /cheat from lua, of course whether it works depends on if you have permission to enable cheats.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Detect if cheats are on

Post by Jools »

So the most fool-proof way would be to check this in gadget:Update(), then send to synced via LuaRulesMsg?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Detect if cheats are on

Post by gajop »

Hm, didn't know you could do that when paused, i thought all commands would happen in the next frame, but guess not.
I'm not sure there is a safe way to do that then, the player could always do /cheat /give all /cheat in sequence by using one widget.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Detect if cheats are on

Post by jK »

Jools wrote:I know there's one Spring.IsCheatingEnabled function in synced read, but there must be a better way than to process that in each gameframe. Is there a specific callin that can be used to catch that cheating has been enabled?
Why check them in a fixed interval at all? You should ALWAYS check when you DO something.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Detect if cheats are on

Post by Jools »

But in this case, the action is done after the game (upload replay, declare winner etc) and it is affected by what is done during the game. As others pointed out.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Detect if cheats are on

Post by CarRepairer »

This sounds like a valid feature request. Perhaps if nothing comes of it, you can solve it on the autohost layer by disallowing cheating unless the user enables an option. If the option is enabled, the replay is not uploaded. It's not a perfect solution, but probably less stressful than dealing with polling spring in the gadget level.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Detect if cheats are on

Post by jK »

In that case I would say catch the `/cheat` chat command. Problem is that, in contrast to mouse & key handling, Lua is not the first one who receives those. So make a feature request to make its handling consistent to the others.
User avatar
bibim
Lobby Developer
Posts: 959
Joined: 06 Dec 2007, 11:12

Re: Detect if cheats are on

Post by bibim »

Jools wrote:Or is spads aware if this somehow?
SPADS isn't directly aware of the cheat mode. But if you consider that the !cheat command is always used to enable cheats, then it can easily be made aware of it using a plugin. This is done in SPADS ZeroK plugin for example to prevent reporting games where cheats have been enabled:

Code: Select all

sub new {
  my $class=shift;
  my $self = { isCheating => 0,
  [...]
}

sub onSpringStart {
  my $self=shift;
  $self->{isCheating}=0;
  [...]
}

sub postSpadsCommand {
  my ($self,$command,undef,undef,undef,$commandResult)=@_;
  $self->{isCheating}=1 if($command eq 'cheat' && (! defined $commandResult || $commandResult ne '0'));
}

There exist cases where cheats can be enabled without using the !cheat command (using "!send /cheat ..." or through a plugin for example), but they are negligible in my opinion since they require special access to the autohost.
Post Reply

Return to “Game Development”