ID:144752
 
Code:
mob/var
rand

client.Click(mob/M in view(1))
usr.rand = rand(1,2)
if(usr.rand == 1)
view() <<"<B><font size = 1><font color = aqua>*[usr] punches [M] in the stomach!*"
M.health -= ((usr.str/M.end))*2
if(usr.rand == 2)
..()


Problem description:Well, when I click on myself, it attacks myself, when I click on the grass under me, it attacks the grass, whats the problem?

There's a few things wrong with it, firstly, you don't need the 'rand' variable, you can just use prob() or rand() inside of the if() statement.

Secondly you're using client/Click() when you should be using mob/Click(), that way you won't be calling the proc everytime a player clicks on anything.

Thirdly, you're never checking to see if the attacker and the victim are the same.

mob/Click()
if(src == usr) return // Prevent self-attacking.
if(prob(50)) // 50% chance of success.
view() << "<b><font size=1 color=aqua>*[usr] punches [src] in the stomach!*</b></font>"
src.health -= (usr.str/M.end)*2


That should give the same effect, you'd probably want to throw some kind of death checking function below the line where you take health, just remember in mob/Click() 'src' is the one being clicked and 'usr' is the one clicking. If you want you can do something like:
mob/Click()
var
mob
clicker = usr
clickee = src


And use 'clicker' in place of the one clicking and 'clickee' in place of the one being clicked.