ID:149079
 
The following code compiles correctly and mostly works, except that it doesn't cancel the rest of the verb.
mob/verb/fire()
usr.AmmoCheck()
fireprojectile(/obj/projectile/arrow,src)
usr.Ammunition -= 1

mob/verb/LAW()
usr.LAWCheck()
fireprojectile(/obj/projectile/law,src)
usr.LAWs -= 1

mob/verb/Shotgun()
usr.ShellCheck()
fireprojectile(/obj/projectile/Shotgun,src)
usr.ShotgunShells -= 1

mob
proc
AmmoCheck()
if(usr.Ammunition <= 0)
usr << "You are out of ammo!"
return 1
ShellCheck()
if(usr.ShotgunShells <= 0)
usr << "You are out of shotgun shells!"
return 1

mob/proc/LAWCheck()
if(usr.LAWs <= 0)
usr << "You are out!"
return 1

Drafonis wrote:
The following code compiles correctly and mostly works, except that it doesn't cancel the rest of the verb.
mob/verb/fire()
usr.AmmoCheck()
fireprojectile(/obj/projectile/arrow,src)
usr.Ammunition -= 1

mob/verb/LAW()
usr.LAWCheck()
fireprojectile(/obj/projectile/law,src)
usr.LAWs -= 1

mob/verb/Shotgun()
usr.ShellCheck()
fireprojectile(/obj/projectile/Shotgun,src)
usr.ShotgunShells -= 1

mob
proc
AmmoCheck()
if(usr.Ammunition <= 0)
usr << "You are out of ammo!"
return 1
ShellCheck()
if(usr.ShotgunShells <= 0)
usr << "You are out of shotgun shells!"
return 1

mob/proc/LAWCheck()
if(usr.LAWs <= 0)
usr << "You are out!"
return 1


I'm assuming that it still fires even when you have no ammunition? This is because you didn't insert an if() statement that checks if the AmmoCheck() returned '1'.

Try this:

mob/verb/fire()
if(!usr.AmmoCheck())
fireprojectile(/obj/projectile/arrow,src)
usr.Ammunition -= 1
Calling return in AmmoCheck() or ShellCheck() or LAWCheck() will only return from that proc, not from the proc that called it. To bail out if your check returns 1, which seems to be what you want, do this:
if(usr.ShellCheck()) return
...

Lummox JR