If I'm trying to find the Area of a mob, is mob.loc.loc the only way to get it? Or is there a better way because mob.loc.loc is not always the area.
|
I could run something like;
mob It crossed my mind, but I was wondering if there is an easier way to do it all with hard coded stuff. |
This should do it:
atom/proc/GetArea() edit: applied Lummox's fix. I didn't realize contained objects inherited the coordinates of the containers, so Ter's method would be best. I mean, it makes sense, since movables on the map have the same coordinates as the turf they're on (but turfs don't inherit coordinates from their area). |
Actually, there's a more reliable way to do this:
atom/movable/proc/get_area() This will get the area a movable is in in all cases. |
In response to Kaiochao
|
|
If you use while(!istype(a)) you'll run into an error in some cases. If for instance the atom you're checking happens to be nowhere, or inside of another atom that's nowhere, then eventually a will be null. istype() will return 0 for that case, and then a=a.loc will attempt to access null.loc.
The correct loop would be:
while(a && !istype(a)) a = a.loc
|
If mob enters another a obj/mob then it'd be mob.loc.loc.loc.
It's either mob is inside a mob/obj, it's on a turf or it has no location. It's pretty finite and you can always use isturf(mob.loc) to check if it's on a turf or not.