ID:1686659
 
Keywords: cross, del, walk
(See the best response by Kaiochao.)
Code:
mob/Unit
Cross(mob/Unit/o)
walk(o,0)


Problem description:

Is it possible that when Walk(ref,0) is called inside Cross() the mob trying to Cross a mob of the same parent is deleted??
Best response
Firstly, you should probably definitely be using Crossed() instead of Cross().

Secondly, when working with movement events like Crossed, Entered, Bump, etc. you should make sure you which variables refer to the objects involved. In Crossed, src is the object being crossed, and the first argument is the moving object.

Thirdly, when specifying a type in the arguments ("mob/Unit/o"), the object 'o' is not actually limited to objects of the type /mob/Unit. What you did there was typecast a variable, telling the compiler what type of variable you expect to be working with, regardless of the actual type of the object. If you want to make sure the argument is a certain type, you need to use istype().

Lastly, I'm not sure what you're asking. You want the crosser (mob/Unit/o) to be deleted when it crosses the src Unit? Then the walk(o, 0) is unnecessary because o would immediately cease to exist. Maybe you want to delete src, the stationary object being crossed? You'll have to do that after the walk(o, 0) because when src is deleted, its running procs (including this Crossed) is forcefully endd.
Thanks for the info, I don't want to delete anything I just wanted to create a custom movement system by using the Standard Cross/Enter/Exit..... Events.

It seems the problem was that I didn't expect to typecast the reference parameter to to mob. I thought that I'd had a runtime error if something else Crossed, istype() solved it thank ;)
Also one more thing, if o is being typecasted then does istype() treat it the way I casted it?? I mean will the istype proc always treat o parameter as /mob/Unit because I typecasted it??
In response to Victorqr
If you're wondering if you can leave out istype's second argument, yes, you can.