ID:145240
 
Code: When a Bullet is made, it flys until it collides with a Player or wall.
obj
Bullets
icon = 'Effects.dmi'
name = "Bullet"
New()
..()
for(src)
spawn(1)
step(src,src.dir)
continue
Bump(turf)
del src
Bump(mob/Player/M)
if(M != usr)
usr.score += 1
del src


Problem description: The bullets only move when another is created and they go through Turf and Players.

I know its pretty shoddy, but its hand-made.

1. It doesn't bump. Reason? It doesn't havd density. (How can, let's say a shadow, bump?)
2. What the hell did you do to that New() proc.
In response to Mysame
1. Oh yeah, I forgot about that. But now it crashs because it thinks the Turf is a mob.
2. I made it, what else?
In response to RedlineM203
Sigh
obj
Bullets
icon = 'Effects.dmi'
name = "Bullet"
New()
..()
walk(src,src.dir) // It has no dir at default, really! :(
Bump(a)
if(ismob(a)
var/mob/M=a
if(M != usr)
usr.score += 1
del src
else del src
In response to Mysame
Well, actually I haven't showed you the Shooting code... that has the direction in. And this topic is now useless, I'm using a system I found for bullets, and it works. Its bigger, but it works.

Nice try anyway, and I gave bullets my very first self-made attempt.
A few problems:

  • No put usr in proc. Ungh.
  • The bullet's New() proc needs to be passed two vars: its location and the shooter. From the shooter it needs to pick up its direction, and to set an owner var to use in Bump() so you know whose score to increase--because usr is wrong there.
  • You're merely overriding Bump() twice. There's no such thing as making one version for turfs, another for mobs. BYOND is not a strongly typed language, so it's going to go with the last version of Bump() you defined. Since M can be a turf, obj, or mob then, anything your projectile touches will give you a point.

    Lummox JR
In response to Lummox JR
Dude, this was solved 30 minutes after you posted.
In response to RedlineM203
RedlineM203 wrote:
Dude, this was solved 30 minutes after you posted.

Wrong. Until you get rid of the things Lummox mentioned (such as the usr abuse) then it will never be solved.
In response to Elation
Solved was the only word I could find.


Its finished. Done by self.