ID:144279
 
Code:
obj/gun/verb
Get()
set src in oview(1)
src.Move(usr)

obj/bullet
icon = 'energyball.dmi'
density=1
var/owner

mob
proc/Shoot()
var/obj/bullet/E = new/obj/bullet(src.loc)
E.owner=src
while(E)
step(E,src.dir)
for(var/mob/M as mob)
Bump(M)


proc/Deathcheck()
if(src.hp<=0)
view() << "[usr] killed [src]!"
src.hp = src.maxhp
src.loc = locate (1,2,3)

var/hp = 10
var/maxhp = 10
verb/shoot()
for(var/mob/M as mob in oview(5))
if(!M)
return
else
usr.Shoot()


Problem description:

the code wont fire visible energyballs (bullets) at the enemy!
cant be arsed looking at the code, but youve probably just forgotton to make a movement state for the bullet


If the bullet is doing damage through a bump proc, then the visual problem means its in the icon

If so, make a new state, edit it and check the movement state box
In response to CuriousNeptune
thanks for the tip, ill try it
            for(var/mob/M as mob)
Bump(M)


That looks like it bumps every mob in the world.
Also use Walk() instead of Step(), Step() moves the Reference once in the designated direction whilst Walk() does it continuesoly (Every Lag which is the time between steps).

A way I do guns might be less buggy;

obj/bullet1
density = 1
icon = 'bullet.dmi'
New()
..()
spawn(1)
walk(src,src.dir,2)
Bump(atom/a)
if(isturf(a))
view(a)<< sound('sound16.wav',volume=50)
del src
if(ismob(a))
if(a.type == /mob/player)
a:Health -= rand(5,20)
a:DeathCheck()
view(a)<< 'sound15.wav'
del src
if(src)
del src

Thats a Bullet I made, It doesnt degarde though so it will keep going.

And in my verb I included:
                for(var/obj/bullet1/B in view(1))
B.dir = usr.dir
step(B,B.dir)


which redirects the bullet to the direction it needs to go to.

I haevent tested this actual code as is because its basically bits and peices that could be handy.