/*
 * well,here is my first code snippit.  A fix for something that isn't broke.
 * This takes leveling on the MUD in a different direction.  It remove the 
 * automatic leveling from the code and requires PC's to go to a mob with the 
 * ACT_LEVEL flag in order to level.  I am placing the flag on a king but it 
 * can go anywhere you like.  If you decide to use it, drop me an email and 
 * leave my name attached to the code.  Any suggestions that might improve 
 * how it works, are also appreciated.  Email is twlthunter@faynet.com.
 */

/* Here's the code... */

1. declare do_level in interp.c & interp.h

2. in merc.h add to other ACT bit's for mobs...

#define ACT_LEVEL			(?)		/* Can Level PC's	*/
 /* substitute ? for a free flag leter */

3. in fight.c under bool is_safe & bool is_safe_spell, add the following line.

	/* no killing healers, trainers, etc */
	if (IS_SET(victim->act,ACT_TRAIN)
	||  IS_SET(victim->act,ACT_PRACTICE)
+	||  IS_SET(victim->act,ACT_LEVEL)
	||  IS_SET(victim->act,ACT_IS_HEALER)
	||  IS_SET(victim->act,ACT_IS_CHANGER))
	    return TRUE;

4. in handler.c under char *act_bit_name add.....

	if (act_flags & ACT_PRACTICE	) strcat(buf, " practice");
+	if (act_flags & ACT_LEVEL		) strcat(buf, " level");
	if (act_flags & ACT_UNDEAD		) strcat(buf, " undead");

5. in update.c replace void gain_exp with the following....

void gain_exp( CHAR_DATA *ch, int gain )
{
    if ( IS_NPC(ch) || ch->level >= LEVEL_HERO )
	return;

	if (ch->exp < exp_per_level(ch,ch->pcdata->points) * (ch->level + 1))
	{
	    ch->exp = UMAX( exp_per_level(ch,ch->pcdata->points), ch->exp + gain );
	    while ( ch->level < LEVEL_HERO && ch->exp >= exp_per_level
			(ch,ch->pcdata->points) * (ch->level+1) )
	    {
		send_to_char( "{YYou may raise a level!! Go visit the King!!{x\n\r", ch );
		return;
		}
	}
	else
	{
		ch->exp = UMAX(exp_per_level(ch,ch->pcdata->points), ch->exp + gain);
		return;
	}
	return;
}

6.  Find a place for this function.  Be sure to declare do_say at the top of 
	the .c file you place it in.  I put it at the bottom of act_comm.c for no
	apparent reason other than it seemed like the thing to do at the time.
	
/*
 * Written by Twilight for The Blades of Destiny. 5/30/99
 */
void do_level( CHAR_DATA *ch, char *argument )
{
	char buf[MAX_STRING_LENGTH];
	CHAR_DATA *leveler;
	
	for ( leveler = ch->in_room->people; 
		leveler != NULL; 
		leveler = leveler->next_in_room )
	{
	    if ( IS_NPC(leveler) && IS_SET(leveler->act, ACT_LEVEL) )
		break;
	}

    if (leveler == NULL || !can_see(ch,leveler))
	{
	    send_to_char( "You can't do that here.\n\r", ch );
	    return;
	}
	
	if (ch->exp < exp_per_level(ch,ch->pcdata->points) * (ch->level + 1))
	{
		sprintf(buf, "Your present level in society seems suited to your abilities for now %s.",ch->name);
		do_say(leveler,buf);
		return;
	}
	
	if (ch->exp >= exp_per_level(ch,ch->pcdata->points) * (ch->level + 1))
	{
		sprintf(buf, "%s, the story of your travels is impressive.",ch->name);
		do_say(leveler,buf);
		do_say(leveler, "Word will be spread throught the realm of your new status in society!!");
		ch->level += 1;
		sprintf(buf,"%s gained level %d",ch->name,ch->level);
		log_string(buf);
		sprintf(buf,"$N has attained level %d!",ch->level);
		wiznet(buf,ch,NULL,WIZ_LEVELS,0,0);
		advance_level(ch,FALSE);
		save_char_obj(ch);
		do_info( ch,"has gained a new level!" );		
	}
	return;
}


7.	Clean recompile & find a mob to put the flag on, and you are in business.  