In my game i'm using a cursor as a weapon, but its a little unrealistic when you can just click an enemy through a wall and kill him,
How would I make this particular cursor work only in say a 100 pixel radius around him.
You could either add a check to on_mouse_click, or to whatever you call to calculate the hit, that compares the target's location to the players. At it's most basic:
if (cTarget.x > player.x-50 && cTarget.x < player.x+50 && cTarget.y > player.y-50 && cTarget.y < player.y+50) {
// Do attack
}
else Display ("Out of range");
Although that's a square checking area. KhrisMUC came up with a circular check (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=13649.msg305918#msg305918), over in the RPG thread (scroll down a few posts for SSH's cleaned up, working version). I used something like it in a coding contest entry (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=25282.msg322062#msg322062), that might also give you some ideas. [/self-promotion]
thanks