/
mudd/docs/html/
mudd/world/
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"

// Some stuff from other code - not much.. mostly weather crap

long average_time[MT];
long times_through[MT];
long last_time[MT];
long this_time[MT];
long total_time[MT];
long temp_time[MT];
int hours_up = 0;
char *itoa (int);
int hit_gain (CHAR_DATA * ch);
int move_gain (CHAR_DATA * ch);
void mobile_update (void);
void weather_update (void);
void char_update (void);
void char_only_update (void);
void transport_update (void);
void obj_update (void);
void aggr_update (void);
void do_disaster (void);

void
fix_char (CHAR_DATA * ch)
{
  I_ARMOR *r; 
  AFFECT_DATA *paf;
  AFFECT_DATA *paf_next;
  SINGLE_OBJECT *obj;
  int mod, i;
  if (!ch || IS_MOB (ch))
    return;

  ch->hitroll = 0;
  ch->damroll = 0;
  ch->armor = ch->pcdata->nat_armor;
  ch->pcdata->plus_hide = 0;
  ch->pcdata->plus_sneak = 0;
  ch->pcdata->plus_kick = 0;
  ch->pcdata->armor[0] = 0;
  ch->pcdata->armor[1] = 0;
  ch->pcdata->armor[2] = 0;
  ch->pcdata->armor[3] = 0;
  ch->pcdata->carry_weight = 0;
  ch->pcdata->carry_number = 0;
  ch->pcdata->command_objs = 0;
  if (ch->pcdata->online_spot)
    ch->pcdata->online_spot->alignment = ch->pcdata->alignment;
  for (i = 0; i < NUM_STATS; i++)
    {
      ch->pcdata->stat_mod[i] = 0;
    }
  for (i = 0; i < 3; i++)
    {
      ch->pcdata->learned[race_info[ch->pcdata->race].nat_skills[i]] = 100;
      ch->pcdata->learned[align_info[ch->pcdata->alignment].nat_skills[i]] = 100;
    }
  
  if (ch->pcdata->warpoints < 0) ch->pcdata->warpoints = 0;
  if (ch->pcdata->total_wps < 0) ch->pcdata->total_wps = 0;
  LOOP (paf, ch->affected, paf->next)
    { 
      mod = paf->modifier;
      
      switch (paf->location)
	{
	default:
	  break;
	case APPLY_NONE:
	  break;
	case APPLY_AC:
	  ch->armor += mod;
	  break;
	case APPLY_HITROLL:
	  ch->hitroll += mod;
	  break;
	case APPLY_DAMROLL:
	  ch->damroll += mod;
	  break;
	case APPLY_KICK_DAMAGE:
	  ch->pcdata->plus_kick += mod;
	  break;
	case APPLY_SNEAK:
	  ch->pcdata->plus_sneak += mod;
	  break;
	case APPLY_WARMTH:
	  ch->pcdata->warmth += mod;
	  break;
	case APPLY_HIDE:
	  ch->pcdata->plus_hide += mod;
	  break;
	case APPLY_STR:
          ch->pcdata->stat_mod[STR] += mod;
          break;
	case APPLY_INT:
          ch->pcdata->stat_mod[INT] += mod;
          break;
	case APPLY_CHA:
          ch->pcdata->stat_mod[CHA] += mod;
          break;
	case APPLY_WIS:
          ch->pcdata->stat_mod[WIS] += mod;
          break;
	case APPLY_DEX:
          ch->pcdata->stat_mod[DEX] += mod;
          break;
	case APPLY_CON:
          ch->pcdata->stat_mod[CON] += mod;
          break;
case APPLY_LCK:
          ch->pcdata->stat_mod[LCK] += mod;
          break;
case APPLY_WIL:
          ch->pcdata->stat_mod[WIL] += mod;
          break;

	}
      
    }
  LOOP (obj, ch->carrying, obj->next_content)
    {
      ch->pcdata->carry_weight += get_obj_weight (obj);
      ch->pcdata->carry_number += get_obj_number (obj);
      if (IS_OBJ_STAT(obj, ITEM_COMMANDSCRIPT))
	ch->pcdata->command_objs++;
      if (obj->wear_loc == WEAR_NONE || worn_flags[obj->wear_loc].flagname == ITEM_WEAR_BELT)
	continue;
      if(obj->pIndexData->item_type == ITEM_ARMOR)
	{
	  r = (I_ARMOR *) obj->more;
	  if (r->max_condition == 0)
	    {
	      ch->pcdata->armor[0] += (r->protects_body);
	      ch->pcdata->armor[1] += (r->protects_head);
	      ch->pcdata->armor[2] += (r->protects_legs);
	      ch->pcdata->armor[3] += (r->protects_arms);
	    }
	  else
	    {
	      ch->pcdata->armor[2] += (r->protects_legs * r->condition_now) / (r->max_condition);
	      ch->pcdata->armor[0] += (r->protects_body * r->condition_now) / (r->max_condition);
	      ch->pcdata->armor[1] += (r->protects_head * r->condition_now) / (r->max_condition);
	      ch->pcdata->armor[3] += (r->protects_arms * r->condition_now) / (r->max_condition);
	    }
	}
      for (paf = obj->pIndexData->affected; paf != NULL; paf = paf_next)
	{
	  mod = paf->modifier;
	  paf_next = paf->next;
	  switch (paf->location)
	    {
	    default: 
	      break;
	    case APPLY_NONE:
	      break;
	    case APPLY_AC:
	      ch->armor += mod;
	      break;
	    case APPLY_HITROLL:
	      ch->hitroll += mod;
	      break;
	    case APPLY_DAMROLL:
	      ch->damroll += mod;
	      break;
	    case APPLY_KICK_DAMAGE:
	      ch->pcdata->plus_kick += mod;
	      break;
	    case APPLY_SNEAK:
	      ch->pcdata->plus_sneak += mod;
	      break;
	    case APPLY_WARMTH:
	      ch->pcdata->warmth +=mod;
	      break;
	    case APPLY_HIDE:
	      ch->pcdata->plus_hide += mod;
	      break;
	    case APPLY_STR:
	      ch->pcdata->stat_mod[STR] += mod;
	      break;
	    case APPLY_INT:
	      ch->pcdata->stat_mod[INT] += mod;
	      break;
	    case APPLY_CHA:
	      ch->pcdata->stat_mod[CHA] += mod;
	      break;
	    case APPLY_WIS:
	      ch->pcdata->stat_mod[WIS] += mod;
	      break;
	    case APPLY_DEX:
	      ch->pcdata->stat_mod[DEX] += mod;
	      break;
	    case APPLY_CON:
	      ch->pcdata->stat_mod[CON] += mod;
	      break;
	    case APPLY_LCK:
	      ch->pcdata->stat_mod[LCK] += mod;
	      break;
	    case APPLY_WIL:
	      ch->pcdata->stat_mod[WIL] += mod;
	      break;
	      
	    }
       }
      for (paf = obj->affected; paf != NULL; paf = paf_next)
	{
	  mod = paf->modifier;
	  paf_next = paf->next;
	  switch (paf->location)
	    {
	    default: 
	      break;
	    case APPLY_NONE:
	      break;
	    case APPLY_AC:
	      ch->armor += mod;
	      break;
	    case APPLY_HITROLL:
	      ch->hitroll += mod;
	      break;
	    case APPLY_DAMROLL:
	      ch->damroll += mod;
	      break;
	    case APPLY_KICK_DAMAGE:
	      ch->pcdata->plus_kick += mod;
	      break;
	    case APPLY_SNEAK:
	      ch->pcdata->plus_sneak += mod;
	      break;
	    case APPLY_WARMTH:
	      ch->pcdata->warmth += mod;
	      break;
	    case APPLY_HIDE:
	      ch->pcdata->plus_hide += mod;
	      break;
	    case APPLY_STR:
	      ch->pcdata->stat_mod[STR] += mod;
	      break;
	    case APPLY_INT:
	      ch->pcdata->stat_mod[INT] += mod;
	      break;
	    case APPLY_WIS:
	      ch->pcdata->stat_mod[WIS] += mod;
	      break;
	    case APPLY_DEX:
	      ch->pcdata->stat_mod[DEX] += mod;
	      break;
	    case APPLY_CON:
	      ch->pcdata->stat_mod[CON] += mod;
	      break;
	      case APPLY_LCK:
	      ch->pcdata->stat_mod[LCK] += mod;
	      break;
	    case APPLY_WIL:
	      ch->pcdata->stat_mod[WIL] += mod;
	      break;
	     case APPLY_CHA:
	      ch->pcdata->stat_mod[CHA] += mod;
	      break;
	       
	    }
	}
    }
  ch->damroll += 
    ch->pcdata->remort_times +
    is_member(ch, GUILD_WARRIOR) +
    (IS_SET (ch->pcdata->fight_ops, F_AGGRESSIVE) ? 2 : 0)+
    (IS_SET (ch->pcdata->fight_ops, F_POWER) ? 1 : 0)+
    race_info[ch->pcdata->race].combat_damage_bonus+
    align_info[ch->pcdata->alignment].combat_damage_bonus;
  
  

  ch->hitroll += 
    (LEVEL(ch)/4 +
     (IS_SET(ch->pcdata->fight_ops, F_AGGRESSIVE) ? -4 : 0) +
     (IS_AUGMENTED(ch, AUG_HAND_SPD) ? 4 : 0) + 
     is_member(ch, GUILD_THIEF) + 
     (IS_AUGMENTED(ch, AUG_LEG_SPD) ? 4 : 0));
  
  
  
  for (i = 0; i < 4; i++)
    {
      ch->aff[i] |= ch->pcdata->nat_aff[i];
      ch->aff[i] |= race_info[ch->pcdata->race].aff[i];
      ch->aff[i] |= align_info[ch->pcdata->alignment].aff[i];
    }
  return;
}
  


void
advance_level (CHAR_DATA * ch)
{
  int add_prac;
  int add_learn;
  int ct;
  ct = 0;
  if (IS_MOB (ch))
    return;

  add_level_bonuses (ch, 1);
  add_prac = (pow.practice_percent * wis_app[get_stat (ch, WIS) - 1].practice) / 100;
    add_learn = LEVEL (ch) < 4 ? 2 : 1;

  ch->pcdata->practice += add_prac;
  ch->pcdata->learn += add_learn;
  natural_mana (ch);
  
  return;
}


void
gain_exp (CHAR_DATA * ch, int gain)
{
  char general_use[500];
  int ii=0;
  if (IS_MOB (ch) || LEVEL (ch) >= 90 || gain == 0)
    return;
  if (IN_BATTLE (ch)  || CHALLENGE (ch) == ARENA_FIGHTING)
    return;
  if (gain < 1)
    {
      if (-gain >= ch->pcdata->exp)
	{
	  ch->pcdata->exp = 0;
	}
      return;
    }
  else
    ch->pcdata->exp += gain;
  while (LEVEL (ch) < pow.max_level && ch->pcdata->exp >= FIND_EXP (LEVEL (ch), ch->pcdata->race))
    {
      send_to_char ("You have become more powerful!\n\r", ch);
      sprintf (general_use,
               "\x1B[1;30m-->\x1B[37;0mYour overall power and learning capacities have increased!\n\r");
      send_to_char (general_use, ch);
      ch->pcdata->level++;
      advance_level (ch);
      if (ch->pcdata->remort_times == 0 && ch->pcdata->level == pow.level_to_choose -1)
	{
	  send_to_char("You must choose your alignment next level!!!!\n\r", ch);
	  send_to_char("\x1b[1;31mPlease type help choose and aligninfo to help you decide.\n\r", ch);
	  return;
	}
      ii = clan_number (ch);
      sprintf(general_use, "%s has just gained a level! Up to level %d!!", NAME(ch), LEVEL(ch));
      if (ii > 0)
	clan_notify (general_use, ii);
      if (LEVEL(ch) == pow.level_to_choose && ch->pcdata->remort_times == 0 && pow.choose_in_room != 0 && get_room_index(pow.choose_in_room) != NULL)
	{
	  char_from_room(ch);
	  char_to_room(ch, get_room_index(pow.choose_in_room));
	  do_look(ch, "auto");
	  send_to_char("You must now choose which path you wish to take.\n\r", ch);
	}
    }
  return;
}

int
max_mana (CHAR_DATA * ch)
{
   int base;
   int i;
   if (IS_MOB (ch))
     return 500;
   base = (get_stat(ch, INT) + get_stat (ch, WIS) + get_stat(ch, WIL)) +
     (((LEVEL (ch) / 3) * (get_stat (ch, WIS) + get_stat (ch, INT) + get_stat (ch, WIL))) / 9);
   if (IS_AUGMENTED(ch, AUG_MANA_BOOST))
     base = (12*base)/10;
   base = (base * (race_info[ch->pcdata->race].mana_percent + align_info[ch->pcdata->alignment].mana_percent))/100;
   if (race_info[ch->pcdata->race].parts[2] > 1)
     base *= race_info[ch->pcdata->race].parts[2];
   for (i = 0; i < MAX_HOLD; i++)
     {
       if(ch->hold[i] && ch->hold[i]->pIndexData->item_type == ITEM_GEM)
	 base += ((I_GEM *)ch->hold[i]->more)->max_mana;
     }
   return base;
}

void
mana_gain (CHAR_DATA * ch, short hehe)
{
  SINGLE_OBJECT *gem;
  I_GEM *gm;
  int i;
  int num_hands;
  char general_use[500];
  /*MANA REGEN HERE */
  if (IS_MOB (ch))
    return;
  num_hands = 2*race_info[ch->pcdata->race].parts[3];
  
  if (ch->pcdata->n_mana < ch->pcdata->n_max_mana && hehe != 2)
    {
      int tt = pow.base_mana_regen_bonus +
	((ch->position == POSITION_MEDITATING) ? pow.med_mana_regen_bonus : 0 )+
	(IS_AUGMENTED(ch, AUG_HEAD_WIS) ? 1 : 0) +
	(IS_AUGMENTED(ch, AUG_HEAD_INT)? 1 : 0) +
	(IS_AUGMENTED(ch, AUG_MANA_BOOST) ? 3 : 0) +
	(get_stat (ch, WIS) + get_stat (ch, INT) + get_stat (ch, WIL))/15;
      ch->pcdata->n_mana = UMIN (ch->pcdata->n_max_mana, ch->pcdata->n_mana + tt); 
    }
  if ((hehe == 2) || IS_HURT(ch, MINDSAP))
    {
      ch->pcdata->n_mana -= 3;
      if (ch->pcdata->n_mana <= 0)
	ch->pcdata->n_mana = 0;
    }
  
  for (i = 0; i < num_hands; i++)
    {
      if ((gem = ch->hold[i]) != NULL && gem->pIndexData->item_type == ITEM_GEM)
	{
	  gm = (I_GEM *)gem->more;
	  if (hehe == 2 || IS_HURT(ch, MINDSAP))
	    {
	      gm->mana_now = UMAX(gm->mana_now - 3, 0);
	      continue;
	    }
	  if (gm->mana_now == gm->max_mana) return;
	  if (gm->mana_now == (gm->max_mana - 1))
	    {
	      sprintf (general_use, "%s has been charged to its maximum capacity!\n\r",   capitalize (STRR (gem, short_descr)));
	      send_to_char (general_use, ch);
	    }
	  if (IS_AUGMENTED(ch, AUG_MANA_BOOST)) gm->mana_now++;
	  if (hehe) gm->mana_now++;
	  else if (ch->position == POSITION_MEDITATING)
	    gm->mana_now += (7 + (get_stat (ch, INT) + get_stat (ch, WIS) + get_stat (ch, WIL))/10 );
	  else if (ch->position == POSITION_SLEEPING)
	     gm->mana_now += (4 + (get_stat (ch, INT) + get_stat (ch, WIS) + get_stat (ch, WIL))/18);
	  else if (ch->position == POSITION_RESTING)
	    gm->mana_now += 3;
	  else
	    gm->mana_now += 2;
	  if (get_stat (ch, WIS) > 19)
	    gm->mana_now++;
	  if (get_curr_wis (ch) > 23)
	    gm->mana_now++;
	  if (gm->mana_now > gm->max_mana)
	    gm->mana_now = gm->max_mana;
	  else
	    {
	      if (gm->mana_now > 19 && gm->mana_now < 22)
		send_to_char ("Your gem begins to glow softly.\n\r", ch);
	      else if (gm->mana_now > 32 && gm->mana_now < 35)
		send_to_char ("Your gem begins to warm your hand with its power.\n\r", ch);
	      else if (gm->mana_now > 61 && gm->mana_now < 64)
	    send_to_char ("Your gem hums with powerful magical energy!\n\r", ch);
	    }
	}
    }
  return;
}

/*
   * Regeneration stuff.
 */
int
hit_gain (CHAR_DATA * ch)
{
  int gain;
  if (FIGHTING (ch))
    return 0;
  if (ch->hit >= ch->max_hit)
    return 0;
  
  gain = pow.base_hp_regen +
    (ch->position == POSITION_SLEEPING ? pow.hp_bonus_sleeping : 
     (ch->position == POSITION_RESTING ? pow.hp_bonus_resting : 0)) +
    number_range (1, get_stat (ch, CON) / 4);
  if (IS_MOB (ch))
    gain += LEVEL (ch)/5;
  else
    {
      if (ch->pcdata->condition[COND_FULL] < 4 ||
	  ch->pcdata->condition[COND_THIRST] < 4)
	{
	  gain /= 2;
	  if (ch->pcdata->condition[COND_FULL] < 1 ||
	      ch->pcdata->condition[COND_THIRST] < 1)
	    gain = 1;
	}
      gain = (gain * 
	      (race_info[ch->pcdata->race].regen_hit_percent + 
	       align_info[ch->pcdata->alignment].regen_hit_percent)) / 100;
    }
  gain /= (1 + IS_HURT (ch, POISON) * 2 + 
	   IS_HURT (ch, PLAGUE) * 3 +
	   IS_HURT (ch, VAMPIRIC) * 5);

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

}

int
move_gain (CHAR_DATA * ch)
{
  int gain = 0;
  if (FIGHTING (ch))
    return 1;
  if (ch->hit >= ch->max_hit)
    return 0;
  gain = pow.base_mp_regen +
    (ch->position == POSITION_SLEEPING ? pow.mp_bonus_sleeping : 
     (ch->position == POSITION_RESTING ? pow.mp_bonus_resting : 0)) +
    number_range (1, get_stat (ch, DEX) / 4);
  
  if (IS_PLAYER (ch))
    {
      if (ch->pcdata->condition[COND_FULL] <= 0 || 
	  ch->pcdata->condition[COND_THIRST] <= 0)
        gain = 1;
      gain = (gain * 
	      (race_info[ch->pcdata->race].regen_move_percent + 
	       align_info[ch->pcdata->alignment].regen_move_percent)) / 100; 
    }
  gain /= (1 + IS_HURT (ch, POISON) * 1 + 
	   IS_HURT (ch, PLAGUE) * 2 +
	   IS_HURT (ch, VAMPIRIC) * 3);

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

void
gain_condition (CHAR_DATA * ch, int iCond, int value)
{
  int condit = ch->pcdata->condition[iCond] + value;
  
  if (value == 0 || IS_MOB (ch))
    return;
  
  switch (iCond)
    {
    case COND_FULL:
      {
	if (ch->pcdata->remort_times > 7 && condit < 20)
	  ch->pcdata->condition[iCond] = 20;
	if (condit < -2)
	  send_to_char ("You hurt from hunger!\n\r", ch);
	else if (condit < 2)
	  send_to_char ("You begin to feel yourself weaken from intense hunger!\n\r", ch);
	else if (condit == 3)
	  send_to_char ("Your stomach rumbles with hunger.\n\r", ch);
	else if (condit == 9)
	  send_to_char ("You are beginning to get hungry... better get some food.\n\r", ch);
	else if (condit > 48)
	  ch->pcdata->condition[iCond] = 48;
      }
    break;
    case COND_THIRST:
      {
	if (ch->pcdata->remort_times > 3 && condit < 20)
	  ch->pcdata->condition[iCond] = 20;
	if (condit < -2)
	  send_to_char ("You hurt from thirst!\n\r", ch);
	else if (condit < 2)
	  send_to_char ("You feel so dehydrated that your vision begins to blur!\n\r", ch);
	else if (condit == 3) 
	  send_to_char ("You begin to feel dehydrated.\n\r", ch);
	else if (condit == 9)
	  send_to_char ("You are beginning to get thirsty", ch);
	else if (condit > 48)
	  ch->pcdata->condition[iCond] = 48;
      }
    break;
    case COND_DRUNK:
      {
	if (condit == 1)
	  send_to_char ("You sober up.", ch);
	else if (condit < 0)
	  ch->pcdata->condition[COND_DRUNK] = 0;
	return;
      }
    }
  if (condit < 0)
    {
      SUBHIT (ch, -condit * condit);
      if (ch->hit < 0)
	{
	  send_to_char ("Your body finally gives out under the stress of malnourishment...\n\r", ch);
	  ch->pcdata->condition[COND_THIRST] = 48;
	  ch->pcdata->condition[COND_FULL] = 48;
	  strcpy (reasonfd, "Starvation");
	  raw_kill (ch, FALSE);
	  send_to_char ("Your vision blurs as the world slips away around you...\n\r", ch);
	  update_pos (ch);
	}
    }
  return;
}


void
mobile_update (void)
{
  char buffy[STD_LENGTH];
  CHAR_DATA *ch;
  CHAR_DATA *ch_next;
  CHAR_DATA *fch;
  CLAN_DATA *clan;
  buffy[0] = '\0';
  for (ch = char_list[pulse_mobile]; ch != NULL; ch = ch_next)
    {
      ch_next = ch->next;
      if (ch->in_room && ch->in_room->area->nplayer > 0 && 
	  pulse_mobile == MOB_LIST)
	{
	  remove_char_from_list (ch);
	  add_char_to_list (ch);
	}
      if (ch->in_room == NULL)
	{
	  CHAR_DATA *fx;
	  int i;
	  for (i = 0; i < TOTAL_LIST ; i++)
	    {
		for (fx = char_list[i]; fx != NULL; fx = fx->next)
		  {
		    if (fx->fgt && fx->fgt->fighting == ch)
		      {
			fx->fgt->fighting = NULL;
		      }
		  }
	    }
	  fprintf (stderr, "Extracted mob/char %d society %d that was not in any room...\n", ch->pIndexData ? ch->pIndexData->vnum : 0, ch->society);
	  extract_char (ch, TRUE);
	  continue;
	}
      if (ch->fgt)
	{
	  if (ch->fgt->fighting && ch->fgt->fighting->data_type==50)
	      ch->fgt->fighting=NULL;
	  if(!ch->fgt->fighting && ch->position == POSITION_BASHED)
	    {
	      ch->position = POSITION_STANDING;
	      ch->fgt->ears = 2;
	      }
	}
      if (IS_HURT(ch, NUMB) && number_range(1,5) == 3)
	{
	  int kk;
	  SINGLE_OBJECT* helditem;
	  for (kk = 0; kk < 6; kk++)
	    {
	      if (number_range(1,3) == 2 && (helditem = ch->hold[kk]) != NULL)
		{
		  obj_from(helditem);
		  obj_to(helditem, ch->in_room);
		  send_to_char("\x1b[1;31mYou clumsy oaf!\x1b[0;37m\n\r", ch);
		  act ("You just dropped $p!", ch, helditem, NULL, TO_CHAR);
		  act ("$n just dropped $p!", ch, helditem, NULL, TO_ROOM);
		}
	    }
	}
      if (IS_HURT(ch, FUMBLE) && number_range(1,10) == 3)
	{
	  SINGLE_OBJECT *obj;
	  SINGLE_OBJECT *obj_next;
	  for (obj = ch->carrying; obj != NULL; obj = obj_next)
	    {
	      obj_next = obj->next_content;
	      if (number_range(1,8) == 3)
		{
		  obj_from(obj);
		  obj_to(obj, ch->in_room);
		  act ("$BYou fumble and clumsily drop $p$R$B!$R", ch, obj, NULL, TO_CHAR);
		  act ("$n fumbles and clumsily drops $p$R!", ch, obj, NULL, TO_ROOM);
		}
	    }
	}
      if (IS_PLAYER(ch))
	continue;
      if (ch->in_room->area->nplayer > 0 && !IS_HURT (ch, CHARM))
	{
	  if(ch->pIndexData->act4 >= ACT4_KILL_OPP || ch->pIndexData->guard)
	    {
	      if (FIGHTING(ch) == NULL)
		{
		  if (IS_SET (ch->pIndexData->act4, ACT4_REST) && ch->in_room->pcs == 0)
		    {
		      if (ch->hit < ch->max_hit/5)
			{
			  do_sleep(ch, "");
                          continue;
			}
		      else if (ch->hit < ch->max_hit/2)
			{
			  do_rest(ch, "");
                          continue;
			}
		      else if (ch->hit > (ch->max_hit * 9)/10)
			do_stand(ch, "");
		      if (ch->position != POSITION_STANDING) 
			continue;
		    }
		  for (fch = ch->in_room->people; fch != NULL; fch = fch->next_in_room)
		    {
		      if (!can_see(ch, fch) || fch == ch)
			continue;
		      if (IS_PLAYER(fch))
			{
			  if (LEVEL(ch) >= IMM_LEVEL) 
			    continue;
			  if (nightmare && number_range(1,4) == 2)
			    {
			      do_kill(ch, NAME(fch));
			      break;
			    }
			  if (IS_SET(ch->pIndexData->act4, ACT4_KILL_OPP) && DIFF_ALIGN(ch, fch))
			    {
			      multi_hit(ch, fch, TYPE_UNDEFINED);
			      break;
			    }
			  if (IS_SET(ch->pIndexData->act4, ACT4_KILL_CLAN) &&
			      fch->pcdata->clan >= 0 &&
			      (clan = get_clan_index(fch->pcdata->clan)) != NULL &&    clan->shitlist == TRUE)
			    {
			      char clanbuf[SML_LENGTH];
			      sprintf(clanbuf, "All of you %s scum need to die now, %s!", clan->name, NAME(fch));
			      do_say(ch, clanbuf);
			      multi_hit(ch, fch, TYPE_UNDEFINED);
			      break;
			    }
			  if (IS_SET(ch->pIndexData->act4, ACT4_KILLALLONE |
				     ACT4_KILLALLTWO) ||
			      (IS_SET(ch->pIndexData->act4, ACT4_SLEEPAGGRO) &&
			       fch->position == POSITION_SLEEPING))
			    {
			      multi_hit(ch, fch, TYPE_UNDEFINED);
			      break;
			    }
			  if ((1 << fch->pcdata->race) & ch->pIndexData->race_hate)
			    {
			      racehate_message(ch);
			      multi_hit(ch, fch, TYPE_UNDEFINED);
			      break;
			    }
			  if (fch->fgt && fch->fgt->fighting != NULL && 
			      fch->fgt->fighting != ch &&
			      IS_MOB(fch->fgt->fighting) &&
			      IS_SET(ch->pIndexData->act4, ACT4_ASSISTALL))
			    {
			      multi_hit(ch, fch, TYPE_UNDEFINED);
			      break;
			    }
			}
		      else
			{
			  if (nightmare && number_range(1,4) == 2)
			    do_kill(ch, NAME(fch));
			  
			  if (IS_SET(ch->pIndexData->act4, ACT4_KILL_OPP) && DIFF_ALIGN(ch, fch))
			    {
			      multi_hit(ch, fch, TYPE_UNDEFINED);
			      break;
			    }
			  
			  if (IS_SET (ch->pIndexData->act4, ACT4_RANGER) 
			      && fch->pIndexData->mobtype == MOB_GENERAL_ANIMAL)
			    {
			      multi_hit(ch, fch, TYPE_UNDEFINED);
			      break;
			    }
			  if ((IS_SET (ch->pIndexData->act4, ACT4_KILLALLONE) &&
			       !IS_SET(fch->pIndexData->act4, ACT4_KILLALLONE)) ||
			      (IS_SET (ch->pIndexData->act4, ACT4_KILLALLTWO) &&
			       !IS_SET(fch->pIndexData->act4, ACT4_KILLALLTWO)))
			    {
			      multi_hit(ch, fch, TYPE_UNDEFINED);
			      break;
			    }
			  if (ch->pIndexData->guard && FIGHTING(fch) &&
			      ch->pIndexData->guard->assists == fch->pIndexData->vnum)
			    {
			      multi_hit(ch, FIGHTING(fch), TYPE_UNDEFINED);
			      break;
			    }
			}
		    }
		}
	      else
		{
		  MOB_PROTOTYPE *pmob;
		  if (ch->pIndexData->spec != NULL && 
		      ch->pIndexData->spec->summons > 1 && 
		      ((pmob = get_mob_index(ch->pIndexData->spec->summons)) !=NULL))
		    {
		      CHAR_DATA * summoned;
		      if (number_percent() < UMIN(15, LEVEL(ch)/10))
			{
			  summoned = create_mobile(pmob);
			  char_to_room(summoned, ch->in_room);
			  summoned->society = ch->society;
			  act("$n barks a single syllable and suddenly $N appears!", ch, NULL, summoned, TO_ROOM);
			  check_fgt(summoned);
			  summoned->fgt->fighting = ch->fgt->fighting;
			  summoned->fgt->hunting = str_dup(RNAME(summoned->fgt->fighting));
			  add_to_fighting_list (summoned);
			}
		    }
		}
	      if (ch->pIndexData->guard &&
		  ch->pIndexData->guard->rescues)
		{
		  for (fch = ch->in_room->people; fch != NULL; fch = fch->next_in_room)
		    {
		      if (IS_MOB(fch) &&  FIGHTING (fch) && 
			  can_see(ch, fch) &&
			  fch->pIndexData->vnum == 
			  ch->pIndexData->guard->rescues)
			{
			  do_rescue(ch, RNAME(fch));
			  break;
			}
		    }
		}
	    }
	}
      if (FIGHTING(ch) == NULL)
	{
	  ch->aff[AFF] |= ch->pIndexData->aff[AFF];
	    if ((ch->society || !IS_SET (ch->act, ACT_SENTINEL))
	      && (MOUNTED_BY (ch) == NULL)
	      && !IS_SET (ch->pIndexData->act3, ACT3_FOLLOW)
	      && number_range(1,15) == 3 && (!ch->fgt ||
					     !ch->fgt->pulling))
	    move_char(ch, number_range(0,5));
	}
      else
	{
	  if (ch->hit < ch->max_hit / 5 &&
	    !IS_SET (ch->act, ACT_SENTINEL) &&
	      number_range(1,3) == 2)
	    do_flee(ch, "");
	}
    } 
  return;
}


void
weather_update (void)
{
  char buf[STD_LENGTH];
  char general_use[500];
  int diff, i;
  CHAR_DATA *wch;
  CHAR_DATA *ch_next;
  SCRIPT_INFO *scr;
  SCRIPT_INFO *scr_next;
  SINGLE_TRIGGER *tr;
  SCRIPT_INFO *s;
  int newday = 0;
  buf[0] = '\0';
  
  
  /* Check running scripts for delay resumes */
  for (scr = info_list; scr != NULL; scr = scr_next)
    {
      scr_next = scr->next;
      if (scr->delay_ticks <= 0)
	continue;
      if (scr->tick_type != 3)
	continue;
      scr->delay_ticks--;
      if (scr->delay_ticks == 0)
	{
	  execute_code (scr);
	}
    }
  
  if (ticks_to_reboot != 0)
    {
      if (ticks_to_reboot == 1)
	{
	  CHAR_DATA *bah;
	  FILE *fpqr;
	  extern bool aturion_down;
	  if (nightmare)
	    {
	      sprintf(general_use, "\n\n\x1b[1;31mThe Nightmare Does Not End!\x1b[0;37m\n\r");
	      {
		CHAR_DATA *sch;
		sch=create_mobile(get_mob_index(1));
		char_to_room(sch,get_room_index(2));
		do_echo (sch, general_use);
		extract_char(sch,TRUE);
		ticks_to_reboot = 66667;
	      }
	    }
	  else
	    {
	      if (char_list[MOB_LIST] && IS_MOB(char_list[MOB_LIST]))
		do_asave (char_list[MOB_LIST], "changed");
	      fprintf (stderr, "Auto-saved changed areas.\n");
	      for (bah = char_list[PLAYER_LIST]; bah != NULL; bah = bah->next)
		{
		  if (IS_PLAYER (bah))
		    {
		      do_save (bah, "xx2xx11");
		    }
		}
	      fprintf (stderr, "Auto-saved all players.\n");
	      fprintf (stderr, "Auto-reboot invoked...\n");
	      fpqr = fopen ("reason.fi", "w+");
	      fprintf (fpqr, "Mud-Auto-Reboot \n\rEnd~\n\r");
	      fclose (fpqr);
	      aturion_down = TRUE;
	      return;
	    }
	}
      --ticks_to_reboot;
      sprintf (general_use, "\x1B[1;34m----[\x1B[32mMud Autosave and Reboot in \x1B[37m%d\x1B[32m game ticks/hour%s!\x1B[34m]----\x1B[37;0m",ticks_to_reboot,
	       (ticks_to_reboot == 1 ? "" : "s"));
      {
	CHAR_DATA *sch;
	sch=create_mobile(get_mob_index(1));
	char_to_room(sch,get_room_index(2));
	do_echo (sch, general_use);
	extract_char(sch,TRUE);
      }
    }
  if (ticks_to_battlefield != 0)
    {
      CHAR_DATA *sch;
      sch=create_mobile(get_mob_index(1));
      char_to_room(sch,get_room_index(2));
      
      if (ticks_to_battlefield == 1)
	{
	  allow_anything = TRUE;
	  {
	    do_transfer (sch, "all Battleground");
	  }
	  allow_anything = FALSE;
	}
      if(--ticks_to_battlefield > 0)
	{
	  int jj;
	  bool hasprize = FALSE;
	  sprintf (general_use, "\x1B[1;34m-->\x1B[37m%d\x1B[34m game hour%s to battleground! [Levels %d-%d]\x1B[37;0m",
		   ticks_to_battlefield, (ticks_to_battlefield == 1 ? "" : "s"),
		   min_level, max_level);
	  do_echo (sch, general_use);
	  for (jj = 0; jj < MAX_NUM_BG_PRIZES; jj++)
	    {
	      if (bg_prize[jj] != NULL)
		{
		  
		  sprintf(general_use,"\x1b[1;37m-->\x1b[1;31mBattleground\x1b[1;37m Prize:
\x1b[0;37m%s",format_obj_to(bg_prize[jj], sch, TRUE));
		  do_echo (sch, general_use);
		  hasprize = TRUE;
		}
	    }
	  if (!hasprize)
	    {
	      do_echo(sch, "\x1b[1;37mNo Prizes.\x1b[0;37m\n\r");
	    }
	  if (ticks_to_battlefield > 2)
	    {
	      do_echo (sch, "\x1B[37;0mTo sign up for the battleground, type battle.");
	    }
	}
      
      extract_char(sch, TRUE);
    }
  /*Check for any winners in the battleground */
  if (ticks_to_battlefield == 0)
    {
      DESCRIPTOR_DATA *dd;
      CHAR_DATA *found_winner;
      ROOM_DATA *rid;
      int cnt;
      int jj;
      char general_use[500];
      int people_in_bground;
      people_in_bground = 0;
      found_winner = NULL;
      for (dd = descriptor_list; dd != NULL; dd = dd->next)
	{
	  if (!dd->character || dd->connected != CON_PLAYING)
	    continue;
	  if (dd->character->in_room && 
	      dd->character->in_room->vnum >= BATTLEGROUND_START_VNUM &&
	      dd->character->in_room->vnum <= BATTLEGROUND_END_VNUM)
	    {
	      people_in_bground++;
	      found_winner = dd->character;
	    }
	}
      if (people_in_bground == 1 && found_winner)
	{
	  /*Below checks for mobs that may still be in bground */
	  for (cnt = BATTLEGROUND_START_VNUM; cnt < BATTLEGROUND_END_VNUM; cnt++)
	  {
	    if ((rid = get_room_index (cnt)) == NULL)
	      continue;
	    if ((rid->people != NULL && rid->people != found_winner)
		|| (rid->people && rid->people->next_in_room))
	      {
		found_winner = NULL;
		break;
	      }
	  }
	  if (found_winner != NULL && IS_PLAYER (found_winner))
	    {
	      char_from_room (found_winner);
	      char_to_room(found_winner,get_room_index(found_winner->pcdata->alignment+100));
	      sprintf (general_use, "\x1B[1;34m%s is the battleground winner! \x1B[1;37mCongratulations!\x1B[0m", NAME (found_winner));
	      {
		CHAR_DATA *sch;
		sch=create_mobile(get_mob_index(1));
		char_to_room(sch,get_room_index(2));
		do_echo (sch, general_use);
		do_restore (sch, NAME (found_winner));
		extract_char(sch,TRUE);
	      }
	      for(jj = 0; jj <MAX_NUM_BG_PRIZES; jj++)
		{
		  if(bg_prize[jj] != NULL)
		    {
		      obj_from(bg_prize[jj]);
		      obj_to(bg_prize[jj], found_winner);
		      bg_prize[jj] = NULL;
		    }
		}  
	      send_to_char ("Congratulations! You've won the battleground!\n\r", found_winner);
	    }
	}
    }  
  if (nightmare)
    {
      time_info.hour++;
      if (number_range(1,2) == 1)
	weather_info.temperature  += number_range(1,20);
      else
	weather_info.temperature  -= number_range(1,20);
      if (number_range(1,12) == 2)
	{
	  switch(number_range(1,5))
	    {
	    case 1:
	      strcat(buf, "A blood red splotch appears in the hazy sky.\n\r");
	      break;
	    case 2:
	      strcat(buf, "The sky above is lit by a distant fire.\n\r");
	      break;
	    case 3:
	      strcat(buf, "A flock of winged monsters passes in the distance.\n\r");
	      break;
	    case 4:
	      strcat(buf, "The darkness is eternal.\n\r");
	      break;
	    case 5:
	  strcat(buf, "A dim globe peeks through the bloody overhead clouds.\n\r");
	  break;
	    }
	}
    }
  else
    {
      switch (++time_info.hour)
	{
	case 2:
	  {
	    switch(number_range(1,3))
	      {
	      case 1:
		strcat(buf, "Hungry creatures howl off in the distance.\n\r");
		break;
	      case 2:
		strcat(buf, "A chill wind passes through the darkness...\n\r");
		break;
	      case 3:
		strcat(buf, "A tingling sensation comes over you, as if you are being watched...\n\r");
		break;
	      }
	    break;
	  }
	case 6:
	  weather_info.sunlight = SUN_RISE;
	  strcat (buf, "The first rays of sunlight appear.\n\r");
	  if (time_info.month <= 4 || time_info.month >= 17)
	    weather_info.temperature = 25 + number_range(1,15);
	  else
	    weather_info.temperature = 50 + number_range(1,15);
	  break;
	case 7:
	  weather_info.sunlight = SUN_MORNING;
	  strcat (buf, "A new day begins as the sun peeks over the eastern horizon.\n\r");
	  weather_info.temperature += number_range(1,8);
	  break;
	case 11:
	  weather_info.sunlight = SUN_MIDDAY;
	  strcat (buf, "The sun crawls overhead.\n\r");
	  weather_info.temperature += number_range(1,12);
	  break; 
	case 14:
	  weather_info.sunlight = SUN_AFTERNOON;
	  strcat (buf, "The sun passes overhead and begins its descent to the west.\n\r");
	  weather_info.temperature += number_range(1,9);
	  break;
	case 17:
	  weather_info.sunlight = SUN_EVENING;
	  strcat(buf, "The rays of the sun begin to cast long shadows over the land.\n\r");
	  weather_info.temperature -= number_range(1,9);
	  break;
	case 20:
	  weather_info.sunlight = SUN_SET;
	  strcat (buf, "The sky begins to darken in anticipation of the night to come.\n\r");
	  weather_info.temperature -= number_range(1,12);
	  break;
	case 21:
	  weather_info.sunlight = SUN_DARK;
	  strcat (buf, "The night has begun.\n\r");
	  weather_info.temperature -= number_range(1,8);
	  break;
	case 24:
	  weather_info.temperature -= number_range(1,10);
	  time_info.hour = 0;
	  time_info.day++;
	  day_counter++;
	  save_day_counter ();
	  newday = 1;
	  break;
	}
    }
  if (time_info.day >= 35)
    {
      time_info.day = 0;
      time_info.month++;
    }
  if (time_info.month >= 17)
    {
      strcat (buf, "It is the dawn of a New Year!!!\n\r");
      time_info.month = 0;
      time_info.year++;
    }
  /*
   * Weather change.
   */
  if (!nightmare)
    {
      weather_info.winddir += number_range (0, 2) - 1;
      if (time_info.month >= 3 && time_info.month <= 19)
	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 (time_info.month <= 4 || time_info.month >= 17)
	    {
	      if (number_range(1,6) == 3)
		{
		  strcat (buf, "A few flakes of snow are falling... there is definately a chill in the air!\n\r");
		  weather_info.temperature -= 10;
		}
	      else if (number_range(1,5) == 2)
		{
		  strcat(buf, "Thick clouds obscure the sky.\n\r");
		  weather_info.temperature -=2;
		  weather_info.sky = SKY_CLOUDY;
		}
	    }
	  else if (number_range(1,5) == 2)
	    {
	      strcat(buf, "Clouds start to form off to the west.\n\r");
	      weather_info.temperature -=2;
	      weather_info.sky = SKY_CLOUDY;
	    }
	  break;
	case SKY_CLOUDY:
	  if (time_info.month <= 4 || time_info.month >= 17)
	    {
	      if (number_range(1,5) == 2)
		{
		  strcat(buf, "A few snowflakes start to fall from the sky.\n\r");
		  weather_info.temperature -= 3;
		  weather_info.windspeed += 2;
		}
	      else if (number_range(1,5) == 2)
		{
		  strcat(buf, "Heavy snowfall begins to blanket the land.\n\r");
		  weather_info.temperature -= 5;
		  weather_info.sky = SKY_RAINING;
		  weather_info.windspeed -= 2;
		}
	      else if (number_range(1,2) == 2)
		{
		  strcat(buf, "The clouds part, leaving the clear sky visible above.\n\r");
		  weather_info.temperature += 5;
		  weather_info.windspeed -= 3;
		  weather_info.sky = SKY_CLOUDLESS;
		}
	      else if (number_range(1,24) == 2)
		{
		  strcat(buf, "Thick fog rolls in, obscuring everything.\n\r");
		  weather_info.temperature +=3;
		  weather_info.windspeed -= 3;
		  weather_info.sky = SKY_FOGGY;
		}
	    }
	  else
	    {
	      if (number_range(1,4) == 2)
		{
		  strcat(buf, "The clouds part, leaving the clear sky visible above.\b\r");
		  weather_info.sky = SKY_CLOUDLESS;
		  weather_info.temperature += 4;
		  weather_info.windspeed -= 10;
		}
	      else
		{
		  if (number_range(1,4) == 2)
		    {
		      if (number_range(1,3) != 2)
			{
			  strcat(buf, "The clouds open up, and it begins to rain.\n\r");
		      }
		      else
			{
			  int hash;
			  ROOM_DATA *ridd;
			  TRACK_DATA *tr;
			  TRACK_DATA *tr_n;
			  bool stp = FALSE;
			  strcat (buf, "Dark clouds in the sky begin to pour rain down upon the lands.\n\r");
			  weather_info.windspeed += 5;
			  
			  /* CLEAR ALL TRACKS!! WASHED AWAY */
			  for (hash = 0; hash < HASH_MAX; hash++)
			    {
			      for (ridd = room_hash[hash]; ridd != NULL; ridd = ridd->next)
				{
			       for (tr = ridd->tracks; !stp && tr; tr = tr_n)
				 {
				   tr_n = tr->next;
				   if (tr_n == NULL)
				     stp = TRUE;
				   free_m (tr);
				 }
			       stp = FALSE;
			       ridd->tracks = NULL;
				}
			    }
			}
		    }
		}
	      weather_info.sky = SKY_RAINING;
	      weather_info.temperature -= 6;
	      weather_info.windspeed += 3;
	    }
	  break;
	case SKY_RAINING:
	  if(number_range(1,8) == 2)
	    {
	      if (time_info.month <= 4 || time_info.month >= 17)
		{
		  strcat (buf, "You are caught in a blizzard... It's *damn* cold!\n\r");
		  weather_info.temperature -= 10;
		}
	      else
		strcat (buf, "Lightning flashes in the sky; it looks as if a storm is brewing.\n\r");
	      weather_info.sky = SKY_LIGHTNING;
	      weather_info.windspeed += 10;
	  }
	  else if(number_range(1,3) == 2)
	    {
	      if (time_info.month <= 4 || time_info.month >= 17)
		{
		  strcat (buf, "The snow lets up, and the temperature rises.\n\r");
		  weather_info.temperature += 30;
		}
	      else
		strcat (buf, "The rain has stopped.\n\r");
	      weather_info.sky = SKY_CLOUDY;
	      weather_info.windspeed -= 10;
	      weather_info.temperature += 10;
	    }
	  break;
	case SKY_FOGGY:
	  if (number_range(1,2) == 1)
	    {
	      strcat (buf, "The fog slowly dissolves...\n\r");
	      weather_info.sky = SKY_CLOUDY;
	      weather_info.temperature += 5;
	    }
	  break;
	  
	case SKY_LIGHTNING:
	  if(number_range(1,4) != 3)
	    {
	      if (time_info.month <= 4 || time_info.month >= 17)
		{
		  strcat (buf, "The blizzard subsides.\n\r");
		  weather_info.temperature += 10;
		}
	      else
		strcat (buf, "The lightning has stopped.\n\r");
	    weather_info.sky = SKY_RAINING;
	    weather_info.windspeed -= 7;
	    }
	  break;
	}
    }
  
  for (i = 0; i < TOTAL_LIST; i++)
    {
      if (i == MOB_LIST)
	continue;
      for (wch = char_list[i]; wch != NULL; wch = ch_next)
	{
	  ch_next = wch->next;
	  if (!wch->in_room)
	    continue;
	  if (IS_PLAYER(wch))
	    {
	      if(--wch->pcdata->no_quit < 0)
		wch->pcdata->no_quit = 0;
	      if (!FIGHTING(wch) && --wch->pcdata->no_quit_pk < 0)
		wch->pcdata->no_quit_pk = 0;
	      
	      if (wch->desc && wch->desc == CON_PLAYING)
		{
		  if (nightmare)
		    {
		      if (buf[0] != '\0')
			{
			  send_to_char(buf, wch);
			}
		    }
		  else
		    {
		      if(wch->in_room->sector_type != SECT_INSIDE && 
			 !IS_SET(wch->in_room->room_flags, ROOM_INDOORS |
				 ROOM_UNDERGROUND) &&
			 wch->in_room->sector_type != SECT_UNDERWATER &&
			 wch->in_room->sector_type < SECT_ASTRAL)
			{
			  if (weather_info.sky == SKY_LIGHTNING && number_range (1, 900) == 185)
			    {
			      send_to_char ("You feel your hair stand on your neck...", wch);
			      send_to_char ("ZAP!!\n\r", wch);
			      act ("Watch out! $n just got struck by lightning!", wch, NULL,
				   NULL, TO_ROOM);
			      SUBHIT(wch, 50);
			      if (wch->hit < 0)
				{
				  raw_kill(wch, FALSE);
				  continue;
				}
			    }
			  if (buf[0] != '\0' && IS_AWAKE(wch))
			    {
			      if (((wch->in_room->sector_type == SECT_AIR || wch->in_room->sector_type == SECT_CLOUDS)) && find_str (buf, "fog"))
				continue;
			      if (wch->in_room->sector_type > SECT_CLOUDS &&  wch->in_room->sector_type < SECT_TROPICAL && (!find_str (buf, "snow") || !find_str (buf, "blizzard")   || !find_str (buf, "cloud")))
				continue;
			      
			      if ((wch->in_room->sector_type == SECT_DESERT || wch->in_room->sector_type == SECT_WASTELAND)  && (find_str (buf, "snow") || find_str (buf, "blizzard")))
				continue;
			      if (wch->in_room->sector_type == SECT_TROPICAL  && (find_str (buf, "snow") || find_str (buf, "blizzard")))
				continue;
			      
			      send_to_char (buf, wch);
			    }
			}
		    }
		}
	      continue;
	    }
	check_a1:
	  /* Check for triggers on mobbies! */
	  for (tr = trigger_list[TEVERY_HOUR]; tr != NULL; tr = tr->next)
	    {
	      if (wch->pIndexData->vnum == tr->attached_to_mob)
		{
		  if (tr->players_only)
		    continue;
		  if (tr->running_info && !tr->interrupted)
		    continue;       /* Already running, interrupted, but script says not to allow interruptions. */
		  if (tr->running_info && tr->interrupted != 2)
		    {
		      end_script (tr->running_info);
		      goto check_a1;
		    }
		  /* ----------------- */
		  /* Start the script! */
		  /* ----------------- */
		  tr->running_info = mem_alloc (sizeof (*tr->running_info));
		  s = tr->running_info;
		  bzero (s, sizeof (*s));
		  s->current = wch;
		  s->mob = wch;
		  strcpy (s->code_seg, tr->code_label);
		  s->current_line = 0;
		  s->called_by = tr;
		  s->next = info_list;
		  info_list = s;
		  execute_code (s);
		  /* ----------------- */
		}
	    }
	  
	  if (wch->pIndexData->pShop != NULL && wch->pIndexData->pShop->creates_vnum != 0)
	    {
	      SHOP_DATA *pShop;
	      SINGLE_OBJECT *obj;
	      SINGLE_OBJECT *ooo;
	      OBJ_PROTOTYPE *obj_mask;
	      int vnum_same;
	      vnum_same = 0;
	      pShop = wch->pIndexData->pShop;
	      if (pShop->creates_hours == 1 || (number_range (1, pShop->creates_hours) == 2))
		{
		  for (ooo = wch->carrying; ooo != NULL; ooo = ooo->next_content)
		    if (ooo->pIndexData->vnum == pShop->creates_vnum)
		      vnum_same++;
		  if ((obj_mask = get_obj_index (pShop->creates_vnum)) == NULL)
		    {
		      goto skip_over;
		    }
		  if (obj_mask->item_type == ITEM_FOOD && vnum_same > 24)
		    goto skip_over;
		  if (obj_mask->item_type != ITEM_FOOD && vnum_same > 4)
		    goto skip_over;
		  {
		    obj = create_object (obj_mask, 5);
		    obj_to (obj, wch);
		    SET_BIT (obj->extra_flags, ITEM_INVENTORY);
		    
		  }
		}
	    }
	  if (wch->pIndexData->spec && wch->pIndexData->spec->switches_vnum &&
	      wch->pIndexData->spec->switches_hour == time_info.hour &&
	      !wch->society /* society + switch = bad stuff */)
	    {
	MOB_PROTOTYPE *pmob;
	if ((pmob = (get_mob_index (wch->pIndexData->spec->switches_vnum))) != NULL)
	  {
	    replace_mob (wch, wch->pIndexData->spec->switches_vnum);
	  }
	continue;
	    }
	skip_over:
	  if (wch->in_room == NULL || wch->in_room->area == NULL || wch->in_room->area->nplayer < 1)
	    continue;
	  if (wch->position == POSITION_SLEEPING
	      && IS_SET (wch->pIndexData->act3, ACT3_SLEEP)
	      && time_info.hour > 7 && time_info.hour < 21
	      && dice (1, 3) == 2)
	    {
	      act ("$n wakes up from $s sleep.", wch, NULL, NULL, TO_ROOM);
	      wch->position = POSITION_STANDING;
	      continue;
	    }
	  if (IS_SET (wch->pIndexData->act3, ACT3_SLEEP)
	      && (wch->position == POSITION_STANDING || wch->position == POSITION_RESTING)
	      && FIGHTING (wch) == NULL
	      && (time_info.hour >= 21 || time_info.hour <= 7)
	      && dice (1, 3) == 2)
	    {
	      act ("$n lays down for the night.", wch, NULL, NULL, TO_ROOM);
	      wch->position = POSITION_SLEEPING;
	      continue;
	    }
	  if (IS_MOB (wch) && wch->timer > 0)
	    {
	      if (--wch->timer == 0)
		{
		  act ("$n disappears.", wch, NULL, NULL, TO_ROOM);
		  act ("Your time has run out.", wch, NULL, NULL, TO_CHAR);
		  raw_kill (wch, FALSE);
		  continue;
		}
	    }
	}
    }
  return;
}

/*
   * Update all chars, including mobs.
   * This function is performance sensitive.
 */
void
char_update (void)
{
  CHAR_DATA *ch;
  CHAR_DATA *ch_next;
  time_t save_time;
  AFFECT_DATA af;
  int i, castenum;
  SPELL_DATA *spell;
  SOCIETY_DATA *soc;
  CASTE_DATA *cst;
  bzero (&af, sizeof (af));
  if (chars_sent > 1048576)
    {
      meg_sent++;
      chars_sent -= 1048576;
    }
  
  save_time = current_time;
  
  for (ch = char_list[pulse_hour]; ch != NULL; ch = ch_next)
    {
      AFFECT_DATA *paf;
      AFFECT_DATA *paf_next;
      ch_next = ch->next;
      if (ch->desc && ch->desc->connected != CON_PLAYING)
	continue;
      if (ch->in_room == NULL)
	continue;
      if (CHALLENGE (ch) == ARENA_FIGHTING && (ch->in_room->vnum > 507 || ch->in_room->vnum < 504))
	ch->fgt->challenge = 0;
      if (IS_PLAYER (ch))
	{
	  if (ch->pcdata->challenge_time > 0)
	    ch->pcdata->challenge_time--;
	  if (ch->pcdata->recent_deaths >0 && number_range(1,4) == 3)
	    ch->pcdata->recent_deaths--;
	  if (LEVEL (ch) < 100)
	    {
	      ch->timer++;
	      if (ch->timer > 90) {
                if (ch->desc) {
		  close_socket(ch->desc);
		  continue;
                }
	      }
	      if (ch->timer > 5 && ch->timer < 16)
		ch->timer = 90;
	      if (number_range (1, 3) == 2)
		{
		  gain_condition (ch, COND_DRUNK, -1);
		  if (ch->pcdata->remort_times < 7)
		    gain_condition (ch, COND_FULL, -1);
		  if (ch->pcdata->remort_times < 4 )
		    gain_condition (ch, COND_THIRST, -1);
		}
	      if (IS_PLAYER (ch) && (ch->in_room->sector_type == SECT_DESERT
				     || ch->in_room->sector_type == SECT_WASTELAND)
		  && time_info.hour >= 11 && time_info.hour <= 17 )
		{
		  send_to_char ("Whew it's hot!", ch);
		  gain_condition (ch, COND_THIRST, -2);
		}
	    }
	}
      else
	{
	  if (ch->fgt)
	    {
	      if (ch->fgt->compliance < 25)
		ch->fgt->compliance++;
	      else 
		ch->fgt->compliance--;
	    }
	}
      
      LOOP (paf, ch->affected, 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)
		{
		  spell = skill_lookup (NULL, paf->type);
		  if (paf->type > 0 && spell && spell->wear_off_msg != NULL &&
		      str_cmp (spell->wear_off_msg, "None"))
		    {
		      send_to_char (spell->wear_off_msg, ch);
		      send_to_char ("\n\r", ch);
		    }
		}
	      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 (IS_HURT (ch, POISON))
	{
	  act ("$n shivers and suffers.", ch, NULL, NULL, TO_ROOM);
	  send_to_char ("\x1B[0;31mYou feel painfully ill.\x1B[0m\n\r", ch);
	  if (ch->hit - 2 < 1)
	    {
	      ch->hit = 1;
	    }
	  else
	    SUBHIT(ch,2);
	}
      if (IS_HURT (ch, BURNING))
	{
	  if (ch->hit - 20 < 1)
	    ch->hit = 1;
	  else
	    {
	      SUBHIT(ch,20);
	    }
	  if ((ch->hit / (ch->max_hit / 10)) > 8)
	    {
	      send_to_char ("\x1B[0;31mYou wince in agony and pain as f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms consume your body!\x1B[0m\n\r", ch);
	      act ("\x1B[0;31m$n\x1B[0;31m winces in agony and pain as f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms consume $s body!\x1B[0m", ch, NULL, NULL, TO_ROOM);
	    }
	  else if ((ch->hit / (ch->max_hit / 10)) > 6)
	    {
	      send_to_char ("\x1B[0;31mYou contort in agony as f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms cover your body!\x1B[0m\n\r", ch);
	      act ("\x1B[0;31m$n\x1B[0;31m contorts in agony as f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms cover $s body!\x1B[0m", ch, NULL, NULL, TO_ROOM);
	    }
	  else if ((ch->hit / (ch->max_hit / 10)) > 4)
	    {
	      send_to_char ("\x1B[0;31mYou spasm as your flesh blisters from burning f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms!\x1B[0m\n\r", ch);
	    act ("\x1B[0;31m$n\x1B[0;31m spasms as $s flesh blisters from burning f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms!\x1B[0m", ch, NULL, NULL, TO_ROOM);
	    }
	  else if ((ch->hit / (ch->max_hit / 10)) > 2)
	    {
	      send_to_char ("\x1B[0;31mYou writhe in pain as your skin melts from burning f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms!\x1B[0m\n\r", ch);
	      act ("\x1B[0;31m$n\x1B[0;31m writhes in pain as $s skin melts from burning f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms!\x1B[0m", ch, NULL, NULL, TO_ROOM);
	    }
	  else
	    {
	      send_to_char ("\x1B[0;31mYou convulse in agony as f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms engulf your body!\x1B[0m\n\r", ch);
	      act ("\x1B[0;31m$n\x1B[0;31m convulses in agony as f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms engulf $s body!\x1B[0m", ch, NULL, NULL, TO_ROOM);
	    }
	}
      if (IS_HURT (ch, PLAGUE) && ch->in_room->pcs > 0)
	{
	  act ("$n winces in pain as disease gradually rots his body.",
	       ch, NULL, NULL, TO_ROOM);
	  send_to_char ("You scream in pain as disease slowly rots your body.\n\r", ch);
	  /* Take out Plague spreading JRAJRA  
	     LOOP (plague, ch->in_room->people, plague->next)
	     if (plague != ch
	     && !IS_HURT (plague, PLAGUE)
	     && LEVEL (plague) >= 10 &&
	     number_range (1, 100) < pow.plague_chance)
	     {
	     bzero (&af, sizeof (af));
	     af.type = gsn_plague;
	     af.duration = 6;
	     af.location = APPLY_STR;
	     af.modifier = -5;
	     af.aff[0] = PLAGUE;
	     renew_affect (plague, &af);
	     send_to_char ("You feel as if your body is being eaten away from the inside.\n\r", plague);
	     act ("$n's face turns a deathly pale as the plague spreads to $s body.",
	     plague, NULL, NULL, TO_ROOM);
	     }*/
	  if (ch->hit - 8 < 1)
	    {
	      ch->hit = 1;
	      
	    }
	  else
	    SUBHIT(ch,8);
	}
    }
  return;
}
void
dummycall ()
{
  return;
}

void
char_only_update (void)
{
  CHAR_DATA *ch;
  CHAR_DATA *ch_next;
  SINGLE_TRIGGER *tr;
  SCRIPT_INFO *s;
  SCRIPT_INFO *scr;
  SCRIPT_INFO *scr_next;

/* Check running scripts for delay resumes */
  if (pulse_char == 13)
    {
      for (scr = info_list; scr != NULL; scr = scr_next)
	{
	  scr_next = scr->next;
	  if (scr->delay_ticks <= 0)
	    continue;
	  if (scr->tick_type != 2)
	    continue;
	  scr->delay_ticks--;
	  if (scr->delay_ticks == 0)
	    {
	      execute_code (scr);
	    }
	}
    }


  
  for (ch = char_list[pulse_char]; ch != NULL; ch = ch_next)
    {
      ch_next = ch->next;
      if (ch->desc && ch->desc->connected != CON_PLAYING)
        continue;
      if (ch->position <= POSITION_STUNNED && ch->position >= 0 && ch->hit > 0)
        update_pos (ch);
      if (!ch->in_room) continue;
      
      if (IS_PLAYER (ch))
        {
          mana_gain (ch, FALSE);
	  ch->pcdata->speedwalk -= 50;
	  if (ch->pcdata->speedwalk < 0)
	    ch->pcdata->speedwalk = 0;
	  if (ch->pcdata->auction_count > 0)
	    ch->pcdata->auction_count--;
	  
	  if (!IS_SET(ch->act, PLR_HOLYWALK) && !nightmare)
	    {
	      switch (ch->in_room->sector_type)
		{
		default:
		  break;
		case SECT_AIR:
		case SECT_CLOUDS:
		  {
		    if(FIGHTING (ch) == NULL && !IS_AFF (ch, FLYING))
		      {
			send_to_char ("Oh oh! You are falling to the ground!\n\r", ch);
			act ("$n starts to fall towards the earth!", ch, NULL, NULL, TO_ROOM);
			NEW_POSITION(ch, POSITION_FALLING);
			continue;
		      }
		  }
		break;
		case SECT_UNDERWATER:
		  {
		    if(!IS_AFF (ch, WATER_BREATH) &&
		       !IS_SET(ch->act, PLR_HAS_SCUBA))
		      {
			send_to_char ("You are drowning!!\n\r", ch);
			SUBHIT(ch, number_range (12, 27));
			update_pos (ch);
			if (ch->hit < 0)
			  {
			    strcpy (reasonfd, "Drowning");
			    raw_kill (ch, FALSE);
			    return;
			  }
			
			continue;
		      }
		  }
		break;
		case SECT_WATER_NOSWIM:
		  {
		    if (!IS_SET(ch->act, PLR_HAS_BOAT))
		      {
			if (ch->move > 20)
			  {
			    send_to_char ("You can barely stay afloat in this deep, rough water!\n\r", ch);
			    SUBMOVE(ch, 17);
			    continue;
			  }
			else
			  {
			    send_to_char ("You can't manage to stay afloat! You are drowning!\n\r", ch);
			    SUBHIT(ch, number_range (5, 15));
			    update_pos (ch);
			    if (ch->hit < 0)
			      {
				strcpy (reasonfd, "Drowning");
				raw_kill (ch, FALSE);
				return;
			      }
			    
			    continue;
			  }
		      }
		  }
		break;
		case SECT_ASTRAL:
		  {
		    if(!IS_PROT (ch, CHAOS))
		      {
			send_to_char ("The astral forces pummel you from all sides!!\n\r", ch);
			SUBHIT(ch, number_range (100, 600));
			update_pos (ch);
			if (ch->hit < 0)
			  {
			    strcpy (reasonfd, "Astral Plane");
			    raw_kill (ch, FALSE);
			    return;
			  }
			
			continue;
		      }
		  }
		break;
		case SECT_LAVA:
		  {
		    if(!IS_PROT (ch, FIRE))
		      {
			send_to_char ("The lava is burning you to a crisp!!\n\r", ch);
			SUBHIT(ch, number_range (50, 150));
			update_pos (ch);
			if (ch->hit < 0)
			  {
			    strcpy (reasonfd, "Lava");
			    raw_kill (ch, FALSE);
			    return;
			  }
			
			continue;
		      }
		  }
		}
	    }
           	      FIXIT(ch);
	  if(number_range (1, 20) == 7)
	    {
	      fix_char(ch);
	      
	      if (number_range(1,10) == 3)
		{
		  check_pkdata(ch);
		  do_save (ch, "xx2xx11");
		}
	    } 
	  
	}
      else
        {
        check_a2:
	  /* Check for triggers on mobbies! */
          for (tr = trigger_list[TEVERY_REGENTICK]; tr != NULL; tr = tr->next)
            {
              if (ch->pIndexData->vnum == tr->attached_to_mob)
                {
                  if (tr->players_only)
                    continue;
                  if (tr->running_info && !tr->interrupted)
                    continue;   /* Already running, interrupted, but script says not to allow interruptions. */
                  if (tr->running_info && tr->interrupted != 2)
                    {
                      end_script (tr->running_info);
                      goto check_a2;
                    }
                  /* ----------------- */
                  /* Start the script! */
                  /* ----------------- */
                  tr->running_info = mem_alloc (sizeof (*tr->running_info));
                  s = tr->running_info;
                  bzero (s, sizeof (*s));
                  s->current = ch;
                  s->mob = ch;
                  strcpy (s->code_seg, tr->code_label);
                  s->current_line = 0;
                  s->called_by = tr;
                  s->next = info_list;
                  info_list = s;
                  execute_code (s);
                  /* ----------------- */
                }
            }
/* End trigger check! */


          /* Scavenge */
          if (IS_SET (ch->act, ACT_SCAVENGER)
              && ch->in_room->contents != NULL
              && number_range (0, 4) == 1)
            {
              SINGLE_OBJECT *obj;
              SINGLE_OBJECT *obj_best;
              int max;
              max = 1;
              obj_best = NULL;
              for (obj = ch->in_room->contents; obj != NULL; obj = obj->next_content)
                {
                  if (obj->in_room && IS_SET (obj->pIndexData->wear_flags, ITEM_TAKE) && CAN_WEAR (obj, ITEM_TAKE) && obj->cost > max)
                    {
                      obj_best = obj;
                      max = obj->cost;
                    }
                }
              if (obj_best != NULL && obj_best->in_room == ch->in_room && IS_SET (obj_best->pIndexData->wear_flags, ITEM_TAKE))
                {
                  act ("$n picks up $p.", ch, obj_best, ch, TO_ROOM);
                  obj_from (obj_best);
                  obj_to (obj_best, ch);
                  if (obj_best->in_room == NULL)
                    {
                      wear_obj (ch, obj_best, FALSE);
                    }
                }
            }
          if (IS_SET (ch->pIndexData->act3, ACT3_REGENERATE) && number_range (1, 7) == 2)
            {
              if (ch->hit < ch->max_hit)
                {
                  act ("$n regenerates.", ch, NULL, NULL, TO_ROOM);
		  ADDHIT (ch, UMIN (((ch->max_hit - ch->hit)/5), ch->max_hit/10));
                  update_pos (ch);
                }
            }
        }
      if (ch->hit < ch->max_hit)
        {
          ADDHIT(ch, hit_gain (ch));
          
        }
      
      if (ch->move < ch->max_move)
        {
          ADDMOVE(ch,move_gain (ch));
        }
      if (ch->hit == -1)
        {
          NEW_POSITION(ch, POSITION_STANDING);
          ch->hit = 1;
        }
      if (ch->position == POSITION_STUNNED)
        update_pos (ch);
      if (check_body_temp (ch))
        continue;
      if (IS_PLAYER (ch) && ch->timer > 93 && ch->pcdata->no_quit_pk < 1)
        {
          do_quit (ch, "specqa");
          continue;
        }
    }
  return;
}
void
transport_update (void)
{
  CHAR_DATA *ch;
  EXIT_DATA *pexit;
  CHAR_DATA *ch_next = NULL;
  ROOM_DATA *to_room;
  ROOM_DATA *roomav = NULL;
  ROOM_DATA *roomstink = NULL;
  bool avalancheoff = FALSE;
  CHAR_DATA *victim;
  SCRIPT_INFO *scr;
  SCRIPT_INFO *scr_next;
  SINGLE_TRIGGER *tr;
  SCRIPT_INFO *s;
  int door, i, num, j;
  I_SHIELD *shld;
  SINGLE_OBJECT *shield;
  SPELL_DATA *spl;
  int percent;
  bool FLAGGYSET = FALSE;
  if (pulse_transport == 10)
    {
      for (scr = info_list; scr != NULL; scr = scr_next)
	{
	  scr_next = scr->next;
	  if (scr->delay_ticks <= 0)
	    continue;
	  if (scr->tick_type != 1)
	    continue;
	  scr->delay_ticks--;
	  if (scr->delay_ticks == 0)
	    {
	      execute_code (scr);
	    }
	  check_background_processes ();
	}
    }
  for (j = pulse_transport; j < TOTAL_LIST; j += TOTAL_LIST/3)
    {
      if (j == MOB_LIST)
	continue;
      for (ch = char_list[j]; ch != NULL; ch = ch_next)
	{ 
	  ch_next = ch->next;
	  if (IS_MOB(ch) && IS_SET(ch->pIndexData->act4, ACT4_QUICKTICK))
	    {
	    check_a3:
	      /* Check for triggers on mobbies! */
	      for (tr = trigger_list[TEVERY_QUICKTICK]; tr != NULL; tr = tr->next)
		{
		  if (ch->pIndexData->vnum == tr->attached_to_mob)
		    {
		      if (tr->players_only)
			continue;
		      if (tr->running_info && !tr->interrupted)
			continue;   /* Already running, interrupted, but script says not to allow interruptions. */
		      if (tr->running_info && tr->interrupted != 2)
			{
			  end_script (tr->running_info);
			  goto check_a3;
			}
		      /* ----------------- */
		      /* Start the script! */
		      /* ----------------- */
		      tr->running_info = mem_alloc (sizeof (*tr->running_info));
		      s = tr->running_info;
		      bzero (s, sizeof (*s));
		      s->current = ch;
		      s->mob = ch;
		      strcpy (s->code_seg, tr->code_label);
		      s->current_line = 0;
		      s->called_by = tr;
		      s->next = info_list;
		      info_list = s;
		      execute_code (s);
		      /* ----------------- */
		    }
		}
	    }
	  if (j == MOB_LIST)
	    continue;
	  for (i = 0; i < MAX_HOLD; i++)
	    {
	      if (ch->hold[i] && number_range(1,25) == 2)
		{
		  num = 0;
		  if (ch->hold[i]->pIndexData->item_type == ITEM_GEM)
		    {
		      num = ((I_GEM *)ch->hold[i]->more)->casts_spell;
		    }
		  else if (ch->hold[i]->pIndexData->item_type == ITEM_WEAPON)
		    {
		      num = ((I_WEAPON *)ch->hold[i]->more)->casts_spell;
		    }
		  if (num > 0 && (spl = skill_lookup(NULL, num)) != NULL)
		    {
		      if (spl->spell_type == TAR_CHAR_OFFENSIVE && FIGHTING(ch))
			{
			  if (number_range (1,10) == 3)
			    area_spell = TRUE;
			  else
			    area_spell = FALSE;
			  general_spell(spl, LEVEL(ch), ch, FIGHTING(ch));
			  area_spell = FALSE;
			}
		      else if (spl->spell_type == TAR_CHAR_DEFENSIVE ||
			       spl->spell_type == TAR_CHAR_SELF)
			{
			  if (number_range(1, 10) == 3)
			    area_spell = TRUE;
			  general_spell(spl, LEVEL(ch), ch, ch);
			  area_spell = FALSE;
			}
		      
		    }
		}
	    }
	  for (shield = ch->carrying; shield != NULL; shield =shield->next_content)
	    {
	      if(worn_flags[shield->wear_loc].flagname != ITEM_FLOATING)
		break;
	      if(shield->pIndexData->item_type != ITEM_SHIELD)
		continue;
	      shld = (I_SHIELD *)shield->more;
	      if (shld->current_power < shld->max_power)
		{
		  shld->current_power +=3;
		  shld->current_power += UMIN(shld->current_power/11, shld->max_power/15);
		  if (shld->current_power > shld->max_power)
		    {
		      shld->current_power = shld->max_power;
		    }
		  percent = PERCENTAGE(shld->current_power, shld->max_power)/10;
		  switch (percent)
		    {
		    case 1:
		      send_to_char("Your powershield begins to get some energy back.\n\r", ch);
		      break;
		    case 5:
		      send_to_char("Your powershield is glowing with greater power.\n\r", ch);
		      break;
		    case 9:
		      send_to_char("Your powershield is glowing with tremendous energy.\n\r", ch);
		      break;
		    case 10:
		      send_to_char("Your powershield is fully charged.\n\r", ch);
		      break;
		    }
		}
	    }
	  if (IS_HURT (ch, WOUND))
	    {
	      if (LEVEL(ch) < IMM_LEVEL && number_range(1, (get_curr_con(ch) * 2)) == 1) 
		{
		  SUBHIT(ch, number_range(5,13));
		  if (ch->hit < 0)
		    {
		      raw_kill (ch, TRUE);
		      send_to_char ("Your body goes into convulsions as you die of grievous wounds!\n\r", ch);
		      act ("$n's body goes into convulsions as $E dies from grievous wounds!\n\rYou hear $n's death cry!", ch, NULL, NULL, TO_ROOM);
		    }
		  else
		    {
		      send_to_char("Your wounds tear at you, leaving you in agony!\n\r", ch);
		    }
		}
	    }
	  if (nightmare && ch->hit > 100)
	    {
	      ch->hit -= 1;
	    }
	  if (IS_AFF (ch, REGENERATE))
	    {
	      if (ch->hit < ch->max_hit)
		{
		  ADDHIT(ch, number_range(2,12));
		  
		}
	      if (ch->move < ch->max_move)
		{
		  ch->move++;
		}
	    }
	  if (nightmare && ch->in_room->vnum >= 100 && ch->in_room->vnum < 110 && number_range(1,7) == 2)
	    {
	      int new_room;
	      int k;
	      act("$n cannot stay here during the nightmare!\n\r", ch, NULL, NULL, TO_ROOM);
	      send_to_char("You cannot stay here during the nightmare!\n\r", ch);
	      for (k = 0; k < 10; k++)
		{
		  new_room = number_range(1200, 200000);
		  if ((get_room_index(new_room) == NULL))
		    new_room = 0;
		  else
		    
		    break;
		}
	      char_from_room(ch);
	      char_to_room(ch,get_room_index(new_room));
	    }
	  if (IS_MOB (ch))
	    {
	      if (IS_SET (ch->act, ACT_SCRAMBLE)
		  && !IS_SET (ch->act, ACT_SENTINEL)
		  && (door = number_range (0, 7)) <= 5
		  && (pexit = ch->in_room->exit[door]) != NULL
		  && (ROOM_DATA *) pexit->to_room != NULL
		  && (!pexit->d_info || !IS_SET (pexit->d_info->exit_info, EX_CLOSED))
		  && !IS_SET (((ROOM_DATA *) pexit->to_room)->room_flags, ROOM_NO_MOB)
		  && (!IS_SET (ch->act, ACT_STAY_AREA)
		      || ((ROOM_DATA *) pexit->to_room)->area == ch->in_room->area)
		  && (!ch->fgt || !ch->fgt->pulling))
		{
		  move_char (ch, door);
		}
	      if(IS_SET(ch->pIndexData->act4, ACT4_PROTECTOR) && number_range(1,7) == 3)
		{
		  CHAR_DATA *enemy;
		  if ((enemy = get_char_room_near(ch, ch->in_room, 6, "enemy")) != NULL )
		    {
		      SPELL_DATA *spl;
		      
		      if((spl = skill_lookup(NULL, number_range(58,116))) != NULL)
			{
			  if (enemy->in_room != ch->in_room)
			    general_spell(spl, LEVEL(ch), ch, enemy);
			}
		    }
		}
	      if (HUNTING (ch) != NULL && ch->position >= POSITION_STANDING)
		{
		  char buf[200];
		  if ((victim = get_char_world (ch, HUNTING (ch))) == NULL)
		    continue;
		  if (FIGHTING (ch) != NULL ||
		      ch->position == POSITION_FIGHTING ||
		      ch->position == POSITION_GROUNDFIGHTING)
		    continue;
		  if (!IS_SET (ch->pIndexData->act3, ACT3_MUTE) && 
		      (FIGHTING (victim) != NULL &&	
		       ch->in_room == victim->in_room &&
		       victim->fgt->fighting->position != POSITION_GROUNDFIGHTING))
		    {
		      if (ch->pIndexData->will_help && ch->pIndexData->yeller_number != 0)
			{
			  sprintf (buf, "You shall pay for your cruelty!!");
			  if (can_yell (ch))
			    do_say (ch, buf);
			}
		      else
			{
			  sprintf (buf, "There you are, %s, but not for long!", NAME (victim));
			  if (can_yell (ch))
			    do_yell (ch, buf);
			}
		      set_fighting (ch, victim);
		    }
		}
	      if (ch->wait < 0)
		ch->wait = 0;
	      if (FIGHTING (ch) == NULL &&  
		  HUNTING (ch) != NULL && !IS_SET (ch->act, ACT_SENTINEL))
		hunt_victim (ch);
	      
	      if (!ch->in_room || ch->in_room->area->nplayer < 1)
		continue;
	    }
	  if (IS_PLAYER (ch))
	    {
	      if (FIGHTING (ch) == NULL && 
		  (ch->position == POSITION_FIGHTING || 
		   ch->position == POSITION_GROUNDFIGHTING))
		NEW_POSITION(ch, POSITION_STANDING);
	      ch->wait -= 8;
	      if (ch->wait < 0)
		ch->wait = 0;
	      if (ch->position == POSITION_FALLING)
		{
		  if (IS_AFF (ch, FLYING) || IS_SET (ch->act, PLR_HOLYWALK))
		    {
		      send_to_char ("You stop falling.\n\r", ch);
		      act ("$n stops falling.", ch, NULL, NULL, TO_ROOM);
		      NEW_POSITION(ch, POSITION_STANDING);
		      continue;
		    }
		  else 
		    {
		      if (ch->in_room->exit[DIR_DOWN] &&
			  (ROOM_DATA *) ch->in_room->exit[DIR_DOWN]->to_room != NULL
			  && ch->in_room->sector_type == SECT_AIR)
			{
			  send_to_char ("Still falling...\n\r", ch);
			  act ("$n falls right by you.", ch, NULL, NULL, TO_ROOM);
			  to_room = ch->in_room->exit[DIR_DOWN]->to_room;
			  char_from_room (ch);
			  char_to_room (ch, to_room);
			  do_look (ch, "auto");
			  act ("$n falls from above...", ch, NULL, NULL, TO_ROOM);
			  continue;
			}
		      else
			{
			  send_to_char ("OUCH! You land with a loud THUD!\n\r", ch);
			  act ("$n slams into the ground!", ch, NULL, NULL, TO_ROOM);
			  NEW_POSITION(ch, POSITION_STANDING);
			  if (ch->hit > 25)
			    {
			      SUBHIT(ch, number_range(14,20));
			  
			    }
			  if (ch->position >= POSITION_STUNNED)
			    NEW_POSITION(ch, POSITION_RESTING);
			  continue;
			}
		    }
		}
	      if (ch->in_room->room_flags2 != 0)
		{
		  
		  if (IS_SET (ch->in_room->room_flags2, ROOM2_MANADRAIN))
		    {
		      mana_gain (ch, 2);
		    }
		  else if (IS_SET (ch->in_room->room_flags2, ROOM2_EXTRAMANA))
		    {
		      mana_gain (ch, TRUE);
		    }
		  if (IS_SET (ch->in_room->room_flags2, ROOM2_EXTRAHEAL))
		    {
		      if (ch->hit < ch->max_hit && ch->position)
			{
			  ADDHIT(ch, 2);
			  
			}
		    }
		  if (IS_SET(ch->in_room->room_flags2, ROOM2_CASINO) ||
		      (ch->pcdata->casino == CASINO_DECK &&
		       ch->pcdata->casino_ticks <= 1))
		    casino_update(ch);
		  
		  else if (ch->pcdata->casino > 0)
		    {
		      int k;
		      send_to_char ("You left the casino and lost your bet!\n\r", ch);
		      ch->pcdata->casino = 0;
		      for(k = 0; k < 10; k++)
			ch->pcdata->casino_outcome[k] = 0;
		      ch->pcdata->casino_bet = 0;
		      ch->pcdata->casino_ticks = 0;
		    } 
		  if (ch->data_type !=K_CHAR)
		    continue;
		}
	      if (IS_SET (ch->act, PLR_HOLYWALK))
		continue;
	    }
	  
	  if (ch->in_room->room_flags2 > 0 && number_range(1,4) == 2)
	    {
	      if (IS_SET (ch->in_room->room_flags2, ROOM2_FIRETRAP) && !IS_PROT(ch, FIRE))
		{
		  int chan;
		  if (IS_MOB (ch))
		    chan = (LEVEL (ch) / (double) 1.5);
		  else
		    chan = get_curr_dex (ch) + get_curr_int (ch);
		  if (number_range (1, 55) > chan)
		    {
		      act ("Searing flames rise up around you, burning your flesh!", ch, NULL, NULL, TO_CHAR);
		      act ("$N is engulfed in flames!", ch, NULL, ch, TO_ROOM);
		      SUBHIT(ch, number_range (1, 30));
		      update_pos (ch);
		      if (ch->position == POSITION_DEAD)
			{
			  strcpy (reasonfd, "Fire");
			  raw_kill (ch, FALSE);
			  continue;
			}
		      
		    }
		  else
		    act ("Searing flames rise up around you, but you quickly move out of the way!!", ch, NULL, NULL, TO_CHAR);
		}
	      if (IS_SET (ch->in_room->room_flags2, ROOM2_ROCKTRAP) && !IS_PROT(ch, SHARDS))
		{
		  if (number_range (0, 2) == 1)
		    {
		      int chan;
		      int dam;
		      if (IS_MOB (ch))
			chan = (LEVEL (ch) / (double) 1.5);
		      else
			chan = get_curr_dex (ch) + get_curr_int (ch);
		      if (number_range (1, 55) > chan)
			{
			  act ("Large rocks fall from above, hitting you on the head!", ch, NULL, NULL, TO_CHAR);
			  act ("$N is smashed on the head by large rocks!", ch, NULL, ch, TO_ROOM);
			  dam = number_range (1, 50);
			  if (dam < 1)
			    dam = 1;
			  SUBHIT(ch,dam);
			  update_pos (ch);
			  if (ch->position == POSITION_DEAD)
			    {
			      strcpy (reasonfd, "Falling rocks");
			      raw_kill (ch, FALSE);
			      continue;
			    }
			  
			}
		      else
			act ("Your quick thinking and fast action allows you to dodge a bunch of\n\rlarge rocks that fall from the ceiling!", ch, NULL, NULL, TO_CHAR);
		    }
		}
	      if (IS_SET (ch->in_room->room_flags2, ROOM2_ARROWTRAP) ||
		  IS_SET (ch->in_room->room_flags2, ROOM2_POISONTRAP))
		{
		  int chan;
		  int dam;
		  if (IS_MOB (ch))
		    chan = (LEVEL (ch));
		  else
		    chan = get_curr_dex (ch) + get_curr_wis (ch) + get_curr_int (ch);
		  if (number_range (1, 80) > chan)
		    {
		      act ("Small arrows seem to shoot out at you from nowhere. OUCH!", ch, NULL, NULL, TO_CHAR);
		      act ("$N is pierced by a small barage of arrows!", ch, NULL, ch, TO_ROOM);
		      dam = number_range (1, 25);
		      if (ch->armor > 140)
			{
			  act ("Your superb armor shrugs off most of the puny arrows!", ch, NULL, NULL, TO_CHAR);
			  dam -= 15;
			}
		      else if (ch->armor > 110)
			{
			  act ("Your armor lessens the penetration of the arrows!", ch, NULL, NULL, TO_CHAR);
			  dam -= 6;
			}
		      if (dam < 1)
			dam = 1;
		      SUBHIT(ch,dam);
		      update_pos (ch);
		      
		      if (ch->position == POSITION_DEAD)
			{
			  raw_kill (ch, FALSE);
			  continue;
			}
		    }
		  else
		    act ("Arrows suddenly fire at you from out of nowhere, but your quick thinking\n\rand fast reflexes allow you to dodge them!", ch, NULL, NULL, TO_CHAR);
		}
	      if (IS_SET (ch->in_room->room_flags2, ROOM2_SPIKETRAP) && number_range (1, 3) == 2)
		{
		  int chan;
		  int dam;
		  if (IS_MOB (ch))
		    chan = (LEVEL (ch));
		  else
		    chan = get_curr_dex (ch) + get_curr_wis (ch) + get_curr_int (ch);
		  if (number_range (1, 80) > chan)
		    {
		      act ("You stumble and fall on some nasty spikes!", ch, NULL, NULL, TO_CHAR);
		      act ("$N stumbles and lands hard on some spikes!", ch, NULL, ch, TO_ROOM);
		      dam = number_range (1, 35);
		      if (ch->armor > 200)
			{
			  act ("Your superb armor prevents penetration!", ch, NULL, NULL, TO_CHAR);
			  dam -= 25;
			}
		      else if (ch->armor > 130)
			{
			  act ("Your armor lessens the penetration of the spikes!", ch, NULL, NULL, TO_CHAR);
			  dam -= 8;
			}
		      if (dam < 1)
			dam = 1;
		      SUBHIT(ch,dam);
		      update_pos (ch);
		      
		      if (ch->position == POSITION_DEAD)
			{
			  raw_kill (ch, FALSE);
			  continue;
			}
		    }
		}
	      if ((IS_SET (ch->in_room->room_flags2, ROOM2_GASTRAPONE) ||
		   IS_SET (ch->in_room->room_flags2, ROOM2_GASTRAPTWO)) &&
		  !IS_PROT(ch, GAS))
		{
		  int dam;
		  if (number_range (1, 2) == 1)
		    {
		      act ("Horrible noxious gasses which hang in the air here make your lungs burn!", ch, NULL, NULL, TO_CHAR);
		      act ("$N coughs uncontrollably and $s eyes water!", ch, NULL, ch, TO_ROOM);
		      if (IS_SET (ch->in_room->room_flags2, ROOM2_GASTRAPONE))
			{
			  dam = number_range (1, 4);
			}
		      else
			dam = number_range (1, 35);
		      SUBHIT(ch,dam);
		      update_pos (ch);
		      
		      if (ch->position == POSITION_DEAD)
			{
			  raw_kill (ch, FALSE);
			  continue;
			}
		      if (IS_SET (ch->in_room->room_flags2, ROOM2_GASTRAPTWO) && !IS_PROT(ch, POISON))
			{
			  AFFECT_DATA af;
			  af.type = gsn_poison;
			  af.duration = number_range (2, 10);
			  af.modifier = -2;
			  if (IS_HURT (ch, POISON))
			    {
			      af.duration = 1;
			      af.modifier = 0;
			    }
			  af.location = APPLY_STR;
			  af.aff[0] = POISON;
			  renew_affect (ch, &af);
			  act ("You feel very sick! The gas must be poisonous!", ch, NULL, NULL, TO_CHAR);
			}
		    }
	    }
	      if (IS_SET (ch->in_room->room_flags2, ROOM2_AVALANCHE))
		{
		  int dam;
		  avalancheoff = TRUE;
		  roomav = ch->in_room;
		  act ("You are smashed by huge chunks of ice and snow!\n\rAVALANCHE!!!!", ch, NULL, NULL, TO_CHAR);
		  dam = number_range (10, 55);
		  if (number_range (1, 3) == 2)
		    {
		      act ("Snow completely covers you! You can't breath!!!", ch, NULL, NULL, TO_CHAR);
		      dam += number_range (20, 40);
		    }
		  SUBHIT(ch,dam);
		  update_pos (ch);
		  
		  if (ch->position == POSITION_DEAD)
		    {
		      raw_kill (ch, FALSE);
		      continue;
		    }
		}
	      if (IS_SET (ch->in_room->room_flags2, ROOM2_GEYSERTRAP) && number_range (1, 10) == 2)
		{
		  int dam;
		  act ("You are sprayed by scalding hot water!!!", ch, NULL, NULL, TO_CHAR);
		  dam = number_range (10, 40);
		  SUBHIT(ch,dam);
		  update_pos (ch);
		  
		  if (ch->position == POSITION_DEAD)
		    {
		      raw_kill (ch, FALSE);
		      continue;
		    }
		}
	      
	      if (FLAGGYSET && IS_SET (roomstink->room_flags2, ROOM2_GASTRAPONE))
		roomstink->room_flags2 ^= ROOM2_GASTRAPONE;
	      if (avalancheoff)
		roomav->room_flags2 ^= ROOM2_AVALANCHE;
	    }
	 
	}
    }
  return;
}

void
obj_update (void)
{
  SINGLE_OBJECT *obj;
  SINGLE_OBJECT *obj_next;
  SINGLE_OBJECT *objtmp;
  SINGLE_OBJECT *objnxt;
  if (arena_timelimit > -1)
    arena_timelimit--;
  if (arena_timelimit == 0)
    {
      arena_timelimit = -1;
      give_back_money ();
      {
	CHAR_DATA *sch;
	sch=create_mobile(get_mob_index(1));
	char_to_room(sch,get_room_index(2));
	do_cancel (sch, "");
	extract_char(sch,TRUE);
      }
    }
  
  if (number_range (1, 3) > 1)
    return;
  for (obj = object_list[OBJ_TIMED]; obj != NULL; obj = obj_next)
    {
      CHAR_DATA *owner;
      CHAR_DATA *rch;
      char *message;
      obj_next = obj->next;
      if (obj->in_room == NULL && obj->carried_by == NULL && obj->in_obj == NULL)
        continue;
      
      
      /* Move this to object update */
      if (obj->carried_by && obj->carried_by->in_room &&
          obj->pIndexData->item_type == ITEM_LIGHT
          && IS_LIT (obj) && ((I_LIGHT *) obj->more)->max_light > 0)
        {
          if (--((I_LIGHT *) obj->more)->light_now == 0 && obj->carried_by->in_room != NULL)
            {
              --obj->carried_by->in_room->light;
              if (IS_PLAYER(obj->carried_by) &&
		  obj->carried_by->pcdata->light > 0)
		obj->carried_by->pcdata->light--;
              act ("$p goes out.", obj->carried_by, obj, NULL, TO_ROOM);
              act ("$p goes out.", obj->carried_by, obj, NULL, TO_CHAR);
              REMOVE_BIT (((I_LIGHT *) obj->more)->light_lit, LIGHT_LIT);
              if (!IS_SET (((I_LIGHT *) obj->more)->light_lit, LIGHT_FILLABLE))
                {
		  
                  free_it (obj);
                  continue;
                }
            }
          if (((I_LIGHT *) obj->more)->light_now > 0)
            {
              switch (PERCENTAGE (((I_LIGHT *) obj->more)->light_now, ((I_LIGHT *) obj->more)->max_light) / 10)
                {
                case 0:
                  act ("$p belonging to $n, sputters.", obj->carried_by, obj, NULL, TO_ROOM);
                  act ("$p flickers and sputters.", obj->carried_by, obj, NULL, TO_CHAR);
                  break;
                case 1:
                  act ("$p belonging to $n, flickers.", obj->carried_by, obj, NULL, TO_ROOM);
                  act ("$p flickers.", obj->carried_by, obj, NULL, TO_CHAR);
                  break;
                case 2:
                  act ("$p belonging to $n, flickers slightly.", obj->carried_by, obj, NULL, TO_ROOM);
                  act ("$p flickers slightly.", obj->carried_by, obj, NULL, TO_CHAR);
                  break;
                }
            }
        }
      
      if (obj->timer <= 0 || --obj->timer > 0)
        continue;
      
      if ((owner = obj->carried_by) != NULL && owner->in_room && obj->wear_loc != -1)
        unequip_char (owner, obj);
      if (owner && !owner->in_room) continue;
      
      switch (obj->pIndexData->item_type)
        {
        default:
          message = "$p vanishes.";
          break;
        case ITEM_FOUNTAIN:
          message = "$p dries up.";
          break;
        case ITEM_CORPSE_NPC:
          message = "$p decays into dust.\x1B[37;0m";
          break;
        case ITEM_CORPSE_PC:
          {
            char name[SML_LENGTH];
            char *pd;
            char buffy[200];
            pd = OOSTR (obj, short_descr);
            pd = one_argy (pd, name);
            pd = one_argy (pd, name);
            pd = one_argy (pd, name);
            pd = one_argy (pd, name);
            /*name now equals the name of the person */
            sprintf (buffy, "rm %s%s.cor &", PLAYER_DIR_2, capitalize (name));
            system (buffy);

            if (obj->in_room == NULL)
              continue;
            for (objtmp = obj->contains; objtmp != NULL; objtmp = objnxt)
              {
                objnxt = objtmp->next_content;
                obj_from (objtmp);
                obj_to (objtmp, obj->in_room);
              }
            message = "$p decays into dust.";
            break;
          }
        case ITEM_FOOD:
          message = "$p rots.";
          break;
        }
      if (obj->pIndexData->vnum != 40)
        {
          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);
            }
        }
      /*get rid of power coin!? */
      if (obj->carried_by != NULL && obj->wear_loc != -1)
        unequip_char (obj->carried_by, obj);
      free_it (obj);
    }
  return;
}

bool
can_yell (CHAR_DATA * ch)
{
  if (IS_PLAYER (ch))
    return TRUE;
  if (ch->pIndexData->mobtype == MOB_PLANT ||
      ch->pIndexData->mobtype == MOB_GENERAL_ANIMAL ||
      ch->pIndexData->mobtype == MOB_DUMMY ||
      ch->pIndexData->mobtype == MOB_INSECT ||
      ch->pIndexData->mobtype == MOB_UNDEAD ||
      ch->pIndexData->mobtype == MOB_BIRD ||
      ch->pIndexData->mobtype == MOB_FISH ||
      ch->pIndexData->mobtype == MOB_CANINE ||
      ch->pIndexData->mobtype == MOB_FELINE ||
      ch->pIndexData->mobtype == MOB_REPTILE ||
      ch->pIndexData->mobtype == MOB_GHOST ||
      ch->pIndexData->mobtype == MOB_ARACHNID ||
      ch->pIndexData->mobtype == MOB_MUTANT ||
      ch->pIndexData->mobtype == MOB_RODENT)
    return FALSE;
  return TRUE;
}

void
racehate_message (CHAR_DATA * ch)
{
  if (IS_PLAYER (ch))
    return;
  if (ch->pIndexData->mobtype == MOB_PLANT ||
      ch->pIndexData->mobtype == MOB_GENERAL_ANIMAL ||
      ch->pIndexData->mobtype == MOB_DUMMY ||
      ch->pIndexData->mobtype == MOB_INSECT ||
      ch->pIndexData->mobtype == MOB_UNDEAD ||
      ch->pIndexData->mobtype == MOB_BIRD ||
      ch->pIndexData->mobtype == MOB_FISH ||
      ch->pIndexData->mobtype == MOB_CANINE ||
      ch->pIndexData->mobtype == MOB_FELINE ||
      ch->pIndexData->mobtype == MOB_REPTILE ||
      ch->pIndexData->mobtype == MOB_GHOST ||
      ch->pIndexData->mobtype == MOB_ARACHNID ||
      ch->pIndexData->mobtype == MOB_MUTANT ||
      ch->pIndexData->mobtype == MOB_RODENT)
    return;
  switch (number_range(1,4))
    {
    case 1:
      do_say (ch, "I don't like your kind! I think I'll just kill you...");
      break;
    case 2:
      do_say (ch, "All of your kind must die!");
      break;
    case 3:
      do_say(ch, "Your kind will be obliterated!");
      break;
    }
  return;
}

void
aggr_update (void)
{
  CHAR_DATA *wch;
  CHAR_DATA *ch_next;
  CHAR_DATA *ch;
  CHAR_DATA *victim;
  SCRIPT_INFO *scr;
  SCRIPT_INFO *scr_next;
  int count = 0;
  int num = 0;
  int align_count = 0;
/* Check running scripts for delay resumes */
  for (scr = info_list; scr != NULL; scr = scr_next)
    {
      scr_next = scr->next;
      if (scr->tick_type != 4)
        continue;
      if (--scr->delay_ticks <= 0)
	{
          execute_code (scr);
        }
    }


  for (ch = aggro_check; ch != NULL; ch = ch_next)
    {
      count = 0;
      num = 0;
      align_count = 0;
      ch_next = ch->next;
      if (!ch->in_room || ch->in_room->pcs == 0 || IS_PLAYER(ch) ||
	  IS_HURT(ch, CHARM) || ch->data_type == 50 || ch->data_type == 0)
	{
	  remove_from_aggro_list(ch);
	  continue;
	}
      if (FIGHTING(ch))
	continue;
      if ((!ch->fgt || !ch->fgt->hunting) &&
	  !IS_SET(ch->act, ACT_AGGRESSIVE) &&
	  !IS_SET(ch->pIndexData->act4, ACT4_KILL_OPP) &&
	  !IS_SET(ch->act, ACT_ANGRY))
	{
	  remove_from_aggro_list(ch);
	  continue;
	}
      if (IS_SET(ch->act, ACT_ANGRY) && number_range(1,6) != 3)
	continue;
      victim = NULL;
      for (wch = ch->in_room->people; wch && wch != NULL; wch = wch->next_in_room)
        {
          if (wch == ch) continue;
	  if (IS_PLAYER(wch) && can_see(ch, wch))
	    {
	      if (HUNTING(ch) && !str_cmp(HUNTING(ch), NAME(wch)))
		{
		  victim = wch;
		  break;
		}
              if (LEVEL (wch) >= IMM_LEVEL)
                continue;
	      if (IS_SET(ch->pIndexData->act4, ACT4_KILL_OPP) &&
		  DIFF_ALIGN(ch, wch))
		{
		  align_count++;
		}
	      if (!IS_SET(ch->act, ACT_WIMPY) || !IS_AWAKE(wch))
		count++;
	    }
	}
      if (!victim)
	{
	  if (count == 0)
	    continue;
	  if (align_count > 0)
	    num = number_range(1, align_count);
	  else
	    num = number_range(1, count);
	  count = 0;
	  for (wch = ch->in_room->people; wch && wch != NULL; wch = wch->next_in_room)
	    {
	      if (IS_PLAYER(wch) && can_see(ch, wch) && 
                   LEVEL (wch) < IMM_LEVEL &&
		  (align_count == 0 || !DIFF_ALIGN(wch, ch)))
		{
		  if (++count == num)
		    {
		      victim = wch;
		      break;
		    }
		}
	    }
	}
      if (!victim)
	continue;
      if (LEVEL(victim) > IMM_LEVEL || (IS_AFF (victim, SAFE) && LEVEL (ch) < LEVEL (victim) && number_range (1, 4) < 4))
	continue;
      if (IS_SET(ch->pIndexData->act4, ACT4_KILL_OPP) && DIFF_ALIGN(ch, victim))
	{
	  act("$B$&All of your kind must die!$R$7", ch, NULL, victim, TO_ROOM);
	}
      else
	{
	  switch (number_bits (2))
	    {
	    default:
	      act ("$4$n attacks $N!$R", ch, NULL, victim, TO_NOTVICT);
	      act ("$4$n attacks you!$R", ch, NULL, victim, TO_VICT);
	      break;
	    case 1:
	      if (can_yell (ch))
		{
		  act ("$4$n screams and attacks $N!$R", ch, NULL, victim, TO_NOTVICT);
		  act ("$4$n screams and attacks you!$R", ch, NULL, victim, TO_VICT);
		}
	      break;
	    case 2:	
	      if (can_yell (ch))
		{
		  act ("$4$n leaps towards $N!$R", ch, NULL, victim, TO_NOTVICT);
		  act ("$4$n leaps towards you!$R", ch, NULL, victim, TO_VICT);
		}
	      else
		{
		  act ("$4$n attacks $N!$R", ch, NULL, victim, TO_NOTVICT);
		  act ("$4$n attacks you!$R", ch, NULL, victim, TO_VICT);
		}
	      break;
	    case 3:
	      act ("$4$N's eyes widen in horror as $n attacks!$R", ch, NULL, victim, TO_NOTVICT);
	      act ("$4$n attacks you!$R", ch, NULL, victim, TO_VICT);
	      break;
	    }
	}
      multi_hit (ch, victim,TYPE_UNDEFINED);
    }
  return;
}

void
dum (void)
{
  return;
}
/*
   * Reset one room.
 */
void
reset_room (ROOM_DATA * pRoom)
{
  RESET_DATA *pReset = NULL;
  CHAR_DATA *pMob = NULL;
  SINGLE_OBJECT *pObj = NULL;
  CHAR_DATA *LastMob = NULL;
  SINGLE_OBJECT *LastObj = NULL;
  SINGLE_OBJECT *LastObjPrev = NULL;
  MOB_PROTOTYPE *pMobIndex = NULL;
  OBJ_PROTOTYPE *pObjIndex = NULL;
  EXIT_DATA *pexit = NULL;
  int iExit = 0;
  if (pRoom == NULL)
    return;
  if (get_room_index (pRoom->vnum) == NULL)
    {
      bug ("Reset_room: invalid room %d", pRoom->vnum);
      return;
    }
  for (iExit = 0; iExit < MAX_DIR; iExit++)
    {
      if (((pexit = (EXIT_DATA *) pRoom->exit[iExit]) != NULL) && pexit->d_info)
        {
          if (pexit->d_info->str < 0 && !IS_SET (pexit->d_info->exit_info, EX_RESET))
            continue;
	  if (IS_SET (pexit->d_info->rs_flags, EX_ISWALL) && !fBootDb)
	    continue;
	  pexit->d_info->exit_info = pexit->d_info->rs_flags;
          if (IS_SET(pexit->d_info->exit_info, EX_CLOSED) &&
              IS_SET(pexit->d_info->exit_info, EX_ISDOOR) &&
              number_range(1,30) == 2)
            pexit->d_info->trap = number_range(1,6);
          if (IS_SET (pexit->d_info->rs_flags, EX_ISDOOR)
              && pexit->d_info->maxstr > 0)
	    pexit->d_info->str = pexit->d_info->maxstr;
	  if (((ROOM_DATA *) pRoom->exit[iExit]->to_room) != NULL &&
	      (pexit = (EXIT_DATA *) ((ROOM_DATA *) pRoom->exit[iExit]->to_room)->exit[rev_dir[iExit]]) != NULL && pexit->d_info != NULL)
	    pexit->d_info->exit_info = pexit->d_info->rs_flags;
	}
    }
  if (!pRoom->resets) return;
  LastMob = NULL;
  LastObj = NULL;
  /* for (pReset = pRoom->resets; pReset != NULL; pReset = pReset->next)
    {
      RESET_DATA *rst;
      int total_in_room = 0;
      int vnum = 0;
      pMobIndex = NULL;
      if (pReset->command != 'M')
	continue;
      if ((pMobIndex = get_mob_index (pReset->rs_vnum)) == NULL)
	continue;
      else
	vnum = pReset->rs_vnum;
      for (rst = pRoom->resets; rst != NULL; rst = rst->next)
	{
	  if (pReset->command == 'M' && rst->rs_vnum == vnum)
	    total_in_room++;
	}
      for (rst = pRoom->resets; rst != NULL; rst = rst->next)
	{
	  if (rst->command == 'M' && rst->rs_vnum == vnum)
	    rst->loc = total_in_room;
	}
    }*/
  for (pReset = pRoom->resets; pReset != NULL; pReset = pReset->next)
    {
      pMobIndex = NULL;
      pObjIndex = NULL;
      if (pReset->percent < 1 || pReset->percent > 100)
	pReset->percent = 1;
      if (number_percent () > UMAX(pReset->percent, 3))
        {
          if (pReset->command == 'M')
            LastMob = NULL;
          continue;
        }
      switch (pReset->command)
        {
        default:
          bug ("Reset_room: bad command %c.", pReset->command);
          break;
        case 'M':
	  {
	    CHAR_DATA *rch;
	    int in_room_count = 0;
	    if ((pMobIndex = get_mob_index (pReset->rs_vnum)) == NULL)
	      {
		continue;
	      }
	    if (pMobIndex->count >= pMobIndex->max_in_world || 
		(IS_SET(pMobIndex->act, ACT_REBOOT_ONLY) &&
		 pMobIndex->killed > 0))
	      {
		LastMob = NULL;
		break;
	      }
	    for (rch = pRoom->people; rch != NULL; rch = rch->next_in_room)
	      {
		if (IS_MOB(rch) && (pReset->rs_vnum == rch->pIndexData->vnum))
		  in_room_count++;
		if (in_room_count >= pReset->loc)
		  {
		    LastMob = NULL;
		    in_room_count = -1;
		    break;
		  }
	      }
	    if (in_room_count == -1)
	      break;
	    pMob = create_mobile (pMobIndex);
	    if (room_is_dark (pRoom))
	      {
		SET_BIT (pMob->aff[DET], DARK | COLD);
	      }
	    char_to_room (pMob, pRoom);
	    
	  checkagain:
	    {
	      SINGLE_TRIGGER *tr;
	      SCRIPT_INFO *s;
	      for (tr = trigger_list[TCREATED]; tr != NULL; tr = tr->next)
		{
		  if (pMob->pIndexData->vnum == tr->attached_to_mob)
		    {
		      if (tr->running_info && !tr->interrupted)
			continue; /* Already running, interrupted, but script says not to allow interruptions. */
		      if (tr->running_info && tr->interrupted != 2)
			{
			  end_script (tr->running_info);
			  goto checkagain;
			}
		      /* ----------------- */
		      /* Start the script! */
		      /* ----------------- */
		      tr->running_info = mem_alloc (sizeof (*tr->running_info));
		      s = tr->running_info;
		      bzero (s, sizeof (*s));
		      s->current = pMob;
		      s->mob = pMob;
		      strcpy (s->code_seg, tr->code_label);
		      s->current_line = 0;
		      s->called_by = tr;
		      s->next = info_list;
		      info_list = s;
		      execute_code (s);
		      /* ----------------- */
		    }
		}
	    }
	    /* End trigger check! */
	    if (IS_HURT (pMob, SLEEP))
              do_sleep (pMob, "");
	    if (IS_SET (pMob->pIndexData->act3, ACT3_RIDE) &&
		LastMob != NULL && RIDING (LastMob) == NULL)
	      do_mount (pMob, RNAME (LastMob));
	    if (IS_SET (pMob->pIndexData->act3, ACT3_FOLLOW) &&
		LastMob != NULL)
	      {
		CHAR_DATA *prev;
		prev = LastMob;
		while (MASTER (prev))
		  prev = MASTER (prev);
		add_follower (pMob, prev);
	      }
	    LastObj = NULL;
	    LastObjPrev = NULL;
	    LastMob = pMob;
	  }
	break;
        case 'O':
	  {
	    int vnum = pReset->rs_vnum; 
	    int i = vnum;
	    pObj = NULL;
	    switch (i)
	      {
	      case 100: /* Clothpop */
		vnum = number_range (204,208);
		break;
	      case 101: /* Leatherpop */
		vnum = number_range(205, 218);
		break;
	      case 102: /* Chainpop */
		vnum = number_range(219, 223);
		break;
	      case 103: /* Metalpop */
		vnum = number_range(224, 231);
		break;
	      case 104: /* Steelpop */
		vnum = number_range(232, 237);
		break;
	      case 105: /* Leather or less pop */
		vnum = number_range(200, 218);
		break;
	      case 106: /* Chain or less pop */
		vnum = number_range(200, 223);
		break;
	      case 107: /* Metal or less pop */
		vnum = number_range(200, 231);
		break;
	      case 108: /* Steel or less pop */
		vnum = number_range(200, 237);
		break;
	      case 109: /* Chain or more pop */
		vnum = number_range(219, 237);
		break;
	      case 110: /* Metal or more pop */
		vnum = number_range(224, 237);
		break;
	      case 111: /* Low mineral */
		{
		  int jj;
		  for (jj = 0; jj < 7; jj++)
		    if (number_range(1,3) == 2) break;
		  vnum = 90019 + (jj * 40);
		}
	      break;
	      case 112: /* mud mineral */
		{
		  int jj;
		  for (jj = 0; jj < 8; jj++)
		    if (number_range(1,3) == 2) break;
		  if (jj == 7 && number_range(1,3) != 2)
		    jj = 0;
		  vnum = 90139 + (jj * 40);
		}
	      break;
	      case 113: /* High mineral */
		{
		  int jj;
		  for (jj = 0; jj < 8; jj++)
			if (number_range(1,3) == 2) break;
		  if (jj == 7 && number_range(1,5) != 3) 
		    jj = 0;
		  vnum = 90219 + (jj * 40);
		}
	      break;
	      case 114: /* mineral pop */ 
		{
		  int jj;
		  for (jj = 0; jj < 15; jj++)
		    if (number_range(1,3) == 2) 
		      break;
		  if (jj == 14 && number_range(1,4) != 3) jj = 0;
		  vnum = 90019 + (jj * 40);
		} 
	      break;
	      case 115: /* Wood */
		{
		  vnum = number_range(551,560);
		}
	      break;
	      case 116: /* Herbs */
		{
		  vnum = number_range(561,602);
		}
	      break; 
	      case 117: /* Dagger */
		{
		  if (number_range(1,2) != 2)
		    vnum = 250;
		  else if (number_range(1,2) != 2)
		    vnum = 251;
		  else if (number_range(1,2) != 2)
		    vnum = 252;
		  else vnum = 253;
		  break;
		}
	      case 118: /* Swords */
		{
		  if (number_range(1,2) != 2)
		    vnum = 260;
		  else if (number_range(1,2) != 2)
		    vnum = 261;
		  else if (number_range(1,2) != 2)
		    vnum = 262;   
		  else vnum = 263;
		  break;
		}
	      case 119: /* Clubs */
		{
		  if (number_range(1,2) != 2)
		    vnum = 270;
		  else if (number_range(1,2) != 2)
		    vnum = 271;   
		  else if (number_range(1,2) != 2)
                        vnum = 272;
		  else vnum = 273;
		  break; 
		}
	      case 120: /* Crap wpn */
		{
		  if (number_range(1,3) != 2)
		    vnum = 250;   
		  else if (number_range(1,3) != 2)
		    vnum = 251;
		  else vnum = 252;
		  vnum += 10*number_range(0,2);
		  break;
		}
	      case 121: /* Good wpn */
		{
		  if (number_range(1,2) == 2)
		    vnum = 252;
		  else if (number_range(1,3) != 2)
		    vnum = 253;   
		  else
		    vnum = 251;
		  vnum += 10*number_range(0,2);
		  break;
		}
	      case 122: /* Cloth raw pop */
		{
		  int jj;
		  for (jj = 0; jj < 4; jj++)
			if (number_range(1,3) != 2) break;
		  if (jj == 3 && number_range(1,5) != 3) 
		    jj = 0;
		  vnum = 91212 + 20 * jj;
		}
	      break;
	      }
	    if ((pObjIndex = get_obj_index (vnum)) == NULL)
	      {
		/*bug ("Reset_room: 'O': bad vnum %d.", pReset->rs_vnum);
		  bug ("Reset in room : %d.", pRoom->vnum);*/
		continue;
	      }
	    
	    if (pReset->loc == RESET_LOC_INROOM)
	      {
		SINGLE_OBJECT *obj2;
		int count_in_room;
		count_in_room = 0;
		for (obj2 = pRoom->contents; obj2 != NULL; obj2 = obj2->next_content)
		  {
		    if (obj2->pIndexData->vnum == /*pObj->pIndexData->vnum */ pObjIndex->vnum)
		      count_in_room++;
		  }
		if (pObjIndex->max_in_room <= count_in_room)
		  continue;
		pObj = create_object (pObjIndex,0);
		obj_to (pObj, pRoom);
		if ( /*LastObj == NULL || */ pObj->pIndexData->item_type == ITEM_CONTAINER)
		  {
		    LastObjPrev = LastObj;
		    LastObj = pObj;
		  }
		continue;
	      }
	    if (pReset->loc == RESET_LOC_INOBJ && LastObj != NULL)
	      {
		pObj = create_object (pObjIndex,0);
		obj_to (pObj, LastObj);
		continue;
	      }
	    if (pReset->loc == RESET_LOC_ONOBJ && LastObj != NULL)
	      {
		pObj = create_object (pObjIndex,0);
		obj_to (pObj, LastObj);
		continue;
	      }
	    /* Make sure reset locations are ok. */
	    if (LastMob != NULL)
	      {
		if (!LastMob->pIndexData->pShop)
		  {
		    pObj = create_object (pObjIndex, 0);
		    if (pReset->loc > 0)
		      pReset->loc = 0;
                    if (pReset->loc == -1)
                      pReset->loc = 0;
		    obj_to (pObj, LastMob);
		    if (pObj->pIndexData->item_type == ITEM_CONTAINER)
		      {
			LastObjPrev = LastObj;
			LastObj = pObj;
		      }
		    wear_obj (LastMob, pObj, FALSE);
		    continue;
		  }
		else
		  {
		    int counter;
		    if (pReset->loc < 1)
		      pReset->loc = 1;
		    for (counter = 0; counter < pReset->loc; counter++)
		      {
			pObj = NULL;
			pObj = create_object (pObjIndex, 1);
			obj_to (pObj, LastMob);
			pObj->wear_loc = WEAR_NONE;
			SET_BIT (pObj->extra_flags, ITEM_INVENTORY);
		      }
		  }
	      }
	  }
	break;
	}
    }
  return;
}

void
do_purgearea (CHAR_DATA * ch, char *argy)
{
  ROOM_DATA *pRoom;
  int ihash;
  DEFINE_COMMAND ("areapurge", do_purgearea, POSITION_DEAD, 101,LOG_NORMAL, "This command performs an invisible purge command in all rooms in the current area.")
    if (IS_MOB (ch))
    return;
  for (ihash = 0; ihash < HASH_MAX; ihash++)
    {
      for (pRoom = room_hash[ihash]; pRoom != NULL; pRoom = pRoom->next)
        {
          if (ch->in_room->area != pRoom->area)
            continue;
          raw_purge (pRoom);
        }
    }
  send_to_char ("Area purged (all objects and mobs).\n\r", ch);
  return;
}

bool temp=FALSE;
void
do_setmiw (CHAR_DATA * ch, char *argy)
{
  int i;
  int j;
  MOB_PROTOTYPE *m;
  int hash;
  char tm[SML_LENGTH];
  char arg[SML_LENGTH];
  DEFINE_COMMAND ("z_setmiw", do_setmiw, POSITION_DEAD, MAX_LEVEL, LOG_ALWAYS, " use...")
    argy = one_argy (argy, arg);
  if (!is_number (arg) || !is_number (argy))
    return;
  i = atoi (arg);
  j = atoi (argy);
sprintf(arg,"%d to %d.\n\r",i,j);
send_to_char(arg,ch);
temp=TRUE;
  for (hash = 0; hash < HASH_MAX; hash++)
    {
      for (m = mob_index_hash[hash]; m != NULL; m = m->next)
        {
          if (m->vnum < i || m->vnum > j)
            continue;
        strcpy(tm,itoa(m->vnum));
          do_mreset (ch, tm);
          m->max_in_world = ti;
          SET_BIT (m->area->area_flags, AREA_CHANGED);
        }
    }
temp=FALSE;
  send_to_char ("Done.\n\r", ch);
  return;
}


void
do_mreset (CHAR_DATA * ch, char *argy)
{
  RESET_DATA *pReset;
  ROOM_DATA *pRoom;
  int ihash;
  int reset_num;
  char general_use[500];
  DEFINE_COMMAND ("mreset", do_mreset, POSITION_DEAD, MAX_LEVEL, LOG_NORMAL, "This command can be used to find resets of the specified mob prototype.")
    if (IS_MOB (ch))
    return;
  if (argy == "" || argy[0] == '\0')
    {
      send_to_char ("mreset <vnum> (vnum is mob number to find reset of)\n\r", ch);
      return;
    }
  if (is_number (argy))
    {
      ti = 0;
      reset_num = atoi (argy);
      if (reset_num < 1)
        return;
      for (ihash = 0; ihash < HASH_MAX; ihash++)
        {
          for (pRoom = room_hash[ihash]; pRoom != NULL; pRoom = pRoom->next)
            {
              if (pRoom->resets == NULL)
                continue;
              for (pReset = pRoom->resets; pReset != NULL; pReset = pReset->next)
                {
                  if (pReset->rs_vnum == reset_num && pReset->command == 'M')
                    {
                      ti++;
		      if (!temp) 
			{
			  sprintf (general_use, "Mob %d reset in room %d at %d chance.\n\r",
				   reset_num, pRoom->vnum, pReset->percent);
			  send_to_char (general_use, ch);
			}
                    }
                }
            }
        }
    }
  else
    {
      MOB_PROTOTYPE *mmid;
      int iHsh;
      bool found_item;
      bool area_only = TRUE;
      if (str_prefix ("maintenance", argy))
        return;
      if (!str_infix ("all", argy))
        area_only = FALSE;
      for (iHsh = 0; iHsh < HASH_MAX; iHsh++)
        {
          for (mmid = mob_index_hash[iHsh]; mmid != NULL; mmid = mmid->next)
            {
              if (!IS_OPEN (mmid->area))
                continue;
              if (area_only && mmid->area != ch->in_room->area)
                continue;
              found_item = FALSE;
              for (ihash = 0; ihash < HASH_MAX; ihash++)
                {
                  for (pRoom = room_hash[ihash]; pRoom != NULL; pRoom = pRoom->next)
                    {
                      for (pReset = pRoom->resets; pReset != NULL; pReset = pReset->next)
                        {
                          if (pReset->rs_vnum == mmid->vnum && pReset->command == 'M')
                            {
                              found_item = TRUE;
                            }
                        }
                      if (found_item)
                        goto firstloopbreak;
                    }
                }
              sprintf (general_use, "Mob %d is unused!\n\r", mmid->vnum);
	      send_to_char (general_use, ch);
            firstloopbreak:
	      if (mmid) {};
	    }
        }
    }
  return;
}

void
do_oreset (CHAR_DATA * ch, char *argy)
{
  RESET_DATA *pReset;
  ROOM_DATA *pRoom;
  char general_use[500];
  int reset_num;
  int ihash;
  DEFINE_COMMAND ("oreset", do_oreset, POSITION_DEAD, MAX_LEVEL, LOG_NORMAL, "This command can be used to find resets of the specified object prototype.")
    if (IS_MOB (ch))
    return;
  if (argy == "" || argy[0] == '\0')
    {
      send_to_char ("oreset <vnum> (vnum is object number to find reset of)\n\r", ch);
      return;
    }
  if (is_number (argy))
    {
      reset_num = atoi (argy);
      if (reset_num < 1)
        return;
      for (ihash = 0; ihash < HASH_MAX; ihash++)
        {
          for (pRoom = room_hash[ihash]; pRoom != NULL; pRoom = pRoom->next)
            {
              for (pReset = pRoom->resets; pReset != NULL; pReset = pReset->next)
                {
                  if (pReset->rs_vnum == reset_num && pReset->command == 'O')
                    {
                      sprintf (general_use, "Object %d reset in room vnum %d at %d chance.\n\r",
                               reset_num, pRoom->vnum, pReset->percent);
                      send_to_char (general_use, ch);
                    }
                }
            }
        }
    }
  else
    {
      int iHsh;
      OBJ_PROTOTYPE *objj;
      bool found_item;
      bool area_only = TRUE;
      if (str_prefix ("maintenance", argy))
        return;
      if (!str_infix ("all", argy))
        area_only = FALSE;
      for (iHsh = 0; iHsh < HASH_MAX; iHsh++)
        {
          for (objj = obj_index_hash[iHsh]; objj != NULL; objj = objj->next)
            {
              if (!IS_OPEN (objj->area))
                continue;
              if (area_only && objj->area != ch->in_room->area)
                continue;
              found_item = FALSE;
              for (ihash = 0; ihash < HASH_MAX; ihash++)
                {
                  for (pRoom = room_hash[ihash]; pRoom != NULL; pRoom = pRoom->next)
                    {
                      for (pReset = pRoom->resets; pReset != NULL; pReset = pReset->next)
                        {
                          if (pReset->rs_vnum == objj->vnum && pReset->command == 'O')
                            {
                              found_item = TRUE;
                            }
                        }
                      if (found_item)
                        goto firstloopbreak;
                    }
                }
              sprintf (general_use, "Object %d is unused!\n\r", objj->vnum);
	      send_to_char (general_use, ch);
              objj->item_type = ITEM_NUKE;
            firstloopbreak:
                  if (objj) {};
            }
        }
    }
  return;
}



void
room_update (void)
{
  ROOM_DATA *pRoom;
  TRACK_DATA *tr_n;
  TRACK_DATA *tr;
  TRACK_DATA *prev;
  CHAR_DATA *pch;
  AREA_DATA *ar;
  MOB_PROTOTYPE *mob;
  bool dried = FALSE;
  bool all_mobs_dead = TRUE;
  int i = 0;
  int iHash;

  if (pulse_hour == 0)
    {
      for (ar = area_first; ar != NULL; ar = ar->next)
	{ 
	  if(ar->repop_counter <= 0)
	    ar->repop_counter = UMIN(35,ar->repop_rate);
	  ar->repop_counter--;
	  if (ar->repop_counter == 0 && 
	      IS_SET (ar->area_flags, AREA_RAIDABLE) &&
	      ar->lastkiller && ar->lastkiller->alignment > 0)
	    {
	      for (i = 0; i < HASH_MAX && all_mobs_dead; i++)
		{
		  for (mob = mob_index_hash[i]; mob != NULL; mob = mob->next)
		    {
		      if (mob->vnum >= ar->lvnum && mob->vnum <= ar->uvnum)
			{
			  if (mob->count > 0)
			    {
			      all_mobs_dead = FALSE;
			      break;
			    }
			}
		    }
		}
	      if (all_mobs_dead)
		set_area_align (ar, ar->lastkiller->alignment, NULL);
	    }
	}
    }
  for (iHash = pulse_hour; iHash < HASH_MAX; iHash += PLAYER_LIST)
    {
      for (pRoom = room_hash[iHash]; pRoom != NULL; pRoom = pRoom->next)
	{
	  if (!pRoom->area || pRoom->area->repop_counter % 3 != 0) continue;
	  if (pRoom->blood && pRoom->area->repop_counter % 6 == 3) 
	    {
	      dried = FALSE;
	      
	      for (i = 0 ; i < 6 ; i++)
		{
		  if(IS_SET(pRoom->blood ,blood_number[i]) && number_range(1,4) !=1)
		    {
		      REMOVE_BIT(pRoom->blood, blood_number[i]);
		      dried = TRUE;
		    }
		}
	      if (dried && pRoom->people)
		{
		  for (pch = pRoom->people; pch != NULL; pch=pch->next_in_room)
		    send_to_char("\x1b[0;31mA blood trail dries up.\x1b[0;37m\n\r", pch);                  
		}
	    }
	  if (pRoom->area->repop_counter % 6 == 0)
	    {
	      for (tr = pRoom->tracks; tr; tr = tr_n)
		{
		  tr_n = tr->next;
		  if (--tr->timer < 1)
		    {
		      if (tr == pRoom->tracks)
			{
			  pRoom->tracks = tr->next;
			  free_m (tr);
			}
		      else
			{
			  for (prev = pRoom->tracks; prev; prev = prev->next)
			    {
			      if (prev->next == tr)
				{
				  prev->next = tr->next;
				  free_m (tr);
				  break;
				}
			    }
			}
		    }
		}
	    }
	  if (pRoom->area->repop_counter == 0)
	    {
	      if (pRoom->area->repop[0] != '\0')
		for (pch = pRoom->people; pch != NULL; pch = pch->next_in_room)
		  {
		    if (nightmare)
		      send_to_char("The nightmare shifts and reforms before your eyes!\n\r", pch);
		    else
		      send_to_char (pRoom->area->repop, pch);
		  }
	      reset_room (pRoom);
	    }
	}
      
    }
  return;
}


void
update_handler (void)
{
  pulse_upd--;
  if (--pulse_transport < 0)
    pulse_transport = TOTAL_LIST/3;
    transport_update ();

  if (pulse_upd % 90 == 78) 
    {
      int i;
      if (saving != NULL)
	{
          for (i = 0; i < 7; i++)
            {
              save_area (saving);
              REMOVE_BIT (saving->area_flags, AREA_CHANGED);
              saving = saving->next;
              if (saving == NULL)
                {
                  do_global ("Database save finished.\n\r", 0, 0);
                  break;
                }
            }
	}
    }
  if (number_range (1,10) != 4)
    {
      if (--pulse_char < 0)
	pulse_char = PLAYER_LIST;
      char_only_update ();
    }
  if (nightmare && number_range(1,2516) == 378)
    {
      nightmare_stage = 11;
      do_nightmare();
    }
  if (pulse_upd % 100 == 57)
    {
      auction_update();
    }
  if (--pulse_mobile < 0)
    pulse_mobile = PLAYER_LIST;
  mobile_update (); /* Do mobile updates about every 8 seconds... */
  if (pulse_upd % 17 == 3)
    violence_update (); /* Combat every 1.7 seconds */
  if (pulse_upd % 5 == 2) /* Hourly "tick" every 40 seconds */
    {
      if (--pulse_hour < 0)
	pulse_hour = PLAYER_LIST;
      char_update ();
      room_update ();
    }
  if (pulse_upd % 400 == 203)
    {
      obj_update ();
      if (biddata.waitticks == 0)
        {
          biddata.waitticks = -1;
          arena ();
        }
      if (biddata.waitticks > 0)
        biddata.waitticks--;
      weather_update ();
    }
  if (pulse_upd % 5 == 0)
      aggr_update (); /* Aggros checked 2x per second */
  if (pulse_upd % 150 == 29)
    update_society ();
  if (pulse_upd <= 0)
    {
      pulse_upd = PULSE_AREA;
      if (number_range (1,10) == 2)
	{
	  save_object_info ();
	  if (number_range (1,2) == 2)
	    {
	      save_mobile_info ();
	    }
	}
      if (ticks_to_reboot == 0)
        {
          hours_up++;
          if (hours_up >= 150 && number_range(1,50)== 2)
            {
              ticks_to_reboot = 10;
            }
        }
      
       if (dice (1, 12000) == 1356)
	 do_disaster ();
    }
  if (nightmare_ticks > 0)
    {
      nightmare_ticks--;
      if (nightmare_ticks == 0)
	{
	  nightmare_stage++;
	  do_nightmare();
	}
    }
  return;
}

void
do_disaster ()
{
  CHAR_DATA *mob;
  AREA_DATA *area = NULL;
  int i;
  for (mob = char_list[PLAYER_LIST]; mob != NULL; mob = mob->next)
    {
      if (number_percent () > 90)
	{
	  if (mob->in_room && mob->in_room->area)
	    area = mob->in_room->area;
	  break;
	}
    }
  if (area == NULL)
    return;
  for (i = 0; i < PLAYER_LIST; i++)
    {
      for (mob = char_list[i]; mob != NULL; mob = mob->next)
	{
	  if (mob->in_room == NULL || mob->in_room->area == NULL)
	    continue;
	  if (mob->in_room->area == area)
	    {
	      if (IS_AFF (mob, FLYING))
		{
		  send_to_char ("You see the earth shake and rumble below!\n\r",
				mob);
		  continue;
		}
	      send_to_char ("The earth shakes and rumbles violently!\n\r", mob);
	      if (dice (3, 10) > get_curr_dex (mob))
		{
		  send_to_char ("The quake knocks you to the ground.\n\r", mob);
		  act ("$n is knocked down by the quake.", mob, NULL, NULL, TO_ROOM);
		  if (IS_SET (mob->act, PLR_HOLYWALK))
		    continue;
		  NEW_POSITION(mob, POSITION_RESTING);
		  if (mob->hit > 11)
		    {
		      SUBHIT(mob, 10);
		    }
		}
	    }
	}
    }
  return;
}