#if defined(macintosh)
#include <types.h>
#include <time.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "merc.h"
#include "recycle.h"
#include "tables.h"
#include "lookup.h"
#include "interp.h"
#include "db.h"
#include "magic.h"
void lightning args ((void));
void ice args ((void));
void hail args ((void));
void blizzard args ((void));
void fog args ((void));
void weather_update args ((void));
extern char *target_name;
#define LI1		MAX_LEVEL/6
#define LI2		MAX_LEVEL/3
#define LI3		MAX_LEVEL
/*
 * Update the weather.
 */
void
weather_update (void)
{
  char buf[MAX_STRING_LENGTH];
  DESCRIPTOR_DATA *d;
  FILE *fp;

  buf[0] = '\0';

  switch (++time_info.hour)
    {
    case 5:
      weather_info.sunlight = SUN_LIGHT;
      strcat (buf, "The {yday{x has begun.\n\r");
      break;

    case 6:
      weather_info.sunlight = SUN_RISE;
      strcat (buf, "The {Ysun{x rises in the east.\n\r");
      break;

    case 19:
      weather_info.sunlight = SUN_SET;
      strcat (buf, "The {Ysun{x slowly disappears in the west.\n\r");
      break;

    case 20:
      weather_info.sunlight = SUN_DARK;
      strcat (buf, "The {Dnight{x has begun.\n\r");
      break;

    case 24:
      strcat (buf,
	      "A wolf howls in the distance as {Dmidnight{x strikes.\n\r");
      time_info.hour = 0;
      time_info.day++;
      break;

      //Code was put in by Xeric (for mud compatibility), created by Taka...
      if (!(fp = fopen (TIME_FILE, "w+")))
	{
	  log_string ("creation of new time_file failed");
	}
      else
	{
	  int total;
	  total = fprintf (fp, "%d %d %d %d",
			   time_info.hour,
			   time_info.day, time_info.month, time_info.year);
	  if (total < 4)
	    log_string ("failed fprintf to time_file");
	  fclose (fp);
	}
      break;
    }

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

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

  /*
   * Weather change.
   */
  switch (weather_info.sky)
    {
    default:
      weather_info.sky = SKY_CLOUDLESS;
      break;

    case SKY_CLOUDLESS:
      if ((number_chance (20)) && (time_info.hour <= 6))
	{
	  weather_info.sky = SKY_FOGGY;
	}
      else if (number_chance (25))
	{
	  weather_info.sky = SKY_CLOUDY;
	}
      else if (number_chance (25))
	{
	  weather_info.sky = SKY_RAINING;
	}
      else

	weather_info.sky = SKY_CLOUDLESS;

      break;

    case SKY_CLOUDY:
      if (number_chance (15))
	{
	  weather_info.sky = SKY_SNOWING;
	}
      else if (number_chance (5))
	{
	  weather_info.sky = SKY_HAILSTORM;
	}
      else if (number_chance (15))
	{
	  weather_info.sky = SKY_THUNDERSTORM;
	}
      else if (number_chance (5))
	{
	  weather_info.sky = SKY_ICESTORM;
	}
      else if (number_chance (65))
	{
	  weather_info.sky = SKY_CLOUDLESS;
	}
      else
	weather_info.sky = SKY_CLOUDY;

    case SKY_RAINING:
      if (number_chance (15))
	{
	  weather_info.sky = SKY_LIGHTNING;
	  lightning ();
	}
      else if (number_chance (5))
	{
	  weather_info.sky = SKY_HAILSTORM;
	  hail ();
	}
      else if (number_chance (15))
	{
	  weather_info.sky = SKY_THUNDERSTORM;
	}
      else if (number_chance (50))
	{
	  weather_info.sky = SKY_CLOUDY;
	}
      else if (number_chance (55))
	{
	  weather_info.sky = SKY_RAINING;
	}
      break;

    case SKY_SNOWING:
      if (number_chance (15))
	{
	  weather_info.sky = SKY_BLIZZARD;
	}
      else if (number_chance (45))
	{
	  weather_info.sky = SKY_CLOUDY;
	}
      else if (number_chance (15))
	{
	  weather_info.sky = SKY_RAINING;
	}
      else if (number_chance (55))
	{
	  weather_info.sky = SKY_SNOWING;
	}

      break;
    case SKY_LIGHTNING:
      if (number_chance (50))
	{
	  weather_info.sky = SKY_THUNDERSTORM;
	}
      else if (number_chance (35))
	{
	  weather_info.sky = SKY_RAINING;
	}
      else if (number_chance (40))
	{
	  weather_info.sky = SKY_CLOUDY;
	}
      else if (number_chance (5))
	{
	  weather_info.sky = SKY_HAILSTORM;
	}
      else if (number_chance (45))
	{
	  weather_info.sky = SKY_LIGHTNING;
	}
      break;
    case SKY_FOGGY:
      if (number_chance (45))
	{
	  weather_info.sky = SKY_CLOUDY;
	}
      else if (number_chance (55))
	{
	  fog ();
	  weather_info.sky = SKY_FOGGY;
	  break;
	}

    case SKY_THUNDERSTORM:
      if (number_chance (35))
	{
	  weather_info.sky = SKY_RAINING;
	}
      else if (number_chance (55))
	{
	  weather_info.sky = SKY_CLOUDY;
	}
      else if (number_chance (35))
	{
	  weather_info.sky = SKY_LIGHTNING;
	}
      else if (number_chance (10))
	{
	  weather_info.sky = SKY_HAILSTORM;
	  hail ();
	}
      else if (number_chance (40))
	{
	  weather_info.sky = SKY_THUNDERSTORM;
	}
      break;

    case SKY_HAILSTORM:
      if (number_chance (60))
	{
	  weather_info.sky = SKY_CLOUDY;
	}
      else if (number_chance (80))
	{
	  weather_info.sky = SKY_RAINING;
	}
      else if (number_chance (25))
	{
	  weather_info.sky = SKY_HAILSTORM;
	  hail ();
	}
      break;

    case SKY_ICESTORM:
      if (number_chance (50))
	{
	  weather_info.sky = SKY_CLOUDY;
	}
      else if (number_chance (20))
	{
	  weather_info.sky = SKY_BLIZZARD;
	}
      else if (number_chance (70))
	{
	  weather_info.sky = SKY_SNOWING;
	}
      else if (number_chance (35))
	{
	  ice ();
	  weather_info.sky = SKY_ICESTORM;
	}
      break;


    case SKY_BLIZZARD:
      if (number_chance (65))
	{
	  weather_info.sky = SKY_SNOWING;
	}
      else if (number_chance (15))
	{
	  blizzard ();
	  weather_info.sky = SKY_ICESTORM;
	  ice ();
	}
      else if (number_chance (65))
	{
	  blizzard ();
	  weather_info.sky = SKY_CLOUDY;
	}
      else if (number_chance (35))
	{
	  blizzard ();
	  weather_info.sky = SKY_BLIZZARD;
	}
      break;

    }

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

  return;
}






/*
New weather command. Reads the new weather stats as well as  tells you
what time of day it is (morning, noon, night) 
Added so that players don't HAVE to have autoweather enabled*/
void
do_weather (CHAR_DATA * ch, char *argument)
{
  char buf[MSL];
  char buf2[MSL];
  char *suf;
  int day;

  day = time_info.day + 1;

  if (day > 4 && day < 20)
    suf = "th";
  else if (day % 10 == 1)
    suf = "st";
  else if (day % 10 == 2)
    suf = "nd";
  else if (day % 10 == 3)
    suf = "rd";
  else
    suf = "th";


  if (!IS_OUTSIDE (ch))
    {
      send_to_char ("You can't see the weather indoors.\n\r", ch);
      return;
    }
  send_to_char ("{x\n\r", ch);

  if (weather_info.sky == SKY_RAINING)
    {
      if (number_range (0, 100) <= 40)
	{
	  send_to_char
	    ("{g[{YWeather{g] {CThere is a cold rain trickling down.{x", ch);
	}
      else if (number_range (0, 100) <= 40)
	{
	  send_to_char
	    ("{g[{YWeather{g] {CThere is a warm rain trickling down.{x", ch);
	}
      else if (number_range (0, 100) <= 50)
	{
	  send_to_char
	    ("{g[{YWeather{g] {CThe rain is coming down very strong.", ch);

	}

      send_to_char ("{x\n\r", ch);

    }

  else if (weather_info.sky == SKY_CLOUDY)
    {
      sprintf (buf, "{g[{YWeather{g] %s{x.\n\r",
	       weather_info.change >= 0
	       ? "{CA warm breeze can be felt about"
	       : "{CA cold breeze can be felt about");
      send_to_char (buf, ch);
    }
  else if (weather_info.sky == SKY_CLOUDLESS)
    {
      send_to_char
	("{g[{YWeather{g] {CThe sky is beautiful, not a cloud around.{x\n\r",
	 ch);
    }
  else if (weather_info.sky == SKY_THUNDERSTORM)
    {
      send_to_char
	("{g[{YWeather{g] {CThe skies thunder as a storm approaches.{x\n\r",
	 ch);
    }
  else if (weather_info.sky == SKY_ICESTORM)
    {
      send_to_char
	("{g[{YWeather{g] {CSheets of ice appear to be falling from the sky.{x\n\r",
	 ch);
    }
  else if (weather_info.sky == SKY_HAILSTORM)
    {
      send_to_char
	("{g[{YWeather{g] {CLarge hailstones are falling from the sky.{x\n\r",
	 ch);
    }
  else if (weather_info.sky == SKY_SNOWING)
    {
      send_to_char ("{g[{YWeather{g] {CA light snow is falling.{x\n\r", ch);
    }
  else if (weather_info.sky == SKY_BLIZZARD)
    {
      send_to_char ("{g[{YWeather{g] {CThere is a blizzard about.{x\n\r", ch);
    }
  else if (weather_info.sky == SKY_FOGGY)
    {
      send_to_char
	("{g[{YWeather{g] {CA misty haze covers the horizon.{x\n\r", ch);
    }

  else if (weather_info.sky == SKY_LIGHTNING)
    {
      send_to_char
	("{g[{YWeather{g] {CA {y Lightning{w storm is approaching {x\n\r",
	 ch);
    }
  sprintf (buf2,
	   "{B[{W Time  {B] {RIt is {M%d{R o'clock {Y%s{x\n\r",
	   (time_info.hour % 12 == 0) ? 12 : time_info.hour % 12,
	   time_info.hour >= 12 ? "pm" : "am");
  send_to_char (buf2, ch);
  return;

}

/*  Xantha  10/00 */



bool
IS_OUTDOORS (CHAR_DATA * ch)
{
  if (!IS_SET (ch->in_room->room_flags, ROOM_INDOORS) &&
      ch->in_room->sector_type != SECT_INSIDE)
    return TRUE;
  else
    return FALSE;
}

void
do_autoweather (CHAR_DATA * ch, char *argument)
{
  if (IS_NPC (ch))
    return;

  if (IS_SET (ch->act, PLR_AUTOWEATHER))
    {
      send_to_char
	("You will no longer see weather descriptions in rooms\n\r", ch);
      REMOVE_BIT (ch->act, PLR_AUTOWEATHER);
    }
  else
    {
      send_to_char ("You will now see weather descriptions in rooms\n\r", ch);
      SET_BIT (ch->act, PLR_AUTOWEATHER);
    }
}

void
show_weather (CHAR_DATA * ch)
{
  char buf[MAX_STRING_LENGTH];

/*for weather stuff -- tjw*/
  if (weather_info.sky == SKY_RAINING)
    {
      if (number_range (0, 100) <= 30)
	{
	  send_to_char
	    ("{g[{YWeather{g] {CThere is a cold rain trickling down.{x\n\r",
	     ch);
	}
      else if (number_range (0, 100) <= 40)
	{
	  send_to_char
	    ("{g[{YWeather{g] {CThere is a warm rain trickling down.{x\n\r",
	     ch);
	}
      else if (number_range (0, 100) <= 70)
	{
	  send_to_char
	    ("{g[{YWeather{g] {CThe wind is coming on strong, the rain is coming down hard.{x\n\r",
	     ch);
	}

      send_to_char ("{x\n\r", ch);

    }

  else if (weather_info.sky == SKY_CLOUDY)
    {
      sprintf (buf, "{g[{YWeather{g] %s{x.\n\r",
	       weather_info.change >= 0
	       ? "{CA warm breeze can be felt about"
	       : "{CA cold breeze can be felt about");
      send_to_char (buf, ch);
    }
  else if (weather_info.sky == SKY_CLOUDLESS)
    {
      send_to_char
	("{g[{YWeather{g] {CThe sky is beautiful, not a cloud around.{x\n\r",
	 ch);
    }
  else if (weather_info.sky == SKY_THUNDERSTORM)
    {
      send_to_char
	("{g[{YWeather{g] {CThe skies thunder as a storm approaches.{x\n\r",
	 ch);
    }
  else if (weather_info.sky == SKY_ICESTORM)
    {
      send_to_char
	("{g[{YWeather{g] {CSheets of ice appear to be falling from the sky.{x\n\r",
	 ch);
    }
  else if (weather_info.sky == SKY_HAILSTORM)
    {
      send_to_char
	("{g[{YWeather{g] {CLarge hailstones are falling from the sky.{x\n\r",
	 ch);
    }
  else if (weather_info.sky == SKY_SNOWING)
    {
      send_to_char ("{g[{YWeather{g] {CA light snow is falling.{x\n\r", ch);
    }
  else if (weather_info.sky == SKY_BLIZZARD)
    {
      send_to_char ("{g[{YWeather{g] {CThere is a blizzard about.{x\n\r", ch);
    }
  else if (weather_info.sky == SKY_FOGGY)
    {
      send_to_char
	("{g[{YWeather{g] {CA misty haze covers the horizon.{x\n\r", ch);
    }

  else if (weather_info.sky == SKY_LIGHTNING)
    {
      send_to_char
	("{g[{YWeather{g] {CA {y Lightning{w storm is approaching {x\n\r",
	 ch);
    }
  else
    {
      send_to_char
	("{g[{YWeather{g] {CBUG!!!!!!!!!!!!!!! A descriptor does not exist for this condition  {x\n\r",
	 ch);
    }
}

void
lightning (void)
{
  DESCRIPTOR_DATA *d;
  for (d = descriptor_list; d != NULL; d = d->next)
    {
      if (d->connected == CON_PLAYING
	  && IS_OUTDOORS (d->character)
	  && IS_AWAKE (d->character)
	  && number_chance (2)
	  && !IS_IMMORTAL (d->character)
	  && d->character->level > 17 && weather_info.sky == SKY_LIGHTNING)
	{

	  send_to_char
	    ("{x{RYou see a brilliant flash come down from the sky and then black out!{x\n\r",
	     d->character);
	  act ("$n has been struck by lightning!", d->character, NULL, NULL,
	       TO_ROOM);
	  if (check_immune (d->character, DAM_LIGHTNING) != IS_IMMUNE)
	    {

	      if (d->character->fighting)
		{
		  stop_fighting (d->character, TRUE);
		}

	      if (check_immune (d->character, DAM_LIGHTNING) != IS_RESISTANT)
		{

		  if (d->character->level < LI1);
		  {
		    d->character->hit -= d->character->hit / 25;
		  }

		  if (d->character->level < LI2);
		  {
		    d->character->hit -= d->character->hit / 20;
		  }

		  if (d->character->level < LI3);
		  {
		    d->character->hit -= d->character->hit / 15;
		    WAIT_STATE (d->character, 40);
		  }
		}
	      else
		{
		  if (check_immune (d->character, DAM_LIGHTNING) ==
		      IS_VULNERABLE)
		    {
		      d->character->hit -= d->character->hit / 10;
		      WAIT_STATE (d->character, 40);
		    }
		}
	    }
	}
    }
}
void
blizzard (void)
{
  DESCRIPTOR_DATA *d;
  for (d = descriptor_list; d != NULL; d = d->next)
    {
      if (d->connected == CON_PLAYING
	  && IS_OUTDOORS (d->character) && weather_info.sky == SKY_BLIZZARD)
	{
	  if (number_range (0, 2000) <= 1000)
	    {
	      send_to_char
		("{WThe sky before you is a mist of white blur. Perhaps you should find a safe place indoors.{x \n\r",
		 d->character);
	    }
	  else if (number_range (0, 2000) <= 1250)
	    {
	      send_to_char
		("{WShards of ice fly through the wind with the oncoming blizzard.{x \n\r",
		 d->character);
	      act ("{WA shard of ice wizzez past $n's ear!{x", d->character,
		   NULL, NULL, TO_ROOM);
	      d->character->hit -= 5;
	    }
	  else if (number_range (0, 2000) <= 1500)
	    {
	      send_to_char
		("{WSnow dances around you in a furious blizzard.{x \n\r",
		 d->character);
	      act ("{WSnow begins to dance around $n as if enchanted.{x",
		   d->character, NULL, NULL, TO_ROOM);
	      d->character->hit -= 15;
	    }
	  else if (number_range (0, 2000) <= 1950)
	    {
	      send_to_char
		("{WThe sky before you is a mist of white blur.{x \n\r",
		 d->character);
	    }
	  else if (number_range (0, 2000) <= 2000)
	    {
	      send_to_char
		("{WThe blizzard about you begins to get increasingly cold, you feel your fingers begin to freeze.{x \n\r",
		 d->character);
	      act ("{W$n's is beginning freeze!{x", d->character, NULL, NULL,
		   TO_ROOM);
	      d->character->hit -= 30;
	    }
	}
    }
}
void
ice (void)
{
  DESCRIPTOR_DATA *d;
  for (d = descriptor_list; d != NULL; d = d->next)
    {
      if (d->connected == CON_PLAYING
	  && IS_OUTDOORS (d->character) && weather_info.sky == SKY_ICESTORM)
	{
	  if (number_range (0, 2000) <= 1000)
	    {
	      send_to_char ("{CIt's starting to rain shards of ice.{x \n\r",
			    d->character);
	    }
	  else if (number_range (0, 2000) <= 1250)
	    {
	      send_to_char
		("{CThe ice around you shatters and cracks beneath your feet{x \n\r",
		 d->character);
	      act
		("{C$n almost loses their balance when the ice around him begins to crack.{x",
		 d->character, NULL, NULL, TO_ROOM);
	      d->character->hit -= 5;
	    }
	  else if (number_range (0, 2000) <= 1500)
	    {
	      send_to_char
		("{CIce batters you, you can barely see your hands in front of you.{x \n\r",
		 d->character);
	      act
		("{CIce batters you, you can barely see your hands in front of you.{x \n\r",
		 d->character, NULL, NULL, TO_ROOM);
	      d->character->hit -= 15;
	    }
	  else if (number_range (0, 2000) <= 1950)
	    {
	      send_to_char
		("{CYou watch as the mosture from your breath crystalizes in front of you.{x \n\r",
		 d->character);
	    }
	  else if (number_range (0, 2000) <= 2000)
	    {
	      send_to_char
		("{CAll you can see is a hazy mist of snow and ice.{x \n\r",
		 d->character);
	      act ("{CAll you can see is a hazy mist of snow and ice.{x \n\r",
		   d->character, NULL, NULL, TO_ROOM);
	      d->character->hit -= 30;
	    }
	}
    }
}
void
hail (void)
{
  DESCRIPTOR_DATA *d;
  for (d = descriptor_list; d != NULL; d = d->next)
    {
      if (d->connected == CON_PLAYING
	  && IS_OUTDOORS (d->character) && weather_info.sky == SKY_HAILSTORM)
	{
	  if (number_range (0, 2000) <= 1000)
	    {
	      send_to_char
		("{wHail begins to come down hard upon you.{x \n\r",
		 d->character);
	    }
	  else if (number_range (0, 2000) <= 1250)
	    {
	      send_to_char
		("{wThe hail begins to come down so hard that your beginning to collect a layer of snow.{x\n\r",
		 d->character);
	      act ("{wYou begin to get covered in snow, hail and ice.{x\n\r",
		   d->character, NULL, NULL, TO_ROOM);
	      d->character->hit -= 5;
	    }
	  else if (number_range (0, 2000) <= 1950)
	    {
	      send_to_char
		("{wThe sky before you is a mist of white blur.{x \n\r",
		 d->character);
	    }
	  else if (number_range (0, 2000) <= 2000)
	    {
	      send_to_char
		("{wHail begins to come down hard, the mosture from your breath crystalizes in front of you.{x \n\r",
		 d->character);
	      act
		("$n breath's deeply watching his breath crystalize in front of $m{w{x\n\r",
		 d->character, NULL, NULL, TO_ROOM);
	      d->character->hit -= 30;
	    }
	}
    }
}

void
fog (void)
{
  DESCRIPTOR_DATA *d;
  for (d = descriptor_list; d != NULL; d = d->next)
    {
      if (d->connected == CON_PLAYING
	  && IS_OUTDOORS (d->character) && weather_info.sky == SKY_FOGGY)
	{
	  if (number_range (0, 2000) <= 1000)
	    {
	      send_to_char
		("{DSuddenly there is a dark mist all about you.{x \n\r",
		 d->character);
	    }
	  else if (number_range (0, 2000) <= 1250)
	    {
	      send_to_char
		("{DA thick fog rolls around you, you can hear a wolf howl in the distance.{x \n\r",
		 d->character);
	      act
		("{DYou here a long high pitched howl in the distance.{x\n\r",
		 d->character, NULL, NULL, TO_ROOM);
	      d->character->hit -= 5;
	    }
	  else if (number_range (0, 2000) <= 1500)
	    {
	      send_to_char
		("{DYou hear a howl of rage and a deep guttural growl far off in the distance.{x\n\r",
		 d->character);
	      act
		("{DYou hear a howl of rage and a deep guttural growl far off in the distance.{x\n\r",
		 d->character, NULL, NULL, TO_ROOM);
	      d->character->hit -= 15;
	    }
	  else if (number_range (0, 2000) <= 1950)
	    {
	      send_to_char
		("{DA huge wall of fog suddenly envelopes you.{x \n\r",
		 d->character);
	    }
	  else if (number_range (0, 2000) <= 2000)
	    {
	      send_to_char
		("{DWisps of fog come pouring in all around you, covering you in a thin mist.{x \n\r",
		 d->character);
	      act
		("{DWisps of fog come pouring in all around you, covering you with a thin mist.{x\n\r",
		 d->character, NULL, NULL, TO_ROOM);
	      d->character->hit -= 30;
	    }

	}
    }
}

bool
number_chance (int num)
{
  if (number_range (1, 100) <= num)
    return TRUE;
  else
    return FALSE;
}

void
spell_control_weather (int sn, int level, CHAR_DATA * ch, void *vo,
		       int target)
{
  if (!str_cmp (target_name, "better"))
    {

      if (weather_info.sky == SKY_CLOUDLESS)
	{
	  send_to_char ("But it's so beautiful outside already\n\r", ch);
	  return;
	}
      else if (weather_info.sky == SKY_CLOUDY)
	{
	  send_to_char
	    ("You recite the ancient spell and the clouds part in obedience\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the clouds part.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_CLOUDLESS;
	  return;
	}
      else if (weather_info.sky == SKY_RAINING)
	{
	  send_to_char
	    ("You recite the ancient spell and the  rain stops in obedience\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the rain stops.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_CLOUDY;
	  return;
	}
      else if (weather_info.sky == SKY_LIGHTNING)
	{
	  send_to_char
	    ("You recite the ancient spell and the lightning ceases in obedience\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the lightning stops.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_THUNDERSTORM;
	  return;
	}
      else if (weather_info.sky == SKY_THUNDERSTORM)
	{
	  send_to_char
	    ("You recite the ancient spell and the storm ceases\n\r", ch);
	  act
	    ("$n makes a strange movement with their hands and the  storm ceases.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_RAINING;
	  return;
	}
      else if (weather_info.sky == SKY_SNOWING)
	{
	  send_to_char
	    ("You recite the ancient spell and the snow ceases in obedience\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the snow ceases.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_CLOUDY;
	  return;
	}
      else if (weather_info.sky == SKY_BLIZZARD)
	{
	  send_to_char
	    ("You recite the ancient spell and the  horizon clears\n\r", ch);
	  act
	    ("$n makes a strange movement with their hands and the horizon clears.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_SNOWING;
	  return;
	}
      else if (weather_info.sky == SKY_ICESTORM)
	{
	  send_to_char
	    ("You recite the ancient spell and the  horizon clears\n\r", ch);
	  act
	    ("$n makes a strange movement with their hands and the horizon clears.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_RAINING;
	  return;
	}
      else if (weather_info.sky == SKY_HAILSTORM)
	{
	  send_to_char
	    ("You recite the ancient spell and the  horizon clears\n\r", ch);
	  act
	    ("$n makes a strange movement with their hands and the horizon clears.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_RAINING;
	  return;
	}
      else if (weather_info.sky == SKY_FOGGY)
	{
	  send_to_char
	    ("You recite the ancient spell and the  horizon clears\n\r", ch);
	  act
	    ("$n makes a strange movement with their hands and the horizon clears.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_CLOUDY;
	  return;
	}
      else
	{
	  send_to_char ("Bad Weather Call. Please notify the imms.\n\r", ch);
	}

    }
  else if (!str_cmp (target_name, "worse"))
    {

      if (weather_info.sky == SKY_CLOUDLESS)
	{
	  send_to_char
	    ("You recite the ancient spell and the clouds  come at your command.\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the clouds  darken the sky.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_CLOUDY;
	  return;
	}
      else if (weather_info.sky == SKY_CLOUDY)
	{
	  send_to_char
	    ("You recite the ancient spell and the clouds trickle down rain\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the clouds open up to rain.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_RAINING;
	  return;
	}
      else if (weather_info.sky == SKY_RAINING)
	{
	  send_to_char
	    ("You recite the ancient spell and the  rain  turns to hail\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the rain  turns to hail.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_HAILSTORM;
	  return;
	}
      else if (weather_info.sky == SKY_LIGHTNING)
	{
	  send_to_char
	    ("You recite the ancient spell and the  clouds send down sheets of ice\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the lightning turns to ice.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_ICESTORM;
	  return;
	}
      else if (weather_info.sky == SKY_THUNDERSTORM)
	{
	  send_to_char
	    ("You recite the ancient spell and the clouds clap in thunderous approval\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the  clouds clap in thunder.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_LIGHTNING;
	  return;
	}
      else if (weather_info.sky == SKY_SNOWING)
	{
	  send_to_char
	    ("You recite the ancient spell and the snow increases in obedience\n\r",
	     ch);
	  act
	    ("$n makes a strange movement with their hands and the snow turns to a blizzard.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_BLIZZARD;
	  return;
	}
      else if (weather_info.sky == SKY_BLIZZARD)
	{
	  send_to_char ("It's already as bad as it can get\n\r", ch);
	  return;
	}
      else if (weather_info.sky == SKY_ICESTORM)
	{
	  send_to_char ("It's already as bad as it can get\n\r", ch);
	  return;
	}
      else if (weather_info.sky == SKY_HAILSTORM)
	{
	  send_to_char ("It's already as bad as it can get\n\r", ch);
	  return;
	}
      else if (weather_info.sky == SKY_FOGGY)
	{
	  send_to_char
	    ("You recite the ancient spell and the  horizon clears\n\r", ch);
	  act
	    ("$n makes a strange movement with their hands and the horizon clears.",
	     ch, NULL, NULL, TO_ROOM);
	  weather_info.sky = SKY_CLOUDY;
	  return;

	}
      else
	{
	  send_to_char ("Bad Weather Call. Please notify the imms.\n\r", ch);
	}

    }
  else
    send_to_char ("Do you want it to get better or worse?\n\r", ch);

  send_to_char ("Ok.\n\r", ch);
  return;
}


void
do_wset (CHAR_DATA * ch, char *argument)
{
  char arg1[MIL];
  argument = one_argument (argument, arg1);
  if (arg1[0] == '\0')
    {
      send_to_char ("Syntax:\n\r", ch);
      send_to_char ("  set weather <condition> \n\r", ch);
      send_to_char ("  Condition can be :\n\r", ch);
      send_to_char ("   hail, fog, icestorm, blizzard, snowing,  rain\n\r",
		    ch);
      send_to_char ("   lightning, thunderstorm, cloudless, cloudy  \n\r",
		    ch);
      return;
    }
  if (!str_cmp (arg1, "cloudless"))
    {
      send_to_char
	("You wave your hands and in reverence to you, the clouds dissapear \n\r",
	 ch);
      weather_info.sky = SKY_CLOUDLESS;
      act
	("$n makes a strange movement with their hands and the clouds part.",
	 ch, NULL, NULL, TO_ROOM);
    }
  else if (!str_cmp (arg1, "fog"))
    {
      send_to_char
	("You wave your hands and in reverence to you, a mist vapors the horizon \n\r",
	 ch);
      weather_info.sky = SKY_FOGGY;
      act
	("$n makes a strange movement with their hands and a mist vapors the horizon.",
	 ch, NULL, NULL, TO_ROOM);
    }
  else if (!str_cmp (arg1, "hail"))
    {
      send_to_char
	("You wave your hands and in reverence to you, hailstones fall from the sky \n\r",
	 ch);
      weather_info.sky = SKY_HAILSTORM;
      act
	("$n makes a strange movement with their hands and hailstones fall from the sky.",
	 ch, NULL, NULL, TO_ROOM);
    }
  else if (!str_cmp (arg1, "icestorm"))
    {
      send_to_char
	("You wave your hands and in reverence to you, it starts raining ice \n\r",
	 ch);
      weather_info.sky = SKY_ICESTORM;
      act
	("$n makes a strange movement with their hands and it starts raining ice.",
	 ch, NULL, NULL, TO_ROOM);
    }
  else if (!str_cmp (arg1, "blizzard"))
    {
      send_to_char
	("You wave your hands and in reverence to you, snowflakes cover the horizon making it impossible to see.\n\r",
	 ch);
      weather_info.sky = SKY_BLIZZARD;
      act
	("$n makes a strange movement with their hands and snowflakes cover the horizon making it impossibile to see",
	 ch, NULL, NULL, TO_ROOM);
    }
  else if (!str_cmp (arg1, "snowing"))
    {
      send_to_char
	("You wave your hands and in reverence to you, snowflakes  fall from the sky..\n\r",
	 ch);
      weather_info.sky = SKY_SNOWING;
      act
	("$n makes a strange movement with their hands and snowflakes fall from the sky",
	 ch, NULL, NULL, TO_ROOM);
    }
  else if (!str_cmp (arg1, "rain"))
    {
      send_to_char
	("You wave your hands and in reverence to you, a warm rain starts to fall.\n\r",
	 ch);
      weather_info.sky = SKY_RAINING;
      act
	("$n makes a strange movement with their hands and a warm rain starts to fall",
	 ch, NULL, NULL, TO_ROOM);
    }
  else if (!str_cmp (arg1, "lightning"))
    {
      send_to_char
	("You wave your hands and in reverence to you, lightning pierces the sky. \n\r",
	 ch);
      weather_info.sky = SKY_LIGHTNING;
      act
	("$n makes a strange movement with their hands and lightning pierces  the sky",
	 ch, NULL, NULL, TO_ROOM);
    }
  else if (!str_cmp (arg1, "thunderstorm"))
    {
      send_to_char
	("You wave your hands and in reverence to you, The clouds clap in thunder.\n\r",
	 ch);
      weather_info.sky = SKY_THUNDERSTORM;
      act
	("$n makes a strange movement with their hands and the clouds clap in thunder",
	 ch, NULL, NULL, TO_ROOM);
    }
  else if (!str_cmp (arg1, "cloudy"))
    {
      send_to_char
	("You wave your hands and in reverence to you, clouds cover the horizon, threatening rain.\n\r",
	 ch);
      weather_info.sky = SKY_CLOUDY;
      act
	("$n makes a strange movement with their hands and clouds cover the horizon, threatening rain",
	 ch, NULL, NULL, TO_ROOM);
    }
/* okay, we haven't met any conditions so far. Did they forget? */
  else
    {
      send_to_char ("Syntax:\n\r", ch);
      send_to_char ("  set weather <condition> \n\r", ch);
      send_to_char ("  Condition can be :\n\r", ch);
      send_to_char ("   hail, fog, icestorm, blizzard, snowing,  rain\n\r",
		    ch);
      send_to_char ("   lightning, thunderstorm, cloudless, cloudy  \n\r",
		    ch);
      return;
    }

}