Cleanse command [by Josh Anderson]
Snippet Posted Sunday, June 11th @ 06:17:26 PM, by Brandon Brown in the Wizard dept.
Josh Anderson writes, "The reason I created it is that I've had some experience on a mud that I used to work with where bugs messed up items regularly.... there was no 'purge all' function, so now that I'm coding for myself I decided to write one as a preemptive measure in case I ever have something like that happen...and just because I like groovy imm commands." You never can have enough groovy imm commands.
Wow, I get to enter the ranks of those who say, "I've taken so much and now get to repay everyone by submitting something".  This is not to say that this is a great bit of code or even a mediocre one as I'm sure it could be optimized and turned inside out, being that I'm still new at this.  

The reason I created it is that I've had some experience on a mud that I used to work with where bugs messed up items regularly.  It caused massive amounts of problems and caused the staff to spend large amounts of time tracking down these items, getting them from people, and destroying them.  There was no 'purge all' function, so now that I'm coding for myself I decided to write one as a preemptive measure in case I ever have something like that happen...and just because I like groovy imm commands.

I added this function to my act.wizard.c file.  Imp as you would any other command.

ACMD(do_cleanse)
{
  struct char_data *i;
  struct obj_data *k;
  mob_vnum number;
  mob_rnum r_num;
  char type[10];
  int num = 0, found = 0;

  two_arguments(argument, buf, buf2);

  if (!*buf || !*buf2 || !isdigit(*buf2)) {
    send_to_char("Usage: cleanse { obj | mob } \r\n", ch);
    return;
  }
  if ((number = atoi(buf2)) < 0) {
    send_to_char("A negative number?\r\n", ch);
    return;
  }
  if (is_abbrev(buf, "mob"))
  {
    if ((r_num = real_mobile(number)) < 0)
    {
      send_to_char("There is no monster with that number.\r\n", ch);
      return;
    }
    for (i = character_list; i; i = i->next)
      if (CAN_SEE(ch, i) && i->in_room != NOWHERE && (GET_MOB_VNUM(i) == number))
      {
        found = 1;
        strcpy(type, "mobs");
        extract_char(i);
      }
  }
  else if (is_abbrev(buf, "obj"))
  {
    if ((r_num = real_object(number)) < 0)
    {
      send_to_char("There is no object with that number.\r\n", ch);
      return;
    }
    for (num = 0, k = object_list; k; k = k->next)
      if (CAN_SEE_OBJ(ch, k) && (GET_OBJ_VNUM(k) == number))
      {
        found = 1;
        strcpy(type, "objs");
        extract_obj(k);
      }
  }
  if (!found)
  {
    send_to_char("Couldn't find any such thing.\r\n", ch);
    return;
  }
  act("$n gathers massive destructive energies around $s body...", FALSE, ch, 0, 0, TO_ROOM);
  act("$e releases them in a wild blast to all the corners of the world!", FALSE, ch, 0, 0, TO_ROOM);
  send_to_char("You release massive amounts of cleansing energies into the world!\r\n", ch);
  sprintf(buf1, "(GC) %s has cleansed the world of all %s with vnum #%d.", GET_NAME(ch), type, number);
  mudlog(buf1, BRF, MAX(LVL_SEN_ADMIN, GET_INVIS_LEV(ch)), TRUE);
}

<< Dual Wield [by Fire] | Reply | Flattened >>

 


Related Links
  Josh Anderson
Related Articles
More by bbrown
 
 

Quick Links
 
The CircleMUD FAQ
The CircleMUD home page
Alex's Snippets
Wintermute Snippets
CircleMUD Bug Reporting or Help
CircleMUD List Archives
CircleMUD Resources
Death Gate's Scripts
(Author of C conversion)
Sammy's code site
Erwin S. Andreasen's page
(Author of mudFTP and other goodies)
Death's Gate Scripting site
Help for CircleMUD in Windows
The OasisOLC Maintenance Effort
George's Random Stuff
Imaginary Realities
MUD Dictionary