RPG Advice Needed

Ok so I have a little project Ive been working on for a little while. Ive been using sprites from zelda just so I can set up the basic engine and Ill move in all my own animations and graphics later so dont think Im just a lazy thief. It may not be the best plan but its how Ive decided to do it. Anyways the main problems Ive been having is with the AI. I tried making something where the enemy would be patroling and if you came within a certain range he would chase you and granted he got close enough he would hurt you. There were bugs and plus I just didnt really like the type AI so I was wondering if anyone coudld give some advice as to anothing type of AI that might work a little bit better in my project and maybe some ideas of code for it or even just a better way to go about doing what I was doing. Also if anyone has any comments on areas that need improvement because I know its messy or just any other ideas of things to add. You know just tell me what you think it would be greatly appreciated.