nvs / gem

Gem TD+: A Warcraft III Tower Defense
https://discord.gg/PxNNp77
26 stars 2 forks source link

Detect cheat codes in single player #374

Closed nvs closed 5 years ago

nvs commented 5 years ago

Why does this matter? I do not want to disallow people from playing the map in single player. I do, however, want to be able to quickly identify the usage of a cheat code without having to pay attention during every second of a replay. If I can detect any cheat code, then I can display an indicator on the board.

Research shows that detecting of chat commands used for cheat codes in single player is not possible.

There are some natives that may be of interest, but I need to figure out what they do. These merely return whether or not the cheat codes to disable victory or defeat have been used.

There are also the following map flags. Testing will need to be done to see if they even work. They do nothing.

nvs commented 5 years ago

Okay, so it seems the only option is to detect the side effects of the cheat codes. First, we need to identify the cheat codes that would be problematic in Gem (or could be in the future):

Resource Gain

This one is pretty simple to detect. Check if the Gem not in play player's gold or lumber goes above 0. If so, one of the resource cheats was used.

Fast Building

Instruct a unit to build a long duration building somewhere. Every so often reset the build status. If it finishes, then fast building was enabled.

Food Limit

This does not currently apply to Gem. It may, however, in the future.

One-hit Kills

Create a two units, one being a damage source and the other a damage sink. The sink has a modest health regeneration that out paces the source. If the sink dies, the cheat was used.

Infinite Mana

Create a unit. Order it to cast a spell it does not have the mana to afford. It this spell casts, the cheat was used.

Map Reveal

Does not currently apply to Gem. This will probably never change as cheats are only usable in single player.