ID:273282
 
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?
area
Exit(var/mob/M)
if(ismob(M) && M.is_an_NPC)
return 0
else
return ..()
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
Enter(mob/NPC/M)
return 0

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.
In response to Garthor
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.
In response to Moonlight Memento
I was wondering why he didn't use a typepath for distinguishing NPCs myself :\

area/Exit(atom/a)
if(istype(a,/mob/npc)
return 0
return ..()
In response to Spunky_Girl
Because no everyone indicates NPCs that way.
In response to Moonlight Memento
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.
In response to Popisfizzy
That's true, but it certainly is easier to do it that way (in most, if not all, cases).
In response to Spunky_Girl
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.
In response to Spunky_Girl
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.
In response to Gamekrazzy
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).
In response to Gamekrazzy
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.
In response to Spunky_Girl
Spunky_Girl wrote:
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).
who cares what I did, I was just pointing out that you added unneeded info. We all know that a mob is an atom.
In response to Gamekrazzy
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"
In response to Spunky_Girl
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.
In response to Gamekrazzy
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.
In response to Spunky_Girl
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.
In response to Gamekrazzy
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.
In response to Spunky_Girl
I didn't take that into consideration, then again I have never tried it so no wonder the thought never came to mind.
In response to Gamekrazzy
On the other hand, if he doesn't want NPCs to be able to access certain other areas, such as non-hostility zones, he'd not want them to enter said areas.
Page: 1 2