ID:2222355
 
(See the best response by Kaiochao.)
I guess it must return a value for swaping mobs and 0 for doing nothing right??
Bump() is only called when trying to move into a dense atom. It returns the obstacle, aka whatever you're bumping into. From the DM reference:

Format:
Bump(atom/Obstacle)
When:
Called when a movement fails due to a dense blockage.
Args:
Obstacle: The blocking object.
Default action:
If the obstacle is a mob and src is in its group, swap their positions. This is only done if the mobs both move by full tiles and do not use pixel movement, to preserve the behavior of older games.
In response to Unwanted4Murder
Best response
Bump() doesn't return anything. The Obstacle is provided as an argument when called by the built-in movement behavior, but the proc returns null by default.
Bump() doesn't return anything, and by default, does nothing. If you want it to swap positions, then src must be a part of obstacle.group (as the reference says).

Edit: Too slow.
Thank you all guys, hmmm so there isn't any way I can override the swapping behavior like turning it on and off??

EDIT: I mean besides the group list because I have like 800 mobs and sometimes I want the mobs at battle phase to not swap positions and on walk mode to swap but adding 800 mobs takes time...
In response to Victorqr
Victorqr wrote:
Thank you all guys, hmmm so there isn't any way I can override the swapping behavior like turning it on and off??

EDIT: I mean besides the group list because I have like 800 mobs and sometimes I want the mobs at battle phase to not swap positions and on walk mode to swap but adding 800 mobs takes time...

Avoid the default behavior in those cases where you don't want swaps to happen.
In response to Victorqr
Victorqr wrote:
Thank you all guys, hmmm so there isn't any way I can override the swapping behavior like turning it on and off??

EDIT: I mean besides the group list because I have like 800 mobs and sometimes I want the mobs at battle phase to not swap positions and on walk mode to swap but adding 800 mobs takes time...

mob
Bump(atom/a)
if(istype(a,/mob/walkthru)) return
else ..()


Edit: Alternatively:

mob
Bump(atom/a)
if(CanBump(a)) ..()
proc/CanBump(atom/a)
if(phase == "walk" && a.phase == "walk") return 0
else return 1
In response to Victorqr
I suppose you could temporarily add the obstacle to the group before calling the default behavior, if you want them to swap.

For more control, you could override the mob's Cross() and/or Crossed() procs. If Cross returns true, whether it's by you returning true or the default behavior returning true, then the mobs overlap regardless of density, and Crossed() is called. If it returns false, then collision with Bump() occurs and the movement fails.
Thanks again guys, I'll try the temporary add method

unfortunately the swap behavior does not occur in Bump :'(

And also about the Cross idea I think Cross is not called at all because of byond pathfinding... I mean to test it

mob/Soldier
Cross()
return 1;

So I expected that my mob would pass through dense objects but pathfinding prevented it... Damn if only I could influence pathfinding with Cross...
unfortunately the swap behavior does not occur in Bump :'(

It does, but I may have found a bug that may explain what you are seeing.

The swap only occurs in tile movement; when using pixel movement, the swap does not occur. The test code:

mob
//step_size=4

Bump(mob/obstacle)
if(!istype(obstacle)) return ..()
group += obstacle
obstacle.group += src
. = ..()
group-= obstacle
obstacle.group -= src
Yeah you're right my bad I had step_size=16, but noticed that when I have step_size=16 and mobs are in same group a mob allows the other to pass through is that expected behavior??
In response to Victorqr
Victorqr wrote:
Yeah you're right my bad I had step_size=16, but noticed that when I have step_size=16 and mobs are in same group a mob allows the other to pass through is that expected behavior??

That doesn't work for me. Not sure what's going on here but it's all bad.
Damn I just noticed my code was really messed up in some points that messed with my Cross proc thanks for your help guys :)


EDIT:Yeah its really bad :)
In response to Victorqr
Actually, is your tile size 16? That's the only thing that comes to mind as to why we're seeing different results.
nope its 32 but its ok about Cross and Bump.

Now if you're interested in checking it out I created 2 mobs 16x16 each and even thought dense if on same group 1 can pass through the other.