To understand the way this system works, I think you're missing the point of a big part of it. It uses what we refer to as a "binary countoff" to transfer exactly the correct amount of minerals each time. A normal trigger can only subtract a set amount of minerals each trigger cycle, but by using multiple triggers right after one another, we can subtract any number within the range of our triggers. A binary countoff works as follows: Every number can be broken down into powers of 2. 32 for example, is 2^5. 33 is 2^5 + 2^0. 63 is 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0 (or 32 + 16 + 8 + 4 + 2 + 1). In terms of triggers, we can have 1 trigger to represent every power of 2. If we place a bunch of them right next to each other, then we can subtract or add any number between the number of binary triggers we have (for example, if we had 5 triggers like in the example above, we could add or subtract any number between 1 and 63, since that's the max of 2^5 + 2^4 ... 2^0). More importantly, we can add or subtract them in 1 trigger cycle, so after the last subtraction trigger runs, the values are in the correct death counts.
Here is a better explaination about binary countoffs:
http://www.staredit.net/wiki/Binary_CountoffsWe use this binary countoff not to make it so they mine 5 minerals, but to detect IF they've mined the minerals, and how much they've mined. This is done by subtracting all their current minerals, and comparing it to the amount of minerals they had the last time the triggers ran. The difference is how much they've mined.
Once we know how much they've mined, we can give back the amount they had the previous trigger cycle first, then give back only 5/8 minerals of the difference that we've calculated. Hope this helps.
Edit:
Just an overview of the process:
1). Figure out how many minerals the player has (by using binary countoff #1)
2). Copy that number to another death count for storage and use later (using another binary countoff)
3). Subtract the amount they had last trigger cycle from the amount they have now (you guessed it - a binary countoff)
4). Give back the amount they had last trigger cycle (binary countoff again)
5). Give back 5/8 of the difference that we found in step 3. (using a binary countoff again, but this time you have to factor in the 5/8 part)
Post has been edited 2 time(s), last time on Aug 11 2009, 9:42 pm by Vrael.
None.