/
SilentMists/class/
SilentMists/gods/
SilentMists/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.						   *
 ***************************************************************************/
 
/***************************************************************************
*	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 "interp.h"
#include "magic.h"
#include "recycle.h"

/* SKILL LIST FOR THIS FILE 
 * 
 * Channeling - Butcher -
 *
 *
 */


void do_channel(CHAR_DATA *ch, char *argument)
{
	 char arg1 [MAX_INPUT_LENGTH];
	 char arg2 [MAX_INPUT_LENGTH];
	 CHAR_DATA *victim;
	 int roll, roll2;

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

	 if (get_skill(ch,gsn_channel) < 1)
	 {
	send_to_char("You have not the power in your soul.\n\r",ch);
	return;
	 }

	 if ( arg1[0] == '\0' )
	 {
		send_to_char("Channel how much?\n\r", ch);
		return ;
	 }

	 if (is_number(arg1) )
	 {
	  int amount;

	  amount = atoi(arg1);

	  if (amount<1)
	  {
	    send_to_char("Yeah right!\n\r",ch);
	    return ;
	  }

	  if(amount>ch->hit)
	  {
		send_to_char("You can not channel more power then you have.\n\r",ch);
		return ;	
	  }
	
	  if(arg2[0] == '\0' ) 
	  {
			ch->hit-=amount;
			update_pos(ch);

			roll=number_percent();
			if(roll<get_skill(ch,gsn_channel))
			{
				ch->mana+=amount;
				send_to_char("You feel physically exhausted.\n\r",ch);
				if(amount>99) check_improve(ch,gsn_channel,TRUE,14);
				return ;
			}
			else
			{
				send_to_char("You feel no gain from your rigorous attempts at power.\n\r",ch);
				if(amount>99) check_improve(ch,gsn_channel,FALSE,14);
				return ;
			}
	  }
	  else
	  {
		roll=number_percent();
		roll2=number_percent();
		if( ( victim = get_char_world(ch, arg2)) == NULL )
		{
		send_to_char("You send your power to nobody.\n\r",ch);
		return ;
		}

		if(amount>ch->mana)
		{
		 send_to_char("You have not enough mana.\n\r", ch);
		 return ;
		}

		if(roll<get_skill(ch,gsn_channel))
		{
		  if(get_skill(victim,gsn_channel)<1)
		  {
			send_to_char("Your target had not the skill to recieve your power.\n\r",ch);
			ch->mana-=amount;
			return ;
		  }
		  if(roll2<get_skill(victim,gsn_channel))
		  {
			ch->mana-=amount;
			victim->mana+= amount*roll2/90;
			send_to_char("You send your power to him.\n\r",ch);
			send_to_char("You recieve magical power from an outer source.\n\r",victim);
			if(amount>99) check_improve(ch,gsn_channel,TRUE,14);
			if(amount>99) check_improve(victim,gsn_channel,TRUE,14);
			return ;
		  }
		  else
		  {
			ch->mana-=amount;
			send_to_char("Your power is recieved by the inept who can not harnass it.\n\r",ch);
			if(amount>99) check_improve(ch,gsn_channel,FALSE,14);
			return ;
		  }
		}
		else
		{
			send_to_char("You failed to send any power.\n\r",ch);
			if(amount>99) check_improve(ch,gsn_channel,TRUE,14);
			return ;
		}
	  }
	 }
	 else
	 {
		send_to_char("You must specify how much to channel in hit points or mana.\n\r",ch);
		return ;
	 }
	 return ;
}

	 /* Butcher skill, created by Argawal                   */
	 /* Original Idea taken fom Carrion Fields Mud          */
	 /* If you have an interest in this skill, feel free    */
	 /* to use it in your mud if you so desire.             */
	 /* All I ask is that Argawal is credited with creating */
	 /* this skill, as I wrote it from scratch.             */

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

    /* If you have an interest in this skill, feel free */
    /* to use it in your mud if you so desire. */

    char buf[MAX_STRING_LENGTH];
    char arg[MAX_STRING_LENGTH];
    int numst = 0;
    OBJ_DATA *steak;
    OBJ_DATA *obj;

    one_argument(argument, arg);

    if(get_skill(ch,gsn_butcher)==0)
    {
       send_to_char("Butchering is beyond your skills.\n\r",ch);
       return;
    }

    if(arg[0]=='\0')
    {
       send_to_char("Butcher what?\n\r",ch);
       return;
    }

    obj = get_obj_list( ch, arg, ch->in_room->contents );

    if ( obj == NULL )
    {
        send_to_char( "It's not here.\n\r", ch );
        return;
    }

    if( (obj->item_type != ITEM_CORPSE_NPC)
        && (obj->item_type!=ITEM_CORPSE_PC) )
    {
        send_to_char( "You can only butcher corpses.\n\r", ch );
        return;
    }

    /* create and rename the steak */
    buf[0]='\0';
    strcat(buf,"A steak of ");
    strcat(buf,str_dup(obj->short_descr));
    strcat(buf," is here.");

    steak = create_object( get_obj_index(OBJ_VNUM_STEAK), 0 );

    steak->description=str_dup(buf);
    steak->value[0] = ch->level / 2;
    steak->value[1] = ch->level;

    buf[0]='\0';
    strcat(buf,"A steak of ");
    strcat(buf,str_dup(obj->short_descr));

    steak->short_descr=str_dup(buf);

    /* Check the skill roll, and put a random ammount of steaks here. */
    if(number_percent( ) < get_skill(ch,gsn_butcher))
    {
       numst = dice(1,4);
       switch(numst)
       {
       case 1:
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         act( "$n butchers a corpse and creates a steak.", ch, steak, NULL, TO_ROOM );
         act( "You butcher a corpse and create a steak.", ch, steak, NULL, TO_CHAR );
         break;
       case 2:
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         act( "$n butchers a corpse and creates two steaks.", ch, steak, NULL, TO_ROOM );
         act( "You butcher a corpse and create two steaks.", ch, steak, NULL, TO_CHAR );
         break;
       case 3:
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         act( "$n butchers a corpse and creates three steaks.", ch, steak, NULL, TO_ROOM );
         act( "You butcher a corpse and create three steaks.", ch, steak, NULL, TO_CHAR );
         break;
       case 4:
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         steak = create_object( get_obj_index( OBJ_VNUM_STEAK ), 0 );
         obj_to_room( steak, ch->in_room );
         act( "$n butchers a corpse and creates four steaks.", ch, steak, NULL, TO_ROOM );
         act( "You butcher a corpse and create four steaks.", ch, steak, NULL, TO_CHAR );
         break;
      }
      check_improve(ch,gsn_butcher,TRUE,1);

    }
    else
    {
       act( "$n fails to butcher a corpse, and destroys it.", ch, steak, NULL, TO_ROOM );
       act( "You fail to butcher a corpse, and destroy it.", ch, steak, NULL, TO_CHAR );
       check_improve(ch,gsn_butcher,FALSE,1);
    }
    /* dump items caried */
    /* Taken from the original ROM code and added into here. */

    if ( obj->item_type == ITEM_CORPSE_PC )
    {   /* save the contents */
       {
            OBJ_DATA *t_obj, *next_obj;
            for (t_obj = obj->contains; t_obj != NULL; t_obj = next_obj)
            {
                next_obj = t_obj->next_content;
                obj_from_obj(t_obj);
                if (obj->in_obj) /* in another object */
                    obj_to_obj(t_obj,obj->in_obj);
                else if (obj->carried_by) /* carried */
                    if (obj->wear_loc == WEAR_FLOAT)
                        if (obj->carried_by->in_room == NULL)
                            extract_obj(t_obj);
                        else
                            obj_to_room(t_obj,obj->carried_by->in_room);
                    else
                        obj_to_char(t_obj,obj->carried_by);
               else if (obj->in_room == NULL) /* destroy it */
                    extract_obj(t_obj);
                else /* to a room */
                    obj_to_room(t_obj,obj->in_room);
           }
      }
  }
  if ( obj->item_type == ITEM_CORPSE_NPC )
    {
       {
            OBJ_DATA *t_obj, *next_obj;
            for (t_obj = obj->contains; t_obj != NULL; t_obj = next_obj)
            {
                next_obj = t_obj->next_content;
                obj_from_obj(t_obj);
                if (obj->in_obj) /* in another object */
                    obj_to_obj(t_obj,obj->in_obj);
                else if (obj->carried_by) /* carried */
                    if (obj->wear_loc == WEAR_FLOAT)
                        if (obj->carried_by->in_room == NULL)
                            extract_obj(t_obj);
                        else
                            obj_to_room(t_obj,obj->carried_by->in_room);
                    else
                        obj_to_char(t_obj,obj->carried_by);
                else if (obj->in_room == NULL) /* destroy it */
                    extract_obj(t_obj);
                else /* to a room */
                    obj_to_room(t_obj,obj->in_room);
         }
     }
  }

    /* Now remove the corpse */
    extract_obj(obj);
    return;
}