ID:273282
![]() Jan 10 2010, 2:04 pm
|
|
Hi is there a way to block NPCs from moving to another place with the use of Area? I thought up a way of using Enter() but dropped it because it was too messy. Anyone have a non messy way of doing this?
|
![]() Jan 10 2010, 2:48 pm
|
|
You could set the NPC's as a group
mob/NPC/NPCname this puts them in a group. Now you can use an Enter proc like this. turf/NPCBlock notice how I used the group to define it. Now you just place this on the map where you don't want NPC's to pass. |
Why would you use a var for this? I'm aware it's an example but can't you simply check if it has a client? Unless you want monsters to cross while shopkeepers, etc, can't.
|
I was wondering why he didn't use a typepath for distinguishing NPCs myself :\
area/Exit(atom/a) |
I will answer his question. first off, Gr1m d4 r34p3r said that he wants it so that the NPC wouldn't be able to pass, he did not say that he only wanted the player to pass. So if your going to ask that question ask him.
|
If you read my first post I used a group. It is kind of stupid to define the NPC as an atom in this case.
|
It's quite clear that Garthor just put that there as a placeholder for whatever way you'd use to tell a NPC is a NPC (as some method of doing so was required to his example), not as a suggestion to use a var to do so. If he was in a different mood, he could've probably written M.IsNPC() instead, or the like.
|
Gamekrazzy wrote:
If you read my first post I used a group. A group? You mean a type? Or in Java/C++, a class? It is kind of stupid to define the NPC as an atom in this case. That's what you did, actually. You made NPCs their own type of atom (atom/movable/mob/NPC). |
Gamekrazzy wrote:
If you read my first post I used a group. It is kind of stupid to define the NPC as an atom in this case. Typecasting the argument passed to Enter() does not ensure that it is actually that type. That is why she casted it as an atom (which is a safe assumption) and then checked with istype() whether or not it is an NPC type. |
Spunky_Girl wrote:
Gamekrazzy wrote:who cares what I did, I was just pointing out that you added unneeded info. We all know that a mob is an atom. |
i think her point is that you can't really try to point out a flaw in something if you just did the same thing my friend. it's called "hypocrisy"
|
Oh, I see now. So what you did is basically a safer way of doing what I did, but with a little more typing. You also used Exit() instead of Enter(). And if you ask me Enter() does the same thing as seting its density = 1, so would not Enter() be a better way of doing this as far as saving space.
|
I guess it would depend upon how the OP would want things to work. If he doesn't want people to move at all, area/Exit is better. If he doesn't want people to move into a certain type of area, area/Enter is better.
|
So for instance if he had certain NPC's he wanted to move then he would not place that area on the NPC, and if he wanted certain NPCs to stay he would place the area on that NPC. Of course if he is not doing that why would he even mess with the Exit proc in this case, right.
|
Wrong.
What if he wants NPCs to remain inside certain areas? Like patrol units for example. He'd not want them to exit that specific area. |
I didn't take that into consideration, then again I have never tried it so no wonder the thought never came to mind.
|