ID:174292
 
I want this projectile, to move in a straight line, creating a tail behind it.
I have this code:
obj
proc
projectile(obj/projectile,var/dir,var/delay)
walk(projectile,dir)
sleep(delay)
del(projectile)
obj
Laser
icon = 'laser.dmi'
icon_state = ""
layer = MOB_LAYER + 99
Bump(A)
if(ismob(A))
var/mob/M = A
if(!M.npp&&!M.npc)
M.Health -= ((3500 * usr.Str)/M.Def)
if(isturf(A))
var/turf/T = A
if(T.dif == 0)
step(src,src.dir)
else
del(src)
else
step(src,src.dir)
Move()
var/obj/T = new /obj/Lasertail (src)
T.player = "[usr]"
walk(src,src.dir)
Del(src)
for(var/obj/Lasertail/T in world)
del(T)
del(src)

obj
Lasertail
icon = 'laser.dmi'
icon_state = "tail"
layer = MOB_LAYER + 99

<dm>

This is for my Laser fighting game!

When I try to play my game, it goes fien until I fire. When I fire the thing doesn't move, and then I get millions of errors, and the game shuts down.

Please help!

~GokuSS4Neo~
No put usr in Move(). Ungh.

Lummox JR
In response to Lummox JR
But it doesn't move if I put usr in Move. I thought it might be src, because usr is the person that is firing it, but if I put src, then it says src.dir undefined! When src.dir IS defined!! And if I get rid of the src.dir bit, when I run it I get loads of errors and the game crashes!!!

~GokuSS4Neo~

P.s. Thankz for your help anyway!
In response to Gokuss4neo
Gokuss4neo wrote:
But it doesn't move if I put usr in Move. I thought it might be src, because usr is the person that is firing it, but if I put src, then it says src.dir undefined! When src.dir IS defined!! And if I get rid of the src.dir bit, when I run it I get loads of errors and the game crashes!!!

No, usr isn't necessarily the person firing. Don't count on usr being anything here.

You forgot a very important thing: Tell your projectile who fired it. It needs that information stored in a var.

The best way to do projectiles is to do all their initialization in New(). Add another argument to New() for the mob who fired the shot, and you can use that information to record who fired and what direction the projectile should go.

Lummox JR
In response to Lummox JR
I understood what I should do in your first 2 sentances, but I am not very clear on the last one, on either what I should do, or how to do it. Is there a demo you can recommend? I have searched for Tails, Trails, Projectiles and Shooting, and looked at all the demos in those results.

~GokuSS4Neo~