Heres the code:
mob/verb/Melee()
set hidden=1
if(usr.attackon==1)
usr.turnattkoff=1
Melee_Attack()
usr<<"Auto attack off."
else
Melee_Attack()
mob
var
attackon
turnattkoff
attackmd
weapondelay=30
attackp
target
weapdmgdisplay
weapdmgdisplay2
hp
canbeattacked
strength
weapdmg
proc
Melee_Attack()
if(usr.turnattkoff==1)
if(usr.attackon==0)
usr.turnattkoff=0
usr.attackmd=0
else
if(!usr.target)
usr<<"You must select a target first."
return 0
else
if(usr.target:canbeattacked==0)
usr<<"This target cannot be attacked."
else
if(usr.target in oview(1))
usr.attackon=1
if(usr.attackmd==1)
else
usr<<"Auto attack on."
usr.attackmd=1
usr.attackp=usr.strength+usr.weapdmg
usr.target:hp-=usr.attackp
usr<<"You [usr.weapdmgdisplay] [usr.target:name] for [usr.attackp]."
usr.target<<"[usr] [usr.weapdmgdisplay2] you for [usr.attackp]."
if(usr.target:hp<=0)
del(usr.target)
usr.attackon=0
usr<<"Auto attack off."
return 0
else
sleep(usr.weapondelay)
if(usr.turnattkoff==1)
usr.attackon=0
Melee_Attack()
else
usr.attackon=1
if(usr.attackmd==1)
else
usr<<"Auto attack on."
usr.attackmd=1
usr<<"[usr.target:name] is out of range."
sleep(usr.weapondelay)
if(usr.turnattkoff==1)
usr.attackon=0
Melee_Attack()