/*----------------------------------------------------------------------------------*\
*																					*			
*  This snippet was written by Kaine De'Arque of Vampire Wars: Embrace the Darkness *
*  (VWETD).  If you use this snippet all I ask is that you email me saying that you *
*  used, benefited, didnt like, etc. from it ( shane@computers-mn.com ).  Also      *
*  on your changes (helpfile or whatever it may be) just make recogonition to me.	*
*																					*
*  This snippet should work with any VW mud, if it doesnt let me know.			    *
*  The original idea for diablerize came from Caine's mud Vampire Wars: The Final   *
*  Sunset, I did not see the code being published anywhere but I did see everyone   *
*  Using it so I decided to write one up.  Thanks Caine!							*
*																					*
*  The concept is very simple, diablerize is a way for vampires to gain generation  *
*  by stealing it from another Vampire.  What my particular code does is starts     *
*  everyone off at generation 13, the highest generation a vampire can go is        *
*  generation 3.  When a vampire attacks another vampire and gets them to mortally  *
*  wounded position you are allowed to diablerize them IF the victim is a vampire   *
*  is avatar or higher, and is not in your clan.  When a diablerize happens it      *
*  takes one generation away from the victim and gives one to the character.		*
*  The code is setup (by altering your code to this snippet) to make new vampires   *
*  generation 13, and old vampires the same generation they were when they got      *
*  staked.																			*
\*----------------------------------------------------------------------------------*/


/* In merc.h below DECLARE_DO_FUN ( do_deposit ); add the following line */

DECLARE_DO_FUN(   do_diablerize  );




/*** fight.c (or whatever suits you best, this file can be pretty much placed anywhere) ***/

void do_diablerize( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *victim;
    char arg [MAX_INPUT_LENGTH];
    char buf [MAX_INPUT_LENGTH];
    int agg=0;
    int def=0;

    one_argument( argument, arg, MAX_INPUT_LENGTH );

    if ( IS_NPC(ch) ) return;

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

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

    if ( ch == victim )
    {
	   send_to_char( "You cant Diablerize yourself!\n\r", ch );
	   return;
    }

    if ( IS_NPC(victim) )
    {
	   send_to_char( "You can only diablerize other vampires.\n\r", ch );
    }

    if( ch->level != 3 )
    {
	   send_to_char( "You must be an avatar to diablerize someone.\n\r", ch );
	   return;
    }

    if ( victim->level != 3 )
    {
           send_to_char( "You can only diablerize other avatars.\n\r", ch );
           return;
    }

    if ( !IS_SET(victim->act, PLR_VAMPIRE))
    {
	   send_to_char( "Only on Vampires.\n\r", ch );
	   return;
    }

    if ( !IS_SET(ch->act, PLR_VAMPIRE))
    {
	   send_to_char( "You are not a vampire.\n\r", ch );
	   return;
    } 

    if ( victim->position > 1 )
    {
	   send_to_char( "You can only do this to mortally wounded players.\n\r", ch );
           return;
    }

    if (!str_cmp(ch->clan,victim->clan) && ch->clan != '\0' &&
	   ch->clan != str_dup("") )
    {
	   send_to_char( "You cannot Diablerize someone of your own clan.\n\r", ch );
	   return;
    }

/* Compare the generations of the victim and the character, if the characters generation
 * is lower then the victims, dont allow the diablerize.
 */
    if (ch->vampgen == 3 ) agg = 0;
    else if( ch->vampgen == 4) agg = 1;
    else if( ch->vampgen == 5) agg = 2;
    else if( ch->vampgen == 6) agg = 3;
    else if( ch->vampgen == 7) agg = 4;
    else if( ch->vampgen == 8) agg = 5;
    else if( ch->vampgen == 9) agg = 6;
    else if( ch->vampgen == 10) agg = 7;
    else if( ch->vampgen == 11) agg = 8;
    else if( ch->vampgen == 12) agg = 9;
    else if( ch->vampgen == 13) agg = 10;

    if (victim->vampgen == 3) def = 0;
    else if(victim->vampgen == 4 ) def = 1;
    else if(victim->vampgen == 5 ) def = 2;
    else if(victim->vampgen == 6 ) def = 3;
    else if(victim->vampgen == 7 ) def = 4;
    else if(victim->vampgen == 8 ) def = 5;
    else if(victim->vampgen == 9 ) def = 6;
    else if(victim->vampgen == 10 ) def = 7;
    else if(victim->vampgen == 11 ) def = 8;
    else if(victim->vampgen == 12 ) def = 9;
    else if(victim->vampgen == 13 ) def = 10;

    if (def>agg)
    {
	    send_to_char("You can only diablerize someone of the same generation as you or lower!\n\r", ch );
	    return;
    }

    act( "You lay your hand down upon the chest of $N!", ch, NULL, victim, TO_CHAR    );
    send_to_char( "You feel your soul drain from your body!\n\r", victim);
    act( "$n starts to drain the soul of $N!", ch, NULL, victim, TO_NOTVICT );

/* I figure if you lose your soul youll probably be weaker, so thats why this is here */

    if(victim->pcdata->perm_str > 5) victim->pcdata->perm_str = victim->pcdata->perm_str - 1;
    if(victim->pcdata->perm_wis > 5)victim->pcdata->perm_wis = victim->pcdata->perm_wis - 1;
    if(victim->pcdata->perm_dex > 5) victim->pcdata->perm_dex = victim->pcdata->perm_dex - 1;
    if(victim->pcdata->perm_int > 5) victim->pcdata->perm_int = victim->pcdata->perm_int - 1;
    if(victim->pcdata->perm_con > 5) victim->pcdata->perm_con = victim->pcdata->perm_con - 1;
    if(victim->pcdata->perm_con > 20) victim->pcdata->perm_con = victim->pcdata->perm_con - 1;
    if(victim->pcdata->perm_str > 20) victim->pcdata->perm_con = victim->pcdata->perm_str - 5;
    if(victim->pcdata->perm_dex > 20) victim->pcdata->perm_con = victim->pcdata->perm_dex - 5;
    ch->exp = ch->exp + victim->exp / 2;
    snprintf( buf, MAX_INPUT_LENGTH, "You receive %ld experience points.\n\r", victim->exp / 2);
    send_to_char( buf, ch);
	/* Give the victim 1k exp to train avatar */
    victim->exp = 1000;
    victim->level = victim->level - 1;

    if (victim->vampgen == 13) victim->vampgen = victim->vampgen + 0;
    else if (victim->vampgen < 13) victim->vampgen = victim->vampgen + 1;
    
    if (ch->vampgen == 3) ch->vampgen = ch->vampgen - 0;
    else if (ch->vampgen > 3) ch->vampgen = ch->vampgen - 1;

    act( "The soul of $N drains from there body into yours.",  ch, NULL, victim, TO_CHAR   );
    act( "$N's soul drains from there body and into $n's.",  ch, NULL, victim, TO_NOTVICT );
    act( "You feel all powerful as the soul sets in your bloodstream.",  ch, NULL, NULL, TO_CHAR   );
    act( "You experience a jolt of fear as $n becomes more powerful.",  ch, NULL, NULL, TO_NOTVICT );
    if (IS_SET(victim->act, PLR_VAMPIRE))
           do_mortalvamp(victim,"");
    snprintf(buf, MAX_INPUT_LENGTH, "%s has been diablerized by %s.",victim->name,ch->name);
    do_info(ch,buf);
    return;
}


/* In the do_stake function look for the follwing line and remove it */

	victim->vampgen = 0;

/* In do_bite look for this line: */

    victim->vampgen = ch->vampgen + 1;

/* and change it to this: */

	if ( victim->vampgen == 0 ) victim->vampgen = 13;
    else victim->vampgen = victim->vampgen;


/* In interp.c look for do_decapitate, and right below it add this: */

    { "diablerize",  do_diablerize,     POS_STANDING,3,  LOG_ALWAYS     },

/* Finally save all the files, make, and do a reboot / copyover, should work dandy, but
   if you already have players that ARE vampires youll have to set there generation back.
   If you have trouble installing this code I will be more then happy to go over it with
   you ( shane@computers-mn.com ).  Also any comments, questions, flames, fixes, or addons
   Id love to hear.

   Thanks.  -Kaine De'Arque
*/