mob
proc
shoot() //name of proc
usr.AmmoCheck()
var/obj/H = new/obj/bullet //set the bullet to H (H is the bullet)
if(src.fired == 0) //if the usred fired is 0 (keeps the usr from holding down 5 for lots of shots)
src.fired = 1 //makes fired equal 1
spawn(15) //waits 1.5 seconds before going to the code underneath it
src.fired = 0 //makes the player's fired 0 so the player can shoot again
H.dir = src.dir //the bullets(H) direction equals the player's direction
H.loc = src.loc //the bullets(H) location equals the player's location
while(H) //while the bullet is still "alive"
step(H,H.dir) //H steps towards H's direction
var/turf/T = H.loc //for the turf that is in H's location
if(T.density == 1) //if that turfs density = 1 (ex: a wall)
del(H) //deletes the bullet
break //breaks out of the while loop
for(var/mob/M as mob in T) //for and M in that turf
if(M == src) //if that M is the person who fired, it continues as if nothing was there
continue
src<<"You shot [M]!" //says you shot M
M.NPCDeathCheck()
M.DeathCheck()
M.health -= 20
src.ammo -= 1
del(H) //deletes the bullet
sleep(1) //sleeps 1/10th of second before re-doing the loop
mob
proc
DeathCheck()
if(usr.health <= 0)
usr << "You have died"
world << "[usr] has died"
usr.loc=locate(0,0,0)
sleep(50)
usr.loc=locate(2,2,1)
else
..()
mob
proc
NPCDeathCheck(mob/M)
if(usr.health <= 0)
usr << "You have died"
world << "[usr] has died"
usr.loc=locate(0,0,0)
sleep(50)
usr.loc=locate(2,2,1)
else
..()
mob
proc
AmmoCheck()
if(usr.ammo <= 0)
usr << "*Click Click* You are out of ammo!"
..()
Problem description: The ammo thing still lets you shoot! Help! I'll give you credit if you tell me how to cancel it!
Anyways what I would do is replace the ..() with
return 0
and then replace the original call with
This tells it that if there isn't any ammo, return false, which is evaluated at the call and the program decides the player can't shoot, so skips the rest of the shoot function
Hope that helps.