Re: [CODE] Death Spec Proc

From: John Evans (evansj@HI-LINE.NET)
Date: 02/13/98


On Fri, 13 Feb 1998, George wrote:

> On Fri, 13 Feb 1998, Eric Grotenhuis wrote:
>
> >Okay, I have been asked to put in a spec proc.  Let's say it's for a
> >playercharacter that comes into the room.  100% kill dead die.  So the only
>
> MobProgs or Death's Gate scripts, you cannot do it with standard CircleMUD
> special procedures.

I'm sorry George. I didn't do this to prove you wrong on a personal level,
but when someone tells me that I "can't do something" I do my absolute
BEST to prove them wrong. :)

Anyway.... Here's a normal CircleMUD spec_proc that I wrote:

SPECIAL(killer)
{
  extern void die(struct char_data * ch);
  struct char_data *mob = (struct char_data *) me;

  if (!MOB_FLAGGED(mob, MOB_SPEC))
    return FALSE;

  act("$n glares at $N and $N dies on the spot!",
      TRUE, me, 0, ch, TO_ROOM);
  act("$n glares at you and you fall to the ground dead!",
      TRUE, me, 0, ch, TO_ROOM);

  die(ch);
  REMOVE_BIT(MOB_FLAGS(mob), MOB_SPEC);
  return(TRUE);
}


As you can tell, it won't run unless the mob has the MOB_SPEC flag, and at
the end of the funtion it removes that flag from the character. That means
that it's going to happen one time and only one time for each time the mob
is loaded.

This works fine, but you will need to alter some code elsewhere... You'll
need to make it so that special procedures are called when people enter
the room.

Stock code called special procedures for two reasons:
1) mobile_activity() is called every 10 secs. and runs specials.
2) a player enters a command.

You'll need to add a third occassion of calling special procedures. I'd do
it like so:

File: act.movement.c
Function: do_simple_move()

At the top add:
struct char_data *tch, *next_ch;
extern int no_specials;
extern struct index_data *mob_index;

Right after:
  if (ch->desc != NULL)
    look_at_room(ch, 0);

Add:
  for (tch = world[ch->in_room].people; tch; tch = next_ch) {
    next_ch = tch->next_in_room;
    if (!IS_MOB(tch) || FIGHTING(tch) || !AWAKE(tch))
      continue;
    if (MOB_FLAGGED(tch, MOB_SPEC) && !no_specials) {
      if (mob_index[GET_MOB_RNUM(tch)].func == NULL) {
        sprintf(buf, "%s (#%d): Attempting to call non-existing mob func",
                GET_NAME(tch), GET_MOB_VNUM(tch));
        log(buf);
        REMOVE_BIT(MOB_FLAGS(tch), MOB_SPEC);
      } else {
        if ((mob_index[GET_MOB_RNUM(tch)].func) (ch, tch, 0, ""))
          continue;             /* go to next char */
      }
    }
  }


Of course, this will mean that all specs are run everytime someone walks
into a room. This could be considered a Bad Thing(tm), but I suppose that
you could code it so that ONLY the killer SPECIAL is run.  *shrug*


PS: Who owns the (tm) on Bad Thing. Is that Daniel Koepke?

John Evans <evansj@hi-line.net>  --  http://www.hi-line.net/~evansj/

Any sufficiently advanced technology is indistinguishable from magic.
--Arthur C. Clarke


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



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