Re: Autoloot

From: Daniel [Trice] Koepke (dkoepke@global.california.com)
Date: 07/25/95


On Tue, 25 Jul 1995, Sammy wrote:

> Merc does this simply and easily.  I've been looking at Merc 2.2 source.  
> In a Merc pfile, which is text-based and parsed when loaded, has text 
> labels for every field.  It's a little wasteful, but you could use 3 
> letter identifiers in place of the long labels.  The beauty of the setup 
> is that the pfile entries can be in any order.  The parser loads a line 
> at a time and decides what to do with each one.

	The problem here is that Merc writes the players file out when 
they save.  If you have a lot of stuff in there, and say 30-50 players, 
and just a small precentage of them type save, plus the occassional 
autosave, you can get some lag.

	Another problem being that Ron was wrong.  DIKUs (and all of it's 
clones from what I've seen) use a method:

	int act;

	In the char_data structure, and then bits (PLR/PRF in circle).  
New plr/prf bits simply need code to implement the toggling of them which 
is simple in Circle.  In the full release of NiM3 [nimud/theisles, merc 
derived] is probably easier than in any other Diku-based system.  It's 
handled like this:

o Have a structure for the bits:
  struct act_bits {
  char *name;
  int   bit;
  int   min_lvl;
  bool  CanTog;
  };

o Then fill in the table appropriately.  Name determines the name
  that can be typed after the ``config'' (or equivalent) command,
  or like my implementation, if the command typed at the prompt by
  the player isn't recognized, then check through the act_bits
  structure for it, and if found, and level/CanTog are appropraite,
  toggle it.  Bit refers to the PRF/PLR bits.  Min_lvl refers to
  the minimum level which can use this command.  You may want to
  make it level[2] and give min/max levels.  CanTog is either TRUE
  or FALSE and determines if it can be toggled.

  { "autoexit", PRF_AUTOEXIT, 0, TRUE },

  Provided PRF_AUTOEXIT exists, etc.  

o Finally, create a ``config'' command that gets two arguments, but
  if neither are provided it lists the current state of the bits:

  if (arg[0] == '\0') {
  int x;
  struct act_bits *ActBits;
  for( x=0; ActBits[x].name != NULL; x++ ) {
   sprintf(buf, "  %15s [%c]",
	   ActBits[x].name,
	   (IS_SET(ch->act, ActBits[x].bit) ? 'x' : ' ') );
   if( x % 4 )
    strcat(buf, "\r\n");
   send_to_char(buf, ch);
  } /* end of for */
  if( x%4 != 0)		/* not sure on this line */
    send_to_char("\r\n", ch);
  return;
  } /* end of if */
  /* end of code segment */

  Note: Not sure about the IS_SET macro for CircleMUD...
  
  Otherwise there's an arg.  First check if the first arg is in the
  list.  You'll have to go through the list one at a time:

  for (x=0; ActBits[x].name != NULL; x++)
   if (!strcmp(ActBits[x].name, arg)) break;

  if (ActBits[x].name == NULL) {
   send_to_char ("No such flag.\r\n", ch);
   return;
  }

  Now if there's not a second arg simply toggle it on/off.  I belive
  Circle has a macro to do this, but just in case:

  #define TOGGLE_BIT(ch, bit)	(IS_SET(ch->act, bit) ? \
				 SET_BIT(ch->act, bit) :\
				 REMOVE_BIT(ch->act, bit))

  Otherwise, if the second arg is the word ``on'' or the word ``off''
  do the respective actions for that.  Else we print the usage message.


> 
> Setting default values is easily accomplished.  Initialize them just 
> before the pfile is loaded.  Then old pfiles are converted to new pfiles 
> the next time the user connects.

	Unfortunately, that's wrong.  It doesn't automatically update the 
pfiles in all cases.  The problem is consider this line:

HitMove    24 24 89 89

        Now you added two more parameters to that, but didn't update 
everyone's pfiles.  Instant crash-ola for 99% of the Merc-based MUDs
when someone tries to login. :^)


--
dak@krimson, 140.174.210.5/mud.california.com 1234



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