ID:149687
 
obj/rock
density = 1
Bump(M as mob)
src.Move(get_step(M,dir))



why dont that work?





Because the rock doesn't Bump() the mob the mob Bump()s the rock.

mob/Bump(atom/A)
if(istype(A,/obj/rock))
//rest of code here
In response to Nadrew
Another nice way to do it is to make a Bumped() proc.

atom/proc/Bumped() 
return

mob/Bump(atom/A)
A.Bumped(src)

obj/rock
Bumped(mob/M)
//move


In response to Foomer
thanx Foomer. I did have some problems with my move code. it makes my rock go around in crazy ways. i want it to go away from me. like da rocks in MLAAS

atom/proc/Bumped() 
return

mob/Bump(atom/A)
A.Bumped(src)

obj/rock
density = 1
Bumped(mob/M)
src.Move(get_step(M,dir))//move code


thanks for your time and help
In response to MatrixMofo
MatrixMofo wrote:
thanx Foomer. I did have some problems with my move code. it makes my rock go around in crazy ways. i want it to go away from me. like da rocks in MLAAS

...
Bumped(mob/M)
src.Move(get_step(M,dir))//move code

Notice your arguments to get_step(): You're finding a step relative to the player (M)--not the rock--in the direction the rock is facing (src.dir). That should be get_step(src,M.dir) instead, since you want a step relative to the rock, in the direction the player is pushing.

If you want the player to move too, you'll need to do this:
  Bumped(mob/M)
var/oldloc=loc
if(Move(get_step(src,M.dir))) // if move works
M.Move(oldloc)

This system is of course a little imperfect; the player's Move() proc will initially return 0 when they push a rock, because they bumped into the rock; however once Bump() is called, they'll be moved anyway. Thus if you have any routines that rely on a player's Move() proc returning 1 if they can push a rock, they'll fail. Fortunately this is a minor problem and the code you have on hand should be a good place to get started.

Lummox JR

Lummox JR
In response to Lummox JR
The order that bumping is done made me disturbed first time I read its define in the reference, this should obviously be a built in function, and all blocking objects should have Bumped() called in them until one refuses to budge (returns 0) 'before' the Move() fails...

Hmm, guess this could work too...?

turf
Enter()
for (atom/moveble/a in contents)
if (we can co-exist with this moveble)
continue
if (!a.Bumped())
return ..()

return ..()

Perhaps...? Just a guess, Im kind of newbie to Byond...