legend/
legend/area/
legend/player/
/***************************************************************************
 *  God Wars Mud copyright (C) 1994, 1995, 1996 by Richard Woolcock        *
 *  									   *
 *  Legend of Chrystancia copyright (C) 1999, 2000, 2001 by Matthew Little *
 *  This mud is NOT to be copied in whole or in part, or to be run without *
 *  the permission of Matthew Little. Nobody else has permission to        *
 *  authorise the use of this code.                                        *
 ***************************************************************************/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif

#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include <unistd.h>
#include <stdarg.h>
#include <limits.h>

#include "merc.h"

/****************************************************************************
 *  Gargoyles (C) Macademus July 2000 All Rights Reserved.                  *
 *  Coded for Legend of Chrystancia: godwars.net 6500.                      *
 ****************************************************************************/

/* Gargoyle Learn Power Command */


void do_endowment (CHAR_DATA * ch, char *argument)
{

   char arg[MIL];
   char arg2[MIL];
   char buf[MSL];

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

   if (IS_NPC (ch))
      return;

   if (!IS_CLASS (ch, CLASS_GARGOYLE))
   {
      do_rand_typo (ch);
      return;
   }


   if (arg[0] == '\0' && arg2[0] == '\0')
   {
      sprintf (buf,
	       "           Sol     ( %d )         Fidelis  ( %d )           Fortitude   ( %d )\n\r",
	       ch->pcdata->powers[GAR_SOL], ch->pcdata->powers[GAR_FIDEL],
	       ch->pcdata->powers[GAR_FOR]);

      stc (buf, ch);
      sprintf (buf, "       Potence     ( %d )     Visceratika  ( %d )\n\r",
	       ch->pcdata->powers[GAR_POT], ch->pcdata->powers[GAR_VIS]);
      stc (buf, ch);

   }
   if (!str_cmp (arg2, "learn") || !str_cmp (arg2, "improve"))
   {
      int improve;
      int cost;
      int max = 6;


      if (!str_cmp (arg, "sol"))
	 improve = GAR_SOL;
      else if (!str_cmp (arg, "fidelis"))
	 improve = GAR_FIDEL;
      else if (!str_cmp (arg, "fortitude"))
	 improve = GAR_FOR;
      else if (!str_cmp (arg, "visceratika"))
	 improve = GAR_VIS;
      else if (!str_cmp (arg, "potene"))
	 improve = GAR_POT;
      else
      {
	 do_endowment (ch, "");
	 return;
      }
      cost = (ch->pcdata->powers[improve] + 1) * 10;
      arg[0] = UPPER (arg[0]);

      if (ch->pcdata->powers[improve] >= max)
      {
	 sprintf (buf,
		  "You have already gained all of the %s Endowments.\n\r",
		  arg);
	 send_to_char (buf, ch);
	 return;
      }

      if (cost > ch->practice)
      {
	 sprintf (buf,
		  "It costs you %d primal to learn a new %s Endowment.\n\r",
		  cost, arg);
	 send_to_char (buf, ch);
	 return;
      }

      ch->pcdata->powers[improve] += 1;
      ch->practice -= cost;
      sprintf (buf, "You have learned a new %s Endowment.\n\r", arg);
      send_to_char (buf, ch);
      return;
   }

}

/* Sol Endowment 

 *        The Light of God
 **       Veil of Shadows
 ***      Color of the Chameleon
 ****     Flesh of Molten Rock
 *****    Shade of Mirrors
 ******   Sun walk
 *******  Body of the Sun
 ******** Defiance of Apollo 

*/


void do_lightofgod (CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   char arg[MAX_INPUT_LENGTH];

   argument = one_argument (argument, arg);

   if (IS_NPC (ch))
      return;

   if (!IS_CLASS (ch, CLASS_GARGOYLE))
   {
      do_rand_typo (ch);
      return;
   }

   if (ch->in_room == NULL)
   {
      do_rand_typo (ch);
      return;
   }
   if (ch->pcdata->powers[GAR_SOL] < 1)
   {
      stc ("You need to learn level 1 Sol to use this power\n\r", ch);
      return;
   }

   if (arg[0] == '\0')
   {
      send_to_char ("Who do you want to blind?\n\r", ch);
      return;
   }

   if ((victim = get_char_room (ch, arg)) == NULL)
   {
      send_to_char ("They are not here.\n\r", ch);
      return;
   }

   if (victim->position != POS_FIGHTING && victim->hit < victim->max_hit)
   {
      send_to_char ("Nothing happens.\n\r", ch);
      return;
   }

   if (is_safe (ch, victim))
      return;

   act ("$n eyes shine brightly.", ch, NULL, NULL, TO_ROOM);
   stop_fighting (victim, TRUE);
   update_pos (victim);
   if (victim->position > POS_STUNNED)
      victim->position = POS_STUNNED;
   if (IS_NPC (victim))
      do_kill (victim, ch->name);
   WAIT_STATE (ch, 24);
   return;
}

void do_vielshadow (CHAR_DATA * ch, char *argument)
{


   if (IS_NPC (ch))
      return;

   if (!IS_CLASS (ch, CLASS_GARGOYLE))
   {
      do_rand_typo (ch);
      return;
   }

   if (ch->pcdata->powers[GAR_SOL] < 2)
   {
      stc ("You need to learn level 2 of Sol to use this power\n\r", ch);
      return;
   }

   if (ch->in_room == NULL)
   {
      send_to_char ("Nothing happens.\n\r", ch);
      return;
   }

   if (IS_SET (ch->more, MORE_DARKNESS))
   {
      REMOVE_BIT (ch->more, MORE_DARKNESS);
      REMOVE_BIT (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS);
      send_to_char ("You banish the shadows from the room\n\r", ch);
      act ("A look of concentration crosses $n's face.", ch, NULL, NULL,
	   TO_ROOM);
      act ("$n banishes the darkness from the room!", ch, NULL, NULL,
	   TO_ROOM);
//        ch->pcdata->darkness = 60;
      return;
   }

   if (IS_SET (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS))
   {
      send_to_char ("The room is already in darkness.\n\r", ch);
      return;
   }
/*     
    if (ch->pcdata->darkness > 0)
    {
        if (ch->pcdata->darkness > 1)
            sprintf(buf,"You cannot call upon the Shroud of Night for another %d seconds.\n\r",ch->pcdata->darkness);
        else
            sprintf(buf,"You cannot call upon the Shroud of Night for another 1 second.\n\r");
        send_to_char(buf,ch);
        return;
    }
*/
   SET_BIT (ch->in_room->room_flags, ROOM_TOTAL_DARKNESS);
   SET_BIT (ch->more, MORE_DARKNESS);
   //  ch->pcdata->darkness = 60;
   send_to_char ("You call forth your viel of shadows\n\r", ch);
   act ("A look of concentration crosses $n's face.", ch, NULL, NULL,
	TO_ROOM);
   act ("The room is filled with a viel of shadows", ch, NULL, NULL, TO_ROOM);
   return;
}

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

   if (!IS_CLASS (ch, CLASS_GARGOYLE))
   {
      do_rand_typo (ch);
      return;
   }

   if (ch->pcdata->powers[GAR_SOL] < 3)
   {
      stc ("You need to learn level 3 of sol to use this power\n\r", ch);
      return;
   }

   if (IS_SET (ch->act, PLR_WIZINVIS))
   {
      REMOVE_BIT (ch->act, PLR_WIZINVIS);
      send_to_char ("You slowly fade into existance.\n\r", ch);
      act ("The light bends and $n slowly appears.", ch, NULL, NULL, TO_ROOM);
   }
   else
   {
      send_to_char ("You slowly fade out of existance.\n\r", ch);
      act ("The light bends and $n slowly fades out of existance.", ch, NULL,
	   NULL, TO_ROOM);
      SET_BIT (ch->act, PLR_WIZINVIS);
   }
   return;
}

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

   if (!IS_CLASS (ch, CLASS_GARGOYLE))
   {
      do_rand_typo (ch);
      return;
   }

   if (ch->pcdata->powers[GAR_SOL] < 4)
   {
      stc ("You need to learn level 4 of soul to use this power\n\r", ch);
      return;
   }

   if (IS_SET (ch->more, MORE_FLESH))
   {
      REMOVE_BIT (ch->more, MORE_FLESH);
      stc ("Your flesh reverts to normal.\n\r", ch);
      act ("$n's flesh slowly hardens as it cools down.", ch, NULL, NULL,
	   TO_ROOM);
   }
   else
   {
      send_to_char ("Your flesh turns to molten rock.\n\r", ch);
      act ("$n's flesh starts bubbling as it turns to molton rock.", ch, NULL,
	   NULL, TO_ROOM);
      SET_BIT (ch->more, MORE_FLESH);
   }
   return;
}

void do_shademirror (CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   CHAR_DATA *original;
   OBJ_DATA *obj;
   OBJ_DATA *obj2;
   char arg[MAX_INPUT_LENGTH];

   argument = one_argument (argument, arg);

   if (IS_NPC (ch))
      return;

   if (!IS_CLASS (ch, CLASS_GARGOYLE))
   {
      do_rand_typo (ch);
      return;
   }

   if (IS_SET (ch->flag2, AFF2_CHALLENGED)
       || IS_SET (ch->flag2, AFF2_CHALLENGER))
   {
      send_to_char ("Not while in the arena!\n\r", ch);
      return;
   }

   if (ch->pcdata->powers[GAR_SOL] < 5)
   {
      stc ("You need to learn level 4 of sol to use this power.\n\r", ch);
      return;
   }

   if (ch->pcdata->followers > 4)
   {
      send_to_char ("Nothing happens.\n\r", ch);
      return;
   }

   if (arg[0] == '\0')
   {
      send_to_char ("Who do you wish to Form an Illusion of?\n\r", ch);
      return;
   }

   if ((original = get_char_room (ch, arg)) == NULL)
   {
      send_to_char ("They aren't here.\n\r", ch);
      return;
   }

   if (original->level > 200 || IS_IMMORTAL (original))
   {
      send_to_char ("Nothing happens.\n\r", ch);
      return;
   }

   ch->pcdata->followers++;
   victim = create_mobile (get_mob_index (MOB_VNUM_GUARDIAN));
   char_to_room (victim, get_room_index (ROOM_VNUM_DISCONNECTION));
   free_string (victim->lord);
   victim->lord = str_dup (ch->name);
   free_string (victim->name);
   victim->name = str_dup (original->name);
   free_string (victim->short_descr);
   if (IS_NPC (original))
      victim->short_descr = str_dup (original->short_descr);
   else
      victim->short_descr = str_dup (original->name);
   free_string (victim->long_descr);
   if (IS_NPC (original))
      victim->long_descr = str_dup (original->long_descr);
   else
      victim->long_descr = str_dup ("");

   if (strlen (original->description) > 1)
   {
      free_string (victim->description);
      victim->description = str_dup (original->description);
   }
   SET_BIT (victim->act, ACT_NOPARTS);
   SET_BIT (victim->act, ACT_NOEXP);

   {
      OBJ_DATA *obj_next;
      for (obj = original->carrying; obj != NULL; obj = obj_next)
      {
	 obj_next = obj->next_content;
	 if (obj->wear_loc != WEAR_NONE)
	 {
	    if ((obj2 = create_object (obj->pIndexData, 0)) != NULL)
	    {
	       SET_BIT (obj2->extra_flags, ITEM_VANISH);
	       obj_to_char (obj2, victim);
	       wear_obj (victim, obj2, obj->wear_loc);
	    }
	 }
      }
   }
   if (IS_NPC (original))
      victim->level = original->level;
   else
      victim->level = 50;
   victim->hit = original->hit;
   victim->max_hit = original->max_hit;
   victim->mana = original->mana;
   victim->max_mana = original->max_mana;
   victim->move = original->move;
   victim->max_move = original->max_move;
   victim->hitroll = char_hitroll (original);
   victim->damroll = char_damroll (original);
   victim->armor = char_ac (original);
   char_from_room (victim);
   char_to_room (victim, original->in_room);

   send_to_char ("A mirror image of you shimmers into existance.\n\r",
		 original);
   act ("A mirror image of $n appears in the room.", original, NULL, NULL,
	TO_ROOM);
   return;
}

void do_sunwalk (CHAR_DATA * ch, char *argument)
{
   char arg[MAX_INPUT_LENGTH];
   CHAR_DATA *victim;

   argument = one_argument (argument, arg);

   if (IS_NPC (ch))
      return;


   if (!IS_CLASS (ch, CLASS_GARGOYLE))
   {
      do_rand_typo (ch);
      return;
   }

   if (ch->fight_timer > 0)
   {
      send_to_char ("Not until your fight timer expires.\n\r", ch);
      return;
   }


   if (arg[0] == '\0')
   {
      send_to_char ("Who do you wish to sunwalk to?\n\r", ch);
      return;
   }

   if (ch->pcdata->powers[GAR_SOL] < 6)
   {
      stc ("You need level 5 sol to use this power.\n\r", ch);
      return;
   }

   if ((victim = get_char_world (ch, arg)) == NULL
       || victim == ch
       || victim->in_room == NULL
       || ch->in_room == NULL || (!IS_NPC (victim)) || victim->level > (250))
   {
      send_to_char ("Nothing happens.\n\r", ch);
      return;
   }

   if (victim->in_room == ch->in_room)
   {
      send_to_char ("But you are already there!\n\r", ch);
      return;
   }

   if (IS_SET (victim->in_room->room_flags, ROOM_SAFE)
       || IS_SET (victim->in_room->room_flags, ROOM_PRIVATE)
       || IS_SET (victim->in_room->room_flags, ROOM_SOLITARY)
       || IS_SET (victim->in_room->room_flags, ROOM_NO_RECALL)
       || victim->position != POS_STANDING
       || (!IS_NPC (victim) && !IS_IMMUNE (victim, IMM_SUMMON)))
   {
      send_to_char ("You are unable to focus on their location.\n\r", ch);
      return;
   }

   send_to_char ("You step into the suns rays.\n\r", ch);
   act ("$n steps into the suns rays and vanishes from sight.", ch, NULL,
	NULL, TO_ROOM);
   char_from_room (ch);
   char_to_room (ch, victim->in_room);
   do_look (ch, "");
   send_to_char ("You step out of the suns rays.\n\r", ch);
   act ("$N steps from the rays of the sun.", victim, NULL, ch, TO_CHAR);
   act ("$N steps from the rays of the sun.", victim, NULL, ch, TO_ROOM);
   return;
}

/* Fidelis Endowment

 *        Breath of God
 **       Fear of God
 ***      Speach of Babylon
 ****     Blood of Christ
 *****    Lazuras Touch
 ******   Penance Glare
 *******  Trumpets of Gabriel

*/


void do_gbreath (CHAR_DATA * ch, char *argument)
{
   char arg[MAX_INPUT_LENGTH];
   CHAR_DATA *victim;
   int dam, sn;

   one_argument (argument, arg);

   if (IS_NPC (ch))
      return;

   if ((sn = skill_lookup ("god breath")) < 0)
   {
      send_to_char ("Bah! bug let Macademus know.\n\r", ch);
      return;
   }

   if (!IS_CLASS (ch, CLASS_GARGOYLE))
   {
      do_rand_typo (ch);
      return;
   }


   if (ch->pcdata->powers[GAR_FIDEL] < 1)
   {
      stc ("You need to learn Fidelis 1 before using this power.\n\r", ch);
      return;
   }


   if (arg[0] == '\0' && ch->fighting == NULL)
   {
      send_to_char ("Who do you wish to use Breath of God on?\n\r", ch);
      return;
   }

   if ((victim = ch->fighting) == NULL)
   {
      if ((victim = get_char_room (ch, arg)) == NULL)
      {
	 send_to_char ("They aren't here.\n\r", ch);
	 return;
      }
   }

   if (is_safe (ch, victim))
      return;

   dam = number_range (750, 1250);

   if (!IS_AWAKE (victim))
      dam *= 2;

   damage (ch, victim, dam, gsn_gbreath);

   WAIT_STATE (ch, 6);
   return;
}