identifying what object blocked your way in Developer Help
|
|
If you override a turf's Enter() proc to return 0, you can't enter it but Bump won't be called (the same happens with returning 0 in the Cross proc of a non-dense mob). In this case, how can the mob detect when an object has blocked its path?
If you override the mob's Move proc you can determine that the move failed, but short of re-creating the attempt to move when it fails there doesn't seem to be an easy way to find out what object (or objects) prevented you from making that move. With tile-based movement this isn't terribly difficult, but with pixel-based movement it is.
At first I thought this was a BYOND bug - if you're not able to enter a turf because it blocks your movement then you bumped it. I never used the Bump() proc much so I'm not sure if it always worked this way or not, but I have a feeling it's always been this way.
I had expected that the default Enter proc would check if you're allowed to enter or not, then, whatever proc calls Enter() would, based on the result, either perform the move or call Bump(). Another way of asking this question is, what causes bump to be called and is there any way to customize that behavior? The reference says that it's called when movement fails due to a dense blockage, but it seems like that's what Enter() lets you do - it lets you define when an object behaves as a dense blockage.
|
Areas, objs, and mobs will always permit anything to enter by default.
Turfs will return 1 (permit) or 0 (deny) based on density. In simple terms, if the atom that is entering is dense, then the turf will deny entry if the turf itself or its contents (any that take up the full tile) are dense.
What actually happens in turf.Enter() is more detailed: The turf's density is checked against the object's density first. If this check succeeds (movement is permitted), then Cross() is called for any atoms in turf.contents that cover the entire tile. If any Cross() call fails, Enter() fails too and will return 0.
If a mob is standing on a turf but its bounding box does not cover the whole tile, it is ignored by Enter(). Instead, its Cross() proc is called if there is a danger of the object overlapping it.
But also I feel I read somewhere Enter() calls Bump(), however I cannot find it now, maybe I made a mistake...