I'm entirely self-taught at CTF, and I use counters to make a lot of stuff work in my games. Are there better ways to do:
1. Randomness. If I want something to happen 25% of the time, I create a counter that counts by 1 every 1 millisecond, and if the counter=4 reset to 0. When the trigger occurs, if the counter displays the number 1, the action happens.
2. Boolean values. The counter named "NPC has given you the diamond" begins at 0. When the NPC gives you the diamond, the counter changes to 1, and then I can use the status of the counter in my code to prevent actions from occurring until you've received the diamond.
3. Cooldown. If I want to limit a gun's firing speed, I create a counter called "AK-47 cooldown" with a minimum value of 0. When the player fires, the counter sets itself to 1 and subtracts 1 every second. The player can only fire when the counter is at 0. This means the player can only fire once a second. I also use this a lot if I need a delay between two things so they don't happen exactly after each other, for example granting the player 1 second of godframes with a "player just took damage" counter.
In addition to the typical use of counters (storing values), I wind up with a lot of hidden counters by the end of a project. Are any of these features doable some other way that might be easier than keeping track of all these counters?