Re: Spec_Procs

From: Daniel Koepke (
Date: 01/03/97

On Thu, 2 Jan 1997, Brian Jones wrote:

> 	Next I have a question about the block_way function. I get very
> confused when I attempt to look at the main game look in comm.c, so I may
> be very wrong.. 
> 1: Character attempts to move a direction. Gets stored in buffer
> 2: Mobile activity gets pulsed. The mobile SOMEHOW see's that X character
> is attempting to move that direction.
> 3: Mobile says "You can't go in that direction!" and somehow removes
> characters command.
> 4: It finally comes time for the player to move, but he doesn't since mob
> stopped him.
> 	How does the mobile notice that a player in his room is attempting
> to move in a restricted direction? And how does he actually stop the
> players direction command from executing? And how wrong is my series of
> steps :)

The mobile doesn't do any of the above.  He catches the actual
command.  See in interpreter.c, the command parser.  It checks if
there's a special procedure attached to the command and, if so,
executes the spec proc instead of the actual command.

> 	My last question is about memory and assigning spec_procs. How
> many spec_procs can I assign and how many mobiles can be running around
> with spec_procs going off until it starts to lag the mud? From what I see,
> every time mobile_activity() is called it runs through the mobs spec_proc.
> Is there any way to calculate or estimate how much resource a spec_proc
> uses and see when you are about maxing out a safe number to define? Say my
> mud has 6 major cities, and 10 sub-area's, and i wanted 10-15 mobs in each
> area to have unique little gimics such as saying stuff, responding to
> strings characters have to say, looking at a character and offering to pay
> for an item they have, activly "Moving a lot" to find players invading
> their base.. responding to triggers.. etc.. that could be well over
> 160-200 spec_procs running at once. What kind of lag would that create? 
> 1: Can a mob respond to shout's or yell's from other mobiles? Such as "If
> little orc shouts 'invaders!'" set a hunt_invader flag.

Mobiles don't receive shouts and can't shout, themselves.  But it
wouldn't be hard to change the global communication functions for
special cases (eg., a MOB_CANSHOUT flag to make certain mobs able
to use global channels, and then another flag MOB_LISTEN for mobs
who need to listen to the global channels):

  for (mob = character_list; mob; mob = mob->next)
      parse_listen(mob, argument);

The 'parse_listen()' is a theoritical function that would be added
in order to parse the argument as a string the mob is looking for.
Personally, were I to do something to this affect, I'd make it a
script based type thing, or something to that affect:

  catch shout "whatever they say" [without quotes would be keywords]
    flag hunt_invader
    shout "DIE INVADERS!"
  end catch

Something to that affect.  That would make it all the much more
flexible and fun.  Still, it's not neccessary to take it all that
far and dynamic.  You could just have parse_listen() be a hard-coded
function that checks the mob's vnum and then what was said, etc.:

  void parse_listen(struct char_data *mob, struct char_data *actor, 
                    char *said) {
    extern struct index_data *mob_index;
    int vnum = GET_MOB_VNUM(mob);

    switch (vnum) {
    case 3062: // fido vnum
      if (strstr(said, "mutt")) {
        act("$n growls at $N.", FALSE, mob, 0, actor, TO_NOTVICT);
        act("$n growls at you.", FALSE, mob, 0, actor, TO_VICT);
      } else if (strstr(said, "cute puppy")) {
        act("$n lays down at $N's feet, wagging $s tail.", FALSE, mob,
            0, actor, TO_NOTVICT);
        act("$n wags his tail and lays down at your feet.", FALSE, mob,
            0, actor, TO_VICT);
    default :

My little fido above growls at someone who says "mutt" or lays down
at someone's feet that says "cute puppy".  Of course, these are
just examples and won't really work, because we're not catching
room based communication, and the fido is acting within the room.
Still, it demonstates how it would work.

Daniel Koepke
Forgive me father, for I am sin.

| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   |

This archive was generated by hypermail 2b30 : 12/18/00 PST