Re: DGscripts finding people in random.

From: Claude Belisle (cbeli@pop.agri.ch)
Date: 01/13/00


First post to this list and hoping it will be of help and I won't appear too
dumb ;)

Surely depends on how modified (if any) your code is, but the .people
field relies on a room UID (in ours) so your method will definitely not
work.
I can think of two ways of doing what you want.
1. Look at the .next_in_room field on the mob and walk through that list
    using a while loop
2. 'eval current_room %self.room%' on the mob, then '%current_room.people%'
    (I remember I had coded something there so maybe that won't work on
yours).
    Walk through that list.

General notes on potential problems:
1.  On our MUD, I had to fix up the while loop code since it would not
     work for nested loops if the script was written with indents.
2.  The .next_in_room field didn't yield the same result depending whether
you
     go it from a player or a mob (some cases 'not defined' in others 0).
3.  UID were not consistently used. I remember having to fix many things
(and that
     broke others that I needed fixing) to make sure all references were
UIDs
     (particularly for rooms)
4. Many functions do not handle UID properly (%echo% being one of them).
Keep that
    in mind when using it to debug.

Thought:
You may want to make sure what you are looking at is a PC unless you want
the
possibility of the mob attacking another mob. Something like:

* If it's a player
if (%curr_player.vnum% == -1)
  * Add the player to the list
  eval player_list %player_list% %curr_player%
  * Increment the number of players
  eval num_player %num_player% + 1
end

As well, in order to randomly pick from the dynamic list, you would need to
dereference the num_player variable (code I wrote and that may not be
available to you). If not, I'm not sure how you would go about it. Maybe the
more experienced members of this list can tell you.

eval index [random.%num_player%]
extract target %index% %player_list%
* Do something with %target%

Doing this as I wake up and from memory, so check it out first ;)

Manwe

-----Ursprüngliche Nachricht-----
Von: bobat <bobat@PACBELL.NET>
An: CIRCLE@post.queensu.ca <CIRCLE@post.queensu.ca>
Datum: Donnerstag, 13. Januar 2000 06:31
Betreff: [CIRCLE] DGscripts finding people in random.


>I am trying to run a MOB RANDOM trigger and I need to be able to search the
>room for all occupants, count them, return that value then randomly select
>one for the target of the MOB.
>
>My problem lies in how to find the first person in the room when using a
>RANDOM trigger.  How do i reference the variable in the docs .people?  I
>tried to access it by using room numbers like this :   eval actor
>%704.people% but that failed and resulted in a very pissed off server
>crashing on me.
>
>Any help with this would be greatly appreciated.
>
>
>     +------------------------------------------------------------+
>     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
>     +------------------------------------------------------------+


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT