ID:148314
 
I am trying to add projectiles to my game, right now it works fairly good. But I have found one major bug, and have spent an hour so far without any luck on how to fix it. If you are moving while shooting the gun, you shoot yourself! I dont really have any idea on how to fix this, right now I have this:
obj
paintball
icon='ball.dmi'
density=1
Bump(mob/M)
//here is the effects
if(istype(M,/mob))//if it is a mob
M.DeathCheck()

I think it is something to do with (istype) ? I am not sure how to have it affect something besides yourself?


Thanks for any help on how to fix this!
Oblivian wrote:
I am trying to add projectiles to my game, right now it works fairly good. But I have found one major bug, and have spent an hour so far without any luck on how to fix it. If you are moving while shooting the gun, you shoot yourself! I dont really have any idea on how to fix this, right now I have this:

What you haven't shown us is the code where the paintball is created and set in motion. (Ideally this should be handled in New(), not in the verb that fired.) The problem is there.

Lummox JR
In response to Lummox JR
oh, well heres that code :

mob
proc
projectile(obj/projectile,var/dir,var/delay)
sleep(1)
walk(projectile,dir)
sleep(delay)
del(projectile)


And the verb that activates all this..

                    usr.projectile(new/obj/paintball(usr.loc),usr.dir,10)
In response to Oblivian
Sleeping before walking is what's causing the problem. But really you're going about the projectile issue wrong; the projectile should start moving in New(), and it should also know who fired it.

Do a forum search on "author:lummoxjr projectile" to find some good basic projectile code. My next Dream Tutor installment for BYONDscape will be on that topic, but work on it has been fitful.

Lummox JR
In response to Lummox JR
ok, thanks for the help.
In response to Lummox JR
Its confusing as hell too.