ID:162442
 
How could i go about making it so that when a player bumped the north side of an NPC they would die? (Im not sure if u can even do directional crap like this...)

Plz And Thxs
-Darkarch

EDIT: I Mean The NPC would get deleted...
Well, here is a way:

1) You need to make a "Bumped()" type of procedure. Bump() will not work since it is called on the person who bumped INTO something. You can use Bump() with a mob but meh...

atom
proc/Bumped(atom/A) return // Defining a default procedure for all /atom children to have this procedure.

movable/Bump(atom/A) // Modifying Bump() to called Bumped()
..() // Does Bump() first, if it is redefined elsewhere... it is important that you call the parent procedure everyplace you modify Bump() and don't have it, otherwise Bumped() won't be called.
if(A) A.Bumped(src) // If the object that X Bump()ed into still exists, Bumped() is called.


That was a free freebie for you, all you need to do is just define Bumped() for whatever you want... remember to call the parent proc (..()) for Bump()! Bumped() you do not need it...
obj/NPC
Bumped(mob/M) // Note that Bumped(), like Bump() and other movement procs, do not check if the argument is the type you defined so double checl
if(!ismob(M)) return // If M is not a mob, it will not continue
world << "[M.name] touched me :("

mob/Crazy
Bump(mob/M)
M.Die()
// Because of ..() not here, Bumped() will not be called EVA :O... well, from this parent anyways


2) Now that you have Bumped() in, check the direction of the person who entered... remember to safety check:
if(!ismob(M)) return
if(M.dir == NORTH) del src // If M's dir is NORTH (south of npc)
if(M.dir == turn(src.dir,180)) del src // if M dir is 180 degree (opposite) of its current dir
if(M.dir & NORTH) // If M's dir is either NORTH, NORTHEAST or NORTHWEST... bitflags <_<