I've recently had someone (who is actually trying to learn and doesn't just want the end result) ask for some help with creating fairly simple AoBs. I'm all about helping those who are willing to learn, so I though I'd share what I've told him, along with what I've found and how I got there. (I may repeat myself because I'm copying/pasting information from the PMs.) A bunch of years back, it was common for people to explain how they found their hacks, the steps they took, and their thought process. I'd like to see that happen again! I know I learned a lot just by reading through some of those posts.
Just a few notes, remember not every game is programmed the same and there are multiple ways to go about doing the same thing. For example, adding or subtracting money.
You could simply do this:
buying: myMoney = myMoney - costOfThing
selling: myMoney = myMoney + costOfThing
Fairly straight forward, right? To add money instead of subtracting it, all you would do is change the subtract opcode to the add opcode.
A different way of achieving the same result would be to do this (which is how this game does it):
buying: myMoney = addMoney(-int(costOfThing)
selling: myMoney = addMoney(int(costOfThing)
This method adds whatever number is passed to the addMoney function. If it's a positive number, it adds, if it's a negative number, it'll subtract. To add money when buying, all you would do is NOP the negate (see below).
Now, on to the advice....
Try different searches for key words related to what you're trying to do until you find what the programmer has used. For example, if it's money, search for things like: money, cash, gold, coin, etc. Another approach is to search for things like: buy, purchase, upgrade. Then you just have to find the function that is called when you actually buy something, then essentially change the subtract to add. If it's health, search for things like: xp, exp, health, life, hit, damage, or die. I've seen games that use languages other than english, which is alway fun. So watch for that as well.
Make sure that if you're using sothink to check the "ignore case" checkbox and your clicking the "Search All AS"* button. That way, if the function is called "addCoins", searching for "coin" will return that function. The initial search is a pain in the ass when they use the variable "xp" for health, because your inital search is going to bring back a LOT of irrelevant information. Keep at it, and follow the code!
* - this will sometimes crash sothink if the game (or parts) is encrypted (like it does with this one). If this happens, you'll have to manually poke around or use a different decompiler like JPEX, Trillix, etc. There are a few out there.
I took a quick peek and it looks like this game may be encrypted in a bunch of places. I did however find a way to add money when purchasing (and possibly upgrading, I haven't played long enough to unlock that feature). Here's an explanation.
Open the swf and go to: Action > main > Tower
I noticed the variable "cost", so I searched within the Tower code for "cost". It's in there a lot so I just quickly looked at the code and functions that contained it and noticed there were 3 lines that had "this.game.addMoney(-int([various maths])". The addMoney function adds whatever number is passed to it to your current money. If it is passed a positive number, it adds the money, if (like in the 3 examples with -int) it is passed a negative number, it subtracts it.
Now go into "Raw Data" view and search for "addMoney". You will find 5 instances. The 1st and 5th results are actually adding money so we'll ignore those, but the 2nd, 3rd, and 4th are subtracting. To make the "Add money when buying and upgrading towers" hack, all you'd have to do is NOP (opcode 02) the _as3_negate code.
BEFORE:
//46 04 01
_as3_callproperty int(param count:1)
//90
_as3_negate
AFTER:
//46 04 01
_as3_callproperty int(param count:1)
//02
_as3_negate
So to apply this hack, open up Cheat Engine, attach it to the correct process and search for (there should be 3 results):
46 04 01 90
And replace all 3 with:
46 04 01 02
I hope this post helps some of you newer folks out there looking to learn how to create AoBs. We have plenty of tutorials and guides on the site, make sure you read em!