OSP Code SP Anti-Cheat System

Users who are viewing this thread

Pumpkin Lord

Greetings Forge,

There should be like ten different ways to achieve the same goal. And, this is just one of those. I took a different approach for each existing cheat in WB and still doing the same. These codes will be useful for mods which aims hardcore gaming experience, hopefully.


I am going to update this thread as soon as I bury another cheat beneath the ground till all is done.


Here are the currently available anti-cheat systems

Cheat: Kills any random agent in any mission.
Solution: Player agent dies even before player can kill one of those agents.

Code:
common_anti_cheat_kill = (
	0,0,0,
	[       (this_or_next|key_is_down, key_right_control),
		(key_is_down, key_left_control),
                (key_clicked, key_f4),
		],
	[       (get_player_agent_no, ":playeragent"),
			 (agent_is_alive,":playeragent"),
			 (display_message, "@Cheating is bad, ya know."),	 
			 (try_begin),
				 (store_agent_hit_points,":hp",":playeragent",1),
				 (val_sub,":hp",100),
				 (try_begin),
					 (le, ":hp", 0),
					 (agent_set_hit_points,":playeragent",0,0),
				 (try_end),				
				 (play_sound,"snd_man_die"),
				 (agent_deliver_damage_to_agent,":playeragent",":playeragent"),
                                 (finish_mission), 
			(try_end),
		 (try_end),
		]
 )

Cheat: Refilling HP.
Solution: Player agent dies instantly whenever the cheat is launched.

Code:
common_anti_cheat_heal = (
	0,0,0,
	[       (this_or_next|key_is_down, key_right_control),
		(key_is_down, key_left_control),
                (key_clicked, key_h),
		],
	[       (get_player_agent_no, ":playeragent"),
			 (agent_is_alive,":playeragent"),
			 (display_message, "@Cheating is bad, ya know."),	 
			 (try_begin),
				 (store_agent_hit_points,":hp",":playeragent",1),
				 (val_sub,":hp",100),
				 (try_begin),
					 (le, ":hp", 0),
					 (agent_set_hit_points,":playeragent",0,0),
				 (try_end),				
				 (play_sound,"snd_man_die"),
				 (agent_deliver_damage_to_agent,":playeragent",":playeragent"), 
                                 (finish_mission),
			(try_end),
		 (try_end),
		]
 )

Regards,
 
You will make many cheating players angry, and they may have a point.

You can put all the cheat key combinations in the condition block of a single trigger, and always deal the same punishment.

If you are doing this for fun, to troll the cheaters, make funny stuff happen, e.g. every ctrl-f4 spawns an enemy ubertroop, ctrl-h sets your health to 1, etc.
 
Nah, make Ctrl+F4 also kill a friendly troop.
You can also try to deal with the character/inventory cheats from the tableau code, although I have no idea if it's run continuously or only when clicked or the inventory updates.
 
The teleport cheat (CTRL + Mouse on the world map) can be countered with a trigger that checks minimum distance between the current and the past player position, and if it's more than normally possible, brings punishment to the player. Character import/export can also be hindered in a similar manner, but I wouldn't recommend it for a number of reasons.
To be honest though, I don't approve much of anti-cheat systems, as I cheat every time I play the game. But I play it only for testing the new stuff I've put in, so my point of view is biased. :smile:
 
Damn,  I cannot find a damn way to revert the player back to where he was before he teleports to anywhere. What I so far tried to do;

Code:
(try_begin),
                   (this_or_next|key_is_down, key_right_control),
                   (key_is_down, key_left_control),
                   (party_get_position, pos1, "p_main_party"),
                 (else_try),
                   (this_or_next|key_is_down, key_right_control),
                   (key_is_down, key_left_control),
                   (key_clicked, key_left_mouse_button),         
		   (party_set_position, "p_main_party", pos1),
                   (display_message, "@Cheating is bad, ya know."),
                 (try_end), 

I need to find a way to store the pos where party is before he teleports. Something to do with storing current hour but not sure.

@Mad, Brytenwalda or PoP-like mods were aiming for a hardcore game-style and even though it is a choice of players whether they want to go on with or without cheats, some mods may not want to give such an option. No, purpose here is not to troll. Just giving penalties of each cheat so players cannot use them or face with unbearable consequences.

@Somebody, thank you for your report. Updated the code now with this.

Code:
common_anti_cheat_kill = (
	0,0,0,
	[       (this_or_next|key_is_down, key_right_control),
		(key_is_down, key_left_control),
                (key_clicked, key_f4),
		],
	[       (get_player_agent_no, ":playeragent"),
			 (agent_is_alive,":playeragent"),
			 (display_message, "@Cheating is bad, ya know."),	 
			 (try_begin),
				 (store_agent_hit_points,":hp",":playeragent",1),
				 (val_sub,":hp",100),
				 (try_begin),
					 (le, ":hp", 0),
					 (agent_set_hit_points,":playeragent",0,0),
				 (try_end),				
				 (play_sound,"snd_man_die"),
				 (agent_deliver_damage_to_agent,":playeragent",":playeragent"),
                                 (finish_mission), 
			(try_end),
		 (try_end),
		]
 )
 
Seeing as the code prior to (else_try) has less conditions than afterward, the second part might not be executed.  Correct if I'm wrong though, I'm not as confident in my coding knowledge as I'd like to be.
Code:
(try_begin),
                   (this_or_next|key_is_down, key_right_control),
                   (key_is_down, key_left_control),
                   (neg|key_is_down, key_left_mouse_button), ## You might want to add something like this.
                   (party_get_position, pos1, "p_main_party"),
                 (else_try),
                   (this_or_next|key_is_down, key_right_control),
                   (key_is_down, key_left_control),
                   (key_clicked, key_left_mouse_button),         
		   (party_set_position, "p_main_party", pos1),
                   (display_message, "@Cheating is bad, ya know."),
                 (try_end), 
Or better yet, maybe you could try exchanging places of the code before and after the (else_try).
 
Im not sure about the trigger orders of the game, but the way you are doing it, there will be one of the either scenarios and both cases the script wont work.

1) The script runs before the party is transported. The party is set to it's original position (doesn't change), then the game moves the party to the place clicked - the person still successfully cheats.
2) The script runs after the party is transported. pos1 is where the party after transporting - hence the party still ends up at the place clicked - ie successful cheat again.

Instead, something like what Lumos said could work:

Code:
(0.1, 0, 0, [],
[
   # store player party position to P1

   # (try_begin)
   #     check if (get_distance_between_pos, P1, P2) > A, where A is unreasonably high
   #     move party to P2
   # (try_end)
   
   # store player party position to P2
])

Or following your method:
Code:
(try_begin),
	(this_or_next|key_is_down, key_right_control),
	(key_is_down, key_left_control),
	(key_is_down, key_left_mouse_button),
	(party_set_position, "p_main_party", pos1),
(else_try),
	(party_get_position, pos25, "p_main_party"), # Using a less used pos number, so less chance of being overwritten between triggers
(try_end), 
 
SonKidd said:
Im not sure about the trigger orders of the game, but the way you are doing it, there will be one of the either scenarios and both cases the script wont work.

1) The script runs before the party is transported. The party is set to it's original position (doesn't change), then the game moves the party to the place clicked - the person still successfully cheats.
2) The script runs after the party is transported. pos1 is where the party after transporting - hence the party still ends up at the place clicked - ie successful cheat again.

Instead, something like what Lumos said could work:

Code:
(0.1, 0, 0, [],
[
   # store player party position to P1

   # (try_begin)
   #     check if (get_distance_between_pos, P1, P2) > A, where A is unreasonably high
   #     move party to P2
   # (try_end)
   
   # store player party position to P2
])

Or following your method:
Code:
(try_begin),
	(this_or_next|key_is_down, key_right_control),
	(key_is_down, key_left_control),
	(key_is_down, key_left_mouse_button),
	(party_set_position, "p_main_party", pos1),
(else_try),
	(party_get_position, pos25, "p_main_party"), # Using a less used pos number, so less chance of being overwritten between triggers
(try_end), 

It's safer to save X,Y,Z of last position into global variable. Pos1 and Pos2 could be used in mission templates and presentations.
 
So, pos25 stores the position where player is teleported from. Right?
 
Yeah, on the map you should really only need x and y coordinates, although we can easily reserve another register in header_commons. I have no idea if the rearm/delay intervals work or not, but you can work something like this
Code:
(0, 0.1, 0, [(key_clicked, key_left_mouse_button),
   # store player party position to pos_party immediately
   (party_get_position, pos_party, "p_main_party"),
   # assuming cheat takes place already before any triggers
],
#0.1 second later, party moved
[
  (get_distance_between_positions, ":distance", pos_party, pos_old),
  (try_begin), #whatever arbitrary map units, fixed point needed?
    (ge, ":distance", 123),
    #move back to pos_old
    (party_set_position, "p_main_party", pos_old),
    (val_div, "$g_player_luck", 2, #or some fitting punishment
    (party_set_bandit_attraction, "p_main_party", 100),
    (party_get_morale, ":morale", "p_main_party"),
    (val_div, ":morale", 2),
    (party_set_morale, "p_main_party", ":morale"),
  (else_try),
    (copy_position, pos_old, pos_party),
  (try_end),
])
 
Can you use local variables in the consequence block  that are declared in the conditions block?
 
Back
Top Bottom