/**********************************************************************************************
*                                 Credits: The bounty command, Found on Kyndig.com            *
*                                          modified by Ceial. The rest is original            *
*                                          code by Ceial made for KBK. Use it as              *
*                                          but leave this header above do bounty.             *
*                                          Ceial (pinch_my_niblets@yahoo.ca)                  *
**********************************************************************************************/



// Not this code has run flawless on a Tartarus based mud. No certain how it'll
// react to stock rom or whatever you run. Use at your own descretion, and don't
// email me telling me how my code sucks. I don't care, it works. :P



// save.c stuff. I stuck it above titles in fwrite_char

fprintf( fp, "Bounty %d\n",	ch->pcdata->bounty  ); // bounty data
fprintf( fp, "Bkills %d\n",	ch->pcdata->bkills );  // points for bounty

// save.c in load_char_obj
ch->pcdata->bounty			= 0;
ch->pcdata->bkills			= 0;

// in load_char, stuck it right after bamfin

KEY( "Bounty",  ch->pcdata->bounty,	fread_number( fp )
KEY( "Bkills", ch->pcdata->bkills, fread_number( fp ) );



// Add this anywheres. Doesn't really matter. Just be sure to add it to interp.c & .h

void do_bounty( CHAR_DATA *ch, char *argument )
{
    char arg1 [MAX_INPUT_LENGTH];
    char arg2 [MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *victim;

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


if ( arg1[0] == '\0' || arg2[0] == '\0' )
    {
	 send_to_char( "Place a bounty on who's head?\n\rSyntax: Bounty <victim> <amount>\n\r", ch );
        if (IS_IMMORTAL(ch)) // lets imms know they can remove bounties
        {
		send_to_char("Bounty <victim> remove to remove bounties.\n\r",ch);
	}
        if (ch->cabal == CABAL_ANCIENT) // lets the clan members know they can check the value
        {
		send_to_char("Bounty <victim> show to see their worth.\n\r",ch);
	}
        return;
    }

    if ( ( victim = get_char_world( ch, arg1 ) ) == NULL)
	{
  	   send_to_char( "They aren't in the lands.", ch );
	   return;
    }

    if (IS_NPC(victim))
    {
		send_to_char( "You cannot bounty that.\n\r", ch );
		return;
    }

	// This is for the clan ancient. Since i made it so only they can see bounties
	// and reap the rewards.

	if ((ch->cabal == CABAL_ANCIENT) && (!strcmp(arg2,"show"))) // shows the worth
	{
		sprintf( buf, "Their bounty is worth %d gold.\n\r", victim->pcdata->bounty);
		send_to_char(buf,ch);
		return;
	}

	if (IS_IMMORTAL(ch) && (!strcmp(arg2,"remove"))) // removes it
	{
		victim->pcdata->bounty = 0;
		send_to_char("Bounty removed.\n\r",ch);
		send_to_char("Your bounty has been removed.\n\r",victim);
		return;
	}

	// Didn't want people adding bounties on top of other bounties.
	if (victim->pcdata->bounty != 0)
	{
		send_to_char( "They already have a bounty on their head.\n\r", ch);
		return;
	}


	// So they can't bounty the person in the clan.
	if (victim->cabal == CABAL_ANCIENT)
	{
		send_to_char("You can't bounty an Ancient!\n\r",ch);
		return;
	}

	if ( is_number( arg2 ) )
    {
		int amount;
		amount   = atoi(arg2);
      if (ch->gold < amount)
      {
		send_to_char( "You don't have that much gold!\n\r", ch );
		return;
      }
	  // Don't be a cheap ass
	  if (amount < 1000)
	  {
		  send_to_char("Bleh! Don't insult Ancient like that. Use more gold!.\n\r",ch);
		  return;
	  }
	  		ch->gold -= amount;
			victim->pcdata->bounty +=amount;
			send_to_char("A bounty has been placed on your head.\n\r",victim);
			sprintf( buf, "You have placed a bounty on %s.\n\r",victim->name);
			send_to_char(buf,ch);
			return;
	}
}

//Bounty payoff for Ancient. in fight.c, stick it in raw_kill
//And be sure you have defined a normal trash item vnum for the scalp
if (!IS_NPC(victim)
&& (ch->cabal == CABAL_ANCIENT)
&& victim->pcdata->bounty > 0)
{
	trophy = create_object(get_obj_index(OBJ_VNUM_ANCIENT_SCALP),0);
	sprintf( buf, trophy->short_descr, victim->name);
	free_string( trophy->short_descr );
	trophy->short_descr = str_dup( buf);
	sprintf( buf, trophy->description, victim->name);
	free_string( trophy->description );
	trophy->description = str_dup(buf);
	obj_to_char(trophy,ch);
	act("You violently carve off their scalp.",ch,0,0,TO_CHAR);
	act("$n violently carves off their scalp.",ch,0,0,TO_ROOM);
	sprintf(buf,"You recive a %d gold bounty, for killing %s.\n\r",
	victim->pcdata->bounty, victim->name);
	send_to_char(buf, ch);
	ch->gold += victim->pcdata->bounty;
	victim->pcdata->bounty =0;
}



// act_obj.c So you can reward the clan person with a point.
// make a mob in the clan area for the pointmaster, and define it in merc
if ((obj->pIndexData->vnum == OBJ_VNUM_ANCIENT_SCALP)
	&& ((victim->pIndexData->vnum == MOB_VNUM_POINTMASTER)))
	{
	if (IS_NPC(victim))
	{
		if (victim->pIndexData->vnum != MOB_VNUM_POINTMASTER)
		{
			send_to_char("You can only give scalps to the pointsmaster.",ch);
			return;
		}

		if (ch->cabal != CABAL_ANCIENT)
		{
			send_to_char("You aren't an assassin!\n\r",ch);
			return;
		}

		send_to_char("Your kill has been recorded.\n\r",ch);
		ch->pcdata->bkills ++;
		obj_from_char( obj );
		return;
	}
	else
	{
		send_to_char("You can only give scalps to the pointsmaster.",ch);
		return;
	}
}