Ok I got malver's system. It works good. Now I can't get my ammo system working. You get to 0 ammo and fire. The alert command works when you hit "ok" you shoot...
mob/proc/Fire(var/mob/ch, var/dir)
if(usr.ammo <=0)
alert("You're out of ammunition!!!")
else
usr.ammo-=1
var/obj/Weapon/O = new /obj/Weapon/Normal_Gun
O.dir = ch.dir
O.loc = ch.loc
while(O)
step(O, dir)
var/turf/Y = get_step(O, O.dir)
if(!Y)
del(O)
break
var/turf/X = O.loc
if(X.density && X.type != /turf/swamp) // Make sure that it isn't water
del(O)
break
for(var/mob/M as mob in X)
if(M == ch)
continue
Damage(M, O.damage)
flick(/turf/Overlays/Pain, M)
spawn(4)
M.overlays -= /turf/Overlays/Pain
sleep(O.speed)
Copyright © 2024 BYOND Software.
All rights reserved.
This where you problem lays. Make the proc return after the alert, and it will work fine. It is currently trying to execute the firing sequence because it isn't indented with the rest of the else statement.