ID:164779
 
I looked it up in the DM referance, and I could't figure it out. I want to pick a mob in the world then have that mob do a certain proc. I want this to be random...

EDIT: I read it again...I saw the bottom that if the only argument is a list, then it will pick someone from that? Soo.... pick(listname) ? That would work, but how can I determine a var to set for one person picked from that list?
Revojake wrote:
I looked it up in the DM referance, and I could't figure it out. I want to pick a mob in the world then have that mob do a certain proc. I want this to be random...

EDIT: I read it again...I saw the bottom that if the only argument is a list, then it will pick someone from that? Soo.... pick(listname) ?

Yes. Make sure you always read the reference entries fully - preferably a couple of times at that (if you're having issues).
That would work, but how can I determine a var to set for one person picked from that list?

Welllll... store the value pick() returns to a variable... if you can't figure that out, you should read the DM Guide.
In response to Kaioken (#1)
I got it to the var/varname=pick(listname) now...
proc
Alien()
var/P=pick(loggedin)
P << "Testing..."

That seems to work.
In response to Revojake (#2)
Yes... why won't it. This is basic stuff, storing a value that a proc returns into a var...
And note that if you want to pick from any mob you don't need a custom list, you can use what...everything (like for(),input()...) uses, world.contents.
In response to Kaioken (#3)
Well, I didnt want ALL the mobs.
In response to Kaioken (#3)
Then you'd be picking from every ATOM in the game, not just mobs.

var/list/players = list()
for(var/client/C)
players += C.mob
var/mob/M = pick(players)
M << "You have been chosen!"


Works pretty well.
In response to Nadrew (#5)
Nadrew wrote:
Then you'd be picking from every ATOM in the game, not just mobs.

Nah, you can use the 'as' keyword to limit it to any atom base type, of course.
Yes, something such as your example is needed for choosing between player mobs.