/
/*
 * Wizinduct code by Rjael (mud@dredge.axcomp.com) of SaltWind MUD
 * (Some minor fixes and safeguarding added by Thoric)
 */
void do_wizinduct ( CHAR_DATA *ch, char *argument)
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *victim;
    CLAN_DATA *clan;

    if ( IS_NPC(ch) || !IS_IMMORTAL(ch) )
    {
	send_to_char( "Huh?\n\r", ch );
	return;
    }

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

    if ( arg1[0] == '\0' )
    {	
	send_to_char( "Usage: wizinduct <clan|outcast> <player>\n\r", ch );
	return;
    }

    if ( !strcmp( arg1, "outcast" ) )
    {
	if ( arg2[0] == '\0' )
	{
	    send_to_char( "Outcast whom?\n\r", ch );
	    return;
	}
	else
	{	
	    if ( (victim=get_char_room(ch, arg2)) == NULL )
	    {
		send_to_char( "That player is not present.\n\r", ch );
		return;
	    }
	    if ( IS_NPC(victim) )
	    {
		send_to_char( "They don't really care for clans anyway.\n\r", ch );
		return;
	    }
	    if ( victim->level > ch->level )
	    {
		send_to_char( "They may not like you doing that.\n\r", ch );
		return;
	    }
	    if ( (clan=victim->pcdata->clan) == NULL )
	    {
		sent_to_char( "They are not a member of any clan.\n\r", ch );
		return;
	    }
	    if ( clan->clan_type == CLAN_GUILD )
	    {
		int sn;

		for ( sn = 0; sn < top_sn; sn++ )
		    if ( skill_table[sn]->guild == victim->pcdata->clan->class
		    &&   skill_table[sn]->name != NULL )
		    { 
			victim->pcdata->learned[sn] = 0;
			ch_printf( ch, "You forget the ways of %s.\n\r", skill_table[sn]->name );
		    }
	    }

	    if ( victim->speaking & LANG_CLAN )
		victim->speaking = LANG_COMMON;
	    REMOVE_BIT( victim->speaks, LANG_CLAN );
	    --clan->members;
	    if ( !str_cmp(victim->name, clan->deity) )
	    {
		STRFREE( clan->deity );
		clan->deity = STRALLOC( "" );
	    }
	    if ( !str_cmp(victim->name, clan->leader) )
		    {
		STRFREE( clan->leader );
		clan->leader = STRALLOC( "" );
	    }
	    if ( !str_cmp(victim->name, clan->number1) )
	    {	
		STRFREE( clan->number1 );
		clan->number1 = STRALLOC( "" );
	    }
	    if ( !str_cmp(victim->name, clan->number2) )
	    {	
		STRFREE( clan->number2 );
		clan->number2 = STRALLOC( "" );
	    }
	    victim->pcdata->clan = NULL;
	    STRFREE(victim->pcdata->clan_name);
	    victim->pcdata->clan_name = STRALLOC( "" );
	    act( AT_MAGIC, "You remove $N from $t", ch, clan->name, victim, TO_CHAR );
	    act( AT_MAGIC, "$n totally removes $N from $t", ch, clan->name, victim, TO_ROOM );
	    act( AT_MAGIC, "$n totally removes you from $t", ch, clan->name, victim, TO_VICT );
	    sprintf(buf, "The Immortal %s has removed %s from their clan!", ch->name, victim->name);
	    echo_to_all(AT_MAGIC, buf, ECHOTAR_ALL);
	    save_char_obj( victim );
	    return;
	}
    }
    else
    {
	clan = get_clan( arg1 );
	if ( !clan ) 
	{
	    send_to_char( "That clan does not exist.\n\r", ch );
	    return;
	}

	if ( arg2[0] == '\0' )
	{
	    send_to_char( "Induct whom?\n\r", ch );
	    return;
	}
	else
	{	
	    if ( (victim=get_char_room(ch, arg2)) == NULL )
	    {
		send_to_char( "That player is not present.\n\r", ch );
		return;
	    }

	    if ( IS_NPC(victim) )
	    {
		send_to_char( "They dont really care for clans anyway.\n\r", ch );
		return;
	    }

	    if ( victim->pcdata->clan )
	    {
		sent_to_char( "They are already a member of a clan/guild!\n\r", ch );
		return;
	    }

	    if ( clan->clan_type == CLAN_GUILD )
	    {
		if ( victim->class != clan->class)
		    send_to_char( "Note: This player is not of the same class as this guild.\n\rProceeding.\n\r", ch);
	    }
	    else
	    {
		if ( victim->level < 10 )
		{
		    send_to_char( "This player has yet to eat their Wheaties.\n\r", ch);
		    return;
		}
	
		if ( victim->level > ch->level )
		{
		    send_to_char( "They may not like you doing that.\n\r", ch);
		    return;
		}
	    }
		
	    ++clan->members;
	    if ( clan->clan_type != CLAN_ORDER && clan->clan_type != CLAN_GUILD )
		SET_BIT(victim->speaks, LANG_CLAN);

	    if ( clan->clan_type != CLAN_NOKILL && clan->clan_type != CLAN_ORDER
	    &&   clan->clan_type != CLAN_GUILD )
		SET_BIT( victim->pcdata->flags, PCFLAG_DEADLY );

	    if ( clan->clan_type == CLAN_GUILD )
	    {
		int sn;

		for ( sn = 0; sn < top_sn; sn++ )
		{
		    if ( skill_table[sn]->guild == clan->class
		    &&   skill_table[sn]->name != NULL )
		    {
			victim->pcdata->learned[sn] = GET_ADEPT(victim, sn);
			ch_printf( victim, "%s instructs you in the ways of %s.\n\r",
				ch->name, skill_table[sn]->name);
		    }
		}
	    }
	
	    victim->pcdata->clan = clan;
	    STRFREE(victim->pcdata->clan_name);
	    victim->pcdata->clan_name = QUICKLINK( clan->name );
	    act( AT_MAGIC, "You induct $N into $t", ch, clan->name, victim, TO_CHAR );
	    act( AT_MAGIC, "$n inducts $N into $t", ch, clan->name, victim, TO_ROOM );
	    act( AT_MAGIC, "$n adds you into $t", ch, clan->name, victim, TO_VICT );
	    save_char_obj ( victim );
	    return;
	}
    }
}