CLAN.C

CLAN.C · 9.8 KB

From the archive gothar_clan.zip

Download the archive   « Back to the archive contents

/* **************************************************************
  December 27th, 1997
  Gothar's Clan Systems Version 1.0
  1997 Copyright <* FREEWARE *>
  If you use this code:
     1.Keep all the credits in the code.
     2.Use the help entry for bank
     3.Send a bug report,any comments or ideas
       Ian McCormick (aka Gothar)
       mcco0055@algonquinc.on.ca

Here is a listing of what the code does:
 1. Allows imms to give leadership to players
 2. Leaders of clans (not imms) guild players
 3. Information listing of the clans

************************************************************** */
/* N.B: READ this code before you ADD anything!!
 *      This is clan.c plus a patch file for other files.
 */
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#endif
#include <stdio.h>
#include <time.h>
#include "merc.h"
#include "clan.h"

#define OUTCAST		2
#define INDEP		0
 
/* for clans */
/* 
 * CLAN NAME   CLAN NUMBER 
 * Independent  clan = 0
 * Rom          clan = 1
 * Outcast      clan = 2
 * Loner        clan = 3
 * Hades        clan = 4
 * Light        clan = 5
 */
const struct clan_type clan_table[MAX_CLAN] =
{
    /* independent should be FALSE if is a real clan */
  /* name,    who entry,    deathroom,        recall,       indep't  min level */
  {"",	 "",		    ROOM_VNUM_MORGUE, ROOM_VNUM_TEMPLE, TRUE,  0},
  {"Rom",    "<*> ROM <*> ",ROOM_VNUM_GODROOM, ROOM_VNUM_GODROOM, FALSE, LEVEL_IMMORTAL},
  {"Outcast","! OUTCAST ! ",ROOM_VNUM_MORGUE, ROOM_VNUM_TEMPLE, TRUE,  0},
  {"Loner",  "[  LONER  ] ",ROOM_VNUM_MORGUE, ROOM_VNUM_TEMPLE, TRUE,  0},
  {"Hades",  "<~ HADES ~> ",ROOM_VNUM_MORGUE, ROOM_VNUM_TEMPLE, FALSE, 30},
  {"Light",  "-= LIGHT =- ",ROOM_VNUM_MORGUE, ROOM_VNUM_TEMPLE, FALSE, 30}
};


void do_cleader( CHAR_DATA *ch, char *argument )
{
  /* 
   * Gothar's Clan system 
   * Immortal command to create clan leaders
   */
    char arg1[MAX_INPUT_LENGTH],arg2[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *victim;
    int clan;

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

    /* Lists all possible clans */
    if (arg1[0] == '\0'|| arg2[0] == '\0')
    {
        send_to_char( "The ROM Clan list:\n\r",ch);
        /* 
         * Won't print the independent
         */
        for(clan = 0; clan < MAX_CLAN; clan++)
	{
            if(!clan_table[clan].independent)
            {
               sprintf( buf, "  %s\n\r", clan_table[clan].name);
               send_to_char( buf, ch);
            }
        }
        send_to_char( "\n\rSyntax: cleader <clan name> <char>\n\r",ch);
        send_to_char( "If <clan name> is 'none' clan leadership has been removed.\n\r",ch);
        return;
    }
    if ( ( victim = get_char_world( ch, arg2 ) ) == NULL )
    {
        send_to_char( "No character by that name exists.\n\r", ch );
        return;
    }
    if(!str_cmp(arg1,"none"))
    {
	 sprintf( buf,"You remove the burden of leadership from %s.\n\r",victim->name);
         send_to_char( buf, ch);
	 sprintf( buf, "You aren't a leader of %s clan anymore!\n\r",
                      clan_table[victim->clan].name);
         send_to_char( buf, victim);
	 victim->pcdata->leader = -1; /* NULL leadership of clan */ 
 	 return;
    }
    if((clan = clan_lookup(arg1)) == INDEP)
    {
	send_to_char("No such clan exists.\n\r",ch);
	return;
    }
    if(clan_table[clan].independent)
    {
       send_to_char("Outcast and Loner aren't clans!\n\r",ch);
       return;
    }
    else  /* is a TRUE clan */
    {
        if(ch->pcdata->leader == -1)
        {
	   sprintf(buf,"%s is now a leader of %s.\n\r",victim->name,clan_table[clan].name);
	   send_to_char(buf,ch);
	   sprintf(buf,"You are now a leader of %s.\n\r",clan_table[clan].name);
	   send_to_char(buf,victim);
	}
	else
	{
	   send_to_char( "They are already hold leadership of a clan.\n\r",ch);
	   return;
	}   
    }
    victim->pcdata->leader = clan; /* SET leadership of clan */
    victim->clan = clan; /* make member of the clan */
}

void do_clanlist( CHAR_DATA *ch, char *argument )
{
  /* 
   * Gothar's Clan system 
   * Command to see a listing of the clans
   */
    char buf[MAX_STRING_LENGTH];
    int clan;

    send_to_char("     'The Clans of ROM'\n\r",ch);
    send_to_char(" Clan Name       Min Level \n\r",ch);
    send_to_char("---------------------------\n\r",ch);
    for(clan = 0; clan < MAX_CLAN; clan++)
    {
       sprintf( buf, "%-17s    %-5d\n\r",
                clan == INDEP ? "Independent" : clan_table[clan].name,
                clan_table[clan].min_level);
       send_to_char( buf, ch);
    }
    return;
}

void do_clantalk( CHAR_DATA *ch, char *argument )
{
    /*
     * Unchanged just moved for convenience
     * to keep all clan stuff together.
     *  Gothar -1997.
     */
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *d;

    if (!is_clan(ch) || clan_table[ch->clan].independent)
    {
	send_to_char("You aren't in a clan.\n\r",ch);
	return;
    }
    if ( argument[0] == '\0' )
    {
      if (IS_SET(ch->comm,COMM_NOCLAN))
      {
        send_to_char("Clan channel is now ON\n\r",ch);
        REMOVE_BIT(ch->comm,COMM_NOCLAN);
      }
      else
      {
        send_to_char("Clan channel is now OFF\n\r",ch);
        SET_BIT(ch->comm,COMM_NOCLAN);
      }
      return;
    }
    if (IS_SET(ch->comm,COMM_NOCHANNELS))
    {
       send_to_char("The gods have revoked your channel priviliges.\n\r",ch);
       return;
    }
    REMOVE_BIT(ch->comm,COMM_NOCLAN);
    sprintf( buf, "You tell the clan '%s'\n\r", argument );
    send_to_char( buf, ch );
    sprintf( buf, "$n tells the clan '%s'", argument );
    for ( d = descriptor_list; d != NULL; d = d->next )
    {
        if ( d->connected == CON_PLAYING 
             && d->character != ch 
             && is_same_clan(ch,d->character) 
             && !IS_SET(d->character->comm,COMM_NOCLAN) 
             && !IS_SET(d->character->comm,COMM_QUIET) )
        {
            act_new("$n tell the clan '$t'",ch,argument,d->character,TO_VICT,POS_DEAD);
        }
    }
    return;
}



void do_cguild( CHAR_DATA *ch, char *argument )
{
  /* 
   * Gothar's Clan system 
   * Clan Leader command to guild clan members
   */
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *victim;
    int clan;

    argument = one_argument( argument, arg );
    clan = ch->clan; /* setting guildee to leader's clan*/
    if(!IS_CLAN(ch))
    {
       /* not in a clan can't use the cguild command */
       sprintf( buf,"Sorry %s, you aren't in a clan.\n\r",ch->name);
       send_to_char( buf,ch);
       return;
    }
    if(arg[0] == '\0')
    {
       /* the syntax for the cguild command */
       send_to_char( "Syntax: cguild <char>\n\r",ch);
       send_to_char( "Type 'help guild' for more information.\n\r",ch);
       send_to_char( "Also see 'help outcast'.\n\r",ch);
       return;
    }
    if( ( victim = get_char_world( ch, arg ) ) == NULL )
    {
        send_to_char( "No character by that name exists.\n\r", ch );
        return;
    }
       /* Remove Outcast flag */
    if((IS_IMMORTAL(ch) && IS_CLAN(victim)) && (victim->clan == OUTCAST))
    {
        sprintf(buf,"You remove the outcast flag from %s\n\r",victim->name);
        send_to_char(buf,ch);
        send_to_char("Your shame as an Outcast has ended.\n\r", victim);
        victim->clan = INDEP;
        return;
    }
    if(ch->pcdata->leader != clan)
    {
       sprintf(buf,"You aren't a leader of %s clan.\n\r",clan_table[clan].name);
       send_to_char(buf,ch);
       return;
    }
    if(victim->clan == OUTCAST ) /* OUTCAST group */
    {
	 sprintf( buf, "%s is an outcast from the clans.\n\r"
                     "They can't join %s.\n\r",
                     victim->name, clan_table[clan].name);
       send_to_char( buf, ch);
	 sprintf( buf, "You are an outcast!  You can't join a clan."
                     "\n\r Type 'help outcast' for more information.\n\r");
       send_to_char( buf, victim);
       return;
    }
    else if(victim->clan == clan)
    {  
       /* leader outcasts victim */
	 send_to_char("They are now outcast from the clan.\n\r",ch);
	 sprintf( buf, "You have been outcast from %s clan!\n\r",
                      clan_table[clan].name);
       send_to_char( buf, victim);
	 victim->clan = OUTCAST; /* OUTCAST GROUP */
       send_to_char( "Type 'help outcast' for more information.\n\r",ch);
 	 return;
    }
    else if( clan_table[victim->clan].name == "")
    {
       if (victim->level >= clan_table[clan].min_level)
       {
          /* victim joins the clan */
          sprintf(buf,"They are now a proud member of %s.\n\r",clan_table[clan].name);
          send_to_char(buf,ch);
          sprintf(buf,"You are now a proud member of %s.\n\r",clan_table[clan].name);
          send_to_char(buf,victim);
          victim->clan = clan;
       }   
       else
       {
          /*  victim's level not high 
           *  enough to join the clan 
           */
          sprintf(buf,"%s's level is too low to join the clan.\n\r"
                      "The requirement was %d.\n\r",
                      victim->name,clan_table[clan].min_level);
          send_to_char(buf,ch);
          sprintf(buf,"Your level is too low to join %s.\n\r"
                      "The requirement was %d.\n\r",
                      clan_table[clan].name,
                      clan_table[clan].min_level);
          send_to_char(buf,victim);
       }
    }
    else
    {
       sprintf( buf, "%s is a member of %s.\n\r",
                     victim->name, clan_table[clan].name);
       send_to_char( buf, ch);
       send_to_char( "You are already in a clan.\n\r", victim);
       return;
    }
    
}


/* returns clan number */
int clan_lookup (const char *name)
{
   int clan;

   for ( clan = 0; clan_table[clan].name != NULL; clan++)
   {
	if (LOWER(name[0]) == LOWER(clan_table[clan].name[0])
	&&  !str_prefix( name,clan_table[clan].name))
	    return clan;
   }

   return 1; /* none found -return independent */
} 

Site Stats

Snippets: 1791
Codebases: 571