legend/
legend/area/
legend/player/
/***************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,        *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.   *
 *                                                                         *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael          *
 *  Chastain, Michael Quan, and Mitchell Tse.                              *
 *                                                                         *
 *  In order to use any part of this Merc Diku Mud, you must comply with   *
 *  both the original Diku license in 'license.doc' as well the Merc       *
 *  license in 'license.txt'.  In particular, you may not remove either of *
 *  these copyright notices.                                               *
 *                                                                         *
 *  Much time and thought has gone into this software and you are          *
 *  benefitting.  We hope that you share your changes too.  What goes      *
 *  around, comes around.                                                  *
 ***************************************************************************/
/***************************************************************************
 *  God Wars Mud 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"

/* Tier Code (C) Tijer 2001 */

void gainstats (CHAR_DATA * ch)
{
   int times;
   int tgain = number_range (5, 8);
   stc ("Your gain is:", ch);
   for (times = 0; times <= 3; times++)
   {
      int stat = number_range (1, 6);
      switch (stat)
      {
      case 1:
	 {

	    int amount = number_range (1, 5);
	    stcprintf (ch, " %d hit points ", (amount * 100));
	    ch->max_hit += (amount * 100);
            ch->xhit += (amount * 100);
	    break;
	 }
      case 2:
	 {

	    int amount = number_range (1, 5);
	    stcprintf (ch, " %d mana points ", (amount * 100));
	    ch->max_mana += (amount * 100);
            ch->xmana += (amount * 100);
	    break;
	 }
      case 3:
	 {
	    int amount = number_range (1, 5);
	    stcprintf (ch, " %d move points ", (amount * 100));
	    ch->max_move += (amount * 100);
            ch->xmove += (amount * 100);
	    break;
	 }
      case 4:
	 {

	    stcprintf (ch, " 5 hitroll ");
	    ch->xhitroll += 5;
	    break;
	 }
      case 5:
	 {
	    stcprintf (ch, " 5 damroll ");
	    ch->xdamroll += 5;
	    break;
	 }
      case 6:
	 {
	    stcprintf (ch, " -25 ac ", ch->xac);
	    ch->xac += 25;
	    break;
	 }
      }
   }
   ch->tpoints += tgain;
   stcprintf (ch, "and %d tier points.\n\r", tgain);

}


// Tier Powers!

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

   if IS_NPC
      (ch) return;

   if (ch->fight_timer > 0)
   {
      stc ("Not with a fight timer!\n\r", ch);
      return;
   }
   if (ch->hit == ch->max_hit && ch->mana == ch->max_mana && ch->move == ch->max_move )
   {
      stc ("You are completely fully healed!\n\r", ch);
      return;
   }
   if (ch->tier < 5)
   {
      stc ("You need to be atleast tier 5 to be able to heal yourself.\n\r",
	   ch);
      return;
   }
   if (ch->tpoints < 10)
   {
      stc ("You dont have enough tier points!\n\r", ch);
      return;
   }

   ch->hit = ch->max_hit;
   ch->mana = ch->max_mana;
   ch->move = ch->max_move;
   ch->loc_hp[0] = 0;
   ch->loc_hp[1] = 0;
   ch->loc_hp[2] = 0;
   ch->loc_hp[3] = 0;
   ch->loc_hp[4] = 0;
   ch->loc_hp[5] = 0;
   ch->loc_hp[6] = 0;
   update_pos (ch);
   stc ("You heal yourself!\n\r", ch);
   act ("$n glows as $e is healed.", ch, NULL, NULL, TO_ROOM);
   ch->tpoints -= 10;
   return;
}

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

   CHAR_DATA *victim;
   char arg[MSL];
   ROOM_INDEX_DATA *location;

   one_argument (argument, arg);

   if IS_NPC
      (ch) return;

   if (ch->tpoints < 20)
   {
      stc ("You dont have enough tier points!\n\r", ch);
      return;
   }

   if ((victim = get_char_world (ch, arg)) == NULL)
   {
      stc ("Portal to who?\n\r", ch);
      return;
   }

   if (IS_NPC (victim))
   {
      stc ("You failed!\n\r", ch);
      return;
   }

   if (IS_SET (victim->in_room->room_flags, ROOM_GOD)
       || IS_SET (victim->in_room->room_flags, ROOM_CCHAMBER)
       || ch->in_room->vnum == victim->in_room->vnum
       || IS_SET (victim->extra2, NHELPER)
       || IS_SET (victim->in_room->area->aflags, AFLAG_HQ)
       || IS_SET (victim->in_room->room_flags, ROOM_NO_TELEPORT))
   {
      stc ("You failed!\n\r", ch);
      return;
   }
   if ((ch->tier - victim->tier) >= 5)
   {
      stc ("You failed\n\r", ch);
      return;
   }


   location = victim->in_room;
   act ("You step into a portal.", ch, NULL, NULL, TO_CHAR);
   act ("$n steps into thin air.", ch, NULL, NULL, TO_ROOM);
   char_from_room (ch);
   char_to_room (ch, location);
   do_look (ch, "auto");
   act ("You step out of the portal.", ch, NULL, NULL, TO_CHAR);
   act ("$n steps out of thin air.", ch, NULL, NULL, TO_ROOM);
   WAIT_STATE (ch, 6);
   ch->tpoints -= 20;
   return;
}