atd/area/
atd/build/
atd/clans/
atd/log/
atd/player/store/
atd/site/
atd/src/bin/
/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,	   *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright (C) 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 originally written by KaVir aka Richard Woolcock.         *
 *  Changes done to the code done by Sage aka Walter Howard, this mud is   *
 *  for the public, however if you run this code it means you agree        *
 *  to the license.low, license.gw, and license.merc have fun. :)          *
 ***************************************************************************/

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

int     pulse_area;
int     pulse_mobile;
int     pulse_violence;
int	    pulse_save;
int     pulse_rooms;

/*
 * Local functions.
 */
int	hit_gain	args( ( CHAR_DATA *ch ) );
int	mana_gain	args( ( CHAR_DATA *ch ) );
int	move_gain	args( ( CHAR_DATA *ch ) );
void	mobile_update	args( ( void ) );
void	weather_update	args( ( void ) );
void    moon_update     args( ( void ) );
void	char_update	args( ( void ) );
void	obj_update	args( ( void ) );
void	aggr_update	args( ( void ) );
void    ww_update       args( ( void ) );
void    player_update	args( ( void ) );
void    embrace_update	args( ( void ) );
void    newbie_update   args( ( void ) );
void    hint_update	args( ( void ) );
void    spam_update     args( ( void ) );
void    time_update     args( ( void ) );
void    rooms_update     args( ( void ) );
void    purge_spam      args( ( ROOM_INDEX_DATA *room ) );
int     get_maxq        args( ( CHAR_DATA *ch ) );
void    end_of_game     args( ( void ) );
void    quest_update    args( ( void ) );

extern const struct damage_message	dam_table	[ ];
extern void vote_update ( void );

void gain_exp( CHAR_DATA *ch, int gain )
{
    CHAR_DATA *mount = NULL;
    CHAR_DATA *master = NULL;

    if ( IS_NPC(ch) && (mount = ch->mount) != NULL && !IS_NPC(mount))
    {
	if ( (master = ch->master) == NULL || master != mount )
	    mount->exp += gain;
    }

	/*if ( (( get_age(ch) - 17) * 2 ) < 5 )
      gain *= 3; NEWBIEEXP
*/

/*    if ( !IS_NPC(ch) && !IS_IMMORTAL(ch) )*/
   if ( !IS_NPC(ch))
	ch->exp += gain;
    return;
}



/*
 * Regeneration stuff.
 */

// NEW REGEN STUFF -Cirin
            
void player_update(void)
{
    CHAR_DATA *ch;
    CHAR_DATA *ch_next;
                
    for ( ch = char_list; ch != NULL; ch = ch_next )
    {
        ch_next = ch->next;
                
        if (IS_NPC(ch) || ch == NULL
            || ch->in_room == NULL)
        {
           continue;
        }
        if (ch->hit > 0
           && (ch->position == POS_MORTAL
           || ch->position == POS_INCAP))
                update_pos(ch);
                
        if (ch->hit > 0 && ch->position == POS_STUNNED && number_range(1,10) < 4)
                update_pos(ch);
                    
                    
        if (ch->hit < ch->max_hit
           || ch->move < ch->max_move
           || ch->mana < ch->max_mana)
           {
                            
                if (ch->in_room->vnum == 29502 && ch->move < ch->max_move)
                        ch->move += 8000;
                if (ch->in_room->vnum == 29501 && ch->mana < ch->max_mana)
                        ch->mana += 8000;
               if (ch->in_room->vnum == 29500 && ch->hit < ch->max_hit)
                        ch->hit += 8000;     

                if (ch->position == POS_MORTAL && number_range(1,10) < 4)
                        stc("Blood stops flowing from your wounds.\n\r",ch);
                if (ch->position == POS_STUNNED && number_range(1,10) < 4)
                        stc("Your bones move back into their proper places.\n\r",ch);
                if (ch->position == POS_INCAP && number_range(1,10) < 4)
                        stc("Your wounds slowly knit themselves back together.\n\r",ch);
                     
                switch (ch->position)
                {
                case POS_MORTAL:{
                ch->hit += number_range(1,3);
                break;}
           
                case POS_INCAP:{
                ch->hit += number_range(1,3);
		update_pos(ch);
                break;}
                
                case POS_STUNNED:{
                ch->hit++;
                break;}
           
                case POS_SLEEPING:{   
                        ch->hit  += number_range(1300,1800);
                        ch->mana += number_range(1300,1800);
                        ch->move += number_range(1300,1800);
                        break;}
                
                case POS_MEDITATING:{
                        ch->hit  += number_range(1200,1300);
                        ch->mana += number_range(1500,1900);
                        ch->move += number_range(1200,1300);
                        break;}
                        
                case POS_RESTING:{
                        ch->hit  += number_range(1120,1300);
                        ch->mana += number_range(1120,1300);
                        ch->move += number_range(1120,1300);
                        break;}
                
                case POS_STANDING:{
                        ch->hit  += number_range(450,520);
                        ch->mana += number_range(450,520);
                        ch->move += number_range(450,520);
                break;}
                
                default: break;
                }
           }    
        if (ch->hit  > ch->max_hit ) ch->hit  = ch->max_hit;
        if (ch->mana > ch->max_mana) ch->mana = ch->max_mana;
        if (ch->move > ch->max_move) ch->move = ch->max_move;

		//if (IS_EXTRA(ch, EXTRA_PREGNANT) && (yy > 0 || (dad > 0 && mm >= 9))) SET_BIT(ch->extra, EXTRA_LABOUR);
                        
    }           
    return;
}



int hit_gain( CHAR_DATA *ch )
{
    int gain;
    int conamount;

    if ( IS_NPC(ch) )
    {
	gain = ch->level;
    }
/*
if (IS_NPC(ch) && POS_MORTAL)
{
gain = number_range( 1, 2 );
} 
*/
   else
    {
	if (IS_CLASS(ch, CLASS_VAMPIRE)) return 0;
	gain = number_range( 300, 500 );

	if ((conamount = (get_curr_con(ch)+1)) > 1)
	{
	    switch ( ch->position )
	    {
		case POS_MEDITATING: gain *= conamount * 0.5;	break;
		case POS_SLEEPING:   gain *= conamount;		break;
		case POS_RESTING:    gain *= conamount * 0.5;	break;
	    }
	}

	if ( ch->pcdata->condition[COND_FULL]   == 0 && !IS_HERO(ch) )
	    gain *= 0.5;

	if ( ch->pcdata->condition[COND_THIRST] == 0 && !IS_HERO(ch) )
	    gain *= 0.5;

    }


    if ( IS_AFFECTED(ch, AFF_POISON) || IS_AFFECTED(ch, AFF_FLAMING))
	gain *= 0.25;

    return UMIN(gain, ch->max_hit - ch->hit);
}



int mana_gain( CHAR_DATA *ch )
{
    int gain;
    int intamount;

    if ( IS_NPC(ch) )
    {
	gain = ch->level;
    }
    else
    {
	if (IS_CLASS(ch, CLASS_VAMPIRE)) return 0;
	gain = number_range( 10, 20 );

	if ((intamount = (get_curr_int(ch)+1)) > 1)
	{
	    switch ( ch->position )
	    {
		case POS_MEDITATING: gain *= intamount * 10.0;	        break;
		case POS_SLEEPING:   gain *= intamount;			break;
		case POS_RESTING:    gain *= intamount * 0.5;		break;
	    }
	}

	if ( !IS_HERO(ch) && ch->pcdata->condition[COND_THIRST] == 0 )
	    gain *= 0.5;

    }

    if( IS_CLASS(ch,CLASS_MAGE) )
	gain *= 50;
    if ( IS_AFFECTED( ch, AFF_POISON ) || IS_AFFECTED(ch, AFF_FLAMING) )
	gain *= 0.25;

    return UMIN(gain, ch->max_mana - ch->mana);
}



int move_gain( CHAR_DATA *ch )
{
    int gain;
    int dexamount;

    if ( IS_NPC(ch) )
    {
	gain = ch->level;
    }
    else
    {
	if (IS_CLASS(ch, CLASS_VAMPIRE)) return 0;
	gain = number_range( 10, 20 );

	if ((dexamount = (get_curr_dex(ch)+1)) > 1)
	{
	    switch ( ch->position )
	    {
		case POS_MEDITATING: gain *= dexamount * (ch->level * 10);	break;
		case POS_SLEEPING:   gain *= dexamount;		break;
		case POS_RESTING:    gain *= dexamount * 0.5;	break;
	    }
	}

	if ( !IS_HERO(ch) && ch->pcdata->condition[COND_THIRST] == 0 )
	    gain *= 0.5;
    }

    if ( IS_AFFECTED(ch, AFF_POISON) || IS_AFFECTED(ch, AFF_FLAMING) )
	gain *= 0.25;

    return UMIN(gain, ch->max_move - ch->move);
}



void gain_condition( CHAR_DATA *ch, int iCond, int value )
{
    int condition;

    if ( value == 0 || IS_NPC(ch) )
	return;

    if (!IS_NPC(ch) && IS_HERO(ch) && !IS_CLASS(ch, CLASS_VAMPIRE) 
	&& iCond != COND_DRUNK)
	return;

    condition				= ch->pcdata->condition[iCond];
    if (!IS_NPC(ch) && !IS_CLASS(ch, CLASS_VAMPIRE) )
	ch->pcdata->condition[iCond]	= URANGE( 0, condition + value, 48 );
    else
	{
               int chargen = ch->pcdata->stats[UNI_GEN];
                int maxblood;
                if (chargen > 12)
                        chargen = 12;
                maxblood = (13 - chargen) * 100;
     
                ch->pcdata->condition[iCond]    = URANGE( 0, condition + value, maxblood );
        }
/*
	if ( ch->pcdata->stats[UNI_GEN] == 2 )
		ch->pcdata->condition[iCond]	= URANGE( 0, condition + value, 1000 );
	else if ( ch->pcdata->stats[UNI_GEN] == 3 )
		ch->pcdata->condition[iCond]	= URANGE( 0, condition + value, 666 );
	else if ( ch->pcdata->stats[UNI_GEN] == 4 )
		ch->pcdata->condition[iCond]	= URANGE( 0, condition + value, 500 );
	else if ( ch->pcdata->stats[UNI_GEN] >= 5 )
		ch->pcdata->condition[iCond]	= URANGE( 0, condition + value, 400 );
	else if ( ch->pcdata->stats[UNI_GEN] == 6 )
  ch->pcdata->condition[iCond]    = URANGE( 0, condition + value, 333 ); 
else if ( ch->pcdata->stats[UNI_GEN] == 7 )
  ch->pcdata->condition[iCond]    = URANGE( 0, condition + value, 285 );
else if ( ch->pcdata->stats[UNI_GEN] == 8 )
  ch->pcdata->condition[iCond]    = URANGE( 0, condition + value, 250 );
else if ( ch->pcdata->stats[UNI_GEN] == 9 )
  ch->pcdata->condition[iCond]    = URANGE( 0, condition + value, 222 );
else if ( ch->pcdata->stats[UNI_GEN] == 10 )
  ch->pcdata->condition[iCond]    = URANGE( 0, condition + value, 200 );
else if ( ch->pcdata->stats[UNI_GEN] == 11 )
  ch->pcdata->condition[iCond]    = URANGE( 0, condition + value, 181 );
else if ( ch->pcdata->stats[UNI_GEN] == 12 )
  ch->pcdata->condition[iCond]    = URANGE( 0, condition + value, 166 );
else if ( ch->pcdata->stats[UNI_GEN] == 13 )
  ch->pcdata->condition[iCond]    = URANGE( 0, condition + value, 153 );	

}
*/
    if ( ch->pcdata->condition[iCond] == 0 )
    {
	switch ( iCond )
	{
	case COND_FULL:
	    if (!IS_CLASS(ch, CLASS_VAMPIRE))
	    {
		send_to_char( "You are REALLY hungry.\n\r",  ch );
		act( "You hear $n's stomach rumbling.", ch, NULL, NULL, TO_ROOM );
	    }
	    break;

	case COND_THIRST:
	    if (!IS_CLASS(ch, CLASS_VAMPIRE)) 
		send_to_char( "You are REALLY thirsty.\n\r", ch );
/*
	    else if (ch->hit > 0)
	    {
		send_to_char( "You are DYING from lack of blood!\n\r", ch );
		act( "$n gets a hungry look in $s eyes.", ch, NULL, NULL, TO_ROOM );
		ch->hit = ch->hit - number_range(2,5);
		if (number_percent() <= ch->beast && ch->beast > 0) vamp_rage(ch);
		if (!IS_VAMPAFF(ch, VAM_FANGS)) do_fangs(ch,"");
	    }
*/
	    break;

	case COND_DRUNK:
	    if ( condition != 0 )
		send_to_char( "You are sober.\n\r", ch );
	    break;
	}
    }
    else if ( ch->pcdata->condition[iCond] < 10 )
    {
	switch ( iCond )
	{
	case COND_FULL:
	    if (!IS_CLASS(ch, CLASS_VAMPIRE)) 
		send_to_char( "You feel hungry.\n\r",  ch );
	    break;

	case COND_THIRST:
	    if (!IS_CLASS(ch, CLASS_VAMPIRE)) 
		send_to_char( "You feel thirsty.\n\r", ch );
	    else
	    {
		send_to_char( "You crave blood.\n\r", ch );
		if (number_range(1,1000) <= ch->beast && ch->beast > 0) 
			vamp_rage(ch);
		if (number_percent() > (ch->pcdata->condition[COND_THIRST]+75)
		    && !IS_VAMPAFF(ch, VAM_FANGS)) do_fangs(ch,"");
	    }
	    break;
	}
    }

    return;
}





/*
 * Mob autonomous action.
 * This function takes 25% to 35% of ALL Merc cpu time.
 * -- Furey
 */
void mobile_update( void )
{
    CHAR_DATA *ch;
    CHAR_DATA *ch_next;
    EXIT_DATA *pexit;
    int door;

    /* Examine all mobs. */
    for ( ch = char_list; ch != NULL; ch = ch_next )
    {
	ch_next = ch->next;

	if ( ch->in_room == NULL ) continue;

	if( !IS_NPC(ch) && IS_CLASS(ch, CLASS_MAGE) )
	{
    if (ch->mageshields[mCHAOS][mTIME] <= 1 && ch->mageshields[mCHAOS][mON]) 
    {
       send_to_char("Your chaotic shield fades.\n\r", ch);
       ch->mageshields[mCHAOS][mON] = FALSE;
    }
    if (ch->mageshields[mPRIS][mTIME] <= 1 && ch->mageshields[mPRIS][mON]) 
    {
       send_to_char("The shadowy force surrounding you weakens.\n\r", ch);
       ch->mageshields[mPRIS][mON] = FALSE;
    }
    if (ch->mageshields[mBLADE][mON] && ch->mageshields[mBLADE][mTIME] <= 1) 
    {
	send_to_char("The blades arround you disinigrate.\n\r", ch);
	ch->mageshields[mBLADE][mON] = FALSE;
    }

    if (ch->mageshields[mBLADE][mTIME] > 0) ch->mageshields[mBLADE][mTIME]  -= 1;
    if (ch->mageshields[mCHAOS][mTIME] > 0) ch->mageshields[mCHAOS][mTIME]  -= 1;
    if (ch->mageshields[mPRIS][mTIME] > 0) ch->mageshields[mPRIS][mTIME] -= 1;
}

	if ( !IS_NPC(ch) )
	{
	    if (IS_CLASS(ch, CLASS_MONK) && ch->chi[CURRENT] > 6 )
		ch->chi[CURRENT] = 6;
	    if ( ch->max_hit < 500 )
		ch->max_hit = 500;
	    if ( ch->max_hit >= 65000 && ch->max_hit < 66000 )
		ch->max_hit = 66000;
	    if (!IS_CLASS(ch, CLASS_DEMON) && ch->in_room->vnum == 30000
&& ch->hit > 0 && !IS_IMMORTAL(ch))
	    {
	    send_to_char("Hellfire burns you!\n\r", ch);
	    ch->hit -= 20000;
	    }
            if (IS_CLASS(ch, CLASS_DEMON) && ch->in_room->vnum == 30010 && ch->hit > 0 &&
!IS_IMMORTAL(ch))
            {
            send_to_char("The Angelic Power hurts you!\n\r", ch);
            ch->hit -= 50000;
            }
	    if (ch->pcdata->condition[COND_DRUNK] > 10 && number_range(1,10) == 1)
	    {
		send_to_char("You hiccup loudly.\n\r",ch);
		act("$n hiccups.",ch,NULL,NULL,TO_ROOM);
	    }
	    if (ch->pcdata->stage[0] > 0 || ch->pcdata->stage[2] > 0)
	    {
		CHAR_DATA *vch;
		if (ch->pcdata->stage[1] > 0 && ch->pcdata->stage[2] >= 225)
		{
		    ch->pcdata->stage[2] += 1;
		    if ( ( vch = ch->pcdata->partner ) != NULL &&
			!IS_NPC(vch) && vch->pcdata->partner == ch &&
			((vch->pcdata->stage[2] >= 200 && vch->sex == SEX_FEMALE) ||
			(ch->pcdata->stage[2] >= 200 && ch->sex == SEX_FEMALE)))
		    {
			if (ch->in_room != vch->in_room) continue;
			if (vch->pcdata->stage[2] >= 225 &&
			    ch->pcdata->stage[2] >= 225 &&
			    vch->pcdata->stage[2] < 240 &&
			    ch->pcdata->stage[2] < 240)
			{
			    ch->pcdata->stage[2] = 240;
			    vch->pcdata->stage[2] = 240;
			}
			if (ch->sex == SEX_MALE && vch->pcdata->stage[2] >= 240)
			{
			    act("You thrust deeply between $N's warm, damp thighs.",ch,NULL,vch,TO_CHAR);
			    act("$n thrusts deeply between your warm, damp thighs.",ch,NULL,vch,TO_VICT);
			    act("$n thrusts deeply between $N's warm, damp thighs.",ch,NULL,vch,TO_NOTVICT);
			    if (vch->pcdata->stage[2] > ch->pcdata->stage[2])
				ch->pcdata->stage[2] = vch->pcdata->stage[2];
			}
			else if (ch->sex == SEX_FEMALE && vch->pcdata->stage[2] >= 240)
			{
			    act("You squeeze your legs tightly around $N, moaning loudly.",ch,NULL,vch,TO_CHAR);
			    act("$n squeezes $s legs tightly around you, moaning loudly.",ch,NULL,vch,TO_VICT);
			    act("$n squeezes $s legs tightly around $N, moaning loudly.",ch,NULL,vch,TO_NOTVICT);
			    if (vch->pcdata->stage[2] > ch->pcdata->stage[2])
				ch->pcdata->stage[2] = vch->pcdata->stage[2];
			}
		    }
		    if (ch->pcdata->stage[2] >= 250)
		    {
			if ( ( vch = ch->pcdata->partner ) != NULL &&
			    !IS_NPC(vch) && vch->pcdata->partner == ch &&
			    ch->in_room == vch->in_room)
			{
			    vch->pcdata->stage[2] = 250;
			    if (ch->sex == SEX_MALE)
			    {
				stage_update(ch,vch,2);
				stage_update(vch,ch,2);
			    }
			    else
			    {
				stage_update(vch,ch,2);
				stage_update(ch,vch,2);
			    }
			    ch->pcdata->stage[0] = 0;
			    vch->pcdata->stage[0] = 0;
			    if (!IS_EXTRA(ch, EXTRA_EXP))
			    {
				send_to_char("Congratulations on achieving a simultanious orgasm!  Recieve 1000000 exp!\n\r",ch);
				SET_BIT(ch->extra, EXTRA_EXP);
				ch->exp += 1000000;
			    }
			    if (!IS_EXTRA(vch, EXTRA_EXP))
			    {
				send_to_char("Congratulations on achieving a simultanious orgasm!  Recieve 1000000 exp!\n\r",vch);
				SET_BIT(vch->extra, EXTRA_EXP);
				vch->exp += 1000000;
			    }
			}
		    }
		}
		else
		{
		    if (ch->pcdata->stage[0] > 0 && ch->pcdata->stage[2] < 1 &&
			ch->position != POS_RESTING) 
		    {
			if (ch->pcdata->stage[0] > 1)
			    ch->pcdata->stage[0] -= 1;
			else
			    ch->pcdata->stage[0] = 0;
		    }
		    else if (ch->pcdata->stage[2]>0 && ch->pcdata->stage[0] < 1)
		    {
			if (ch->pcdata->stage[2] > 10)
			    ch->pcdata->stage[2] -= 10;
			else
			    ch->pcdata->stage[2] = 0;
			if (ch->sex == SEX_MALE && ch->pcdata->stage[2] == 0)
			    send_to_char("You feel fully recovered.\n\r",ch);
		    }
		}
	    }
	    
/* Ninja Michi - Loki */
		if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_NINJA) && IS_HERO(ch))
	    {
		if ( ch->position == POS_FIGHTING && ch->pcdata->stats[UNI_RAGE] > 0 
		    && ch->pcdata->stats[UNI_RAGE] < 200 && !IS_ITEMAFF(ch, ITEMA_RAGER) )
		    ch->pcdata->stats[UNI_RAGE] += 1;
		else if ( ch->position == POS_MEDITATING && ch->pcdata->stats[UNI_RAGE] > 0
		 	&& ch->pcdata->stats[UNI_RAGE] < 200 && !IS_ITEMAFF(ch, ITEMA_RAGER) )
		 	ch->pcdata->stats[UNI_RAGE] -= 20;
		else if (ch->pcdata->stats[UNI_RAGE] > 0 && !IS_ITEMAFF(ch, ITEMA_RAGER))
		    ch->pcdata->stats[UNI_RAGE] -= 1;
		if (ch->pcdata->stats[UNI_RAGE] < 1) continue;
		}
		
	    if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_VAMPIRE) && IS_HERO(ch))
	    {
		if ( ch->position == POS_FIGHTING && ch->pcdata->stats[UNI_RAGE] > 0 
		    && ch->pcdata->stats[UNI_RAGE] < 25 && !IS_ITEMAFF(ch, ITEMA_RAGER))
		    ch->pcdata->stats[UNI_RAGE] += 1;
		else if (ch->pcdata->stats[UNI_RAGE] > 0 && !IS_ITEMAFF(ch, ITEMA_RAGER))
                {
		        if (number_percent() <= ch->beast)
                        beast_rage(ch);
                    else
                        ch->pcdata->stats[UNI_RAGE]--;
                    if (ch->pcdata->stats[UNI_RAGE] < 1)  
                        send_to_char("You feel the beast release it's hold on you.\n\r",ch);
                }

		if (ch->pcdata->stats[UNI_RAGE] < 1) continue;
		if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana || 
		    ch->move < ch->max_move )
		    werewolf_regen(ch);
		if (ch->loc_hp[6] > 0)
		{
		    int sn = skill_lookup( "clot" );
		    (*skill_table[sn].spell_fun) (sn,ch->level,ch,ch);
		}
		else
		{
		    if ((ch->loc_hp[0] + ch->loc_hp[1] + ch->loc_hp[2] +
			ch->loc_hp[3] + ch->loc_hp[4] + ch->loc_hp[5]) != 0)
		    reg_mend(ch);
		}
	    }
	

else if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_WEREWOLF) && (IS_HERO(ch) ||
(IS_CLASS(ch, CLASS_DEMON) && (IS_SET(ch->warp, WARP_REGEN))))) 
	    {
		if (ch->position == POS_FIGHTING && (!IS_ITEMAFF(ch,
ITEMA_RAGER) || (IS_CLASS(ch, CLASS_DEMON) && (IS_SET(ch->warp,
WARP_REGEN))))) 
		{
		    if ( ch->gifts[AHROUN] >= 5 &&
(ch->pcdata->stats[UNI_RAGE] < 350  || (IS_CLASS(ch, CLASS_DEMON) &&
(IS_SET(ch->warp, WARP_REGEN))))) 
		        ch->pcdata->stats[UNI_RAGE] += number_range(2,3);
	            if ( ch->gifts[SHADOWLORDS] >= 5 &&
(ch->pcdata->stats[UNI_RAGE] <= 350  || (IS_CLASS(ch, CLASS_DEMON) &&
(IS_SET(ch->warp, WARP_REGEN))))) 
			ch->pcdata->stats[UNI_RAGE] += number_range(2,4);
		    if (ch->pcdata->stats[UNI_RAGE] < 300)
			ch->pcdata->stats[UNI_RAGE] += number_range(5,10);
		    if (!IS_SET(ch->special, SPC_WOLFMAN) && 
			(ch->pcdata->stats[UNI_RAGE] >= 100 ||
(IS_CLASS(ch, CLASS_DEMON) && (IS_SET(ch->warp, WARP_REGEN))))) 
			do_werewolf(ch,"");
		}
		else if (ch->pcdata->stats[UNI_RAGE] > 0 &&
(!IS_ITEMAFF(ch, ITEMA_RAGER) || (IS_CLASS(ch, CLASS_DEMON) &&
(IS_SET(ch->warp, WARP_REGEN)))))
		{
		    ch->pcdata->stats[UNI_RAGE] -= 1;
		    if (ch->pcdata->stats[UNI_RAGE] < 100)
do_unwerewolf(ch,"");
		}
		if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana || 
		    ch->move < ch->max_move )
 		    werewolf_regen(ch);

            
		if (IS_CLASS(ch,CLASS_WEREWOLF) && ch->position == POS_SLEEPING)
		{
		    if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana
|| 
			ch->move < ch->max_move )
			werewolf_regen(ch);
		    if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana
|| 
			ch->move < ch->max_move )
			werewolf_regen(ch);
		    if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana
|| 
			ch->move < ch->max_move )
			werewolf_regen(ch);
		    if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana
|| 
			ch->move < ch->max_move )
			werewolf_regen(ch);
		}
		if (ch->loc_hp[6] > 0)
		{
		    int sn = skill_lookup( "clot" );
		    (*skill_table[sn].spell_fun) (sn,ch->level,ch,ch);
		}
		else
		{
		    if ((ch->loc_hp[0] + ch->loc_hp[1] + ch->loc_hp[2] +
			ch->loc_hp[3] + ch->loc_hp[4] + ch->loc_hp[5]) !=
0)
		    reg_mend(ch);
		}
	    }	    
             else if (IS_CLASS(ch,CLASS_DROW))
             {

		 if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana  || ch->move < ch->max_move )
                    werewolf_regen(ch);
                if (ch->loc_hp[6] > 0)
                {   
                    int sn = skill_lookup( "clot" );
                    (*skill_table[sn].spell_fun) (sn,ch->level,ch,ch);  
                }
                else
                {
                    if ((ch->loc_hp[0] + ch->loc_hp[1] + ch->loc_hp[2] +
                        ch->loc_hp[3] + ch->loc_hp[4] + ch->loc_hp[5]) != 0)
                    reg_mend(ch);
                }
             }
            else if (((IS_CLASS(ch, CLASS_DEMON) || IS_SET(ch->special, SPC_CHAMPION)) && 
	IS_HERO(ch) && ch->in_room != NULL && ch->in_room->vnum == 30000) || ( (IS_CLASS(ch, CLASS_DROW) &&
	(IS_HERO(ch)) && (ch->in_room !=NULL) && (ch->in_room->vnum == 26000) ) || (ch->in_room->vnum == 26001) ||
	(IS_CLASS(ch, CLASS_ANGEL) && (IS_HERO(ch) && (ch->in_room !=NULL && (ch->in_room->vnum == 30010))))))
	    {
		if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana || 
		    ch->move < ch->max_move )
		    werewolf_regen(ch);
		if (ch->hit > 0)
		{
		    if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana || 
			ch->move < ch->max_move )
			werewolf_regen(ch);
		    if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana || 
			ch->move < ch->max_move )
			werewolf_regen(ch);
		    if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana || 
			ch->move < ch->max_move )
			werewolf_regen(ch);
		    if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana || 
			ch->move < ch->max_move )
			werewolf_regen(ch);
		}
		if (ch->loc_hp[6] > 0)
		{
		    int sn = skill_lookup( "clot" );
		    (*skill_table[sn].spell_fun) (sn,ch->level,ch,ch);
		}
		else
		{
		    if ((ch->loc_hp[0] + ch->loc_hp[1] + ch->loc_hp[2] +
			ch->loc_hp[3] + ch->loc_hp[4] + ch->loc_hp[5]) != 0)
		    reg_mend(ch);
		}
	    }

	    else if (IS_ITEMAFF(ch, ITEMA_REGENERATE) ||(!IS_NPC(ch) && (IS_CLASS(ch, CLASS_HIGHLANDER))))
	    {
		if ( ch->hit < ch->max_hit || ch->mana < ch->max_mana || 
		    ch->move < ch->max_move )
		    werewolf_regen(ch);
		if (ch->loc_hp[6] > 0)
		{
		    int sn = skill_lookup( "clot" );
		    (*skill_table[sn].spell_fun) (sn,ch->level,ch,ch);
		}
		else
		{
		    if ((ch->loc_hp[0] + ch->loc_hp[1] + ch->loc_hp[2] +
			ch->loc_hp[3] + ch->loc_hp[4] + ch->loc_hp[5]) != 0)
		    reg_mend(ch);
		}
	    }
	    continue;
	}

	if ( IS_AFFECTED(ch, AFF_CHARM) ) continue;

	/* Examine call for special procedure */
	if ( ch->spec_fun != 0 )
	{
	    if ( (*ch->spec_fun) ( ch ) )
		continue;
	    if (ch == NULL) continue;
	}

	/* That's all for sleeping / busy monster */
	if ( ch->position != POS_STANDING )
	    continue;

	/* Scavenge */
	if ( IS_SET(ch->act, ACT_SCAVENGER)
	&&   ch->in_room->contents != NULL
	&&   number_bits( 2 ) == 0 )
	{
	    OBJ_DATA *obj;
	    OBJ_DATA *obj_best;
	    int max;

	    max         = 1;
	    obj_best    = 0;
	    for ( obj = ch->in_room->contents; obj; obj = obj->next_content )
	    {
		if ( CAN_WEAR(obj, ITEM_TAKE) && obj->cost > max )
		{
		    obj_best    = obj;
		    max         = obj->cost;
		}
	    }

	    if ( obj_best )
	    {
		obj_from_room( obj_best );
		obj_to_char( obj_best, ch );
		act( "$n picks $p up.", ch, obj_best, NULL, TO_ROOM );
		act( "You pick $p up.", ch, obj_best, NULL, TO_CHAR );
	    }
	}

	/* Wander */
	if ( !IS_SET(ch->act, ACT_SENTINEL)
	&& ( door = number_bits( 5 ) ) <= 5
	&& ( pexit = ch->in_room->exit[door] ) != NULL
	&&   pexit->to_room != NULL
	&&   !IS_SET(pexit->exit_info, EX_CLOSED)
	&&   !IS_SET(pexit->to_room->room_flags, ROOM_NO_MOB)
	&& ( ch->hunting == NULL || strlen(ch->hunting) < 2 ) )
	{
	    if( !IS_SET( ch->act, ACT_STAY_AREA ) )
		    move_char( ch, door );
	    else if( IS_SET(ch->act, ACT_STAY_AREA ) 
		  && ch->in_room->area == pexit->to_room->area )
		move_char( ch, door );
	}

	/* Flee */
	if ( ch->hit < ch->max_hit / 2
	&& ( door = number_bits( 3 ) ) <= 5
	&& ( pexit = ch->in_room->exit[door] ) != NULL
	&&   pexit->to_room != NULL
	&&   !IS_AFFECTED(ch, AFF_WEBBED)
	&&   ch->level < 900
	&&   !IS_SET(pexit->exit_info, EX_CLOSED)
	&&   !IS_SET(pexit->to_room->room_flags, ROOM_NO_MOB) )
	{
	    CHAR_DATA *rch;
	    bool found;

	    found = FALSE;
	    for ( rch  = pexit->to_room->people;
		  rch != NULL;
		  rch  = rch->next_in_room )
	    {
		if ( !IS_NPC(rch) )
		{
		    found = TRUE;
		    break;
		}
	    }
	    if ( !found )
		move_char( ch, door );
	}

    }

    return;
}



/*
 * Update the moonphases
 */
void moon_update(void) {
	switch (time_info.day) {
		case 1: switch (time_info.hour) {
			case 12: weather_info.moonphase = MOON_NEW;
			break;
		} break;
		case 2: weather_info.moonphase = MOON_NEW; break;
		case 3: weather_info.moonphase = MOON_NEW; break;
		case 4: weather_info.moonphase = MOON_NEW; break;
		case 5: weather_info.moonphase = MOON_NEW; break;
		case 6: weather_info.moonphase = MOON_NEW; break;
		case 7: weather_info.moonphase = MOON_NEW; break;
		case 8: weather_info.moonphase = MOON_NEW; break;
		case 9: weather_info.moonphase = MOON_NEW; break;
		case 10: switch (time_info.hour) {
			case 12: weather_info.moonphase = MOON_CRESCENT;
			break;
		} break;
		case 11: weather_info.moonphase = MOON_CRESCENT; break;
		case 12: weather_info.moonphase = MOON_CRESCENT; break;
		case 13: weather_info.moonphase = MOON_CRESCENT; break;
		case 14: weather_info.moonphase = MOON_CRESCENT; break;
		case 15: weather_info.moonphase = MOON_CRESCENT; break;
		case 16: switch (time_info.hour) {
			case 12: weather_info.moonphase = MOON_HALF;
			break;
		} break;
		case 17: switch (time_info.hour) {
			case 12: weather_info.moonphase = MOON_GIBBOUS;
			break;
		} break;
		case 18: weather_info.moonphase = MOON_GIBBOUS; break;
		case 19: weather_info.moonphase = MOON_GIBBOUS; break;
		case 20: weather_info.moonphase = MOON_GIBBOUS; break;
		case 21: weather_info.moonphase = MOON_GIBBOUS; break;
		case 22: weather_info.moonphase = MOON_GIBBOUS; break;
		case 23: weather_info.moonphase = MOON_GIBBOUS; break;
		case 24: weather_info.moonphase = MOON_GIBBOUS; break;
		case 25: weather_info.moonphase = MOON_GIBBOUS; break;
		case 26: weather_info.moonphase = MOON_GIBBOUS; break;
		case 27: weather_info.moonphase = MOON_GIBBOUS; break;
		case 28: weather_info.moonphase = MOON_GIBBOUS; break;
		case 29: weather_info.moonphase = MOON_GIBBOUS; break;
		case 30: weather_info.moonphase = MOON_GIBBOUS; break;
		case 31: weather_info.moonphase = MOON_GIBBOUS; break;
		case 32: switch (time_info.hour) {
			case 12: weather_info.moonphase = MOON_FULL;
			break;
		} break;
		case 33: switch (time_info.hour) {
			case 12: weather_info.moonphase = MOON_WANING;
			break;
		} break;
		case 34: weather_info.moonphase = MOON_WANING; break; 
		case 35: weather_info.moonphase = MOON_WANING; break; 
	}
}



/*
 * Update the weather.
 */
void weather_update(void)
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *d;
    CHAR_DATA *ch = NULL;
     int diff, recover;
    bool char_up;
    bool mes_all = FALSE;

    strcpy(buf,"Bug - Please inform KaVir.\n\r");

    for (d = descriptor_list; d != NULL; d = d->next) {
		if (d->connected == CON_PLAYING
		&& (ch = d->character) != NULL
		&&  !IS_NPC(ch)
		&&  !IS_EXTRA(ch, EXTRA_OSWITCH)
		&&  !IS_HEAD(ch, LOST_HEAD)) {
/*
			if (IS_WEREWOLF(ch) && ch->pcdata->gnosis[0] < ch->pcdata->gnosis[1]) {
				ch->pcdata->gnosis[0] += number_range(5,10);
				if (ch->pcdata->gnosis[0] > ch->pcdata->gnosis[1]) 
					ch->pcdata->gnosis[0] = ch->pcdata->gnosis[1];
			}
			recover = number_range(5,10) + (ch->pcdata->willpower[1] * 0.1);
			if (ch->pcdata->willpower[0] < ch->pcdata->willpower[1])
			ch->pcdata->willpower[0] += recover;
			if (ch->pcdata->willpower[0] > ch->pcdata->willpower[1])
			ch->pcdata->willpower[0] = ch->pcdata->willpower[1];
			if (IS_MORE(ch, MORE_INFORM)) REMOVE_BIT(ch->more, MORE_INFORM);
*/
recover = number_range(5,10) + (ch->pcdata->willpower[1] * 0.1);
			if (ch->pcdata->willpower[0] <
ch->pcdata->willpower[1])
			ch->pcdata->willpower[0] += recover;
			if (IS_SET(ch->newbits, NEW_COURAGE) && number_percent() < 50) {
				send_to_char("You no longer feel quite so brave.\n\r",ch);
				REMOVE_BIT(ch->newbits, NEW_COURAGE);
			}
/*
			if (IS_MORE(ch, MORE_CALM) && number_percent() <
50) {
				send_to_char("You no longer feel so apathetic.\n\r",ch);
				REMOVE_BIT(ch->more, MORE_CALM);
			}
			if (IS_MORE(ch, MORE_ANGER) && number_percent()<50 && ch->pcdata->wolf<1) {
				send_to_char("You no longer feel so angry.\n\r",ch);
				REMOVE_BIT(ch->more, MORE_ANGER);
*/
			}
//		}
//	}

    if (IS_SET(sysdata.world, WORLD_ECLIPSE)) {
		REMOVE_BIT(sysdata.world, WORLD_ECLIPSE);
		mes_all = TRUE;
	} else if (IS_SET(sysdata.world, WORLD_FOG) && number_range(1,5) == 1) {
		REMOVE_BIT(sysdata.world, WORLD_FOG);
		mes_all = TRUE;
	} else if (IS_SET(sysdata.world, WORLD_RAIN) && number_range(1,5) == 1) {
		REMOVE_BIT(sysdata.world, WORLD_RAIN);
		mes_all = TRUE;
	}
    if (mes_all) 
{

		for (d = descriptor_list; d != NULL; d = d->next) {
			if (d->connected == CON_PLAYING
			&& (ch = d->character) != NULL
			&&  !IS_NPC(ch)
			&&  !IS_EXTRA(ch, EXTRA_OSWITCH)
			&&  !IS_HEAD(ch, LOST_HEAD)
			&&  ch->in_room != NULL
			&&  ch->in_room->sector_type != SECT_INSIDE
			&&  IS_OUTSIDE(ch))
                    continue;
		}
	}
    buf[0] = '\0';
    switch (++time_info.hour) {
		case  4:
		weather_info.moonlight = MOON_SET;
		break;

		case  5:
		weather_info.moonlight = MOON_DOWN;
		weather_info.time_of_day = MORNING;
		for (d = descriptor_list; d != NULL; d = d->next) {
			if (d->connected == CON_PLAYING
			&& (ch = d->character) != NULL
			&&  !IS_NPC(ch)
			&&  !IS_EXTRA(ch, EXTRA_OSWITCH)
			&&  !IS_HEAD(ch, LOST_HEAD)
			&& IS_CLASS(ch, CLASS_VAMPIRE))
                    continue;
		}
		break;

		case  6:
		weather_info.sunlight = SUN_RISE;
		break;
	        

		case 10:
		weather_info.time_of_day = DAY;
		break;

		case 12:
		break;

		case 17:
		weather_info.time_of_day = EVENING;
		break;	

		case 19:
		weather_info.sunlight = SUN_SET;
		break;

		case 20:
		weather_info.sunlight = SUN_DARK;
		break;

		case 21:
		weather_info.moonlight = MOON_RISE;
		weather_info.time_of_day = NIGHT;
		break;

		case 22: 
		weather_info.moonlight = MOON_UP;
		break;

		case 23:
		break;

		case 24:

		time_info.hour = 0;
		time_info.day++;
	for ( d = descriptor_list; d != NULL; d = d->next )
	{
	    char_up = FALSE;
	    if ( d->connected == CON_PLAYING
	    &&   (ch = d->character) != NULL
	    &&  !IS_NPC(ch))
	    {
	if (ch->fighting == NULL && !IS_SET(ch->newbits, NEW_NATURAL)
		 && ch->monkab[SPIRIT] >= 2 )
		  SET_BIT(ch->newbits, NEW_NATURAL);

		send_to_char( "You hear a clock in the distance strike midnight.\n\r",ch);
	 	if (IS_SET(ch->flag2, AFF2_ROT) && !IS_SET(ch->warp, WARP_INFIRMITY))
                {
                        send_to_char("Your flesh feels better.\n\r", ch);
                        REMOVE_BIT(ch->flag2, AFF2_ROT);
                        
                }
if ( IS_SET(ch->garou1, GAROU_PAWS) )
{
stc("You are no longer affected by paws of the newborn cub.\n\r",ch);
REMOVE_BIT(ch->garou1, GAROU_PAWS);
}
 if(IS_SET(ch->garou1,WOLF_QUICKSAND))
 {
   stc("You lose your concentration on the land around you.\n\r",ch);
   do_quicksand(ch,"");
 }

 if (IS_SET(ch->newbits,  NEW_VISCERAL))
                {
                        send_to_char("You feel the venom leave your body.\n\r", ch);
                        REMOVE_BIT(ch->newbits, NEW_VISCERAL);

                }
if (IS_SET(ch->newbits, NEW_VIOLATION))
{
stc("Your emotions return to normal.\n\r", ch);
REMOVE_BIT(ch->newbits, NEW_VIOLATION);
}

if (IS_SET(ch->flag2, AFF2_BALOR))
{
stc("You no longer feel the pain of Balor's Gaze.\n\r", ch);
REMOVE_BIT(ch->flag2, AFF2_BALOR);
}
                if (IS_SET(ch->in_room->room_flags, ROOM_SILENCE))
                {
                send_to_char("The silence leaves the room.\n\r",ch);
                act("The silence leaves the room.",ch,NULL,NULL,TO_ROOM);
                REMOVE_BIT(ch->in_room->room_flags,ROOM_SILENCE);
                
                }

                if (IS_SET(ch->in_room->room_flags,ROOM_FLAMING))
                {
                send_to_char("The flames in the room die down.\n\r",ch);
                act("The flames in the room die down.",ch,NULL,NULL,TO_ROOM);
                REMOVE_BIT(ch->in_room->room_flags,ROOM_FLAMING);
                }	
	
           if (!IS_NPC(ch))
		{
		    if (ch->hit < ch->max_hit)
		    { ch->hit = ch->max_hit; char_up = TRUE; }
		    if (ch->mana < ch->max_mana)
			{ ch->mana = ch->max_mana; char_up = TRUE; }
		    if (ch->move < ch->max_move)
			{ ch->move = ch->max_move; char_up = TRUE; }
		    if (char_up) send_to_char( "{CYou feel the power of The Gods flow through you.{x\n\r", ch);
		    ch->position = POS_STANDING;
		}
		    if (IS_EXTRA(ch, EXTRA_POTENCY))
		    { 
			send_to_char("You feel your blood potency fade away.\n\r", ch);	
			ch->pcdata->stats[UNI_GEN]++;
			REMOVE_BIT(ch->extra, EXTRA_POTENCY);
		    }

                    if (IS_SET(ch->newbits, NEW_TIDE))
 	            {
 		     REMOVE_BIT(ch->newbits, NEW_TIDE);
                     send_to_char("The tide of vitae leaves you.\n\r", ch);
		    }	    

}
	}
	break;
    }

    if ( time_info.day   >= 35 )
    {
	time_info.day = 0;
	time_info.month++;
    }

    if ( time_info.month >= 17 )
    {
	time_info.month = 0;
	time_info.year++;
    }



    /*
     * Weather change.
     */
    if (time_info.month >= 9 && time_info.month <= 16)
	diff = weather_info.mmhg >  985 ? -2 : 2;
    else
	diff = weather_info.mmhg > 1015 ? -2 : 2;

    weather_info.change   += diff * dice(1, 4) + dice(2, 6) - dice(2, 6);
    weather_info.change    = UMAX(weather_info.change, -12);
    weather_info.change    = UMIN(weather_info.change,  12);

    weather_info.mmhg += weather_info.change;
    weather_info.mmhg  = UMAX(weather_info.mmhg,  960);
    weather_info.mmhg  = UMIN(weather_info.mmhg, 1040);

    switch (weather_info.sky)
    {
    default: 
	bug("Weather_update: bad sky %d.", weather_info.sky);
	weather_info.sky = SKY_CLOUDLESS;
	break;

    case SKY_CLOUDLESS:
	if (weather_info.mmhg <  990
	|| (weather_info.mmhg < 1010 && number_bits(2) == 0))
	{
	    weather_info.sky = SKY_CLOUDY;
	}
	break;

    case SKY_CLOUDY:
	if (weather_info.mmhg <  970
	|| (weather_info.mmhg <  990 && number_bits(2) == 0))
	{
	    weather_info.sky = SKY_RAINING;
	}

	if (weather_info.mmhg > 1030 && number_bits(2) == 0)
	{
	    weather_info.sky = SKY_CLOUDLESS;
	}
	break;

    case SKY_RAINING:
	if (IS_SET(sysdata.world, WORLD_RAIN))
	{
	    if (weather_info.mmhg <  970)
		weather_info.mmhg += 10;
	    else if (weather_info.mmhg > 1010)
		weather_info.mmhg -= 10;
          break;
	}
	if (weather_info.mmhg <  970 && number_bits(2) == 0)
	{
	    weather_info.sky = SKY_LIGHTNING;
	}

	if (weather_info.mmhg > 1030
	|| (weather_info.mmhg > 1010 && number_bits(2) == 0))
	{
	    weather_info.sky = SKY_CLOUDY;
	}
	break;

    case SKY_LIGHTNING:
	if (weather_info.mmhg > 1010
	|| (weather_info.mmhg >  990 && number_bits(2) == 0))
	{
	    weather_info.sky = SKY_RAINING;
	    break;
	}
	break;
    }

    if (buf[0] != '\0')
    {
	for (d = descriptor_list; d != NULL; d = d->next)
	{
	    if (d->connected == CON_PLAYING
	    &&   IS_OUTSIDE(d->character)
	    &&   IS_AWAKE(d->character))
		send_to_char(buf, d->character);
	}
    }

    return;
}
}

/*
void embrace_update( void )
{
    DESCRIPTOR_DATA *d;
    CHAR_DATA       *ch;
    CHAR_DATA       *victim;
    char buf[MAX_STRING_LENGTH];
    for ( d = descriptor_list; d != NULL; d = d->next )
      {
      if ((ch = d->character) == NULL
        || IS_NPC(ch)
        || ch->embracing==NULL)
	{
            continue;
      }

	if (!IS_CLASS(ch,CLASS_VAMPIRE))
	  stop_embrace(ch,NULL);

	victim=ch->embracing;

	if (get_char_world(ch,victim->name) ==NULL)
	{stop_embrace(ch,NULL);continue;}

	if (ch->in_room != victim->in_room)
	  stop_embrace(ch,victim);

      if (IS_NPC(victim) )
      {
	  ch->pcdata->condition[COND_THIRST] += number_range(40,50);
        act("$N falls to the ground lifeless.",ch,NULL,victim,TO_CHAR);
        act("$N falls to the ground lifeless.",ch,NULL,victim,TO_ROOM);
        stop_embrace(ch,victim);
        raw_kill(victim, ch);
        return;
      }

	if (victim->pcdata->condition[COND_THIRST] < 0)
	  victim->pcdata->condition[COND_THIRST] = 0;

        ch->pcdata->condition[COND_THIRST] += number_range(30,40);
        sprintf(buf,"%s shudders in ecstacy as he drinks blood from %s's neck.\n\r",ch->name,victim->name);
	  act(buf,ch,NULL,NULL,TO_ROOM);
	  sprintf(buf,"You shudder in ecstacy as you drink blood from %s's neck.\n\r",victim->name);
	  send_to_char(buf,ch);
	  sprintf(buf,"You feel some of your life slip away as %s drinks from your neck.\n\r",ch->name);
	  send_to_char(buf,victim);
	  ch->pcdata->condition[COND_THIRST] += number_range(35,40);
	  victim->pcdata->condition[COND_THIRST] -= number_range(40,42);
	  if (ch->pcdata->condition[COND_THIRST] > 2000/ch->pcdata->stats[UNI_GEN])
	{ch->pcdata->condition[COND_THIRST]=2000/ch->pcdata->stats[UNI_GEN];
	  send_to_char("Your bloodlust is sated.\n\r",ch);}
	  if (victim->pcdata->condition[COND_THIRST] < 0)
	    victim->pcdata->condition[COND_THIRST]=0;

	  if (victim->pcdata->condition[COND_THIRST] ==0)
	  {
	    sprintf(buf,"You have been diablerized!\n\r");
	    send_to_char(buf,victim);
	    raw_kill(victim, ch);
	    sprintf(buf,"%s's body falls lifeless to the ground.\n\r",victim->name);
	    act(buf,ch,NULL,NULL,TO_ROOM);
	    send_to_char(buf,ch);
    	    stop_embrace(ch,victim);
  	    if (victim->pcdata->stats[UNI_GEN] < ch->pcdata->stats[UNI_GEN] && ch->pcdata->stats[UNI_GEN] > 3)
  	    {
		sprintf(buf,"%s has been diablerized by %s.",victim->name,ch->name);
  	      ch->pcdata->stats[UNI_GEN] -= 1;
  		victim->pcdata->stats[UNI_GEN] += 1;
  		victim->pcdata->condition[COND_THIRST]=0;
  		do_info(ch,buf);
	    }
  	else
  	{
  	  sprintf(buf,"%s has been diablerized by %s for no generation.", victim->name,ch->name);
  	  victim->pcdata->condition[COND_THIRST]=0;
  	  do_info(ch,buf);
  	}

}
continue; 
 
 
 
      }
    return;
}
*/


/*
 * Update all chars, including mobs.
 * This function is performance sensitive.
 */
void char_update( void )
{   
    CHAR_DATA *ch;
    CHAR_DATA *ch_next;
    CHAR_DATA *ch_save;
    CHAR_DATA *ch_quit;
    bool is_obj;
    bool drop_out = FALSE;
    time_t save_time;
    int i;

    save_time	= current_time;
    ch_save	= NULL;
    ch_quit	= NULL;

    for ( ch = char_list; ch != NULL; ch = ch_next )
    {
	AFFECT_DATA *paf;
	AFFECT_DATA *paf_next;

	ch_next = ch->next;

	if (!IS_NPC(ch) 
	    && (IS_HEAD(ch,LOST_HEAD) || IS_EXTRA(ch,EXTRA_OSWITCH)))
	    is_obj = TRUE;
	else if (!IS_NPC(ch) && ch->pcdata->obj_vnum != 0)
	{   is_obj = TRUE;
	    SET_BIT(ch->extra, EXTRA_OSWITCH);
	}
	else
	    is_obj = FALSE;



	/*
	 * Find dude with oldest save time.
	 */
	if ( !IS_NPC(ch)
	&& ( ch->desc == NULL || ch->desc->connected == CON_PLAYING )
	&&   ch->level >= 2
	&&   current_time - ch->save_time > (sysdata.save_frequency*60) )
	    ch_save	= ch;
	else
	    ch_save	= NULL;


	if (!IS_NPC(ch) 
	 && !IS_HERO(ch) 
         && ch->hit < 1 
         && ch->position != POS_FIGHTING)
	{
		char_from_room(ch);
		char_to_room(ch,get_room_index(ROOM_VNUM_ALTAR));
		act("The healer makes a few gestures and $n appears in the room.",ch,NULL,NULL,TO_ROOM);
		ch->hit = 1;
		update_pos(ch);
		send_to_char("You feel a little better.\n\r",ch);
		act("The healer says 'Are you ok $n?  Lucky I was here!'.",ch,NULL,NULL,TO_ROOM);
		act("The healer says 'Are you ok $n?  Lucky I was here!'.",ch,NULL,NULL,TO_CHAR);
	}

	if (!IS_NPC(ch)) 
		ch->exp = ch->exp + 1;

        if ( is_garou(ch) && ch->gifts[UKTENA] >= 2 && !IS_AFFECTED(ch, AFF_FLYING) )
	  SET_BIT(ch->affected_by, AFF_FLYING);
	if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_NINJA) 
  	   && ch->pcdata->powers[HARA_KIRI] > 0 )
	     ch->pcdata->powers[HARA_KIRI]--;

        if( !IS_NPC(ch) && IS_CLASS(ch,CLASS_MAGE) )
        {
            if ( ch->quint[BODY] < get_maxq(ch) )
                  ch->quint[BODY]++;
            if ( ch->quint[AVATAR] < get_maxq(ch) )
                  ch->quint[AVATAR]++;
        }

       if ( IS_SET(ch->garou1, GAROU_WHELP2) )
       {
	 if ( number_range( 1, 3 ) == 2 )
         {
	   REMOVE_BIT(ch->garou1, GAROU_WHELP2);
	   ch->max_hit += 1500;
           stc("Your body feels slightly stronger.\n\r",ch);
	   SET_BIT(ch->garou1, GAROU_WHELP1);
         }
       }
       if ( IS_SET(ch->garou1, GAROU_WHELP1) )
       {
         if (number_range(1,3) == 2 )
         {
	   REMOVE_BIT(ch->garou1, GAROU_WHELP1);
	   ch->max_hit += 1500;
           stc("You feel the Whelp's Curse leave your body.\n\r",ch);
         }
       }	

        if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_WEREWOLF))
        {
          if ( ch->position == POS_SLEEPING )
            ch->gnosis[GCURRENT] += number_range(10,20);
          else if ( ch->position == POS_RESTING )
            ch->gnosis[GCURRENT] += number_range(10,20);
          else if ( ch->position == POS_FIGHTING )
            ch->gnosis[GCURRENT] += 0;
          else
            ch->gnosis[GCURRENT] += number_range( 1, 8 );
	}

	if (ch->gnosis[GCURRENT] >  ch->gnosis[GMAXIMUM]) 
	      ch->gnosis[GCURRENT] = ch->gnosis[GMAXIMUM];

        if ( IS_CLASS(ch, CLASS_NINJA) && ch->pcdata->powers[NINJAKI] < 500 )
        {
            if ( ch->position == POS_MEDITATING )
            {
               ch->pcdata->powers[NINJAKI] += number_range( 50, 90 );
	       if ( ch->pcdata->powers[NINJAKI] > 500 )
	  	   ch->pcdata->powers[NINJAKI] = 500;
            }
        }

	if ( IS_SET(ch->mflags, MAGE_EMBRACED2) )
        {
          stc("The earth surrounding you starts to slowly crack.\n\r",ch);
	  SET_BIT(ch->mflags, MAGE_EMBRACED1);
          REMOVE_BIT(ch->mflags, MAGE_EMBRACED2);
        }
        else if ( IS_SET(ch->mflags, MAGE_EMBRACED1) )
        {
          stc("The earth surrounding you falls away.\n\r",ch);
          REMOVE_BIT(ch->mflags, MAGE_EMBRACED1);
        }


if ( IS_CLASS(ch, CLASS_VAMPIRE) && ch->beast > 0
	  && ch->pcdata->condition[COND_THIRST] <= 15 )
	{
	  act("You bare your fangs and scream in rage from lack of blood.",ch,NULL,NULL,TO_CHAR);
	  act("$n bares $s fangs and screams in rage.",ch,NULL,NULL,TO_ROOM);
          beast_rage(ch);
	  do_beastlike(ch,"");
	}

	  /* Add tick messages here..
	      if ( TIMER(ch, TIMER_WHATEVER) == 1 )
	        stc("Your whatever timer has worn off.\n\r",ch);
 	  */
	  if ( !IS_NPC(ch) )
          {
/* --> */
	  }

	if ( !IS_NPC(ch) )
	{
	  for ( i = 0; i < MAX_TIMER; i++ )
	    if ( ch->pcdata->tick_timer[i] > 0 ) ch->pcdata->tick_timer[i]--;
	}	

	if ( !IS_NPC(ch) && ch->level < LEVEL_IMMORTAL && !is_obj)
	{
	    OBJ_DATA *obj;

	    if ( ( ( obj = get_eq_char( ch, WEAR_WIELD ) ) != NULL
	    &&   obj->item_type == ITEM_LIGHT
	    &&   obj->value[2] > 0 )
	    || ( ( obj = get_eq_char( ch, WEAR_HOLD ) ) != NULL
	    &&   obj->item_type == ITEM_LIGHT
	    &&   obj->value[2] > 0 ) )
	    {
		if ( --obj->value[2] == 0 && ch->in_room != NULL )
		{
		    --ch->in_room->light;
		    act( "$p goes out.", ch, obj, NULL, TO_ROOM );
		    act( "$p goes out.", ch, obj, NULL, TO_CHAR );
		    obj_from_char( obj);
		    extract_obj( obj );
		}
	    }

	    if ( ++ch->timer >= 12)
	    {
		if ( ch->was_in_room == NULL && ch->in_room != NULL )
		{
		    ch->was_in_room = ch->in_room;
		    if ( ch->fighting != NULL )
			stop_fighting( ch, TRUE );
		    act( "$n disappears into the void.",
			ch, NULL, NULL, TO_ROOM );
		    send_to_char( "You disappear into the void.\n\r", ch );
		    save_char_obj( ch );
		    char_from_room( ch );
		    char_to_room( ch, get_room_index( ROOM_VNUM_LIMBO ) );
		}
	    }

	    if ( ch->timer > 30 ) ch_quit = ch;

	    gain_condition( ch, COND_DRUNK,  -1 );
	    if (!IS_CLASS(ch, CLASS_VAMPIRE))
	    {
	    	gain_condition( ch, COND_FULL, -1 );
	    	gain_condition( ch, COND_THIRST, -1 );
	    }
	    else
	    {
                if (ch->pcdata->condition[COND_THIRST] > 0) ch->pcdata->condition[COND_THIRST]--;
                if (ch->hit > 0 && ch->pcdata->condition[COND_THIRST] < 1)
                {
                    send_to_char( "You are DYING from lack of blood!\n\r", ch );
                    act( "$n gets a hungry look in $s eyes.", ch, NULL, NULL, TO_ROOM );
                    if (ch->hit > 0) ch->hit -= number_range(2,5);
                    update_pos(ch);
                    if (number_percent() <= ch->beast && ch->beast > 0) vamp_rage(ch);
                    if (!IS_VAMPAFF(ch, VAM_FANGS)) do_fangs(ch,"");
                }
                else if (ch->hit > 0 && ch->pcdata->condition[COND_THIRST] <= 20)
                {
                    send_to_char( "You crave blood.\n\r", ch );
                    if (number_range(1,1000) <= ch->beast && ch->beast > 0) vamp_rage(ch);
                    if (number_percent() > (ch->pcdata->condition[COND_THIRST]+75)
                        && !IS_VAMPAFF(ch, VAM_FANGS)) do_fangs(ch,"");
                }   
/*
		blood = -1;

		if (IS_POLYAFF(ch, POLY_ZULO)) blood -= number_range(30,40);
		if (ch->beast > 0)
		{
		    if (IS_VAMPAFF(ch, VAM_CLAWS)) blood -= number_range(1,3);
		    if (IS_VAMPAFF(ch, VAM_FANGS)) blood -= 1;
		    if (IS_VAMPAFF(ch, VAM_NIGHTSIGHT)) blood -= 1;
		    if (IS_VAMPAFF(ch, AFF_SHADOWSIGHT)) blood -= number_range(1,3);
		    if (IS_SET(ch->act, PLR_HOLYLIGHT)) blood -= number_range(1,5);
		    if (IS_VAMPAFF(ch, VAM_DISGUISED)) blood -= number_range(5,10);
		    if (IS_VAMPAFF(ch, VAM_CHANGED)) blood -= number_range(5,10);
		    if (IS_VAMPAFF(ch, IMM_SHIELDED)) blood -= number_range(1,3);
		    if (IS_POLYAFF(ch, POLY_SERPENT)) blood -= number_range(1,3);
		    if (ch->beast == 100) blood *= 2;
		}
		gain_condition( ch, COND_THIRST, blood );
*/
	    }


	}

	for ( paf = ch->affected; paf != NULL; paf = paf_next )
	{
	    paf_next	= paf->next;
	    if ( paf->duration > 0 )
		paf->duration--;
	    else if ( paf->duration < 0 )
		;
	    else
	    {
		if ( paf_next == NULL
		||   paf_next->type != paf->type
		||   paf_next->duration > 0 )
		{
		    if ( paf->type > 0 && skill_table[paf->type].msg_off && !is_obj)
		    {
			send_to_char( skill_table[paf->type].msg_off, ch );
			send_to_char( "\n\r", ch );
			if (IS_SET(ch->in_room->room_flags,
ROOM_TOTAL_DARKNESS)) REMOVE_BIT(ch->in_room->room_flags,
ROOM_TOTAL_DARKNESS);
		    }
		}
	  
		affect_remove( ch, paf );
	    }
	}

	/*
	 * Careful with the damages here,
	 *   MUST NOT refer to ch after damage taken,
	 *   as it may be lethal damage (on NPC).
	 */
	if ( ch->loc_hp[6] > 0 && !is_obj && ch->in_room != NULL )
	{
	    int dam = 0;
	    int minhit = 0;
	    if (!IS_NPC(ch)) minhit = -11;
	    if (IS_BLEEDING(ch,BLEEDING_HEAD) && (ch->hit-dam) > minhit )
	    {
		act( "A spray of blood shoots from the stump of $n's neck.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "A spray of blood shoots from the stump of your neck.\n\r", ch );
		dam += number_range(20,50);
	    }
	    if (IS_BLEEDING(ch,BLEEDING_THROAT) && (ch->hit-dam) > minhit )
	    {
		act( "Blood pours from the slash in $n's throat.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "Blood pours from the slash in your throat.\n\r", ch );
		dam += number_range(10,20);
	    }
	    if (IS_BLEEDING(ch,BLEEDING_ARM_L) && (ch->hit-dam) > minhit )
	    {
		act( "A spray of blood shoots from the stump of $n's left arm.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "A spray of blood shoots from the stump of your left arm.\n\r", ch );
		dam += number_range(10,20);
	    }
	    else if (IS_BLEEDING(ch,BLEEDING_HAND_L) && (ch->hit-dam) > minhit )
	    {
		act( "A spray of blood shoots from the stump of $n's left wrist.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "A spray of blood shoots from the stump of your left wrist.\n\r", ch );
		dam += number_range(5,10);
	    }
	    if (IS_BLEEDING(ch,BLEEDING_ARM_R) && (ch->hit-dam) > minhit )
	    {
		act( "A spray of blood shoots from the stump of $n's right arm.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "A spray of blood shoots from the stump of your right arm.\n\r", ch );
		dam += number_range(10,20);
	    }
	    else if (IS_BLEEDING(ch,BLEEDING_HAND_R) && (ch->hit-dam) > minhit )
	    {
		act( "A spray of blood shoots from the stump of $n's right wrist.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "A spray of blood shoots from the stump of your right wrist.\n\r", ch );
		dam += number_range(5,10);
	    }
	    if (IS_BLEEDING(ch,BLEEDING_LEG_L) && (ch->hit-dam) > minhit )
	    {
		act( "A spray of blood shoots from the stump of $n's left leg.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "A spray of blood shoots from the stump of your left leg.\n\r", ch );
		dam += number_range(10,20);
	    }
	    else if (IS_BLEEDING(ch,BLEEDING_FOOT_L) && (ch->hit-dam) > minhit )
	    {
		act( "A spray of blood shoots from the stump of $n's left ankle.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "A spray of blood shoots from the stump of your left ankle.\n\r", ch );
		dam += number_range(5,10);
	    }
	    if (IS_BLEEDING(ch,BLEEDING_LEG_R) && (ch->hit-dam) > minhit )
	    {
		act( "A spray of blood shoots from the stump of $n's right leg.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "A spray of blood shoots from the stump of your right leg.\n\r", ch );
		dam += number_range(10,20);
	    }
	    else if (IS_BLEEDING(ch,BLEEDING_FOOT_R) && (ch->hit-dam) > minhit )
	    {
		act( "A spray of blood shoots from the stump of $n's right ankle.", ch, NULL, NULL, TO_ROOM );
		send_to_char( "A spray of blood shoots from the stump of your right ankle.\n\r", ch );
		dam += number_range(5,10);
	    }
	    if (IS_HERO(ch)) { ch->hit = ch->hit - dam;
		if (ch->hit < 1) ch->hit = 1; }
	    else ch->hit = ch->hit - dam;
	    update_pos(ch);
	    ch->in_room->blood += dam;
	    if (ch->in_room->blood > 1000) ch->in_room->blood = 1000;
	    if (ch->hit <=-11 || (IS_NPC(ch) && ch->hit < 1))
	    {


		do_killperson(ch,ch->name);
		drop_out = TRUE;
	    }
	}
	
if (IS_SET(ch->newbits, NEW_VISCERAL) && !is_obj && !drop_out)
{
	 int dam;
         if (IS_NPC(ch)) break;
         act( "$n winces in pain.", ch, NULL, NULL, TO_ROOM);
         send_to_char( "You wince in pain as venom spreads throughout your system.\n\r", ch);
         dam = number_range(250,500);
	 ch->hit = ch->hit - dam;
         update_pos(ch);
         if (ch->hit < -10)
         {
            do_killperson(ch,ch->name);
            drop_out = TRUE;
         }
        }
	if (IS_SET(ch->flag2,AFF2_ROT) && !is_obj && !drop_out)
	{
	 int dam;
	 if (IS_NPC(ch)) break;
         act( "$n's flesh shrivels and tears.", ch, NULL, NULL, TO_ROOM);
	 send_to_char( "Your flesh shrivels and tears.\n\r", ch);
         dam = number_range(250,500);
         ch->hit = ch->hit - dam;
         update_pos(ch);
         if (ch->hit < -10)
         {
            do_killperson(ch,ch->name);
            drop_out = TRUE;
         }
        }


 if (IS_SET(ch->flag2,AFF2_BALOR) && !is_obj && !drop_out) 
     {
         int dam;
         if (IS_NPC(ch)) break;
         act( "$n scream in pain as his body is torn apart from the inside out!", ch, NULL, NULL, TO_ROOM);
         send_to_char( "You scream in pain as your body is torn apart from the inside out.\n\r", ch);
         dam = number_range(250,500);
         ch->hit = ch->hit - dam;
         update_pos(ch);
         if (ch->hit < -10)
         {
            do_killperson(ch,ch->name);
            drop_out = TRUE;
         }
        }


	if ( IS_AFFECTED(ch, AFF_FLAMING) && !is_obj && !drop_out && ch->in_room != NULL )
	{
	    int dam;
	    if (!IS_NPC(ch) && IS_HERO(ch)) break;
	    if (!IS_NPC(ch) && IS_IMMUNE(ch, IMM_HEAT) &&
		!IS_CLASS(ch, CLASS_VAMPIRE)) break;
	    act( "$n's flesh burns and crisps.", ch, NULL, NULL, TO_ROOM );
	    send_to_char( "Your flesh burns and crisps.\n\r", ch );
	    dam = number_range(10,20);
	    if (!IS_NPC(ch) && IS_IMMUNE(ch, IMM_HEAT)) dam /= 2;
	    if (!IS_NPC(ch) && IS_CLASS(ch, CLASS_VAMPIRE)) dam *= 2;
	    ch->hit = ch->hit - dam;
	    update_pos(ch);
	    if (ch->hit <=-11)
	    {
		do_killperson(ch,ch->name);
		drop_out = TRUE;
	    }
	}
	else if ( IS_CLASS(ch, CLASS_VAMPIRE) && (!IS_AFFECTED(ch,AFF_SHADOWPLANE)) &&
	    (!IS_NPC(ch) && !IS_IMMUNE(ch,IMM_SUNLIGHT)) && ch->in_room != NULL &&
	    (!ch->in_room->sector_type == SECT_INSIDE) && !is_obj &&
	    (!room_is_dark(ch->in_room)) && (weather_info.sunlight != SUN_DARK) )
	{
	    act( "$n's flesh smolders in the sunlight!", ch, NULL, NULL, TO_ROOM );
	    send_to_char( "Your flesh smolders in the sunlight!\n\r", ch );
	    /* This one's to keep Zarkas quiet ;) */
	    if (IS_POLYAFF(ch, POLY_SERPENT))
	    	ch->hit = ch->hit - number_range(2,4);
	    else
	    	ch->hit = ch->hit - number_range(5,10);
	    update_pos(ch);
	    if (ch->hit <=-11)
	    {
		do_killperson(ch,ch->name);
		drop_out = TRUE;
	    }
	}
	else if ( IS_AFFECTED(ch, AFF_POISON) && !is_obj && !drop_out )
	{
	    act( "$n shivers and suffers.", ch, NULL, NULL, TO_ROOM );
	    send_to_char( "You shiver and suffer.\n\r", ch );
	    damage( ch, ch, 2, gsn_poison );
	}
	else if ( !IS_NPC( ch ) && ch->paradox[1] > 0 )
	{
	    if ( ch->paradox[1] > 2999 /* lower to 2 to add paradox - Vic */ ) paradox( ch );
	    else if ( ch->paradox[2] == 0 && ch->paradox[1] > 0 )
	    {
		ch->paradox[1] --;
		ch->paradox[2] = PARADOX_TICK;
	    }
	    else ch->paradox[3] --;
	}
/*
	else if ( ch->position == POS_INCAP && !is_obj && !drop_out )
	{
	    if (ch->level > 0)
                ch->hit = ch->hit + number_range(2,4);
	    else
                ch->hit = ch->hit - number_range(1,2);
	    update_pos( ch );
            if (ch->position > POS_INCAP)
            {
                act( "$n's wounds stop bleeding and seal up.", ch, NULL, NULL, TO_ROOM );
                send_to_char( "Your wounds stop bleeding and seal up.\n\r", ch );
            }
            if (ch->position > POS_STUNNED)
            {
                act( "$n clambers back to $s feet.", ch, NULL, NULL, TO_ROOM );
                send_to_char( "You clamber back to your feet.\n\r", ch );
            }
	}

	if ( ch->position == POS_MORTAL && !is_obj && !drop_out )
	{
	    drop_out = FALSE;
	    if (ch->level > 0)//right here also
                ch->hit = ch->hit + number_range(2,4);
//recommented by sage
	    else
	    {
                ch->hit = ch->hit - number_range(1,2);
		if (!IS_NPC(ch) && (ch->hit <=-11))
		    do_killperson(ch,ch->name);
		drop_out = TRUE;
	    }
	    if (!drop_out)
	    {
	    	update_pos( ch );
// lala
            	if (ch->position == POS_INCAP)
            	{
                    act( "$n's wounds begin to close, and $s bones pop back into place.", ch, NULL, NULL, TO_ROOM );
                    send_to_char( "Your wounds begin to close, and your bones pop back into place.\n\r", ch );
            	}
	    }
	}
*/
	if ( ch->position == POS_DEAD && !is_obj && !drop_out )
	{
	   update_pos(ch);
	   if (!IS_NPC(ch))
		do_killperson(ch,ch->name);
	}
	drop_out = FALSE;
    }
/*

//new regen shit hope it works? SAGE
	else if ( ch->position == POS_INCAP && !is_obj && !drop_out )
	{
	    if (IS_HERO(ch))
                ch->hit = ch->hit + number_range(2,4);
	    else
                ch->hit = ch->hit - number_range(1,2);
	    update_pos( ch );
            if (ch->position > POS_INCAP)
            {
                act( "$n's wounds stop bleeding and seal up.", ch, NULL,
NULL, TO_ROOM );
                send_to_char( "Your wounds stop bleeding and seal up.\n\r", ch );
            }
            if (ch->position > POS_STUNNED)
            {
                act( "$n clambers back to $s feet.", ch, NULL, NULL,
TO_ROOM );
                send_to_char( "You clamber back to your feet.\n\r", ch );
            }
	}
	else if ( ch->position == POS_MORTAL && !is_obj && !drop_out )
	{
	    drop_out = FALSE;
	    if (IS_HERO(ch))
                ch->hit = ch->hit + number_range(2,4);
	    else
	    {
                ch->hit = ch->hit - number_range(1,2);
		if ((!IS_NPC(ch) && ch->hit<-10) || (IS_NPC(ch) &&
ch->hit<0))
		{
		    ch->fatal = 16;
		killperson(ch,ch);	    
	//do_killperson(ch,ch);
		    continue;
		}
	    }
	    if (!drop_out)
	    {
	    	update_pos( ch );
            	if (ch->position == POS_INCAP)
            	{
                    act( "$n's wounds begin to close, and $s bones pop back into place.", ch, NULL, NULL, TO_ROOM );
                    send_to_char( "Your wounds begin to close, and your bones pop back into place.\n\r", ch );
            	}
	    }
	}
	else if ( ch->position == POS_DEAD && !is_obj && !drop_out )
	{
	    if (!IS_NPC(ch)) 
	    {
//		ch->form = 16;
		killperson(ch,ch);
		//do_killperson(ch,ch);
		continue;
	    }
	}
	drop_out = FALSE;
    }
*/
    /*
     * Autosave and autoquit.
     * Check that these chars still exist.
     */
    if ( ch_save != NULL || ch_quit != NULL )
    {
	for ( ch = char_list; ch != NULL; ch = ch_next )
	{
	    ch_next = ch->next;
	    if ( ch == ch_save )
		save_char_obj( ch );
	    if ( ch == ch_quit )
		do_quit( ch, "" );
	}
    }

    return;
}


void quest( void )
{
    static const sh_int rvnum[] =
    {
         109,  2210, 19192, 2396, 2429, 1477, 7900,  601,
        9103, 25008,   931, 9326, 9236, 2103, 2350
    };
    static const sh_int ovnum[] =
    {
	200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
	210, 211
    };
    static const sh_int mvnum[] =
    {
	200, 201
    };
    OBJ_DATA *obj;
    CHAR_DATA *ch;
    int rrandom;
    int orandom;
    int mrandom;

    rrandom = number_range(0,14);
    orandom = number_range(0,11);
    mrandom = number_range(0,1);
    obj = create_object(get_obj_index(ovnum[orandom]),100);
    ch = create_mobile(get_mob_index(mvnum[mrandom]));
    obj_to_char(obj,ch);
    char_to_room(ch,get_room_index(rvnum[rrandom]));
    SET_BIT(ch->special,SPC_NOFIND);
    SET_BIT(obj->quest,ITEM_EQUEST);
    obj->cost = 15;

    return;
}




void obj_check(OBJ_DATA *obj, OBJ_DATA *obj_next)
{
        if (obj == object_list)
        {
          extract_obj(obj);
	  if (obj_next != NULL)
               obj_next = object_list;
        }
        else
        {
          OBJ_DATA *oldobj;
 
          for (oldobj = object_list; oldobj; oldobj = oldobj->next)
            if (oldobj->next == obj) 
		break;

          if (!oldobj)
          {
            bug("obj_check: obj %d not a valid object, Uh oh.", 
			obj->pIndexData->vnum);
            return;
          }
          extract_obj(obj); 
	  if (obj_next != NULL)
          	obj_next = oldobj->next;
        }
}

void obj_update( void )
{   
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;

    for ( obj = object_list; obj != NULL; obj = obj_next )
    {
	CHAR_DATA *rch;
	char *message;

	obj_next = obj->next;

	if ( IS_SET(obj->quest, QUEST_ARTIFACT ) 
	    && obj->carried_by
	    && ( obj->wear_loc == WEAR_WIELD || obj->wear_loc == WEAR_HOLD )
	    && strlen( obj->chpoweruse ) > 3 
	    && !obj->carried_by->fighting
	    && number_percent() < 2 
	    && number_percent() < 2)
	    kavitem( obj->chpoweruse, obj->carried_by, obj, NULL, TO_CHAR );
	if( obj->pIndexData->vnum == 29504 
	   && obj->carried_by != NULL )
	{
	   CHAR_DATA *ch;
	   ch = obj->carried_by;
	   ch->hit += UMIN(ch->max_hit, ch->hit + 1000 );
	   ch->mana += UMIN(ch->max_mana, ch->mana + 1000 );
	   ch->move += UMIN(ch->max_move, ch->move + 1000 );
	}

	if ( obj->timer <= 0 || --obj->timer > 0 )
	    continue;

	switch ( obj->item_type )
	{
	default:              message = "$p vanishes.";         		break;
	case ITEM_WGATE:      message = "$p vanishes in a burst of energy.";	break;
	case ITEM_FOUNTAIN:   message = "$p dries up.";         		break;
	case ITEM_CORPSE_NPC: message = "$p decays into dust."; 		break;
	case ITEM_CORPSE_PC:  message = "$p decays into dust."; 		break;
	case ITEM_FOOD:       message = "$p decomposes.";			break;
	case ITEM_TRASH:      message = "$p crumbles into dust.";		break;
	case ITEM_EGG:        message = "$p cracks open.";			break;
	case ITEM_WEAPON:     message = "The poison on $p melts through it.";	break;
	}

	if ( obj->carried_by != NULL )
	{
	    act( message, obj->carried_by, obj, NULL, TO_CHAR );
	}
	else if ( obj->in_room != NULL
	&&      ( rch = obj->in_room->people ) != NULL )
	{
	    act( message, rch, obj, NULL, TO_ROOM );
	    act( message, rch, obj, NULL, TO_CHAR );
	}

	/* If the item is an egg, we need to create a mob and shell!
	 * KaVir
	 */
	if ( obj->item_type == ITEM_EGG )
	{
	    CHAR_DATA      *creature;
	    OBJ_DATA       *egg;
	    if ( get_mob_index( obj->value[0] ) != NULL )
	    {
		if (obj->carried_by != NULL && obj->carried_by->in_room != NULL)
		{
	    	    creature = create_mobile( get_mob_index( obj->value[0] ) );
		    char_to_room(creature,obj->carried_by->in_room);
		}
		else if (obj->in_room != NULL)
		{
	    	    creature = create_mobile( get_mob_index( obj->value[0] ) );
		    char_to_room(creature,obj->in_room);
		}
		else
		{
	    	    creature = create_mobile( get_mob_index( obj->value[0] ) );
		    char_to_room(creature,get_room_index(ROOM_VNUM_HELL));
/*
		    obj->timer = 1;
		    continue;
*/
		}
	    	egg = create_object( get_obj_index( OBJ_VNUM_EMPTY_EGG ), 0 );
	    	egg->timer = 2;
	    	obj_to_room( egg, creature->in_room );
	    	act( "$n clambers out of $p.", creature, obj, NULL, TO_ROOM );
	    }
	    else if (obj->in_room != NULL)
	    {
	    	egg = create_object( get_obj_index( OBJ_VNUM_EMPTY_EGG ), 0 );
	    	egg->timer = 2;
	    	obj_to_room( egg, obj->in_room );
	    }
	}
//	obj_check( obj, obj_next );
	if (obj != NULL) extract_obj( obj );
    }

    return;
}



/*
 * Aggress.
 *
 * for each mortal PC
 *     for each mob in room
 *         aggress on some random PC
 *
 * This function takes 25% to 35% of ALL Merc cpu time.
 * Unfortunately, checking on each PC move is too tricky,
 *   because we don't want the mob to just attack the first PC
 *   who leads the party into the room.
 *
 * -- Furey
 */
void aggr_update( void )
{
    CHAR_DATA *wch;
    CHAR_DATA *wch_next;
    CHAR_DATA *ch;
    CHAR_DATA *ch_next;
    CHAR_DATA *vch;
    CHAR_DATA *vch_next;
    CHAR_DATA *victim = NULL;

    OBJ_DATA *obj = NULL;
    OBJ_DATA *chobj = NULL;
    ROOM_INDEX_DATA *objroom = NULL;
    DESCRIPTOR_DATA *d;

    for ( d = descriptor_list; d != NULL; d = d->next )
    {
/*
	if ( d->connected == CON_PLAYING
	&& ( ch = d->character ) != NULL
	&&   !IS_NPC(ch)
	&&   ch->pcdata->stage[1] > 0
	&& ( victim = ch->pcdata->partner ) != NULL
	&&   !IS_NPC(victim)
	&&   ch->in_room != NULL
	&&   victim->in_room != NULL
	&&   victim->in_room != ch->in_room )
	{
	    ch->pcdata->stage[1] = 0;
	    victim->pcdata->stage[1] = 0;
	}
*/
	if ( d->connected == CON_PLAYING
	&& ( ch = d->character ) != NULL
	&&   !IS_NPC(ch)
	&&   ch->pcdata != NULL
	&& ( obj = ch->pcdata->chobj ) != NULL )
	{
	    if (obj->in_room != NULL)
	    	objroom = obj->in_room;
	    else if (obj->in_obj != NULL)
	    	objroom = get_room_index(ROOM_VNUM_IN_OBJECT);
	    else if (obj->carried_by != NULL)
	    {
		if (obj->carried_by != ch && obj->carried_by->in_room != NULL)
		    objroom = obj->carried_by->in_room;
		else continue;
	    }
	    else continue;
	    if (ch->in_room != objroom && objroom != NULL)
	    {
	    	char_from_room(ch);
	    	char_to_room(ch,objroom);
		do_look(ch,"auto");
	    }
	}
	else if ( d->connected == CON_PLAYING
	&& ( ch = d->character ) != NULL
	&&   !IS_NPC(ch)
	&&   ch->pcdata != NULL
	&&   (IS_HEAD(ch,LOST_HEAD) || IS_EXTRA(ch,EXTRA_OSWITCH) || ch->pcdata->obj_vnum != 0) )
	{
	    if (ch->pcdata->obj_vnum != 0)
	    {
		bind_char(ch);
		continue;
	    }
	    if (IS_HEAD(ch,LOST_HEAD))
	    {
	    	REMOVE_BIT(ch->loc_hp[0],LOST_HEAD);
	    	send_to_char("You are able to regain a body.\n\r",ch);
	    	ch->position = POS_RESTING;
	    	ch->hit = 1;
	    } else {
	    	send_to_char("You return to your body.\n\r",ch);
		REMOVE_BIT(ch->extra,EXTRA_OSWITCH);}
	    REMOVE_BIT(ch->affected_by,AFF_POLYMORPH);
	    free_string(ch->morph);
	    ch->morph = str_dup("");
	    char_from_room(ch);
	    char_to_room(ch,get_room_index(ROOM_VNUM_ALTAR));
	    if ( ( chobj = ch->pcdata->chobj ) != NULL )
		chobj->chobj = NULL;
	    ch->pcdata->chobj = NULL;
	    do_look(ch,"auto");
	}
	continue;
    }

    for ( wch = char_list; wch != NULL; wch = wch_next )
    {
	wch_next = wch->next;
	if ( IS_NPC(wch)
	|| ( wch->desc != NULL && wch->desc->connected != CON_PLAYING )
	||   wch->position <= POS_STUNNED
	||   wch->level >= LEVEL_IMMORTAL
	||   wch->pcdata == NULL
	|| ( ( chobj = wch->pcdata->chobj ) != NULL )
	||   wch->in_room == NULL )
	    continue;

	if ( (IS_CLASS(wch, CLASS_WEREWOLF) && IS_HERO(wch)) ||
	    IS_ITEMAFF(wch, ITEMA_STALKER) )
	{
	    if ( wch->hunting != NULL && wch->hunting != '\0' && 
		strlen(wch->hunting) > 1 && wch->pcdata->powers[WPOWER_LYNX] > 1)
	    {
		ROOM_INDEX_DATA *old_room = wch->in_room;
		check_hunt( wch );
		if (wch->in_room == old_room)
		{
		    free_string(wch->hunting);
		    wch->hunting = str_dup( "" );
		    continue;
		}
		check_hunt( wch );
		if (wch->in_room == old_room)
		{
		    free_string(wch->hunting);
		    wch->hunting = str_dup( "" );
		}
		continue;
	    }
	}

	for ( ch = wch->in_room->people; ch != NULL; ch = ch_next )
	{
	    int count;

	    ch_next	= ch->next_in_room;

	    if ( !IS_NPC(ch)
	    ||   !IS_SET(ch->act, ACT_AGGRESSIVE)
	    ||   no_attack(ch, wch)
	    ||   ch->fighting != NULL
	    ||   IS_AFFECTED(ch, AFF_CHARM)
	    ||   !IS_AWAKE(ch)
	    ||   ( IS_SET(ch->act, ACT_WIMPY) && IS_AWAKE(wch) )
	    ||   !can_see( ch, wch ) )
		continue;

	    /*
	     * Ok we have a 'wch' player character and a 'ch' npc aggressor.
	     * Now make the aggressor fight a RANDOM pc victim in the room,
	     *   giving each 'vch' an equal chance of selection.
	     */
	    count	= 0;
	    victim	= NULL;
	    for ( vch = wch->in_room->people; vch != NULL; vch = vch_next )
	    {
		vch_next = vch->next_in_room;

		if ( !IS_NPC(vch)
		&&   !no_attack(ch, vch)
		&&   vch->pcdata != NULL
		&& ( ( chobj = vch->pcdata->chobj ) == NULL )
		&&   vch->level < LEVEL_IMMORTAL
		&&   vch->position > POS_STUNNED
		&&   ( !IS_SET(ch->act, ACT_WIMPY) || !IS_AWAKE(vch) )
		&&   can_see( ch, vch ) )
		{
		    if ( number_range( 0, count ) == 0 )
			victim = vch;
		    count++;
		}
	    }

	    if ( victim == NULL )
	    {
		continue;
	    }
	    if ( is_garou(victim) && victim->gifts[PHILODOX] >= 2 )
	        continue;

	    multi_hit( ch, victim, TYPE_UNDEFINED );
	}
    }

    return;
}


/*added by sage for embrace*/

void embrace_update( void )
{
    DESCRIPTOR_DATA *d;
    CHAR_DATA       *ch;
    CHAR_DATA       *victim;
    int blpr;  /* variable to check for amout of blood sucked. Shakti */
    char buf[MAX_STRING_LENGTH];
               int chargen;
                int maxblood;

    for ( d = descriptor_list; d != NULL; d = d->next )
    {
      
      if ( ( ch = d->character) == NULL )
	continue;

    if ( IS_CLASS(ch, CLASS_MONK) && ch->fighting == NULL )
        ch->monkblock = 0;
    
      if ( !IS_NPC(ch) && IS_CLASS(ch, CLASS_MONK)
          && ch->focus[MAXIMUM] > 0 && ch->focus[MAXIMUM] > ch->focus[CURRENT] )
        {
          if ( ch->position == POS_SLEEPING )
            ch->focus[CURRENT] += number_range(1, 10);
          else if ( ch->position == POS_MEDITATING )
            ch->focus[CURRENT] += number_range( 4, 5 );
          else if ( ch->position == POS_RESTING )
            ch->focus[CURRENT] += number_range(1,9);
          else if ( ch->position == POS_FIGHTING )
            ch->focus[CURRENT] += 0;
          else
            ch->focus[CURRENT] += number_range( 1, 8 );
        }
      if ( IS_CLASS(ch, CLASS_MONK) && ch->focus[CURRENT] > ch->focus[MAXIMUM])    
         ch->focus[CURRENT] = ch->focus[MAXIMUM];
 
      if ( IS_NPC(ch) || ch->embracing == NULL )
        continue;

	if (!IS_CLASS(ch,CLASS_VAMPIRE))
	  stop_embrace(ch,NULL);

	victim=ch->embracing;


	if (IS_NPC(victim) )
	{
		if (victim->level > 75 )
		{
			stop_embrace(ch,victim);
			send_to_char("You cannot embrace someone so powerful!\n\r",ch);
			return;
		}
		
	
		(blpr =number_range(30,40));
		victim->practice -=blpr;
		ch->pcdata->condition[COND_THIRST] +=blpr;
		
		sprintf(buf, "%s shudders in ecstacy as he drinks blood from %s's neck.\n\r", ch->name,victim->short_descr);
	    act(buf,ch,NULL,NULL,TO_ROOM);
	    sprintf(buf, "You shudder in ecstacy as you drink blood from %s's neck.\n\r",victim->short_descr);
	    send_to_char(buf,ch);
/*	    
		if ( ch->pcdata->condition[COND_THIRST] >
		    (2000 / ch->pcdata->stats[UNI_GEN]) )

		{
		  stc("Your blood thirst is sated.\n\r",ch);
		  ch->pcdata->condition[COND_THIRST] = (2000/ch->pcdata->stats[UNI_GEN]);
                }
*/
               chargen = ch->pcdata->stats[UNI_GEN];
                if (chargen > 12)
                        chargen = 12;
                maxblood = (13 - chargen) * 100;
                if (ch->pcdata->condition[COND_THIRST] >= maxblood)
                        send_to_char( "Your blood thirst is sated.\n\r", ch);
        
                ch->pcdata->condition[COND_THIRST] = maxblood;
                    
		if (victim->practice < 0)
		{
			victim->practice = 0;
		}

		if (victim->practice == 0)
		
		{
	     raw_kill(victim, ch);
	     sprintf(buf,"%s's body falls lifless to the ground!.\n\r",victim->short_descr);
	     act(buf,ch,NULL,NULL,TO_ROOM);
	     send_to_char(buf,ch);
	     stop_embrace(ch,victim);
		 return;
		}
	 
		continue;
	}



	if (get_char_world(ch,victim->name) == NULL)
	  {stop_embrace(ch,NULL);continue;}
	if (ch->in_room != victim->in_room)
	  stop_embrace(ch,victim);
	if (victim->pcdata->condition[COND_THIRST] < 0)
	  victim->pcdata->condition[COND_THIRST] = 0;
       
	ch->pcdata->condition[COND_THIRST] += number_range(30,40);
    sprintf(buf, "%s shudders in ecstacy as he drinks blood from %s's neck.\n\r", ch->name,victim->name);
	act(buf,ch,NULL,NULL,TO_ROOM);
	sprintf(buf, "You shudder in ecstacy as you drink blood from %s's neck.\n\r",victim->name);
	send_to_char(buf,ch);
	sprintf(buf, "You feel some of your life slip away as %s drinks from your neck.\n\r", ch->name);
	send_to_char(buf,victim);
	ch->pcdata->condition[COND_THIRST] += number_range(35,40);
	victim->pcdata->condition[COND_THIRST] -= number_range(40,42);
	if (ch->pcdata->condition[COND_THIRST] > 2000/ch->pcdata->stats[UNI_GEN]);

{ch->pcdata->condition[COND_THIRST]=2000/ch->pcdata->stats[UNI_GEN];
	send_to_char("Your bloodlust is sated.\n\r",ch);}
	if (victim->pcdata->condition[COND_THIRST] < 0)
	  victim->pcdata->condition[COND_THIRST]=0;
	if (victim->pcdata->condition[COND_THIRST] ==0)
	{
	  sprintf(buf,"You have been diablerized!\n\r");
	  send_to_char(buf,victim);
	  raw_kill(victim, ch);
	  sprintf(buf,"%s's body falls lifeless to the ground.\n\r",victim->name);
	  act(buf,ch,NULL,NULL,TO_ROOM);
	  send_to_char(buf,ch);
	  stop_embrace(ch,victim);
     	  if (victim->pcdata->stats[UNI_GEN] < ch->pcdata->stats[UNI_GEN] && ch->pcdata->stats[UNI_GEN] > 3)
  	  {
	    sprintf(buf,"%s has been diablerized by %s.",victim->name,ch->name);
	    ch->pcdata->stats[UNI_GEN] -= 1;
	    victim->pcdata->stats[UNI_GEN] += 1;
	    victim->pcdata->condition[COND_THIRST] = 0;
	    do_info(ch,buf);
	  }
	  else
  	  {
	    sprintf(buf,"%s has been diablerized by %s for no generation.", victim->name,ch->name);
	    victim->pcdata->condition[COND_THIRST] = 0;
	    do_info(ch,buf);
	  }
    }
    continue; 
  }
  return;
}





void ww_update( void )
{
    DESCRIPTOR_DATA *d;
    CHAR_DATA       *victim;
    float            dam = 0;

    for ( d = descriptor_list; d != NULL; d = d->next )
      {
      if (!IS_PLAYING(d) || (victim = d->character) == NULL
        || IS_NPC(victim) || IS_IMMORTAL(victim)
	|| victim->in_room == NULL || victim->pcdata->chobj != NULL
        || IS_CLASS(victim,CLASS_WEREWOLF))
	{
            continue;
        }
      if ( !IS_SET( d->character->in_room->room_flags, ROOM_BLADE_BARRIER ) )
        continue;

      act( "The scattered blades on the ground fly up into the air ripping into you.", d->character, NULL, NULL, TO_CHAR );
      act( "The scattered blades on the ground fly up into the air ripping into $n.", d->character, NULL, NULL, TO_ROOM );

      act( "The blades drop to the ground inert.", d->character, NULL, NULL, TO_CHAR );
      act( "The blades drop to the ground inert.", d->character, NULL, NULL, TO_ROOM );

      dam = number_range( 7, 14 );
      dam = dam / 100;
      dam = d->character->hit * dam;
      if ( dam < 100 ) dam = 100;
      d->character->hit = d->character->hit - dam;
      if ( d->character->hit < -10 ) d->character->hit = -10;
      update_pos( victim );
      }

    return;
}

char * goodie_time( int count )
{
    char  * time;
    static char buf  [ MAX_STRING_LENGTH ];

    if( count >= ( ( PULSE_PER_SECOND * 60) * 60) *24 )
    {
        count /= ( ( PULSE_PER_SECOND * 60) * 60) * 24;
        time = "Day";
    }
    else if ( count >= ( ( PULSE_PER_SECOND * 60) * 60 ) )
    {
        count /= ( PULSE_PER_SECOND * 60) * 60;
        time = "Hour";
    }
    else if ( count >= ( PULSE_PER_SECOND * 60) )
    {
        count /= ( PULSE_PER_SECOND * 60);
        time = "Minute";
    }
    else
    {
        count /= PULSE_PER_SECOND;
        time = "Second";
    }
    
    sprintf( buf, "{W[{Y%d{W] %s%s{x",
             count,
             time,
             ( count > 1 ) ? "s" : "" );
    return buf;
}

/*
 * Handle all kinds of updates.
 * Called once per pulse from game loop.
 * Random times to defeat tick-timing clients and players.
 */
void update_handler( void )
{
    static	int	pulse_auction;
    static  int     pulse_point;
    static  int     pulse_ww;
    static  int     pulse_hint;
    static  int     pulse_vote;
/*    static  int     dxpcount;*/
DESCRIPTOR_DATA *d;
CHAR_DATA *ch = NULL;
CHAR_DATA *ch_next = NULL;
extern int dxpcount;
    static  int     pulse_quest;

    	if (dxpcount > 0)
	{
	    dxpcount--;
	    if (dxpcount <= 0)
	    {
		for ( ch = char_list; ch != NULL; ch = ch_next )
		{
		    ch_next = ch->next;
		    if (!IS_NPC(ch)) do_autosave(ch,"");
		}
		sprintf(log_buf,"Goodie Exp Timer." );
		log_string( log_buf );
                REMOVE_BIT( sysdata.world, WORLD_DOUBLEXP );
	    }
	}

	for ( d = descriptor_list; d != NULL; d = d->next )
	{
	    if ( d->connected == CON_PLAYING
	    &&   (ch = d->character) != NULL
	    &&  !IS_NPC(ch))
	    {


	if (ch->pcdata->resist[WILL_ANIMALISM] > 0)
		{
		    ch->pcdata->resist[WILL_ANIMALISM]--;
		    if (ch->pcdata->resist[WILL_ANIMALISM] < 1)
		    {
			send_to_char("You are no longer immune to Beast Within or Song of Serenity.\n\r",ch);
			if (!IS_WILLPOWER(ch, RES_TOGGLE)) 
			    REMOVE_BIT(ch->pcdata->resist[0], RES_ANIMALISM);
		    }
		}
		if (ch->pcdata->resist[WILL_AUSPEX] > 0)
		{
		    ch->pcdata->resist[WILL_AUSPEX]--;
		    if (ch->pcdata->resist[WILL_AUSPEX] < 1)
		    {
			send_to_char("You are no longer immune to having your mind Unveiled.\n\r",ch);
			if (!IS_WILLPOWER(ch, RES_TOGGLE)) 
			    REMOVE_BIT(ch->pcdata->resist[0], RES_AUSPEX);
		    }
		}
		if (ch->pcdata->resist[WILL_DOMINATE] > 0)
		{
		    ch->pcdata->resist[WILL_DOMINATE]--;
		    if (ch->pcdata->resist[WILL_DOMINATE] < 1)
		    {
			send_to_char("You are no longer immune to being Dominated.\n\r",ch);
			if (!IS_WILLPOWER(ch, RES_TOGGLE)) 
			    REMOVE_BIT(ch->pcdata->resist[0],
RES_DOMINATE);
		    }
		}
		if (ch->pcdata->resist[WILL_PRESENCE] > 0)
		{
		    ch->pcdata->resist[WILL_PRESENCE]--;
		    if (ch->pcdata->resist[WILL_PRESENCE] < 1)
		    {
			send_to_char("You are no longer immune to Dread Gaze and Entrancement.\n\r",ch);
			if (!IS_WILLPOWER(ch, RES_TOGGLE)) 
			    REMOVE_BIT(ch->pcdata->resist[0],RES_PRESENCE);
		    }
		}
         }
    }
    if ( --pulse_vote     <= 0 )
    {
	pulse_vote	= PULSE_PER_SECOND * 5;
	vote_update	( );
    }
    if ( --pulse_ww       <= 0 )
    {
        pulse_ww        = PULSE_WW;
        ww_update       ( );
    }

    if ( --pulse_rooms     <= 0 )
    {
       pulse_rooms      = PULSE_ROOMS;
       rooms_update();
    }
       if ( --pulse_hint <= 0)
       {
            pulse_hint = PULSE_HINT;
            hint_update ( );
       }

    if( --pulse_save	<= 0 )
    {
	pulse_save = PULSE_SAVE;
	for( d = descriptor_list ; d ; d = d->next )
        {
		if( !d->character )
			continue;
		ch = d->character;
		do_autosave(ch,"");
	}
    }

    if ( --pulse_area     <= 0 )
    {
	pulse_area	= number_range( PULSE_AREA / 2, 3 * PULSE_AREA / 2 );
	area_update	( );
    }

    if ( --pulse_mobile   <= (PULSE_MOBILE>>1) )
    {
	if ( pulse_mobile   <= 0 )
	{
	    pulse_mobile	= PULSE_MOBILE;
	    mobile_update	( );
	    player_update	( );
	}
    }

    if ( --pulse_violence <= 0 )
    {
	pulse_violence	= PULSE_VIOLENCE;
	violence_update	( );
        aggr_update( );
	embrace_update();
    }

    if ( --pulse_point    <= 0 )
    {
	pulse_point     = number_range( PULSE_TICK / 2, 3 * PULSE_TICK / 2 );
	weather_update	( );
	moon_update	( );
	char_update	( );
	obj_update	( );
    }

    if ( --pulse_auction        <= 0 )
    {
        pulse_auction   = PULSE_AUCTION;
        auction_update( );
    }

    if( --pulse_quest <= 0 )
    {
	pulse_quest = 60 * PULSE_PER_SECOND;
	quest_update();
    }

    aggr_update( );
    save_kingdoms();
    spam_update( );
    time_update( );
    tail_chain( );
    return;
}

void hint_update( void )
{
  CHAR_DATA *ch;
  CHAR_DATA *ch_next;

  for(ch=char_list;ch!=NULL;ch=ch_next)
    {
    ch_next = ch->next;

    if(!IS_NPC(ch) && !IS_SET(ch->deaf, CHANNEL_HINT))
      {
      send_to_char("\n\r{D[#sHINT{D]{w ",ch);
      switch(number_range(0,13))
        {
        default: send_to_char("{wTo turn this hint channel off, type 'channel -hint'", ch); break;
        case 0: send_to_char("{wUse 'selfclass' to class yourself.",ch); break;
        case 1: send_to_char("{wBe sure to read 'help rules' so you don't get punished",ch); break;
        case 2: send_to_char("{wThere are many helpfiles here, read them.",ch); break;
        case 3: send_to_char("{wIf you need quest directions go to: http://www.angelfire.com/ia/cuthbert",ch); break;
        case 4: send_to_char("{wBe sure to read 'help cps'",ch);break;
        case 5: send_to_char("{wYou should start off killing in 'Elemental Canyon' Dirs: 2s6e4s2es2edsu from recall",ch); break;
        case 6: send_to_char("{wWe aren't looking for any new imms at this time.",ch); break;
        case 7: send_to_char("{wYou can see the mud's webpage at: www.atdmud.com",ch);break;
        case 8: send_to_char("{wDon't ask imms idiotic questions.",ch); break;
        case 9: send_to_char("{wWe do have a mapper here, type 'help mapper'",ch); break;
        case 10: send_to_char("{wTo automatically stance when attacking a mob, use 'autostance'",ch);break;
        case 11: send_to_char("{wThe more you use a spell color, the better you'll get with it",ch);break;
        case 12: send_to_char("{wMany of changes will occur, to keep up-to-date read 'news'",ch);break;
        case 13: send_to_char("{wDon't bother pracing things, when you train avatar they'll all be 100%",ch);break;
        }
      send_to_char("\n\r{wTo turn this channel off type,{w '{Rchannel -hint{w'\n\r",ch);
      }
    }
return;
}



void update_class(CHAR_DATA *ch)
{
   if( PLR_FLAGS(ch,PLR_COUNTED ) )
	return;

   if( IS_CLASS(ch,CLASS_MAGE) )
	sysdata.mages++;
   else if( IS_CLASS(ch,CLASS_DEMON ))
	sysdata.demons++;
   else if( IS_CLASS(ch,CLASS_WEREWOLF ))
	sysdata.werewolfs++;
   else if( IS_CLASS(ch,CLASS_VAMPIRE))
	sysdata.vampires++;
   else if( IS_CLASS(ch,CLASS_DROW ))
	sysdata.drows++;
   else if( IS_CLASS(ch,CLASS_NINJA ))
	sysdata.ninjas++;
   else if( IS_CLASS(ch,CLASS_MONK ))
	sysdata.monks++;
   else if( IS_CLASS(ch,CLASS_ANGEL ))
	sysdata.angels++;
   else if( IS_CLASS(ch,CLASS_PRIEST ))
	sysdata.priests++;
   else
	return;
   xSET_BIT(PC(ch,plr_flags),PLR_COUNTED);
   save_sysdata( sysdata );
   return;
}

void remove_class(CHAR_DATA *ch)
{
   if( IS_CLASS(ch,CLASS_MAGE) )
	sysdata.mages--;
   else if( IS_CLASS(ch,CLASS_DEMON ))
	sysdata.demons--;
   else if( IS_CLASS(ch,CLASS_WEREWOLF ))
	sysdata.werewolfs--;
   else if( IS_CLASS(ch,CLASS_VAMPIRE))
	sysdata.vampires--;
   else if( IS_CLASS(ch,CLASS_DROW ))
	sysdata.drows--;
   else if( IS_CLASS(ch,CLASS_NINJA ))
	sysdata.ninjas--;
   else if( IS_CLASS(ch,CLASS_MONK ))
	sysdata.monks--;
   else if( IS_CLASS(ch,CLASS_ANGEL ))
	sysdata.angels--;
   else if( IS_CLASS(ch,CLASS_PRIEST ))
	sysdata.priests--;
   else
	return;
   save_sysdata( sysdata );
   return;
}

/*
 * Battle Spam by Dreimas
 */
void spam_update ( void )
{
    DESCRIPTOR_DATA *d;

    for( d = descriptor_list; d; d = d->next )
    {
	if( d->connected == CON_PLAYING 
         && CH(d)
	 && CH(d)->in_room )
		purge_spam( CH(d)->in_room );
    }
}

char *dam_amount( char *outstr, CHAR_DATA *ch, const int dam )
{
    sprintf( outstr, " {r<%d>{n", dam );
    return outstr;
}

void purge_spam( ROOM_INDEX_DATA *room )
{
    CHAR_DATA *ch, *vch, *victim;
    static const char *const him_her[] = { "it", "him", "her" };
    char buf[ MAX_INPUT_LENGTH ];
    char buf1[256];
    char buf2[256];
    char buf3[256];
    char buf4[256];
    char buf5[256];
    char tmp[25];
    char punct, *point;
    int i;

    for( ch = room->people; ch; ch = ch->next_in_room )
    {
	if( !ch->fighting || ch->num_hits < 0 )
	    continue;
	victim = ch->fighting;
	for( i = 0; dam_table[i].max_dam >= 0; i++ )
	{
	    if( dam_table[i].max_dam >= ch->tot_dam )
		break;
	}
	punct = ( ch->tot_dam <= 100 ) ? '.' : '!';
	
	if( ch->tot_dam > 0 )
	{
	    sprintf( buf1, "Your %d attack%s %s %%s{n%c%%s\n\r",
		     ch->num_hits, ch->num_hits > 1 ? "s" : "",
		     dam_table[i].mesg, punct );
	    sprintf( buf2, "%%s{n's %d attack%s %s you%c%%s\n\r",
		     ch->num_hits, ch->num_hits > 1 ? "s" : "",
		     dam_table[i].mesg, punct );
	    sprintf( buf3, "%%s{n's %d attack%s %s %%s{n%c%%s\n\r",
		     ch->num_hits, ch->num_hits > 1 ? "s" : "",
		     dam_table[i].mesg, punct );
	    sprintf( buf4, "Your %d attack%s %s you%c%%s\n\r",
		     ch->num_hits, ch->num_hits > 1 ? "s" : "",
		     dam_table[i].mesg, punct );
	    sprintf( buf5, "%%s{n's %d attack%s %s %%s%c%%s\n\r",
		     ch->num_hits, ch->num_hits > 1 ? "s" : "",
		     dam_table[i].mesg, punct );
	}
	else
	{
	    strcpy( buf1, "Your attacks haven't hurt %s{n!%s\n\r" );
	    strcpy( buf2, "%s{n's attacks haven't hurt you!%s\n\r" );
	    strcpy( buf3, "%s{n's attacks haven't hurt %s{n!%s\n\r" );
	    strcpy( buf4, "Your attacks haven't hurt you!%s\n\r" );
	    strcpy( buf5, "%s{n's attacks haven't hurt %s!%s\n\r" );
	}
	for( vch = room->people; vch; vch = vch->next_in_room )
	{
	    if( !vch 
		|| !vch->desc || !IS_AWAKE( vch ) 
		|| ( ( vch == ch || vch == victim ) &&
		     !PLR_FLAGS( CH(vch->desc), PLR_BATTLESELF ) )
		|| ( ( vch != ch && vch != victim ) &&
		     !PLR_FLAGS( CH(vch->desc), PLR_BATTLEOTHER ) ) )
		continue;
	    
	    if( vch == ch )
	    {
		if( ch == victim )
		    sprintf( buf, buf4, dam_amount( tmp, vch, ch->tot_dam ) );
		else
		    sprintf( buf, buf1, PERS( victim, vch ),
			     dam_amount( tmp, vch, ch->tot_dam ) );
	    }
	    else if( vch == victim )
		sprintf( buf, buf2, PERS( ch, vch ),
			 dam_amount( tmp, vch, ch->tot_dam ) );
	    else if( ch == victim )
		sprintf( buf, buf5, PERS( ch, vch ),
			 him_her[URANGE( 0, ch->sex, 2 )],
			 dam_amount( tmp, vch, ch->tot_dam ) );
	    else
		sprintf( buf, buf3, PERS( ch, vch ),
			 PERS( victim, vch ), 
			dam_amount( tmp, vch, ch->tot_dam ) );

	    point = &buf[0];
	    while( *point == '{' )
		point += 2;
	    *point = UPPER( *point );
	    send_to_char( buf, vch );
	}
	ch->num_hits = -1;
	ch->tot_dam = 0;
    }
}

void time_update( void )
{
    FILE            *fp;
    char             buf [ MAX_STRING_LENGTH ];
    char            *type;    
    extern bool      merc_down;
    if ( sysdata.down_time <= 0 )
        return;

    if( IS_SET(sysdata.world, WORLD_REBOOT) )
	type = "Reboot";
    else if ( IS_SET(sysdata.world, WORLD_COPYOVER) )
	type = "Copyover";
    else
	type = "Shutdown";

    if ((int)( sysdata.down_time -current_time) / 60 > 0 
     && (int)( sysdata.down_time -current_time) % 60 == 0  )
    {
	sprintf( buf, "{R%s in %d minute%s.  Please type 'save'.\n\r",
		type,
		(int) ( sysdata.down_time - current_time ) / 60,
		((int) ( sysdata.down_time - current_time ) / 60 == 1) ? "" : "s" );
	do_info( NULL, buf );
	return;
    }
    if ( current_time == sysdata.down_time - 10 )
    {
	sprintf( buf, "%s in 10 seconds.  Please type 'save'.\n\r",
		type );
	do_info( NULL, buf );
    }
    if ( current_time > sysdata.down_time )
    {
        sprintf( buf, "%s by system.\n\r", type );
	do_info( NULL, buf );
	log_string( buf );

	end_of_game( );

	if ( !IS_SET(sysdata.world, WORLD_REBOOT)
	  && !IS_SET(sysdata.world, WORLD_COPYOVER) )
	{
	    fclose( fpReserve );
	    if ( !( fp = fopen( SHUTDOWN_FILE, "a" ) ) )
	      {
		perror( SHUTDOWN_FILE );
		bug( "Could not open the Shutdown file!", 0 );
	      }
	    else
	      {
		fprintf( fp, "Shutdown by System\n" );
		fclose ( fp );
	      }
	    fpReserve = fopen ( NULL_FILE, "r" );
	}
	merc_down = TRUE;
    }
    
    return;

}

/*
 * Check room effects list for rooms.  Since there will be a second link
 * link list, the time should be realitivly fast for checking.
 */

void rooms_update( void )
{
    int iHash;
    AREA_DATA       *pArea;
    ROOM_INDEX_DATA *room;
    ROOM_AFFECT_DATA *raf;
    ROOM_AFFECT_DATA *raf_next;


    for( pArea = area_first; pArea; pArea = pArea->next)
    {
        for( iHash = pArea->lvnum; iHash < pArea->uvnum; iHash++ )
        {
            room = get_room_index( iHash );
            if( !room|| room->area != pArea ) continue;
            for ( raf = room->affected; raf; raf = raf_next )
            {
                raf_next = raf->next;

                if ( raf->duration > 0 )
                    raf->duration--;
                else if ( raf->duration < 0 )
                    ;
                else
                {
                    if ( !raf_next
                         || raf_next->type     != raf->type
                         || raf_next->duration > 0 )
                    {
                        if ( raf->type > 0)
                        {
                           if ( room_aff_table[raf->type].msg_off )
                            {
			send_to_room(room_aff_table[raf->type].msg_off, room );
                            }
                            if( raf->caster
                                && room_aff_table[raf->type].msg_caster )
                            {
                                ch_printf(raf->caster,
				room_aff_table[raf->type].msg_caster,
                                        room->name );
                            }
                        }
                        r_affect_remove( room, raf );
                    }
                }
            }
        }
    }
    return;
}

void quest_update( void )
{
    QUEST_DATA * qq;
    DESCRIPTOR_DATA *d;

    for( d = descriptor_list; d; d = d->next )
    {
	if( d->connected != CON_PLAYING )
	    continue;
	qq = CH( d )->pcdata->aquest;

	if( !qq || qq->time <= 0 )
	    continue;

	if( --qq->time == 0 )
	{
	    if( qq->type != QUEST_NONE )
	    {
		send_to_char( "You have run out of time for your quest.\n\r",
			      d->character );
		qq->target = NULL;
		qq->type = QUEST_NONE;
		qq->time = 10;
	    }
	    else
		{
		send_to_char( "You may now quest again.\n\r",d->character );
		qq->time = 0;
		}
	}
	else
	{
	    qq->reward = qq->reward * number_fuzzy( 9 ) / 10;
	    if( qq->time <= 3 && qq->type != QUEST_NONE )
		send_to_char( "Better hurry, you are almost"
			      " out of time for your quest.\n\r",
			      d->character );
	}
    }
    return;
}