Altered the code to use arrays (also encapsulated some stuff in function...

Altered the code to use arrays (also encapsulated some stuff in functions). I did not change everything I thought was awkward (for example it still uses the name CombatAI for a file that has very little to do with AI)