pistol
icon_state = "pistol"
aboutthingy = "A standard 9mm pistol."
var/fuel = 8
Harm(var/mob/Q)
if(Q in view(1))
sleep(20)
var/shot = (rand(1,4))
if(shot == 1)
view(8,Q)<<"<b>[usr] tried to pistol whip but [Q] dodged the attack!"
var/lol = Q:loc
for(var/mob/M in lol)
M:hp -= 0
M:Health()
if(shot > 1)
view(8,Q)<<"<b><font color = red>[usr] has pistol whipped [Q]!"
var/lol = Q:loc
for(var/mob/M in lol)
M:hp -= 25
M:Health()
if(Q in view (2))
if(fuel > 0)
var/shot = (rand(1,3))
if(shot == 1)
fuel --
view(8,Q)<<"<b>[usr] shot [Q] with [src] but missed!"
var/lol = Q:loc
for(var/mob/M in lol)
M:hp -= 0
M:Health()
sleep(30)
if(shot > 1)
fuel --
view(8,Q)<<"<b><font color = red>[usr] has shot [Q] with [src]!"
var/lol = Q:loc
var/lol2 = new /obj/Misc/bullet(usr.loc)
while(get_dist(lol,lol2) > 0)
sleep(1)
step_towards(lol2,lol)
del(lol2)
for(var/mob/M in lol)
M:hp -= 35
M:Health()
sleep(30)
else
usr<<"<b>*click*"
if(Q in view (3,4))
if(fuel > 0)
var/shot = (rand(1,2))
if(shot == 1)
fuel --
view(8,Q)<<"<b>[usr] shot [Q] with [src] but missed!"
var/lol = Q:loc
for(var/mob/M in lol)
M:hp -= 0
M:Health()
sleep(30)
if(shot == 2)
fuel --
view(8,Q)<<"<b><font color = red>[usr] has shot [Q] with [src]!"
var/lol = Q:loc
var/lol2 = new /obj/Misc/bullet(usr.loc)
while(get_dist(lol,lol2) > 0)
sleep(1)
step_towards(lol2,lol)
del(lol2)
for(var/mob/M in lol)
M:hp -= 35
M:Health()
sleep(30)
else
usr<<"<b>*click*"
Problem description:
This is bothering me, for some reason the different distances isn't working. You can only hit someone 1 tile away and when you do that you pistol whip AND shoot them, which isn't supposed to happen. Basically I just wanted to make it so that it pistol whips one tile away, and shoots after that losing accuracy farther away. The Q variable is the taget.
1) Why are you doing atom:proc/variable? Do atom.proc/variable. An example would be M:Health() should become M.Health()
2) What is the point in doing M:hp -= 0?
3) Don't use usr in a proc.
4) Don't do if(var==1) or if(var==0) for a boolean variable (a variable that can only be 1 or 0). Instead do if(var) or if(!var).