ID:143025
 
Code:
obj/shotgun
icon = 'shotgun.dmi'
verb
Fire() //also a verb for Shoot
shoot()
obj
proc
shoot()
if(!src.fired)
src.fired = 1
spawn(15)
src.fired = 0
var/obj/H = new/obj/bullet
H.dir = src.dir
H.loc = src.loc
while(H)
var nextLocation = get_step(H,H.dir)
var/turf/T = nextLocation
for(var/mob/M as mob in T)
if(M == src)
var/damage = rand(1,5)
if(prob(70)
src<<"You shot [M] for [damage] damage!"
M<<"[src] shot you for [damage] damage!"
M.hp -= damage
if(M.hp <= 0)
M.Deathcheck(usr)
del(H)
if(T.density == 1)
del(H)
if(H)
step(H,H.dir)
sleep(1)
obj/var
fired = 0


Problem description:
Whenever I use the Fire verb, the bullet just goes straight down... I can be facing up but the bullet still goes down..
That's because the shotgun is in your contents and does not share your direction. What you'll want to do is:

var/mob/M = loc
if(!istype(M)) return


Then, use M instead of src when you have to deal with directions and locations and whatnot.
In response to Garthor
whenever i put this code in, an error comes up
where do i put it?
and thx for helping
In response to Biggyneo88
At the start of the shoot() proc.
In response to Garthor
The same error comes up...
"error: obj: expected end of statement"
wherever i put it, the line under it becomes an error
In response to Biggyneo88
Then you've messed something up. Post what you have now.
In response to Garthor
obj/shotgun
icon = 'shotgun.dmi'
verb
Fire() //also a verb for Shoot
shoot()

var/mob/M = loc
if(!istype(M))
return
obj
proc
shoot()
if(!src.fired)
src.fired = 1
spawn(15)
src.fired = 0
var/obj/H = new/obj/bullet
H.dir = src.dir
H.loc = src.loc
while(H)
var nextLocation = get_step(H,H.dir)
var/turf/T = nextLocation
for(var/mob/M as mob in T)
if(M == src)
var/damage = rand(1,5)
if(prob(70)
src<<"You shot [M] for [damage] damage!"
M<<"[src] shot you for [damage] damage!"
M.hp -= damage
if(M.hp <= 0)
M.Deathcheck(usr)
del(H)
if(T.density == 1)
del(H)
if(H)
step(H,H.dir)
sleep(1)
obj/var
fired = 0

and i also changed all the src to M
In response to Biggyneo88
Once again, you put those two lines INSIDE the shoot() proc, at the start of it.
In response to Garthor
thx.. i got it now, and it works