User blog:Birdpool/How RTON format stores numbers

So, today, I was digging through the files in the CDN folder in PvZ2, because I got sick of how my strategy in Battlez would win against 4 or 5 opponents then begin to consistently lose, and so I started editing the PlantLevels.rton file to give a boost to all of the Plants I was using, at the level I had them (if they were level 1 then I could theoretically just edit the OBB directly, but...umm...I don't know how to get the .section file data for OBBPatcher...or make the OBB directly editable...uhh) and I naturally found that Pepper-pult had a stat which started at an "unown value" (it was two bytes, which I couldn't understand at the time) and eventually progressed down to a byte 7D (which is 125). I logically concluded that this was the Sun cost since that's the only stat which is a value of 125 at level 15. I then broke out my ol'reliable, which is Ballistic Planet's hacking guide, which has a table of Sun Costs and how they're stored in the game's data.

About half an hour ago, I decided to take a closer look at the values of the two bytes. I noticed that the second byte increases at a rate of 1 every time the proper value increased by 125. 150+ has a second byte value of 1+, 275+ has a second byte value of 2+, 400+ has a second byte value of 3+, 525+ has a second byte value of 4+, etc. The first byte increases at a rate of 25, however there's an anomaly in the costs higher than 125 - 150 is 96 01, not 99 01. Keeping in mind that 25 is 99 00, this doesn't make a whole lot of sense. But then I did a bit more math.

The first byte, when it loops, loses a value of 3 from itself. This means that 150 is coded as 96 01, 275 is coded as 93 02, 400 is coded as 90 03, etc. The second byte, in addition to being a multiple of 125 that needs to be stored, also is multiplied by 3 and added to the first byte! With all this information, we can now calculate Sun costs (or anything we want two bytes for) for any multiple of 25 that we want! :D

I've also rebuilt Ballistic Planet's Sun Cost table, without the list of plants that have the costs, all the way up to and including a value of 1,000: