[Question] Ranged NPCs

Hi all, I have a question regarding creating custom npcs.

See, I have a hunter-like npc which attacks on range, and has all kinds of ranged abilities.

But as soon as he goes in to combat he slowly, step by step, comes closer to his target, and starts whacking him with his melee weapons.

My question is: Is there a way to make the npc stay at range of his target, unless the target approaches him?

Thanks in advance for your answers~

Edit: After some testing I found out that its the ranged attacks that are not working. I managed to use smart scripts to keep it in place during a fight. But he doesn’t use his ranged attacks, he uses one spell: Steady Shot, which I gave him. But it’s supposed to do 150% weapon damage. Instead it does 1 damage. I can only assume that there’s something wrong with the ranged attacks, but I don’t know what.

In creature_template I wrote the following.

rangeattacktime: 2100

minrangedmg: 1983

maxrangedmg: 2320

rangedattackpower: 4982

So it should do some ranged damage. Did I forget something that allows him to attack ranged?

Is this about world of warcraft?