Added terrain funcs and more support to AIs