/*******************************************************************************
 *         _               | File Name:   autoconsume and autoall.txt
 *        / \      _-'     | Description: This allows you the MUD master to 
 *      _/|  \-''- _ /     |              set consume commands for undead races.
 * __-' |          \       |              It also allows the player to set 
 *     /              \    |              themselves to autoconsume the dead.
 *     /       "o.  |o |   |              Autoall turns on all default options
 *     |            \ ;    |              
 *                   ',    |
 *        \_         __\   | (c) 2000-2001 TAKA 
 *          ''-_    \.//   | (c) 2000-2001 The GhostMud Project Team
 *            / '-____'    | 
 *           /             | You may use this code under GNU license restriction 
 *         _'  The Wolf    | 1) This header block remains in the code.          
 *       _-'   strikes!    | 2) You email me at a_ghost_dancer@excite.com
 *_________________________|    letting me know you are using this code
 *                              please incluse your name, your mud name
 * All rights reserved          your mud address, your email and this file
 * GhostMud is copyrighted      name.                                         
 * by TAKA                   3) In your help files mention me where appropriate 
 *                              IE: help snippets.
 *********************************************************************************/

/***************************************************************************
 * (c) 2000 TAKA and the GhostMud PROJECT TEAM
 *                                                                         
 *  Last thank you to all the ROM amd MERC folks for this wounderful code  
 *  base know as ROM.                                                      
 *                                                                      
 *          The Ghost Dancer MUD Project Team and me TAKA thank you
 *          for your interest.
 *
 *          You can email me at:   
 *          TAKA                                                      
 *          a_ghost_dancer@excite.com                                      
 *                                                                         
 ***************************************************************************

/*
 * auto consume code for vampire/lich/were classed
 * also auto all function by Taka
 * by TAKA of GhostMud Project Team
 * in act_info.c do_autolist add.
 */
	send_to_char("autoconsume    ",ch); 
	if (IS_SET(ch->act,PLR_AUTOCONSUME)) 
	    send_to_char("ON\n\r",ch); 
	else 
	    send_to_char("OFF\n\r",ch);   

/*
 * auto consume code for vampire/lich/were classed
 * by TAKA of GhostMud Project Team
 * in act_info.c add.
 */

void do_autoconsume(CHAR_DATA *ch, char *argument)
{
    if (IS_NPC(ch))
      return;
    
	if (!IS_SET(ch->form, FORM_UNDEAD))
	{
		send_to_char("{RYou are not undead!\n\r",ch);
		return;
	}

    if (IS_SET(ch->act,PLR_AUTOCONSUME))
    {
      send_to_char("Autoconsume removed.\n\r",ch);
      REMOVE_BIT(ch->act,PLR_AUTOCONSUME);
    }
    else
    {
      send_to_char("You will now consume the blood of corpses!\n\r",ch);
      SET_BIT(ch->act,PLR_AUTOCONSUME);
    }
}


/* turn on all auto flags! TAKA     */
void do_autoall(CHAR_DATA *ch, char *argument)
{
	if (IS_NPC(ch))
		return;
	
	SET_BIT(ch->act,PLR_AUTOASSIST);
	SET_BIT(ch->act,PLR_AUTOEXIT);
	SET_BIT(ch->act,PLR_AUTOGOLD);
	SET_BIT(ch->act,PLR_AUTOLOOT);
	SET_BIT(ch->act,PLR_AUTOSAC);
	SET_BIT(ch->act,PLR_AUTOSPLIT);
	if (IS_SET(ch->form, FORM_UNDEAD))
	{
	      SET_BIT(ch->act,PLR_AUTOCONSUME);
	}
	SET_BIT(ch->act,PLR_AUTODAMAGE);

	send_to_char("{RAll autos turned on.{x\n\r",ch);
}

/*
 * in interp.h add
 */
DECLARE_DO_FUN(	do_consume		);
DECLARE_DO_FUN(	do_autoconsume	);
DECLARE_DO_FUN( do_autoall	);

/*
 * in interp.c add
 */
	{ "autoall",    do_autoall,     POS_DEAD,		 0,  LOG_NORMAL, 1 },
	{ "autoconsume", do_autoconsume, POS_DEAD,		 0,  LOG_NORMAL, 1 },

	{ "consume",	do_consume,		POS_DEAD,		 0,  LOG_NORMAL, 1 },
/*
 * in fight.c add at the top
 */
DECLARE_DO_FUN(do_consume	);
/*
 * in fight.c in function damage find this
 */
		if ((coins = get_obj_list(ch,"gcash",corpse->contains))
		     != NULL)
	      	    do_get(ch, "all.gcash corpse");
/* add this */
		if ( IS_SET(ch->act, PLR_AUTOCONSUME) )
       		{
	   	    if ( IS_SET(ch->act,PLR_AUTOLOOT) && corpse && corpse->contains)
				return TRUE;  /* leave if corpse has treasure */
			else
				do_consume( ch, "corpse" );		
		}
/* 
 * in merc.h add in the PLR_ section this
 */
#define PLR_AUTOCONSUME		(B) /* UNDEAD PC RACES ONLY */

/*
 * in act_obj.c add
 */
void do_consume( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_INPUT_LENGTH];

    OBJ_DATA *obj;

    one_argument( argument, arg );

    if ( arg[0] == '\0' || !str_cmp( arg, ch->name ) )
    {
		act( "$n bites $mself hard and draws blood.", ch, NULL, NULL, TO_ROOM );
		send_to_char("You are a sick puppy, consuming yourself!\n\r", ch );
		return;
    }

    obj = get_obj_list( ch, arg, ch->in_room->contents );
    if ( obj == NULL )
    {
		send_to_char( "You can't find it.\n\r", ch );
		return;
    }

    if ( obj->item_type == ITEM_CORPSE_PC )
    {
		if (obj->contains)
        {
			send_to_char("Mota wouldn't like that.\n\r",ch);
			return;
        }
    }

	if ((obj->level * 2) <= 10)
	{
		ch->hit += 10;
		ch->mana += 20;
		ch->move += 10;
		sprintf(buf, "You gain 10 hit points 20 mana 10 movement by consuming the corpse!");
	}
	else
	{
		ch->hit += (obj->level * 2);
		ch->mana += (obj->level * 4);
		ch->move += (obj->level * 2);
		sprintf(buf, "You gain %d hit points %d mana %d movement by consuming the corpse!",
			(obj->level * 2), (obj->level * 4), (obj->level * 2));
	}

    act( "$n consumes the blood of the corpse.", ch, obj, NULL, TO_ROOM );
    wiznet("$N consumed the corpse $p.", ch,obj,WIZ_SACCING,0,0);

	send_to_char( buf, ch );
	extract_obj( obj );

    return;
}