/***************************************************************************
 *  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.						   *
 ***************************************************************************/

/***************************************************************************
*	ROM 2.4 is copyright 1993-1998 Russ Taylor			   *
*	ROM has been brought to you by the ROM consortium		   *
*	    Russ Taylor (rtaylor@hypercube.org)				   *
*	    Gabrielle Taylor (gtaylor@hypercube.org)			   *
*	    Brian Moore (zump@rom.org)					   *
*	By using this code, you have agreed to follow the terms of the	   *
*	ROM license, in the file Rom24/doc/rom.license			   *
***************************************************************************/

#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 "magic.h"

/*
 * Yet another Intelectual copyright by
 * Pyrox (c) 2000 Pyrox Ribber for her pleasure
 *
 * (c) 2000 Taka of the Ghost Dancer MUD Project
 * code by TAKA
 *
 * allow healer to heal cancel
 */

void
do_heal (CHAR_DATA * ch, char *argument)
{
  CHAR_DATA *mob;
  char arg[MAX_INPUT_LENGTH];
  int cost, sn;
  SPELL_FUN *spell;
  char *words;

  /* check for healer */
  for (mob = ch->in_room->people; mob; mob = mob->next_in_room)
    {
      if (IS_NPC (mob) && IS_SET (mob->act, ACT_IS_HEALER))
	break;
    }

  if (mob == NULL)
    {
      send_to_char ("You can't do that here.\n\r", ch);
      return;
    }

  one_argument (argument, arg);

  if (arg[0] == '\0')
    {
      /* display price list */
      act ("{W$N {Gsays 'I offer the following spells:'{x", ch, NULL, mob,
	   TO_CHAR);
      send_to_char ("  {Mlight:   cure light wounds     {y 10 gold{x\n\r",
		    ch);
      send_to_char ("  {Mserious: cure serious wounds   {y 15 gold{x\n\r",
		    ch);
      send_to_char ("  {Mcritic:  cure critical wounds  {y 25 gold{x\n\r",
		    ch);
      send_to_char ("  {Mheal:    healing spell	     {y 50 gold{x\n\r", ch);
      send_to_char ("  {Mblind:   cure blindness        {y 20 gold{x\n\r",
		    ch);
      send_to_char ("  {Mdisease: cure disease          {y 15 gold{x\n\r",
		    ch);
      send_to_char ("  {Mpoison:  cure poison	         {y 25 gold{x\n\r",
		    ch);
      send_to_char ("  {Muncurse: remove curse	         {y 50 gold{x\n\r",
		    ch);
      send_to_char ("  {Mrefresh: restore movement      {y  5 gold{x\n\r",
		    ch);
      send_to_char ("  {Mmana:    restore mana	         {y 10 gold{x\n\r",
		    ch);
      send_to_char
	("  {Mcancel:  cacnels spells	     {y100 gold{x\n\r", ch);
      send_to_char (" {GType heal <type> to be healed.{x\n\r", ch);
      return;
    }

  if (!str_prefix (arg, "light"))
    {
      spell = spell_cure_light;
      sn = skill_lookup ("cure light");
      words = "judicandus dies";
      cost = 1000;
    }

  else if (!str_prefix (arg, "serious"))
    {
      spell = spell_cure_serious;
      sn = skill_lookup ("cure serious");
      words = "judicandus gzfuajg";
      cost = 1600;
    }

  else if (!str_prefix (arg, "critical"))
    {
      spell = spell_cure_critical;
      sn = skill_lookup ("cure critical");
      words = "judicandus qfuhuqar";
      cost = 2500;
    }

  else if (!str_prefix (arg, "heal"))
    {
      spell = spell_heal;
      sn = skill_lookup ("heal");
      words = "pzar";
      cost = 5000;
    }

  else if (!str_prefix (arg, "blindness"))
    {
      spell = spell_cure_blindness;
      sn = skill_lookup ("cure blindness");
      words = "judicandus noselacri";
      cost = 2000;
    }

  else if (!str_prefix (arg, "disease"))
    {
      spell = spell_cure_disease;
      sn = skill_lookup ("cure disease");
      words = "judicandus eugzagz";
      cost = 1500;
    }

  else if (!str_prefix (arg, "poison"))
    {
      spell = spell_cure_poison;
      sn = skill_lookup ("cure poison");
      words = "judicandus sausabru";
      cost = 2500;
    }

  else if (!str_prefix (arg, "uncurse") || !str_prefix (arg, "curse"))
    {
      spell = spell_remove_curse;
      sn = skill_lookup ("remove curse");
      words = "candussido judifgz";
      cost = 5000;
    }

  else if (!str_prefix (arg, "mana") || !str_prefix (arg, "energize"))
    {
      spell = NULL;
      sn = -1;
      words = "energizer";
      cost = 1000;
    }


  else if (!str_prefix (arg, "refresh") || !str_prefix (arg, "moves"))
    {
      spell = spell_refresh;
      sn = skill_lookup ("refresh");
      words = "candusima";
      cost = 500;
    }
  else if (!str_prefix (arg, "cancel"))
    {
      spell = spell_cancellation;
      sn = skill_lookup ("cancellation");
      words = "cancel";
      cost = 10000;
    }


  else
    {
      act ("$N says 'Type 'heal' for a list of spells.'",
	   ch, NULL, mob, TO_CHAR);
      return;
    }

  if (cost > (ch->gold * 100 + ch->silver))
    {
      act ("$N says 'You do not have enough gold for my services.'",
	   ch, NULL, mob, TO_CHAR);
      return;
    }

  WAIT_STATE (ch, PULSE_VIOLENCE);

  deduct_cost (ch, cost);
  mob->gold += cost / 100;
  mob->silver += cost % 100;
  act ("$n utters the words '$T'.", mob, NULL, words, TO_ROOM);

  if (spell == NULL)		/* restore mana trap...kinda hackish */
    {
      ch->mana += dice (2, 8) + mob->level / 3;
      ch->mana = UMIN (ch->mana, ch->max_mana);
      send_to_char ("A warm glow passes through you.\n\r", ch);
      return;
    }

  if (sn == -1)
    return;

  spell (sn, mob->level, mob, ch, TARGET_CHAR);
}

void
do_cyber (CHAR_DATA * ch, char *argument)
{
  CHAR_DATA *mob;
  char arg[MAX_INPUT_LENGTH];
  char buf[MAX_STRING_LENGTH];
  int cost;

  /* check for surgeon */
  for (mob = ch->in_room->people; mob; mob = mob->next_in_room)
    {
      if (IS_NPC (mob) && IS_SET (mob->act, ACT_IS_SURGEON))
	break;
    }

  /* if there are no surgeon, display the characters enhancements */
  if (mob == NULL)
    {
      sprintf (buf, "Cyber Parts:\n\r %s\n\r", cyber_bit_name (ch->cyber));
      send_to_char (buf, ch);
      return;
    }

  one_argument (argument, arg);

  /* if there are a surgeon, give a list */
  if (arg[0] == '\0')
    {
      /* display price list */
      act ("$N says 'I have these parts in stock:'", ch, NULL, mob, TO_CHAR);
      send_to_char ("  comm    : Internal Comm Unit       5000 creds\n\r",
		    ch);
      send_to_char ("  eyes    : Mirror Linses            2000 creds\n\r",
		    ch);
      send_to_char ("  legs    : Cyber Replacements      12000 creds\n\r",
		    ch);
      send_to_char ("  chest   : External Chest Plating  20000 creds\n\r",
		    ch);
      send_to_char ("  reflex  : Argumented Reflexes     18000 creds\n\r",
		    ch);
      send_to_char ("  mind    : Internal Computer       25000 creds\n\r",
		    ch);
      send_to_char ("  muscle  : Argumented Muscles      35000 creds\n\r",
		    ch);
      send_to_char
	(" Type cyber <type> to buy one, or help cyber to get more info.\n\r",
	 ch);
      return;
    }

  /* Lets see what the character wants to have */
  if (!str_prefix (arg, "comm"))
    {
      cost = 5000;
      if (cost > (ch->silver))
	{
	  act ("$N says 'You do not have enough creds for my services.'",
	       ch, NULL, mob, TO_CHAR);
	  return;
	}
      if (IS_SET (ch->cyber, CYBER_COMM))
	{
	  send_to_char ("You already got that part.\n\r", ch);
	  return;
	}
      SET_BIT (ch->cyber, CYBER_COMM);
      /* add benefit here */
    }

  else if (!str_prefix (arg, "eyes"))
    {
      cost = 2000;
      if (cost > (ch->silver))
	{
	  act ("$N says 'You do not have enough creds for my services.'",
	       ch, NULL, mob, TO_CHAR);
	  return;
	}
      if (IS_SET (ch->cyber, CYBER_EYES))
	{
	  send_to_char ("You already got that part.\n\r", ch);
	  return;
	}
      SET_BIT (ch->cyber, CYBER_EYES);
      /* add benefit here */
    }

  else if (!str_prefix (arg, "legs"))
    {
      cost = 12000;
      if (cost > (ch->silver))
	{
	  act ("$N says 'You do not have enough creds for my services.'",
	       ch, NULL, mob, TO_CHAR);
	  return;
	}
      if (IS_SET (ch->cyber, CYBER_LEGS))
	{
	  send_to_char ("You already got that part.\n\r", ch);
	  return;
	}
      SET_BIT (ch->cyber, CYBER_LEGS);
      /* add benefit here */
    }

  else if (!str_prefix (arg, "chest"))
    {
      cost = 20000;
      if (cost > (ch->silver))
	{
	  act ("$N says 'You do not have enough creds for my services.'",
	       ch, NULL, mob, TO_CHAR);
	  return;
	}
      if (IS_SET (ch->cyber, CYBER_CHEST))
	{
	  send_to_char ("You already got that part.\n\r", ch);
	  return;
	}
      SET_BIT (ch->cyber, CYBER_CHEST);
      /* add benefit here */
    }

  else if (!str_prefix (arg, "reflex"))
    {
      cost = 18000;
      if (cost > (ch->silver))
	{
	  act ("$N says 'You do not have enough creds for my services.'",
	       ch, NULL, mob, TO_CHAR);
	  return;
	}
      if (IS_SET (ch->cyber, CYBER_REFLEXES))
	{
	  send_to_char ("You already got that part.\n\r", ch);
	  return;
	}
      SET_BIT (ch->cyber, CYBER_REFLEXES);
      /* add benefit here */
    }

  else if (!str_prefix (arg, "mind"))
    {
      cost = 25000;
      if (cost > (ch->silver))
	{
	  act ("$N says 'You do not have enough creds for my services.'",
	       ch, NULL, mob, TO_CHAR);
	  return;
	}
      if (IS_SET (ch->cyber, CYBER_MIND))
	{
	  send_to_char ("You already got that part.\n\r", ch);
	  return;
	}
      SET_BIT (ch->cyber, CYBER_MIND);
      /* add benefit here */
    }

  else if (!str_prefix (arg, "muscle"))
    {
      cost = 35000;
      if (cost > (ch->silver))
	{
	  act ("$N says 'You do not have enough creds for my services.'",
	       ch, NULL, mob, TO_CHAR);
	  return;
	}
      if (IS_SET (ch->cyber, CYBER_STRENGTH))
	{
	  send_to_char ("You already got that part.\n\r", ch);
	  return;
	}
      SET_BIT (ch->cyber, CYBER_STRENGTH);
      /* add benefit here */
    }

  else
    {
      act ("$N says 'Type 'cyber' for a list of cybernetics.'",
	   ch, NULL, mob, TO_CHAR);
      return;
    }

  WAIT_STATE (ch, PULSE_VIOLENCE);

  deduct_cost (ch, cost);
  act ("$n says 'There we go, better than the original'.", mob, NULL, NULL,
       TO_ROOM);
}