ID:144426
 
Code:
obj
bullet
icon = 'bullets.dmi'
layer = 5
density = 1
New()
if(istype(usr,/mob/Player/Red_Team/))
src.icon_state = "red"
else
src.icon_state = "blue"

Bump(atom/M)
if(istype(M,/turf/wall/bwall))
if(istype(usr,/mob/Player/Red_Team/))
usr << "you shot the blue wall"
else
return
if(istype(M,/turf/wall/rwall))
if(istype(usr,/mob/Player/Blue_Team/))
usr << "you shot the red wall"
else
return


if(istype(M,/obj/bullet))
loc = M.loc
return

loc = M.loc
spawn(1)
del(src)


Problem description:

For some reason its not doing anything when the bullets are bumping into walls. Anyone see what could be wrong?
No put usr in proc. Ungh.

Lummox JR
In response to Lummox JR
obj
bullet
icon = 'bullets.dmi'
layer = 5
density = 1
var/owner // the person who fired. set when bullet is created.
New()
if(istype(usr,/mob/Player/Red_Team/))
src.icon_state = "red"
else
src.icon_state = "blue"

Bump(atom/O)
world << "[O] - [src.owner]" // not triggering - so it could be bump() thats not working

if(istype(O,/mob/Player))
if(O == src.owner) // dont hit yourself
return
src.owner << "you hit [O]"

if(istype(O,/turf/wall/bwall))
if(istype(src.owner,/mob/Player/Red_Team/))
src.owner << "you shot the blue wall"
else
return
if(istype(O,/turf/wall/rwall))
if(istype(src.owner,/mob/Player/Blue_Team/))
src.owner << "you shot the red wall"
else
return

if(istype(O,/obj/bullet))
loc = O.loc
return

loc = O.loc
spawn(1)
del(src)


sorry bout that, fixed it up. i dont think its bumping things right since the debug msg doesnt work out.
In response to Drakiel
Err... I don't see you're actually making the bullet move anywhere?
In response to Kaioken
I am using walk_to(f,xyz) on creation of bullet. So it does move. f being the bullet and xyz its destination.


HELP.
In response to Drakiel
bump
In response to Drakiel
on every else return put a message so you know what might be acting up.
In response to Animay3
I already put a trigger in front of the bump and it doesnt come out. so somehow its not reading whatever its bumping.
In response to Drakiel
I don't see owner being set anywhere.

Also, if owner is always going to be a mob, you should make the variable of type mob

var/mob/owner

Also, as Lummox said, no put usr in proc. You still have it New. Instead, pass a mob into new and use it to set owner and the color

New(mob/M)
owner = M
if(istype(M,/mob/Player/Red_Team/))
src.icon_state = "red"
else
src.icon_state = "blue"
In response to Prodigal Squirrel
atom
Click()
Go
var/xyz = locate(src.x,src.y,src.z)
var/obj/bullet/f = new(usr.loc)
f.owner = usr
walk_to(f,xyz)
usr.Energy -= 2
sleep(7)
del(f)

//this is how the bullets created. f.owner = usr
In response to Drakiel
Drakiel wrote:
> atom
> Click()
> Go //useless label. Also, you should almost NEVER use goto.
> var/xyz = locate(src.x,src.y,src.z) //...just use 'src.loc' instead.
> var/obj/bullet/f = new(usr.loc)
> f.owner = usr
> walk_to(f,xyz)
> usr.Energy -= 2
> sleep(7) //identation error :O
> del(f)
>
> //this is how the bullets created. f.owner = usr
>
>


Also, walk_to() will BTW attempt to avoid obstacles on the way to Target... so it will avoid some Bump()s (excluding the final one). Also, you don't want a bullet to be homing, don't you?
Use walk_towards(f,src.loc) instead.
If you still don't get the Bump() debug message, try putting the debug message in a spawn().
In response to Kaioken
thanks that fixed it. I didnt know walk_to avoided stuff like that.

In response to Drakiel
That's why you look-up procs in the DM Reference before using them. ;)