legend_clan.c

legend/src/legend_clan.c · 58.4 KB

From the archive LoCRelease.tgz

Download the archive   « Back to the archive contents

/***************************************************************************
 *  Original Diku Mud copyright © 1990, 1991 by Sebastian Hammer,          *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright © 1992, 1993 by Michael            *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc       *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.                                               *
 *                                                                         *
 *  Much time and thought has gone into this software and you are          *
 *  benefitting.  We hope that you share your changes too.  What goes      *
 *  around, comes around.                                                  *
 ***************************************************************************/
/***************************************************************************
 *  God Wars Mud improvements copyright © 1994, 1995, 1996 by Richard      *
 *  Woolcock.  This mud is NOT to be copied in whole or in part, or to be  *
 *  run without the permission of Richard Woolcock.  Nobody else has       *
 *  permission to authorise the use of this code.                          *
 ***************************************************************************/
/***************************************************************************
 *  God Wars Mud copyright (C) 1994, 1995, 1996 by Richard Woolcock        *
 *                                                                         *
 *  Legend of Chrystancia copyright (C) 1999, 2000, 2001 by Matthew Little *
 *  This mud is NOT to be copied in whole or in part, or to be run without *
 *  the permission of Matthew Little. Nobody else has permission to        *
 *  authorise the use of this code.                                        *
 ***************************************************************************/
/***************************************************************************
 * This clancode copyright (c) Malstar 2002-2007.                          *
 * Based upon changes code created by Xkilla in 2000.                      *
 *                                                                         *
 * This code must not be used without written permission of Malstar.       *
 ***************************************************************************/

#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"

int MaxClans;
NCLANS_DATA *nclans_table;

void load_clans (void)
{
   FILE *fp;
   int i;

   if (!(fp = fopen ("../db/clans.dat", "r")))
   {
      bug ("Could not open clans File for reading.", 0);
      return;
   }

   fscanf (fp, "%d\n", &MaxClans);

   /* Use malloc so we can realloc later on */
   nclans_table = malloc (sizeof (NCLANS_DATA) * (MaxClans + 1));

   for (i = 0; i < MaxClans; i++)
   {
      nclans_table[i].name = fread_string (fp);
      nclans_table[i].display = fread_string (fp);
      nclans_table[i].leader = fread_string (fp);
      nclans_table[i].prince = fread_string (fp);
      nclans_table[i].retalclan = fread_string (fp);
      nclans_table[i].class = fread_number (fp);
      nclans_table[i].members = fread_number (fp);
      nclans_table[i].qps = fread_number (fp);
      nclans_table[i].bits = fread_number (fp);
      nclans_table[i].hpreq = fread_number (fp);
      nclans_table[i].manareq = fread_number (fp);
      nclans_table[i].movereq = fread_number (fp);
      nclans_table[i].pks = fread_number (fp);
      nclans_table[i].pds = fread_number (fp);
      nclans_table[i].pdx = fread_number (fp);
      nclans_table[i].magic = fread_number (fp);
      nclans_table[i].merc = fread_number (fp);
   }

   fclose (fp);
   return;			/* just return */
}

void save_clans (void)
{
   FILE *fp;
   int i;

   if (!(fp = fopen ("../db/clans.dat", "w")))
   {
      perror ("../db/clans.dat");
      return;
   }

   fprintf (fp, "%d\n", MaxClans);
   for (i = 0; i < MaxClans; i++)
   {
      fprintf (fp, "%s~\n", nclans_table[i].name); 
      fprintf (fp, "%s~\n", nclans_table[i].display); 
      fprintf (fp, "%s~\n", nclans_table[i].leader); 
      fprintf (fp, "%s~\n", nclans_table[i].prince); 
      fprintf (fp, "%s~\n", nclans_table[i].retalclan);
      fprintf (fp, "%d\n", nclans_table[i].class);
      fprintf (fp, "%d\n", nclans_table[i].members); 
      fprintf (fp, "%d\n", nclans_table[i].qps); 
      fprintf (fp, "%d\n", nclans_table[i].bits); 
      fprintf (fp, "%d\n", nclans_table[i].hpreq);
      fprintf (fp, "%d\n", nclans_table[i].manareq); 
      fprintf (fp, "%d\n", nclans_table[i].movereq); 
      fprintf (fp, "%d\n", nclans_table[i].pks); 
      fprintf (fp, "%d\n", nclans_table[i].pds); 
      fprintf (fp, "%d\n", nclans_table[i].pdx); 
      fprintf (fp, "%d\n", nclans_table[i].magic); 
      fprintf (fp, "%d\n", nclans_table[i].merc); 
      fprintf (fp, "\n");
   }
   fclose (fp);

   return;
}

void do_addclan (CHAR_DATA * ch, char *argument)
{
   NCLANS_DATA *new_table;
   int classbit;
   char buf[MSL];
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];

   argument = one_argument (argument, arg1);
   strcpy(arg2, argument);

   if (IS_NPC (ch))
      return;

   if (arg1[0] == '\0' || arg2[0] == '\0' )
   {
      send_to_char ("Syntax: addclan <class> <clanname>\n\r", ch);
      send_to_char ("Type 'clanlist' to view the list.#n\n\r", ch);
      return;
   }    

   if (!str_cmp(arg1, "werewolf"))
	classbit = CLASS_WEREWOLF;
   else if (!str_cmp(arg1, "vampire"))
      classbit = CLASS_VAMPIRE;
   else if (!str_cmp(arg1, "demon"))
      classbit = CLASS_DEMON;
   else if (!str_cmp(arg1, "mage"))
      classbit = CLASS_MAGE;
   else if (!str_cmp(arg1, "ninja"))
      classbit = CLASS_NINJA;
   else if (!str_cmp(arg1, "monk"))
      classbit = CLASS_MONK;
   else if(!str_cmp(arg1, "drow"))
      classbit = CLASS_DROW;
   else if(!str_cmp(arg1, "fae"))
      classbit = CLASS_FAE;
   else if(!str_cmp(arg1, "wraith"))
      classbit = CLASS_WRAITH;
   else
      { stc("Valid classes to have clans: werewolf, vampire, demon, mage, ninja, drow, monk, fae and wraith.\n\r", ch); return; }

   if ( nclan_exists(arg2) )
   {
     stc("There is already a clan with that name!\n\r",ch);
     return;
   }

   MaxClans++;
   new_table =
      realloc (nclans_table, sizeof (NCLANS_DATA) * (MaxClans + 1));

   if (!new_table)
   {				/* realloc failed */
      send_to_char ("Memory allocation failed. Brace for impact.\n\r", ch);
      return;
   }
   nclans_table = new_table;

   nclans_table[MaxClans  - 1].name = str_dup(arg2);
   nclans_table[MaxClans  - 1].display = str_dup(arg2);
   nclans_table[MaxClans  - 1].leader = str_dup("???");
   nclans_table[MaxClans  - 1].prince  = str_dup("???");
   nclans_table[MaxClans  - 1].retalclan  = str_dup("None");
   nclans_table[MaxClans  - 1].class = classbit;
   nclans_table[MaxClans  - 1].members = 0;
   nclans_table[MaxClans  - 1].qps = 0;
   nclans_table[MaxClans  - 1].bits = 0;
   nclans_table[MaxClans  - 1].hpreq = 0;
   nclans_table[MaxClans  - 1].manareq = 0;
   nclans_table[MaxClans  - 1].movereq = 0;
   nclans_table[MaxClans  - 1].pks = 0;
   nclans_table[MaxClans  - 1].pds = 0;
   nclans_table[MaxClans  - 1].pdx = 0;
   nclans_table[MaxClans  - 1].magic = 7;

   sprintf (buf, "#7You created the clan '%s'.\n\r",  arg2);
   stc (buf, ch);
   //sprintf (buf, "#7The world rumbles as a new clan is aknowledged. Have fear for the %s!", arg2);
   //do_info (ch, buf);
   save_clans();
   return;
}

void do_clantable(CHAR_DATA *ch, char *argument)
{
   char buf[MSL];
   int pk_pd_ratio;
   NCLANS_DATA new_table[MaxClans];
   int i;

   cprintf(buf, "#w[#r%-3s#w][#g%-13s#w][#y%-13s#w][#b%-7s#w][#p%-7s#w][#P%-5s#+#w]#n\n\r","Num", "Clan Name", "Leader", "Pkills", "Pdeaths", "Ratio" );
   stc(buf, ch);
  
   for (i = 0; i < MaxClans; i++)
   {
     new_table[i].display = nclans_table[i].display;
     new_table[i].leader = nclans_table[i].leader;
     new_table[i].pks = nclans_table[i].pks;
     new_table[i].pds = nclans_table[i].pds;
   }

   i = 0;

   while (i < MaxClans)
   {
       if (i == 0) i++;
       if ( (new_table[i].pks + new_table[i].pds == 0) && (new_table[i-1].pks + new_table[i-1].pds == 0) ) i++;
       else if ( (new_table[i].pks + new_table[i].pds == 0) && (new_table[i-1].pks >= new_table[i-1].pds) ) i++;
       else if ( (new_table[i].pks + new_table[i-1].pks == 0) && (new_table[i].pds < new_table[i-1].pds) )
       {
           NCLANS_DATA tmp = new_table[i];
           new_table[i] = new_table[i-1];
           new_table[--i] = tmp;
       }
       else if ( (new_table[i].pks < new_table[i].pds) && (new_table[i-1].pks + new_table[i-1].pds == 0) ) i++;
       else if ( (new_table[i].pks + new_table[i].pds == 0) || (new_table[i-1].pks + new_table[i-1].pds == 0) )
       {
           NCLANS_DATA tmp = new_table[i];
           new_table[i] = new_table[i-1];
           new_table[--i] = tmp;
       }
       else if ( (((long double) new_table[i].pks*100) / (new_table[i].pds+new_table[i].pks)) <= (((long double) new_table[i-1].pks*100) / (new_table[i-1].pds+new_table[i-1].pks)) ) i++;
       else
       {
           NCLANS_DATA tmp = new_table[i];
           new_table[i] = new_table[i-1];
           new_table[--i] = tmp;
       }
   }

   for (i = 0; i < MaxClans; i++)
   {
     if ( (new_table[i].pks + new_table[i].pds) == 0 )
       pk_pd_ratio = 50;
     else if ( new_table[i].pks == 0 )
       pk_pd_ratio = 0;
     else
       pk_pd_ratio =  (100 * new_table[i].pks/ (new_table[i].pks + new_table[i].pds));

      	cprintf(buf, "#w[#r%3d#w][#g%-13s#w][#y%-13s#w][#b%7d#w][#p%7d#w][#P%5d#+#w]#n\n\r", 
        (i + 1), 
        new_table[i].display, 
        new_table[i].leader, 
        new_table[i].pks, 
        new_table[i].pds, pk_pd_ratio);
        stc(buf, ch);
   }
   return;
}

void do_clanlistimm(CHAR_DATA * ch, char *argument)
{
   char arg[MIL], arg2[MIL], buf[MSL], cls[MSL];
   int i, page = 0, maxpage = 0;
   argument = one_argument (argument, arg);
   argument = one_argument (argument, arg2);

   if (IS_NPC (ch))
      return;
   if (MaxClans  < 1)
      return;

   if (is_number (arg))
      page = atoi (arg);

   maxpage = (MaxClans + 9) / 10;

   if (page > 0)
   {
      if (page > maxpage)
      {
	 sprintf (buf, "Show which page 1-%d\n\r", maxpage);
	 stc (buf, ch);
	 return;
      }
      page *= 10;
   }
   stc ("#wNUMBER #CCLANNAME        #rLEADER           #gCLASS#n    #yPRINCE(SS)   #0MBR PDS PKS PDX QPS#n\n\r", ch);

   stc ("#C---------------------------------------------------------------------------------#n\n\r", ch);

   if (!str_cmp (arg, "search"))
   {
      int dsp = 0;

      if (arg2[0] == '\0')
      {
	 stc ("What do you want to search for??.\n\r", ch);
	 return;
      }

      for (i = 1; i < MaxClans; i++)
      {
	 if (!str_infix (arg2, nclans_table[i].name)
	     || !str_infix (arg2, nclans_table[i].leader))

	 {
	if (nclans_table[i].class == CLASS_WEREWOLF)
	  sprintf(cls, "Werewolf");
	else if (nclans_table[i].class == CLASS_VAMPIRE)
	  sprintf(cls, "Vampire");
	else if (nclans_table[i].class == CLASS_NINJA)
	  sprintf(cls, "Ninja");
	else if (nclans_table[i].class == CLASS_DEMON)
          sprintf(cls, "Demon");
	else if (nclans_table[i].class == CLASS_MAGE)
          sprintf(cls, "Mage");
        else if (nclans_table[i].class == CLASS_DROW)
	  sprintf(cls, "Drow");
        else if (nclans_table[i].class == CLASS_MONK)
	  sprintf(cls, "Monk");
        else if (nclans_table[i].class == CLASS_FAE)
          sprintf(cls, "Fae");
        else if (nclans_table[i].class == CLASS_WRAITH)
          sprintf(cls, "Wraith");
      else
	  sprintf(cls, "None");
	    sprintf (buf, "#0[#7%4d#0] #C%-13s   #r%-13s#n    #g%-8s#n #y%-12s#0 %3d %3d %3d %3d %3d#n\n\r",
                     (++dsp),
		     nclans_table[i].name,  
		     nclans_table[i].leader,
		     cls,
		     nclans_table[i].prince,
		     nclans_table[i].members,
		     nclans_table[i].pks,
		     nclans_table[i].pds,
		     nclans_table[i].pdx,
		     nclans_table[i].qps);
	    stc (buf, ch);
	 }
      }
      if (dsp == 0)
	 stc ("There is NO match with what you have entered!.\n\r", ch);
      stc ("#C---------------------------------------------------------------------------------#n\n\r", ch);
      return;
   }


   for (i = 1; i < MaxClans; i++)
   {
	if (nclans_table[i].class == CLASS_WEREWOLF)
	  sprintf(cls, "Werewolf");
	else if (nclans_table[i].class == CLASS_VAMPIRE)
	  sprintf(cls, "Vampire");
        else if (nclans_table[i].class == CLASS_NINJA)
          sprintf(cls, "Ninja");
        else if (nclans_table[i].class == CLASS_DEMON)
          sprintf(cls, "Demon");
        else if (nclans_table[i].class == CLASS_MAGE)
          sprintf(cls, "Mage");
        else if (nclans_table[i].class == CLASS_DROW)
          sprintf(cls, "Drow");
        else if (nclans_table[i].class == CLASS_MONK)
          sprintf(cls, "Monk");
        else if (nclans_table[i].class == CLASS_FAE)
          sprintf(cls, "Fae");
        else if (nclans_table[i].class == CLASS_WRAITH)
          sprintf(cls, "Wraith");
      else
	  sprintf(cls, "None");

      sprintf (buf, "#0[#7%4d#0] #C%-13s   #r%-13s#n    #g%-8s#n #y%-12s#0 %3d %3d %3d %3d %3d#n\n\r",
               i,
	       nclans_table[i].name,
		     nclans_table[i].leader,
		     cls,
		     nclans_table[i].prince,
		     nclans_table[i].members,
		     nclans_table[i].pks,
		     nclans_table[i].pds,
		     nclans_table[i].pdx,
		     nclans_table[i].qps);
      stc (buf, ch);
   }
   stc ("#C---------------------------------------------------------------------------------#n\n\r", ch);
   cent_to_char
      ("#7To search all clans for a string use: 'clanlist search <#Cword#w>'#n",
       ch);
   stc ("#C---------------------------------------------------------------------------------#n\n\r", ch);

}

void delete_clan (int iClan)
{
   int i, j;
   NCLANS_DATA *new_table;

   new_table = malloc (sizeof (NCLANS_DATA) * MaxClans);

   if (!new_table)
      return;

   for (i = 0, j = 0; i < MaxClans + 1; i++)
   {
      if (i != iClan)
      {
	 new_table[j] = nclans_table[i];
	 j++;
      }
   }

   free (nclans_table);
   nclans_table = new_table;
   MaxClans--;
   save_clans ();
   return;
}

void do_clanset ( CHAR_DATA *ch, char *argument )
{
   CHAR_DATA *victim;
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   char arg3[MAX_INPUT_LENGTH];
   char buf[MSL];
   int num;

   argument = one_argument (argument, arg1);
   argument = one_argument (argument, arg2);
   strcpy(arg3, argument);

   if (IS_NPC (ch))
      return;

   if ( arg1[0] == '\0' || arg2[0] == '\0' )
   {
     stc("Syntax: clanset <clanname/victim> <area> <value>\n\r",ch);
     stc("\n\r",ch);
     stc("Area being one of:\n\r",ch);
     stc("name display clan leader deputy pks\n\r",ch);
     stc("pds pdx qps members delete\n\r",ch);
     return;
   }

   if (!str_cmp(arg2, "name") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( arg3[0] == '\0' )
     {
       stc("Set the name to what?\n\r",ch);
       return;
     }

     if ( nclan_exists( arg3 ) )
     {
       stc("But there are already a clan existing by that name!\n\r",ch);
       return;
     }

     if ( (strlen(arg3) < 3) || is_number(arg3))
     {
       stc("Thats not a valid name! (No numbers and atleast 3 characters)\n\r",ch);
       return;
     }

     sprintf(buf, "%s#n clan has been renamed to %s#n!\n\r", nclans_table[num].name, arg3);
     stc(buf, ch);
     nclans_table[num].name = str_dup(arg3);
     save_clans();
     return;
   }

   else if (!str_cmp(arg2, "display") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( arg3[0] == '\0' )
     {
       stc("Set the display to what?\n\r",ch);
       return;
     }

     if ( (strlen(arg3) < 3) || is_number(arg3))
     {
       stc("Thats not a valid display! (No numbers and atleast 3 characters)\n\r",ch);
       return;
     }

     sprintf(buf, "The display of %s clan has been changed to %s#n!\n\r", nclans_table[num].name, arg3);
     stc(buf, ch);
     nclans_table[num].display = str_dup(arg3);
     save_clans();
     return;
   }

   else if (!str_cmp(arg2, "clan") )
   {
     if ( ( victim = get_char_world( ch, arg1 ) ) == NULL )
     {
       stc("They are not here!\n\r",ch);
       return;
     }

     if( arg3[0] == '\0' )
     {
       stc("Set them into what clan?\n\r",ch);
       stc("To outcast them, use 'clanset <victim> clan none'.\n\r",ch);
       return;
     }

     if(!str_cmp(arg3, "none"))
     {
       if( victim->clannum == 0 )
       {
          stc("They are outcast already!\n\r",ch);
          return;
       }
       nclans_table[victim->clannum].members--;
       save_clans();
       victim->clannum = 0;
       do_save(victim, "");
       stc("Their clan has been cleared.\n\r",ch);
       stc("You have been outcast from your clan!\n\r",ch);
       return;
     }

     if ( !nclan_exists( arg3 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg3 );

     sprintf(buf, "%s has been set as member of %s#n!\n\r", victim->name, nclans_table[num].display);
     stc(buf, ch);
     nclans_table[num].members++;
     save_clans();

     num = fetch_clannum( arg3 );
     victim->clannum = num;
     do_save(victim, "");
     return;
   }

   else if (!str_cmp(arg2, "leader") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( arg3[0] == '\0' )
     {
       sprintf(buf, "Set %s's leader to what?\n\r", nclans_table[num].name);
       stc(buf, ch);
       stc("To reset the leader to none, use 'clanset <clanname> leader clear'.\n\r",ch);
       return;
     }

     if (!str_cmp(arg3, "clear"))
     {
       nclans_table[num].leader = str_dup("???");
       save_clans();
       sprintf(buf, "%s leader reset.\n\r", nclans_table[num].name);
       return;
     }

     if ( (strlen(arg3) < 3) || is_number(arg3))
     {
       stc("Thats not a valid leader! (No numbers and atleast 3 characters)\n\r",ch);
       return;
     }

     sprintf(buf, "The leader of the %s clan has been changed to %s#n!\n\r", nclans_table[num].name, arg3);
     stc(buf, ch);
     nclans_table[num].leader = str_dup(arg3);
     save_clans();
     return;
   }

   else if (!str_cmp(arg2, "deputy") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( arg3[0] == '\0' )
     {
       sprintf(buf, "Set %s's deputy to what?\n\r", nclans_table[num].name);
       stc(buf, ch);
       stc("To reset the leader to none, use 'clanset <clanname> deputy clear'.\n\r",ch);
       return;
     }

     if (!str_cmp(arg3, "clear"))
     {
       nclans_table[num].prince = str_dup("???");
       save_clans();
       sprintf(buf, "%s deputy reset.\n\r", nclans_table[num].name);
       return;
     }

     if ( (strlen(arg3) < 3) || is_number(arg3))
     {
       stc("Thats not a valid deputy! (No numbers and atleast 3 characters)\n\r",ch);
       return;
     }

     sprintf(buf, "The deputy of the %s clan has been changed to %s#n!\n\r", nclans_table[num].name, arg3);
     stc(buf, ch);
     nclans_table[num].prince = str_dup(arg3);
     save_clans();
     return;
   }

   else if (!str_cmp(arg2, "pks") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( arg3[0] == '\0' )
     {
       sprintf(buf, "Set %s's playerkill count to what?\n\r", nclans_table[num].name);
       stc(buf, ch);
       return;
     }

     if ( !is_number(arg3) )
     {
       stc("Thats not a number!\n\r",ch);
       return;
     }

     sprintf(buf, "The playerkill count of the %s clan has been changed to %d#n!\n\r", nclans_table[num].name, atoi(arg3));
     stc(buf, ch);
     nclans_table[num].pks = atoi(arg3);
     save_clans();
     return;
   }

   else if (!str_cmp(arg2, "pds") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( arg3[0] == '\0' )
     {
       sprintf(buf, "Set %s's playerdeath count to what?\n\r", nclans_table[num].name);
       stc(buf, ch);
       return;
     }

     if ( !is_number(arg3) )
     {
       stc("Thats not a number!\n\r",ch);
       return;
     }

     sprintf(buf, "The playerdeath count of the %s clan has been changed to %d#n!\n\r", nclans_table[num].name, atoi(arg3));
     stc(buf, ch);
     nclans_table[num].pds = atoi(arg3);
     save_clans();
     return;
   }

   else if (!str_cmp(arg2, "pdx") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( arg3[0] == '\0' )
     {
       sprintf(buf, "Set %s's paradox count to what?\n\r", nclans_table[num].name);
       stc(buf, ch);
       return;
     }

     if ( !is_number(arg3) )
     {
       stc("Thats not a number!\n\r",ch);
       return;
     }

     sprintf(buf, "The paradox count of the %s clan has been changed to %d#n!\n\r", nclans_table[num].name, atoi(arg3));
     stc(buf, ch);
     nclans_table[num].pdx = atoi(arg3);
     save_clans();
     return;
   }

   else if (!str_cmp(arg2, "members") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( arg3[0] == '\0' )
     {
       sprintf(buf, "Set %s's member count to what?\n\r", nclans_table[num].name);
       stc(buf, ch);
       return;
     }

     if ( !is_number(arg3) )
     {
       stc("Thats not a number!\n\r",ch);
       return;
     }

     sprintf(buf, "The member count of the %s clan has been changed to %d#n!\n\r", nclans_table[num].name, atoi(arg3));
     stc(buf, ch);
     nclans_table[num].members = atoi(arg3);
     save_clans();
     return;
   }

   else if (!str_cmp(arg2, "qps") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( arg3[0] == '\0' )
     {
       sprintf(buf, "Set %s's questpoint vault to what?\n\r", nclans_table[num].name);
       stc(buf, ch);
       return;
     }

     if ( !is_number(arg3) )
     {
       stc("Thats not a number!\n\r",ch);
       return;
     }

     sprintf(buf, "The questpoint vault of the %s clan has been changed to %d#n!\n\r", nclans_table[num].name, atoi(arg3));
     stc(buf, ch);
     nclans_table[num].qps = atoi(arg3);
     save_clans();
     return;
   }

   else if (!str_cmp(arg2, "delete") )
   {
     if ( !nclan_exists( arg1 ) )
     {
       stc("That clan does not exist!\n\r", ch);
       return;
     }

     num = fetch_clannum( arg1 );

     if( str_cmp(arg3, "delete") )
     {
       sprintf(buf, "Are you sure you want to delete the %s clan?\n\r", nclans_table[num].name);
       stc(buf, ch);
       stc("To delete them use 'clanset <clanname> delete delete'.\n\r", ch);
       return;
     }

     if ( nclans_table[num].members > 1 )
     {
       SET_BIT( nclans_table[num].bits, CLANBIT_DELETION);
       stc("Clan set for deletion. Will autodelete when all members logged and autokicked out.\n\r",ch);
	 save_clans();
       return;
     }

     //sprintf(buf, "The %s clan are now forever gone!\n\r", nclans_table[num].name);
     //do_info(ch, buf);
     delete_clan(num);
     save_clans();
     return;
   }

   else
   {
     do_clanset(ch, "");
     return;
   }
   return;
}

void do_oclanset (CHAR_DATA * ch, char *argument)
{
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   char arg3[MAX_INPUT_LENGTH];
   char buf[MSL];

   argument = one_argument (argument, arg1);
   argument = one_argument (argument, arg2);
   strcpy(arg3, argument);

   if (IS_NPC (ch))
      return;

   if (!ch->desc || NULLSTR (arg1))
   {
      stc ("Syntax: #rclanset #0[#yload #0|#y save#0]#n\n\r", ch);
      stc ("Syntax: #rclanset #0[#ydelete#0] #0[#yclannumber#0]#n\n\r", ch);
      stc ("Syntax: #rclanset #0[#yname #0|#y display #0|#y clannum #0|#y leader #0|#y prince #0|#y pks #0|#y pds #0|#y pdx #0|#y qps #0|#y members #0]#y value\n\r", ch);
      return;
   }
   else if (!str_cmp (arg1, "load"))
   {
      load_clans ();
      send_to_char ("Loaded clans.dat sucessfully.\n\r", ch);
      return;
   }
   else if (!str_cmp (arg1, "save"))
   {
      save_clans ();
      send_to_char ("Wrote clans.dat sucessfully.\n\r", ch);
      return;
   }
   else if (!str_cmp (arg1, "delete"))
   {
      int num;

      if (NULLSTR (arg2) || !is_number (arg2))
      {
	 send_to_char
	    ("#7To remove a clan, syntax: clanset delete [clannumber].#n\n\r",
	     ch);
	 return;
      }

      num = atoi (arg2);

      if (num < 1 || num > MaxClans)
      {
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 stc (buf, ch);
	 return;
      }
      if ( nclans_table[num].members > 1 )
      {
        SET_BIT( nclans_table[num].bits, CLANBIT_DELETION);
        stc("Clan set for deletion. Will autodelete when all members logged and autokicked out.\n\r",ch);
	  save_clans();
        return;
      }
      delete_clan(num);
      send_to_char ("Clan deleted.\n\r", ch);

      return;
   }
   else if (strcmp (arg1, "clannum") == 0)
   {
      CHAR_DATA *victim;
      int num;

      if ( ( victim = get_char_world( ch, arg2 ) ) == NULL || NULLSTR (arg3) || !is_number (arg3))
      {
	 send_to_char
	    ("#7To someones clannum, syntax: clanset [clannum] [victim] [clannum]#n\n\r",
	     ch);
	 return;
      }
      num = atoi (arg3);
      if (num < 0 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 0 to %d. 0 = NO CLAN\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      if(victim->clannum != 0)
      {
         nclans_table[victim->clannum].members--;
         save_clans();
      }
      victim->clannum = num;
      nclans_table[victim->clannum].members++;
      save_clans ();
      send_to_char ("Clan number reset.\n\r", ch);
      return;
   }
   else if (strcmp (arg1, "leader") == 0)
   {
      int num;
      if (NULLSTR (arg2) || !is_number (arg2) || NULLSTR (argument) || NULLSTR (arg3))
      {
	 send_to_char
	    ("#7To set a leader, syntax: clanset [leader] [clannumber] [new leader name]#n\n\r",
	     ch);
	 return;
      }
      num = atoi (arg2);
      if (num < 1 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      nclans_table[num].leader = str_dup (arg3);
      save_clans ();
      send_to_char ("Clan leader reset.\n\r", ch);
      return;
   }
   else if (strcmp (arg1, "prince") == 0)
   {
      int num;
      if (NULLSTR (arg2) || !is_number (arg2) || NULLSTR (argument) || NULLSTR (arg3))
      {
	 send_to_char
	    ("#7To set a leader, syntax: clanset [leader] [clannumber] [new prince name]#n\n\r",
	     ch);
	 return;
      }
      num = atoi (arg2);
      if (num < 1 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      nclans_table[num].prince = str_dup (arg3);
      save_clans ();
      send_to_char ("Clan prince reset.\n\r", ch);
      return;
   }
   else if (strcmp (arg1, "name") == 0)
   {
      int num;

      if (NULLSTR (arg2) || !is_number (arg2) || NULLSTR (argument) || NULLSTR (arg3))
      {
	 send_to_char
	    ("#7To set a name, syntax: clanset [name] [clannumber] [new clanname]#n\n\r",
	     ch);
	 return;
      }
      num = atoi (arg2);
      if (num < 1 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      nclans_table[num].name = str_dup (arg3);
      save_clans ();
      send_to_char ("Clan name set.\n\r", ch);
      return;
   }
   else if (strcmp (arg1, "display") == 0)
   {
      int num;

      if (NULLSTR (arg2) || !is_number (arg2) || NULLSTR (argument) || NULLSTR (arg3))
      {
	 send_to_char
	    ("#7To set the display on who etc, syntax: clanset [display] [clannumber] [new clanname]#n\n\r",
	     ch);
	 return;
      }
      num = atoi (arg2);
      if (num < 1 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      nclans_table[num].display = str_dup (arg3);
      save_clans ();
      send_to_char ("Clan namedisplay set.\n\r", ch);
      return;
   }
   else if (strcmp (arg1, "pks") == 0)
   {
      int num;
      int value;

      if (NULLSTR (arg2) || !is_number (arg2) || NULLSTR (argument) || !is_number (arg3))
      {
	 send_to_char
	    ("#7To set a leader, syntax: clanset [name] [pks] [new value]#n\n\r",
	     ch);
	 return;
      }

      num = atoi (arg2);
	value = atoi (arg3);

      if (num < 1 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      nclans_table[num].pks = value;
      save_clans ();
      send_to_char ("Clan player kills set.\n\r", ch);
      return;
   }
   else if (strcmp (arg1, "pds") == 0)
   {
      int num;
      int value;

      if (NULLSTR (arg2) || !is_number (arg2) || NULLSTR (argument) || !is_number (arg3))
      {
	 send_to_char
	    ("#7To set a leader, syntax: clanset [name] [pds] [new value]#n\n\r",
	     ch);
	 return;
      }

      num = atoi (arg2);
	value = atoi (arg3);

      if (num < 1 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      nclans_table[num].pds = value;
      save_clans ();
      send_to_char ("Clan player deaths set.\n\r", ch);
      return;
   }
   else if (strcmp (arg1, "qps") == 0)
   {
      int num;
      int value;

      if (NULLSTR (arg2) || !is_number (arg2) || NULLSTR (argument) || !is_number (arg3))
      {
	 send_to_char
	    ("#7To set a leader, syntax: clanset [name] [qps] [new value]#n\n\r",
	     ch);
	 return;
      }

      num = atoi (arg2);
	value = atoi (arg3);

      if (num < 1 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      nclans_table[num].qps  = value;
      save_clans ();
      send_to_char ("Clan quest points set.\n\r", ch);
      return;
   }
   else if (strcmp (arg1, "pdx") == 0)
   {
      int num;
      int value;

      if (NULLSTR (arg2) || !is_number (arg2) || NULLSTR (argument) || !is_number (arg3))
      {
	 send_to_char
	    ("#7To set a leader, syntax: clanset [name] [pdx] [new value]#n\n\r",
	     ch);
	 return;
      }

      num = atoi (arg2);
	value = atoi (arg3);

      if (num < 1 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      nclans_table[num].pdx  = value;
      save_clans ();
      send_to_char ("Clan paradox kills set.\n\r", ch);
      return;
   }
   else if (strcmp (arg1, "members") == 0)
   {
      int num;
      int value;

      if (NULLSTR (arg2) || !is_number (arg2) || NULLSTR (argument) || !is_number (arg3))
      {
	 send_to_char
	    ("#7To set a leader, syntax: clanset members [clannum] [new value]#n\n\r",
	     ch);
	 return;
      }

      num = atoi (arg2);
	value = atoi (arg3);

      if (num < 1 || num > MaxClans)
      {
	 char buf[MAX_STRING_LENGTH];
	 sprintf (buf, "Valid clans are from 1 to %d.\n\r", MaxClans);
	 send_to_char (buf, ch);
	 return;
      }
      nclans_table[num].members  = value;
      save_clans ();
      send_to_char ("Clan members set.\n\r", ch);
      return;
   }
}

void do_clanindex(CHAR_DATA *ch, char *argument)
{
  int i, vamprow=0, wwrow=0, demonrow=0, magerow=0, ninjarow=0, monkrow=0, drowrow=0, faerow=0, wraithrow=0;
  char vampbuf[MSL], vamp[MSL], were[MSL], wwbuf[MSL], demonbuf[MSL], demon[MSL], magebuf[MSL], mage[MSL], ninjabuf[MSL], ninja[MSL];
  char monkbuf[MSL], monk[MSL], drow[MSL], drowbuf[MSL], fae[MSL], faebuf[MSL], wraith[MSL], wraithbuf[MSL];
  char buf[MSL];
  char clanname[MSL];

  if (IS_NPC(ch)) return;

  vampbuf[0]  = '\0';
  vamp[0]  = '\0';
  wwbuf[0]  = '\0';
  were[0]  = '\0';
  demonbuf[0]  = '\0';
  demon[0]  = '\0';
  magebuf[0]  = '\0';
  mage[0]  = '\0';
  ninjabuf[0]  = '\0';
  ninja[0]  = '\0';
  monkbuf[0]  = '\0';
  monk[0]  = '\0';
  drowbuf[0]  = '\0';
  drow[0]  = '\0';
  faebuf[0]  = '\0';
  fae[0]  = '\0';
  wraithbuf[0]  = '\0';
  wraith[0]  = '\0';

  if ( argument[0] == '\0' )
  {
      for (i = 1; i < MaxClans; i++)
      {
                cprintf(clanname, "#r<<Founder of %s#r>>", nclans_table[i].display);
		if(nclans_table[i].class == CLASS_VAMPIRE)
		{
                    cprintf(vamp, "#r%-30s#n - #w%-12s#n ", clanname, nclans_table[i].leader);
                    strcat(vampbuf, vamp);
		    vamprow++;
		  if (vamprow % 2 == 0)
		  strcat(vampbuf, "\n\r");
		}
		if(nclans_table[i].class == CLASS_WEREWOLF)
		{
                  cprintf(clanname, "#o((%s #oChief#o))", nclans_table[i].display);
                  cprintf(were, "%-30s#n - #w%-12s#n ", clanname, nclans_table[i].leader);
                  strcat(wwbuf, were);
		  wwrow++;
		  if (wwrow % 2 == 0)
		  strcat(wwbuf, "\n\r");
		}
		if(nclans_table[i].class == CLASS_MAGE)
		{
                  cprintf(clanname, "#b{{Oracle of %s#b}}", nclans_table[i].display);
                  cprintf(mage, "%-30s#n - #w%-12s#n ", clanname, nclans_table[i].leader);
                  strcat(magebuf, mage);
		  magerow++;
		  if (magerow % 2 == 0)
		  strcat(magebuf, "\n\r");
		}
		if(nclans_table[i].class == CLASS_DEMON)
		{
                  cprintf(clanname, "#y[[Demon Lord of %s#y]]", nclans_table[i].display);
                  cprintf(demon, "%-30s#n - #w%-12s#n ", clanname, nclans_table[i].leader);
                  strcat(demonbuf, demon);
		  demonrow++;
		  if (demonrow % 2 == 0)
		  strcat(demonbuf, "\n\r");
		}
		if(nclans_table[i].class == CLASS_NINJA)
		{
                  cprintf(clanname, "#p**Sennin of #p%s#p**", nclans_table[i].display);
                  cprintf(ninja, "%-30s#n - #w%-12s#n ", clanname, nclans_table[i].leader);
                  strcat(ninjabuf, ninja);
		  ninjarow++;
		  if (ninjarow % 2 == 0)
		  strcat(ninjabuf, "\n\r");
		}
		if(nclans_table[i].class == CLASS_MONK)
		{
                  cprintf(clanname, "#g<:Abbot of #g%s#g:>", nclans_table[i].display);
                  cprintf(monk, "#g%-30s#n - #w%-12s#n ", clanname, nclans_table[i].leader);
                  strcat(monkbuf, monk);
		  monkrow++;
		  if (monkrow % 2 == 0)
		  strcat(monkbuf, "\n\r");
		}
		if(nclans_table[i].class == CLASS_DROW)
		{
                  cprintf(clanname, "#c.oO%s #cIlharn#cOo.", nclans_table[i].display);
                  cprintf(drow, "#c%-30s#n - #w%-12s#n ", clanname, nclans_table[i].leader);
                  strcat(drowbuf, drow);
		  drowrow++;
		  if (drowrow % 2 == 0)
		  strcat(drowbuf, "\n\r");
		}
		if(nclans_table[i].class == CLASS_FAE)
		{
                  cprintf(clanname, "#B[#b<#c%s King#b>#B]", nclans_table[i].display);
                  cprintf(fae, "%-30s#n - #w%-12s ", clanname, nclans_table[i].leader);
                  strcat(faebuf, fae);
		  faerow++;
		  if (faerow % 2 == 0)
		  strcat(faebuf, "\n\r");
		}
		if(nclans_table[i].class == CLASS_WRAITH)
		{
                  cprintf(wraith, "%-30s#n - %-12s ", nclans_table[i].display, nclans_table[i].leader);
                  strcat(wraithbuf, wraith);
		  wraithrow++;
		  if (wraithrow % 2 == 0)
		  strcat(wraithbuf, "\n\r");
		}
      }           
stc("#C---------------------------------------------------------------------------------------\n\r", ch);
	if(strlen(vampbuf) > 1)
	{
	   cent_to_char("#r<<Vampire Clans#r>>#n\n\r",ch);
           strcat(vampbuf, "\n\r");
	   send_to_char(vampbuf, ch);
        }
	if(strlen(wwbuf) > 1)
	{
	   cent_to_char("#o((Werewolf Tribes))#n\n\r",ch);
           strcat(wwbuf, "\n\r");
	   send_to_char(wwbuf, ch);
      }
	if(strlen(demonbuf) > 1)
	{
	   cent_to_char("#y[[Demonic Hordes#y]]#n\n\r",ch);
           strcat(demonbuf, "\n\r");
	   send_to_char(demonbuf, ch);
      }
	if(strlen(magebuf) > 1)
	{
	   cent_to_char("#b{{Magi Traditions}}#n\n\r",ch);
           strcat(magebuf, "\n\r");
	   send_to_char(magebuf, ch);
      }
	if(strlen(ninjabuf) > 1)
	{
	   cent_to_char("#p***Ninja Clans***#n\n\r",ch);
           strcat(ninjabuf, "\n\r");
	   send_to_char(ninjabuf, ch);
      }
	if(strlen(monkbuf) > 1)
	{
	   cent_to_char("#g<:Monk Monastries#g:>#n\n\r",ch);
           strcat(monkbuf, "\n\r");
	   send_to_char(monkbuf, ch);
      }
	if(strlen(drowbuf) > 1)
	{
	   cent_to_char("#c.o0Drow Houses#c0o.#n\n\r",ch);
           strcat(drowbuf, "\n\r");
	   send_to_char(drowbuf, ch);
      }
	if(strlen(faebuf) > 1)
	{
	   cent_to_char("#B[#b<#7Fae Courts#b>#B]#n\n\r",ch);
           strcat(faebuf, "\n\r");
	   send_to_char(faebuf, ch);
      }
	if(strlen(wraithbuf) > 1)
	{
	   cent_to_char("#e-+#7Wraith Clans#e+-#n\n\r",ch);
           strcat(wraithbuf, "\n\r");
	   send_to_char(wraithbuf, ch);
      }
stc("#C---------------------------------------------------------------------------------------\n\r", ch);
      stc("   #7To view detailed information about a clan, use 'clanindex <clanname>'.\n\r",ch);
stc("#C---------------------------------------------------------------------------------------\n\r", ch);
      return;
  }
  else
  {
    bool found=FALSE;
    for (i = 1; i < MaxClans; i++)
    {
      if(str_cmp(argument, nclans_table[i].name) == 1) continue;

stc("#C---------------------------------------------------------------------------------------\n\r", ch);
	sprintf(buf, "%s", nclans_table[i].display);
	cent_to_char(buf,ch);
      sprintf(buf, "\n\r\n\r   #rLeader:#7 %-20s                           #rDeputy:#7 %s\n\r", nclans_table[i].leader, nclans_table[i].prince);
      stc(buf, ch);
      stc("\n\r", ch);
      stc("   #CMembers     Player kills     Player Deaths     Paradoxes#n\n\r",ch);
      stc("   #0---------------------------------------------------------------------------------#n\n\r", ch);
      sprintf(buf, "   #C%7d     %12d     %13d     %9d\n\r", nclans_table[i].members, nclans_table[i].pks, nclans_table[i].pds, nclans_table[i].pdx);
      stc(buf, ch);
	stc("\n\r",ch);
      if(ch->class == nclans_table[i].class || IS_CLASS(ch, CLASS_HIGHLANDER) || IS_IMMORTAL(ch))
      {
        stc("\n\r",ch);
	  stc("\n\r",ch);
	  stc("\n\r",ch);
	  cent_to_char("#7REQUIREMENTS\n\r",ch);
        stc("   #CHit Points    Mana    Move\n\r",ch);
        stc("   #0---------------------------------------------------------------------------------#n\n\r", ch);
	  sprintf(buf, "   #C%-10d    %-7d %d\n\r", nclans_table[i].hpreq, nclans_table[i].manareq, nclans_table[i].movereq);
        stc(buf,ch);
        stc("\n\r",ch);
      }
stc("#C---------------------------------------------------------------------------------------\n\r", ch);
	found = TRUE;
	return;
    }
    if(!found)
    {
      stc("#C---------------------------------------------------------------------------------------\n\r", ch);
	stc("   #7No clan with that name found in the index.\n\r",ch);
      stc("#C---------------------------------------------------------------------------------------\n\r", ch);
    }
    return;
  }
  return;
}

void do_clanedit(CHAR_DATA *ch, char *argument)
{
  char arg1[MIL], arg2[MIL];
  char buf[MSL], col[MSL];
  CHAR_DATA *victim;

  argument = one_argument (argument, arg1);
  strcpy(arg2, argument);

  if(IS_NPC(ch)) return;

  if(str_cmp(ch->name, nclans_table[ch->clannum].leader))
  {
    stc("Huh?\n\r",ch);
    return;
  }

  if ( arg1[0] == '\0' )
  {
    stc("Syntax: clanedit [field] [value]\n\r",ch);
    if(IS_CLASS(ch, CLASS_MAGE))
      stc("Field: display hpreq manareq movereq deputy colorreq",ch);
    else
      stc("Field: display hpreq manareq movereq deputy",ch);
    return;
  }

  if(!str_cmp(arg1, "display"))
  {
    if( arg2[0] == '\0' )
    {
      stc("What do you want displayed on who and public displays?\n\r",ch);
	stc("#7#FHERE YOU CAN COLOR YOUR CLANNAME HOW YOU WANT, BUT IF IT#n\n\r",ch);
	stc("#7#FCONTAINS FLASHING TEXT OR DOESN'T REFLECT YOUR CLANNAME#n\n\r", ch);
      stc("#7#FIT MIGHT GET YOUR CLAN DELETED!#n\n\r",ch);
      return;
    }

    if (strlen(arg2) < 3)
    { stc("Atleast 3 characters...\n\r",ch); return; }
    nclans_table[ch->clannum].display = str_dup(arg2);
    sprintf(buf, "Your public display of the clan is set to '%s#n'.\n\r", nclans_table[ch->clannum].display);
    save_clans();
  }
  else if(IS_CLASS(ch, CLASS_MAGE) && !str_cmp(arg1, "colorreq"))
  {
    if( arg2[0] == '\0' )
    {
      stc("What color do you require mages to be to join the clan?\n\r",ch);
	stc("#7None#n, #rFire#n, #ySpirit#n, #bWater#n, #pAir#n, #gEarth#n.\n\r",ch);
      return;
    }
    if(!str_cmp(arg2, "none"))
        nclans_table[ch->clannum].magic = 7;
    else if(!str_cmp(arg2, "fire"))
        nclans_table[ch->clannum].magic = RED_MAGIC;
    else if(!str_cmp(arg2, "spirit"))
        nclans_table[ch->clannum].magic = YELLOW_MAGIC;
    else if(!str_cmp(arg2, "earth"))
        nclans_table[ch->clannum].magic = GREEN_MAGIC;
    else if(!str_cmp(arg2, "water"))
        nclans_table[ch->clannum].magic = BLUE_MAGIC;
    else if(!str_cmp(arg2, "air"))
        nclans_table[ch->clannum].magic = PURPLE_MAGIC;
    else { do_clanedit(ch, "colorreq"); return; }

    save_clans();
        if ( nclans_table[ch->clannum].magic == RED_MAGIC )
	  sprintf(col, "#rFire#n");
        else if ( nclans_table[ch->clannum].magic == BLUE_MAGIC ) 
	  sprintf(col, "#bWater#n");
        else if ( nclans_table[ch->clannum].magic == PURPLE_MAGIC ) 
	  sprintf(col, "#pAir#n");
        else if ( nclans_table[ch->clannum].magic == GREEN_MAGIC ) 
	  sprintf(col, "#gEarth#n");
        else if ( nclans_table[ch->clannum].magic == YELLOW_MAGIC ) 
	  sprintf(col, "#ySpirit#n");
	else sprintf(col, "#7None#n");
    sprintf(buf, "Your required color to join the clan has been set to '%s#n'.\n\r", col);
    stc(buf, ch);
    return;
  }
  else if(!str_cmp(arg1, "deputy"))
  {
    if( arg2[0] == '\0' )
    {
      stc("What do you want to be your deputy?\n\r",ch);
      return;
    }
    
    if(!str_cmp(arg2, "clear"))
    {
       nclans_table[ch->clannum].prince = str_dup("???");
       save_clans();
       stc("Your current deputy has been removed from their title.\n\r",ch);
       return;
    }

    if ( ( victim = get_char_world( ch, arg2 ) ) == NULL )
    {
	send_to_char( "They aren't here.\n\r", ch );
	return;
    }
    
    if (victim == ch)
    {
	stc("You are not able to be your own deputy!\n\r", ch);
        return;
    }

    if ( victim->clannum != ch->clannum )
    {
      stc("But they are not of your clan!\n\r",ch);
      return;
    }

    if ( victim->class != nclans_table[ch->clannum].class )
    {
      stc("But they are not of your class!\n\r",ch);
      return;
    }

    if ( str_cmp(nclans_table[ch->clannum].prince, "???") )
    {
      send_to_char("You already have a deputy for your clan!\n\r",ch);
      send_to_char("To have the current deputy removed, use 'clanedit deputy clear'.\n\r",ch);
      return;
    }

    nclans_table[ch->clannum].prince = str_dup( victim->name );
    sprintf(buf, "#7%s is now the deputy of your clan!\n\r", nclans_table[ch->clannum].prince);
    stc(buf, ch);
    sprintf(buf, "#r%s#7 has been chosen the new deputy of the clan!", victim->name);
    do_claninfo(ch, buf);
    return;
  }
  else if(!str_cmp(arg1, "hpreq"))
  {
    int num;

    if(!is_number(arg2) || arg1[0] == '\0' )
    {
      stc("Set the hp req to what?\n\r",ch);
      return;
    }

    num = atoi(arg2);

    if(num > 300000)
    {
      stc("Be reasonable...\n\r",ch);
      return;
    }
    nclans_table[ch->clannum].hpreq = num;
    save_clans();
    sprintf(buf, "Hp req for your clan is set to %d.\n\r", num);
    stc(buf, ch);
    return;
  }
  else if(!str_cmp(arg1, "manareq"))
  {
    int num;

    if(!is_number(arg2) || arg1[0] == '\0' )
    {
      stc("Set the mana req to what?\n\r",ch);
      return;
    }

    num = atoi(arg2);

    if(num > 300000)
    {
      stc("Be reasonable...\n\r",ch);
      return;
    }
    nclans_table[ch->clannum].manareq = num;
    save_clans();
    sprintf(buf, "Mana req for your clan is set to %d.\n\r", num);
    stc(buf, ch);
    return;
  }
  else if(!str_cmp(arg1, "movereq"))
  {
    int num;

    if(!is_number(arg2) || arg1[0] == '\0' )
    {
      stc("Set the move req to what?\n\r",ch);
      return;
    }

    num = atoi(arg2);

    if(num > 300000)
    {
      stc("Be reasonable...\n\r",ch);
      return;
    }
    nclans_table[ch->clannum].movereq = num;
    save_clans();
    sprintf(buf, "Move req for your clan is set to %d.\n\r", num);
    stc(buf, ch);
    return;
  }
  else { do_clanedit(ch, ""); return; }
  return;
}

void do_induct(CHAR_DATA *ch, char *argument)
{
  char arg1[MIL], arg2[MIL];
  char buf[MSL], col[MSL];
  CHAR_DATA *victim;

  argument = one_argument (argument, arg1);
  argument = one_argument (argument, arg2);

  if(IS_NPC(ch)) return;

  if( ch->clannum == 0 )
  {
    stc("Huh?\n\r",ch);
    return;
  }

  if (str_cmp(ch->name, nclans_table[ch->clannum].leader) && str_cmp(ch->name, nclans_table[ch->clannum].prince))
  {
    stc("Huh?\n\r",ch);
    return;
  }

  if( arg1[0] == '\0' )
  {
    stc("Induct whom?\n\r",ch);
    return;
  }

  if ( ( victim = get_char_room( ch, arg1 ) ) == NULL )
  {
    send_to_char( "They aren't here.\n\r", ch );
    return;
  }

  if (!IS_IMMUNE(victim, IMM_VAMPIRE))
  {
    send_to_char("They do not wish to get inducted!\n\r",ch);
    return;
  }
  
  if ( victim->class != nclans_table[ch->clannum].class && !IS_CLASS(victim, CLASS_HIGHLANDER))
  {
    stc("But they are not of your class!\n\r",ch);
    return;
  }
  
  if ( IS_CLASS(ch, CLASS_MAGE) && IS_CLASS(victim, CLASS_MAGE) && nclans_table[ch->clannum].magic < 7)
  {
        if ( nclans_table[ch->clannum].magic == RED_MAGIC )
	  sprintf(col, "#rFire#n");
        else if ( nclans_table[ch->clannum].magic == BLUE_MAGIC ) 
	  sprintf(col, "#bWater#n");
        else if ( nclans_table[ch->clannum].magic == PURPLE_MAGIC ) 
	  sprintf(col, "#pAir#n");
        else if ( nclans_table[ch->clannum].magic == GREEN_MAGIC ) 
	  sprintf(col, "#gEarth#n");
        else if ( nclans_table[ch->clannum].magic == YELLOW_MAGIC ) 
	  sprintf(col, "#ySpirit#n");
	else sprintf(col, "#7Hollow#n");

      if ( victim->pcdata->runes[0] != nclans_table[ch->clannum].magic )
 	{
          sprintf(buf, "#7The leader of %s#7 Tradition has decided that only %s#7 can join the clan!\n\r", nclans_table[ch->clannum].name, col);
	  stc(buf, ch);
        return;
      }
  }

  if ( victim->clannum != 0 )
  {
    stc("But they already have a clan!\n\r",ch);
    return;
  }

  if (IS_SET (victim->special, SPC_INCONNU))
  {
    stc("But they have already made their decision about clans!\n\r",ch);
  }

  if ( victim->max_hit < nclans_table[ch->clannum].hpreq )
  {
    stc("They do not have the required hit points to join the clan!\n\r",ch);
    return;
  }

  if ( victim->max_mana < nclans_table[ch->clannum].manareq )
  {
    stc("They do not have the required mana points to join the clan!\n\r",ch);
    return;
  }

  if ( victim->max_move < nclans_table[ch->clannum].movereq )
  {
    stc("They do not have the required vitality points to join the clan!\n\r",ch);
    return;
  }

  victim->clannum = ch->clannum;
  nclans_table[victim->clannum].members++;
  save_clans();
  stc("You have induct them to your clan!\n\r", ch);
  stc("You have been inducted!\n\r", victim);
  sprintf(buf, "#r%s#7 has inducted #r%s#7 to the clan!", ch->name, victim->name);
  do_claninfo(ch, buf);
  return;
}

void do_outcast(CHAR_DATA *ch, char *argument)
{
  char arg1[MIL], arg2[MIL];
  CHAR_DATA *victim;
  char buf[MSL];

  argument = one_argument (argument, arg1);
  argument = one_argument (argument, arg2);

  if(IS_NPC(ch)) return;

  if( ch->clannum == 0 )
  {
    stc("Huh?\n\r",ch);
    return;
  }

  if ( str_cmp(ch->name, nclans_table[ch->clannum].leader) && str_cmp(ch->name, nclans_table[ch->clannum].prince))
  {
    stc("Huh?\n\r",ch);
    return;
  }

  if( arg1[0] == '\0' )
  {
    stc("Outcast whom?\n\r",ch);
    return;
  }

  if ( ( victim = get_char_room( ch, arg1 ) ) == NULL )
  {
    send_to_char( "They aren't here.\n\r", ch );
    return;
  }

  if (!str_cmp(victim->name, nclans_table[ch->clannum].leader))
  {
    send_to_char("You can not outcast your leader!\n\r",ch);
    return;
  }
  
  if ( victim->clannum == 0 )
  {
    stc("But they already outcast!\n\r",ch);
    return;
  }

  nclans_table[victim->clannum].members--;
  victim->clannum = 0;
  save_clans();
  stc("You have outcast them from your clan!\n\r", ch);
  sprintf(buf, "#r%s#7 has outcast #r%s#7 from the clan!", ch->name, victim->name);
  do_claninfo(ch, buf);
  stc("You have been outcast!\n\r", victim);
  return;
}

void do_claninfo( CHAR_DATA *ch, char *argument )
{
    DESCRIPTOR_DATA *d;
    char buf[MSL];

    if ( argument[0] == '\0' )
	return;

    if (!IS_NPC(ch) && IS_IMMORTAL(ch) && IS_SET(ch->act,PLR_WIZINVIS))
	return;

    for ( d = first_descriptor; d != NULL; d = d->next )
    {
        {
            if (d->connected != CON_PLAYING)
               continue;
            if (IS_NPC(d->character))
               continue;
            if (ch->clannum != d->character->clannum && !IS_IMMORTAL(d->character))
               continue;

            sprintf(buf, "#C[#n%s#C]->#7 %s\n\r", nclans_table[ch->clannum].display, argument);
	    send_to_char( buf,   d->character );
	}
    }

    return;
}

void do_nclantalk( CHAR_DATA *ch, char *argument )
{
    DESCRIPTOR_DATA *d;
    char buf[MSL];

    if (IS_IMMORTAL(ch))
    { clan_talk_imm(ch, argument); return; }

    if ( ch->clannum == 0 )
    {
	stc("Huh?\n\r",ch);
      return;
    }

    if ( argument[0] == '\0' )
    { 
       stc("Clanttalk what?\n\r",ch);
	 return;
    }
   if (IS_SET (ch->act, PLR_SILENCE))
   {
      sprintf (buf, "You can't clantalk because you are silenced.\n\r");
      send_to_char (buf, ch);
      return;
   }
    if (!IS_NPC(ch) && IS_IMMORTAL(ch) && IS_SET(ch->act,PLR_WIZINVIS))
	return;

    for ( d = first_descriptor; d != NULL; d = d->next )
    {
	{
            if (d->connected != CON_PLAYING)
               continue;
            if (IS_NPC(d->character))
               continue;
            if (ch->clannum != d->character->clannum && !IS_IMMORTAL(d->character))
               continue;
            if (IS_SET (d->character->deaf, CHANNEL_CLANTALK))
               continue;
            sprintf(buf, "#C-[#n%s #C|#7 %s#C]-#r %s\n\r", nclans_table[ch->clannum].display, ch->name, argument);
	    send_to_char( buf,   d->character );
	}
    }
    return;
}

void clan_talk_imm( CHAR_DATA *ch, char *argument)
{
  DESCRIPTOR_DATA *d;
  char arg1[MIL], arg2[MIL];
  char buf[MSL];
  int num;

  argument = one_argument (argument, arg1);
  strcpy(arg2, argument);

  if(IS_NPC(ch)) return;

  if (arg1[0] == '\0' || arg2[0] == '\0' )
  {
    stc("Clanttalk <clanname> <argument>\n\r",ch);
    return;
  }

  if (!nclan_exists( arg1 ) )
  { 
    stc("That clan does not exist!\n\r",ch);
    return;
  }

  num = fetch_clannum(arg1);

  for ( d = first_descriptor; d != NULL; d = d->next )
  {
	{
            if (d->connected != CON_PLAYING)
               continue;
            if (IS_NPC(d->character))
               continue;
            if (d->character->clannum != num && !IS_IMMORTAL(d->character))
               continue;
            if (IS_SET (d->character->deaf, CHANNEL_CLANTALK))
               continue;
            sprintf(buf, "#C-[#n%s #C|#7 %s#C]-#r %s\n\r", nclans_table[num].display, ch->name, argument);
	    send_to_char( buf,   d->character );
	}
  }
  return;
}

void do_withdraw( CHAR_DATA *ch, char *argument )
{
  char buf[MSL];
  int num;

  if(IS_NPC(ch)) return;

  if( ch->clannum == 0 )
  { 
    stc("Huh?\n\r",ch);
    return;
  }

  if ( !is_number(argument) )
  {
    stc("Specify an amount of quest points to withdraw from the vault.\n\r",ch);
    return;
  }  

  num = atoi( argument );

  if ( num > nclans_table[ch->clannum].qps )
  {
    sprintf(buf, "Current vault balance is #r%d#n quest points.\n\r", nclans_table[ch->clannum].qps);
    stc(buf, ch);
    return;
  }

  if ( (str_cmp(ch->name, nclans_table[ch->clannum].leader) && str_cmp(ch->name, nclans_table[ch->clannum].prince)) && num > 5000)
  {
    stc("You can only withdraw 5000 quest points at a time!\n\r", ch);
    return;
  }

  nclans_table[ch->clannum].qps -= num;
  ch->pcdata->quest += num;
  save_clans();
  sprintf(buf, "#7%s has withdrawn #r%d#7 quest points from the clan bank!", ch->name, num);
  do_claninfo(ch, buf);
  return;
}

void do_deposit( CHAR_DATA *ch, char *argument )
{
  char buf[MSL];
  int num;

  if(IS_NPC(ch)) return;

  if( ch->clannum == 0 )
  { 
    stc("Huh?\n\r",ch);
    return;
  }

  if ( !is_number(argument) )
  {
    stc("Specify an amount of quest points to deposit to the vault.\n\r",ch);
    return;
  }  

  num = atoi( argument );

  if ( num > ch->pcdata->quest )
  {
    sprintf(buf, "That's too generous, you only have #r%d#n quest points.\n\r", ch->pcdata->quest);
    stc(buf, ch);
    return;
  }

  nclans_table[ch->clannum].qps += num;
  ch->pcdata->quest -= num;
  save_clans();
  sprintf(buf, "#7%s has deposited #r%d#7 quest points to the clan bank!", ch->name, num);
  do_claninfo(ch, buf);
  return;
}

void do_clanstatus( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    char col[MAX_STRING_LENGTH];
    CHAR_DATA *gch;

  if (IS_NPC(ch)) return;

  if ( ch->clannum == 0 )
  {
    stc("Huh?\n\r",ch);
    return;
  }

  if(!IS_CLASS(ch, CLASS_MAGE))
  {
    send_to_char("#g[      Name      ] [ Hits /  %  ] [ Mana /  %  ] [Vital / %   ] [         Exp        ]#n\n\r", ch );
    send_to_char("#g--------------------------------------------------------------------------------------#n\n\r",ch);
    for (gch = char_list; gch != NULL; gch = gch->next)
    {
	if ( IS_NPC(gch) ) continue;
	if ( gch->clannum != ch->clannum ) continue;
	if ( IS_IMMORTAL(gch) && !IS_IMMORTAL(ch) && IS_SET(gch->act, PLR_WIZINVIS) ) continue;

	    sprintf( buf,
	    "[%-16s] [%-6d / %3d] [%-6d / %3d] [%-6d / %3d] [%-20lli]\n\r",
		capitalize( gch->name ),
		gch->hit,  (gch->hit  * 100 / gch->max_hit ),
		gch->mana, (gch->mana * 100 / gch->max_mana),
		gch->move, (gch->move * 100 / gch->max_move),
		gch->exp);
		send_to_char( buf, ch );
	}
    send_to_char("#g--------------------------------------------------------------------------------------#n\n\r",ch);
      sprintf(buf, "#7Leader:#r %-12s#7          Deputy: #r%-12s\n\r", nclans_table[ch->clannum].leader, nclans_table[ch->clannum].prince);
      stc(buf, ch);
      sprintf(buf, "#7PKills:#r %-12d#7          PDeath: #r%-12d\n\r", nclans_table[ch->clannum].pks, nclans_table[ch->clannum].pds);
      stc(buf, ch);
      sprintf(buf, "#7Last clan/player to attack member of clan:#r %-12s#7\n\r", nclans_table[ch->clannum].retalclan);
      stc(buf, ch);
      sprintf(buf, "#7Clan Quest Points Bank Balance:#r %d#7.\n\r", nclans_table[ch->clannum].qps);
      stc(buf, ch);
    send_to_char("#g--------------------------------------------------------------------------------------#n\n\r",ch);
    }
  else
  {

    send_to_char("#g[      Name      ] [Color ] [ Hits  /  %   ] [  Mana / %    ] [ Vital / %    ] [         Exp        ]#n\n\r", ch );
    send_to_char("#g-----------------------------------------------------------------------------------------------------#n\n\r",ch);
    for (gch = char_list; gch != NULL; gch = gch->next)
    {
	if ( IS_NPC(gch) ) continue;
	if ( gch->clannum != ch->clannum ) continue;
	if ( IS_IMMORTAL(gch) && !IS_IMMORTAL(ch) && IS_SET(gch->act, PLR_WIZINVIS) ) continue;

	if ( gch->pcdata->runes[0] == RED_MAGIC )
	  sprintf(col, "#rRed   #n");
	else if ( gch->pcdata->runes[0] == BLUE_MAGIC ) 
	  sprintf(col, "#bBlue  #n");
	else if ( gch->pcdata->runes[0] == PURPLE_MAGIC ) 
	  sprintf(col, "#pPurple#n");
	else if ( gch->pcdata->runes[0] == GREEN_MAGIC ) 
	  sprintf(col, "#gGreen #n");
	else if ( gch->pcdata->runes[0] == YELLOW_MAGIC ) 
	  sprintf(col, "#yYellow#n");
	else sprintf(col, "#7None  #n");

	    sprintf( buf,
	    "[%-16s] [%s] [%-6d / %3d] [%-6d / %3d] [%-6d / %3d] [%-20lli]\n\r",
		capitalize( gch->name ),
		col,
		gch->hit,  (gch->hit  * 100 / gch->max_hit ),
		gch->mana, (gch->mana * 100 / gch->max_mana),
		gch->move, (gch->move * 100 / gch->max_move),
		gch->exp);
		send_to_char( buf, ch );
	}
    send_to_char("#g-----------------------------------------------------------------------------------------------------#n\n\r",ch);
      sprintf(buf, "#7Leader:#r %-12s#7          Deputy: #r%-12s\n\r", nclans_table[ch->clannum].leader, nclans_table[ch->clannum].prince);
      stc(buf, ch);
      sprintf(buf, "#7PKills:#r %-12d#7          PDeath: #r%-12d\n\r", nclans_table[ch->clannum].pks, nclans_table[ch->clannum].pds);
      stc(buf, ch);
      sprintf(buf, "#7Last clan/player to attack member of clan:#r %-12s#7\n\r", nclans_table[ch->clannum].retalclan);
      stc(buf, ch);
      sprintf(buf, "#7Clan Quest Points Bank Balance:#r %d#7.\n\r", nclans_table[ch->clannum].qps);
      stc(buf, ch);
    send_to_char("#g-----------------------------------------------------------------------------------------------------#n\n\r",ch);
    }
    return;
}

void clancheck(CHAR_DATA *ch)
{
  if(ch->clannum < 0 || ch->clannum > MaxClans )
   ch->clannum = 0;
  if (IS_SET (ch->special, SPC_INCONNU))
   ch->clannum = 0;
  return;
}

bool nclan_exists( char *argument)
{
      int i, cnt=0;

      for (i = 1; i < MaxClans; i++)
      {
	   if (!str_cmp(argument, nclans_table[i].name))
  	   {
	  	cnt++;
         }
      }
      if ( cnt > 0 )
        return TRUE;
      else
	  return FALSE;
}

int fetch_clannum( char *argument )
{
      int i, cnt=0;

      for (i = 1; i < MaxClans; i++)
      {
	   if (!str_cmp(argument, nclans_table[i].name))
  	   {
                cnt += i;
         }
      }
	return cnt;
}

bool is_clanleader(CHAR_DATA *ch)
{
  if(IS_IMMORTAL(ch)) return TRUE;
  else if (IS_NPC(ch)) return FALSE;
  else if ( ch->clannum == 0 ) return FALSE;
  else if ( !str_cmp(ch->name, nclans_table[ch->clannum].leader)) return TRUE;
  else return FALSE;
}

Site Stats

Snippets: 1791
Codebases: 571