ID:149988
 
Ok here's my verb for the layer mob:
Melee_NPC(mob/M as mob in oview(1))

The rest of the code checks to make sure M is not an PC (aka !M.client). And it works fine when there is all PCs or all NPCs around. But if there is both a NPC and a PC around you when you call that verb, it pops up a dialog telling you to choose one! I didn't know oveiw was supposed to do that! Any tips?
I'd help if you'd just show the whole code :o)
In response to Foomer
I tested with a friend with just the declaration of the verb, and I still got the same result, so the rest of the code is redundant.
In response to Dreq
Mmm well I'm bored so I'll just write my own.

proc/Melee_NPC(mob/M)
var/list/List = list()
for(var/mob/M in oview(M,1))
if(!M.client) List += M
return List

mob/verb/Greet_NPCs(M in Melee_NPC(src))
usr << "You greet [M]."
M.Greeted(src)

mob/proc/Greeted(mob/M)
M << "[src] greets you."


Does that look anything like what you're trying to do?
In response to Foomer
Dreq wrote:
Ok here's my verb for the layer mob:
Melee_NPC(mob/M as mob in oview(1))

The rest of the code checks to make sure M is not an PC (aka !M.client). And it works fine when there is all PCs or all NPCs around. But if there is both a NPC and a PC around you when you call that verb, it pops up a dialog telling you to choose one! I didn't know oveiw was supposed to do that!

oview(n) is just a list of all the things in your view between 1 and n squares away... if you tell the computer this verb needs a mob in oview(1), it will ask you which one. If all the mobs are the same type, it won't bother to ask, because the dialog box would only contain one entry. (A sometimes flaw in BYOND's dialogues... redundant entries are excluded.)

Any tips?

Here's a big tip... make a totally separate type of mob for pcs and npcs (like mob/npc and mob/pc)... then you can have code like:

Melee_NPC(mob/npc/M as mob in oview(1))

and avoid all this. This is what I meant when I said about "typing" your verbs... i.e., telling the computer exactly what "type" of object it applies to. This method does have one problem... the client program only sees the "as mob" part, so lets you right-click on any mob to try to use this verb on it. If the mob isn't a mob/npc, it'll give you an ugly error. How do you avoid this?

If you have a separate mob/npc, define verbs that can only be done to NPCs under mob/npc. Instead of making the target one of the verb's parameters, the target is now the source, so your declaration would look like this:

Melee_NPC() //notice no parameters here.
set src in oview(1)

src is now the target, and usr is the attacker.

Not only will you be unable to use this verb on a PC, even to get a "You can't do that!" message, but... the verb won't even be accessible unless there's a valid NPC target present.