How to prevent cheating with Gamecih?

前端 未结 10 1536
孤独总比滥情好
孤独总比滥情好 2021-01-31 12:07

Background

I\'ve had problems for quite a while now with players cheating in my android game. For a strict single-player game this wouldn\'t be a big is

相关标签:
10条回答
  • 2021-01-31 12:29

    In the Pokemon games, they used DMA. You could get a similar effect by having a timer go off and trigger an update of all values while the game is paused for very short time. The update would add some random amount to all variables (including the one that you subtract from to get individual values). You can also try having values stored in a large array and change the starting position. Instead of an absolute pointer like GameState[121], you'd have something like GameState[121+StartingPosition] and just combine the value-incrementor with a location randomizer. Modular arithmetic is your friend, in both cases. Be wary of overflowing the array and off-by-one bugs. A buffer overrun would not be good. ;)

    If this was a Flash or Java app: Sadly, using memory management to quickly remap the position in RAM of values is not as convenient as in a native binary like the Gameboy Advance uses. Copying all variables to a second set, in a random order, then deleting and garbage-collecting the original values would probably make your game run slow as heck.

    0 讨论(0)
  • 2021-01-31 12:33

    The people who are good at cheating games read these forums too, and they know all your little secrets.

    There is no solid way to prevent people from cheating a game that stores important variables locally. A game must keep these variables on the server. If these variables are not kept on the server, there will always be someone that can hack your game.

    0 讨论(0)
  • 2021-01-31 12:37

    You can check periodically if your value has changed when it was not supposed to.

    For example, you can store in a separate hidden flag the fact that the health value has changed. If your check method does detect a change in the value, and the flag is not set, then you can tell that the change was illegal.

    For example :

    void incrementHealth(int amount) {
        health = health + amout;
        hiddenCheck.hasChanged = true;
        }
    

    and in a separate method which must be invoked periodically :

    void checkHealth() {
        if (hiddenCheck.hasChanged) {
            // change is valid
            hiddenCheck.hasChanged = false;
            hiddenCheck.lastKnownValue = health;
            } else {
                if (hiddenCheck.lastKnownValue != health) {
                    // An illegal change has occured ! Punish the hacker !
                    }
                }
            }
       }
    
    0 讨论(0)
  • 2021-01-31 12:42

    Calculate your stats dynamically from a stored value.

    private double getSaltedSqrt(int i){
        return Math.sqrt(i)+1337;
    }
    
    private int getTrueValue(double i){
        return (i-1337)*(i-1337);
    }
    

    This way, no regular-brained human will be able to find your values from RAM ever. Somebody with 100 health will have a health value of 1347.0

    If somebody deals 10 damage to that player, you just have to call:

    currentHealth = getSaltedSqrt(getTrueValue(currentHealth)-damage);
    

    However, the most secure way to do this, is to implement all those changes via server.

    0 讨论(0)
提交回复
热议问题