mob
DblClick(mob/M in view())
if(src == usr)
return
if(istype(usr.equip,/obj/Rifle))
if(usr.ChkUse())
for(var/obj/Rifle/R in usr)
if(!R.ammo)
view() << "\red\bold [usr]'s rifle clicks!"
return
if(prob(rand(50,75)))
src.Dmg(rand(10,30))
if(!(locate(/obj/blood/) in src.loc)) new/obj/blood(loc)
view() << "\red\bold [usr] shoots [src] with a rifle!"
if(prob(25))
src.Bleed(rand(1,2),10)
goto ammo
view() << "\red\bold [usr] misses [src]!"
:ammo
for(var/obj/Rifle/R in usr)
R.ammo--
Problem description:
It works fine, but currently I am only allowing one rifle in the inventory at a time. Is there a better way to rewrite this so that I can only decrease the ammo of the rifle the player is using? Like if there are multiple rifles in his inventory?
if(istype(usr.equip,/obj/Rifle))
Shows you already have an accessible way to identify which rifle is firing.
Just add:
var/obj/Rifle/R = usr.equip
Before the istype line and remove the for()'s.